defaults = array( 'title' => __( 'Authors List', $this->domain ), 'size' => '45', 'orderby' => 'login', 'order' => 'ASC', 'excludes' => '', ); $this->orderby = array( 'login' => __( 'login ID', $this->domain ), 'email' => __( 'E-mail', $this->domain ), 'url' => __( 'URL', $this->domain ), 'registered' => __( 'Registerd', $this->domain ), 'display_name' => __( 'Display name', $this->domain ), 'post_count' => __( 'Post count', $this->domain ), 'orderby' => __( 'Order', $this->domain ), ); $this->order = array( 'ASC' => __( 'Ascending', $this->domain ), 'DESC' => __( 'Descending', $this->domain ), ); $this->WP_Widget( 'author-profile-widget-list', __( 'Authors List', $this->domain ), array( 'classname' => 'author-profile-widget-list', 'description' => __( 'Authors List', $this->domain ) ) ); } /** * form * @param array $instance */ public function form( $instance ) { $instance = $this->_parse_options( $instance ); ?>
get_field_id( 'title' ); $title_name = $this->get_field_name( 'title' ); ?>
get_field_id( 'size' ); $size_name = $this->get_field_name( 'size' ); ?> px
get_field_id( 'orderby' ); $orderby_name = $this->get_field_name( 'orderby' ); ?>
get_field_id( 'order' ); $order_name = $this->get_field_name( 'order' ); ?>
get_field_id( 'excludes' ); $excludes_name = $this->get_field_name( 'excludes' ); ?>
defaults ); // size $new_instance['size'] = mb_convert_kana( $new_instance['size'], 'a', 'utf-8' ); if ( !preg_match( '/^\d+$/', $new_instance['size'] ) ) { $new_instance['size'] = $this->defaults['size']; } // orderby if ( !array_key_exists( $new_instance['orderby'], $this->orderby ) ) { $new_instance['orderby'] = $this->defaults['orderby']; } // order if ( !array_key_exists( $new_instance['order'], $this->order ) ) { $new_instance['order'] = $this->defaults['order']; } // excludes if ( !preg_match( '/^(\d+?,?)+$/', $new_instance['excludes'] ) ) { $new_instance['excludes'] = $this->defaults['excludes']; } $instance = wp_parse_args( $new_instance, $old_instance ); return $instance; } /** * widget * @param array $args * @param array $instance */ public function widget( $args, $instance ) { $instance = $this->_parse_options( $instance ); echo $args['before_widget']; echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title']; echo do_shortcode( sprintf ( '[apw-list size="%d" orderby="%s" order="%s" excludes="%s"]', $instance['size'], $instance['orderby'], $instance['order'], $instance['excludes'] ) ); echo $args['after_widget']; } }