Version Description
- Added new profile options
- Changed default border radius to 3px
Download this release
Release Info
| Developer | nathanrice |
| Plugin | |
| Version | 0.9.2 |
| Comparing to | |
| See all releases | |
Code changes from version 0.9.0 to 0.9.2
- images/sprite_24x24.png +0 -0
- images/sprite_32x32.png +0 -0
- images/sprite_48x48.png +0 -0
- readme.txt +9 -2
- simple-social-icons.php +113 -82
images/sprite_24x24.png
CHANGED
|
Binary file
|
images/sprite_32x32.png
CHANGED
|
Binary file
|
images/sprite_48x48.png
CHANGED
|
Binary file
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: nathanrice, studiopress
|
|
| 3 |
Tags: social media, social networking, social profiles
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 3.3.1
|
| 6 |
-
Stable tag: 0.9.
|
| 7 |
|
| 8 |
This plugin/widget allows you to insert social icons in any widget area.
|
| 9 |
|
|
@@ -27,4 +27,11 @@ No, not at this time.
|
|
| 27 |
== Changelog ==
|
| 28 |
|
| 29 |
= 0.9.0 =
|
| 30 |
-
* Initial Beta Release
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
Tags: social media, social networking, social profiles
|
| 4 |
Requires at least: 3.3
|
| 5 |
Tested up to: 3.3.1
|
| 6 |
+
Stable tag: 0.9.2
|
| 7 |
|
| 8 |
This plugin/widget allows you to insert social icons in any widget area.
|
| 9 |
|
| 27 |
== Changelog ==
|
| 28 |
|
| 29 |
= 0.9.0 =
|
| 30 |
+
* Initial Beta Release
|
| 31 |
+
|
| 32 |
+
= 0.9.1 =
|
| 33 |
+
* Fixed some styling issues
|
| 34 |
+
|
| 35 |
+
= 0.9.2 =
|
| 36 |
+
* Added new profile options
|
| 37 |
+
* Changed default border radius to 3px
|
simple-social-icons.php
CHANGED
|
@@ -6,42 +6,42 @@ Description: A simple, CSS and sprite driven social icons widget.
|
|
| 6 |
Author: Nathan Rice
|
| 7 |
Author URI: http://www.nathanrice.net/
|
| 8 |
|
| 9 |
-
Version: 0.9.
|
| 10 |
|
| 11 |
License: GNU General Public License v2.0 (or later)
|
| 12 |
License URI: http://www.opensource.org/licenses/gpl-license.php
|
| 13 |
*/
|
| 14 |
|
| 15 |
class Simple_Social_Icons_Widget extends WP_Widget {
|
| 16 |
-
|
| 17 |
/**
|
| 18 |
* Default widget values.
|
| 19 |
-
*
|
| 20 |
* @var array
|
| 21 |
*/
|
| 22 |
protected $defaults;
|
| 23 |
-
|
| 24 |
/**
|
| 25 |
* Default widget values.
|
| 26 |
-
*
|
| 27 |
* @var array
|
| 28 |
*/
|
| 29 |
protected $sizes;
|
| 30 |
-
|
| 31 |
/**
|
| 32 |
* Default widget values.
|
| 33 |
-
*
|
| 34 |
* @var array
|
| 35 |
*/
|
| 36 |
protected $profiles;
|
| 37 |
-
|
| 38 |
/**
|
| 39 |
* Constructor method.
|
| 40 |
-
*
|
| 41 |
* Set some global values and create widget.
|
| 42 |
*/
|
| 43 |
function __construct() {
|
| 44 |
-
|
| 45 |
/**
|
| 46 |
* Default widget option values.
|
| 47 |
*/
|
|
@@ -49,85 +49,115 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 49 |
'title' => '',
|
| 50 |
'new_window' => 0,
|
| 51 |
'size' => 32,
|
| 52 |
-
'border_radius' =>
|
| 53 |
'background_color' => '#999999',
|
| 54 |
'background_color_hover' => '#666666',
|
| 55 |
'alignment' => 'alignleft',
|
|
|
|
|
|
|
| 56 |
'facebook' => '',
|
| 57 |
'gplus' => '',
|
| 58 |
'linkedin' => '',
|
| 59 |
'pinterest' => '',
|
| 60 |
'rss' => '',
|
|
|
|
| 61 |
'twitter' => '',
|
| 62 |
);
|
| 63 |
-
|
| 64 |
/**
|
| 65 |
* Icon sizes.
|
| 66 |
*/
|
| 67 |
$this->sizes = array( '24', '32', '48' );
|
| 68 |
-
|
| 69 |
/**
|
| 70 |
* Social profile choices.
|
| 71 |
*/
|
| 72 |
$this->profiles = array(
|
| 73 |
-
'
|
| 74 |
-
'label'
|
| 75 |
-
'pattern' => '<li class="social-
|
| 76 |
'background_positions' => array(
|
| 77 |
'24' => '0 0',
|
| 78 |
'32' => '0 0',
|
| 79 |
'48' => '0 0',
|
| 80 |
)
|
| 81 |
),
|
| 82 |
-
'
|
| 83 |
-
'label'
|
| 84 |
-
'pattern' => '<li class="social-
|
| 85 |
'background_positions' => array(
|
| 86 |
'24' => '-24px 0',
|
| 87 |
'32' => '-32px 0',
|
| 88 |
'48' => '-48px 0',
|
| 89 |
)
|
| 90 |
),
|
| 91 |
-
'
|
| 92 |
-
'label'
|
| 93 |
-
'pattern' => '<li class="social-
|
| 94 |
'background_positions' => array(
|
| 95 |
'24' => '-48px 0',
|
| 96 |
'32' => '-64px 0',
|
| 97 |
'48' => '-96px 0',
|
| 98 |
)
|
| 99 |
),
|
| 100 |
-
'
|
| 101 |
-
'label'
|
| 102 |
-
'pattern' => '<li class="social-
|
| 103 |
'background_positions' => array(
|
| 104 |
'24' => '-72px 0',
|
| 105 |
'32' => '-96px 0',
|
| 106 |
'48' => '-144px 0',
|
| 107 |
)
|
| 108 |
),
|
| 109 |
-
'
|
| 110 |
-
'label'
|
| 111 |
-
'pattern' => '<li class="social-
|
| 112 |
'background_positions' => array(
|
| 113 |
'24' => '-96px 0',
|
| 114 |
'32' => '-128px 0',
|
| 115 |
'48' => '-192px 0',
|
| 116 |
)
|
| 117 |
),
|
| 118 |
-
'
|
| 119 |
-
'label'
|
| 120 |
-
'pattern' => '<li class="social-
|
| 121 |
'background_positions' => array(
|
| 122 |
'24' => '-120px 0',
|
| 123 |
'32' => '-160px 0',
|
| 124 |
'48' => '-240px 0',
|
| 125 |
)
|
| 126 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
);
|
| 128 |
-
|
| 129 |
$widget_ops = array(
|
| 130 |
-
'classname'
|
| 131 |
'description' => __( 'Displays select social icons.', 'ssiw' ),
|
| 132 |
);
|
| 133 |
|
|
@@ -138,12 +168,12 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 138 |
);
|
| 139 |
|
| 140 |
$this->WP_Widget( 'simple-social-icons', __( 'Simple Social Icons', 'ssiw' ), $widget_ops, $control_ops );
|
| 141 |
-
|
| 142 |
/** Load CSS in <head> */
|
| 143 |
add_action( 'wp_head', array( $this, 'css' ) );
|
| 144 |
-
|
| 145 |
}
|
| 146 |
-
|
| 147 |
/**
|
| 148 |
* Widget Form.
|
| 149 |
*
|
|
@@ -151,15 +181,15 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 151 |
*
|
| 152 |
*/
|
| 153 |
function form( $instance ) {
|
| 154 |
-
|
| 155 |
/** Merge with defaults */
|
| 156 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
| 157 |
?>
|
| 158 |
-
|
| 159 |
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
|
| 160 |
-
|
| 161 |
<p><label><input id="<?php echo $this->get_field_id( 'new_window' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'new_window' ); ?>" value="1" <?php checked( 1, $instance['new_window'] ); ?>/> <?php esc_html_e( 'Open links in new window?', 'ssiw' ); ?></label></p>
|
| 162 |
-
|
| 163 |
<p>
|
| 164 |
<label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e( 'Icon Size', 'ssiw' ); ?>:</label>
|
| 165 |
<select id="<?php echo $this->get_field_id( 'size' ); ?>" name="<?php echo $this->get_field_name( 'size' ); ?>">
|
|
@@ -170,13 +200,13 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 170 |
?>
|
| 171 |
</select>
|
| 172 |
</p>
|
| 173 |
-
|
| 174 |
<p><label for="<?php echo $this->get_field_id( 'border_radius' ); ?>"><?php _e( 'Icon Border Radius:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'border_radius' ); ?>" name="<?php echo $this->get_field_name( 'border_radius' ); ?>" type="text" value="<?php echo esc_attr( $instance['border_radius'] ); ?>" size="3" />px</p>
|
| 175 |
-
|
| 176 |
<p><label for="<?php echo $this->get_field_id( 'background_color' ); ?>"><?php _e( 'Icon Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'background_color' ); ?>" name="<?php echo $this->get_field_name( 'background_color' ); ?>" type="text" value="<?php echo esc_attr( $instance['background_color'] ); ?>" size="8" /></p>
|
| 177 |
-
|
| 178 |
<p><label for="<?php echo $this->get_field_id( 'background_color_hover' ); ?>"><?php _e( 'Hover Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'background_color_hover' ); ?>" name="<?php echo $this->get_field_name( 'background_color_hover' ); ?>" type="text" value="<?php echo esc_attr( $instance['background_color_hover'] ); ?>" size="8" /></p>
|
| 179 |
-
|
| 180 |
<p>
|
| 181 |
<label for="<?php echo $this->get_field_id( 'alignment' ); ?>"><?php _e( 'Alignment', 'ssiw' ); ?>:</label>
|
| 182 |
<select id="<?php echo $this->get_field_id( 'alignment' ); ?>" name="<?php echo $this->get_field_name( 'alignment' ); ?>">
|
|
@@ -184,19 +214,19 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 184 |
<option value="alignright" <?php selected( 'alignright', $instance['alignment'] ) ?>><?php _e( 'Align Right', 'ssiw' ); ?></option>
|
| 185 |
</select>
|
| 186 |
</p>
|
| 187 |
-
|
| 188 |
<hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
|
| 189 |
-
|
| 190 |
<?php
|
| 191 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 192 |
-
|
| 193 |
printf( '<p><label for="%s">%s:</label>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) );
|
| 194 |
printf( '<input type="text" id="%s" class="widefat" name="%s" value="%s" /></p>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), esc_url( $instance[$profile] ) );
|
| 195 |
-
|
| 196 |
}
|
| 197 |
-
|
| 198 |
}
|
| 199 |
-
|
| 200 |
/**
|
| 201 |
* Form validation and sanitization.
|
| 202 |
*
|
|
@@ -204,30 +234,30 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 204 |
*
|
| 205 |
*/
|
| 206 |
function update( $newinstance, $oldinstance ) {
|
| 207 |
-
|
| 208 |
foreach ( $newinstance as $key => $value ) {
|
| 209 |
-
|
| 210 |
/** Border radius must not be empty, must be a digit */
|
| 211 |
if ( 'border_radius' == $key && ( '' == $value || ! ctype_digit( $value ) ) ) {
|
| 212 |
$newinstance[$key] = 0;
|
| 213 |
}
|
| 214 |
-
|
| 215 |
/** Validate hex code colors */
|
| 216 |
elseif ( strpos( $key, '_color' ) && 0 == preg_match( '/^#(([a-fA-F0-9]{3}$)|([a-fA-F0-9]{6}$))/', $value ) ) {
|
| 217 |
$newinstance[$key] = $oldinstance[$key];
|
| 218 |
}
|
| 219 |
-
|
| 220 |
/** Sanitize Profile URIs */
|
| 221 |
elseif ( array_key_exists( $key, (array) $this->profiles ) ) {
|
| 222 |
$newinstance[$key] = esc_url( $newinstance[$key] );
|
| 223 |
}
|
| 224 |
-
|
| 225 |
}
|
| 226 |
-
|
| 227 |
return $newinstance;
|
| 228 |
-
|
| 229 |
}
|
| 230 |
-
|
| 231 |
/**
|
| 232 |
* Widget Output.
|
| 233 |
*
|
|
@@ -235,9 +265,9 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 235 |
*
|
| 236 |
*/
|
| 237 |
function widget( $args, $instance ) {
|
| 238 |
-
|
| 239 |
extract( $args );
|
| 240 |
-
|
| 241 |
/** Merge with defaults */
|
| 242 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
| 243 |
|
|
@@ -245,47 +275,50 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 245 |
|
| 246 |
if ( ! empty( $instance['title'] ) )
|
| 247 |
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
|
| 248 |
-
|
| 249 |
$output = '';
|
| 250 |
-
|
| 251 |
$new_window = $instance['new_window'] ? 'target="_blank"' : '';
|
| 252 |
-
|
| 253 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 254 |
if ( ! empty( $instance[$profile] ) )
|
| 255 |
$output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_window );
|
| 256 |
}
|
| 257 |
-
|
| 258 |
if ( $output )
|
| 259 |
printf( '<ul class="%s">%s</ul>', $instance['alignment'], $output );
|
| 260 |
-
|
| 261 |
echo $after_widget;
|
| 262 |
-
|
| 263 |
}
|
| 264 |
-
|
| 265 |
/**
|
| 266 |
* Custom CSS.
|
| 267 |
*
|
| 268 |
* Outputs custom CSS to control the look of the icons.
|
| 269 |
*/
|
| 270 |
function css() {
|
| 271 |
-
|
| 272 |
/** Pull widget settings, merge with defaults */
|
| 273 |
$all_instances = $this->get_settings();
|
| 274 |
$instance = wp_parse_args( $all_instances[$this->number], $this->defaults );
|
| 275 |
-
|
| 276 |
/** The image locations */
|
| 277 |
$imgs = array(
|
| 278 |
'24' => plugin_dir_url( __FILE__ ) . 'images/sprite_24x24.png',
|
| 279 |
'32' => plugin_dir_url( __FILE__ ) . 'images/sprite_32x32.png',
|
| 280 |
'48' => plugin_dir_url( __FILE__ ) . 'images/sprite_48x48.png'
|
| 281 |
);
|
| 282 |
-
|
| 283 |
/** The CSS to output */
|
| 284 |
-
$css = '.simple-social-icons
|
|
|
|
|
|
|
|
|
|
| 285 |
margin: 0; padding: 0;
|
| 286 |
}
|
| 287 |
-
.simple-social-icons ul li {
|
| 288 |
-
background: none; border: none; float: left;
|
| 289 |
}
|
| 290 |
.simple-social-icons ul li a,
|
| 291 |
.simple-social-icons ul li a:hover {
|
|
@@ -295,39 +328,37 @@ class Simple_Social_Icons_Widget extends WP_Widget {
|
|
| 295 |
border-radius: ' . $instance['border_radius'] . 'px;
|
| 296 |
display: block;
|
| 297 |
height: ' . $instance['size'] . 'px;
|
| 298 |
-
margin: 0 5px;
|
| 299 |
overflow: hidden;
|
| 300 |
-
padding: 0;
|
| 301 |
text-indent: -999px;
|
| 302 |
width: ' . $instance['size'] . 'px;
|
| 303 |
}
|
| 304 |
-
|
| 305 |
.simple-social-icons ul li a:hover {
|
| 306 |
background-color: ' . $instance['background_color_hover'] . ';
|
| 307 |
}';
|
| 308 |
-
|
| 309 |
/** Individual Profile button styles */
|
| 310 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 311 |
|
| 312 |
if ( ! $instance[$profile] )
|
| 313 |
continue;
|
| 314 |
-
|
| 315 |
$css .= '.simple-social-icons ul li.social-' . $profile . ' a,
|
| 316 |
.simple-social-icons ul li.social-' . $profile . ' a:hover {
|
| 317 |
background-position: ' . $data['background_positions'][$instance['size']] . ';
|
| 318 |
}';
|
| 319 |
|
| 320 |
}
|
| 321 |
-
|
| 322 |
/** Minify a bit */
|
| 323 |
$css = str_replace( "\t", '', $css );
|
| 324 |
$css = str_replace( array( "\n", "\r" ), ' ', $css );
|
| 325 |
-
|
| 326 |
/** Echo the CSS */
|
| 327 |
echo '<style type="text/css" media="screen">' . $css . '</style>';
|
| 328 |
-
|
| 329 |
}
|
| 330 |
-
|
| 331 |
}
|
| 332 |
|
| 333 |
add_action( 'widgets_init', 'ssiw_load_widget' );
|
| 6 |
Author: Nathan Rice
|
| 7 |
Author URI: http://www.nathanrice.net/
|
| 8 |
|
| 9 |
+
Version: 0.9.2
|
| 10 |
|
| 11 |
License: GNU General Public License v2.0 (or later)
|
| 12 |
License URI: http://www.opensource.org/licenses/gpl-license.php
|
| 13 |
*/
|
| 14 |
|
| 15 |
class Simple_Social_Icons_Widget extends WP_Widget {
|
| 16 |
+
|
| 17 |
/**
|
| 18 |
* Default widget values.
|
| 19 |
+
*
|
| 20 |
* @var array
|
| 21 |
*/
|
| 22 |
protected $defaults;
|
| 23 |
+
|
| 24 |
/**
|
| 25 |
* Default widget values.
|
| 26 |
+
*
|
| 27 |
* @var array
|
| 28 |
*/
|
| 29 |
protected $sizes;
|
| 30 |
+
|
| 31 |
/**
|
| 32 |
* Default widget values.
|
| 33 |
+
*
|
| 34 |
* @var array
|
| 35 |
*/
|
| 36 |
protected $profiles;
|
| 37 |
+
|
| 38 |
/**
|
| 39 |
* Constructor method.
|
| 40 |
+
*
|
| 41 |
* Set some global values and create widget.
|
| 42 |
*/
|
| 43 |
function __construct() {
|
| 44 |
+
|
| 45 |
/**
|
| 46 |
* Default widget option values.
|
| 47 |
*/
|
| 49 |
'title' => '',
|
| 50 |
'new_window' => 0,
|
| 51 |
'size' => 32,
|
| 52 |
+
'border_radius' => 3,
|
| 53 |
'background_color' => '#999999',
|
| 54 |
'background_color_hover' => '#666666',
|
| 55 |
'alignment' => 'alignleft',
|
| 56 |
+
'dribbble' => '',
|
| 57 |
+
'email' => '',
|
| 58 |
'facebook' => '',
|
| 59 |
'gplus' => '',
|
| 60 |
'linkedin' => '',
|
| 61 |
'pinterest' => '',
|
| 62 |
'rss' => '',
|
| 63 |
+
'stumbleupon' => '',
|
| 64 |
'twitter' => '',
|
| 65 |
);
|
| 66 |
+
|
| 67 |
/**
|
| 68 |
* Icon sizes.
|
| 69 |
*/
|
| 70 |
$this->sizes = array( '24', '32', '48' );
|
| 71 |
+
|
| 72 |
/**
|
| 73 |
* Social profile choices.
|
| 74 |
*/
|
| 75 |
$this->profiles = array(
|
| 76 |
+
'dribbble' => array(
|
| 77 |
+
'label' => __( 'Dribbble URI', 'ssiw' ),
|
| 78 |
+
'pattern' => '<li class="social-dribbble"><a href="%s" %s>Dribbble</a></li>',
|
| 79 |
'background_positions' => array(
|
| 80 |
'24' => '0 0',
|
| 81 |
'32' => '0 0',
|
| 82 |
'48' => '0 0',
|
| 83 |
)
|
| 84 |
),
|
| 85 |
+
'email' => array(
|
| 86 |
+
'label' => __( 'Email URI', 'ssiw' ),
|
| 87 |
+
'pattern' => '<li class="social-email"><a href="%s" %s>Email</a></li>',
|
| 88 |
'background_positions' => array(
|
| 89 |
'24' => '-24px 0',
|
| 90 |
'32' => '-32px 0',
|
| 91 |
'48' => '-48px 0',
|
| 92 |
)
|
| 93 |
),
|
| 94 |
+
'facebook' => array(
|
| 95 |
+
'label' => __( 'Facebook URI', 'ssiw' ),
|
| 96 |
+
'pattern' => '<li class="social-facebook"><a href="%s" %s>Facebook</a></li>',
|
| 97 |
'background_positions' => array(
|
| 98 |
'24' => '-48px 0',
|
| 99 |
'32' => '-64px 0',
|
| 100 |
'48' => '-96px 0',
|
| 101 |
)
|
| 102 |
),
|
| 103 |
+
'gplus' => array(
|
| 104 |
+
'label' => __( 'Google+ URI', 'ssiw' ),
|
| 105 |
+
'pattern' => '<li class="social-gplus"><a href="%s" %s>Google+</a></li>',
|
| 106 |
'background_positions' => array(
|
| 107 |
'24' => '-72px 0',
|
| 108 |
'32' => '-96px 0',
|
| 109 |
'48' => '-144px 0',
|
| 110 |
)
|
| 111 |
),
|
| 112 |
+
'linkedin' => array(
|
| 113 |
+
'label' => __( 'Linkedin URI', 'ssiw' ),
|
| 114 |
+
'pattern' => '<li class="social-linkedin"><a href="%s" %s>Linkedin</a></li>',
|
| 115 |
'background_positions' => array(
|
| 116 |
'24' => '-96px 0',
|
| 117 |
'32' => '-128px 0',
|
| 118 |
'48' => '-192px 0',
|
| 119 |
)
|
| 120 |
),
|
| 121 |
+
'pinterest' => array(
|
| 122 |
+
'label' => __( 'Pinterest URI', 'ssiw' ),
|
| 123 |
+
'pattern' => '<li class="social-pinterest"><a href="%s" %s>Pinterest</a></li>',
|
| 124 |
'background_positions' => array(
|
| 125 |
'24' => '-120px 0',
|
| 126 |
'32' => '-160px 0',
|
| 127 |
'48' => '-240px 0',
|
| 128 |
)
|
| 129 |
),
|
| 130 |
+
'rss' => array(
|
| 131 |
+
'label' => __( 'RSS URI', 'ssiw' ),
|
| 132 |
+
'pattern' => '<li class="social-rss"><a href="%s" %s>RSS</a></li>',
|
| 133 |
+
'background_positions' => array(
|
| 134 |
+
'24' => '-144px 0',
|
| 135 |
+
'32' => '-192px 0',
|
| 136 |
+
'48' => '-288px 0',
|
| 137 |
+
)
|
| 138 |
+
),
|
| 139 |
+
'stumbleupon' => array(
|
| 140 |
+
'label' => __( 'StumbleUpon URI', 'ssiw' ),
|
| 141 |
+
'pattern' => '<li class="social-stumbleupon"><a href="%s" %s>StumbleUpon</a></li>',
|
| 142 |
+
'background_positions' => array(
|
| 143 |
+
'24' => '-168px 0',
|
| 144 |
+
'32' => '-224px 0',
|
| 145 |
+
'48' => '-336px 0',
|
| 146 |
+
)
|
| 147 |
+
),
|
| 148 |
+
'twitter' => array(
|
| 149 |
+
'label' => __( 'Twitter URI', 'ssiw' ),
|
| 150 |
+
'pattern' => '<li class="social-twitter"><a href="%s" %s>Twitter</a></li>',
|
| 151 |
+
'background_positions' => array(
|
| 152 |
+
'24' => '-192px 0',
|
| 153 |
+
'32' => '-256px 0',
|
| 154 |
+
'48' => '-384px 0',
|
| 155 |
+
)
|
| 156 |
+
),
|
| 157 |
);
|
| 158 |
+
|
| 159 |
$widget_ops = array(
|
| 160 |
+
'classname' => 'simple-social-icons',
|
| 161 |
'description' => __( 'Displays select social icons.', 'ssiw' ),
|
| 162 |
);
|
| 163 |
|
| 168 |
);
|
| 169 |
|
| 170 |
$this->WP_Widget( 'simple-social-icons', __( 'Simple Social Icons', 'ssiw' ), $widget_ops, $control_ops );
|
| 171 |
+
|
| 172 |
/** Load CSS in <head> */
|
| 173 |
add_action( 'wp_head', array( $this, 'css' ) );
|
| 174 |
+
|
| 175 |
}
|
| 176 |
+
|
| 177 |
/**
|
| 178 |
* Widget Form.
|
| 179 |
*
|
| 181 |
*
|
| 182 |
*/
|
| 183 |
function form( $instance ) {
|
| 184 |
+
|
| 185 |
/** Merge with defaults */
|
| 186 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
| 187 |
?>
|
| 188 |
+
|
| 189 |
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /></p>
|
| 190 |
+
|
| 191 |
<p><label><input id="<?php echo $this->get_field_id( 'new_window' ); ?>" type="checkbox" name="<?php echo $this->get_field_name( 'new_window' ); ?>" value="1" <?php checked( 1, $instance['new_window'] ); ?>/> <?php esc_html_e( 'Open links in new window?', 'ssiw' ); ?></label></p>
|
| 192 |
+
|
| 193 |
<p>
|
| 194 |
<label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e( 'Icon Size', 'ssiw' ); ?>:</label>
|
| 195 |
<select id="<?php echo $this->get_field_id( 'size' ); ?>" name="<?php echo $this->get_field_name( 'size' ); ?>">
|
| 200 |
?>
|
| 201 |
</select>
|
| 202 |
</p>
|
| 203 |
+
|
| 204 |
<p><label for="<?php echo $this->get_field_id( 'border_radius' ); ?>"><?php _e( 'Icon Border Radius:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'border_radius' ); ?>" name="<?php echo $this->get_field_name( 'border_radius' ); ?>" type="text" value="<?php echo esc_attr( $instance['border_radius'] ); ?>" size="3" />px</p>
|
| 205 |
+
|
| 206 |
<p><label for="<?php echo $this->get_field_id( 'background_color' ); ?>"><?php _e( 'Icon Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'background_color' ); ?>" name="<?php echo $this->get_field_name( 'background_color' ); ?>" type="text" value="<?php echo esc_attr( $instance['background_color'] ); ?>" size="8" /></p>
|
| 207 |
+
|
| 208 |
<p><label for="<?php echo $this->get_field_id( 'background_color_hover' ); ?>"><?php _e( 'Hover Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'background_color_hover' ); ?>" name="<?php echo $this->get_field_name( 'background_color_hover' ); ?>" type="text" value="<?php echo esc_attr( $instance['background_color_hover'] ); ?>" size="8" /></p>
|
| 209 |
+
|
| 210 |
<p>
|
| 211 |
<label for="<?php echo $this->get_field_id( 'alignment' ); ?>"><?php _e( 'Alignment', 'ssiw' ); ?>:</label>
|
| 212 |
<select id="<?php echo $this->get_field_id( 'alignment' ); ?>" name="<?php echo $this->get_field_name( 'alignment' ); ?>">
|
| 214 |
<option value="alignright" <?php selected( 'alignright', $instance['alignment'] ) ?>><?php _e( 'Align Right', 'ssiw' ); ?></option>
|
| 215 |
</select>
|
| 216 |
</p>
|
| 217 |
+
|
| 218 |
<hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
|
| 219 |
+
|
| 220 |
<?php
|
| 221 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 222 |
+
|
| 223 |
printf( '<p><label for="%s">%s:</label>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) );
|
| 224 |
printf( '<input type="text" id="%s" class="widefat" name="%s" value="%s" /></p>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), esc_url( $instance[$profile] ) );
|
| 225 |
+
|
| 226 |
}
|
| 227 |
+
|
| 228 |
}
|
| 229 |
+
|
| 230 |
/**
|
| 231 |
* Form validation and sanitization.
|
| 232 |
*
|
| 234 |
*
|
| 235 |
*/
|
| 236 |
function update( $newinstance, $oldinstance ) {
|
| 237 |
+
|
| 238 |
foreach ( $newinstance as $key => $value ) {
|
| 239 |
+
|
| 240 |
/** Border radius must not be empty, must be a digit */
|
| 241 |
if ( 'border_radius' == $key && ( '' == $value || ! ctype_digit( $value ) ) ) {
|
| 242 |
$newinstance[$key] = 0;
|
| 243 |
}
|
| 244 |
+
|
| 245 |
/** Validate hex code colors */
|
| 246 |
elseif ( strpos( $key, '_color' ) && 0 == preg_match( '/^#(([a-fA-F0-9]{3}$)|([a-fA-F0-9]{6}$))/', $value ) ) {
|
| 247 |
$newinstance[$key] = $oldinstance[$key];
|
| 248 |
}
|
| 249 |
+
|
| 250 |
/** Sanitize Profile URIs */
|
| 251 |
elseif ( array_key_exists( $key, (array) $this->profiles ) ) {
|
| 252 |
$newinstance[$key] = esc_url( $newinstance[$key] );
|
| 253 |
}
|
| 254 |
+
|
| 255 |
}
|
| 256 |
+
|
| 257 |
return $newinstance;
|
| 258 |
+
|
| 259 |
}
|
| 260 |
+
|
| 261 |
/**
|
| 262 |
* Widget Output.
|
| 263 |
*
|
| 265 |
*
|
| 266 |
*/
|
| 267 |
function widget( $args, $instance ) {
|
| 268 |
+
|
| 269 |
extract( $args );
|
| 270 |
+
|
| 271 |
/** Merge with defaults */
|
| 272 |
$instance = wp_parse_args( (array) $instance, $this->defaults );
|
| 273 |
|
| 275 |
|
| 276 |
if ( ! empty( $instance['title'] ) )
|
| 277 |
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
|
| 278 |
+
|
| 279 |
$output = '';
|
| 280 |
+
|
| 281 |
$new_window = $instance['new_window'] ? 'target="_blank"' : '';
|
| 282 |
+
|
| 283 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 284 |
if ( ! empty( $instance[$profile] ) )
|
| 285 |
$output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_window );
|
| 286 |
}
|
| 287 |
+
|
| 288 |
if ( $output )
|
| 289 |
printf( '<ul class="%s">%s</ul>', $instance['alignment'], $output );
|
| 290 |
+
|
| 291 |
echo $after_widget;
|
| 292 |
+
|
| 293 |
}
|
| 294 |
+
|
| 295 |
/**
|
| 296 |
* Custom CSS.
|
| 297 |
*
|
| 298 |
* Outputs custom CSS to control the look of the icons.
|
| 299 |
*/
|
| 300 |
function css() {
|
| 301 |
+
|
| 302 |
/** Pull widget settings, merge with defaults */
|
| 303 |
$all_instances = $this->get_settings();
|
| 304 |
$instance = wp_parse_args( $all_instances[$this->number], $this->defaults );
|
| 305 |
+
|
| 306 |
/** The image locations */
|
| 307 |
$imgs = array(
|
| 308 |
'24' => plugin_dir_url( __FILE__ ) . 'images/sprite_24x24.png',
|
| 309 |
'32' => plugin_dir_url( __FILE__ ) . 'images/sprite_32x32.png',
|
| 310 |
'48' => plugin_dir_url( __FILE__ ) . 'images/sprite_48x48.png'
|
| 311 |
);
|
| 312 |
+
|
| 313 |
/** The CSS to output */
|
| 314 |
+
$css = '.simple-social-icons {
|
| 315 |
+
overflow: hidden;
|
| 316 |
+
}
|
| 317 |
+
.simple-social-icons .alignleft, .simple-social-icons .alignright {
|
| 318 |
margin: 0; padding: 0;
|
| 319 |
}
|
| 320 |
+
.simple-social-icons ul li, .sidebar .simple-social-icons ul li, #header .widget-area ul li {
|
| 321 |
+
background: none; border: none; float: left; list-style-type: none; margin: 0 5px; padding: 0;
|
| 322 |
}
|
| 323 |
.simple-social-icons ul li a,
|
| 324 |
.simple-social-icons ul li a:hover {
|
| 328 |
border-radius: ' . $instance['border_radius'] . 'px;
|
| 329 |
display: block;
|
| 330 |
height: ' . $instance['size'] . 'px;
|
|
|
|
| 331 |
overflow: hidden;
|
|
|
|
| 332 |
text-indent: -999px;
|
| 333 |
width: ' . $instance['size'] . 'px;
|
| 334 |
}
|
| 335 |
+
|
| 336 |
.simple-social-icons ul li a:hover {
|
| 337 |
background-color: ' . $instance['background_color_hover'] . ';
|
| 338 |
}';
|
| 339 |
+
|
| 340 |
/** Individual Profile button styles */
|
| 341 |
foreach ( (array) $this->profiles as $profile => $data ) {
|
| 342 |
|
| 343 |
if ( ! $instance[$profile] )
|
| 344 |
continue;
|
| 345 |
+
|
| 346 |
$css .= '.simple-social-icons ul li.social-' . $profile . ' a,
|
| 347 |
.simple-social-icons ul li.social-' . $profile . ' a:hover {
|
| 348 |
background-position: ' . $data['background_positions'][$instance['size']] . ';
|
| 349 |
}';
|
| 350 |
|
| 351 |
}
|
| 352 |
+
|
| 353 |
/** Minify a bit */
|
| 354 |
$css = str_replace( "\t", '', $css );
|
| 355 |
$css = str_replace( array( "\n", "\r" ), ' ', $css );
|
| 356 |
+
|
| 357 |
/** Echo the CSS */
|
| 358 |
echo '<style type="text/css" media="screen">' . $css . '</style>';
|
| 359 |
+
|
| 360 |
}
|
| 361 |
+
|
| 362 |
}
|
| 363 |
|
| 364 |
add_action( 'widgets_init', 'ssiw_load_widget' );
|
