WP Tab Widget - Version 1.2.11

Version Description

[Oct 31, 2020] = * Fixed PHP notices when saving widget * Removed an option to show 'Powered by' credit in the frontend

Download this release

Release Info

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

Code changes from version 1.2.10 to 1.2.11

css/wp-tab-widget.css CHANGED
@@ -1,245 +1,245 @@
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 {
10
- position: relative;
11
- border: 1px solid #E4E4E4;
12
- }
13
- .wpt_widget_content img {
14
- max-width: 100%;
15
- height: auto;
16
- }
17
- .wpt_widget_content a {
18
- color: #444;
19
- }
20
- .wpt_widget_content ul.wpt-tabs li {
21
- list-style: none;
22
- display: block;
23
- width: 50%;
24
- float: left;
25
- text-align: center;
26
- margin: 0;
27
- padding: 0 !important;
28
- }
29
- .wpt_widget_content ul.has-1-tabs li {
30
- width: 100%;
31
- float: none;
32
- margin: 0 auto;
33
- }
34
- .wpt_widget_content ul.has-2-tabs li {
35
-
36
- }
37
- .wpt_widget_content ul.has-3-tabs li {
38
- width: 33.33%;
39
- }
40
- .wpt_widget_content ul.has-4-tabs li {
41
- width: 50%;
42
- }
43
- .wpt_widget_content .has-4-tabs .tab_title.selected a {
44
- border-bottom: 1px solid #E4E4E4;
45
- }
46
- .wpt_widget_content .has-4-tabs .tab_title:nth-child(3) a {
47
- border-left: 0;
48
- }
49
- .wpt_widget_content .tab_title a {
50
- display: block;
51
- background: #f0f0f0;
52
- border-left: 1px solid #E4E4E4;
53
- border-bottom: 1px solid #E4E4E4;
54
- padding: 2px 0 4px;
55
- line-height: 2.4;
56
- text-decoration: none;
57
- position: relative;
58
- font-weight: bold;
59
- }
60
- .wpt_widget_content .tab_title:first-child a {
61
- margin-left: 0;
62
- border-left: 0;
63
- }
64
- .wpt_widget_content .tab_title.selected a {
65
- background: #fff;
66
- border-bottom: 1px solid #fff;
67
- }
68
- .wpt_widget_content .inside {
69
- background: #fff;
70
- padding-top: 10px;
71
- }
72
- .wpt_widget_content .tab-content li {
73
- list-style-type: none;
74
- float: left;
75
- width: 100%;
76
- -moz-box-sizing: border-box;
77
- box-sizing: border-box;
78
- margin: 0 0 11px 0;
79
- padding: 0px 15px 15px 15px;
80
- border-bottom: 1px solid #E4E4E4;
81
- text-align: left;
82
- color: #444;
83
- background: none;
84
- position: relative;
85
- }
86
- .wpt_widget_content .tab-content li:last-child {
87
- border: none;
88
- margin-bottom: 0;
89
- }
90
- .wpt_widget_content .tab-content li:first-child {
91
- padding-top: 5px;
92
- }
93
-
94
- .wpt_thumb_small {
95
- float: left;
96
- margin-right: 12px;
97
- padding-top: 4px;
98
- width: 65px;
99
- height: 65px;
100
- overflow: hidden;
101
- }
102
- .wpt_thumb_large {
103
- float: none;
104
- max-width: 100%;
105
- display: inline-block;
106
- margin-bottom: 4px;
107
- position: relative;
108
- }
109
- .wpt_widget_content .entry-title {
110
- font-weight: bold;
111
- margin: 0;
112
- padding: 0;
113
- }
114
- .wpt_widget_content .wpt-postmeta, .wpt_comment_content, .wpt_excerpt {
115
- color: #999;
116
- font-size: 13px;
117
- }
118
- .wpt_widget_content .wp-post-image {
119
- margin: 0 !important;
120
- }
121
-
122
- /* Comments */
123
- .wpt_avatar {
124
- margin-right: 10px;
125
- float: left;
126
- margin-top: 4px;
127
- }
128
- .wpt_comment_content p, .wpt_excerpt p {
129
- margin-bottom: 0;
130
- }
131
- .wpt_comment_meta {
132
- font-weight: bold;
133
- }
134
-
135
- /* Tags tab */
136
- .wpt_widget_content #tags-tab-content {
137
- padding-bottom: 10px;
138
- }
139
- .wpt_widget_content #tags-tab-content ul {
140
- margin: 0;
141
- overflow: hidden;
142
- padding: 0 10px;
143
- text-align: center;
144
- font-size: 0;
145
- line-height: 0;
146
- }
147
- .wpt_widget_content #tags-tab-content ul li {
148
- width: auto;
149
- color: #fff;
150
- margin-bottom: 0;
151
- list-style: none;
152
- display: inline-block;
153
- padding: 0;
154
- margin: 3px 3px 0 0;
155
- float: none;
156
- font-size: 13px;
157
- }
158
- .wpt_widget_content #tags-tab-content ul li a {
159
- padding: 12px 10px;
160
- background: #f0f0f0;
161
- white-space: nowrap;
162
- display: block;
163
- }
164
-
165
- /* Pagination */
166
- .wpt_widget_content .wpt-pagination {
167
- margin: 0;
168
- width: 100%;
169
- padding-top: 0;
170
- padding-bottom: 15px;
171
- float: left;
172
- }
173
- .wpt_widget_content .wpt-pagination a {
174
- margin: 0 15px;
175
- }
176
- .wpt-pagination a.next {
177
- float: right;
178
- }
179
-
180
- /* Loading... */
181
- .wpt-loading {
182
- min-height: 120px;
183
- }
184
- .wpt-loading:before {
185
- content: "";
186
- display: block;
187
- position: absolute;
188
- top: 0;
189
- right: 0;
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
- }
239
-
240
- .wpt_show_love {
241
- font-size: 12px;
242
- font-style: italic;
243
- padding: 5px;
244
- margin: 0 10px;
245
  }
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 {
10
+ position: relative;
11
+ border: 1px solid #E4E4E4;
12
+ }
13
+ .wpt_widget_content img {
14
+ max-width: 100%;
15
+ height: auto;
16
+ }
17
+ .wpt_widget_content a {
18
+ color: #444;
19
+ }
20
+ .wpt_widget_content ul.wpt-tabs li {
21
+ list-style: none;
22
+ display: block;
23
+ width: 50%;
24
+ float: left;
25
+ text-align: center;
26
+ margin: 0;
27
+ padding: 0 !important;
28
+ }
29
+ .wpt_widget_content ul.has-1-tabs li {
30
+ width: 100%;
31
+ float: none;
32
+ margin: 0 auto;
33
+ }
34
+ .wpt_widget_content ul.has-2-tabs li {
35
+
36
+ }
37
+ .wpt_widget_content ul.has-3-tabs li {
38
+ width: 33.33%;
39
+ }
40
+ .wpt_widget_content ul.has-4-tabs li {
41
+ width: 50%;
42
+ }
43
+ .wpt_widget_content .has-4-tabs .tab_title.selected a {
44
+ border-bottom: 1px solid #E4E4E4;
45
+ }
46
+ .wpt_widget_content .has-4-tabs .tab_title:nth-child(3) a {
47
+ border-left: 0;
48
+ }
49
+ .wpt_widget_content .tab_title a {
50
+ display: block;
51
+ background: #f0f0f0;
52
+ border-left: 1px solid #E4E4E4;
53
+ border-bottom: 1px solid #E4E4E4;
54
+ padding: 2px 0 4px;
55
+ line-height: 2.4;
56
+ text-decoration: none;
57
+ position: relative;
58
+ font-weight: bold;
59
+ }
60
+ .wpt_widget_content .tab_title:first-child a {
61
+ margin-left: 0;
62
+ border-left: 0;
63
+ }
64
+ .wpt_widget_content .tab_title.selected a {
65
+ background: #fff;
66
+ border-bottom: 1px solid #fff;
67
+ }
68
+ .wpt_widget_content .inside {
69
+ background: #fff;
70
+ padding-top: 10px;
71
+ }
72
+ .wpt_widget_content .tab-content li {
73
+ list-style-type: none;
74
+ float: left;
75
+ width: 100%;
76
+ -moz-box-sizing: border-box;
77
+ box-sizing: border-box;
78
+ margin: 0 0 11px 0;
79
+ padding: 0px 15px 15px 15px;
80
+ border-bottom: 1px solid #E4E4E4;
81
+ text-align: left;
82
+ color: #444;
83
+ background: none;
84
+ position: relative;
85
+ }
86
+ .wpt_widget_content .tab-content li:last-child {
87
+ border: none;
88
+ margin-bottom: 0;
89
+ }
90
+ .wpt_widget_content .tab-content li:first-child {
91
+ padding-top: 5px;
92
+ }
93
+
94
+ .wpt_thumb_small {
95
+ float: left;
96
+ margin-right: 12px;
97
+ padding-top: 4px;
98
+ width: 65px;
99
+ height: 65px;
100
+ overflow: hidden;
101
+ }
102
+ .wpt_thumb_large {
103
+ float: none;
104
+ max-width: 100%;
105
+ display: inline-block;
106
+ margin-bottom: 4px;
107
+ position: relative;
108
+ }
109
+ .wpt_widget_content .entry-title {
110
+ font-weight: bold;
111
+ margin: 0;
112
+ padding: 0;
113
+ }
114
+ .wpt_widget_content .wpt-postmeta, .wpt_comment_content, .wpt_excerpt {
115
+ color: #999;
116
+ font-size: 13px;
117
+ }
118
+ .wpt_widget_content .wp-post-image {
119
+ margin: 0 !important;
120
+ }
121
+
122
+ /* Comments */
123
+ .wpt_avatar {
124
+ margin-right: 10px;
125
+ float: left;
126
+ margin-top: 4px;
127
+ }
128
+ .wpt_comment_content p, .wpt_excerpt p {
129
+ margin-bottom: 0;
130
+ }
131
+ .wpt_comment_meta {
132
+ font-weight: bold;
133
+ }
134
+
135
+ /* Tags tab */
136
+ .wpt_widget_content #tags-tab-content {
137
+ padding-bottom: 10px;
138
+ }
139
+ .wpt_widget_content #tags-tab-content ul {
140
+ margin: 0;
141
+ overflow: hidden;
142
+ padding: 0 10px;
143
+ text-align: center;
144
+ font-size: 0;
145
+ line-height: 0;
146
+ }
147
+ .wpt_widget_content #tags-tab-content ul li {
148
+ width: auto;
149
+ color: #fff;
150
+ margin-bottom: 0;
151
+ list-style: none;
152
+ display: inline-block;
153
+ padding: 0;
154
+ margin: 3px 3px 0 0;
155
+ float: none;
156
+ font-size: 13px;
157
+ }
158
+ .wpt_widget_content #tags-tab-content ul li a {
159
+ padding: 12px 10px;
160
+ background: #f0f0f0;
161
+ white-space: nowrap;
162
+ display: block;
163
+ }
164
+
165
+ /* Pagination */
166
+ .wpt_widget_content .wpt-pagination {
167
+ margin: 0;
168
+ width: 100%;
169
+ padding-top: 0;
170
+ padding-bottom: 15px;
171
+ float: left;
172
+ }
173
+ .wpt_widget_content .wpt-pagination a {
174
+ margin: 0 15px;
175
+ }
176
+ .wpt-pagination a.next {
177
+ float: right;
178
+ }
179
+
180
+ /* Loading... */
181
+ .wpt-loading {
182
+ min-height: 120px;
183
+ }
184
+ .wpt-loading:before {
185
+ content: "";
186
+ display: block;
187
+ position: absolute;
188
+ top: 0;
189
+ right: 0;
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
+ }
239
+
240
+ .wpt_show_love {
241
+ font-size: 12px;
242
+ font-style: italic;
243
+ padding: 5px;
244
+ margin: 0 10px;
245
  }
img/largethumb.png CHANGED
File without changes
img/smallthumb.png CHANGED
File without changes
js/wp-tab-widget.js CHANGED
@@ -1,69 +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
  });
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 CHANGED
File without changes
languages/default.po CHANGED
@@ -1,165 +1,165 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: WP Tab Widget by MyThemeShop\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2016-03-27 16:20+0100\n"
6
- "PO-Revision-Date: 2016-03-27 16:20+0100\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.8.1\n"
16
- "X-Poedit-SearchPath-0: ..\n"
17
-
18
- #: ../wp-tab-widget.php:25
19
- msgid "Display popular posts, recent posts, comments, and tags in tabbed format."
20
- msgstr ""
21
-
22
- #: ../wp-tab-widget.php:27
23
- msgid "WP Tab Widget by MyThemeShop"
24
- msgstr ""
25
-
26
- #: ../wp-tab-widget.php:75
27
- msgid "Select Tabs"
28
- msgstr ""
29
-
30
- #: ../wp-tab-widget.php:80
31
- msgid "Popular Tab"
32
- msgstr ""
33
-
34
- #: ../wp-tab-widget.php:84
35
- msgid "Recent Tab"
36
- msgstr ""
37
-
38
- #: ../wp-tab-widget.php:88
39
- msgid "Comments Tab"
40
- msgstr ""
41
-
42
- #: ../wp-tab-widget.php:92
43
- msgid "Tags Tab"
44
- msgstr ""
45
-
46
- #: ../wp-tab-widget.php:97
47
- msgid "Tab Order"
48
- msgstr ""
49
-
50
- #: ../wp-tab-widget.php:103 ../wp-tab-widget.php:253
51
- msgid "Popular"
52
- msgstr ""
53
-
54
- #: ../wp-tab-widget.php:107 ../wp-tab-widget.php:254
55
- msgid "Recent"
56
- msgstr ""
57
-
58
- #: ../wp-tab-widget.php:111 ../wp-tab-widget.php:255 ../wp-tab-widget.php:395
59
- #: ../wp-tab-widget.php:448
60
- msgid "Comments"
61
- msgstr ""
62
-
63
- #: ../wp-tab-widget.php:115 ../wp-tab-widget.php:256
64
- msgid "Tags"
65
- msgstr ""
66
-
67
- #: ../wp-tab-widget.php:120
68
- msgid "Advanced Options"
69
- msgstr ""
70
-
71
- #: ../wp-tab-widget.php:126
72
- msgid "Allow pagination"
73
- msgstr ""
74
-
75
- #: ../wp-tab-widget.php:133
76
- msgid "Number of posts to show:"
77
- msgstr ""
78
-
79
- #: ../wp-tab-widget.php:140
80
- msgid "Title length (words):"
81
- msgstr ""
82
-
83
- #: ../wp-tab-widget.php:149
84
- msgid "Show post thumbnails"
85
- msgstr ""
86
-
87
- #: ../wp-tab-widget.php:154
88
- msgid "Thumbnail size:"
89
- msgstr ""
90
-
91
- #: ../wp-tab-widget.php:156
92
- msgid "Small"
93
- msgstr ""
94
-
95
- #: ../wp-tab-widget.php:157
96
- msgid "Large"
97
- msgstr ""
98
-
99
- #: ../wp-tab-widget.php:164
100
- msgid "Show post date"
101
- msgstr ""
102
-
103
- #: ../wp-tab-widget.php:171
104
- msgid "Show number of comments"
105
- msgstr ""
106
-
107
- #: ../wp-tab-widget.php:178
108
- msgid "Show post excerpt"
109
- msgstr ""
110
-
111
- #: ../wp-tab-widget.php:184
112
- msgid "Excerpt length (words):"
113
- msgstr ""
114
-
115
- #: ../wp-tab-widget.php:197
116
- msgid "Number of comments on Comments Tab:"
117
- msgstr ""
118
-
119
- #: ../wp-tab-widget.php:206
120
- msgid "Show avatars on Comments Tab"
121
- msgstr ""
122
-
123
- #: ../wp-tab-widget.php:214
124
- msgid "Show Some Love (Powered by Tab Widget Pro)"
125
- msgstr ""
126
-
127
- #: ../wp-tab-widget.php:296
128
- msgid "Powered by WP Tab Widget"
129
- msgstr ""
130
-
131
- #: ../wp-tab-widget.php:331
132
- msgid "Unable to load tab content"
133
- msgstr ""
134
-
135
- #: ../wp-tab-widget.php:395 ../wp-tab-widget.php:448
136
- msgid "No Comment"
137
- msgstr ""
138
-
139
- #: ../wp-tab-widget.php:395 ../wp-tab-widget.php:448
140
- msgid "One Comment"
141
- msgstr ""
142
-
143
- #: ../wp-tab-widget.php:512
144
- msgid "No comments yet."
145
- msgstr ""
146
-
147
- #: ../wp-tab-widget.php:535
148
- msgid "No tags created."
149
- msgstr ""
150
-
151
- #: ../wp-tab-widget.php:548
152
- msgid "&laquo; Previous"
153
- msgstr ""
154
-
155
- #: ../wp-tab-widget.php:551
156
- msgid "Next &raquo;"
157
- msgstr ""
158
-
159
- #: ../wp-tab-widget.php:690
160
- msgid "Like WP Tab Widget? You will <strong>LOVE WP Tab Widget Pro</strong>!"
161
- msgstr ""
162
-
163
- #: ../wp-tab-widget.php:690
164
- msgid "Click here for all the exciting features."
165
- msgstr ""
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Tab Widget by MyThemeShop\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2016-03-27 16:20+0100\n"
6
+ "PO-Revision-Date: 2016-03-27 16:20+0100\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.8.1\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+
18
+ #: ../wp-tab-widget.php:25
19
+ msgid "Display popular posts, recent posts, comments, and tags in tabbed format."
20
+ msgstr ""
21
+
22
+ #: ../wp-tab-widget.php:27
23
+ msgid "WP Tab Widget by MyThemeShop"
24
+ msgstr ""
25
+
26
+ #: ../wp-tab-widget.php:75
27
+ msgid "Select Tabs"
28
+ msgstr ""
29
+
30
+ #: ../wp-tab-widget.php:80
31
+ msgid "Popular Tab"
32
+ msgstr ""
33
+
34
+ #: ../wp-tab-widget.php:84
35
+ msgid "Recent Tab"
36
+ msgstr ""
37
+
38
+ #: ../wp-tab-widget.php:88
39
+ msgid "Comments Tab"
40
+ msgstr ""
41
+
42
+ #: ../wp-tab-widget.php:92
43
+ msgid "Tags Tab"
44
+ msgstr ""
45
+
46
+ #: ../wp-tab-widget.php:97
47
+ msgid "Tab Order"
48
+ msgstr ""
49
+
50
+ #: ../wp-tab-widget.php:103 ../wp-tab-widget.php:253
51
+ msgid "Popular"
52
+ msgstr ""
53
+
54
+ #: ../wp-tab-widget.php:107 ../wp-tab-widget.php:254
55
+ msgid "Recent"
56
+ msgstr ""
57
+
58
+ #: ../wp-tab-widget.php:111 ../wp-tab-widget.php:255 ../wp-tab-widget.php:395
59
+ #: ../wp-tab-widget.php:448
60
+ msgid "Comments"
61
+ msgstr ""
62
+
63
+ #: ../wp-tab-widget.php:115 ../wp-tab-widget.php:256
64
+ msgid "Tags"
65
+ msgstr ""
66
+
67
+ #: ../wp-tab-widget.php:120
68
+ msgid "Advanced Options"
69
+ msgstr ""
70
+
71
+ #: ../wp-tab-widget.php:126
72
+ msgid "Allow pagination"
73
+ msgstr ""
74
+
75
+ #: ../wp-tab-widget.php:133
76
+ msgid "Number of posts to show:"
77
+ msgstr ""
78
+
79
+ #: ../wp-tab-widget.php:140
80
+ msgid "Title length (words):"
81
+ msgstr ""
82
+
83
+ #: ../wp-tab-widget.php:149
84
+ msgid "Show post thumbnails"
85
+ msgstr ""
86
+
87
+ #: ../wp-tab-widget.php:154
88
+ msgid "Thumbnail size:"
89
+ msgstr ""
90
+
91
+ #: ../wp-tab-widget.php:156
92
+ msgid "Small"
93
+ msgstr ""
94
+
95
+ #: ../wp-tab-widget.php:157
96
+ msgid "Large"
97
+ msgstr ""
98
+
99
+ #: ../wp-tab-widget.php:164
100
+ msgid "Show post date"
101
+ msgstr ""
102
+
103
+ #: ../wp-tab-widget.php:171
104
+ msgid "Show number of comments"
105
+ msgstr ""
106
+
107
+ #: ../wp-tab-widget.php:178
108
+ msgid "Show post excerpt"
109
+ msgstr ""
110
+
111
+ #: ../wp-tab-widget.php:184
112
+ msgid "Excerpt length (words):"
113
+ msgstr ""
114
+
115
+ #: ../wp-tab-widget.php:197
116
+ msgid "Number of comments on Comments Tab:"
117
+ msgstr ""
118
+
119
+ #: ../wp-tab-widget.php:206
120
+ msgid "Show avatars on Comments Tab"
121
+ msgstr ""
122
+
123
+ #: ../wp-tab-widget.php:214
124
+ msgid "Show Some Love (Powered by Tab Widget Pro)"
125
+ msgstr ""
126
+
127
+ #: ../wp-tab-widget.php:296
128
+ msgid "Powered by WP Tab Widget"
129
+ msgstr ""
130
+
131
+ #: ../wp-tab-widget.php:331
132
+ msgid "Unable to load tab content"
133
+ msgstr ""
134
+
135
+ #: ../wp-tab-widget.php:395 ../wp-tab-widget.php:448
136
+ msgid "No Comment"
137
+ msgstr ""
138
+
139
+ #: ../wp-tab-widget.php:395 ../wp-tab-widget.php:448
140
+ msgid "One Comment"
141
+ msgstr ""
142
+
143
+ #: ../wp-tab-widget.php:512
144
+ msgid "No comments yet."
145
+ msgstr ""
146
+
147
+ #: ../wp-tab-widget.php:535
148
+ msgid "No tags created."
149
+ msgstr ""
150
+
151
+ #: ../wp-tab-widget.php:548
152
+ msgid "&laquo; Previous"
153
+ msgstr ""
154
+
155
+ #: ../wp-tab-widget.php:551
156
+ msgid "Next &raquo;"
157
+ msgstr ""
158
+
159
+ #: ../wp-tab-widget.php:690
160
+ msgid "Like WP Tab Widget? You will <strong>LOVE WP Tab Widget Pro</strong>!"
161
+ msgstr ""
162
+
163
+ #: ../wp-tab-widget.php:690
164
+ msgid "Click here for all the exciting features."
165
+ msgstr ""
readme.txt CHANGED
@@ -1,152 +1,157 @@
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: 4.0
6
- Tested up to: 4.9.5
7
- Stable tag: 1.2.10
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
-
44
- All support for this plugin is provided through our forums. If you have not registered yet, you can do so here for **FREE** <br>
45
- <a href=“https://mythemeshop.com/#signup”>https://mythemeshop.com/#signup</a>
46
-
47
- If after checking our Free WordPress video tutorials here:<br>
48
- <a href=“https://mythemeshop.com/wordpress-101/”>https://mythemeshop.com/wordpress-101/</a><br>
49
- &<br>
50
- <a href=“https://community.mythemeshop.com/tutorials/category/2-free-video-tutorials/“>https://community.mythemeshop.com/tutorials/category/2-free-video-tutorials/</a><br>
51
- <br>
52
- you are still stuck, please feel free to open a new thread, and a member of our support team will be happy to help.<br>
53
-
54
- Support link:<br>
55
- <a href=“https://community.mythemeshop.com/forum/11-free-plugin-support/”>https://community.mythemeshop.com/forum/11-free-plugin-support/</a><br>
56
- <br>
57
-
58
- = Help to make it better =
59
-
60
- 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.
61
-
62
- GitHub link: <a href="https://github.com/MyThemeShopTeam/WP-Tab-Widget">https://github.com/MyThemeShopTeam/WP-Tab-Widget</a>
63
-
64
- = Feedback =
65
- 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>
66
-
67
- == Installation ==
68
-
69
- This section describes how to install the plugin and get it working.
70
-
71
- 1. Upload the `wp-tab-widget` folder to the to the `/wp-content/plugins/` directory
72
- 2. Activate the plugin through the 'Plugins' menu in WordPress
73
- 3. You can see **WP Tab Widget by MyThemeShop** widget in widgets section.
74
- 4. Add it in sidebar and footer and configure as you want.
75
- 5. Enjoy!
76
-
77
- == Frequently Asked Questions ==
78
-
79
- = Plugin is not working =
80
-
81
- 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.
82
-
83
- = Plugins is consuming too much resources =
84
-
85
- The pageview is incremented on the database everytime a user visits a page but this can start getting quite expensive on high-traffic websites. We've added the filter `wpt_sampling_rate` which you can use to lower the sampling rate from the default <strong>100%</strong>. Note that setting this value too low will result to innacurate pageviews.
86
-
87
- `
88
- <?php
89
-
90
- function wpt_my_sampling_rate( $rate ) {
91
- // Reduce the percentage of pageviews recorded to 80%.
92
- return 80;
93
- }
94
- add_filter( 'wpt_sampling_rate', 'wpt_my_sampling_rate' );
95
- `
96
-
97
- == Screenshots ==
98
-
99
- 1. WP Tab Widget Settings
100
- 2. WP Tab Widget
101
-
102
- == Changelog ==
103
-
104
- = 1.2.10 [June 30, 2018] =
105
- * Changed admin notices
106
- * Fixed deprecated notice
107
-
108
- = 1.2.9 [June 29, 2018] =
109
- * Updated admin notices
110
-
111
- = 1.2.8 (Apr 20, 2018) =
112
- * Fixed compatibility with PHP 7
113
- * Checked compatibility with WordPress v4.9.5
114
- * Improved Code
115
-
116
- = 1.2.7 (Feb 03, 2017) =
117
- * Added new wpt_sampling_rate filter. See the FAQ section on how this works.
118
-
119
- = 1.2.6 (Jan 28, 2017) =
120
- * Updated view counter function
121
-
122
- = 1.2.5 (Apr 06, 2016) =
123
- * Added missing Pro version image
124
-
125
- = 1.2.4 (Mar 27, 2016) =
126
- * Replaced “comm” CSS class with “comments-number” on comment count in Recent tab
127
- * Added “Show Some Love” option
128
-
129
- = 1.2.3 (Mar 22, 2016) =
130
- * Fixed issue where tab content couldn’t be loaded on servers with non UTF8 character encoding
131
- * List only comments from default comment type in Comments tab
132
- * Prevent conflict with Pro version
133
- * Added Notification & Banner for Pro Version
134
-
135
- = 1.2.2 (Aug 21, 2015) =
136
- * Changed text domain to make plugin compatible with WordPress Language Packs
137
-
138
- = 1.2.1 (Aug 19, 2015) =
139
- * Switched to PHP 5 style constructor method for the widget class
140
-
141
- = 1.2 (Oct 15, 2014) =
142
- * Added Title Length option
143
- * Fixed post view count compatibility with themes
144
-
145
- = 1.1 (Oct 1, 2014) =
146
- * Popular posts will be decided by number of views
147
- * Added loading effect
148
- * Fixed small bugs
149
- * Performance improvement
150
-
151
- = 1.0 (Mar 24, 2014) =
152
- * Plugin released
 
 
 
 
 
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: 5.6
6
+ Tested up to: 5.9
7
+ Requires PHP: 7.2
8
+ Stable tag: 1.2.11
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+
12
+ WP Tab Widget is the AJAXified plugin which loads content by demand, and thus it makes the plugin incredibly lightweight.
13
+
14
+ == Description ==
15
+
16
+ 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.
17
+
18
+ **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.
19
+
20
+ = Live demos: =
21
+ See WP Tab Widget in action on our demo pages:
22
+ <a href="http://demo.mythemeshop.com/truepixel/">http://demo.mythemeshop.com/truepixel/</a>
23
+
24
+ = Why WP Tab from <a href="http://mythemeshop.com/">MyThemeShop</a>: =
25
+ * It's the only free plugin which offers so many features
26
+ * It loads the content by demand
27
+ * Choose between, Popular, Recent, Comments, Tags tab
28
+ * In-built Pagination System
29
+ * Fully Responsive
30
+ * Control the order of the tabs
31
+ * Change the number of tabs to show
32
+ * Control the number of posts to show
33
+ * Super light weight
34
+ * In-built cache system, once a tab is loaded, it stays in the memory
35
+ * Cool effects
36
+ * Easy to modify the CSS to better fit your theme style
37
+ * Choose between 3 unique styles of small, big or no thumbnails
38
+ * Show/Hide post date
39
+ * Show/Hide number of comments
40
+ * Show/Hide post excerpt
41
+ * Position it anywhere where a widget is configured in your theme.
42
+
43
+ = Support =
44
+
45
+ All support for this plugin is provided through our forums. If you have not registered yet, you can do so here for **FREE** <br>
46
+ <a href=“https://mythemeshop.com/#signup”>https://mythemeshop.com/#signup</a>
47
+
48
+ If after checking our Free WordPress video tutorials here:<br>
49
+ <a href=“https://mythemeshop.com/wordpress-101/”>https://mythemeshop.com/wordpress-101/</a><br>
50
+ &<br>
51
+ <a href=“https://community.mythemeshop.com/tutorials/category/2-free-video-tutorials/“>https://community.mythemeshop.com/tutorials/category/2-free-video-tutorials/</a><br>
52
+ <br>
53
+ you are still stuck, please feel free to open a new thread, and a member of our support team will be happy to help.<br>
54
+
55
+ Support link:<br>
56
+ <a href=“https://community.mythemeshop.com/forum/11-free-plugin-support/”>https://community.mythemeshop.com/forum/11-free-plugin-support/</a><br>
57
+ <br>
58
+
59
+ = Help to make it better =
60
+
61
+ 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.
62
+
63
+ GitHub link: <a href="https://github.com/MyThemeShopTeam/WP-Tab-Widget">https://github.com/MyThemeShopTeam/WP-Tab-Widget</a>
64
+
65
+ = Feedback =
66
+ 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>
67
+
68
+ == Installation ==
69
+
70
+ This section describes how to install the plugin and get it working.
71
+
72
+ 1. Upload the `wp-tab-widget` folder to the to the `/wp-content/plugins/` directory
73
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
74
+ 3. You can see **WP Tab Widget by MyThemeShop** widget in widgets section.
75
+ 4. Add it in sidebar and footer and configure as you want.
76
+ 5. Enjoy!
77
+
78
+ == Frequently Asked Questions ==
79
+
80
+ = Plugin is not working =
81
+
82
+ 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.
83
+
84
+ = Plugins is consuming too much resources =
85
+
86
+ The pageview is incremented on the database everytime a user visits a page but this can start getting quite expensive on high-traffic websites. We've added the filter `wpt_sampling_rate` which you can use to lower the sampling rate from the default <strong>100%</strong>. Note that setting this value too low will result to innacurate pageviews.
87
+
88
+ `
89
+ <?php
90
+
91
+ function wpt_my_sampling_rate( $rate ) {
92
+ // Reduce the percentage of pageviews recorded to 80%.
93
+ return 80;
94
+ }
95
+ add_filter( 'wpt_sampling_rate', 'wpt_my_sampling_rate' );
96
+ `
97
+
98
+ == Screenshots ==
99
+
100
+ 1. WP Tab Widget Settings
101
+ 2. WP Tab Widget
102
+
103
+ == Changelog ==
104
+
105
+ = 1.2.11 [Oct 31, 2020] =
106
+ * Fixed PHP notices when saving widget
107
+ * Removed an option to show 'Powered by' credit in the frontend
108
+
109
+ = 1.2.10 [June 30, 2018] =
110
+ * Changed admin notices
111
+ * Fixed deprecated notice
112
+
113
+ = 1.2.9 [June 29, 2018] =
114
+ * Updated admin notices
115
+
116
+ = 1.2.8 (Apr 20, 2018) =
117
+ * Fixed compatibility with PHP 7
118
+ * Checked compatibility with WordPress v4.9.5
119
+ * Improved Code
120
+
121
+ = 1.2.7 (Feb 03, 2017) =
122
+ * Added new wpt_sampling_rate filter. See the FAQ section on how this works.
123
+
124
+ = 1.2.6 (Jan 28, 2017) =
125
+ * Updated view counter function
126
+
127
+ = 1.2.5 (Apr 06, 2016) =
128
+ * Added missing Pro version image
129
+
130
+ = 1.2.4 (Mar 27, 2016) =
131
+ * Replaced “comm” CSS class with “comments-number” on comment count in Recent tab
132
+ * Added “Show Some Love” option
133
+
134
+ = 1.2.3 (Mar 22, 2016) =
135
+ * Fixed issue where tab content couldn’t be loaded on servers with non UTF8 character encoding
136
+ * List only comments from default comment type in Comments tab
137
+ * Prevent conflict with Pro version
138
+ * Added Notification & Banner for Pro Version
139
+
140
+ = 1.2.2 (Aug 21, 2015) =
141
+ * Changed text domain to make plugin compatible with WordPress Language Packs
142
+
143
+ = 1.2.1 (Aug 19, 2015) =
144
+ * Switched to PHP 5 style constructor method for the widget class
145
+
146
+ = 1.2 (Oct 15, 2014) =
147
+ * Added Title Length option
148
+ * Fixed post view count compatibility with themes
149
+
150
+ = 1.1 (Oct 1, 2014) =
151
+ * Popular posts will be decided by number of views
152
+ * Added loading effect
153
+ * Fixed small bugs
154
+ * Performance improvement
155
+
156
+ = 1.0 (Mar 24, 2014) =
157
+ * Plugin released
wp-tab-widget.php CHANGED
@@ -1,718 +1,743 @@
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.2.10
8
- Author URI: http://mythemeshop.com/
9
- */
10
- if ( !class_exists('wpt_widget') ) {
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.', 'wp-tab-widget'));
26
- $control_ops = array('width' => 300, 'height' => 350);
27
- parent::__construct('wpt_widget', __('WP Tab Widget by MyThemeShop', 'wp-tab-widget'), $widget_ops, $control_ops);
28
- }
29
-
30
- function wpt_init() {
31
- load_plugin_textdomain('wp-tab-widget', 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
- wp_register_script('wpt_widget_admin', plugins_url('js/wpt-admin.js', __FILE__), array('jquery'));
38
- wp_enqueue_script('wpt_widget_admin');
39
- }
40
- function wpt_register_scripts() {
41
- // JS
42
- wp_register_script('wpt_widget', plugins_url('js/wp-tab-widget.js', __FILE__), array('jquery'));
43
- wp_localize_script( 'wpt_widget', 'wpt',
44
- array( 'ajax_url' => admin_url( 'admin-ajax.php' ))
45
- );
46
- // CSS
47
- wp_register_style('wpt_widget', plugins_url('css/wp-tab-widget.css', __FILE__), true);
48
- }
49
-
50
- function form( $instance ) {
51
- $instance = wp_parse_args( (array) $instance, array(
52
- 'tabs' => array('recent' => 1, 'popular' => 1, 'comments' => 0, 'tags' => 0),
53
- 'tab_order' => array('popular' => 1, 'recent' => 2, 'comments' => 3, 'tags' => 4),
54
- 'allow_pagination' => 1,
55
- 'post_num' => '5',
56
- 'comment_num' => '5',
57
- 'show_thumb' => 1,
58
- 'thumb_size' => 'small',
59
- 'show_date' => 1,
60
- 'show_excerpt' => 0,
61
- 'excerpt_length' => apply_filters( 'wpt_excerpt_length_default', '15' ),
62
- 'show_comment_num' => 0,
63
- 'show_avatar' => 1,
64
- 'title_length' => apply_filters( 'wpt_title_length_default', '15' ) ,
65
- 'show_love' => 0,
66
- ) );
67
-
68
- extract($instance);
69
-
70
- ?>
71
- <div class="wpt_options_form">
72
-
73
- <h4><?php _e('Select Tabs', 'wp-tab-widget'); ?></h4>
74
-
75
- <div class="wpt_select_tabs">
76
- <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px" for="<?php echo $this->get_field_id("tabs"); ?>_popular">
77
- <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 ); } ?> />
78
- <?php _e( 'Popular Tab', 'wp-tab-widget'); ?>
79
- </label>
80
- <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px;" for="<?php echo $this->get_field_id("tabs"); ?>_recent">
81
- <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 ); } ?> />
82
- <?php _e( 'Recent Tab', 'wp-tab-widget'); ?>
83
- </label>
84
- <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id("tabs"); ?>_comments">
85
- <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 ); } ?> />
86
- <?php _e( 'Comments Tab', 'wp-tab-widget'); ?>
87
- </label>
88
- <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id("tabs"); ?>_tags">
89
- <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 ); } ?> />
90
- <?php _e( 'Tags Tab', 'wp-tab-widget'); ?>
91
- </label>
92
- </div>
93
- <div class="clear"></div>
94
-
95
- <h4 class="wpt_tab_order_header"><a href="#"><?php _e('Tab Order', 'wp-tab-widget'); ?></a></h4>
96
-
97
- <div class="wpt_tab_order" style="display: none;">
98
-
99
- <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_popular" style="width: 50%;">
100
- <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;" />
101
- <?php _e('Popular', 'wp-tab-widget'); ?>
102
- </label>
103
- <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_recent" style="width: 50%;">
104
- <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;" />
105
- <?php _e('Recent', 'wp-tab-widget'); ?>
106
- </label>
107
- <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_comments" style="width: 50%;">
108
- <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;" />
109
- <?php _e('Comments', 'wp-tab-widget'); ?>
110
- </label>
111
- <label class="alignleft" for="<?php echo $this->get_field_id('tab_order'); ?>_tags" style="width: 50%;">
112
- <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;" />
113
- <?php _e('Tags', 'wp-tab-widget'); ?>
114
- </label>
115
- </div>
116
- <div class="clear"></div>
117
-
118
- <h4 class="wpt_advanced_options_header"><a href="#"><?php _e('Advanced Options', 'wp-tab-widget'); ?></a></h4>
119
-
120
- <div class="wpt_advanced_options" style="display: none;">
121
- <p>
122
- <label for="<?php echo $this->get_field_id("allow_pagination"); ?>">
123
- <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 ); } ?> />
124
- <?php _e( 'Allow pagination', 'wp-tab-widget'); ?>
125
- </label>
126
- </p>
127
-
128
- <div class="wpt_post_options">
129
-
130
- <p>
131
- <label for="<?php echo $this->get_field_id('post_num'); ?>"><?php _e('Number of posts to show:', 'wp-tab-widget'); ?>
132
- <br />
133
- <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; ?>" />
134
- </label>
135
- </p>
136
-
137
- <p>
138
- <label for="<?php echo $this->get_field_id('title_length'); ?>"><?php _e('Title length (words):', 'wp-tab-widget'); ?>
139
- <br />
140
- <input id="<?php echo $this->get_field_id('title_length'); ?>" name="<?php echo $this->get_field_name('title_length'); ?>" type="number" min="1" step="1" value="<?php echo $title_length; ?>" />
141
- </label>
142
- </p>
143
-
144
- <p>
145
- <label for="<?php echo $this->get_field_id("show_thumb"); ?>">
146
- <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 ); } ?> />
147
- <?php _e( 'Show post thumbnails', 'wp-tab-widget'); ?>
148
- </label>
149
- </p>
150
-
151
- <p class="wpt_thumbnail_size"<?php echo (empty($show_thumb) ? ' style="display: none;"' : ''); ?>>
152
- <label for="<?php echo $this->get_field_id('thumb_size'); ?>"><?php _e('Thumbnail size:', 'wp-tab-widget'); ?></label>
153
- <select id="<?php echo $this->get_field_id('thumb_size'); ?>" name="<?php echo $this->get_field_name('thumb_size'); ?>" style="margin-left: 12px;">
154
- <option value="small" <?php selected($thumb_size, 'small', true); ?>><?php _e('Small', 'wp-tab-widget'); ?></option>
155
- <option value="large" <?php selected($thumb_size, 'large', true); ?>><?php _e('Large', 'wp-tab-widget'); ?></option>
156
- </select>
157
- </p>
158
-
159
- <p>
160
- <label for="<?php echo $this->get_field_id("show_date"); ?>">
161
- <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 ); } ?> />
162
- <?php _e( 'Show post date', 'wp-tab-widget'); ?>
163
- </label>
164
- </p>
165
-
166
- <p>
167
- <label for="<?php echo $this->get_field_id("show_comment_num"); ?>">
168
- <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 ); } ?> />
169
- <?php _e( 'Show number of comments', 'wp-tab-widget'); ?>
170
- </label>
171
- </p>
172
-
173
- <p>
174
- <label for="<?php echo $this->get_field_id("show_excerpt"); ?>">
175
- <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 ); } ?> />
176
- <?php _e( 'Show post excerpt', 'wp-tab-widget'); ?>
177
- </label>
178
- </p>
179
-
180
- <p class="wpt_excerpt_length"<?php echo (empty($show_excerpt) ? ' style="display: none;"' : ''); ?>>
181
- <label for="<?php echo $this->get_field_id('excerpt_length'); ?>">
182
- <?php _e('Excerpt length (words):', 'wp-tab-widget'); ?>
183
- <br />
184
- <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; ?>" />
185
- </label>
186
- </p>
187
-
188
- </div>
189
- <div class="clear"></div>
190
-
191
- <div class="wpt_comment_options"<?php echo (empty($tabs['comments']) ? ' style="display: none;"' : ''); ?>>
192
-
193
- <p>
194
- <label for="<?php echo $this->get_field_id('comment_num'); ?>">
195
- <?php _e('Number of comments on Comments Tab:', 'wp-tab-widget'); ?>
196
- <br />
197
- <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; ?>" />
198
- </label>
199
- </p>
200
-
201
- <p>
202
- <label for="<?php echo $this->get_field_id("show_avatar"); ?>">
203
- <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 ); } ?> />
204
- <?php _e( 'Show avatars on Comments Tab', 'wp-tab-widget'); ?>
205
- </label>
206
- </p>
207
- </div><!-- .wpt_comment_options -->
208
- </div><!-- .wpt_advanced_options -->
209
- <p>
210
- <label for="<?php echo $this->get_field_id("show_love"); ?>">
211
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id("show_love"); ?>" name="<?php echo $this->get_field_name("show_love"); ?>" value="1" <?php if (isset($show_love)) { checked( 1, $show_love, true ); } ?> />
212
- <?php _e( 'Show Some Love (Powered by Tab Widget Pro)', 'wp-tab-widget'); ?>
213
- </label>
214
- </p>
215
- <a href="https://mythemeshop.com/plugins/wp-tab-widget-pro/?utm_source=WP+Tab+Widget+Free&utm_medium=Banner+CPC&utm_content=WP+Tab+Widget+Pro+LP&utm_campaign=WordPressOrg&wpmts" target="_blank"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>/img/wp-tab-widget-pro.jpg" style="width:100%; max-width: 100%; margin-bottom: 10px;"></a>
216
- </div><!-- .wpt_options_form -->
217
- <?php
218
- }
219
-
220
- function update( $new_instance, $old_instance ) {
221
- $instance = $old_instance;
222
- $instance['tabs'] = $new_instance['tabs'];
223
- $instance['tab_order'] = $new_instance['tab_order'];
224
- $instance['allow_pagination'] = $new_instance['allow_pagination'];
225
- $instance['post_num'] = $new_instance['post_num'];
226
- $instance['title_length'] = $new_instance['title_length'];
227
- $instance['comment_num'] = $new_instance['comment_num'];
228
- $instance['show_thumb'] = $new_instance['show_thumb'];
229
- $instance['thumb_size'] = $new_instance['thumb_size'];
230
- $instance['show_date'] = $new_instance['show_date'];
231
- $instance['show_excerpt'] = $new_instance['show_excerpt'];
232
- $instance['excerpt_length'] = $new_instance['excerpt_length'];
233
- $instance['show_comment_num'] = $new_instance['show_comment_num'];
234
- $instance['show_avatar'] = $new_instance['show_avatar'];
235
- $instance['show_love'] = $new_instance['show_love'];
236
- return $instance;
237
- }
238
- function widget( $args, $instance ) {
239
- extract($args);
240
- extract($instance);
241
- wp_enqueue_script('wpt_widget');
242
- wp_enqueue_style('wpt_widget');
243
- if (empty($tabs)) $tabs = array('recent' => 1, 'popular' => 1);
244
- $tabs_count = count($tabs);
245
- if ($tabs_count <= 1) {
246
- $tabs_count = 1;
247
- } elseif($tabs_count > 3) {
248
- $tabs_count = 4;
249
- }
250
-
251
- $available_tabs = array('popular' => __('Popular', 'wp-tab-widget'),
252
- 'recent' => __('Recent', 'wp-tab-widget'),
253
- 'comments' => __('Comments', 'wp-tab-widget'),
254
- 'tags' => __('Tags', 'wp-tab-widget'));
255
-
256
- array_multisort($tab_order, $available_tabs);
257
-
258
- $show_love = !empty($instance['show_love']);
259
- ?>
260
- <?php echo $before_widget; ?>
261
- <div class="wpt_widget_content" id="<?php echo $widget_id; ?>_content" data-widget-number="<?php echo esc_attr( $this->number ); ?>">
262
- <ul class="wpt-tabs <?php echo "has-$tabs_count-"; ?>tabs">
263
- <?php foreach ($available_tabs as $tab => $label) { ?>
264
- <?php if (!empty($tabs[$tab])): ?>
265
- <li class="tab_title"><a href="#" id="<?php echo $tab; ?>-tab"><?php echo $label; ?></a></li>
266
- <?php endif; ?>
267
- <?php } ?>
268
- </ul> <!--end .tabs-->
269
- <div class="clear"></div>
270
- <div class="inside">
271
- <?php if (!empty($tabs['popular'])): ?>
272
- <div id="popular-tab-content" class="tab-content">
273
- </div> <!--end #popular-tab-content-->
274
- <?php endif; ?>
275
- <?php if (!empty($tabs['recent'])): ?>
276
- <div id="recent-tab-content" class="tab-content">
277
- </div> <!--end #recent-tab-content-->
278
- <?php endif; ?>
279
- <?php if (!empty($tabs['comments'])): ?>
280
- <div id="comments-tab-content" class="tab-content">
281
- <ul>
282
- </ul>
283
- </div> <!--end #comments-tab-content-->
284
- <?php endif; ?>
285
- <?php if (!empty($tabs['tags'])): ?>
286
- <div id="tags-tab-content" class="tab-content">
287
- <ul>
288
- </ul>
289
- </div> <!--end #tags-tab-content-->
290
- <?php endif; ?>
291
- <div class="clear"></div>
292
- </div> <!--end .inside -->
293
- <?php if ( $show_love ) { ?>
294
- <a href="https://mythemeshop.com/plugins/wp-review-pro/?utm_source=WP+Tab+Widget&amp;utm_medium=Link+CPC&amp;utm_content=WP+Tab+Widget+Pro+LP&amp;utm_campaign=WordPressOrg" class="wpt_show_love"><?php _e('Powered by WP Tab Widget', 'wp-tab-widget'); ?></a>
295
- <?php } ?>
296
- <div class="clear"></div>
297
- </div><!--end #tabber -->
298
- <?php
299
- // inline script
300
- // to support multiple instances per page with different settings
301
-
302
- unset($instance['tabs'], $instance['tab_order']); // unset unneeded
303
- ?>
304
- <script type="text/javascript">
305
- jQuery(function($) {
306
- $('#<?php echo $widget_id; ?>_content').data('args', <?php echo json_encode($instance); ?>);
307
- });
308
- </script>
309
- <?php echo $after_widget; ?>
310
- <?php
311
- }
312
-
313
-
314
- function ajax_wpt_widget_content() {
315
- $tab = $_POST['tab'];
316
- $args = $_POST['args'];
317
- $number = isset( $_POST['widget_number'] ) ? intval( $_POST['widget_number'] ) : '';
318
- $page = isset( $_POST['page'] ) ? intval( $_POST['page'] ) : '';
319
- if ($page < 1)
320
- $page = 1;
321
-
322
- if ( !is_array( $args ) || empty( $args ) ) { // json_encode() failed
323
- $wpt_widgets = new wpt_widget();
324
- $settings = $wpt_widgets->get_settings();
325
-
326
- if ( isset( $settings[ $number ] ) ) {
327
- $args = $settings[ $number ];
328
- } else {
329
- die( __('Unable to load tab content', 'wp-tab-widget') );
330
- }
331
- }
332
-
333
-
334
- // sanitize args
335
- $post_num = (!isset($args['post_num']) ? 5 : intval($args['post_num']));
336
- if ($post_num > 20 || $post_num < 1) { // max 20 posts
337
- $post_num = 5;
338
- }
339
- $comment_num = (!isset($args['comment_num']) ? 5 : intval($args['comment_num']));
340
- if ($comment_num > 20 || $comment_num < 1) {
341
- $comment_num = 5;
342
- }
343
- $show_thumb = isset( $args['show_thumb'] ) ? $args['show_thumb'] : 0;
344
- $thumb_size = isset( $args['thumb_size'] ) ? $args['thumb_size'] : 'small';
345
- if ($thumb_size != 'small' && $thumb_size != 'large') {
346
- $thumb_size = 'small'; // default
347
- }
348
- $show_date = isset( $args['show_date'] ) ? $args['show_date'] : 1;
349
- $show_excerpt = isset( $args['show_excerpt'] ) ? $args['show_excerpt'] : 1;
350
- $excerpt_length = isset( $args['excerpt_length'] ) ? intval( $args['excerpt_length'] ) : 15;
351
- if ($excerpt_length > 50 || $excerpt_length < 1) {
352
- $excerpt_length = 10;
353
- }
354
- $show_comment_num = isset( $args['show_comment_num'] ) ? $args['show_comment_num'] : 0;
355
- $show_avatar = isset( $args['show_avatar'] ) ? $args['show_avatar'] : 0;
356
- $allow_pagination = isset( $args['allow_pagination'] ) ? $args['allow_pagination'] : 0;
357
- $title_length = !isset($args['title_length']) ? $args['title_length'] : apply_filters( 'wpt_title_length_default', '15' );
358
-
359
- /* ---------- Tab Contents ---------- */
360
- switch ($tab) {
361
-
362
- /* ---------- Popular Posts ---------- */
363
- case "popular":
364
- ?>
365
- <ul>
366
- <?php
367
- $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));
368
- $last_page = $popular->max_num_pages;
369
- while ($popular->have_posts()) : $popular->the_post(); ?>
370
- <li>
371
- <?php if ( $show_thumb == 1 ) : ?>
372
- <div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
373
- <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
374
- <?php if(has_post_thumbnail()): ?>
375
- <?php the_post_thumbnail('wp_review_'.$thumb_size, array('title' => '')); ?>
376
- <?php else: ?>
377
- <img src="<?php echo plugins_url('img/'.$thumb_size.'thumb.png', __FILE__); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
378
- <?php endif; ?>
379
- </a>
380
- </div>
381
- <?php endif; ?>
382
- <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php echo $this->post_title( $title_length ); ?></a></div>
383
- <?php if ( $show_date == 1 || $show_comment_num == 1) : ?>
384
- <div class="wpt-postmeta">
385
- <?php if ( $show_date == 1 ) : ?>
386
- <?php the_time('F j, Y'); ?>
387
- <?php endif; ?>
388
- <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
389
- &bull;
390
- <?php endif; ?>
391
- <?php if ( $show_comment_num == 1 ) : ?>
392
- <?php echo comments_number(__('No Comment','wp-tab-widget'), __('One Comment','wp-tab-widget'), '<span class="comments-number">%</span> '.__('Comments','wp-tab-widget'));?>
393
- <?php endif; ?>
394
- </div> <!--end .entry-meta-->
395
- <?php endif; ?>
396
-
397
- <?php if ( $show_excerpt == 1 ) : ?>
398
- <div class="wpt_excerpt">
399
- <p><?php echo $this->excerpt($excerpt_length); ?></p>
400
- </div>
401
- <?php endif; ?>
402
-
403
- <div class="clear"></div>
404
- </li>
405
- <?php $post_num++; endwhile; wp_reset_query(); ?>
406
- </ul>
407
- <div class="clear"></div>
408
- <?php if ($allow_pagination) : ?>
409
- <?php $this->tab_pagination($page, $last_page); ?>
410
- <?php endif; ?>
411
- <?php
412
- break;
413
-
414
- /* ---------- Recent Posts ---------- */
415
- case "recent":
416
- ?>
417
- <ul>
418
- <?php
419
- $recent = new WP_Query('posts_per_page='. $post_num .'&orderby=post_date&order=desc&post_status=publish&paged='. $page);
420
- $last_page = $recent->max_num_pages;
421
- while ($recent->have_posts()) : $recent->the_post();
422
- ?>
423
- <li>
424
- <?php if ( $show_thumb == 1 ) : ?>
425
- <div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
426
- <a title="<?php the_title(); ?>" href="<?php the_permalink() ?>">
427
- <?php if(has_post_thumbnail()): ?>
428
- <?php the_post_thumbnail('wp_review_'.$thumb_size, array('title' => '')); ?>
429
- <?php else: ?>
430
- <img src="<?php echo plugins_url('img/'.$thumb_size.'thumb.png', __FILE__); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
431
- <?php endif; ?>
432
- </a>
433
- </div>
434
- <?php endif; ?>
435
- <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php echo $this->post_title( $title_length ); ?></a></div>
436
- <?php if ( $show_date == 1 || $show_comment_num == 1) : ?>
437
- <div class="wpt-postmeta">
438
- <?php if ( $show_date == 1 ) : ?>
439
- <?php the_time('F j, Y'); ?>
440
- <?php endif; ?>
441
- <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
442
- &bull;
443
- <?php endif; ?>
444
- <?php if ( $show_comment_num == 1 ) : ?>
445
- <?php echo comments_number(__('No Comment','wp-tab-widget'), __('One Comment','wp-tab-widget'), '<span class="comments-number">%</span> '.__('Comments','wp-tab-widget'));?>
446
- <?php endif; ?>
447
- </div> <!--end .entry-meta-->
448
- <?php endif; ?>
449
-
450
- <?php if ( $show_excerpt == 1 ) : ?>
451
- <div class="wpt_excerpt">
452
- <p><?php echo $this->excerpt($excerpt_length); ?></p>
453
- </div>
454
- <?php endif; ?>
455
-
456
- <div class="clear"></div>
457
- </li>
458
- <?php endwhile; wp_reset_query(); ?>
459
- </ul>
460
- <div class="clear"></div>
461
- <?php if ($allow_pagination) : ?>
462
- <?php $this->tab_pagination($page, $last_page); ?>
463
- <?php endif; ?>
464
- <?php
465
- break;
466
-
467
- /* ---------- Latest Comments ---------- */
468
- case "comments":
469
- ?>
470
- <ul>
471
- <?php
472
- $no_comments = false;
473
- $avatar_size = 65;
474
- $comment_length = 90; // max length for comments
475
- $comment_args = apply_filters(
476
- 'wpt_comments_tab_args',
477
- array(
478
- 'type' => 'comments',
479
- 'status' => 'approve'
480
- )
481
- );
482
- $comments_total = new WP_Comment_Query();
483
- $comments_total_number = $comments_total->query( array_merge( array('count' => 1 ), $comment_args ) );
484
- $last_page = (int) ceil($comments_total_number / $comment_num);
485
- $comments_query = new WP_Comment_Query();
486
- $offset = ($page-1) * $comment_num;
487
- $comments = $comments_query->query( array_merge( array( 'number' => $comment_num, 'offset' => $offset ), $comment_args ) );
488
- if ( $comments ) : foreach ( $comments as $comment ) : ?>
489
- <li>
490
- <?php if ($show_avatar) : ?>
491
- <div class="wpt_avatar">
492
- <a href="<?php echo get_comment_link($comment->comment_ID); ?>">
493
- <?php echo get_avatar( $comment->comment_author_email, $avatar_size ); ?>
494
- </a>
495
- </div>
496
- <?php endif; ?>
497
- <div class="wpt_comment_meta">
498
- <a href="<?php echo get_comment_link($comment->comment_ID); ?>">
499
- <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>
500
- </a>
501
- </div>
502
- <div class="wpt_comment_content">
503
- <p><?php echo $this->truncate(strip_tags(apply_filters( 'get_comment_text', $comment->comment_content )), $comment_length);?></p>
504
- </div>
505
- <div class="clear"></div>
506
- </li>
507
- <?php endforeach; else : ?>
508
- <li>
509
- <div class="no-comments"><?php _e('No comments yet.', 'wp-tab-widget'); ?></div>
510
- </li>
511
- <?php $no_comments = true;
512
- endif; ?>
513
- </ul>
514
- <?php if ($allow_pagination && !$no_comments) : ?>
515
- <?php $this->tab_pagination($page, $last_page); ?>
516
- <?php endif; ?>
517
- <?php
518
- break;
519
-
520
- /* ---------- Tags ---------- */
521
- case "tags":
522
- ?>
523
- <ul>
524
- <?php
525
- $tags = get_tags(array('get'=>'all'));
526
- if($tags) {
527
- foreach ($tags as $tag): ?>
528
- <li><a href="<?php echo get_term_link($tag); ?>"><?php echo $tag->name; ?></a></li>
529
- <?php
530
- endforeach;
531
- } else {
532
- _e('No tags created.', 'wp-tab-widget');
533
- }
534
- ?>
535
- </ul>
536
- <?php
537
- break;
538
- }
539
- die(); // required to return a proper result
540
- }
541
- function tab_pagination($page, $last_page) {
542
- ?>
543
- <div class="wpt-pagination">
544
- <?php if ($page > 1) : ?>
545
- <a href="#" class="previous"><span><?php _e('&laquo; Previous', 'wp-tab-widget'); ?></span></a>
546
- <?php endif; ?>
547
- <?php if ($page != $last_page) : ?>
548
- <a href="#" class="next"><span><?php _e('Next &raquo;', 'wp-tab-widget'); ?></span></a>
549
- <?php endif; ?>
550
- </div>
551
- <div class="clear"></div>
552
- <input type="hidden" class="page_num" name="page_num" value="<?php echo $page; ?>" />
553
- <?php
554
- }
555
-
556
- function excerpt($limit = 10) {
557
- $limit++;
558
- $excerpt = explode(' ', get_the_excerpt(), $limit);
559
- if (count($excerpt)>=$limit) {
560
- array_pop($excerpt);
561
- $excerpt = implode(" ",$excerpt).'...';
562
- } else {
563
- $excerpt = implode(" ",$excerpt);
564
- }
565
- $excerpt = preg_replace('`[[^]]*]`','',$excerpt);
566
- return $excerpt;
567
- }
568
- function post_title($limit = 10) {
569
- $limit++;
570
- $title = explode(' ', get_the_title(), $limit);
571
- if (count($title)>=$limit) {
572
- array_pop($title);
573
- $title = implode(" ",$title).'...';
574
- } else {
575
- $title = implode(" ",$title);
576
- }
577
- return $title;
578
- }
579
- function truncate($str, $length = 24) {
580
- if (mb_strlen($str) > $length) {
581
- return mb_substr($str, 0, $length).'...';
582
- } else {
583
- return $str;
584
- }
585
- }
586
- }
587
- }
588
-
589
- add_action('widgets_init', function(){
590
- return register_widget('wpt_widget');
591
- });
592
-
593
- // post view count
594
- // AJAX is used to support caching plugins
595
- add_filter('the_content', 'wpt_view_count_js'); // outputs JS for AJAX call on single
596
- add_action('wp_ajax_wpt_view_count', 'ajax_wpt_view_count');
597
- add_action('wp_ajax_nopriv_wpt_view_count','ajax_wpt_view_count');
598
- // prevent additional ajax call if theme has view counter already
599
- add_action('mts_view_count_after_update', 'wpt_update_view_count');
600
-
601
- function wpt_view_count_js( $content ) {
602
- global $post;
603
- $id = $post->ID;
604
- $use_ajax = apply_filters( 'mts_view_count_cache_support', true );
605
-
606
- $exclude_admins = apply_filters( 'mts_view_count_exclude_admins', false ); // pass in true or a user capaibility
607
- if ($exclude_admins === true) $exclude_admins = 'edit_posts';
608
- if ($exclude_admins && current_user_can( $exclude_admins )) return $content; // do not count post views here
609
- if (!is_single()) return $content; // Only on single posts
610
-
611
- if ($use_ajax) { // prevent additional ajax call if theme has view counter already
612
- // enqueue jquery
613
- wp_enqueue_script( 'jquery' );
614
-
615
- $url = admin_url( 'admin-ajax.php' );
616
- $content .= "
617
- <script type=\"text/javascript\">
618
- jQuery(document).ready(function($) {
619
- $.post('{$url}', {action: 'wpt_view_count', id: '{$id}'});
620
- });
621
- </script>";
622
- } else {
623
- wpt_update_view_count($id);
624
- }
625
-
626
- remove_filter('the_content', 'wpt_view_count_js');
627
-
628
- return $content;
629
- }
630
-
631
- function ajax_wpt_view_count() {
632
- // do count
633
- $post_id = $_POST['id'];
634
- wpt_update_view_count( $post_id );
635
- }
636
- function wpt_update_view_count( $post_id ) {
637
- $sample_rate = intval( apply_filters( 'wpt_sampling_rate', 100 ) ) / 100;
638
- if ( ( mt_rand() / mt_getrandmax() ) <= $sample_rate ) {
639
- $count = get_post_meta( $post_id, '_wpt_view_count', true );
640
- update_post_meta( $post_id, '_wpt_view_count', $count + 1 );
641
- }
642
- }
643
-
644
- // Add meta for all existing posts that don't have it
645
- // to make them show up in Popular tab
646
- function wpt_add_views_meta_for_posts() {
647
- $allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
648
-
649
- foreach( $allposts as $postinfo ) {
650
- add_post_meta( $postinfo->ID, '_wpt_view_count', 0, true );
651
- }
652
- }
653
-
654
- // Reset post count for specific post or all posts
655
- function wpt_reset_post_count($post_id = 0) {
656
- if ($post_id == 0) {
657
- $allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
658
- foreach( $allposts as $postinfo ) {
659
- update_post_meta( $postinfo->ID, '_wpt_view_count', '0' );
660
- }
661
- } else {
662
- update_post_meta( $post_id, '_wpt_view_count', '0' );
663
- }
664
- }
665
-
666
- // add post meta on plugin activation
667
- function wpt_plugin_activation() {
668
- wpt_add_views_meta_for_posts();
669
- update_option('wp_tab_widget_activated', time());
670
- }
671
- register_activation_hook( __FILE__, 'wpt_plugin_activation' );
672
-
673
- // unregister MTS Tabs Widget and Tabs Widget v2
674
- add_action('widgets_init', 'unregister_mts_tabs_widget', 100);
675
- function unregister_mts_tabs_widget() {
676
- unregister_widget('mts_Widget_Tabs_2');
677
- unregister_widget('mts_Widget_Tabs');
678
- }
679
-
680
- /* Display a admin notice */
681
-
682
- add_action('admin_notices', 'wp_tab_widget_admin_notice');
683
- function wp_tab_widget_admin_notice() {
684
- global $current_user ;
685
- $user_id = $current_user->ID;
686
- /* Check that the user hasn't already clicked to ignore the message */
687
- if ( ! get_user_meta($user_id, 'wp_tab_widget_ignore_notice') && time() >= (get_option( 'wp_tab_widget_activated', 0 ) + (2 * 24 * 60 * 60)) ) {
688
- echo '<div class="updated notice-info wp-tab-widget-pro-notice" style="position:relative;"><p>';
689
- echo __('Like WP Tab Widget? You will <strong>LOVE WP Tab Widget Pro</strong>!','wp-tab-widget').'<a href="https://mythemeshop.com/plugins/wp-tab-widget-pro/?utm_source=WP+Tab+Widget+Free&utm_medium=Notification+Link&utm_content=WP+Tab+Widget+Pro+LP&utm_campaign=WordPressOrg&wpmts" target="_blank">&nbsp;'.__('Click here for all the exciting features.','wp-tab-widget').'</a></p><a href="%1$s" class="dashicons dashicons-dismiss dashicons-dismiss-icon tabwidget-notice-dismiss" data-ignore="0" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
690
- echo "</div>";
691
- }
692
-
693
- /* Other notice appears right after activating */
694
- /* And it gets hidden after showing 3 times */
695
- if ( ! get_user_meta($user_id, 'wp_tab_widget_ignore_notice_2') && get_option('wp_tab_widget_notice_views', 0) < 3 && get_option( 'wp_tab_widget_activated', 0 ) ) {
696
- $views = get_option('wp_tab_widget_notice_views', 0);
697
- update_option( 'wp_tab_widget_notice_views', ($views + 1) );
698
- echo '<div class="updated notice-info wp-tab-widget-notice" id="wptabwodget-notice2" style="position:relative;">';
699
- echo '<p>';
700
- _e('Thank you for trying WP Tab Widget. We hope you will like it.', 'wp-tab-widget');
701
- echo '</p>';
702
- echo '<a class="notice-dismiss tabwidget-notice-dismiss" data-ignore="1" href="#"></a>';
703
- echo "</div>";
704
- }
705
- }
706
-
707
- add_action('wp_ajax_mts_dismiss_tabwidget_notice', function(){
708
- global $current_user;
709
- $user_id = $current_user->ID;
710
- /* If user clicks to ignore the notice, add that to their user meta */
711
- if ( isset($_POST['dismiss']) ) {
712
- if ( '0' == $_POST['dismiss'] ) {
713
- add_user_meta($user_id, 'wp_tab_widget_ignore_notice', '1', true);
714
- } elseif ( '1' == $_POST['dismiss'] ) {
715
- add_user_meta($user_id, 'wp_tab_widget_ignore_notice_2', '1', true);
716
- }
717
- }
718
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2.11
8
+ Author URI: http://mythemeshop.com/
9
+ */
10
+
11
+ if ( !class_exists('wpt_widget') ) {
12
+ class wpt_widget extends WP_Widget {
13
+ public function __construct() {
14
+
15
+ // add image sizes and load language file
16
+ add_action( 'init', array( &$this, 'wpt_init' ) );
17
+
18
+ // ajax functions
19
+ add_action( 'wp_ajax_wpt_widget_content', array( &$this, 'ajax_wpt_widget_content' ) );
20
+ add_action( 'wp_ajax_nopriv_wpt_widget_content', array( &$this, 'ajax_wpt_widget_content' ) );
21
+
22
+ // css
23
+ add_action( 'wp_enqueue_scripts', array( &$this, 'wpt_register_scripts' ) );
24
+ add_action( 'admin_enqueue_scripts', array( &$this, 'wpt_admin_scripts' ) );
25
+
26
+ $widget_ops = array(
27
+ 'classname' => 'widget_wpt',
28
+ 'description' => __( 'Display popular posts, recent posts, comments, and tags in tabbed format.', 'wp-tab-widget' ),
29
+ );
30
+
31
+ $control_ops = array(
32
+ 'width' => 300,
33
+ 'height' => 350,
34
+ );
35
+
36
+ parent::__construct( 'wpt_widget', __( 'WP Tab Widget by MyThemeShop', 'wp-tab-widget' ), $widget_ops, $control_ops );
37
+ }
38
+
39
+ public function wpt_init() {
40
+ load_plugin_textdomain( 'wp-tab-widget', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
41
+
42
+ add_image_size( 'wp_review_small', 65, 65, true ); // small thumb
43
+ add_image_size( 'wp_review_large', 320, 240, true ); // large thumb
44
+ }
45
+
46
+ public function wpt_admin_scripts( $hook ) {
47
+ wp_register_script( 'wpt_widget_admin', plugins_url( 'js/wpt-admin.js', __FILE__ ), array( 'jquery' ) );
48
+ wp_enqueue_script( 'wpt_widget_admin' );
49
+ }
50
+
51
+ public function wpt_register_scripts() {
52
+ // JS
53
+ wp_register_script( 'wpt_widget', plugins_url( 'js/wp-tab-widget.js', __FILE__ ), array( 'jquery' ) );
54
+ wp_localize_script( 'wpt_widget', 'wpt', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
55
+ // CSS
56
+ wp_register_style( 'wpt_widget', plugins_url( 'css/wp-tab-widget.css', __FILE__ ), true );
57
+ }
58
+
59
+ public function form( $instance ) {
60
+ $instance = wp_parse_args( (array) $instance, array(
61
+ 'tabs' => array( 'recent' => 1, 'popular' => 1, 'comments' => 0, 'tags' => 0 ),
62
+ 'tab_order' => array( 'popular' => 1, 'recent' => 2, 'comments' => 3, 'tags' => 4 ),
63
+ 'allow_pagination' => 1,
64
+ 'post_num' => '5',
65
+ 'comment_num' => '5',
66
+ 'show_thumb' => 1,
67
+ 'thumb_size' => 'small',
68
+ 'show_date' => 1,
69
+ 'show_excerpt' => 0,
70
+ 'excerpt_length' => apply_filters( 'wpt_excerpt_length_default', '15' ),
71
+ 'show_comment_num' => 0,
72
+ 'show_avatar' => 1,
73
+ 'title_length' => apply_filters( 'wpt_title_length_default', '15' ) ,
74
+ ) );
75
+
76
+ extract($instance);
77
+
78
+ ?>
79
+ <div class="wpt_options_form">
80
+
81
+ <h4><?php _e( 'Select Tabs', 'wp-tab-widget' ); ?></h4>
82
+
83
+ <div class="wpt_select_tabs">
84
+ <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px" for="<?php echo $this->get_field_id( 'tabs' ); ?>_popular">
85
+ <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 ); } ?> />
86
+ <?php _e( 'Popular Tab', 'wp-tab-widget' ); ?>
87
+ </label>
88
+ <label class="alignleft" style="display: block; width: 50%; margin-bottom: 5px;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_recent">
89
+ <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 ); } ?> />
90
+ <?php _e( 'Recent Tab', 'wp-tab-widget' ); ?>
91
+ </label>
92
+ <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_comments">
93
+ <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 ); } ?> />
94
+ <?php _e( 'Comments Tab', 'wp-tab-widget'); ?>
95
+ </label>
96
+ <label class="alignleft" style="display: block; width: 50%;" for="<?php echo $this->get_field_id( 'tabs' ); ?>_tags">
97
+ <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 ); } ?> />
98
+ <?php _e( 'Tags Tab', 'wp-tab-widget' ); ?>
99
+ </label>
100
+ </div>
101
+ <div class="clear"></div>
102
+
103
+ <h4 class="wpt_tab_order_header"><a href="#"><?php _e( 'Tab Order', 'wp-tab-widget' ); ?></a></h4>
104
+
105
+ <div class="wpt_tab_order" style="display: none;">
106
+
107
+ <label class="alignleft" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_popular" style="width: 50%;">
108
+ <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;" />
109
+ <?php _e( 'Popular', 'wp-tab-widget' ); ?>
110
+ </label>
111
+ <label class="alignleft" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_recent" style="width: 50%;">
112
+ <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;" />
113
+ <?php _e( 'Recent', 'wp-tab-widget' ); ?>
114
+ </label>
115
+ <label class="alignleft" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_comments" style="width: 50%;">
116
+ <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;" />
117
+ <?php _e( 'Comments', 'wp-tab-widget' ); ?>
118
+ </label>
119
+ <label class="alignleft" for="<?php echo $this->get_field_id( 'tab_order' ); ?>_tags" style="width: 50%;">
120
+ <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;" />
121
+ <?php _e( 'Tags', 'wp-tab-widget' ); ?>
122
+ </label>
123
+ </div>
124
+ <div class="clear"></div>
125
+
126
+ <h4 class="wpt_advanced_options_header"><a href="#"><?php _e( 'Advanced Options', 'wp-tab-widget' ); ?></a></h4>
127
+
128
+ <div class="wpt_advanced_options" style="display: none;">
129
+ <p>
130
+ <label for="<?php echo $this->get_field_id( 'allow_pagination' ); ?>">
131
+ <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 ); } ?> />
132
+ <?php _e( 'Allow pagination', 'wp-tab-widget'); ?>
133
+ </label>
134
+ </p>
135
+
136
+ <div class="wpt_post_options">
137
+
138
+ <p>
139
+ <label for="<?php echo $this->get_field_id( 'post_num' ); ?>"><?php _e( 'Number of posts to show:', 'wp-tab-widget' ); ?>
140
+ <br />
141
+ <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; ?>" />
142
+ </label>
143
+ </p>
144
+
145
+ <p>
146
+ <label for="<?php echo $this->get_field_id( 'title_length' ); ?>"><?php _e( 'Title length (words):', 'wp-tab-widget' ); ?>
147
+ <br />
148
+ <input id="<?php echo $this->get_field_id( 'title_length' ); ?>" name="<?php echo $this->get_field_name( 'title_length' ); ?>" type="number" min="1" step="1" value="<?php echo $title_length; ?>" />
149
+ </label>
150
+ </p>
151
+
152
+ <p>
153
+ <label for="<?php echo $this->get_field_id( 'show_thumb' ); ?>">
154
+ <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 ); } ?> />
155
+ <?php _e( 'Show post thumbnails', 'wp-tab-widget' ); ?>
156
+ </label>
157
+ </p>
158
+
159
+ <p class="wpt_thumbnail_size"<?php echo ( empty( $show_thumb ) ? ' style="display: none;"' : '' ); ?>>
160
+ <label for="<?php echo $this->get_field_id('thumb_size'); ?>"><?php _e( 'Thumbnail size:', 'wp-tab-widget' ); ?></label>
161
+ <select id="<?php echo $this->get_field_id('thumb_size'); ?>" name="<?php echo $this->get_field_name( 'thumb_size' ); ?>" style="margin-left: 12px;">
162
+ <option value="small" <?php selected( $thumb_size, 'small', true ); ?>><?php _e( 'Small', 'wp-tab-widget' ); ?></option>
163
+ <option value="large" <?php selected( $thumb_size, 'large', true ); ?>><?php _e( 'Large', 'wp-tab-widget' ); ?></option>
164
+ </select>
165
+ </p>
166
+
167
+ <p>
168
+ <label for="<?php echo $this->get_field_id( 'show_date' ); ?>">
169
+ <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 ); } ?> />
170
+ <?php _e( 'Show post date', 'wp-tab-widget' ); ?>
171
+ </label>
172
+ </p>
173
+
174
+ <p>
175
+ <label for="<?php echo $this->get_field_id( 'show_comment_num' ); ?>">
176
+ <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 ); } ?> />
177
+ <?php _e( 'Show number of comments', 'wp-tab-widget' ); ?>
178
+ </label>
179
+ </p>
180
+
181
+ <p>
182
+ <label for="<?php echo $this->get_field_id( 'show_excerpt' ); ?>">
183
+ <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 ); } ?> />
184
+ <?php _e( 'Show post excerpt', 'wp-tab-widget' ); ?>
185
+ </label>
186
+ </p>
187
+
188
+ <p class="wpt_excerpt_length"<?php echo ( empty( $show_excerpt ) ? ' style="display: none;"' : '' ); ?>>
189
+ <label for="<?php echo $this->get_field_id( 'excerpt_length' ); ?>">
190
+ <?php _e( 'Excerpt length (words):', 'wp-tab-widget' ); ?>
191
+ <br />
192
+ <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; ?>" />
193
+ </label>
194
+ </p>
195
+
196
+ </div>
197
+ <div class="clear"></div>
198
+
199
+ <div class="wpt_comment_options"<?php echo ( empty( $tabs['comments'] ) ? ' style="display: none;"' : '' ); ?>>
200
+
201
+ <p>
202
+ <label for="<?php echo $this->get_field_id( 'comment_num' ); ?>">
203
+ <?php _e( 'Number of comments on Comments Tab:', 'wp-tab-widget' ); ?>
204
+ <br />
205
+ <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; ?>" />
206
+ </label>
207
+ </p>
208
+
209
+ <p>
210
+ <label for="<?php echo $this->get_field_id( 'show_avatar' ); ?>">
211
+ <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 ); } ?> />
212
+ <?php _e( 'Show avatars on Comments Tab', 'wp-tab-widget' ); ?>
213
+ </label>
214
+ </p>
215
+ </div><!-- .wpt_comment_options -->
216
+ </div><!-- .wpt_advanced_options -->
217
+
218
+ <a href="https://mythemeshop.com/plugins/wp-tab-widget-pro/?utm_source=WP+Tab+Widget+Free&utm_medium=Banner+CPC&utm_content=WP+Tab+Widget+Pro+LP&utm_campaign=WordPressOrg&wpmts" target="_blank"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>/img/wp-tab-widget-pro.jpg" style="width:100%; max-width: 100%; margin-bottom: 10px;"></a>
219
+ </div><!-- .wpt_options_form -->
220
+ <?php
221
+ }
222
+
223
+ public function update( $new_instance, $old_instance ) {
224
+ $instance = $old_instance;
225
+ $instance['tabs'] = isset( $new_instance['tabs'] ) ? $new_instance['tabs'] : array();
226
+ $instance['tab_order'] = $new_instance['tab_order'];
227
+ $instance['allow_pagination'] = isset( $new_instance['allow_pagination'] ) ? $new_instance['allow_pagination'] : '';
228
+ $instance['post_num'] = $new_instance['post_num'];
229
+ $instance['title_length'] = $new_instance['title_length'];
230
+ $instance['comment_num'] = $new_instance['comment_num'];
231
+ $instance['show_thumb'] = isset( $new_instance['show_thumb'] ) ? $new_instance['show_thumb'] : '';
232
+ $instance['thumb_size'] = $new_instance['thumb_size'];
233
+ $instance['show_date'] = isset( $new_instance['show_date'] ) ? $new_instance['show_date'] : '';
234
+ $instance['show_excerpt'] = isset( $new_instance['show_excerpt'] ) ? $new_instance['show_excerpt'] : '';
235
+ $instance['excerpt_length'] = $new_instance['excerpt_length'];
236
+ $instance['show_comment_num'] = isset( $new_instance['show_comment_num'] ) ? $new_instance['show_comment_num'] : '';
237
+ $instance['show_avatar'] = isset( $new_instance['show_avatar'] ) ? $new_instance['show_avatar'] : '';
238
+ return $instance;
239
+ }
240
+
241
+ public function widget( $args, $instance ) {
242
+ extract( $args );
243
+ extract( $instance );
244
+ wp_enqueue_script( 'wpt_widget' );
245
+ wp_enqueue_style( 'wpt_widget' );
246
+ if ( empty( $tabs ) ) {
247
+ $tabs = array( 'recent' => 1, 'popular' => 1 );
248
+ }
249
+ $tabs_count = count( $tabs );
250
+ if ( $tabs_count <= 1 ) {
251
+ $tabs_count = 1;
252
+ } elseif ( $tabs_count > 3 ) {
253
+ $tabs_count = 4;
254
+ }
255
+
256
+ $available_tabs = array(
257
+ 'popular' => __( 'Popular', 'wp-tab-widget' ),
258
+ 'recent' => __( 'Recent', 'wp-tab-widget' ),
259
+ 'comments' => __( 'Comments', 'wp-tab-widget' ),
260
+ 'tags' => __( 'Tags', 'wp-tab-widget' ),
261
+ );
262
+
263
+ array_multisort( $tab_order, $available_tabs );
264
+ ?>
265
+ <?php echo $before_widget; ?>
266
+ <div class="wpt_widget_content" id="<?php echo $widget_id; ?>_content" data-widget-number="<?php echo esc_attr( $this->number ); ?>">
267
+ <ul class="wpt-tabs <?php echo "has-$tabs_count-"; ?>tabs">
268
+ <?php foreach ( $available_tabs as $tab => $label ) { ?>
269
+ <?php if ( ! empty( $tabs[ $tab ] ) ): ?>
270
+ <li class="tab_title"><a href="#" id="<?php echo $tab; ?>-tab"><?php echo $label; ?></a></li>
271
+ <?php endif; ?>
272
+ <?php } ?>
273
+ </ul> <!--end .tabs-->
274
+ <div class="clear"></div>
275
+ <div class="inside">
276
+ <?php if ( ! empty( $tabs['popular'] ) ) : ?>
277
+ <div id="popular-tab-content" class="tab-content">
278
+ </div> <!--end #popular-tab-content-->
279
+ <?php endif; ?>
280
+ <?php if ( ! empty( $tabs['recent'] ) ) : ?>
281
+ <div id="recent-tab-content" class="tab-content">
282
+ </div> <!--end #recent-tab-content-->
283
+ <?php endif; ?>
284
+ <?php if ( ! empty( $tabs['comments'] ) ) : ?>
285
+ <div id="comments-tab-content" class="tab-content">
286
+ <ul>
287
+ </ul>
288
+ </div> <!--end #comments-tab-content-->
289
+ <?php endif; ?>
290
+ <?php if ( ! empty( $tabs['tags'] ) ) : ?>
291
+ <div id="tags-tab-content" class="tab-content">
292
+ <ul>
293
+ </ul>
294
+ </div> <!--end #tags-tab-content-->
295
+ <?php endif; ?>
296
+ <div class="clear"></div>
297
+ </div> <!--end .inside -->
298
+ <div class="clear"></div>
299
+ </div><!--end #tabber -->
300
+ <?php
301
+ // inline script
302
+ // to support multiple instances per page with different settings
303
+
304
+ unset( $instance['tabs'], $instance['tab_order'] ); // unset unneeded
305
+ ?>
306
+ <script type="text/javascript">
307
+ jQuery(function($) {
308
+ $('#<?php echo $widget_id; ?>_content').data('args', <?php echo json_encode( $instance ); ?>);
309
+ });
310
+ </script>
311
+ <?php echo $after_widget; ?>
312
+ <?php
313
+ }
314
+
315
+ public function ajax_wpt_widget_content() {
316
+ $tab = $_POST['tab'];
317
+ $args = $_POST['args'];
318
+ $number = isset( $_POST['widget_number'] ) ? intval( $_POST['widget_number'] ) : '';
319
+ $page = isset( $_POST['page'] ) ? intval( $_POST['page'] ) : '';
320
+ if ( $page < 1 ) {
321
+ $page = 1;
322
+ }
323
+
324
+ if ( ! is_array( $args ) || empty( $args ) ) { // json_encode() failed
325
+ $wpt_widgets = new wpt_widget();
326
+ $settings = $wpt_widgets->get_settings();
327
+
328
+ if ( isset( $settings[ $number ] ) ) {
329
+ $args = $settings[ $number ];
330
+ } else {
331
+ die( __( 'Unable to load tab content', 'wp-tab-widget' ) );
332
+ }
333
+ }
334
+
335
+
336
+ // sanitize args
337
+ $post_num = ( ! isset( $args['post_num'] ) ? 5 : intval( $args['post_num'] ) );
338
+ if ( $post_num > 20 || $post_num < 1 ) { // max 20 posts
339
+ $post_num = 5;
340
+ }
341
+ $comment_num = ( ! isset( $args['comment_num'] ) ? 5 : intval( $args['comment_num'] ) );
342
+ if ( $comment_num > 20 || $comment_num < 1 ) {
343
+ $comment_num = 5;
344
+ }
345
+ $show_thumb = isset( $args['show_thumb'] ) ? $args['show_thumb'] : 0;
346
+ $thumb_size = isset( $args['thumb_size'] ) ? $args['thumb_size'] : 'small';
347
+ if ( $thumb_size != 'small' && $thumb_size != 'large' ) {
348
+ $thumb_size = 'small'; // default
349
+ }
350
+ $show_date = isset( $args['show_date'] ) ? $args['show_date'] : 1;
351
+ $show_excerpt = isset( $args['show_excerpt'] ) ? $args['show_excerpt'] : 1;
352
+ $excerpt_length = isset( $args['excerpt_length'] ) ? intval( $args['excerpt_length'] ) : 15;
353
+ if ( $excerpt_length > 50 || $excerpt_length < 1 ) {
354
+ $excerpt_length = 10;
355
+ }
356
+ $show_comment_num = isset( $args['show_comment_num'] ) ? $args['show_comment_num'] : 0;
357
+ $show_avatar = isset( $args['show_avatar'] ) ? $args['show_avatar'] : 0;
358
+ $allow_pagination = isset( $args['allow_pagination'] ) ? $args['allow_pagination'] : 0;
359
+ $title_length = ! isset( $args['title_length'] ) ? $args['title_length'] : apply_filters( 'wpt_title_length_default', '15' );
360
+
361
+ /* ---------- Tab Contents ---------- */
362
+ switch ( $tab ) {
363
+
364
+ /* ---------- Popular Posts ---------- */
365
+ case "popular":
366
+ ?>
367
+ <ul>
368
+ <?php
369
+ $popular = new WP_Query(
370
+ array(
371
+ 'ignore_sticky_posts' => 1,
372
+ 'posts_per_page' => $post_num,
373
+ 'post_status' => 'publish',
374
+ 'orderby' => 'meta_value_num',
375
+ 'meta_key' => '_wpt_view_count',
376
+ 'order' => 'desc',
377
+ 'paged' => $page,
378
+ )
379
+ );
380
+
381
+ $last_page = $popular->max_num_pages;
382
+ while ( $popular->have_posts()) : $popular->the_post(); ?>
383
+ <li>
384
+ <?php if ( $show_thumb == 1 ) : ?>
385
+ <div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
386
+ <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">
387
+ <?php if ( has_post_thumbnail() ) : ?>
388
+ <?php the_post_thumbnail( 'wp_review_' . $thumb_size, array( 'title' => '' ) ); ?>
389
+ <?php else: ?>
390
+ <img src="<?php echo plugins_url( 'img/' . $thumb_size . 'thumb.png', __FILE__ ); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
391
+ <?php endif; ?>
392
+ </a>
393
+ </div>
394
+ <?php endif; ?>
395
+
396
+ <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php echo $this->post_title( $title_length ); ?></a></div>
397
+
398
+ <?php if ( $show_date == 1 || $show_comment_num == 1 ) : ?>
399
+ <div class="wpt-postmeta">
400
+ <?php if ( $show_date == 1 ) : ?>
401
+ <?php the_time('F j, Y'); ?>
402
+ <?php endif; ?>
403
+ <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
404
+ &bull;
405
+ <?php endif; ?>
406
+ <?php if ( $show_comment_num == 1 ) : ?>
407
+ <?php comments_number( __( 'No Comment', 'wp-tab-widget' ), __( 'One Comment','wp-tab-widget' ), '<span class="comments-number">%</span> ' . __( 'Comments', 'wp-tab-widget' ) ); ?>
408
+ <?php endif; ?>
409
+ </div> <!--end .entry-meta-->
410
+ <?php endif; ?>
411
+
412
+ <?php if ( $show_excerpt == 1 ) : ?>
413
+ <div class="wpt_excerpt">
414
+ <p><?php echo $this->excerpt( $excerpt_length ); ?></p>
415
+ </div>
416
+ <?php endif; ?>
417
+
418
+ <div class="clear"></div>
419
+ </li>
420
+ <?php $post_num++; endwhile; wp_reset_query(); ?>
421
+ </ul>
422
+ <div class="clear"></div>
423
+ <?php if ( $allow_pagination ) : ?>
424
+ <?php $this->tab_pagination( $page, $last_page ); ?>
425
+ <?php endif; ?>
426
+ <?php
427
+ break;
428
+
429
+ /* ---------- Recent Posts ---------- */
430
+ case "recent":
431
+ ?>
432
+ <ul>
433
+ <?php
434
+ $recent = new WP_Query( 'posts_per_page=' . $post_num . '&orderby=post_date&order=desc&post_status=publish&paged=' . $page );
435
+ $last_page = $recent->max_num_pages;
436
+ while ( $recent->have_posts() ) : $recent->the_post();
437
+ ?>
438
+ <li>
439
+ <?php if ( $show_thumb == 1 ) : ?>
440
+ <div class="wpt_thumbnail wpt_thumb_<?php echo $thumb_size; ?>">
441
+ <a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>">
442
+ <?php if ( has_post_thumbnail() ): ?>
443
+ <?php the_post_thumbnail( 'wp_review_' . $thumb_size, array( 'title' => '' ) ); ?>
444
+ <?php else: ?>
445
+ <img src="<?php echo plugins_url( 'img/' . $thumb_size . 'thumb.png', __FILE__ ); ?>" alt="<?php the_title(); ?>" class="wp-post-image" />
446
+ <?php endif; ?>
447
+ </a>
448
+ </div>
449
+ <?php endif; ?>
450
+ <div class="entry-title"><a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php echo $this->post_title( $title_length ); ?></a></div>
451
+ <?php if ( $show_date == 1 || $show_comment_num == 1) : ?>
452
+ <div class="wpt-postmeta">
453
+ <?php if ( $show_date == 1 ) : ?>
454
+ <?php the_time('F j, Y'); ?>
455
+ <?php endif; ?>
456
+ <?php if ( $show_date == 1 && $show_comment_num == 1) : ?>
457
+ &bull;
458
+ <?php endif; ?>
459
+ <?php if ( $show_comment_num == 1 ) : ?>
460
+ <?php comments_number( __( 'No Comment', 'wp-tab-widget' ), __( 'One Comment', 'wp-tab-widget' ), '<span class="comments-number">%</span> ' . __( 'Comments','wp-tab-widget' ) ); ?>
461
+ <?php endif; ?>
462
+ </div> <!--end .entry-meta-->
463
+ <?php endif; ?>
464
+
465
+ <?php if ( $show_excerpt == 1 ) : ?>
466
+ <div class="wpt_excerpt">
467
+ <p><?php echo $this->excerpt( $excerpt_length ); ?></p>
468
+ </div>
469
+ <?php endif; ?>
470
+
471
+ <div class="clear"></div>
472
+ </li>
473
+ <?php endwhile; wp_reset_query(); ?>
474
+ </ul>
475
+ <div class="clear"></div>
476
+ <?php if ( $allow_pagination ) : ?>
477
+ <?php $this->tab_pagination( $page, $last_page ); ?>
478
+ <?php endif; ?>
479
+ <?php
480
+ break;
481
+
482
+ /* ---------- Latest Comments ---------- */
483
+ case "comments":
484
+ ?>
485
+ <ul>
486
+ <?php
487
+ $no_comments = false;
488
+ $avatar_size = 65;
489
+ $comment_length = 90; // max length for comments
490
+ $comment_args = apply_filters(
491
+ 'wpt_comments_tab_args',
492
+ array(
493
+ 'type' => 'comments',
494
+ 'status' => 'approve'
495
+ )
496
+ );
497
+ $comments_total = new WP_Comment_Query();
498
+ $comments_total_number = $comments_total->query( array_merge( array( 'count' => 1 ), $comment_args ) );
499
+ $last_page = (int) ceil( $comments_total_number / $comment_num );
500
+ $comments_query = new WP_Comment_Query();
501
+ $offset = ( $page - 1 ) * $comment_num;
502
+ $comments = $comments_query->query( array_merge( array( 'number' => $comment_num, 'offset' => $offset ), $comment_args ) );
503
+ if ( $comments ) : foreach ( $comments as $comment ) : ?>
504
+ <li>
505
+ <?php if ( $show_avatar ) : ?>
506
+ <div class="wpt_avatar">
507
+ <a href="<?php echo get_comment_link( $comment->comment_ID ); ?>">
508
+ <?php echo get_avatar( $comment->comment_author_email, $avatar_size ); ?>
509
+ </a>
510
+ </div>
511
+ <?php endif; ?>
512
+ <div class="wpt_comment_meta">
513
+ <a href="<?php echo get_comment_link( $comment->comment_ID ); ?>">
514
+ <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>
515
+ </a>
516
+ </div>
517
+ <div class="wpt_comment_content">
518
+ <p><?php echo $this->truncate( strip_tags( apply_filters( 'get_comment_text', $comment->comment_content ) ), $comment_length );?></p>
519
+ </div>
520
+ <div class="clear"></div>
521
+ </li>
522
+ <?php endforeach; else : ?>
523
+ <li>
524
+ <div class="no-comments"><?php _e( 'No comments yet.', 'wp-tab-widget' ); ?></div>
525
+ </li>
526
+ <?php $no_comments = true;
527
+ endif; ?>
528
+ </ul>
529
+ <?php if ( $allow_pagination && ! $no_comments ) : ?>
530
+ <?php $this->tab_pagination( $page, $last_page ); ?>
531
+ <?php endif; ?>
532
+ <?php
533
+ break;
534
+
535
+ /* ---------- Tags ---------- */
536
+ case "tags":
537
+ ?>
538
+ <ul>
539
+ <?php
540
+ $tags = get_tags( array( 'get' => 'all' ) );
541
+ if ( $tags ) {
542
+ foreach ( $tags as $tag ) : ?>
543
+ <li><a href="<?php echo get_term_link( $tag ); ?>"><?php echo $tag->name; ?></a></li>
544
+ <?php
545
+ endforeach;
546
+ } else {
547
+ _e( 'No tags created.', 'wp-tab-widget' );
548
+ }
549
+ ?>
550
+ </ul>
551
+ <?php
552
+ break;
553
+ }
554
+ die(); // required to return a proper result
555
+ }
556
+
557
+ public function tab_pagination( $page, $last_page ) {
558
+ ?>
559
+ <div class="wpt-pagination">
560
+ <?php if ( $page > 1 ) : ?>
561
+ <a href="#" class="previous"><span><?php _e( '&laquo; Previous', 'wp-tab-widget' ); ?></span></a>
562
+ <?php endif; ?>
563
+ <?php if ( $page != $last_page ) : ?>
564
+ <a href="#" class="next"><span><?php _e( 'Next &raquo;', 'wp-tab-widget' ); ?></span></a>
565
+ <?php endif; ?>
566
+ </div>
567
+ <div class="clear"></div>
568
+ <input type="hidden" class="page_num" name="page_num" value="<?php echo $page; ?>" />
569
+ <?php
570
+ }
571
+
572
+ public function excerpt( $limit = 10 ) {
573
+ $limit++;
574
+ $excerpt = explode( ' ', get_the_excerpt(), $limit );
575
+ if ( count( $excerpt ) >= $limit ) {
576
+ array_pop($excerpt );
577
+ $excerpt = implode(' ', $excerpt ) . '...';
578
+ } else {
579
+ $excerpt = implode(' ', $excerpt );
580
+ }
581
+ $excerpt = preg_replace( '`[[^]]*]`', '', $excerpt );
582
+ return $excerpt;
583
+ }
584
+
585
+ public function post_title( $limit = 10 ) {
586
+ $limit++;
587
+ $title = explode( ' ', get_the_title(), $limit );
588
+ if ( count( $title ) >= $limit ) {
589
+ array_pop( $title );
590
+ $title = implode(' ', $title ) . '...';
591
+ } else {
592
+ $title = implode( ' ', $title );
593
+ }
594
+ return $title;
595
+ }
596
+
597
+ public function truncate( $str, $length = 24 ) {
598
+ if ( mb_strlen( $str ) > $length ) {
599
+ return mb_substr( $str, 0, $length ) . '...';
600
+ } else {
601
+ return $str;
602
+ }
603
+ }
604
+ }
605
+ }
606
+
607
+ add_action( 'widgets_init', function() {
608
+ register_widget( 'wpt_widget' );
609
+ } );
610
+
611
+ // post view count
612
+ // AJAX is used to support caching plugins
613
+ add_filter( 'the_content', 'wpt_view_count_js' ); // outputs JS for AJAX call on single
614
+ add_action( 'wp_ajax_wpt_view_count', 'ajax_wpt_view_count' );
615
+ add_action( 'wp_ajax_nopriv_wpt_view_count','ajax_wpt_view_count' );
616
+ // prevent additional ajax call if theme has view counter already
617
+ add_action( 'mts_view_count_after_update', 'wpt_update_view_count' );
618
+
619
+ function wpt_view_count_js( $content ) {
620
+ global $post;
621
+ $id = $post->ID;
622
+ $use_ajax = apply_filters( 'mts_view_count_cache_support', true );
623
+
624
+ $exclude_admins = apply_filters( 'mts_view_count_exclude_admins', false ); // pass in true or a user capaibility
625
+ if ( true === $exclude_admins ) {
626
+ $exclude_admins = 'edit_posts';
627
+ }
628
+ if ( $exclude_admins && current_user_can( $exclude_admins ) ) {
629
+ return $content; // do not count post views here
630
+ }
631
+ if ( ! is_single() ) {
632
+ return $content; // Only on single posts
633
+ }
634
+
635
+ if ( $use_ajax ) { // prevent additional ajax call if theme has view counter already
636
+ // enqueue jquery
637
+ wp_enqueue_script( 'jquery' );
638
+
639
+ $url = admin_url( 'admin-ajax.php' );
640
+ $content .= "
641
+ <script type=\"text/javascript\">
642
+ jQuery(document).ready(function($) {
643
+ $.post('{$url}', {action: 'wpt_view_count', id: '{$id}'});
644
+ });
645
+ </script>";
646
+ } else {
647
+ wpt_update_view_count( $id );
648
+ }
649
+
650
+ remove_filter( 'the_content', 'wpt_view_count_js' );
651
+
652
+ return $content;
653
+ }
654
+
655
+ function ajax_wpt_view_count() {
656
+ // do count
657
+ $post_id = $_POST['id'];
658
+ wpt_update_view_count( $post_id );
659
+ }
660
+
661
+ function wpt_update_view_count( $post_id ) {
662
+ $sample_rate = intval( apply_filters( 'wpt_sampling_rate', 100 ) ) / 100;
663
+ if ( ( mt_rand() / mt_getrandmax() ) <= $sample_rate ) {
664
+ $count = get_post_meta( $post_id, '_wpt_view_count', true );
665
+ update_post_meta( $post_id, '_wpt_view_count', $count + 1 );
666
+ }
667
+ }
668
+
669
+ // Add meta for all existing posts that don't have it
670
+ // to make them show up in Popular tab
671
+ function wpt_add_views_meta_for_posts() {
672
+ $allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
673
+
674
+ foreach( $allposts as $postinfo ) {
675
+ add_post_meta( $postinfo->ID, '_wpt_view_count', 0, true );
676
+ }
677
+ }
678
+
679
+ // Reset post count for specific post or all posts
680
+ function wpt_reset_post_count( $post_id = 0 ) {
681
+ if ( $post_id == 0 ) {
682
+ $allposts = get_posts( 'numberposts=-1&post_type=post&post_status=any' );
683
+ foreach( $allposts as $postinfo ) {
684
+ update_post_meta( $postinfo->ID, '_wpt_view_count', '0' );
685
+ }
686
+ } else {
687
+ update_post_meta( $post_id, '_wpt_view_count', '0' );
688
+ }
689
+ }
690
+
691
+ // add post meta on plugin activation
692
+ function wpt_plugin_activation() {
693
+ wpt_add_views_meta_for_posts();
694
+ update_option( 'wp_tab_widget_activated', time() );
695
+ }
696
+ register_activation_hook( __FILE__, 'wpt_plugin_activation' );
697
+
698
+ // unregister MTS Tabs Widget and Tabs Widget v2
699
+ add_action( 'widgets_init', 'unregister_mts_tabs_widget', 100 );
700
+ function unregister_mts_tabs_widget() {
701
+ unregister_widget( 'mts_Widget_Tabs_2' );
702
+ unregister_widget( 'mts_Widget_Tabs' );
703
+ }
704
+
705
+ /* Display a admin notice */
706
+
707
+ add_action( 'admin_notices', 'wp_tab_widget_admin_notice' );
708
+ function wp_tab_widget_admin_notice() {
709
+ global $current_user ;
710
+ $user_id = $current_user->ID;
711
+ /* Check that the user hasn't already clicked to ignore the message */
712
+ if ( ! get_user_meta( $user_id, 'wp_tab_widget_ignore_notice' ) && time() >= ( get_option( 'wp_tab_widget_activated', 0 ) + ( 2 * 24 * 60 * 60 ) ) ) {
713
+ echo '<div class="updated notice-info wp-tab-widget-pro-notice" style="position:relative;"><p>';
714
+ echo __( 'Like WP Tab Widget? You will <strong>LOVE WP Tab Widget Pro</strong>!', 'wp-tab-widget' ) . '<a href="https://mythemeshop.com/plugins/wp-tab-widget-pro/?utm_source=WP+Tab+Widget+Free&utm_medium=Notification+Link&utm_content=WP+Tab+Widget+Pro+LP&utm_campaign=WordPressOrg&wpmts" target="_blank">&nbsp;'.__('Click here for all the exciting features.','wp-tab-widget').'</a></p><a href="%1$s" class="dashicons dashicons-dismiss dashicons-dismiss-icon tabwidget-notice-dismiss" data-ignore="0" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
715
+ echo '</div>';
716
+ }
717
+
718
+ /* Other notice appears right after activating */
719
+ /* And it gets hidden after showing 3 times */
720
+ if ( ! get_user_meta( $user_id, 'wp_tab_widget_ignore_notice_2' ) && get_option( 'wp_tab_widget_notice_views', 0 ) < 3 && get_option( 'wp_tab_widget_activated', 0 ) ) {
721
+ $views = get_option( 'wp_tab_widget_notice_views', 0 );
722
+ update_option( 'wp_tab_widget_notice_views', ( $views + 1 ) );
723
+ echo '<div class="updated notice-info wp-tab-widget-notice" id="wptabwodget-notice2" style="position:relative;">';
724
+ echo '<p>';
725
+ _e( 'Thank you for trying WP Tab Widget. We hope you will like it.', 'wp-tab-widget' );
726
+ echo '</p>';
727
+ echo '<a class="notice-dismiss tabwidget-notice-dismiss" data-ignore="1" href="#"></a>';
728
+ echo "</div>";
729
+ }
730
+ }
731
+
732
+ add_action( 'wp_ajax_mts_dismiss_tabwidget_notice', function() {
733
+ global $current_user;
734
+ $user_id = $current_user->ID;
735
+ /* If user clicks to ignore the notice, add that to their user meta */
736
+ if ( isset( $_POST['dismiss'] ) ) {
737
+ if ( '0' == $_POST['dismiss'] ) {
738
+ add_user_meta( $user_id, 'wp_tab_widget_ignore_notice', '1', true );
739
+ } elseif ( '1' == $_POST['dismiss'] ) {
740
+ add_user_meta( $user_id, 'wp_tab_widget_ignore_notice_2', '1', true );
741
+ }
742
+ }
743
+ } );