__( 'Show Author Profile', 'bone' )]; parent::__construct( $id, $name, $ops ); } public function widget( $args, $instance ) { global $post; $res = ''; $menu = ''; if ( get_the_author_meta( 'twitter') || get_the_author_meta( 'facebook') || get_the_author_meta( 'gplus') || get_the_author_meta( 'line') || get_the_author_meta( 'instagram') ) { $menu = <<< EOD
EOD; $tmp = '$name'; $setLink = function ( $id, $label ) use ( $tmp, &$menu ) { $href = get_the_author_meta( $id ); if ( $href ) { $table = [ '$href' => $href, '$name' => $label, ]; $menu .= strtr( $tmp, $table ); } }; $setLink( 'twitter', 'Twitter' ); $setLink( 'facebook', 'Facebook' ); $setLink( 'gplus', 'Google+' ); $setLink( 'line', 'LINE' ); $setLink( 'instagram', 'Instagram' ); $menu .= '
'; } if ( !empty( $instance['title'] ) ) { $res = $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $menu . $args['after_title']; } $res .= '
'; $res .= str_replace( '
'; echo $args['before_widget'] . $res . $args['after_widget']; } public function form( $instance ) { $title_id = $this->get_field_id( 'title' ); $title_name = $this->get_field_name( 'title' ); $old_title = empty( $instance['title'] ) ? '' : $instance['title']; ?>