芝麻web文件管理V1.00
编辑当前文件:/home/mybf1/public_html/rambut.bf1.my/wp-content/themes/ef-practical/inc/widgets/social-widget.php
'ef_social_widget', 'description' => esc_html__( 'Display social icons.', 'ef-practical' ), ); parent::__construct( 'practical_social_widget', esc_html__( 'Practical: Social', 'ef-practical' ), $widget_ops ); } /** * Output the content of the widget */ public function widget( $args, $instance ) { // vars $output = ''; $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $target = isset( $instance['target'] ) ? $instance['target'] : 0; $show = isset( $instance['show'] ) ? $instance['show'] : 'icon'; // Before widget $output .= $args['before_widget']; // Widget title if ( $title ) { $output .= $args['before_title']; $output .= $title; $output .= $args['after_title']; } // Target if ( $target ) { $new_tab = 'target="_blank"'; } else { $new_tab = ''; } $output .= '
'; $socials = array( 'facebook', 'twitter', 'google-plus', 'youtube', 'pinterest', 'instagram', 'linkedin', 'flickr', 'rss' ); foreach( $socials as $social_icon ) { if ( 'icon' == $show ) { $icon_text = '
'; } elseif ( 'text' == $show ) { $icon_text = '
'. esc_html( ucfirst( $social_icon ) ) .'
'; } else { $icon_text = '
'.esc_html( ucfirst( $social_icon ) ).'
'; } if ( ! empty( $instance[ ''.$social_icon.'' ] ) ) { $output .= '
'.$icon_text.'
'; } } $output .= '
'; // After widget $output .= $args['after_widget']; // output echo echo $output; // WPCS: XSS ok. } /** * Update the information in the WordPress database */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : ''; $instance['target'] = ! empty( $new_instance['target'] ) ? true : false; $instance['show'] = ! empty( $new_instance['show'] ) ? sanitize_text_field( $new_instance['show'] ) : 'icon'; $instance[ 'facebook' ] = sanitize_text_field( $new_instance[ 'facebook' ] ); $instance[ 'twitter' ] = sanitize_text_field( $new_instance[ 'twitter' ] ); $instance[ 'google-plus' ] = sanitize_text_field( $new_instance[ 'google-plus' ] ); $instance[ 'youtube' ] = sanitize_text_field( $new_instance[ 'youtube' ] ); $instance[ 'pinterest' ] = sanitize_text_field( $new_instance[ 'pinterest' ] ); $instance[ 'instagram' ] = sanitize_text_field( $new_instance[ 'instagram' ] ); $instance[ 'linkedin' ] = sanitize_text_field( $new_instance[ 'linkedin' ] ); $instance[ 'flickr' ] = sanitize_text_field( $new_instance[ 'flickr' ] ); $instance[ 'rss' ] = sanitize_text_field( $new_instance[ 'rss' ] ); return $instance; } /** * Add form fields to the widget which will be displayed in the WordPress admin area. */ public function form( $instance ) { $instance = wp_parse_args( ( array ) $instance, array( 'title' => esc_html__( 'Social', 'ef-practical' ), 'target' => 0, 'show' => 'icon', 'facebook' => '', 'twitter' => '', 'google-plus' => '', 'youtube' => '', 'pinterest' => '', 'instagram' => '', 'linkedin' => '', 'flickr' => '', 'rss' => '', ) ); if ( $instance ) { $title = $instance[ 'title' ]; } if ( isset( $instance[ 'target' ] ) ) { $target = $instance[ 'target' ]; } if ( isset( $instance[ 'show' ] ) ) { $show = $instance[ 'show' ]; } if ( isset( $instance[ 'facebook' ] ) ) { global $facebook; $facebook = $instance[ 'facebook' ]; } if ( isset( $instance[ 'twitter' ] ) ) { $twitter = $instance[ 'twitter' ]; } if ( isset( $instance[ 'google-plus' ] ) ) { $googleplus = $instance[ 'google-plus' ]; } if ( isset( $instance[ 'youtube' ] ) ) { $youtube = $instance[ 'youtube' ]; } if ( isset( $instance[ 'pinterest' ] ) ) { $pinterest = $instance[ 'pinterest' ]; } if ( isset( $instance[ 'instagram' ] ) ) { $instagram = $instance[ 'instagram' ]; } if ( isset( $instance[ 'linkedin' ] ) ) { $linkedin = $instance[ 'linkedin' ]; } if ( isset( $instance[ 'flickr' ] ) ) { $flickr = $instance[ 'flickr' ]; } if ( isset( $instance['rss'] ) ) { $rss = $instance['rss']; } ?>
/>
>
>
>