Version Description
- Popular posts will be decided by number of views.
- Added loading effect.
- Fixed small bugs.
- Performance improvement.
Download this release
Release Info
Developer | MyThemeShop |
Plugin | WP Tab Widget |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- css/wp-tab-widget.css +49 -3
- img/largethumb.png +0 -0
- img/smallthumb.png +0 -0
- js/wp-tab-widget.js +3 -2
- js/wpt-admin.js +3 -3
- languages/default.po +0 -0
- readme.txt +7 -1
- wp-tab-widget.php +90 -8
css/wp-tab-widget.css
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
|
|
|
|
3 |
Author: MyThemeShop
|
4 |
-
Author URI: mythemeshop.com
|
5 |
-
Version: 1.0
|
6 |
*/
|
7 |
|
8 |
.wpt_widget_content {
|
@@ -177,7 +178,10 @@ Version: 1.0
|
|
177 |
}
|
178 |
|
179 |
/* Loading... */
|
180 |
-
.wpt-loading
|
|
|
|
|
|
|
181 |
content: "";
|
182 |
display: block;
|
183 |
position: absolute;
|
@@ -186,7 +190,49 @@ Version: 1.0
|
|
186 |
bottom: 0;
|
187 |
left: 0;
|
188 |
background-color: rgba(255,255,255,0.8);
|
|
|
189 |
}
|
190 |
.clear {
|
191 |
clear: both;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-tab-widget/
|
4 |
+
Description: WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
|
5 |
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
|
|
7 |
*/
|
8 |
|
9 |
.wpt_widget_content {
|
178 |
}
|
179 |
|
180 |
/* Loading... */
|
181 |
+
.wpt-loading {
|
182 |
+
min-height: 120px;
|
183 |
+
}
|
184 |
+
.wpt-loading:before {
|
185 |
content: "";
|
186 |
display: block;
|
187 |
position: absolute;
|
190 |
bottom: 0;
|
191 |
left: 0;
|
192 |
background-color: rgba(255,255,255,0.8);
|
193 |
+
z-index: 11;
|
194 |
}
|
195 |
.clear {
|
196 |
clear: both;
|
197 |
+
}
|
198 |
+
|
199 |
+
.wpt-loading:after {
|
200 |
+
content: "";
|
201 |
+
margin: 0 auto 3em auto;
|
202 |
+
font-size: 10px;
|
203 |
+
position: absolute;
|
204 |
+
top: 45%;
|
205 |
+
left: 45%;
|
206 |
+
z-index: 12;
|
207 |
+
text-indent: -9999em;
|
208 |
+
border-top: 0.4em solid rgba(0, 0, 0, 0.2);
|
209 |
+
border-right: 0.4em solid rgba(0, 0, 0, 0.2);
|
210 |
+
border-bottom: 0.4em solid rgba(0, 0, 0, 0.2);
|
211 |
+
border-left: 0.4em solid #000;
|
212 |
+
-webkit-animation: load8 0.5s infinite linear;
|
213 |
+
animation: load8 0.5s infinite linear;
|
214 |
+
border-radius: 50%;
|
215 |
+
width: 2em;
|
216 |
+
height: 2em;
|
217 |
+
}
|
218 |
+
|
219 |
+
@-webkit-keyframes load8 {
|
220 |
+
0% {
|
221 |
+
-webkit-transform: rotate(0deg);
|
222 |
+
transform: rotate(0deg);
|
223 |
+
}
|
224 |
+
100% {
|
225 |
+
-webkit-transform: rotate(360deg);
|
226 |
+
transform: rotate(360deg);
|
227 |
+
}
|
228 |
+
}
|
229 |
+
@keyframes load8 {
|
230 |
+
0% {
|
231 |
+
-webkit-transform: rotate(0deg);
|
232 |
+
transform: rotate(0deg);
|
233 |
+
}
|
234 |
+
100% {
|
235 |
+
-webkit-transform: rotate(360deg);
|
236 |
+
transform: rotate(360deg);
|
237 |
+
}
|
238 |
}
|
img/largethumb.png
CHANGED
File without changes
|
img/smallthumb.png
CHANGED
File without changes
|
js/wp-tab-widget.js
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
|
|
|
|
3 |
Author: MyThemeShop
|
4 |
-
Author URI: mythemeshop.com
|
5 |
*/
|
6 |
-
|
7 |
function wpt_loadTabContent(tab_name, page_num, container, args_obj) {
|
8 |
|
9 |
var container = jQuery(container);
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-tab-widget/
|
4 |
+
Description: WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
|
5 |
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
*/
|
|
|
8 |
function wpt_loadTabContent(tab_name, page_num, container, args_obj) {
|
9 |
|
10 |
var container = jQuery(container);
|
js/wpt-admin.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
|
|
|
|
3 |
Author: MyThemeShop
|
4 |
-
Author URI: mythemeshop.com
|
5 |
-
Version: 1.0
|
6 |
*/
|
7 |
-
|
8 |
jQuery(document).on('click', function(e) {
|
9 |
var $this = jQuery(e.target);
|
10 |
var $form = $this.closest('.wpt_options_form');
|
1 |
/*
|
2 |
Plugin Name: WP Tab Widget
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-tab-widget/
|
4 |
+
Description: WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
|
5 |
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
|
|
7 |
*/
|
|
|
8 |
jQuery(document).on('click', function(e) {
|
9 |
var $this = jQuery(e.target);
|
10 |
var $form = $this.closest('.wpt_options_form');
|
languages/default.po
CHANGED
File without changes
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Creator's website link: http://mythemeshop.com/
|
|
4 |
Tags: tabs, tab widget, recent posts tab, tabs widget, ajax tabs, ajax widget.
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.0
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -75,5 +75,11 @@ Please disable all plugins and check if shortcode plugin is working properly. Th
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
= 1.0 =
|
79 |
* Official plugin release.
|
4 |
Tags: tabs, tab widget, recent posts tab, tabs widget, ajax tabs, ajax widget.
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.0
|
7 |
+
Stable tag: 1.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 1.1 =
|
79 |
+
* Popular posts will be decided by number of views.
|
80 |
+
* Added loading effect.
|
81 |
+
* Fixed small bugs.
|
82 |
+
* Performance improvement.
|
83 |
+
|
84 |
= 1.0 =
|
85 |
* Official plugin release.
|
wp-tab-widget.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP Tab Widget
|
4 |
-
Plugin URI: http://mythemeshop.com/
|
5 |
Description: WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
|
6 |
Author: MyThemeShop
|
7 |
-
Version: 1.
|
8 |
Author URI: http://mythemeshop.com/
|
9 |
*/
|
10 |
|
@@ -21,7 +21,7 @@ class wpt_widget extends WP_Widget {
|
|
21 |
// css
|
22 |
add_action('wp_enqueue_scripts', array(&$this, 'wpt_register_scripts'));
|
23 |
add_action('admin_enqueue_scripts', array(&$this, 'wpt_admin_scripts'));
|
24 |
-
|
25 |
$widget_ops = array('classname' => 'widget_wpt', 'description' => __('Display popular posts, recent posts, comments, and tags in tabbed format.', 'mts_wpt'));
|
26 |
$control_ops = array('width' => 300, 'height' => 350);
|
27 |
$this->WP_Widget('wpt_widget', __('WP Tab Widget by MyThemeShop', 'mts_wpt'), $widget_ops, $control_ops);
|
@@ -226,7 +226,7 @@ class wpt_widget extends WP_Widget {
|
|
226 |
|
227 |
?>
|
228 |
<?php echo $before_widget; ?>
|
229 |
-
<div class="wpt_widget_content" id="<?php echo $widget_id; ?>_content">
|
230 |
<ul class="wpt-tabs <?php echo "has-$tabs_count-"; ?>tabs">
|
231 |
<?php foreach ($available_tabs as $tab => $label) { ?>
|
232 |
<?php if (!empty($tabs[$tab])): ?>
|
@@ -317,11 +317,11 @@ class wpt_widget extends WP_Widget {
|
|
317 |
?>
|
318 |
<ul>
|
319 |
<?php
|
320 |
-
$popular = new WP_Query( array('ignore_sticky_posts' => 1, 'posts_per_page' => $post_num, 'post_status' => 'publish', 'orderby' => '
|
321 |
$last_page = $popular->max_num_pages;
|
322 |
while ($popular->have_posts()) : $popular->the_post(); ?>
|
323 |
-
<li>
|
324 |
-
<?php if ( $show_thumb == 1 ) : ?>
|
325 |
<div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
|
326 |
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
|
327 |
<?php if(has_post_thumbnail()): ?>
|
@@ -430,7 +430,7 @@ class wpt_widget extends WP_Widget {
|
|
430 |
$last_page = ceil($comments_total_number / $comment_num);
|
431 |
$comments_query = new WP_Comment_Query();
|
432 |
$offset = ($page-1) * $comment_num;
|
433 |
-
$comments = $comments_query->query( array( 'number' => $comment_num, 'offset' => $offset ) );
|
434 |
if ( $comments ) : foreach ( $comments as $comment ) : ?>
|
435 |
<li>
|
436 |
|
@@ -519,9 +519,91 @@ class wpt_widget extends WP_Widget {
|
|
519 |
return $str;
|
520 |
}
|
521 |
}
|
|
|
522 |
}
|
523 |
add_action( 'widgets_init', create_function( '', 'register_widget( "wpt_widget" );' ) );
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
// unregister MTS Tabs Widget and Tabs Widget v2
|
526 |
add_action('widgets_init', 'unregister_mts_tabs_widget', 100);
|
527 |
function unregister_mts_tabs_widget() {
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP Tab Widget
|
4 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-tab-widget/
|
5 |
Description: WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
|
6 |
Author: MyThemeShop
|
7 |
+
Version: 1.1
|
8 |
Author URI: http://mythemeshop.com/
|
9 |
*/
|
10 |
|
21 |
// css
|
22 |
add_action('wp_enqueue_scripts', array(&$this, 'wpt_register_scripts'));
|
23 |
add_action('admin_enqueue_scripts', array(&$this, 'wpt_admin_scripts'));
|
24 |
+
|
25 |
$widget_ops = array('classname' => 'widget_wpt', 'description' => __('Display popular posts, recent posts, comments, and tags in tabbed format.', 'mts_wpt'));
|
26 |
$control_ops = array('width' => 300, 'height' => 350);
|
27 |
$this->WP_Widget('wpt_widget', __('WP Tab Widget by MyThemeShop', 'mts_wpt'), $widget_ops, $control_ops);
|
226 |
|
227 |
?>
|
228 |
<?php echo $before_widget; ?>
|
229 |
+
<div class="wpt_widget_content" id="<?php echo $widget_id; ?>_content">
|
230 |
<ul class="wpt-tabs <?php echo "has-$tabs_count-"; ?>tabs">
|
231 |
<?php foreach ($available_tabs as $tab => $label) { ?>
|
232 |
<?php if (!empty($tabs[$tab])): ?>
|
317 |
?>
|
318 |
<ul>
|
319 |
<?php
|
320 |
+
$popular = new WP_Query( array('ignore_sticky_posts' => 1, 'posts_per_page' => $post_num, 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => '_wpt_view_count', 'order' => 'desc', 'paged' => $page));
|
321 |
$last_page = $popular->max_num_pages;
|
322 |
while ($popular->have_posts()) : $popular->the_post(); ?>
|
323 |
+
<li>
|
324 |
+
<?php if ( $show_thumb == 1 ) : ?>
|
325 |
<div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
|
326 |
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
|
327 |
<?php if(has_post_thumbnail()): ?>
|
430 |
$last_page = ceil($comments_total_number / $comment_num);
|
431 |
$comments_query = new WP_Comment_Query();
|
432 |
$offset = ($page-1) * $comment_num;
|
433 |
+
$comments = $comments_query->query( array( 'number' => $comment_num, 'offset' => $offset, 'status' => 'approve' ) );
|
434 |
if ( $comments ) : foreach ( $comments as $comment ) : ?>
|
435 |
<li>
|
436 |
|
519 |
return $str;
|
520 |
}
|
521 |
}
|
522 |
+
|
523 |
}
|
524 |
add_action( 'widgets_init', create_function( '', 'register_widget( "wpt_widget" );' ) );
|
525 |
|
526 |
+
// post view count
|
527 |
+
// AJAX is used to support caching plugins
|
528 |
+
add_filter('the_content', 'wpt_view_count_js'); // outputs JS for AJAX call on single
|
529 |
+
add_action('wp_ajax_wpt_view_count', 'ajax_wpt_view_count');
|
530 |
+
add_action('wp_ajax_nopriv_wpt_view_count','ajax_wpt_view_count');
|
531 |
+
// prevent additional ajax call if theme has view counter already
|
532 |
+
add_action('mts_view_count_after_update', 'wpt_add_view_count');
|
533 |
+
|
534 |
+
function wpt_view_count_js( $content ) {
|
535 |
+
global $post;
|
536 |
+
$id = $post->ID;
|
537 |
+
$use_ajax = apply_filters( 'mts_view_count_cache_support', true );
|
538 |
+
|
539 |
+
$exclude_admins = apply_filters( 'mts_view_count_exclude_admins', false ); // pass in true or a user capaibility
|
540 |
+
if ($exclude_admins === true) $exclude_admins = 'edit_posts';
|
541 |
+
if ($exclude_admins && current_user_can( $exclude_admins )) return $content; // do not count post views here
|
542 |
+
|
543 |
+
if (is_single()) {
|
544 |
+
if ( ! has_filter('the_content', 'mts_view_count_js') && $use_ajax) { // prevent additional ajax call if theme has view counter already
|
545 |
+
// enqueue jquery
|
546 |
+
wp_enqueue_script( 'jquery' );
|
547 |
+
|
548 |
+
$url = admin_url( 'admin-ajax.php' );
|
549 |
+
$content .= "
|
550 |
+
<script type=\"text/javascript\">
|
551 |
+
jQuery(document).ready(function($) {
|
552 |
+
$.post('{$url}', {action: 'wpt_view_count', id: '{$id}'});
|
553 |
+
});
|
554 |
+
</script>";
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
+
// if there's no general filter set and ajax is OFF
|
559 |
+
if (! has_filter('the_content', 'mts_view_count_js') && ! $use_ajax) {
|
560 |
+
wpt_update_view_count($id);
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
+
return $content;
|
565 |
+
}
|
566 |
+
|
567 |
+
|
568 |
+
|
569 |
+
function ajax_wpt_view_count() {
|
570 |
+
// do count
|
571 |
+
$post_id = $_POST['id'];
|
572 |
+
wpt_update_view_count( $post_id );
|
573 |
+
}
|
574 |
+
function wpt_update_view_count( $post_id ) {
|
575 |
+
$count = get_post_meta( $post_id, '_wpt_view_count', true );
|
576 |
+
update_post_meta( $post_id, '_wpt_view_count', $count + 1 );
|
577 |
+
}
|
578 |
+
|
579 |
+
// Add meta for all existing posts that don't have it
|
580 |
+
// to make them show up in Popular tab
|
581 |
+
function wpt_add_views_meta_for_posts() {
|
582 |
+
$allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
|
583 |
+
|
584 |
+
foreach( $allposts as $postinfo ) {
|
585 |
+
add_post_meta( $postinfo->ID, '_wpt_view_count', 0, true );
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
// Reset post count for specific post or all posts
|
590 |
+
function wpt_reset_post_count($post_id = 0) {
|
591 |
+
if ($post_id == 0) {
|
592 |
+
$allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
|
593 |
+
foreach( $allposts as $postinfo ) {
|
594 |
+
update_post_meta( $postinfo->ID, '_wpt_view_count', '0' );
|
595 |
+
}
|
596 |
+
} else {
|
597 |
+
update_post_meta( $post_id, '_wpt_view_count', '0' );
|
598 |
+
}
|
599 |
+
}
|
600 |
+
|
601 |
+
// add post meta on plugin activation
|
602 |
+
function wpt_plugin_activation() {
|
603 |
+
wpt_add_views_meta_for_posts();
|
604 |
+
}
|
605 |
+
register_activation_hook( __FILE__, 'wpt_plugin_activation' );
|
606 |
+
|
607 |
// unregister MTS Tabs Widget and Tabs Widget v2
|
608 |
add_action('widgets_init', 'unregister_mts_tabs_widget', 100);
|
609 |
function unregister_mts_tabs_widget() {
|