WP Tab Widget - Version 1.0

Version Description

  • Official plugin release.
Download this release

Release Info

Developer MyThemeShop
Plugin Icon 128x128 WP Tab Widget
Version 1.0
Comparing to
See all releases

Version 1.0

css/wp-tab-widget.css ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 {
9
+ position: relative;
10
+ border: 1px solid #E4E4E4;
11
+ }
12
+ .wpt_widget_content img {
13
+ max-width: 100%;
14
+ height: auto;
15
+ }
16
+ .wpt_widget_content a {
17
+ color: #444;
18
+ }
19
+ .wpt_widget_content ul.wpt-tabs li {
20
+ list-style: none;
21
+ display: block;
22
+ width: 50%;
23
+ float: left;
24
+ text-align: center;
25
+ margin: 0;
26
+ padding: 0 !important;
27
+ }
28
+ .wpt_widget_content ul.has-1-tabs li {
29
+ width: 100%;
30
+ float: none;
31
+ margin: 0 auto;
32
+ }
33
+ .wpt_widget_content ul.has-2-tabs li {
34
+
35
+ }
36
+ .wpt_widget_content ul.has-3-tabs li {
37
+ width: 33.33%;
38
+ }
39
+ .wpt_widget_content ul.has-4-tabs li {
40
+ width: 50%;
41
+ }
42
+ .wpt_widget_content .has-4-tabs .tab_title.selected a {
43
+ border-bottom: 1px solid #E4E4E4;
44
+ }
45
+ .wpt_widget_content .has-4-tabs .tab_title:nth-child(3) a {
46
+ border-left: 0;
47
+ }
48
+ .wpt_widget_content .tab_title a {
49
+ display: block;
50
+ background: #f0f0f0;
51
+ border-left: 1px solid #E4E4E4;
52
+ border-bottom: 1px solid #E4E4E4;
53
+ padding: 2px 0 4px;
54
+ line-height: 2.4;
55
+ text-decoration: none;
56
+ position: relative;
57
+ font-weight: bold;
58
+ }
59
+ .wpt_widget_content .tab_title:first-child a {
60
+ margin-left: 0;
61
+ border-left: 0;
62
+ }
63
+ .wpt_widget_content .tab_title.selected a {
64
+ background: #fff;
65
+ border-bottom: 1px solid #fff;
66
+ }
67
+ .wpt_widget_content .inside {
68
+ background: #fff;
69
+ padding-top: 10px;
70
+ }
71
+ .wpt_widget_content .tab-content li {
72
+ list-style-type: none;
73
+ float: left;
74
+ width: 100%;
75
+ -moz-box-sizing: border-box;
76
+ box-sizing: border-box;
77
+ margin: 0 0 11px 0;
78
+ padding: 0px 15px 15px 15px;
79
+ border-bottom: 1px solid #E4E4E4;
80
+ text-align: left;
81
+ color: #444;
82
+ background: none;
83
+ position: relative;
84
+ }
85
+ .wpt_widget_content .tab-content li:last-child {
86
+ border: none;
87
+ margin-bottom: 0;
88
+ }
89
+ .wpt_widget_content .tab-content li:first-child {
90
+ padding-top: 5px;
91
+ }
92
+
93
+ .wpt_thumb_small {
94
+ float: left;
95
+ margin-right: 12px;
96
+ padding-top: 4px;
97
+ width: 65px;
98
+ height: 65px;
99
+ overflow: hidden;
100
+ }
101
+ .wpt_thumb_large {
102
+ float: none;
103
+ max-width: 100%;
104
+ display: inline-block;
105
+ margin-bottom: 4px;
106
+ position: relative;
107
+ }
108
+ .wpt_widget_content .entry-title {
109
+ font-weight: bold;
110
+ margin: 0;
111
+ padding: 0;
112
+ }
113
+ .wpt_widget_content .wpt-postmeta, .wpt_comment_content, .wpt_excerpt {
114
+ color: #999;
115
+ font-size: 13px;
116
+ }
117
+ .wpt_widget_content .wp-post-image {
118
+ margin: 0 !important;
119
+ }
120
+
121
+ /* Comments */
122
+ .wpt_avatar {
123
+ margin-right: 10px;
124
+ float: left;
125
+ margin-top: 4px;
126
+ }
127
+ .wpt_comment_content p, .wpt_excerpt p {
128
+ margin-bottom: 0;
129
+ }
130
+ .wpt_comment_meta {
131
+ font-weight: bold;
132
+ }
133
+
134
+ /* Tags tab */
135
+ .wpt_widget_content #tags-tab-content {
136
+ padding-bottom: 10px;
137
+ }
138
+ .wpt_widget_content #tags-tab-content ul {
139
+ margin: 0;
140
+ overflow: hidden;
141
+ padding: 0 10px;
142
+ text-align: center;
143
+ font-size: 0;
144
+ line-height: 0;
145
+ }
146
+ .wpt_widget_content #tags-tab-content ul li {
147
+ width: auto;
148
+ color: #fff;
149
+ margin-bottom: 0;
150
+ list-style: none;
151
+ display: inline-block;
152
+ padding: 0;
153
+ margin: 3px 3px 0 0;
154
+ float: none;
155
+ font-size: 13px;
156
+ }
157
+ .wpt_widget_content #tags-tab-content ul li a {
158
+ padding: 12px 10px;
159
+ background: #f0f0f0;
160
+ white-space: nowrap;
161
+ display: block;
162
+ }
163
+
164
+ /* Pagination */
165
+ .wpt_widget_content .wpt-pagination {
166
+ margin: 0;
167
+ width: 100%;
168
+ padding-top: 0;
169
+ padding-bottom: 15px;
170
+ float: left;
171
+ }
172
+ .wpt_widget_content .wpt-pagination a {
173
+ margin: 0 15px;
174
+ }
175
+ .wpt-pagination a.next {
176
+ float: right;
177
+ }
178
+
179
+ /* Loading... */
180
+ .wpt-loading:after {
181
+ content: "";
182
+ display: block;
183
+ position: absolute;
184
+ top: 0;
185
+ right: 0;
186
+ bottom: 0;
187
+ left: 0;
188
+ background-color: rgba(255,255,255,0.8);
189
+ }
190
+ .clear {
191
+ clear: both;
192
+ }
img/largethumb.png ADDED
Binary file
img/smallthumb.png ADDED
Binary file
js/wp-tab-widget.js ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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);
10
+ var tab_content = container.find('#'+tab_name+'-tab-content');
11
+
12
+ // only load content if it wasn't already loaded
13
+ var isLoaded = tab_content.data('loaded');
14
+
15
+ if (!isLoaded || page_num != 1) {
16
+ if (!container.hasClass('wpt-loading')) {
17
+ container.addClass('wpt-loading');
18
+
19
+ tab_content.load(wpt.ajax_url, {
20
+ action: 'wpt_widget_content',
21
+ tab: tab_name,
22
+ page: page_num,
23
+ args: args_obj
24
+ }, function() {
25
+ container.removeClass('wpt-loading');
26
+ tab_content.data('loaded', 1).hide().fadeIn().siblings().hide();
27
+ }
28
+ );
29
+ }
30
+ } else {
31
+ tab_content.fadeIn().siblings().hide();
32
+ }
33
+ }
34
+
35
+ jQuery(document).ready(function() {
36
+ jQuery('.wpt_widget_content').each(function() {
37
+ var $this = jQuery(this);
38
+ var widget_id = this.id;
39
+ var args = $this.data('args');
40
+
41
+ // load tab content on click
42
+ $this.find('.wpt-tabs a').click(function(e) {
43
+ e.preventDefault();
44
+ jQuery(this).parent().addClass('selected').siblings().removeClass('selected');
45
+ var tab_name = this.id.slice(0, -4); // -tab
46
+ wpt_loadTabContent(tab_name, 1, $this, args);
47
+ });
48
+
49
+ // pagination
50
+ $this.on('click', '.wpt-pagination a', function(e) {
51
+ e.preventDefault();
52
+ var $this_a = jQuery(this);
53
+ var tab_name = $this_a.closest('.tab-content').attr('id').slice(0, -12); // -tab-content
54
+ var page_num = parseInt($this_a.closest('.tab-content').children('.page_num').val());
55
+
56
+ if ($this_a.hasClass('next')) {
57
+ wpt_loadTabContent(tab_name, page_num + 1, $this, args);
58
+ } else {
59
+ $this.find('#'+tab_name+'-tab-content').data('loaded', 0);
60
+ wpt_loadTabContent(tab_name, page_num - 1, $this, args);
61
+ }
62
+
63
+ });
64
+
65
+ // load first tab now
66
+ $this.find('.wpt-tabs a').first().click();
67
+ });
68
+
69
+ });
js/wpt-admin.js ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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');
11
+
12
+ if ($this.is('.wpt_enable_comments')) {
13
+ var $related = $form.find('.wpt_comment_options');
14
+ var val = $this.is(':checked');
15
+ if (val) {
16
+ $related.slideDown();
17
+ } else {
18
+ $related.slideUp();
19
+ }
20
+ } else if ($this.is('.wpt_show_thumbnails')) {
21
+ var $related = $form.find('.wpt_thumbnail_size');
22
+ var val = $this.is(':checked');
23
+ if (val) {
24
+ $related.slideDown();
25
+ } else {
26
+ $related.slideUp();
27
+ }
28
+ } else if ($this.is('.wpt_show_excerpt')) {
29
+ var $related = $form.find('.wpt_excerpt_length');
30
+ var val = $this.is(':checked');
31
+ if (val) {
32
+ $related.slideDown();
33
+ } else {
34
+ $related.slideUp();
35
+ }
36
+ } else if ($this.is('.wpt_tab_order_header a')) {
37
+ e.preventDefault();
38
+ var $related = $form.find('.wpt_tab_order');
39
+ $related.slideToggle();
40
+ } else if ($this.is('.wpt_advanced_options_header a')) {
41
+ e.preventDefault();
42
+ var $related = $form.find('.wpt_advanced_options');
43
+ $related.slideToggle();
44
+ }
45
+ });
languages/default.mo ADDED
Binary file
languages/default.po ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Tab Widget by MyThemeShop\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-03-24 01:53+0530\n"
6
+ "PO-Revision-Date: 2014-03-24 01:53+0530\n"
7
+ "Last-Translator: MyThemeShop <support-team@mythemeshop.com>\n"
8
+ "Language-Team: MyThemeShop <support-team@mythemeshop.com>\n"
9
+ "Language: en_US\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Poedit-KeywordsList: __;_e\n"
14
+ "X-Poedit-Basepath: .\n"
15
+ "X-Generator: Poedit 1.6.2\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../wp-tab-widget.php:25
19
+ msgid ""
20
+ "Display popular posts, recent posts, comments, and tags in tabbed format."
21
+ msgstr ""
22
+
23
+ #: ../wp-tab-widget.php:27
24
+ msgid "WP Tab Widget by MyThemeShop"
25
+ msgstr ""
26
+
27
+ #: ../wp-tab-widget.php:58
28
+ msgid "Select Tabs"
29
+ msgstr ""
30
+
31
+ #: ../wp-tab-widget.php:63
32
+ msgid "Popular Tab"
33
+ msgstr ""
34
+
35
+ #: ../wp-tab-widget.php:67
36
+ msgid "Recent Tab"
37
+ msgstr ""
38
+
39
+ #: ../wp-tab-widget.php:71
40
+ msgid "Comments Tab"
41
+ msgstr ""
42
+
43
+ #: ../wp-tab-widget.php:75
44
+ msgid "Tags Tab"
45
+ msgstr ""
46
+
47
+ #: ../wp-tab-widget.php:80
48
+ msgid "Tab Order"
49
+ msgstr ""
50
+
51
+ #: ../wp-tab-widget.php:86 ../wp-tab-widget.php:220
52
+ msgid "Popular"
53
+ msgstr ""
54
+
55
+ #: ../wp-tab-widget.php:90 ../wp-tab-widget.php:221
56
+ msgid "Recent"
57
+ msgstr ""
58
+
59
+ #: ../wp-tab-widget.php:94 ../wp-tab-widget.php:222 ../wp-tab-widget.php:345
60
+ #: ../wp-tab-widget.php:398
61
+ msgid "Comments"
62
+ msgstr ""
63
+
64
+ #: ../wp-tab-widget.php:98 ../wp-tab-widget.php:223
65
+ msgid "Tags"
66
+ msgstr ""
67
+
68
+ #: ../wp-tab-widget.php:103
69
+ msgid "Advanced Options"
70
+ msgstr ""
71
+
72
+ #: ../wp-tab-widget.php:109
73
+ msgid "Allow pagination"
74
+ msgstr ""
75
+
76
+ #: ../wp-tab-widget.php:116
77
+ msgid "Number of posts to show:"
78
+ msgstr ""
79
+
80
+ #: ../wp-tab-widget.php:125
81
+ msgid "Show post thumbnails"
82
+ msgstr ""
83
+
84
+ #: ../wp-tab-widget.php:130
85
+ msgid "Thumbnail size:"
86
+ msgstr ""
87
+
88
+ #: ../wp-tab-widget.php:132
89
+ msgid "Small"
90
+ msgstr ""
91
+
92
+ #: ../wp-tab-widget.php:133
93
+ msgid "Large"
94
+ msgstr ""
95
+
96
+ #: ../wp-tab-widget.php:140
97
+ msgid "Show post date"
98
+ msgstr ""
99
+
100
+ #: ../wp-tab-widget.php:147
101
+ msgid "Show number of comments"
102
+ msgstr ""
103
+
104
+ #: ../wp-tab-widget.php:154
105
+ msgid "Show post excerpt"
106
+ msgstr ""
107
+
108
+ #: ../wp-tab-widget.php:160
109
+ msgid "Excerpt length (words):"
110
+ msgstr ""
111
+
112
+ #: ../wp-tab-widget.php:173
113
+ msgid "Number of comments on Comments Tab:"
114
+ msgstr ""
115
+
116
+ #: ../wp-tab-widget.php:182
117
+ msgid "Show avatars on Comments Tab"
118
+ msgstr ""
119
+
120
+ #: ../wp-tab-widget.php:345 ../wp-tab-widget.php:398
121
+ msgid "No Comment"
122
+ msgstr ""
123
+
124
+ #: ../wp-tab-widget.php:345 ../wp-tab-widget.php:398
125
+ msgid "One Comment"
126
+ msgstr ""
127
+
128
+ #: ../wp-tab-widget.php:457
129
+ msgid "No comments yet."
130
+ msgstr ""
131
+
132
+ #: ../wp-tab-widget.php:480
133
+ msgid "No tags created."
134
+ msgstr ""
135
+
136
+ #: ../wp-tab-widget.php:493
137
+ msgid "&laquo; Previous"
138
+ msgstr ""
139
+
140
+ #: ../wp-tab-widget.php:496
141
+ msgid "Next &raquo;"
142
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WP Tab Widget ===
2
+ Contributors: mythemeshop
3
+ 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.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
12
+
13
+ == Description ==
14
+
15
+ We know you always loved those tab widgets which have that lazy loading effect in them. We at <a href="http://mythemeshop.com/">MyThemeShop</a> understand your need, and have developed a unique, cleanly coded, premium tab plugin. We are now distributing it for FREE to give back to the WordPress community. We have been given so much by the WordPress, it's the time to pay back.
16
+
17
+ **WP Tab plugin** is the only plugin you need to get the perfect tabs on your blog. We have made it AJAXified, so the content loads only when demanded, and thus it makes the plugin incredibly lightweight. It loads before you could even blink your eye. If you're a website owner, you always want your visitors to stay longer on your website. With WP Tab plugin, you could do it in a simple way. Install the plugin, configure the widget and let your visitors find the best content on your website in the sidebar without struggling to actually search for it.
18
+
19
+ = Live demos: =
20
+ See WP Tab Widget in action on our demo pages:
21
+ <a href="http://demo.mythemeshop.com/truepixel/">http://demo.mythemeshop.com/truepixel/</a>
22
+
23
+ = Why WP Tab from <a href="http://mythemeshop.com/">MyThemeShop</a>: =
24
+ * It's the only free plugin which offers so many features
25
+ * It loads the content by demand
26
+ * Choose between, Popular, Recent, Comments, Tags tab
27
+ * In-built Pagination System
28
+ * Fully Responsive
29
+ * Control the order of the tabs
30
+ * Change the number of tabs to show
31
+ * Control the number of posts to show
32
+ * Super light weight
33
+ * In-built cache system, once a tab is loaded, it stays in the memory
34
+ * Cool effects
35
+ * Easy to modify the CSS to better fit your theme style
36
+ * Choose between 3 unique styles of small, big or no thumbnails
37
+ * Show/Hide post date
38
+ * Show/Hide number of comments
39
+ * Show/Hide post excerpt
40
+ * Position it anywhere where a widget is configured in your theme.
41
+
42
+ = Support =
43
+ We will do our best to provide support through the WordPress forums. However, all plugin support is provided in our forum. If you have not registered yet, you can do so here: <a href="https://mythemeshop.com/go/signup/index/c/free">https://mythemeshop.com/go/signup/index/c/free</a>. After searching the knowledge base and forum if you are still stuck, feel free to open a new thread, and a member of our support team will be happy to help. Cheers!<br>
44
+ Support link: <a href="http://community.mythemeshop.com/forum/free/plugin-support">http://community.mythemeshop.com/forum/free/plugin-support</a>
45
+
46
+ = Help to make it better =
47
+
48
+ MyThemeShop is a premium WordPress theme provider and we develop premium plugins in our free time and distribute them for free to give back to the community. Though we take a lot of care while developing anything, we might have missed something useful/important. Please help us make it better by submitting the bug/suggestions/feedback on GitHub.
49
+
50
+ GitHub link: <a href="https://github.com/MyThemeShop/WP-Tab-Widget-by-MyThemeShop">https://github.com/MyThemeShop/WP-Tab-Widget-by-MyThemeShop</a>
51
+
52
+ = Feedback =
53
+ If you like this plugin, then please leave us a good rating and review.<br> Consider following us on <a rel="author" href="https://plus.google.com/+Mythemeshop/">Google+</a>, <a href="https://twitter.com/MyThemeShopTeam">Twitter</a>, and <a href="https://www.facebook.com/MyThemeShop">Facebook</a>
54
+
55
+ == Installation ==
56
+
57
+ This section describes how to install the plugin and get it working.
58
+
59
+ 1. Upload the `wp-tab-widget` folder to the to the `/wp-content/plugins/` directory
60
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
61
+ 3. You can see **WP Tab Widget by MyThemeShop** widget in widgets section.
62
+ 4. Add it in sidebar and footer and configure as you want.
63
+ 5. Enjoy!
64
+
65
+ == Frequently Asked Questions ==
66
+
67
+ = Plugin is not working =
68
+
69
+ Please disable all plugins and check if shortcode plugin is working properly. Then you can enable all plugins one by one to find out which plugin is conflicting with plugin.
70
+
71
+ == Screenshots ==
72
+
73
+ 1. WP Tab Widget Settings
74
+ 2. WP Tab Widget
75
+
76
+ == Changelog ==
77
+
78
+ = 1.0 =
79
+ * Official plugin release.
wp-tab-widget.php ADDED
@@ -0,0 +1,532 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0
8
+ Author URI: http://mythemeshop.com/
9
+ */
10
+
11
+ class wpt_widget extends WP_Widget {
12
+ function __construct() {
13
+
14
+ // add image sizes and load language file
15
+ add_action( 'init', array(&$this, 'wpt_init') );
16
+
17
+ // ajax functions
18
+ add_action('wp_ajax_wpt_widget_content', array(&$this, 'ajax_wpt_widget_content'));
19
+ add_action('wp_ajax_nopriv_wpt_widget_content', array(&$this, 'ajax_wpt_widget_content'));
20
+
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);
28
+ }
29
+
30
+ function wpt_init() {
31
+ load_plugin_textdomain('mts_wpt', false, dirname(plugin_basename(__FILE__)) . '/languages/' );
32
+
33
+ add_image_size( 'wp_review_small', 65, 65, true ); // small thumb
34
+ add_image_size( 'wp_review_large', 320, 240, true ); // large thumb
35
+ }
36
+ function wpt_admin_scripts($hook) {
37
+ if ($hook != 'widgets.php')
38
+ return;
39
+ wp_register_script('wpt_widget_admin', plugins_url('js/wpt-admin.js', __FILE__), array('jquery'));
40
+ wp_enqueue_script('wpt_widget_admin');
41
+ }
42
+ function wpt_register_scripts() {
43
+ // JS
44
+ wp_register_script('wpt_widget', plugins_url('js/wp-tab-widget.js', __FILE__), array('jquery'));
45
+ wp_localize_script( 'wpt_widget', 'wpt',
46
+ array( 'ajax_url' => admin_url( 'admin-ajax.php' ))
47
+ );
48
+ // CSS
49
+ wp_register_style('wpt_widget', plugins_url('css/wp-tab-widget.css', __FILE__), true);
50
+ }
51
+
52
+ function form( $instance ) {
53
+ $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' => 10, 'show_comment_num' => 0, 'show_avatar' => 1) );
54
+ extract($instance);
55
+ ?>
56
+ <div class="wpt_options_form">
57
+
58
+ <h4><?php _e('Select Tabs', 'mts_wpt'); ?></h4>
59
+
60
+ <div class="wpt_select_tabs">
61
+ <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px" for="<?php echo $this->get_field_id("tabs"); ?>_popular">
62
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("tabs"); ?>_popular" name="<?php echo $this->get_field_name("tabs"); ?>[popular]" value="1" <?php if (isset($tabs['popular'])) { checked( 1, $tabs['popular'], true ); } ?> />
63
+ <?php _e( 'Popular Tab', 'mts_wpt'); ?>
64
+ </label>
65
+ <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px;" for="<?php echo $this->get_field_id("tabs"); ?>_recent">
66
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("tabs"); ?>_recent" name="<?php echo $this->get_field_name("tabs"); ?>[recent]" value="1" <?php if (isset($tabs['recent'])) { checked( 1, $tabs['recent'], true ); } ?> />
67
+ <?php _e( 'Recent Tab', 'mts_wpt'); ?>
68
+ </label>
69
+ <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id("tabs"); ?>_comments">
70
+ <input type="checkbox" class="checkbox wpt_enable_comments" id="<?php echo $this->get_field_id("tabs"); ?>_comments" name="<?php echo $this->get_field_name("tabs"); ?>[comments]" value="1" <?php if (isset($tabs['comments'])) { checked( 1, $tabs['comments'], true ); } ?> />
71
+ <?php _e( 'Comments Tab', 'mts_wpt'); ?>
72
+ </label>
73
+ <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id("tabs"); ?>_tags">
74
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("tabs"); ?>_tags" name="<?php echo $this->get_field_name("tabs"); ?>[tags]" value="1" <?php if (isset($tabs['tags'])) { checked( 1, $tabs['tags'], true ); } ?> />
75
+ <?php _e( 'Tags Tab', 'mts_wpt'); ?>
76
+ </label>
77
+ </div>
78
+ <div class="clear"></div>
79
+
80
+ <h4 class="wpt_tab_order_header"><a href="#"><?php _e('Tab Order', 'mts_wpt'); ?></a></h4>
81
+
82
+ <div class="wpt_tab_order" style="display: none;">
83
+
84
+ <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_popular" style="width: 50%;">
85
+ <input id="<?php echo $this->get_field_id('tab_order'); ?>_popular" name="<?php echo $this->get_field_name('tab_order'); ?>[popular]" type="number" min="1" step="1" value="<?php echo $tab_order['popular']; ?>" style="width: 48px;" />
86
+ <?php _e('Popular', 'mts_wpt'); ?>
87
+ </label>
88
+ <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_recent" style="width: 50%;">
89
+ <input id="<?php echo $this->get_field_id('tab_order'); ?>_recent" name="<?php echo $this->get_field_name('tab_order'); ?>[recent]" type="number" min="1" step="1" value="<?php echo $tab_order['recent']; ?>" style="width: 48px;" />
90
+ <?php _e('Recent', 'mts_wpt'); ?>
91
+ </label>
92
+ <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_comments" style="width: 50%;">
93
+ <input id="<?php echo $this->get_field_id('tab_order'); ?>_comments" name="<?php echo $this->get_field_name('tab_order'); ?>[comments]" type="number" min="1" step="1" value="<?php echo $tab_order['comments']; ?>" style="width: 48px;" />
94
+ <?php _e('Comments', 'mts_wpt'); ?>
95
+ </label>
96
+ <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_tags" style="width: 50%;">
97
+ <input id="<?php echo $this->get_field_id('tab_order'); ?>_tags" name="<?php echo $this->get_field_name('tab_order'); ?>[tags]" type="number" min="1" step="1" value="<?php echo $tab_order['tags']; ?>" style="width: 48px;" />
98
+ <?php _e('Tags', 'mts_wpt'); ?>
99
+ </label>
100
+ </div>
101
+ <div class="clear"></div>
102
+
103
+ <h4 class="wpt_advanced_options_header"><a href="#"><?php _e('Advanced Options', 'mts_wpt'); ?></a></h4>
104
+
105
+ <div class="wpt_advanced_options" style="display: none;">
106
+ <p>
107
+ <label for="<?php echo $this->get_field_id("allow_pagination"); ?>">
108
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("allow_pagination"); ?>" name="<?php echo $this->get_field_name("allow_pagination"); ?>" value="1" <?php if (isset($allow_pagination)) { checked( 1, $allow_pagination, true ); } ?> />
109
+ <?php _e( 'Allow pagination', 'mts_wpt'); ?>
110
+ </label>
111
+ </p>
112
+
113
+ <div class="wpt_post_options">
114
+
115
+ <p>
116
+ <label for="<?php echo $this->get_field_id('post_num'); ?>"><?php _e('Number of posts to show:', 'mts_wpt'); ?>
117
+ <br />
118
+ <input id="<?php echo $this->get_field_id('post_num'); ?>" name="<?php echo $this->get_field_name('post_num'); ?>" type="number" min="1" step="1" value="<?php echo $post_num; ?>" />
119
+ </label>
120
+ </p>
121
+
122
+ <p>
123
+ <label for="<?php echo $this->get_field_id("show_thumb"); ?>">
124
+ <input type="checkbox" class="checkbox wpt_show_thumbnails" id="<?php echo $this->get_field_id("show_thumb"); ?>" name="<?php echo $this->get_field_name("show_thumb"); ?>" value="1" <?php if (isset($show_thumb)) { checked( 1, $show_thumb, true ); } ?> />
125
+ <?php _e( 'Show post thumbnails', 'mts_wpt'); ?>
126
+ </label>
127
+ </p>
128
+
129
+ <p class="wpt_thumbnail_size"<?php echo (empty($show_thumb) ? ' style="display: none;"' : ''); ?>>
130
+ <label for="<?php echo $this->get_field_id('thumb_size'); ?>"><?php _e('Thumbnail size:', 'mts_wpt'); ?></label>
131
+ <select id="<?php echo $this->get_field_id('thumb_size'); ?>" name="<?php echo $this->get_field_name('thumb_size'); ?>" style="margin-left: 12px;">
132
+ <option value="small" <?php selected($thumb_size, 'small', true); ?>><?php _e('Small', 'mts_wpt'); ?></option>
133
+ <option value="large" <?php selected($thumb_size, 'large', true); ?>><?php _e('Large', 'mts_wpt'); ?></option>
134
+ </select>
135
+ </p>
136
+
137
+ <p>
138
+ <label for="<?php echo $this->get_field_id("show_date"); ?>">
139
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_date"); ?>" name="<?php echo $this->get_field_name("show_date"); ?>" value="1" <?php if (isset($show_date)) { checked( 1, $show_date, true ); } ?> />
140
+ <?php _e( 'Show post date', 'mts_wpt'); ?>
141
+ </label>
142
+ </p>
143
+
144
+ <p>
145
+ <label for="<?php echo $this->get_field_id("show_comment_num"); ?>">
146
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_comment_num"); ?>" name="<?php echo $this->get_field_name("show_comment_num"); ?>" value="1" <?php if (isset($show_comment_num)) { checked( 1, $show_comment_num, true ); } ?> />
147
+ <?php _e( 'Show number of comments', 'mts_wpt'); ?>
148
+ </label>
149
+ </p>
150
+
151
+ <p>
152
+ <label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
153
+ <input type="checkbox" class="checkbox wpt_show_excerpt" id="<?php echo $this->get_field_id("show_excerpt"); ?>" name="<?php echo $this->get_field_name("show_excerpt"); ?>" value="1" <?php if (isset($show_excerpt)) { checked( 1, $show_excerpt, true ); } ?> />
154
+ <?php _e( 'Show post excerpt', 'mts_wpt'); ?>
155
+ </label>
156
+ </p>
157
+
158
+ <p class="wpt_excerpt_length"<?php echo (empty($show_excerpt) ? ' style="display: none;"' : ''); ?>>
159
+ <label for="<?php echo $this->get_field_id('excerpt_length'); ?>">
160
+ <?php _e('Excerpt length (words):', 'mts_wpt'); ?>
161
+ <br />
162
+ <input type="number" min="1" step="1" id="<?php echo $this->get_field_id('excerpt_length'); ?>" name="<?php echo $this->get_field_name('excerpt_length'); ?>" value="<?php echo $excerpt_length; ?>" />
163
+ </label>
164
+ </p>
165
+
166
+ </div>
167
+ <div class="clear"></div>
168
+
169
+ <div class="wpt_comment_options"<?php echo (empty($tabs['comments']) ? ' style="display: none;"' : ''); ?>>
170
+
171
+ <p>
172
+ <label for="<?php echo $this->get_field_id('comment_num'); ?>">
173
+ <?php _e('Number of comments on Comments Tab:', 'mts_wpt'); ?>
174
+ <br />
175
+ <input type="number" min="1" step="1" id="<?php echo $this->get_field_id('comment_num'); ?>" name="<?php echo $this->get_field_name('comment_num'); ?>" value="<?php echo $comment_num; ?>" />
176
+ </label>
177
+ </p>
178
+
179
+ <p>
180
+ <label for="<?php echo $this->get_field_id("show_avatar"); ?>">
181
+ <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_avatar"); ?>" name="<?php echo $this->get_field_name("show_avatar"); ?>" value="1" <?php if (isset($show_avatar)) { checked( 1, $show_avatar, true ); } ?> />
182
+ <?php _e( 'Show avatars on Comments Tab', 'mts_wpt'); ?>
183
+ </label>
184
+ </p>
185
+ </div><!-- .wpt_comment_options -->
186
+ </div><!-- .wpt_advanced_options -->
187
+ </div><!-- .wpt_options_form -->
188
+ <?php
189
+ }
190
+
191
+ function update( $new_instance, $old_instance ) {
192
+ $instance = $old_instance;
193
+ $instance['tabs'] = $new_instance['tabs'];
194
+ $instance['tab_order'] = $new_instance['tab_order'];
195
+ $instance['allow_pagination'] = $new_instance['allow_pagination'];
196
+ $instance['post_num'] = $new_instance['post_num'];
197
+ $instance['comment_num'] = $new_instance['comment_num'];
198
+ $instance['show_thumb'] = $new_instance['show_thumb'];
199
+ $instance['thumb_size'] = $new_instance['thumb_size'];
200
+ $instance['show_date'] = $new_instance['show_date'];
201
+ $instance['show_excerpt'] = $new_instance['show_excerpt'];
202
+ $instance['excerpt_length'] = $new_instance['excerpt_length'];
203
+ $instance['show_comment_num'] = $new_instance['show_comment_num'];
204
+ $instance['show_avatar'] = $new_instance['show_avatar'];
205
+ return $instance;
206
+ }
207
+ function widget( $args, $instance ) {
208
+ extract($args);
209
+ extract($instance);
210
+ wp_enqueue_script('wpt_widget');
211
+ wp_enqueue_style('wpt_widget');
212
+ if (empty($tabs)) $tabs = array('recent' => 1, 'popular' => 1);
213
+ $tabs_count = count($tabs);
214
+ if ($tabs_count <= 1) {
215
+ $tabs_count = 1;
216
+ } elseif($tabs_count > 3) {
217
+ $tabs_count = 4;
218
+ }
219
+
220
+ $available_tabs = array('popular' => __('Popular', 'mts_wpt'),
221
+ 'recent' => __('Recent', 'mts_wpt'),
222
+ 'comments' => __('Comments', 'mts_wpt'),
223
+ 'tags' => __('Tags', 'mts_wpt'));
224
+
225
+ array_multisort($tab_order, $available_tabs);
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])): ?>
233
+ <li class="tab_title"><a href="#" id="<?php echo $tab; ?>-tab"><?php echo $label; ?></a></li>
234
+ <?php endif; ?>
235
+ <?php } ?>
236
+ </ul> <!--end .tabs-->
237
+ <div class="clear"></div>
238
+ <div class="inside">
239
+ <?php if (!empty($tabs['popular'])): ?>
240
+ <div id="popular-tab-content" class="tab-content">
241
+ </div> <!--end #popular-tab-content-->
242
+ <?php endif; ?>
243
+ <?php if (!empty($tabs['recent'])): ?>
244
+ <div id="recent-tab-content" class="tab-content">
245
+ </div> <!--end #recent-tab-content-->
246
+ <?php endif; ?>
247
+ <?php if (!empty($tabs['comments'])): ?>
248
+ <div id="comments-tab-content" class="tab-content">
249
+ <ul>
250
+ </ul>
251
+ </div> <!--end #comments-tab-content-->
252
+ <?php endif; ?>
253
+ <?php if (!empty($tabs['tags'])): ?>
254
+ <div id="tags-tab-content" class="tab-content">
255
+ <ul>
256
+ </ul>
257
+ </div> <!--end #tags-tab-content-->
258
+ <?php endif; ?>
259
+ <div class="clear"></div>
260
+ </div> <!--end .inside -->
261
+ <div class="clear"></div>
262
+ </div><!--end #tabber -->
263
+ <?php
264
+ // inline script
265
+ // to support multiple instances per page with different settings
266
+
267
+ unset($instance['tabs'], $instance['tab_order']); // unset unneeded
268
+ ?>
269
+ <script type="text/javascript">
270
+ jQuery(function($) {
271
+ $('#<?php echo $widget_id; ?>_content').data('args', <?php echo json_encode($instance); ?>);
272
+ });
273
+ </script>
274
+ <?php echo $after_widget; ?>
275
+ <?php
276
+ }
277
+
278
+
279
+ function ajax_wpt_widget_content() {
280
+ $tab = $_POST['tab'];
281
+ $args = $_POST['args'];
282
+ $page = intval($_POST['page']);
283
+ if ($page < 1)
284
+ $page = 1;
285
+ if (!is_array($args))
286
+ return '';
287
+
288
+ // sanitize args
289
+ $post_num = (empty($args['post_num']) ? 5 : intval($args['post_num']));
290
+ if ($post_num > 20 || $post_num < 1) { // max 20 posts
291
+ $post_num = 5;
292
+ }
293
+ $comment_num = (empty($args['comment_num']) ? 5 : intval($args['comment_num']));
294
+ if ($comment_num > 20 || $comment_num < 1) {
295
+ $comment_num = 5;
296
+ }
297
+ $show_thumb = !empty($args['show_thumb']);
298
+ $thumb_size = $args['thumb_size'];
299
+ if ($thumb_size != 'small' && $thumb_size != 'large') {
300
+ $thumb_size = 'small'; // default
301
+ }
302
+ $show_date = !empty($args['show_date']);
303
+ $show_excerpt = !empty($args['show_excerpt']);
304
+ $excerpt_length = intval($args['excerpt_length']);
305
+ if ($excerpt_length > 50 || $excerpt_length < 1) {
306
+ $excerpt_length = 10;
307
+ }
308
+ $show_comment_num = !empty($args['show_comment_num']);
309
+ $show_avatar = !empty($args['show_avatar']);
310
+ $allow_pagination = !empty($args['allow_pagination']);
311
+
312
+ /* ---------- Tab Contents ---------- */
313
+ switch ($tab) {
314
+
315
+ /* ---------- Popular Posts ---------- */
316
+ case "popular":
317
+ ?>
318
+ <ul>
319
+ <?php
320
+ $popular = new WP_Query( array('ignore_sticky_posts' => 1, 'posts_per_page' => $post_num, 'post_status' => 'publish', 'orderby' => 'comment_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()): ?>
328
+ <?php the_post_thumbnail('wp_review_'.$thumb_size, array('title' => '')); ?>
329
+ <?php else: ?>
330
+ <img src="<?php echo plugins_url('img/'.$thumb_size.'thumb.png', __FILE__); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
331
+ <?php endif; ?>
332
+ </a>
333
+ </div>
334
+ <?php endif; ?>
335
+ <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php echo get_the_title(); ?></a></div>
336
+ <?php if ( $show_date == 1 || $show_comment_num == 1) : ?>
337
+ <div class="wpt-postmeta">
338
+ <?php if ( $show_date == 1 ) : ?>
339
+ <?php the_time('F j, Y'); ?>
340
+ <?php endif; ?>
341
+ <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
342
+ &bull;
343
+ <?php endif; ?>
344
+ <?php if ( $show_comment_num == 1 ) : ?>
345
+ <?php echo comments_number(__('No Comment','mts_wpt'), __('One Comment','mts_wpt'), '<span class="comments-number">%</span> '.__('Comments','mts_wpt'));?>
346
+ <?php endif; ?>
347
+ </div> <!--end .entry-meta-->
348
+ <?php endif; ?>
349
+
350
+ <?php if ( $show_excerpt == 1 ) : ?>
351
+ <div class="wpt_excerpt">
352
+ <p><?php echo $this->excerpt($excerpt_length); ?></p>
353
+ </div>
354
+ <?php endif; ?>
355
+
356
+ <div class="clear"></div>
357
+ </li>
358
+ <?php $post_num++; endwhile; wp_reset_query(); ?>
359
+ </ul>
360
+ <div class="clear"></div>
361
+ <?php if ($allow_pagination) : ?>
362
+ <?php $this->tab_pagination($page, $last_page); ?>
363
+ <?php endif; ?>
364
+ <?php
365
+ break;
366
+
367
+ /* ---------- Recent Posts ---------- */
368
+ case "recent":
369
+ ?>
370
+ <ul>
371
+ <?php
372
+ $recent = new WP_Query('posts_per_page='. $post_num .'&orderby=post_date&order=desc&post_status=publish&paged='. $page);
373
+ $last_page = $recent->max_num_pages;
374
+ while ($recent->have_posts()) : $recent->the_post();
375
+ ?>
376
+ <li>
377
+ <?php if ( $show_thumb == 1 ) : ?>
378
+ <div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
379
+ <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
380
+ <?php if(has_post_thumbnail()): ?>
381
+ <?php the_post_thumbnail('wp_review_'.$thumb_size, array('title' => '')); ?>
382
+ <?php else: ?>
383
+ <img src="<?php echo plugins_url('img/'.$thumb_size.'thumb.png', __FILE__); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
384
+ <?php endif; ?>
385
+ </a>
386
+ </div>
387
+ <?php endif; ?>
388
+ <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php echo get_the_title(); ?></a></div>
389
+ <?php if ( $show_date == 1 || $show_comment_num == 1) : ?>
390
+ <div class="wpt-postmeta">
391
+ <?php if ( $show_date == 1 ) : ?>
392
+ <?php the_time('F j, Y'); ?>
393
+ <?php endif; ?>
394
+ <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
395
+ &bull;
396
+ <?php endif; ?>
397
+ <?php if ( $show_comment_num == 1 ) : ?>
398
+ <?php echo comments_number(__('No Comment','mts_wpt'), __('One Comment','mts_wpt'), '<span class="comm">%</span> '.__('Comments','mts_wpt'));?>
399
+ <?php endif; ?>
400
+ </div> <!--end .entry-meta-->
401
+ <?php endif; ?>
402
+
403
+ <?php if ( $show_excerpt == 1 ) : ?>
404
+ <div class="wpt_excerpt">
405
+ <p><?php echo $this->excerpt($excerpt_length); ?></p>
406
+ </div>
407
+ <?php endif; ?>
408
+
409
+ <div class="clear"></div>
410
+ </li>
411
+ <?php endwhile; wp_reset_query(); ?>
412
+ </ul>
413
+ <div class="clear"></div>
414
+ <?php if ($allow_pagination) : ?>
415
+ <?php $this->tab_pagination($page, $last_page); ?>
416
+ <?php endif; ?>
417
+ <?php
418
+ break;
419
+
420
+ /* ---------- Latest Comments ---------- */
421
+ case "comments":
422
+ ?>
423
+ <ul>
424
+ <?php
425
+ $no_comments = false;
426
+ $avatar_size = 65;
427
+ $comment_length = 90; // max length for comments
428
+ $comments_total = new WP_Comment_Query();
429
+ $comments_total_number = $comments_total->query(array('count' => 1));
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
+
437
+ <?php if ($show_avatar) : ?>
438
+ <div class="wpt_avatar">
439
+ <a href="<?php echo get_comment_link($comment->comment_ID); ?>">
440
+ <?php echo get_avatar( $comment->comment_author_email, $avatar_size ); ?>
441
+ </a>
442
+ </div>
443
+ <?php endif; ?>
444
+ <div class="wpt_comment_meta">
445
+ <a href="<?php echo get_comment_link($comment->comment_ID); ?>">
446
+ <span class="wpt_comment_author"><?php echo get_comment_author( $comment->comment_ID ); ?> </span> - <span class="wpt_comment_post"><?php echo get_the_title($comment->comment_post_ID); ?></span>
447
+ </a>
448
+ </div>
449
+ <div class="wpt_comment_content">
450
+ <p><?php echo $this->truncate(strip_tags(apply_filters( 'get_comment_text', $comment->comment_content )), $comment_length);?></p>
451
+ </div>
452
+ </a>
453
+ <div class="clear"></div>
454
+ </li>
455
+ <?php endforeach; else : ?>
456
+ <li>
457
+ <div class="no-comments"><?php _e('No comments yet.', 'mts_wpt'); ?></div>
458
+ </li>
459
+ <?php $no_comments = true;
460
+ endif; ?>
461
+ </ul>
462
+ <?php if ($allow_pagination && !$no_comments) : ?>
463
+ <?php $this->tab_pagination($page, $last_page); ?>
464
+ <?php endif; ?>
465
+ <?php
466
+ break;
467
+
468
+ /* ---------- Tags ---------- */
469
+ case "tags":
470
+ ?>
471
+ <ul>
472
+ <?php
473
+ $tags = get_tags(array('get'=>'all'));
474
+ if($tags) {
475
+ foreach ($tags as $tag): ?>
476
+ <li><a href="<?php echo get_term_link($tag); ?>"><?php echo $tag->name; ?></a></li>
477
+ <?php
478
+ endforeach;
479
+ } else {
480
+ _e('No tags created.', 'mts_wpt');
481
+ }
482
+ ?>
483
+ </ul>
484
+ <?php
485
+ break;
486
+ }
487
+ die(); // required to return a proper result
488
+ }
489
+ function tab_pagination($page, $last_page) {
490
+ ?>
491
+ <div class="wpt-pagination">
492
+ <?php if ($page > 1) : ?>
493
+ <a href="#" class="previous"><span><?php _e('&laquo; Previous', 'mts_wpt'); ?></span></a>
494
+ <?php endif; ?>
495
+ <?php if ($page != $last_page) : ?>
496
+ <a href="#" class="next"><span><?php _e('Next &raquo;', 'mts_wpt'); ?></span></a>
497
+ <?php endif; ?>
498
+ </div>
499
+ <div class="clear"></div>
500
+ <input type="hidden" class="page_num" name="page_num" value="<?php echo $page; ?>" />
501
+ <?php
502
+ }
503
+
504
+ function excerpt($limit = 10) {
505
+ $excerpt = explode(' ', get_the_excerpt(), $limit);
506
+ if (count($excerpt)>=$limit) {
507
+ array_pop($excerpt);
508
+ $excerpt = implode(" ",$excerpt).'...';
509
+ } else {
510
+ $excerpt = implode(" ",$excerpt);
511
+ }
512
+ $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
513
+ return $excerpt;
514
+ }
515
+ function truncate($str, $length = 24) {
516
+ if (mb_strlen($str) > $length) {
517
+ return mb_substr($str, 0, $length).'...';
518
+ } else {
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() {
528
+ unregister_widget('mts_Widget_Tabs_2');
529
+ unregister_widget('mts_Widget_Tabs');
530
+ }
531
+
532
+ ?>