'widget_wpt', 'description' => __('Display popular posts, recent posts, comments, and tags in tabbed format.', 'themeidol-all-widget')); $control_ops = array('width' => 300, 'height' => 350); parent::__construct('themeidoltb_widget', __('Themeidol-WP Tab Widget', 'themeidol-all-widget'), $widget_ops, $control_ops); } function wpt_admin_scripts($hook) { if ($hook != 'widgets.php') return; wp_register_script('themeidol_wpt_widget_admin', THEMEIDOL_WIDGET_JS_URL.'tab-admin.js', array('jquery')); wp_enqueue_script('themeidol_wpt_widget_admin'); } function wpt_register_scripts() { // JS wp_register_script('themeidol_wpt_widget', THEMEIDOL_WIDGET_JS_URL.'tab-widget.js', array('jquery')); wp_localize_script( 'themeidol_wpt_widget', 'wpt', array( 'ajax_url' => admin_url( 'admin-ajax.php' )) ); // CSS wp_register_style('themeidol_wpt_widget-style', THEMEIDOL_WIDGET_CSS_URL.'tab-widget.css'); } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'tabs' => array('recent' => 1, 'popular' => 1, 'comments' => 0, 'tags' => 0), 'tab_order' => array('popular' => 1, 'recent' => 2, 'comments' => 3, 'tags' => 4), 'allow_pagination' => 1, 'post_num' => '5', 'comment_num' => '5', 'show_thumb' => 1, 'thumb_size' => 'small', 'show_date' => 1, 'show_excerpt' => 0, 'excerpt_length' => apply_filters( 'wpt_excerpt_length_default', '15' ), 'show_comment_num' => 0, 'show_avatar' => 1, 'title_length' => apply_filters( 'wpt_title_length_default', '15' ) , 'popularity'=>'visited', 'show_love' => 0, ) ); extract($instance); ?>
1, 'popular' => 1); $tabs_count = count($tabs); if ($tabs_count <= 1) { $tabs_count = 1; } elseif($tabs_count > 3) { $tabs_count = 4; } $available_tabs = array('popular' => __('Popular', 'themeidol-all-widget'), 'recent' => __('Recent', 'themeidol-all-widget'), 'comments' => __('Comments', 'themeidol-all-widget'), 'tags' => __('Tags', 'themeidol-all-widget')); array_multisort($tab_order, $available_tabs); $show_love = !empty($instance['show_love']); ?> get_settings(); if ( isset( $settings[ $number ] ) ) { $args = $settings[ $number ]; } else { die( __('Unable to load tab content', 'themeidol-all-widget') ); } } // sanitize args $post_num = (empty($args['post_num']) ? 5 : intval($args['post_num'])); if ($post_num > 20 || $post_num < 1) { // max 20 posts $post_num = 5; } $comment_num = (empty($args['comment_num']) ? 5 : intval($args['comment_num'])); if ($comment_num > 20 || $comment_num < 1) { $comment_num = 5; } $show_thumb = !empty($args['show_thumb']); $thumb_size = $args['thumb_size']; $popularity=$args['popularity']; if ($thumb_size != 'small' && $thumb_size != 'large') { $thumb_size = 'small'; // default } $show_date = !empty($args['show_date']); $show_excerpt = !empty($args['show_excerpt']); $excerpt_length = intval($args['excerpt_length']); if ($excerpt_length > 50 || $excerpt_length < 1) { $excerpt_length = 10; } $show_comment_num = !empty($args['show_comment_num']); $show_avatar = !empty($args['show_avatar']); $allow_pagination = !empty($args['allow_pagination']); $title_length = ! empty($args['title_length']) ? $args['title_length'] : apply_filters( 'wpt_title_length_default', '15' ); /* ---------- Tab Contents ---------- */ switch ($tab) { /* ---------- Popular Posts ---------- */ case "popular": ?>excerpt($excerpt_length); ?>
excerpt($excerpt_length); ?>
truncate(strip_tags(apply_filters( 'get_comment_text', $comment->comment_content )), $comment_length);?>