Community Forums › Forums › Archived Forums › Design Tips and Tricks › Changing simple social icons
- This topic has 1 reply, 2 voices, and was last updated 10 years, 5 months ago by nutsandbolts.
-
AuthorPosts
-
October 31, 2013 at 12:54 am #70060alliechynnaMember
Hi I'm trying to rearrange the simple social icons I've rearrange them and click save and it comes up with this error.
I have not change any php only rearrange it, can someone tell me what I need to add/change for it to work.Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home4/alliec/public_html/test/wp-content/plugins/simple-social-icons/simple-social-icons.php on line 124
Here is my php
<?php
/*
Plugin Name: Simple Social Icons
Plugin URI: http://wordpress.org/plugins/simple-social-icons/
Description: A simple, CSS and icon font driven social icons widget.
Author: Nathan Rice
Author URI: http://www.nathanrice.net/Version: 1.0.4
License: GNU General Public License v2.0 (or later)
License URI: http://www.opensource.org/licenses/gpl-license.php
*/class Simple_Social_Icons_Widget extends WP_Widget {
/**
* Default widget values.
*
* @var array
*/
protected $defaults;/**
* Default widget values.
*
* @var array
*/
protected $sizes;/**
* Default widget values.
*
* @var array
*/
protected $profiles;/**
* Constructor method.
*
* Set some global values and create widget.
*/
function __construct() {/**
* Default widget option values.
*/
$this->defaults = array(
'title' => '',
'new_window' => 0,
'size' => 36,
'border_radius' => 3,
'icon_color' => '#ffffff',
'icon_color_hover' => '#ffffff',
'background_color' => '#999999',
'background_color_hover' => '#666666',
'alignment' => 'alignleft',
'facebook' => '',
'pinterest' => '',
'instagram' => '',
'twitter' => '',
'youtube' => '',
'email' => '',
'rss' => '',
'vimeo' => '',
'tumblr' => '',
'gplus' => '',
'github' => '',
'dribble' => '',
'stumbleupon' => '',
'linkedin' => '',
'flickr' => '',
);/**
* Social profile choices.
*/
$this->profiles = array(
'facebook' => array(
'label' => __( 'Facebook URI', 'ssiw' ),
'pattern' => '<li class="social-facebook">',
),
'pinterest' => array(
'label' => __( 'Pinterest URI', 'ssiw' ),
'pattern' => '<li class="social-pinterest">',
),
'instagram' => array(
'label' => __( 'Instagram URI', 'ssiw' ),
'pattern' => '<li class="social-instagram">',
),
'twitter' => array(
'label' => __( 'Twitter URI', 'ssiw' ),
'pattern' => '<li class="social-twitter">',
),
'youtube' => array(
'label' => __( 'YouTube URI', 'ssiw' ),
'pattern' => '<li class="social-youtube">',
),
'email' => array(
'label' => __( 'Email URI', 'ssiw' ),
'pattern' => '<li class="social-email">',
),
'rss' => array(
'label' => __( 'RSS URI', 'ssiw' ),
'pattern' => '<li class="social-rss">',
),
'vimeo' => array(
'label' => __( 'Vimeo URI', 'ssiw' ),
'pattern' => '<li class="social-vimeo">',
),
'tumblr' => array(
'label' => __( 'Tumblr URI', 'ssiw' ),
'pattern' => '<li class="social-tumblr">',
),
'gplus' => array(
'label' => __( 'Google+ URI', 'ssiw' ),
'pattern' => '<li class="social-gplus">',
),
'github' => array(
'label' => __( 'GitHub URI', 'ssiw' ),
'pattern' => '<li class="social-github">',
),
dribbble' => array(
'label' => __( 'Dribbble URI', 'ssiw' ),
'pattern' => '<li class="social-dribbble">',
),
'stumbleupon' => array(
'label' => __( 'StumbleUpon URI', 'ssiw' ),
'pattern' => '<li class="social-stumbleupon">',
'linkedin' => array(
'label' => __( 'Linkedin URI', 'ssiw' ),
'pattern' => '<li class="social-linkedin">',flickr' => array(
'label' => __( 'Flickr URI', 'ssiw' ),
'pattern' => '<li class="social-flickr">',
),
);$widget_ops = array(
'classname' => 'simple-social-icons',
'description' => __( 'Displays select social icons.', 'ssiw' ),
);$control_ops = array(
'id_base' => 'simple-social-icons',
);$this->WP_Widget( 'simple-social-icons', __( 'Simple Social Icons', 'ssiw' ), $widget_ops, $control_ops );
/** Enqueue icon font */
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_css' ) );/** Load CSS in <head> */
add_action( 'wp_head', array( $this, 'css' ) );}
/**
* Widget Form.
*
* Outputs the widget form that allows users to control the output of the widget.
*
*/
function form( $instance ) {/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );
?><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>
<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>
<p><label for="<?php echo $this->get_field_id( 'size' ); ?>"><?php _e( 'Icon Size', 'ssiw' ); ?>:</label> <input id="<?php echo $this->get_field_id( 'size' ); ?>" name="<?php echo $this->get_field_name( 'size' ); ?>" type="text" value="<?php echo esc_attr( $instance['size'] ); ?>" size="3" />px</p>
<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>
<p>
<label for="<?php echo $this->get_field_id( 'alignment' ); ?>"><?php _e( 'Alignment', 'ssiw' ); ?>:</label>
<select id="<?php echo $this->get_field_id( 'alignment' ); ?>" name="<?php echo $this->get_field_name( 'alignment' ); ?>">
<option value="alignleft" <?php selected( 'alignright', $instance['alignment'] ) ?>><?php _e( 'Align Left', 'ssiw' ); ?></option>
<option value="aligncenter" <?php selected( 'aligncenter', $instance['alignment'] ) ?>><?php _e( 'Align Center', 'ssiw' ); ?></option>
<option value="alignright" <?php selected( 'alignright', $instance['alignment'] ) ?>><?php _e( 'Align Right', 'ssiw' ); ?></option>
</select>
</p><hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
<p><label for="<?php echo $this->get_field_id( 'background_color' ); ?>"><?php _e( 'Icon Font Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'icon_color' ); ?>" name="<?php echo $this->get_field_name( 'icon_color' ); ?>" type="text" value="<?php echo esc_attr( $instance['icon_color'] ); ?>" size="6" /></p>
<p><label for="<?php echo $this->get_field_id( 'background_color_hover' ); ?>"><?php _e( 'Icon Font Hover Color:', 'ssiw' ); ?></label> <input id="<?php echo $this->get_field_id( 'icon_color_hover' ); ?>" name="<?php echo $this->get_field_name( 'icon_color_hover' ); ?>" type="text" value="<?php echo esc_attr( $instance['icon_color_hover'] ); ?>" size="6" /></p>
<p><label for="<?php echo $this->get_field_id( 'background_color' ); ?>"><?php _e( 'Background 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="6" /></p>
<p><label for="<?php echo $this->get_field_id( 'background_color_hover' ); ?>"><?php _e( 'Background 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="6" /></p>
<hr style="background: #ccc; border: 0; height: 1px; margin: 20px 0;" />
<?php
foreach ( (array) $this->profiles as $profile => $data ) {printf( '<p><label for="%s">%s:</label></p>', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) );
printf( '<p><input type="text" id="%s" name="%s" value="%s" class="widefat" />', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), esc_url( $instance[$profile] ) );
printf( '</p>' );}
}
/**
* Form validation and sanitization.
*
* Runs when you save the widget form. Allows you to validate or sanitize widget options before they are saved.
*
*/
function update( $newinstance, $oldinstance ) {foreach ( $newinstance as $key => $value ) {
/** Border radius and Icon size must not be empty, must be a digit */
if ( ( 'border_radius' == $key || 'size' == $key ) && ( '' == $value || ! ctype_digit( $value ) ) ) {
$newinstance[$key] = 0;
}/** Validate hex code colors */
elseif ( strpos( $key, '_color' ) && 0 == preg_match( '/^#(([a-fA-F0-9]{3}$)|([a-fA-F0-9]{6}$))/', $value ) ) {
$newinstance[$key] = $oldinstance[$key];
}/** Sanitize Profile URIs */
elseif ( array_key_exists( $key, (array) $this->profiles ) ) {
$newinstance[$key] = esc_url( $newinstance[$key] );
}}
return $newinstance;
}
/**
* Widget Output.
*
* Outputs the actual widget on the front-end based on the widget options the user selected.
*
*/
function widget( $args, $instance ) {extract( $args );
/** Merge with defaults */
$instance = wp_parse_args( (array) $instance, $this->defaults );echo $before_widget;
if ( ! empty( $instance['title'] ) )
echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;$output = '';
$new_window = $instance['new_window'] ? 'target="_blank"' : '';
$profiles = (array) $this->profiles;
foreach ( $profiles as $profile => $data ) {
if ( ! empty( $instance[$profile] ) )
$output .= sprintf( $data['pattern'], esc_url( $instance[$profile] ), $new_window );
}if ( $output )
printf( '<ul class="%s">%s', $instance['alignment'], $output );echo $after_widget;
}
function enqueue_css() {
wp_enqueue_style( 'simple-social-icons-font', plugin_dir_url( __FILE__ ) . 'css/style.css', array(), '1.0.4' );
}/**
* Custom CSS.
*
* Outputs custom CSS to control the look of the icons.
*/
function css() {/** Pull widget settings, merge with defaults */
$all_instances = $this->get_settings();
$instance = wp_parse_args( $all_instances[$this->number], $this->defaults );$font_size = round( (int) $instance['size'] / 2 );
$icon_padding = round ( (int) $font_size / 2 );/** The CSS to output */
$css = '
.simple-social-icons ul li a,
.simple-social-icons ul li a:hover {
background-color: ' . $instance['background_color'] . ' !important;
-moz-border-radius: ' . $instance['border_radius'] . 'px
-webkit-border-radius: ' . $instance['border_radius'] . 'px;
border-radius: ' . $instance['border_radius'] . 'px;
color: ' . $instance['icon_color'] . ' !important;
font-size: ' . $font_size . 'px;
padding: ' . $icon_padding . 'px;
}.simple-social-icons ul li a:hover {
background-color: ' . $instance['background_color_hover'] . ' !important;
color: ' . $instance['icon_color_hover'] . ' !important;
}';/** Minify a bit */
$css = str_replace( "\t", '', $css );
$css = str_replace( array( "\n", "\r" ), ' ', $css );/** Echo the CSS */
echo '<style type="text/css" media="screen">' . $css . '</style>';}
}
add_action( 'widgets_init', 'ssiw_load_widget' );
/**
* Widget Registration.
*
* Register Simple Social Icons widget.
*
*/
function ssiw_load_widget() {register_widget( 'Simple_Social_Icons_Widget' );
}
October 31, 2013 at 1:15 am #70061nutsandboltsMemberLooks like you're missing a
),
after this section:‘stumbleupon’ => array( ‘label’ => __( ‘StumbleUpon URI’, ‘ssiw’ ), ‘pattern’ => ‘<li class=”social-stumbleupon”>‘,
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+ -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.