defaults = apply_filters( 'simple_social_default_styles', array( 'title' => '', 'new_window' => 0, 'size' => 36, 'border_radius' => 3, 'border_width' => 0, 'border_color' => '#ffffff', 'border_color_hover' => '#ffffff', 'icon_color' => '#ffffff', 'icon_color_hover' => '#ffffff', 'background_color' => '#999999', 'background_color_hover' => '#666666', 'alignment' => 'alignleft', 'behance' => '', 'bloglovin' => '', 'dribbble' => '', 'email' => '', 'facebook' => '', 'flickr' => '', 'github' => '', 'gplus' => '', 'instagram' => '', 'linkedin' => '', 'medium' => '', 'periscope' => '', 'phone' => '', 'pinterest' => '', 'rss' => '', 'snapchat' => '', 'stumbleupon' => '', 'tumblr' => '', 'twitter' => '', 'vimeo' => '', 'xing' => '', 'youtube' => '', ) ); /** * Filter for social profile choices. * * @since 1.0.6 * * @param array $profiles Social icons to include in widget options. */ $this->profiles = apply_filters( 'simple_social_default_profiles', array( 'behance' => array( 'label' => __( 'Behance URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'behance', __( 'Behance', 'affiliate-booster' ) ), ), 'bloglovin' => array( 'label' => __( 'Bloglovin URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'bloglovin', __( 'Bloglovin', 'affiliate-booster' ) ), ), 'dribbble' => array( 'label' => __( 'Dribbble URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'dribbble', __( 'Dribbble', 'affiliate-booster' ) ), ), 'email' => array( 'label' => __( 'Email URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'email', __( 'Email', 'affiliate-booster' ) ), ), 'facebook' => array( 'label' => __( 'Facebook URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'facebook', __( 'Facebook', 'affiliate-booster' ) ), ), 'flickr' => array( 'label' => __( 'Flickr URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'flickr', __( 'Flickr', 'affiliate-booster' ) ), ), 'github' => array( 'label' => __( 'GitHub URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'github', __( 'GitHub', 'affiliate-booster' ) ), ), 'gplus' => array( 'label' => __( 'Google+ URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'gplus', __( 'Google+', 'affiliate-booster' ) ), ), 'instagram' => array( 'label' => __( 'Instagram URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'instagram', __( 'Instagram', 'affiliate-booster' ) ), ), 'linkedin' => array( 'label' => __( 'Linkedin URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'linkedin', __( 'LinkedIn', 'affiliate-booster' ) ), ), 'medium' => array( 'label' => __( 'Medium URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'medium', __( 'Medium', 'affiliate-booster' ) ), ), 'periscope' => array( 'label' => __( 'Periscope URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'periscope', __( 'Periscope', 'affiliate-booster' ) ), ), 'phone' => array( 'label' => __( 'Phone URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'phone', __( 'Phone', 'affiliate-booster' ) ), ), 'pinterest' => array( 'label' => __( 'Pinterest URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'pinterest', __( 'Pinterest', 'affiliate-booster' ) ), ), 'rss' => array( 'label' => __( 'RSS URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'rss', __( 'RSS', 'affiliate-booster' ) ), ), 'snapchat' => array( 'label' => __( 'Snapchat URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'snapchat', __( 'Snapchat', 'affiliate-booster' ) ), ), 'stumbleupon' => array( 'label' => __( 'StumbleUpon URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'stumbleupon', __( 'StumbleUpon', 'affiliate-booster' ) ), ), 'tumblr' => array( 'label' => __( 'Tumblr URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'tumblr', __( 'Tumblr', 'affiliate-booster' ) ), ), 'twitter' => array( 'label' => __( 'Twitter URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'twitter', __( 'Twitter', 'affiliate-booster' ) ), ), 'vimeo' => array( 'label' => __( 'Vimeo URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'vimeo', __( 'Vimeo', 'affiliate-booster' ) ), ), 'xing' => array( 'label' => __( 'Xing URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'xing', __( 'xing', 'affiliate-booster' ) ), ), 'youtube' => array( 'label' => __( 'YouTube URI', 'affiliate-booster' ), 'pattern' => $this->get_icon_markup( 'youtube', __( 'YouTube', 'affiliate-booster' ) ), ), ) ); /** * Filter to disable output of custom CSS. * * Setting this to true in your child theme will: * - Stop output of inline custom icon CSS. * - Stop styling options showing in Simple Social Icons widget settings. * * The intent if enabling is that your theme will provide CSS for all * widget areas, instead of allowing people to set their own icon * styles. You should consider mentioning in theme documentation that * Simple Social Icons widget settings will not display styling * options, as your theme styles icons instead. * * @since 3.0.0 * * @param bool $disable_css_output True if custom CSS should be disabled. */ $this->disable_css_output = apply_filters( 'simple_social_disable_custom_css', false ); $widget_ops = array( 'classname' => 'simple-social-icons', 'description' => __( 'Displays select social icons.', 'affiliate-booster' ), ); $control_ops = array( 'id_base' => 'affiliatebooster', ); $this->active_instances = array(); parent::__construct( 'simple-social-icons', __( 'Simple Social Icons', 'affiliate-booster' ), $widget_ops, $control_ops ); /** Enqueue scripts and styles */ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_css' ) ); /** Load CSS in */ add_action( 'wp_footer', array( $this, 'css' ) ); /** Load color picker */ add_action( 'admin_enqueue_scripts', array( $this, 'load_color_picker' ) ); add_action( 'admin_footer-widgets.php', array( $this, 'print_scripts' ), 9999 ); } /** * Color Picker. * * Enqueue the color picker script. * */ function load_color_picker( $hook ) { if( 'widgets.php' != $hook ) return; wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'underscore' ); } /** * Print scripts. * * Reference https://core.trac.wordpress.org/attachment/ticket/25809/color-picker-widget.php * */ function print_scripts() { ?> defaults ); ?>

disable_css_output ) { ?>

px

px

px









profiles as $profile => $data ) { printf( '

', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $data['label'] ) ); printf( '

', esc_attr( $this->get_field_id( $profile ) ), esc_attr( $this->get_field_name( $profile ) ), $instance[ $profile ] ); printf( '

' ); } } /** * 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 ) { // Fields that can be transparent if their values are unset. $can_be_transparent = array( 'background_color', 'background_color_hover', 'border_color', 'border_color_hover', ); 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; } if ( ( 'border_width' == $key || 'size' == $key ) && ( '' == $value || ! ctype_digit( $value ) ) ) { $newinstance[ $key ] = 0; } /** Accept empty colors for permitted keys. */ elseif ( in_array( $key, $can_be_transparent, true ) && '' == trim( $value ) ) { $newinstance[ $key ] = ''; } /** 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 ) && ! is_email( $value ) && ! 'phone' === $key ) { $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 = ''; $profiles = (array) $this->profiles; foreach ( $profiles as $profile => $data ) { if ( empty( $instance[ $profile ] ) ) continue; $new_window = $instance['new_window'] ? 'target="_blank" rel="noopener noreferrer"' : ''; if ( is_email( $instance[ $profile ] ) || false !== strpos( $instance[ $profile ], 'mailto:' ) ) $new_window = ''; if ( is_email( $instance[ $profile ] ) ) { $output .= sprintf( $data['pattern'], 'mailto:' . esc_attr( antispambot( $instance[ $profile ] ) ), $new_window ); } elseif ( 'phone' === $profile ) { $output .= sprintf( $data['pattern'], 'tel:' . esc_attr( antispambot( $instance[ $profile ] ) ), $new_window ); } else { $output .= sprintf( $data['pattern'], esc_url( $instance[ $profile ] ), $new_window ); } } if ( $output ) { $output = str_replace( '{WIDGET_INSTANCE_ID}', $this->number, $output ); printf( '', $instance['alignment'], $output ); } echo $after_widget; $this->active_instances[] = $this->number; } function enqueue_css() { /** * Filter the plugin stylesheet location. * * @since 2.0.0 * * @param string $cssfile The full path to the stylesheet. */ $cssfile = apply_filters( 'simple_social_default_stylesheet', plugin_dir_url( __FILE__ ) . 'css/style.css' ); wp_enqueue_style( 'simple-social-icons-font', esc_url( $cssfile ), array(), $this->version, 'all' ); if ( ! function_exists( 'is_amp_endpoint' ) || ( function_exists( 'is_amp_endpoint' ) && ! is_amp_endpoint() ) ) { wp_enqueue_script('svg-x-use', plugin_dir_url(__FILE__) . 'svgxuse.js', array(), '1.1.21' ); } } /** * 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(); $css = ''; foreach ( $this->active_instances as $instance_id ) { // Skip if info for this instance does not exist - this should never happen. if ( ! isset( $all_instances[ $instance_id ] ) || $this->disable_css_output ) { continue; } $instance = wp_parse_args( $all_instances[ $instance_id ], $this->defaults ); $font_size = round( (int) $instance['size'] / 2 ); $icon_padding = round( (int) $font_size / 2 ); // Treat empty background and border colors as transparent. $instance['background_color'] = $instance['background_color'] ?: 'transparent'; $instance['border_color'] = $instance['border_color'] ?: 'transparent'; $instance['background_color_hover'] = $instance['background_color_hover'] ?: 'transparent'; $instance['border_color_hover'] = $instance['border_color_hover'] ?: 'transparent'; /** The CSS to output */ $css .= ' #simple-social-icons-' . $instance_id . ' ul li a, #simple-social-icons-' . $instance_id . ' ul li a:hover, #simple-social-icons-' . $instance_id . ' ul li a:focus { background-color: ' . $instance['background_color'] . ' !important; border-radius: ' . $instance['border_radius'] . 'px; color: ' . $instance['icon_color'] . ' !important; border: ' . $instance['border_width'] . 'px ' . $instance['border_color'] . ' solid !important; font-size: ' . $font_size . 'px; padding: ' . $icon_padding . 'px; } #simple-social-icons-' . $instance_id . ' ul li a:hover, #simple-social-icons-' . $instance_id . ' ul li a:focus { background-color: ' . $instance['background_color_hover'] . ' !important; border-color: ' . $instance['border_color_hover'] . ' !important; color: ' . $instance['icon_color_hover'] . ' !important; } #simple-social-icons-' . $instance_id . ' ul li a:focus { outline: 1px dotted ' . $instance['background_color_hover'] . ' !important; }'; } // Minify a bit. $css = str_replace( "\t", '', $css ); $css = str_replace( array( "\n", "\r" ), ' ', $css ); echo ''; } /** * Construct the markup for each icon * * @param string The lowercase icon name for use in tag attributes. * @param string The plain text icon label. * * @return string The full markup for the given icon. */ function get_icon_markup( $icon, $label ) { $markup = '
  • '; $markup .= '
  • '; /** * Filter the icon markup HTML. * * @since 3.0.0 * * @param string $markup The full HTML markup for a single icon. * @param string $icon The lowercase icon name used in tag attributes. * @param string $label The plain text icon label. */ return apply_filters( 'simple_social_icon_html', $markup, $icon, $label ); } /** * Remove option when uninstalling the plugin. * * @since 2.1.0 */ } add_action( 'widgets_init', 'ssiw_load_widget' ); /** * Widget Registration. * * Register Simple Social Icons widget. * */ function ssiw_load_widget() { register_widget( 'Aff_booster_Social_Icons_Widget' ); }