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 | 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 +244 -244
- img/largethumb.png +0 -0
- img/smallthumb.png +0 -0
- js/wp-tab-widget.js +68 -68
- js/wpt-admin.js +0 -0
- languages/default.po +165 -165
- readme.txt +157 -152
- wp-tab-widget.php +743 -718
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 "« Previous"
|
153 |
-
msgstr ""
|
154 |
-
|
155 |
-
#: ../wp-tab-widget.php:551
|
156 |
-
msgid "Next »"
|
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 "« Previous"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
#: ../wp-tab-widget.php:551
|
156 |
+
msgid "Next »"
|
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 |
-
|
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:
|
6 |
-
Tested up to:
|
7 |
-
|
8 |
-
|
9 |
-
License
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
* It
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
*
|
33 |
-
*
|
34 |
-
*
|
35 |
-
*
|
36 |
-
*
|
37 |
-
*
|
38 |
-
* Show/Hide
|
39 |
-
* Show/Hide
|
40 |
-
*
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
<br>
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
<br>
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
* Fixed
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
*
|
115 |
-
|
116 |
-
= 1.2.
|
117 |
-
*
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
*
|
132 |
-
*
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
*
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
* Added
|
148 |
-
* Fixed
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
*
|
|
|
|
|
|
|
|
|
|
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.
|
8 |
-
Author URI: http://mythemeshop.com/
|
9 |
-
*/
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
add_action('
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
<
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
$instance
|
225 |
-
$instance['
|
226 |
-
$instance['
|
227 |
-
$instance['
|
228 |
-
$instance['
|
229 |
-
$instance['
|
230 |
-
$instance['
|
231 |
-
$instance['
|
232 |
-
$instance['
|
233 |
-
$instance['
|
234 |
-
$instance['
|
235 |
-
$instance['
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
<?php
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
<?php
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
<?php
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
$
|
317 |
-
$
|
318 |
-
$
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
}
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
$
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
$
|
357 |
-
$
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
$
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
<?php
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
$
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
}
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
$
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
function
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
add_action('
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
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 |
+
•
|
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 |
+
•
|
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( '« Previous', 'wp-tab-widget' ); ?></span></a>
|
562 |
+
<?php endif; ?>
|
563 |
+
<?php if ( $page != $last_page ) : ?>
|
564 |
+
<a href="#" class="next"><span><?php _e( 'Next »', '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"> '.__('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 |
+
} );
|