Version Description
- Whole code optimization regarding plugin performance
- Add SQL query optimization regarding plugin performance
- Add Sanitize elements prints on frontend (XSS)
- Test and optimize the plugin to work on website with huge amount of content and small resources
- Fix save and generate new sitemap
- Fix warning with PHP 7.0
Download this release
Release Info
Developer | JoomUnited |
Plugin | WP Meta SEO |
Version | 3.1.0 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.1.0
- css/html_sitemap.css +3 -8
- css/metabox-tabs.css +136 -137
- css/metaseo_admin.css +25 -28
- inc/class.image-helper.php +565 -503
- inc/class.metaseo-admin.php +655 -554
- inc/class.metaseo-broken-link-table.php +496 -356
- inc/class.metaseo-content-list-table.php +387 -385
- inc/class.metaseo-dashboard.php +116 -94
- inc/class.metaseo-image-list-table.php +1050 -966
- inc/class.metaseo-link-list-table.php +234 -184
- inc/class.metaseo-meta.php +52 -8
- inc/class.metaseo-metabox.php +579 -536
- inc/class.metaseo-sitemap.php +524 -462
- inc/class.metaseo-snippet-preview.php +44 -6
- inc/class.wp-metaseo.php +38 -49
- inc/pages/content-meta.php +73 -80
- inc/pages/dashboard.php +118 -120
- inc/pages/image-meta.php +6 -14
- inc/pages/link-meta.php +25 -29
- inc/pages/metaseo-broken-link.php +3 -199
- inc/pages/metaseo-image-compression.php +21 -23
- inc/pages/settings.php +45 -45
- inc/pages/sitemaps/metaseo-google-sitemap.php +10 -12
- inc/pages/sitemaps/metaseo-source_pages.php +23 -14
- inc/pages/sitemaps/metaseo-source_posts.php +14 -6
- js/cliffpyles.js +28 -28
- js/dashboard.js +4 -4
- js/metaseo_admin.js +689 -690
- js/metaseo_sitemap.js +109 -100
- js/pop-up.js +8 -9
- js/site-jPages.js +15 -6
- js/wp-metaseo-admin-media.js +2 -2
- js/wp-metaseo-metabox.js +45 -49
- js/wpms-broken-link.js +220 -0
- js/wpms-bulk-action.js +48 -37
- js/wpms-link-title-field.js +135 -143
- readme.txt +11 -3
- wp-meta-seo.php +456 -429
css/html_sitemap.css
CHANGED
@@ -9,20 +9,15 @@
|
|
9 |
.wpms_clearRow{width:100%; height:24px; display:block; clear:both; position:relative;}
|
10 |
#credits_link{font-size:12px;}
|
11 |
|
12 |
-
/* Columns */
|
13 |
-
/*#wpms_sitemap.columns_2{-moz-column-count: 2; -moz-column-gap: 30px; -webkit-column-count: 2; -webkit-column-gap: 30px; column-count: 2; column-gap: 30px;}
|
14 |
-
#wpms_sitemap.columns_3{-moz-column-count: 3; -moz-column-gap: 25px; -webkit-column-count: 3; -webkit-column-gap: 25px; column-count: 3; column-gap: 25px;}
|
15 |
-
#wpms_sitemap.columns_4{-moz-column-count: 4; -moz-column-gap: 20px; -webkit-column-count: 4; -webkit-column-gap: 20px; column-count: 4; column-gap: 20px;}*/
|
16 |
-
|
17 |
/* Responsive */
|
18 |
@media screen and (max-width:960px){
|
19 |
-
|
20 |
}
|
21 |
@media screen and (max-width:640px){
|
22 |
-
|
23 |
}
|
24 |
@media screen and (max-width:480px){
|
25 |
-
|
26 |
}
|
27 |
.wpms_li_cate{
|
28 |
font-weight:bold;
|
9 |
.wpms_clearRow{width:100%; height:24px; display:block; clear:both; position:relative;}
|
10 |
#credits_link{font-size:12px;}
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
/* Responsive */
|
13 |
@media screen and (max-width:960px){
|
14 |
+
#wpms_sitemap.columns_4{-moz-column-count: 3 !important; -webkit-column-count: 3 !important; column-count: 3 !important;}
|
15 |
}
|
16 |
@media screen and (max-width:640px){
|
17 |
+
#wpms_sitemap.columns_3,#wpms_sitemap.columns_4{-moz-column-count: 2 !important; -webkit-column-count: 2 !important; column-count: 2 !important;}
|
18 |
}
|
19 |
@media screen and (max-width:480px){
|
20 |
+
#wpms_sitemap.columns_4,#wpms_sitemap.columns_3,#wpms_sitemap.columns_2{-moz-column-count: 1 !important; -webkit-column-count: 1 !important; column-count: 1 !important;}
|
21 |
}
|
22 |
.wpms_li_cate{
|
23 |
font-weight:bold;
|
css/metabox-tabs.css
CHANGED
@@ -1,210 +1,209 @@
|
|
1 |
ul.wpmseo-metabox-tabs {
|
2 |
-
|
3 |
-
|
4 |
-
margin-bottom: 3px;
|
5 |
}
|
6 |
|
7 |
.wpmseo-metabox-tabs-div ul {
|
8 |
-
|
9 |
}
|
10 |
|
11 |
.wpmseo-metabox-tabs li {
|
12 |
-
|
13 |
}
|
14 |
|
15 |
ul.wpmseo-metabox-tabs li.active {
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
}
|
20 |
|
21 |
ul.wpmseo-metabox-tabs li {
|
22 |
-
|
23 |
}
|
24 |
|
25 |
.wpmseo-metabox-tabs a {
|
26 |
-
|
27 |
-
|
28 |
}
|
29 |
|
30 |
.wpmseo-metabox-tabs-div div.wpmseo-tabs-panel {
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
}
|
35 |
|
36 |
.wpmseo-heading {
|
37 |
-
|
38 |
}
|
39 |
|
40 |
.wpmseotab {
|
41 |
-
|
42 |
}
|
43 |
|
44 |
.wpmseotab.active {
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
}
|
51 |
|
52 |
#wpmseo_meta .postbox .inside .wpmseotab {
|
53 |
-
|
54 |
}
|
55 |
|
56 |
.inside .wpmseotab .form-table th {
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
|
61 |
.good,
|
62 |
.warn,
|
63 |
.wrong {
|
64 |
-
|
65 |
}
|
66 |
|
67 |
.wpmseotab .good{
|
68 |
-
|
69 |
}
|
70 |
|
71 |
.wpmseotab .warn {
|
72 |
-
|
73 |
}
|
74 |
|
75 |
.wpmseotab .wrong {
|
76 |
-
|
77 |
}
|
78 |
|
79 |
#current_seo_title span {
|
80 |
-
|
81 |
-
|
82 |
}
|
83 |
|
84 |
#wpmseosnippet {
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
}
|
92 |
|
93 |
#wpmseosnippet td {
|
94 |
-
|
95 |
-
|
96 |
}
|
97 |
|
98 |
#wpmseosnippet cite.url {
|
99 |
-
|
100 |
-
|
101 |
}
|
102 |
|
103 |
#wpmseosnippet a {
|
104 |
-
|
105 |
}
|
106 |
|
107 |
#wpmseosnippet .title {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
}
|
117 |
|
118 |
#wpmseosnippet .desc {
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
}
|
123 |
|
124 |
#wpmseosnippet .desc .autogen {
|
125 |
-
|
126 |
}
|
127 |
|
128 |
#wpmseosnippet .date {
|
129 |
-
|
130 |
}
|
131 |
|
132 |
#wpmseosnippet .desc p {
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
}
|
138 |
|
139 |
#wpmseosnippet .url {
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
}
|
144 |
|
145 |
#wpmseosnippet .meta {
|
146 |
-
|
147 |
}
|
148 |
|
149 |
#wpmseosnippet .util {
|
150 |
-
|
151 |
}
|
152 |
|
153 |
#wpmseosnippet p {
|
154 |
-
|
155 |
}
|
156 |
|
157 |
#wpmseosnippet a:hover {
|
158 |
-
|
159 |
}
|
160 |
|
161 |
#mfocuskwresults ul {
|
162 |
-
|
163 |
}
|
164 |
|
165 |
#mfocuskwresults p,
|
166 |
#mfocuskwresults li {
|
167 |
-
|
168 |
}
|
169 |
|
170 |
#mfocuskwresults li {
|
171 |
-
|
172 |
-
|
173 |
}
|
174 |
|
175 |
.wpmseo_hidden {
|
176 |
-
|
177 |
}
|
178 |
|
179 |
/* Linkdex analysis block */
|
180 |
|
181 |
table.wpmseoanalysis th {
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
}
|
186 |
|
187 |
table.wpmseoanalysis th.first {
|
188 |
-
|
189 |
}
|
190 |
|
191 |
table.wpmseoanalysis td {
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
}
|
196 |
|
197 |
table.wpmseoanalysis td.score {
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
}
|
202 |
|
203 |
.wpmseo_msg {
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
}
|
209 |
|
210 |
/*
|
@@ -222,13 +221,13 @@ table.wpmseoanalysis td.score {
|
|
222 |
----------------------------------*/
|
223 |
|
224 |
#wpmseotab .ui-widget-content {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
}
|
229 |
|
230 |
#wpmseotab .ui-widget-content a {
|
231 |
-
|
232 |
}
|
233 |
|
234 |
/*
|
@@ -236,13 +235,13 @@ table.wpmseoanalysis td.score {
|
|
236 |
* http://docs.jquery.com/UI/Autocomplete#theming
|
237 |
*/
|
238 |
#wpmseotab .ui-autocomplete {
|
239 |
-
|
240 |
-
|
241 |
}
|
242 |
|
243 |
/* workarounds */
|
244 |
* html #wpmseotab .ui-autocomplete {
|
245 |
-
|
246 |
}
|
247 |
|
248 |
/* without this, the menu expands to 100% in IE6 */
|
@@ -253,111 +252,111 @@ table.wpmseoanalysis td.score {
|
|
253 |
* http://docs.jquery.com/UI/Menu#theming
|
254 |
*/
|
255 |
.ui-menu {
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
}
|
262 |
|
263 |
.ui-menu .ui-menu {
|
264 |
-
|
265 |
}
|
266 |
|
267 |
.ui-menu .ui-menu-item {
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
}
|
275 |
|
276 |
.ui-menu .ui-menu-item a {
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
}
|
283 |
|
284 |
.ui-menu .ui-menu-item a.ui-state-hover,
|
285 |
.ui-menu .ui-menu-item a.ui-state-active {
|
286 |
-
|
287 |
-
|
288 |
}
|
289 |
|
290 |
.wpmseo-score-icon {
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
}
|
299 |
|
300 |
.wpmseo-score-icon.good {
|
301 |
-
|
302 |
}
|
303 |
|
304 |
.wpmseo-score-icon.ok {
|
305 |
-
|
306 |
}
|
307 |
|
308 |
.wpmseo-score-icon.poor {
|
309 |
-
|
310 |
}
|
311 |
|
312 |
.wpmseo-score-icon.bad {
|
313 |
-
|
314 |
}
|
315 |
|
316 |
.wpmseo-score-icon.na {
|
317 |
-
|
318 |
}
|
319 |
|
320 |
.wpmseo-score-icon.noindex {
|
321 |
-
|
322 |
}
|
323 |
|
324 |
.wpmseo-score-title {
|
325 |
-
|
326 |
}
|
327 |
|
328 |
i.metaseo_help {
|
329 |
-
|
330 |
-
|
331 |
}
|
332 |
|
333 |
.metaseo-qtip {
|
334 |
-
|
335 |
-
|
336 |
}
|
337 |
|
338 |
.wpmseo_content_wrapper p.search-box {
|
339 |
-
|
340 |
}
|
341 |
|
342 |
|
343 |
ul.wpmseo-metabox-tabs li.active {
|
344 |
-
|
345 |
}
|
346 |
|
347 |
ul.wpmseo-metabox-tabs li.active,
|
348 |
div.wpmseo-tab-content {
|
349 |
-
|
350 |
-
|
351 |
}
|
352 |
|
353 |
.wpmseo-metabox-tabs .active a {
|
354 |
-
|
355 |
}
|
356 |
|
357 |
#wpmseotab .ui-widget-content .ui-state-hover {
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
}
|
362 |
|
363 |
|
@@ -381,7 +380,7 @@ div.wpmseo-tab-content {
|
|
381 |
display: block;
|
382 |
width: 275px;
|
383 |
height: 275px;
|
384 |
-
/* margin: 7px;*/
|
385 |
padding: 0;
|
386 |
float: left;
|
387 |
}
|
1 |
ul.wpmseo-metabox-tabs {
|
2 |
+
margin-top: 12px;
|
3 |
+
margin-bottom: 3px;
|
|
|
4 |
}
|
5 |
|
6 |
.wpmseo-metabox-tabs-div ul {
|
7 |
+
list-style: none;
|
8 |
}
|
9 |
|
10 |
.wpmseo-metabox-tabs li {
|
11 |
+
display: inline;
|
12 |
}
|
13 |
|
14 |
ul.wpmseo-metabox-tabs li.active {
|
15 |
+
border-width: 1px 1px 0;
|
16 |
+
border-style: solid solid none;
|
17 |
+
background-color: #fdfdfd;
|
18 |
}
|
19 |
|
20 |
ul.wpmseo-metabox-tabs li {
|
21 |
+
padding: 5px;
|
22 |
}
|
23 |
|
24 |
.wpmseo-metabox-tabs a {
|
25 |
+
text-decoration: none;
|
26 |
+
cursor: pointer;
|
27 |
}
|
28 |
|
29 |
.wpmseo-metabox-tabs-div div.wpmseo-tabs-panel {
|
30 |
+
overflow: auto;
|
31 |
+
padding: 0.5em 0.9em;
|
32 |
+
border: 1px solid;
|
33 |
}
|
34 |
|
35 |
.wpmseo-heading {
|
36 |
+
padding-left: 10px;
|
37 |
}
|
38 |
|
39 |
.wpmseotab {
|
40 |
+
display: none;
|
41 |
}
|
42 |
|
43 |
.wpmseotab.active {
|
44 |
+
display: block;
|
45 |
+
overflow: hidden;
|
46 |
+
padding: 0.5em 0.9em;
|
47 |
+
border: 1px solid #ddd;
|
48 |
+
background-color: #fdfdfd;
|
49 |
}
|
50 |
|
51 |
#wpmseo_meta .postbox .inside .wpmseotab {
|
52 |
+
font-size: 13px !important;
|
53 |
}
|
54 |
|
55 |
.inside .wpmseotab .form-table th {
|
56 |
+
width: 140px !important;
|
57 |
+
font-size: 13px;
|
58 |
}
|
59 |
|
60 |
.good,
|
61 |
.warn,
|
62 |
.wrong {
|
63 |
+
font-weight: bold;
|
64 |
}
|
65 |
|
66 |
.wpmseotab .good{
|
67 |
+
color: #fff !important;
|
68 |
}
|
69 |
|
70 |
.wpmseotab .warn {
|
71 |
+
color: #fff !important;
|
72 |
}
|
73 |
|
74 |
.wpmseotab .wrong {
|
75 |
+
color: #fff !important;
|
76 |
}
|
77 |
|
78 |
#current_seo_title span {
|
79 |
+
padding: 2px 5px;
|
80 |
+
background-color: lightyellow;
|
81 |
}
|
82 |
|
83 |
#wpmseosnippet {
|
84 |
+
width: auto;
|
85 |
+
max-width: 520px;
|
86 |
+
margin: 0 0 10px;
|
87 |
+
padding: 0 5px;
|
88 |
+
font-family: Arial, Helvetica, sans-serif;
|
89 |
+
font-style: normal;
|
90 |
}
|
91 |
|
92 |
#wpmseosnippet td {
|
93 |
+
margin: 0;
|
94 |
+
padding: 0;
|
95 |
}
|
96 |
|
97 |
#wpmseosnippet cite.url {
|
98 |
+
font-weight: normal;
|
99 |
+
font-style: normal;
|
100 |
}
|
101 |
|
102 |
#wpmseosnippet a {
|
103 |
+
text-decoration: none;
|
104 |
}
|
105 |
|
106 |
#wpmseosnippet .title {
|
107 |
+
display: block;
|
108 |
+
overflow: hidden;
|
109 |
+
width: 512px;
|
110 |
+
color: #1e0fbe;
|
111 |
+
font-size: 18px !important;
|
112 |
+
line-height: 1.2;
|
113 |
+
white-space: nowrap;
|
114 |
+
text-overflow: ellipsis;
|
115 |
}
|
116 |
|
117 |
#wpmseosnippet .desc {
|
118 |
+
font-size: small;
|
119 |
+
line-height: 1.4;
|
120 |
+
word-wrap: break-word;
|
121 |
}
|
122 |
|
123 |
#wpmseosnippet .desc .autogen {
|
124 |
+
color: #777;
|
125 |
}
|
126 |
|
127 |
#wpmseosnippet .date {
|
128 |
+
color: #808080;
|
129 |
}
|
130 |
|
131 |
#wpmseosnippet .desc p {
|
132 |
+
color: #545454;
|
133 |
+
font-size: small;
|
134 |
+
line-height: 1.4;
|
135 |
+
word-wrap: break-word;
|
136 |
}
|
137 |
|
138 |
#wpmseosnippet .url {
|
139 |
+
color: #006621;
|
140 |
+
font-size: 13px;
|
141 |
+
line-height: 16px;
|
142 |
}
|
143 |
|
144 |
#wpmseosnippet .meta {
|
145 |
+
color: #767676;
|
146 |
}
|
147 |
|
148 |
#wpmseosnippet .util {
|
149 |
+
color: #4272db;
|
150 |
}
|
151 |
|
152 |
#wpmseosnippet p {
|
153 |
+
margin: 0 !important;
|
154 |
}
|
155 |
|
156 |
#wpmseosnippet a:hover {
|
157 |
+
text-decoration: underline;
|
158 |
}
|
159 |
|
160 |
#mfocuskwresults ul {
|
161 |
+
margin: 0;
|
162 |
}
|
163 |
|
164 |
#mfocuskwresults p,
|
165 |
#mfocuskwresults li {
|
166 |
+
font-size: 13px;
|
167 |
}
|
168 |
|
169 |
#mfocuskwresults li {
|
170 |
+
margin: 0 0 0 20px;
|
171 |
+
list-style-type: disc;
|
172 |
}
|
173 |
|
174 |
.wpmseo_hidden {
|
175 |
+
display: none;
|
176 |
}
|
177 |
|
178 |
/* Linkdex analysis block */
|
179 |
|
180 |
table.wpmseoanalysis th {
|
181 |
+
padding: 15px 0 5px 0;
|
182 |
+
font-size: 14px;
|
183 |
+
text-align: left;
|
184 |
}
|
185 |
|
186 |
table.wpmseoanalysis th.first {
|
187 |
+
padding-top: 0;
|
188 |
}
|
189 |
|
190 |
table.wpmseoanalysis td {
|
191 |
+
margin: 5px 0;
|
192 |
+
font-size: 13px;
|
193 |
+
line-height: 16px;
|
194 |
}
|
195 |
|
196 |
table.wpmseoanalysis td.score {
|
197 |
+
width: 20px;
|
198 |
+
height: 18px;
|
199 |
+
padding-left: 10px;
|
200 |
}
|
201 |
|
202 |
.wpmseo_msg {
|
203 |
+
margin: 5px 0 10px 0;
|
204 |
+
padding: 0 5px;
|
205 |
+
border: 1px solid #e6db55;
|
206 |
+
background-color: lightYellow;
|
207 |
}
|
208 |
|
209 |
/*
|
221 |
----------------------------------*/
|
222 |
|
223 |
#wpmseotab .ui-widget-content {
|
224 |
+
border: 1px solid #ddd;
|
225 |
+
color: #333;
|
226 |
+
background: #f1f1f1;
|
227 |
}
|
228 |
|
229 |
#wpmseotab .ui-widget-content a {
|
230 |
+
color: #333;
|
231 |
}
|
232 |
|
233 |
/*
|
235 |
* http://docs.jquery.com/UI/Autocomplete#theming
|
236 |
*/
|
237 |
#wpmseotab .ui-autocomplete {
|
238 |
+
position: absolute;
|
239 |
+
cursor: default;
|
240 |
}
|
241 |
|
242 |
/* workarounds */
|
243 |
* html #wpmseotab .ui-autocomplete {
|
244 |
+
width: 1px;
|
245 |
}
|
246 |
|
247 |
/* without this, the menu expands to 100% in IE6 */
|
252 |
* http://docs.jquery.com/UI/Menu#theming
|
253 |
*/
|
254 |
.ui-menu {
|
255 |
+
display: block;
|
256 |
+
float: left;
|
257 |
+
margin: 0;
|
258 |
+
padding: 2px;
|
259 |
+
list-style: none;
|
260 |
}
|
261 |
|
262 |
.ui-menu .ui-menu {
|
263 |
+
margin-top: -3px;
|
264 |
}
|
265 |
|
266 |
.ui-menu .ui-menu-item {
|
267 |
+
float: left;
|
268 |
+
clear: left;
|
269 |
+
zoom: 1;
|
270 |
+
width: 100%;
|
271 |
+
margin: 0;
|
272 |
+
padding: 0;
|
273 |
}
|
274 |
|
275 |
.ui-menu .ui-menu-item a {
|
276 |
+
display: block;
|
277 |
+
zoom: 1;
|
278 |
+
padding: 0.2em 0.4em;
|
279 |
+
line-height: 1.5;
|
280 |
+
text-decoration: none;
|
281 |
}
|
282 |
|
283 |
.ui-menu .ui-menu-item a.ui-state-hover,
|
284 |
.ui-menu .ui-menu-item a.ui-state-active {
|
285 |
+
margin: -1px;
|
286 |
+
color: #000;
|
287 |
}
|
288 |
|
289 |
.wpmseo-score-icon {
|
290 |
+
display: inline-block;
|
291 |
+
width: 12px;
|
292 |
+
height: 12px;
|
293 |
+
margin: 3px 10px 0 3px;
|
294 |
+
border-radius: 50%;
|
295 |
+
background: #888;
|
296 |
+
vertical-align: top;
|
297 |
}
|
298 |
|
299 |
.wpmseo-score-icon.good {
|
300 |
+
background-color: #7ad03a;
|
301 |
}
|
302 |
|
303 |
.wpmseo-score-icon.ok {
|
304 |
+
background-color: #ffba00;
|
305 |
}
|
306 |
|
307 |
.wpmseo-score-icon.poor {
|
308 |
+
background-color: #ee7c1b;
|
309 |
}
|
310 |
|
311 |
.wpmseo-score-icon.bad {
|
312 |
+
background-color: #dd3d36;
|
313 |
}
|
314 |
|
315 |
.wpmseo-score-icon.na {
|
316 |
+
background-color: #888;
|
317 |
}
|
318 |
|
319 |
.wpmseo-score-icon.noindex {
|
320 |
+
background-color: #1e8cbe;
|
321 |
}
|
322 |
|
323 |
.wpmseo-score-title {
|
324 |
+
font-weight: 600;
|
325 |
}
|
326 |
|
327 |
i.metaseo_help {
|
328 |
+
cursor: pointer;
|
329 |
+
font-size: 20px;
|
330 |
}
|
331 |
|
332 |
.metaseo-qtip {
|
333 |
+
font-size: 14px !important;
|
334 |
+
line-height: 18px !important;
|
335 |
}
|
336 |
|
337 |
.wpmseo_content_wrapper p.search-box {
|
338 |
+
margin: 10px 0 5px 0;
|
339 |
}
|
340 |
|
341 |
|
342 |
ul.wpmseo-metabox-tabs li.active {
|
343 |
+
background-color: #f1f1f1;
|
344 |
}
|
345 |
|
346 |
ul.wpmseo-metabox-tabs li.active,
|
347 |
div.wpmseo-tab-content {
|
348 |
+
border-color: #dfdfdf;
|
349 |
+
background-color: #fff;
|
350 |
}
|
351 |
|
352 |
.wpmseo-metabox-tabs .active a {
|
353 |
+
color: #333;
|
354 |
}
|
355 |
|
356 |
#wpmseotab .ui-widget-content .ui-state-hover {
|
357 |
+
border: 1px solid #dfdfdf;
|
358 |
+
color: #333;
|
359 |
+
background: #f1f1f1;
|
360 |
}
|
361 |
|
362 |
|
380 |
display: block;
|
381 |
width: 275px;
|
382 |
height: 275px;
|
383 |
+
/* margin: 7px;*/
|
384 |
padding: 0;
|
385 |
float: left;
|
386 |
}
|
css/metaseo_admin.css
CHANGED
@@ -42,11 +42,11 @@ and open the template in the editor.
|
|
42 |
}
|
43 |
|
44 |
.title-len, .desc-len, .keywords-len {
|
45 |
-
|
46 |
-
|
47 |
}
|
48 |
.word-exceed {
|
49 |
-
|
50 |
}
|
51 |
|
52 |
.savedInfo {
|
@@ -58,7 +58,6 @@ and open the template in the editor.
|
|
58 |
/* Snippet */
|
59 |
.snippet {
|
60 |
border:none;
|
61 |
-
/* padding: 4px;*/
|
62 |
margin-top: 2px;
|
63 |
}
|
64 |
|
@@ -68,25 +67,24 @@ and open the template in the editor.
|
|
68 |
font-size: 16px!important;
|
69 |
line-height: 1.2;
|
70 |
text-overflow: ellipsis;
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
font-size: 13px;
|
75 |
line-height: 16px;
|
76 |
-
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
.widefat .snippet_metades {
|
79 |
-
color: #545454;
|
80 |
-
}
|
81 |
-
|
82 |
a.snippet_metatitle:hover {
|
83 |
text-decoration: underline;
|
84 |
-
|
85 |
}
|
86 |
|
87 |
a.info-content {
|
88 |
outline:none;
|
89 |
-
/* padding-right: 10px;*/
|
90 |
margin-left: 10px;
|
91 |
}
|
92 |
|
@@ -118,8 +116,8 @@ a.info-content .tooltip-metacontent .tooltip-metatitle {
|
|
118 |
}
|
119 |
|
120 |
a.info-content .tooltip-metacontent .tooltip-metalink{color: #006621;
|
121 |
-
|
122 |
-
|
123 |
}
|
124 |
|
125 |
a.info-content .tooltip-metacontent .tooltip-metades {
|
@@ -139,27 +137,26 @@ a.info-content .tooltip-metacontent
|
|
139 |
{
|
140 |
border-radius:2px;
|
141 |
box-shadow: 5px 5px 8px #eee;
|
142 |
-
|
143 |
}
|
144 |
|
145 |
.metaseo-metatitle, .metaseo-metadesc{
|
146 |
-
|
147 |
}
|
148 |
.action-wrapper{
|
149 |
-
/* width:38%;*/
|
150 |
-
|
151 |
}
|
152 |
.snippet-wrapper{
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
margin-top: 20px;
|
157 |
}
|
158 |
|
159 |
@media all and (max-width:768px){
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
}
|
164 |
|
165 |
/* Alexa CSS */
|
@@ -340,7 +337,7 @@ strong {
|
|
340 |
margin: 0 0 10px;
|
341 |
}
|
342 |
.note-no-data{
|
343 |
-
|
344 |
}
|
345 |
.yellow-box {
|
346 |
height: auto;
|
42 |
}
|
43 |
|
44 |
.title-len, .desc-len, .keywords-len {
|
45 |
+
background: none repeat scroll 0% 0% #7ad03a;
|
46 |
+
|
47 |
}
|
48 |
.word-exceed {
|
49 |
+
background: none repeat scroll 0% 0% #FFCC00;
|
50 |
}
|
51 |
|
52 |
.savedInfo {
|
58 |
/* Snippet */
|
59 |
.snippet {
|
60 |
border:none;
|
|
|
61 |
margin-top: 2px;
|
62 |
}
|
63 |
|
67 |
font-size: 16px!important;
|
68 |
line-height: 1.2;
|
69 |
text-overflow: ellipsis;
|
70 |
+
}
|
71 |
+
.snippet_metalink {
|
72 |
+
color: #006621;
|
73 |
font-size: 13px;
|
74 |
line-height: 16px;
|
75 |
+
}
|
76 |
+
|
77 |
+
.widefat .snippet_metades {
|
78 |
+
color: #545454;
|
79 |
+
}
|
80 |
|
|
|
|
|
|
|
|
|
81 |
a.snippet_metatitle:hover {
|
82 |
text-decoration: underline;
|
83 |
+
color: #1E0FBE;
|
84 |
}
|
85 |
|
86 |
a.info-content {
|
87 |
outline:none;
|
|
|
88 |
margin-left: 10px;
|
89 |
}
|
90 |
|
116 |
}
|
117 |
|
118 |
a.info-content .tooltip-metacontent .tooltip-metalink{color: #006621;
|
119 |
+
font-size: 13px;
|
120 |
+
line-height: 16px;
|
121 |
}
|
122 |
|
123 |
a.info-content .tooltip-metacontent .tooltip-metades {
|
137 |
{
|
138 |
border-radius:2px;
|
139 |
box-shadow: 5px 5px 8px #eee;
|
140 |
+
|
141 |
}
|
142 |
|
143 |
.metaseo-metatitle, .metaseo-metadesc{
|
144 |
+
padding:4px 6px;
|
145 |
}
|
146 |
.action-wrapper{
|
147 |
+
/* width:38%;*/
|
148 |
+
float:left;
|
149 |
}
|
150 |
.snippet-wrapper{
|
151 |
+
width:100%;
|
152 |
+
float:left;
|
153 |
+
margin-top: 20px;
|
|
|
154 |
}
|
155 |
|
156 |
@media all and (max-width:768px){
|
157 |
+
.action-wrapper, .snippet-wrapper{
|
158 |
+
width: auto; float:none;
|
159 |
+
}
|
160 |
}
|
161 |
|
162 |
/* Alexa CSS */
|
337 |
margin: 0 0 10px;
|
338 |
}
|
339 |
.note-no-data{
|
340 |
+
padding:12px 12px 12px 0;
|
341 |
}
|
342 |
.yellow-box {
|
343 |
height: auto;
|
inc/class.image-helper.php
CHANGED
@@ -1,512 +1,574 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
class ImageHelper{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
$sizes = 'MB';
|
226 |
-
}else{
|
227 |
$sizes = 'KB';
|
228 |
}
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
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 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
313 |
return $ret;
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
public static function IScanPosts($imgs, $meta_checking = false, $forceScan = false){
|
321 |
-
global $wpdb;
|
322 |
-
$msg = array();
|
323 |
-
$meta_keys = array('alt', 'title');
|
324 |
-
$_imgs = array_flip($imgs);
|
325 |
-
|
326 |
-
$post_types = MetaSeo_Content_List_Table::get_post_types();
|
327 |
-
$query = "SELECT `ID`, `post_title`, `post_content`, `post_type`, `post_date`
|
328 |
-
FROM $wpdb->posts
|
329 |
-
WHERE `post_type` IN ($post_types)
|
330 |
-
AND `post_content` <> ''
|
331 |
-
AND `post_content` LIKE '%<img%>%'
|
332 |
-
ORDER BY ID";
|
333 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
$posts = $wpdb->get_results($query);
|
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 |
-
if(!($post_content = @$wpdb->get_row($query)->post_content)){
|
418 |
-
$ret['msg'] = __('This post is not existed or deleted, please choose one another!','wp-meta-seo');
|
419 |
-
|
420 |
-
return $ret;
|
421 |
-
}
|
422 |
-
|
423 |
-
$imgs_to_resize = get_post_meta($img_post_id, '_metaseo_resize_image', true);
|
424 |
-
|
425 |
-
if(preg_match_all('/<img [^<>]+ \/>/i', $post_content, $matches)){
|
426 |
-
$img_tags = $matches[0];
|
427 |
-
$replacement = array();
|
428 |
-
foreach($matches[0] as $order => $tag){
|
429 |
-
$replacement[$order] = $tag;
|
430 |
-
//This block of code maybe changed later
|
431 |
-
if(preg_match('/(width|height)="([^\"]+)"/i', $tag, $dimension)){
|
432 |
-
if(!isset($imgs_to_resize[$post_id])) { continue; }
|
433 |
-
foreach($imgs_to_resize[$post_id]['img_after_optm'] as $key => $img){
|
434 |
-
if(!in_array($order, $img_exclude)){
|
435 |
-
if(stripos($tag, $img['src_origin']) !== false &&
|
436 |
-
(('width' == $dimension[1] && $dimension[2] == $img['width'])
|
437 |
-
|| ('height' == $dimension[1] && $dimension[2] == $img['height']))){
|
438 |
-
|
439 |
-
$replacement[$order] = str_replace($img['src_origin'], $img['src'], $tag);
|
440 |
-
|
441 |
-
}
|
442 |
-
}
|
443 |
-
}
|
444 |
-
}
|
445 |
-
#}
|
446 |
-
}
|
447 |
-
|
448 |
-
//Replace all imgs sources that have new value
|
449 |
-
$post_content = str_replace($matches[0], $replacement, $post_content);
|
450 |
-
}
|
451 |
-
|
452 |
-
//Update post content with all imgs has been just optimized
|
453 |
-
$id = wp_update_post(array(
|
454 |
-
'ID' => $post_id,
|
455 |
-
'post_content' => $post_content
|
456 |
-
));
|
457 |
-
|
458 |
-
if($id){
|
459 |
-
$ret['success'] = true;
|
460 |
-
$ret['msg'] = __('Well! This image is so good now.', 'wp-meta-seo');
|
461 |
-
}
|
462 |
-
else{
|
463 |
-
$ret['msg'] = __('Opps! An error occured when updating the post, please try again', 'wp-meta-seo');
|
464 |
-
}
|
465 |
-
|
466 |
-
return $ret;
|
467 |
-
}
|
468 |
-
|
469 |
-
/**
|
470 |
-
*
|
471 |
-
*/
|
472 |
-
public static function IResize($src, $width, $height, $destination){
|
473 |
-
if(!list($w_origin, $h_origin) = getimagesize($src)) return "Unsupported picture type!";
|
474 |
-
|
475 |
-
if(is_readable($destination)){
|
476 |
-
return true;
|
477 |
-
}
|
478 |
-
|
479 |
-
$type = strtolower(substr(strrchr($src,"."),1));
|
480 |
-
if($type === 'jpeg') $type = 'jpg';
|
481 |
-
switch($type){
|
482 |
-
case 'bmp': $img = imagecreatefromwbmp($src); break;
|
483 |
-
case 'gif': $img = imagecreatefromgif($src); break;
|
484 |
-
case 'jpg': $img = imagecreatefromjpeg($src); break;
|
485 |
-
case 'png': $img = imagecreatefrompng($src); break;
|
486 |
-
default : return "Unsupported picture type!";
|
487 |
-
}
|
488 |
-
|
489 |
-
$new = imagecreatetruecolor($width, $height);
|
490 |
-
|
491 |
-
// preserve transparency
|
492 |
-
if($type === "gif" or $type === "png"){
|
493 |
-
imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
|
494 |
-
imagealphablending($new, false);
|
495 |
-
imagesavealpha($new, true);
|
496 |
-
}
|
497 |
-
|
498 |
-
imagecopyresampled($new, $img, 0, 0, 0, 0, $width, $height, $w_origin, $h_origin);
|
499 |
-
|
500 |
-
//Output
|
501 |
-
switch($type){
|
502 |
-
case 'bmp': imagewbmp($new, $destination); break;
|
503 |
-
case 'gif': imagegif($new, $destination); break;
|
504 |
-
case 'jpg': imagejpeg($new, $destination); break;
|
505 |
-
case 'png': imagepng($new, $destination); break;
|
506 |
-
}
|
507 |
-
|
508 |
-
return true;
|
509 |
-
}
|
510 |
-
|
511 |
-
}
|
512 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
* This class implements some function for image optimize
|
4 |
+
*
|
5 |
+
*/
|
6 |
|
7 |
+
class ImageHelper {
|
8 |
+
|
9 |
+
public static $src = '';
|
10 |
+
|
11 |
+
public function __construct(array $params = array()) {
|
12 |
+
$c = new ReflectionClass(__CLASS__);
|
13 |
+
$statics = $c->getStaticProperties();
|
14 |
+
|
15 |
+
foreach ($params as $key => $value) {
|
16 |
+
if (!in_array($key, array_keys($statics))) {
|
17 |
+
$this->{$key} = $value;
|
18 |
+
} else {
|
19 |
+
self::$$key = $value;
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
/*
|
25 |
+
* get image info
|
26 |
+
*/
|
27 |
+
public static function IGetPart($src = '') {
|
28 |
+
if ($src == '') {
|
29 |
+
$src = self::$src;
|
30 |
+
}
|
31 |
+
$ipart = new ImageHelper(array(
|
32 |
+
'src' => $src,
|
33 |
+
'base_path' => '',
|
34 |
+
'name' => '',
|
35 |
+
'ext' => '',
|
36 |
+
'dimension' => '',
|
37 |
+
'name_prefix' => '',
|
38 |
+
'name_suffix' => ''));
|
39 |
+
|
40 |
+
if (($dot = strrpos($src, '.')) === false) {
|
41 |
+
return $ipart;
|
42 |
+
}
|
43 |
+
|
44 |
+
if (($bslash = strrpos($src, '/')) === false) {
|
45 |
+
$bslash = 0;
|
46 |
+
} else {
|
47 |
+
$bslash++;
|
48 |
+
}
|
49 |
+
|
50 |
+
$ipart->_src = $src;
|
51 |
+
$ipart->base_path = substr($src, 0, $bslash);
|
52 |
+
$ipart->name = substr($src, $bslash, $dot - $bslash);
|
53 |
+
$ipart->ext = substr($src, $dot);
|
54 |
+
$ipart->dimension = self::IGetDimension($ipart->name);
|
55 |
+
if (!empty($ipart->dimension)) {
|
56 |
+
$ipart->name_prefix = substr($ipart->name, 0, strpos($ipart->name, $ipart->dimension) - 1);
|
57 |
+
$ipart->name_suffix = str_replace($ipart->name_prefix . '-' . $ipart->dimension, '', $ipart->name);
|
58 |
+
} else {
|
59 |
+
$ipart->name_prefix = $ipart->name_suffix = '';
|
60 |
+
}
|
61 |
+
|
62 |
+
return $ipart;
|
63 |
+
}
|
64 |
+
|
65 |
+
/*
|
66 |
+
* get Image width and height
|
67 |
+
*/
|
68 |
+
public static function IGetDimension($src) {
|
69 |
+
if (preg_match_all('/(\d+)x(\d+)/i', $src, $match)) {
|
70 |
+
return count($match) > 0 ? end($match[0]) : '';
|
71 |
+
}
|
72 |
+
|
73 |
+
return '';
|
74 |
+
}
|
75 |
+
|
76 |
+
public static function get($part, $src = '') {
|
77 |
+
if ($src == '') {
|
78 |
+
$src = self::$src;
|
79 |
+
}
|
80 |
+
$ipart = self::getIPart($src);
|
81 |
+
return isset($ipart->{$part}) ? $ipart->{$part} : '';
|
82 |
+
}
|
83 |
+
|
84 |
+
/*
|
85 |
+
* Replace image src
|
86 |
+
*/
|
87 |
+
public static function IReplace($newName, $src = '') {
|
88 |
+
if ($src == '') {
|
89 |
+
$src = self::$src;
|
90 |
+
}
|
91 |
+
if ($newName === '') {
|
92 |
+
return $src;
|
93 |
+
}
|
94 |
+
|
95 |
+
$ipart = self::IgetPart($src);
|
96 |
+
$src = $ipart->base_path . $newName . '-' . $ipart->dimension . $ipart->name_suffix . $ipart->ext;
|
97 |
+
return $src;
|
98 |
+
}
|
99 |
+
|
100 |
+
public static function IHasClone($img, $obj) {
|
101 |
+
if (!is_array($img)) {
|
102 |
+
$img = array($img);
|
103 |
+
}
|
104 |
+
$obj_part = self::IGetPart($obj);
|
105 |
+
|
106 |
+
foreach ($img as $_img) {
|
107 |
+
$img_part = self::IGetPart($_img);
|
108 |
+
if ($img_part->ext !== $obj_part->ext) {
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
|
112 |
+
if ($obj_part->dimension !== '') {
|
113 |
+
$cmp = $obj_part->name_prefix;
|
114 |
+
} else {
|
115 |
+
$cmp = $obj_part->name;
|
116 |
+
}
|
117 |
+
|
118 |
+
if (strcmp($img_part->name, $cmp) === 0) {
|
119 |
+
return $_img;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
return false;
|
124 |
+
}
|
125 |
+
|
126 |
+
/*
|
127 |
+
* get image info when scan post
|
128 |
+
*/
|
129 |
+
public static function IScan($imgs = array(), $content) {
|
130 |
+
$ifound = array();
|
131 |
+
$doc = new DOMDocument();
|
132 |
+
libxml_use_internal_errors(true);
|
133 |
+
@$doc->loadHtml($content);
|
134 |
+
$tags = $doc->getElementsByTagName('img');
|
135 |
+
|
136 |
+
//For standard images names, convert spaces to -
|
137 |
+
$_imgs = array();
|
138 |
+
foreach ($imgs as $iname => $iid) {
|
139 |
+
$iname = preg_replace('/(\s{1,})/', '-', $iname);
|
140 |
+
$_imgs[$iname] = $iid;
|
141 |
+
}
|
142 |
+
if ($tags->length > 0) {
|
143 |
+
foreach ($tags as $order => $tag) {
|
144 |
+
// only find img tag have source
|
145 |
+
if (($obj = $tag->getAttribute('src')) == '') {
|
146 |
+
continue;
|
147 |
+
}
|
148 |
+
if ($img_name = self::IHasClone(array_keys($_imgs), $obj)) {
|
149 |
+
if (!empty($_imgs[$img_name])) {
|
150 |
+
$ifound[$order]['id'] = $_imgs[$img_name];
|
151 |
+
$ifound[$order]['src'] = $obj;
|
152 |
+
$ifound[$order]['width'] = $tag->getAttribute('width');
|
153 |
+
$ifound[$order]['height'] = $tag->getAttribute('height');
|
154 |
+
$ifound[$order]['alt'] = trim($tag->getAttribute('alt'));
|
155 |
+
$ifound[$order]['title'] = trim($tag->getAttribute('title'));
|
156 |
+
} else {
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
return $ifound;
|
164 |
+
}
|
165 |
+
|
166 |
+
/*
|
167 |
+
* get posts list
|
168 |
+
*/
|
169 |
+
public static function _get_post_list($iID, $opt_type) {
|
170 |
+
global $wpdb;
|
171 |
+
//Get image info from wp_postmeta with key equals to _metaseo_img_meta_not_good
|
172 |
+
$meta_key = '_metaseo_' . strtolower(trim($opt_type));
|
173 |
+
$posts = get_post_meta($iID, $meta_key, true);
|
174 |
+
|
175 |
+
if (is_array($posts) && !empty($posts)) {
|
176 |
+
$posts = metaseo_utf8($posts, 'decode');
|
177 |
+
return $posts;
|
178 |
+
}
|
179 |
+
|
180 |
+
return array();
|
181 |
+
}
|
182 |
+
|
183 |
+
/*
|
184 |
+
* get image not good
|
185 |
+
*/
|
186 |
+
public static function IPrepare($imgs, $posts, $meta_checkout = array(), $forceScan = false) {
|
187 |
+
$iNotGood = array();
|
188 |
+
$iNotGoodTotal = array();
|
189 |
+
$metaNotGood = array();
|
190 |
+
$metaNotGoodTotal = array();
|
191 |
+
$upload_dir = wp_upload_dir();
|
192 |
+
|
193 |
+
// scan img tag for each post content
|
194 |
+
foreach ($posts as $post) {
|
195 |
+
if (empty($post->post_content)) {
|
196 |
+
continue;
|
197 |
+
}
|
198 |
+
$ifound = self::IScan($imgs, $post->post_content);
|
199 |
+
if (count($ifound) < 1) {
|
200 |
+
continue;
|
201 |
+
}
|
202 |
+
|
203 |
+
foreach ($ifound as $order => $img) {
|
204 |
+
$iID = $img['id'];
|
205 |
+
//Get image that its size is not good
|
206 |
+
if (!list($width_origin, $height_origin) = @getimagesize($img['src'])) {
|
207 |
+
continue;
|
208 |
+
}
|
209 |
+
$ratio_origin = $width_origin / $height_origin;
|
210 |
+
$width = $img['width'];
|
211 |
+
$height = $img['height'];
|
212 |
+
//Check if img tag is missing with/height attribute value or not
|
213 |
+
if (!$width && !$height) {
|
214 |
+
$width = $width_origin;
|
215 |
+
$height = $height_origin;
|
216 |
+
} elseif ($width && !$height) {
|
217 |
+
$height = $width * (1 / $ratio_origin);
|
218 |
+
} elseif ($height && !$width) {
|
219 |
+
$width = $height * ($ratio_origin);
|
220 |
+
}
|
221 |
+
|
222 |
+
if ($width_origin > $width || $height_origin > $height) {
|
223 |
+
$img_before = str_replace(array($upload_dir['baseurl']), '', $img['src']);
|
224 |
+
$ibpart = ImageHelper::IGetPart($img_before);
|
225 |
+
|
226 |
+
$img_after = $ibpart->base_path
|
227 |
+
. (!empty($ibpart->name_prefix) ? $ibpart->name_prefix : $ibpart->name)
|
228 |
+
. '-' . $width . 'x' . $height
|
229 |
+
. $ibpart->name_suffix
|
230 |
+
. $ibpart->ext;
|
231 |
+
|
232 |
+
$destination = $upload_dir['basedir'] . '/' . $img_after;
|
233 |
+
|
234 |
+
// create new image url and dir
|
235 |
+
$srcs = array(
|
236 |
+
'img_before_dir' => $upload_dir['basedir'] . $img_before,
|
237 |
+
'img_before_url' => $upload_dir['baseurl'] . $img_before,
|
238 |
+
'img_after_dir' => $upload_dir['basedir'] . $img_after,
|
239 |
+
'img_after_url' => $upload_dir['baseurl'] . $img_after
|
240 |
+
);
|
241 |
+
|
242 |
+
// get size img
|
243 |
+
$size = (filesize($srcs['img_before_dir']) / 1024);
|
244 |
+
if ($size > 1024) {
|
245 |
+
$size = $size / 1024;
|
246 |
$sizes = 'MB';
|
247 |
+
} else {
|
248 |
$sizes = 'KB';
|
249 |
}
|
250 |
+
$size = @round($size, 1);
|
251 |
+
|
252 |
+
$iNotGood[$iID][$post->ID]['ID'] = $post->ID;
|
253 |
+
$iNotGood[$iID][$post->ID]['title'] = $post->post_title;
|
254 |
+
$iNotGood[$iID][$post->ID]['post_type'] = $post->post_type;
|
255 |
+
$iNotGood[$iID][$post->ID]['img_before_optm'][$order] = array(
|
256 |
+
'size' => $size,
|
257 |
+
'sizes' => $sizes,
|
258 |
+
'src' => $srcs['img_before_url'],
|
259 |
+
'width' => $width,
|
260 |
+
'height' => $height,
|
261 |
+
'dimension' => ImageHelper::IGetDimension($img_before)
|
262 |
+
);
|
263 |
+
|
264 |
+
$iNotGood[$iID][$post->ID]['img_after_optm'][$order] = array(
|
265 |
+
'size' => 0,
|
266 |
+
'path' => $img_after,
|
267 |
+
'src' => $srcs['img_after_url'],
|
268 |
+
'src_origin' => $srcs['img_before_url'],
|
269 |
+
'width' => $width,
|
270 |
+
'height' => $height,
|
271 |
+
'dimension' => ImageHelper::IGetDimension($img_after)
|
272 |
+
);
|
273 |
+
|
274 |
+
//Get the number of images which their size are not good
|
275 |
+
if (!isset($iNotGoodTotal[$iID])) {
|
276 |
+
$iNotGoodTotal[$iID] = 0;
|
277 |
+
}
|
278 |
+
$iNotGoodTotal[$iID] ++;
|
279 |
+
} else {
|
280 |
+
if (!isset($iNotGood[$iID])) {
|
281 |
+
$iNotGood[$iID] = array();
|
282 |
+
}
|
283 |
+
if (!isset($iNotGoodTotal[$iID])) {
|
284 |
+
$iNotGoodTotal[$iID] = 0;
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
//Get image that its meta/metas is/are not good
|
289 |
+
if (count($meta_checkout) > 0) {
|
290 |
+
foreach ($meta_checkout as $key => $meta) {
|
291 |
+
$meta_value = $img[$meta];
|
292 |
+
$imNotGood[$iID][$post->ID]['ID'] = $post->ID;
|
293 |
+
$imNotGood[$iID][$post->ID]['title'] = $post->post_title;
|
294 |
+
$imNotGood[$iID][$post->ID]['post_type'] = $post->post_type;
|
295 |
+
$imNotGood[$iID][$post->ID]['meta'][$order]['img_src'] = $img['src'];
|
296 |
+
$imNotGood[$iID][$post->ID]['meta'][$order]['type'][$meta] = $meta_value;
|
297 |
+
if ($meta_value == '') {
|
298 |
+
if (!isset($imNotGoodTotal[$iID][$meta])) {
|
299 |
+
$imNotGoodTotal[$iID][$meta] = 0;
|
300 |
+
}
|
301 |
+
$imNotGoodTotal[$iID][$meta] ++;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
}
|
307 |
+
|
308 |
+
foreach ($imgs as $name => $iID) {
|
309 |
+
if (!isset($iNotGoodTotal[$iID])) {
|
310 |
+
$iNotGoodTotal[$iID] = -1;
|
311 |
+
}
|
312 |
+
if (!isset($iNotGood[$iID])) {
|
313 |
+
$iNotGood[$iID] = array();
|
314 |
+
}
|
315 |
+
if (!isset($imNotGood[$iID])) {
|
316 |
+
$imNotGood[$iID] = array();
|
317 |
+
}
|
318 |
+
if (!isset($imNotGoodTotal[$iID])) {
|
319 |
+
foreach ($meta_checkout as $mkey) {
|
320 |
+
$imNotGoodTotal[$iID][$mkey] = 0;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
foreach ($imNotGoodTotal as &$mStatis) {
|
326 |
+
foreach ($meta_checkout as $mkey) {
|
327 |
+
if (!isset($mStatis[$mkey])) {
|
328 |
+
$mStatis[$mkey] = 0;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
unset($posts, $imgs);
|
334 |
+
|
335 |
+
$ret = array('iNotGood' => $iNotGood, 'iNotGoodTotal' => $iNotGoodTotal, 'imNotGood' => $imNotGood, 'imNotGoodTotal' => $imNotGoodTotal);
|
336 |
+
|
337 |
return $ret;
|
338 |
+
}
|
339 |
+
|
340 |
+
/*
|
341 |
+
* Scan image that has not good size or not good meta(s), then update info to postmeta table
|
342 |
+
* @return: array of message that will be responsed to ajax call
|
343 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
+
public static function IScanPosts($imgs, $meta_checking = false, $forceScan = false) {
|
346 |
+
global $wpdb;
|
347 |
+
$imgs_1 = array_slice($imgs, 0, 1);
|
348 |
+
$idPost = array_shift($imgs_1);
|
349 |
+
|
350 |
+
// get list sizes image
|
351 |
+
$metadats = get_post_meta($idPost, '_wp_attachment_metadata', true);
|
352 |
+
$sizes = $metadats['sizes'];
|
353 |
+
|
354 |
+
// get list url image and image thumbnail
|
355 |
+
$list_thum_url = array();
|
356 |
+
$imageUrl = wp_get_attachment_url($idPost);
|
357 |
+
$list_thum_url[] = $imageUrl;
|
358 |
+
foreach ($sizes as $key => $size){
|
359 |
+
$thum_url = wp_get_attachment_image_src($idPost,$key);
|
360 |
+
$list_thum_url[] = $thum_url[0];
|
361 |
+
}
|
362 |
+
|
363 |
+
$msg = array();
|
364 |
+
$meta_keys = array('alt', 'title');
|
365 |
+
$_imgs = array_flip($imgs);
|
366 |
+
$post_types = MetaSeo_Content_List_Table::get_post_types();
|
367 |
+
|
368 |
+
// sql where
|
369 |
+
$w = '';
|
370 |
+
$w .= '(';
|
371 |
+
$i = 0;
|
372 |
+
foreach ($list_thum_url as $url){
|
373 |
+
$i++;
|
374 |
+
if($i == count($list_thum_url)){
|
375 |
+
$w .= ' post_content LIKE "%' . $url . '%"';
|
376 |
+
}else{
|
377 |
+
$w .= ' post_content LIKE "%' . $url . '%" OR';
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
$w .= ')';
|
383 |
+
$where = array();
|
384 |
+
$where[] = "post_type IN ($post_types)";
|
385 |
+
$where[] = "post_content LIKE '%<img%>%'";
|
386 |
+
$where[] = $w;
|
387 |
+
$query = "SELECT `ID`, `post_title`, `post_content`, `post_type`, `post_date`
|
388 |
+
FROM $wpdb->posts
|
389 |
+
WHERE ".implode(' AND ', $where)." ORDER BY ID";
|
390 |
+
// query post
|
391 |
$posts = $wpdb->get_results($query);
|
392 |
+
$results = self::IPrepare($imgs, $posts, $meta_keys, $forceScan);
|
393 |
+
//Update some value into fields in wp_postmeta
|
394 |
+
if (count($results['iNotGood']) > 0) {
|
395 |
+
foreach ($results['iNotGood'] as $iID => $post_group) {
|
396 |
+
if ($results['iNotGoodTotal'][$iID] > 0) {
|
397 |
+
//This has a litle bit value
|
398 |
+
if ($results['iNotGoodTotal'][$iID] > 1) {
|
399 |
+
$im = ' images ';
|
400 |
+
} else {
|
401 |
+
$im = ' image ';
|
402 |
+
}
|
403 |
+
|
404 |
+
$msg[$iID]['iNotGood']['msg'] = __($results['iNotGoodTotal'][$iID] . $im . 'with wrong size', 'wp-meta-seo');
|
405 |
+
$msg[$iID]['iNotGood']['warning'] = true;
|
406 |
+
|
407 |
+
$msg[$iID]['iNotGood']['button'] = '<a href="javascript:void(0);" class=" img-resize button button-primary" data-img-name="' . $_imgs[$iID] . '" data-post-id="' . $iID . '" data-opt-key="resize_image" onclick="showPostsList(this)">' . __('Resize image', 'wp-meta-seo') . '<span class="spinner-light"></span></a>';
|
408 |
+
|
409 |
+
update_post_meta($iID, '_metaseo_resize_image_counter', $results['iNotGoodTotal'][$iID]);
|
410 |
+
update_post_meta($iID, '_metaseo_resize_image', $post_group);
|
411 |
+
} else {
|
412 |
+
$msg[$iID]['iNotGood']['msg'] = __('Image sizes are good!', 'wp-meta-seo');
|
413 |
+
$msg[$iID]['iNotGood']['warning'] = false;
|
414 |
+
|
415 |
+
delete_post_meta($iID, '_metaseo_resize_image_counter');
|
416 |
+
delete_post_meta($iID, '_metaseo_resize_image');
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
// create list image wrong
|
422 |
+
if (count($results['imNotGood']) > 0) {
|
423 |
+
foreach ($results['imNotGood'] as $iID => $post_group) {
|
424 |
+
//This has a litle bit value
|
425 |
+
foreach ($meta_keys as $mkey) {
|
426 |
+
$text = '';
|
427 |
+
if ($mkey == 'alt') {
|
428 |
+
$text = ' text';
|
429 |
+
}
|
430 |
+
|
431 |
+
if ($results['imNotGoodTotal'][$iID][$mkey] > 1) {
|
432 |
+
$msg[$iID]['imNotGood']['msg'][$mkey] = __($results['imNotGoodTotal'][$iID][$mkey] . ' ' . $mkey . $text . 's are missing', 'wp-meta-seo');
|
433 |
+
} elseif ($results['imNotGoodTotal'][$iID][$mkey] == 1) {
|
434 |
+
$msg[$iID]['imNotGood']['msg'][$mkey] = __($results['imNotGoodTotal'][$iID][$mkey] . ' ' . $mkey . $text . ' is missing', 'wp-meta-seo');
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
$msg[$iID]['imNotGood']['warning'] = true;
|
439 |
+
$msg[$iID]['imNotGood']['button'] = '<a href="javascript:void(0);" class=" fix-metas button button-primary" data-img-name="' . $_imgs[$iID] . '" data-post-id="' . $iID . '" data-opt-key="fix_metas" onclick="showPostsList(this)">' . __('Fix meta', 'wp-meta-seo') . '<span class="spinner-light"></span></a>';
|
440 |
+
|
441 |
+
|
442 |
+
update_post_meta($iID, '_metaseo_fix_metas_counter', count($post_group));
|
443 |
+
update_post_meta($iID, '_metaseo_fix_metas', $post_group);
|
444 |
+
|
445 |
+
|
446 |
+
if ($results['imNotGoodTotal'][$iID]['alt'] == 0 && $results['imNotGoodTotal'][$iID]['title'] == 0) {
|
447 |
+
if ($results['iNotGoodTotal'][$iID] != -1) {
|
448 |
+
$msg[$iID]['imNotGood']['button'] = '<a href="javascript:void(0);" class=" fix-metas button" data-img-name="' . $_imgs[$iID] . '" data-post-id="' . $iID . '" data-opt-key="fix_metas" onclick="showPostsList(this)">' . __('Edit meta', 'wp-meta-seo') . '<span class="spinner-light"></span></a>';
|
449 |
+
} else {
|
450 |
+
$msg[$iID]['imNotGood']['button'] = '';
|
451 |
+
}
|
452 |
+
$msg[$iID]['imNotGood']['warning'] = false;
|
453 |
+
$msg[$iID]['imNotGood']['msg'] = '';
|
454 |
+
}
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
unset($results, $imgs);
|
459 |
+
|
460 |
+
return $msg;
|
461 |
+
}
|
462 |
+
|
463 |
+
/*
|
464 |
+
* Ajax optimize image and update content
|
465 |
+
*/
|
466 |
+
public static function _optimizeImages($post_id, $img_post_id, $img_exclude) {
|
467 |
+
global $wpdb;
|
468 |
+
$ret = array('success' => false, 'msg' => '');
|
469 |
+
$query = "SELECT `post_content` FROM $wpdb->posts WHERE `ID`=" . $post_id;
|
470 |
+
|
471 |
+
if (!($post_content = @$wpdb->get_row($query)->post_content)) {
|
472 |
+
$ret['msg'] = __('This post is not existed or deleted, please choose one another!', 'wp-meta-seo');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
+
return $ret;
|
475 |
+
}
|
476 |
+
|
477 |
+
$imgs_to_resize = get_post_meta($img_post_id, '_metaseo_resize_image', true);
|
478 |
+
|
479 |
+
if (preg_match_all('/<img [^<>]+ \/>/i', $post_content, $matches)) {
|
480 |
+
$img_tags = $matches[0];
|
481 |
+
$replacement = array();
|
482 |
+
foreach ($matches[0] as $order => $tag) {
|
483 |
+
$replacement[$order] = $tag;
|
484 |
+
//This block of code maybe changed later
|
485 |
+
if (preg_match('/(width|height)="([^\"]+)"/i', $tag, $dimension)) {
|
486 |
+
if (!isset($imgs_to_resize[$post_id])) {
|
487 |
+
continue;
|
488 |
+
}
|
489 |
+
foreach ($imgs_to_resize[$post_id]['img_after_optm'] as $key => $img) {
|
490 |
+
if (!in_array($order, $img_exclude)) {
|
491 |
+
if (stripos($tag, $img['src_origin']) !== false &&
|
492 |
+
(('width' == $dimension[1] && $dimension[2] == $img['width']) || ('height' == $dimension[1] && $dimension[2] == $img['height']))) {
|
493 |
+
|
494 |
+
$replacement[$order] = str_replace($img['src_origin'], $img['src'], $tag);
|
495 |
+
}
|
496 |
+
}
|
497 |
+
}
|
498 |
+
}
|
499 |
+
#}
|
500 |
+
}
|
501 |
+
|
502 |
+
//Replace all imgs sources that have new value
|
503 |
+
$post_content = str_replace($matches[0], $replacement, $post_content);
|
504 |
+
}
|
505 |
+
|
506 |
+
//Update post content with all imgs has been just optimized
|
507 |
+
$id = wp_update_post(array(
|
508 |
+
'ID' => $post_id,
|
509 |
+
'post_content' => $post_content
|
510 |
+
));
|
511 |
+
|
512 |
+
if ($id) {
|
513 |
+
$ret['success'] = true;
|
514 |
+
$ret['msg'] = __('Well! This image is so good now.', 'wp-meta-seo');
|
515 |
+
} else {
|
516 |
+
$ret['msg'] = __('Opps! An error occured when updating the post, please try again', 'wp-meta-seo');
|
517 |
+
}
|
518 |
+
|
519 |
+
return $ret;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* create new size for image
|
524 |
+
*/
|
525 |
+
public static function IResize($src, $width, $height, $destination) {
|
526 |
+
if (!list($w_origin, $h_origin) = getimagesize($src))
|
527 |
+
return "Unsupported picture type!";
|
528 |
+
|
529 |
+
if (is_readable($destination)) {
|
530 |
+
return true;
|
531 |
+
}
|
532 |
+
|
533 |
+
$type = strtolower(substr(strrchr($src, "."), 1));
|
534 |
+
if ($type === 'jpeg')
|
535 |
+
$type = 'jpg';
|
536 |
+
switch ($type) {
|
537 |
+
case 'bmp': $img = imagecreatefromwbmp($src);
|
538 |
+
break;
|
539 |
+
case 'gif': $img = imagecreatefromgif($src);
|
540 |
+
break;
|
541 |
+
case 'jpg': $img = imagecreatefromjpeg($src);
|
542 |
+
break;
|
543 |
+
case 'png': $img = imagecreatefrompng($src);
|
544 |
+
break;
|
545 |
+
default : return "Unsupported picture type!";
|
546 |
+
}
|
547 |
+
|
548 |
+
$new = imagecreatetruecolor($width, $height);
|
549 |
+
|
550 |
+
// preserve transparency
|
551 |
+
if ($type === "gif" or $type === "png") {
|
552 |
+
imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
|
553 |
+
imagealphablending($new, false);
|
554 |
+
imagesavealpha($new, true);
|
555 |
+
}
|
556 |
+
|
557 |
+
imagecopyresampled($new, $img, 0, 0, 0, 0, $width, $height, $w_origin, $h_origin);
|
558 |
+
|
559 |
+
//Output
|
560 |
+
switch ($type) {
|
561 |
+
case 'bmp': imagewbmp($new, $destination);
|
562 |
+
break;
|
563 |
+
case 'gif': imagegif($new, $destination);
|
564 |
+
break;
|
565 |
+
case 'jpg': imagejpeg($new, $destination);
|
566 |
+
break;
|
567 |
+
case 'png': imagepng($new, $destination);
|
568 |
+
break;
|
569 |
+
}
|
570 |
+
|
571 |
+
return true;
|
572 |
+
}
|
573 |
+
|
574 |
+
}
|
inc/class.metaseo-admin.php
CHANGED
@@ -1,77 +1,80 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
3 |
class MetaSeo_Admin {
|
4 |
-
|
5 |
private $options;
|
6 |
private $pagenow;
|
7 |
public static $desc_length = 156;
|
8 |
public static $title_length = 69;
|
9 |
-
|
10 |
function __construct() {
|
11 |
$this->settings = array(
|
12 |
-
"metaseo_title_home"=>"",
|
13 |
-
"metaseo_desc_home"=>"",
|
14 |
-
|
15 |
-
"metaseo_showtwitter"=>"",
|
16 |
-
"metaseo_twitter_card"=>"summary",
|
17 |
-
"metaseo_showkeywords"=>0,
|
18 |
-
"metaseo_showtmetablock"=>1,
|
19 |
"metaseo_showsocial" => 1,
|
20 |
"metaseo_seovalidate" => 0,
|
21 |
"metaseo_linkfield" => 1,
|
22 |
"metaseo_metatitle_tab" => 0,
|
23 |
"metaseo_follow" => 0,
|
24 |
"metaseo_index" => 0
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
$this->pagenow = $GLOBALS['pagenow'];
|
33 |
-
if((isset($this->settings['metaseo_showtmetablock']) && $this->settings['metaseo_showtmetablock'] == 1)){
|
34 |
$this->load_meta_boxes();
|
35 |
}
|
36 |
-
|
37 |
add_action('admin_menu', array($this, 'register_menu_page'));
|
38 |
|
39 |
/** Load admin js * */
|
40 |
add_action('admin_enqueue_scripts', array($this, 'loadAdminScripts'));
|
41 |
-
|
42 |
-
/** Load admin css * */
|
43 |
-
add_action('admin_init', array($this, 'addAdminStylesheets'));
|
44 |
$this->ajaxHandle();
|
45 |
-
|
46 |
//register ajax update meta handler...
|
47 |
-
add_action(
|
48 |
-
add_action('admin_init', array($this,'metaseo_field_settings'));
|
49 |
-
|
50 |
-
add_action('admin_init', array($this,'metaseo_create_db'));
|
51 |
-
|
52 |
-
add_action('init', array($this,'wpms_load_langguage'));
|
53 |
-
|
54 |
-
if(!get_option('wpms_set_ignore', false)){
|
55 |
-
|
56 |
}
|
57 |
-
|
58 |
-
add_action('wp_ajax_wpms_set_ignore',array($this,'wpms_set_ignore'));
|
59 |
-
if (
|
60 |
-
|
61 |
}
|
62 |
-
add_action(
|
63 |
-
add_action(
|
64 |
-
add_action(
|
65 |
-
add_action(
|
66 |
-
add_action(
|
67 |
}
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
70 |
global $wpdb;
|
71 |
$option_v = 'metaseo_db_version2.2.0';
|
72 |
-
$db_installed = get_option(
|
73 |
-
|
74 |
-
if(!$db_installed){
|
75 |
// create table wpms_links
|
76 |
$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wpms_links`(
|
77 |
`id` int(20) unsigned NOT NULL AUTO_INCREMENT,
|
@@ -92,36 +95,38 @@ class MetaSeo_Admin {
|
|
92 |
PRIMARY KEY (id))";
|
93 |
|
94 |
|
95 |
-
require_once(ABSPATH.'wp-admin/includes/upgrade.php');
|
96 |
dbDelta($sql);
|
97 |
|
98 |
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
if(empty($row)){
|
104 |
-
$wpdb->query("ALTER TABLE ".$wpdb->prefix."wpms_links ADD follow tinyint(1) DEFAULT 1");
|
105 |
}
|
|
|
|
|
|
|
|
|
106 |
|
107 |
-
$row
|
108 |
-
|
109 |
-
|
110 |
-
if(empty($row)){
|
111 |
-
$wpdb->query("ALTER TABLE ".$wpdb->prefix."wpms_links ADD meta_title varchar(250) DEFAULT ''");
|
112 |
}
|
|
|
|
|
|
|
|
|
113 |
|
114 |
-
$row
|
115 |
-
|
116 |
-
|
117 |
-
if(empty($row)){
|
118 |
-
$wpdb->query("ALTER TABLE ".$wpdb->prefix."wpms_links ADD internal tinyint(1) DEFAULT 1");
|
119 |
}
|
120 |
-
|
121 |
// create page 404
|
122 |
-
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s"
|
123 |
$post_if = $wpdb->get_var($sql);
|
124 |
-
if($post_if < 1){
|
125 |
$content = '<div class="wall" style="background-color: #F2F3F7; border: 30px solid #fff; width: 90%; height: 90%; margin: 0 auto;">
|
126 |
|
127 |
<h1 style="text-align: center; font-family:\'open-sans\', arial; color: #444; font-size: 60px; padding: 50px;">ERROR 404 <br />-<br />NOT FOUND</h1>
|
@@ -129,124 +134,135 @@ class MetaSeo_Admin {
|
|
129 |
// You may have mis-typed the URL,<br />
|
130 |
// Or the page has been removed,<br />
|
131 |
// Actually, there is nothing to see here...</p>
|
132 |
-
<p style="text-align: center;"><a style=" font-family:\'open-sans\', arial; color: #444; font-size: 20px; padding: 20px; line-height: 30px; text-decoration: none;" href="'.
|
133 |
</div>';
|
134 |
$_page404 = array(
|
135 |
-
'post_title'
|
136 |
-
'post_content'
|
137 |
-
'post_status'
|
138 |
-
'post_excerpt'
|
139 |
-
'post_type'
|
140 |
);
|
141 |
-
wp_insert_post(
|
142 |
}
|
143 |
|
144 |
-
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s"
|
145 |
$post_if = $wpdb->get_var($sql);
|
146 |
-
if($post_if < 1){
|
147 |
$_sitemap_page = array(
|
148 |
-
'post_title'
|
149 |
-
'post_content'
|
150 |
-
'post_status'
|
151 |
-
'post_excerpt'
|
152 |
-
'post_type'
|
153 |
);
|
154 |
-
wp_insert_post(
|
155 |
}
|
156 |
-
|
157 |
update_option($option_v, true);
|
158 |
}
|
159 |
}
|
160 |
|
|
|
|
|
|
|
161 |
function wpms_link_title_field() {
|
162 |
-
if(isset($this->settings['metaseo_linkfield']) && $this->settings['metaseo_linkfield'] == 1){
|
163 |
-
wp_enqueue_script(
|
164 |
-
wp_localize_script(
|
165 |
-
|
166 |
-
)
|
167 |
}
|
168 |
}
|
169 |
|
170 |
-
|
|
|
|
|
|
|
171 |
update_option('wpms_set_ignore', 0);
|
172 |
wp_send_json(true);
|
173 |
}
|
174 |
|
|
|
|
|
|
|
175 |
function wpms_public_warning() {
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
<div id="robotsmessage" class="error">
|
199 |
<p>
|
200 |
<strong>%1$s</strong>
|
201 |
%2$s
|
202 |
<a href="javascript:wpmsSetIgnore(\'wpms_public_warning\',\'robotsmessage\',\'%3$s\');" class="button">%4$s</a>
|
203 |
</p>
|
204 |
-
</div>',
|
205 |
-
|
206 |
-
sprintf( __( '%sFix it now%s', 'wp-meta-seo' ), sprintf( '<a href="%s">', esc_url( admin_url( 'options-reading.php' ) ) ), '</a>' ),
|
207 |
-
esc_js( wp_create_nonce( 'wpseo-ignore' ) ),
|
208 |
-
__( 'OK I know that.', 'wp-meta-seo' )
|
209 |
-
);
|
210 |
}
|
211 |
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
214 |
}
|
215 |
-
|
216 |
-
function metaseo_create_field($data_title
|
217 |
-
$output = '<div class="metaseo_analysis metaseo_tool" data-title="'
|
218 |
-
$output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms['
|
219 |
return $output;
|
220 |
}
|
221 |
|
|
|
|
|
|
|
222 |
function metaseo_reload_analysis() {
|
223 |
$tooltip_page = array();
|
224 |
-
$tooltip_page['title_in_heading'] = __('Check if a word of this content title is also in a title heading (h1, h2...)','wp-meta-seo');
|
225 |
-
$tooltip_page['title_in_content'] = __('Check if a word of this content title is also in the text','wp-meta-seo');
|
226 |
-
$tooltip_page['page_url'] = __('Does the page title match with the permalink (URL structure)','wp-meta-seo');
|
227 |
-
$tooltip_page['meta_title'] = __('Is the meta title of this page filled?','wp-meta-seo');
|
228 |
-
$tooltip_page['meta_desc'] = __('Is the meta description of this page filled?','wp-meta-seo');
|
229 |
-
$tooltip_page['image_resize'] = __('Check for image HTML resizing in content (usually image resized using handles)','wp-meta-seo');
|
230 |
-
$tooltip_page['image_alt'] = __('Check for image Alt text and title','wp-meta-seo');
|
231 |
-
if(empty($_POST['datas'])){
|
232 |
wp_send_json(false);
|
233 |
}
|
234 |
-
|
235 |
-
if(isset($_POST['datas']['post_id'])){
|
236 |
update_post_meta($_POST['datas']['post_id'], 'wpms_validate_analysis', '');
|
237 |
}
|
238 |
-
|
239 |
$check = 0;
|
240 |
$output = '';
|
241 |
-
|
242 |
// title heading
|
243 |
-
$words_post_title = preg_split('~[^\p{L}\p{N}\']+~u',strtolower($_POST['datas']['title']));
|
244 |
-
if($_POST['datas']['content'] == '') {
|
245 |
-
$output .= $this->metaseo_create_field('heading_title'
|
246 |
-
}else{
|
247 |
$dom = new DOMDocument;
|
248 |
-
libxml_use_internal_errors(
|
249 |
-
if ($dom->loadHTML('<div>'.html_entity_decode(stripcslashes($_POST['datas']['content'])).'</div>')) {
|
250 |
// Extracting the specified elements from the web page
|
251 |
$tags_h1 = $dom->getElementsByTagName('h1');
|
252 |
$tags_h2 = $dom->getElementsByTagName('h2');
|
@@ -256,15 +272,16 @@ class MetaSeo_Admin {
|
|
256 |
$tags_h6 = $dom->getElementsByTagName('h6');
|
257 |
|
258 |
$test = false;
|
259 |
-
if(count($tags_h1) == 0 && count($tags_h2) == 0 && count($tags_h3) == 0 && count($tags_h4) == 0 && count($tags_h5) == 0 && count($tags_h6) == 0){
|
260 |
$test = false;
|
261 |
-
}else{
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
268 |
$test = true;
|
269 |
}
|
270 |
}
|
@@ -272,64 +289,69 @@ class MetaSeo_Admin {
|
|
272 |
}
|
273 |
}
|
274 |
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
|
|
281 |
$test = true;
|
282 |
}
|
283 |
}
|
284 |
}
|
285 |
}
|
286 |
}
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
294 |
$test = true;
|
295 |
}
|
296 |
}
|
297 |
}
|
298 |
}
|
299 |
}
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
|
|
307 |
$test = true;
|
308 |
}
|
309 |
}
|
310 |
}
|
311 |
}
|
312 |
}
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
320 |
$test = true;
|
321 |
}
|
322 |
}
|
323 |
}
|
324 |
}
|
325 |
}
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
|
|
333 |
$test = true;
|
334 |
}
|
335 |
}
|
@@ -338,136 +360,140 @@ class MetaSeo_Admin {
|
|
338 |
}
|
339 |
}
|
340 |
|
341 |
-
if($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))){
|
342 |
-
$output .= $this->metaseo_create_field('heading_title'
|
343 |
$check ++;
|
344 |
-
}else{
|
345 |
-
$output .= $this->metaseo_create_field('heading_title'
|
346 |
}
|
347 |
-
|
348 |
-
|
349 |
-
$output .= $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'warning',__('Page title word in content heading','wp-meta-seo'),0);
|
350 |
}
|
351 |
}
|
352 |
-
|
353 |
// title content
|
354 |
-
$words_title = preg_split('~[^\p{L}\p{N}\']+~u',strtolower($_POST['datas']['title']));
|
355 |
-
$words_post_content = preg_split('~[^\p{L}\p{N}\']+~u',strtolower($_POST['datas']['content']));
|
356 |
-
|
357 |
$test1 = false;
|
358 |
-
if(is_array($words_title) && is_array($words_post_content)){
|
359 |
-
foreach ($words_title as $mtitle){
|
360 |
-
if(in_array($mtitle, $words_post_content) && $mtitle != ''){
|
361 |
$test1 = true;
|
362 |
break;
|
363 |
}
|
364 |
}
|
365 |
-
}else{
|
366 |
$test1 = false;
|
367 |
}
|
368 |
-
|
369 |
-
if($test1){
|
370 |
-
$output .= $this->metaseo_create_field('content_title'
|
371 |
$check ++;
|
372 |
-
}else{
|
373 |
-
$output .= $this->metaseo_create_field('content_title'
|
374 |
}
|
375 |
-
|
376 |
// page url matches page title
|
377 |
$mtitle = $_POST['datas']['title'];
|
378 |
-
if($_POST['datas']['mpageurl'] == sanitize_title($mtitle)){
|
379 |
-
$output .= $this->metaseo_create_field('pageurl'
|
380 |
$check ++;
|
381 |
-
}else{
|
382 |
-
$output .= $this->metaseo_create_field('pageurl'
|
383 |
}
|
384 |
-
|
385 |
// meta title filled
|
386 |
-
if(($_POST['datas']['meta_title'] != '' && strlen($_POST['datas']['meta_title']) <= self::$title_length)){
|
387 |
-
$output .= $this->metaseo_create_field('metatitle'
|
388 |
$check++;
|
389 |
-
}else{
|
390 |
-
$output .= $this->metaseo_create_field('metatitle'
|
391 |
}
|
392 |
-
|
393 |
// desc filled
|
394 |
-
if(($_POST['datas']['meta_desc'] != '' && strlen($_POST['datas']['meta_desc']) <= self::$desc_length)){
|
395 |
-
$output .= $this->metaseo_create_field('metadesc'
|
396 |
$check++;
|
397 |
-
}else{
|
398 |
-
$output .= $this->metaseo_create_field('metadesc'
|
399 |
}
|
400 |
-
|
401 |
// image resize
|
402 |
-
if($_POST['datas']['content'] == '') {
|
403 |
-
$output .= $this->metaseo_create_field('imgresize'
|
404 |
-
$output .= $this->metaseo_create_field('imgalt'
|
405 |
$check += 2;
|
406 |
-
}else{
|
407 |
$dom = new DOMDocument;
|
408 |
-
libxml_use_internal_errors(
|
409 |
-
if ($dom->loadHTML('<div>'.html_entity_decode(stripcslashes($_POST['datas']['content'])).'</div>')) {
|
410 |
// Extracting the specified elements from the web page
|
411 |
$tags = $dom->getElementsByTagName('img');
|
412 |
$img_wrong = false;
|
413 |
$img_wrong_alt = false;
|
414 |
-
foreach($tags as $order => $tag){
|
415 |
$src = $tag->getAttribute('src');
|
416 |
$b = strrpos($src, '-');
|
417 |
$e = strrpos($src, '.');
|
418 |
-
$string_wh = substr($src, $b+1
|
419 |
$array_wh = explode('x', $string_wh);
|
420 |
-
if(!empty($array_wh[0]) && !empty($array_wh[1])){
|
421 |
-
if(((int)$array_wh[0] != (int)$tag->getAttribute('width')) || ((int)$array_wh[1] != (int)$tag->getAttribute('height'))){
|
422 |
$img_wrong = true;
|
423 |
}
|
424 |
}
|
425 |
-
|
426 |
$image_title = $tag->getAttribute('title');
|
427 |
$image_alt = $tag->getAttribute('alt');
|
428 |
-
if($image_title == '' || $image_alt == ''){
|
429 |
$img_wrong_alt = true;
|
430 |
}
|
431 |
}
|
432 |
-
|
433 |
-
if($img_wrong == false){
|
434 |
-
$output .= $this->metaseo_create_field('imgresize'
|
435 |
$check++;
|
436 |
-
}else{
|
437 |
-
$output .= $this->metaseo_create_field('imgresize'
|
438 |
}
|
439 |
-
|
440 |
-
if($img_wrong_alt == false){
|
441 |
-
$output .= $this->metaseo_create_field('imgalt'
|
442 |
$check++;
|
443 |
-
}else{
|
444 |
-
$output .= $this->metaseo_create_field('imgalt'
|
445 |
}
|
446 |
-
}else{
|
447 |
-
$output .= $this->metaseo_create_field('imgresize'
|
448 |
-
$output .= $this->metaseo_create_field('imgalt'
|
449 |
}
|
450 |
}
|
451 |
-
|
452 |
-
$circliful = ceil(100*($check)/7);
|
453 |
-
wp_send_json(array('circliful' => $circliful,'output' => $output
|
454 |
-
|
455 |
}
|
456 |
|
457 |
-
|
|
|
|
|
|
|
458 |
$post_id = $_POST['post_id'];
|
459 |
$key = 'wpms_validate_analysis';
|
460 |
-
$analysis = get_post_meta($post_id, $key,true);
|
461 |
-
if(empty($analysis)
|
462 |
$analysis = array();
|
463 |
}
|
464 |
-
|
465 |
$analysis[$_POST['field']] = 1;
|
466 |
update_post_meta($post_id, $key, $analysis);
|
467 |
wp_send_json(true);
|
468 |
}
|
469 |
|
470 |
-
|
|
|
|
|
|
|
471 |
if (isset($_POST['link_id'])) {
|
472 |
global $wpdb;
|
473 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
|
@@ -482,9 +508,9 @@ class MetaSeo_Admin {
|
|
482 |
|
483 |
|
484 |
$post = get_post($link_detail->source_id);
|
485 |
-
if(!empty($post)){
|
486 |
$old_value = $post->post_content;
|
487 |
-
$edit_result = $this->wpms_edit_linkhtml($old_value
|
488 |
$my_post = array(
|
489 |
'ID' => $link_detail->source_id,
|
490 |
'post_content' => $edit_result['content']
|
@@ -493,83 +519,94 @@ class MetaSeo_Admin {
|
|
493 |
wp_update_post($my_post);
|
494 |
wp_send_json(array('status' => true));
|
495 |
}
|
496 |
-
|
497 |
}
|
498 |
wp_send_json(false);
|
499 |
-
}
|
500 |
|
501 |
-
|
502 |
-
|
|
|
|
|
|
|
503 |
update_post_meta($_POST['page_id'], '_metaseo_metaindex', $_POST['index']);
|
504 |
wp_send_json(array('status' => true));
|
505 |
}
|
506 |
wp_send_json(array('status' => false));
|
507 |
}
|
508 |
|
509 |
-
|
510 |
-
|
|
|
|
|
|
|
511 |
update_post_meta($_POST['page_id'], '_metaseo_metafollow', $_POST['follow']);
|
512 |
wp_send_json(array('status' => true));
|
513 |
}
|
514 |
wp_send_json(array('status' => false));
|
515 |
}
|
516 |
|
517 |
-
|
|
|
|
|
|
|
518 |
if (isset($_POST['link_id'])) {
|
519 |
-
$this->update_follow($_POST['link_id']
|
520 |
wp_send_json(array('status' => true));
|
521 |
}
|
522 |
wp_send_json(array('status' => false));
|
523 |
}
|
524 |
|
525 |
-
|
|
|
|
|
|
|
526 |
global $wpdb;
|
527 |
$follow_value = $_POST['follow_value'];
|
528 |
$limit = 20;
|
529 |
-
|
530 |
-
switch ($follow_value){
|
531 |
case 'follow_selected':
|
532 |
-
if (empty($_POST['linkids']))
|
|
|
533 |
$follow = 1;
|
534 |
-
foreach ($_POST['linkids'] as $linkId){
|
535 |
-
$this->update_follow($linkId
|
536 |
}
|
537 |
break;
|
538 |
|
539 |
case 'follow_all':
|
540 |
$follow = 1;
|
541 |
$i = 0;
|
542 |
-
$
|
543 |
-
$links
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
$this->update_follow($link->id,$follow);
|
549 |
$i++;
|
550 |
}
|
551 |
}
|
552 |
-
|
553 |
break;
|
554 |
|
555 |
case 'nofollow_selected':
|
556 |
$follow = 0;
|
557 |
-
if (empty($_POST['linkids']))
|
558 |
-
|
559 |
-
|
|
|
560 |
}
|
561 |
break;
|
562 |
|
563 |
case 'nofollow_all':
|
564 |
$follow = 0;
|
565 |
$i = 0;
|
566 |
-
$
|
567 |
-
$links
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
$this->update_follow($link->id,$follow);
|
573 |
$i++;
|
574 |
}
|
575 |
}
|
@@ -578,7 +615,10 @@ class MetaSeo_Admin {
|
|
578 |
wp_send_json(array('status' => true));
|
579 |
}
|
580 |
|
581 |
-
|
|
|
|
|
|
|
582 |
global $wpdb;
|
583 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($linkId));
|
584 |
$link_detail = $wpdb->get_row($sql);
|
@@ -591,9 +631,9 @@ class MetaSeo_Admin {
|
|
591 |
);
|
592 |
|
593 |
$post = get_post($link_detail->source_id);
|
594 |
-
if(!empty($post)){
|
595 |
$old_value = $post->post_content;
|
596 |
-
$edit_result = $this->wpms_edit_linkhtml($old_value
|
597 |
$my_post = array(
|
598 |
'ID' => $link_detail->source_id,
|
599 |
'post_content' => $edit_result['content']
|
@@ -603,7 +643,10 @@ class MetaSeo_Admin {
|
|
603 |
}
|
604 |
}
|
605 |
|
606 |
-
|
|
|
|
|
|
|
607 |
//Save the old & new URLs for use in the edit callback.
|
608 |
$args = array(
|
609 |
'old_url' => $old_url,
|
@@ -625,189 +668,227 @@ class MetaSeo_Admin {
|
|
625 |
}
|
626 |
return $result;
|
627 |
}
|
628 |
-
|
629 |
-
|
630 |
-
|
|
|
|
|
|
|
631 |
update_option('wpms_settings_404', $_POST['wpms_redirect']);
|
632 |
wp_send_json(true);
|
633 |
}
|
634 |
}
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
add_settings_field('
|
643 |
-
add_settings_field('
|
644 |
-
add_settings_field('
|
645 |
-
add_settings_field('
|
646 |
-
add_settings_field('
|
647 |
-
add_settings_field('
|
648 |
-
add_settings_field('
|
649 |
-
add_settings_field('
|
650 |
-
add_settings_field('
|
651 |
-
add_settings_field('
|
|
|
|
|
|
|
652 |
}
|
653 |
|
654 |
-
|
|
|
|
|
|
|
655 |
echo '<input name="_metaseo_settings[metaseo_metatitle_tab]" type="hidden" value="0"/>';
|
656 |
?>
|
657 |
-
<label><input name="_metaseo_settings[metaseo_metatitle_tab]" type="checkbox" id="metaseo_metatitle_tab" value="1" <?php checked(
|
658 |
-
|
659 |
<?php
|
660 |
}
|
661 |
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
}
|
666 |
-
|
667 |
-
public function metaseo_title_home(){
|
668 |
-
$home_title = isset( $this->settings['metaseo_title_home'] ) ? $this->settings['metaseo_title_home'] : '';
|
669 |
-
echo '<input id="metaseo_title_home" name="_metaseo_settings[metaseo_title_home]" type="text" value="'.esc_attr( $home_title ).'" size="50"/>';
|
670 |
}
|
671 |
|
672 |
-
|
673 |
-
|
674 |
-
|
|
|
|
|
|
|
675 |
}
|
676 |
|
677 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
echo '<input name="_metaseo_settings[metaseo_showkeywords]" type="hidden" value="0"/>';
|
679 |
?>
|
680 |
-
<label><input name="_metaseo_settings[metaseo_showkeywords]" type="checkbox" id="metaseo_showkeywords" value="1" <?php checked(
|
681 |
-
|
682 |
<?php
|
683 |
}
|
684 |
|
685 |
-
|
686 |
-
|
|
|
|
|
|
|
687 |
?>
|
688 |
-
<label><input name="_metaseo_settings[metaseo_showtmetablock]" type="checkbox" id="metaseo_showtmetablock" value="1" <?php checked(
|
689 |
-
|
690 |
<?php
|
691 |
}
|
692 |
|
693 |
-
|
|
|
|
|
|
|
694 |
echo '<input name="_metaseo_settings[metaseo_showsocial]" type="hidden" value="0"/>';
|
695 |
?>
|
696 |
-
<label><input name="_metaseo_settings[metaseo_showsocial]" type="checkbox" id="metaseo_showsocial" value="1" <?php checked(
|
697 |
-
|
698 |
<?php
|
699 |
}
|
700 |
|
701 |
-
|
|
|
|
|
|
|
702 |
echo '<input name="_metaseo_settings[metaseo_seovalidate]" type="hidden" value="0"/>';
|
703 |
?>
|
704 |
-
<label><input name="_metaseo_settings[metaseo_seovalidate]" type="checkbox" id="metaseo_seovalidate" value="1" <?php checked(
|
705 |
-
|
706 |
<?php
|
707 |
}
|
708 |
|
709 |
-
|
|
|
|
|
|
|
710 |
echo '<input name="_metaseo_settings[metaseo_linkfield]" type="hidden" value="0"/>';
|
711 |
?>
|
712 |
-
<label><input name="_metaseo_settings[metaseo_linkfield]" type="checkbox" id="metaseo_linkfield" value="1" <?php checked(
|
713 |
-
|
714 |
<?php
|
715 |
}
|
716 |
|
717 |
-
|
|
|
|
|
|
|
718 |
echo '<input name="_metaseo_settings[metaseo_follow]" type="hidden" value="0"/>';
|
719 |
?>
|
720 |
-
<label><input name="_metaseo_settings[metaseo_follow]" type="checkbox" id="metaseo_follow" value="1" <?php checked(
|
721 |
-
|
722 |
<?php
|
723 |
}
|
724 |
|
725 |
-
|
|
|
|
|
|
|
726 |
echo '<input name="_metaseo_settings[metaseo_index]" type="hidden" value="0"/>';
|
727 |
?>
|
728 |
-
<label><input name="_metaseo_settings[metaseo_index]" type="checkbox" id="metaseo_index" value="1" <?php checked(
|
729 |
-
|
730 |
<?php
|
731 |
}
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
|
|
|
|
|
|
736 |
}
|
737 |
|
738 |
-
|
739 |
-
|
740 |
-
|
|
|
|
|
|
|
741 |
}
|
742 |
|
743 |
-
|
744 |
-
|
|
|
|
|
|
|
745 |
?>
|
746 |
<select class="select" name="_metaseo_settings[metaseo_twitter_card]" id="metaseo_twitter_card">
|
747 |
-
<option <?php if($twitter_card == 'summary') echo 'selected' ?> value="summary"><?php _e(
|
748 |
-
<option <?php if($twitter_card == 'summary_large_image') echo 'selected' ?> value="summary_large_image"><?php _e(
|
749 |
</select>
|
750 |
<?php
|
751 |
}
|
752 |
-
|
753 |
private function load_meta_boxes() {
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
}
|
764 |
-
|
765 |
function stop_heartbeat() {
|
766 |
-
|
767 |
-
|
768 |
wp_deregister_script('heartbeat');
|
769 |
}
|
770 |
-
|
|
|
|
|
|
|
771 |
function updateContentMeta_callback() {
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
//
|
785 |
-
// echo json_encode($response);
|
786 |
-
// wp_die();
|
787 |
-
// }
|
788 |
-
|
789 |
-
$response->msg = __('Modification was saved', 'wp-meta-seo') ;
|
790 |
-
if($metakey == 'metatitle') {
|
791 |
-
if(!update_post_meta($postID, '_metaseo_metatitle', $value)) {
|
792 |
$response->updated = false;
|
793 |
-
$response->msg = __('Meta title was not saved', 'wp-meta-seo')
|
|
|
|
|
|
|
794 |
}
|
795 |
-
|
796 |
-
$response->updated = true;
|
797 |
-
$response->msg = __('Meta title was saved', 'wp-meta-seo') ;
|
798 |
-
}
|
799 |
-
}
|
800 |
|
801 |
-
if($metakey =='metadesc') {
|
802 |
-
if(!update_post_meta($postID, '_metaseo_metadesc', $value)) {
|
803 |
$response->updated = false;
|
804 |
-
$response->msg = __('Meta description was not saved', 'wp-meta-seo')
|
805 |
-
}else{
|
806 |
$response->updated = true;
|
807 |
-
$response->msg = __('Meta description was saved', 'wp-meta-seo')
|
808 |
-
}
|
809 |
}
|
810 |
-
|
811 |
if ($metakey == 'metakeywords') {
|
812 |
if (!update_post_meta($postID, '_metaseo_metakeywords', $value)) {
|
813 |
$response->updated = false;
|
@@ -821,68 +902,82 @@ class MetaSeo_Admin {
|
|
821 |
echo json_encode($response);
|
822 |
wp_die();
|
823 |
}
|
824 |
-
|
825 |
/**
|
826 |
* Loads js/ajax scripts
|
827 |
-
*
|
828 |
*/
|
829 |
public function loadAdminScripts($hook) {
|
830 |
-
global $current_screen;
|
831 |
-
wp_enqueue_script('jquery');
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
836 |
|
837 |
-
if($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta' || $current_screen->base == 'wp-meta-seo_page_metaseo_content_meta'){
|
838 |
wp_enqueue_script('wpms-bulk', plugins_url('js/wpms-bulk-action.js', dirname(__FILE__)), array('jquery'), time(), true);
|
839 |
wp_localize_script('wpms-bulk', 'wpmseobulkL10n', $this->meta_seo_localize_script());
|
840 |
}
|
841 |
-
|
842 |
-
if($current_screen->base == 'toplevel_page_metaseo_dashboard'){
|
843 |
wp_enqueue_script('Chart', plugins_url('js/Chart.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
844 |
wp_enqueue_script('jquery-knob', plugins_url('js/jquery.knob.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
845 |
wp_enqueue_script('metaseo-dashboard', plugins_url('js/dashboard.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
846 |
-
wp_enqueue_style('chart', plugins_url('/css/chart.css', dirname(__FILE__)
|
847 |
-
wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__)
|
848 |
-
wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__)
|
849 |
}
|
850 |
-
|
851 |
wp_register_style('m-style-qtip', plugins_url('css/jquery.qtip.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
852 |
wp_register_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
|
853 |
-
|
|
|
854 |
wp_register_style('metaseo-google-icon', '//fonts.googleapis.com/icon?family=Material+Icons');
|
855 |
-
if($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta'){
|
856 |
wp_enqueue_script('mautosize', plugins_url('js/autosize.js', dirname(__FILE__)), array('jquery'), '0.1', true);
|
857 |
}
|
858 |
// in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
|
859 |
-
|
860 |
-
array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
|
861 |
}
|
862 |
|
|
|
|
|
|
|
|
|
|
|
863 |
public function meta_seo_localize_script() {
|
864 |
return array(
|
865 |
-
'metaseo_message_false_copy' => __(
|
866 |
);
|
867 |
}
|
868 |
|
869 |
/**
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
function addAdminStylesheets() {
|
876 |
-
wp_enqueue_style('wpmetaseoAdmin', plugins_url('css/metaseo_admin.css', dirname(__FILE__)),array(), WPMSEO_VERSION);
|
877 |
-
wp_enqueue_style('tooltip-metaimage', plugins_url('/css/tooltip-metaimage.css',dirname(__FILE__)),array(), WPMSEO_VERSION);
|
878 |
-
wp_enqueue_style('style', plugins_url('/css/style.css', dirname(__FILE__) ),array(), WPMSEO_VERSION);
|
879 |
-
}
|
880 |
-
|
881 |
function register_menu_page() {
|
882 |
|
883 |
// Add main page
|
884 |
$admin_page = add_menu_page(__('WP Meta SEO:', 'wp-meta-seo') . ' ' . __('Dashboard', 'wp-meta-seo'), __('WP Meta SEO', 'wp-meta-seo'), 'manage_options', 'metaseo_dashboard', array(
|
885 |
-
$this,'load_page',)
|
886 |
|
887 |
/**
|
888 |
* Filter: 'metaseo_manage_options_capability' - Allow changing the capability users need to view the settings pages
|
@@ -995,7 +1090,7 @@ class MetaSeo_Admin {
|
|
995 |
if (!class_exists('MetaSeo_Content_List_Table')) {
|
996 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-sitemap.php' );
|
997 |
}
|
998 |
-
|
999 |
$metaseo_sitemap = new MetaSeo_Sitemap();
|
1000 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/metaseo-google-sitemap.php' );
|
1001 |
break;
|
@@ -1008,7 +1103,7 @@ class MetaSeo_Admin {
|
|
1008 |
case 'metaseo_settings':
|
1009 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
|
1010 |
break;
|
1011 |
-
|
1012 |
case 'metaseo_content_meta':
|
1013 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/content-meta.php' );
|
1014 |
break;
|
@@ -1017,11 +1112,11 @@ class MetaSeo_Admin {
|
|
1017 |
case 'metaseo_image_meta':
|
1018 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/image-meta.php' );
|
1019 |
break;
|
1020 |
-
|
1021 |
case 'metaseo_link_meta':
|
1022 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/link-meta.php' );
|
1023 |
break;
|
1024 |
-
|
1025 |
case 'metaseo_image_optimize':
|
1026 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/image-optimize.php' );
|
1027 |
break;
|
@@ -1034,144 +1129,151 @@ class MetaSeo_Admin {
|
|
1034 |
}
|
1035 |
}
|
1036 |
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
|
|
|
|
|
|
1040 |
$margs = array(
|
1041 |
-
'posts_per_page' => -1,'post_type' => 'attachment','post_status' => 'any',
|
1042 |
'meta_query' => array(
|
1043 |
'relation' => 'OR',
|
1044 |
-
|
1045 |
array(
|
1046 |
'key' => '_wp_attachment_image_alt',
|
1047 |
'value' => '',
|
1048 |
'compare' => '!='
|
1049 |
),
|
1050 |
)
|
1051 |
-
);
|
1052 |
|
1053 |
-
$m_newquery = new WP_Query(
|
1054 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1055 |
-
if(!empty($mposts_empty_alt)){
|
1056 |
wp_send_json(true);
|
1057 |
-
}else{
|
1058 |
wp_send_json(false);
|
1059 |
}
|
1060 |
-
}else{
|
1061 |
global $wpdb;
|
1062 |
-
$
|
1063 |
-
|
|
|
1064 |
wp_send_json(true);
|
1065 |
-
}else{
|
1066 |
wp_send_json(false);
|
1067 |
}
|
1068 |
}
|
1069 |
}
|
1070 |
-
|
1071 |
}
|
1072 |
|
1073 |
-
|
|
|
|
|
|
|
1074 |
global $wpdb;
|
1075 |
-
if(empty($_POST['mtype']))
|
1076 |
-
|
|
|
1077 |
// select all
|
1078 |
$limit = 500;
|
1079 |
// check image alt and title empty
|
1080 |
$margs = array(
|
1081 |
-
'posts_per_page' => -1,'post_type' => 'attachment','post_status' => 'any'
|
1082 |
-
);
|
1083 |
-
|
1084 |
-
$m_newquery = new WP_Query(
|
1085 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1086 |
-
$
|
1087 |
-
|
|
|
1088 |
// query attachment and update meta
|
1089 |
-
$
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
$
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
|
|
|
|
1098 |
$i_info_url = pathinfo($attachment->guid);
|
1099 |
-
switch ($_POST['mtype']){
|
1100 |
case 'image_alt':
|
1101 |
-
update_post_meta($attachment->ID
|
1102 |
-
|
1103 |
-
|
1104 |
case 'image_title':
|
1105 |
-
wp_update_post(array('ID' => $attachment->ID,'post_title' => $i_info_url['filename']));
|
1106 |
-
|
1107 |
}
|
1108 |
}
|
1109 |
}
|
1110 |
-
|
1111 |
wp_send_json(true);
|
1112 |
-
|
1113 |
-
}else{
|
1114 |
// selected
|
1115 |
-
if(isset($_POST['ids'])){
|
1116 |
$ids = $_POST['ids'];
|
1117 |
$margs = array(
|
1118 |
'posts_per_page' => -1,
|
1119 |
-
'post_type'
|
1120 |
'post_status' => 'any',
|
1121 |
'post__in' => $ids
|
1122 |
-
);
|
1123 |
-
|
1124 |
$query = "SELECT *
|
1125 |
FROM $wpdb->posts
|
1126 |
WHERE `post_type` = 'attachment'
|
1127 |
-
AND `post_mime_type` LIKE '%image%' AND `ID` IN (".
|
1128 |
";
|
1129 |
-
|
1130 |
-
$m_newquery = new WP_Query(
|
1131 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1132 |
$mposts_empty_title = $wpdb->get_results($query);
|
1133 |
-
|
1134 |
-
switch ($_POST['mtype']){
|
1135 |
case 'image_alt':
|
1136 |
-
if(!empty($mposts_empty_alt)){
|
1137 |
-
foreach ($mposts_empty_alt as $post){
|
1138 |
$i_info_url = pathinfo($post->guid);
|
1139 |
-
update_post_meta($post->ID
|
1140 |
}
|
1141 |
-
}else{
|
1142 |
wp_send_json(false);
|
1143 |
}
|
1144 |
-
|
1145 |
|
1146 |
case 'image_title':
|
1147 |
-
if(!empty($mposts_empty_title)){
|
1148 |
-
foreach ($mposts_empty_title as $post){
|
1149 |
$i_info_url = pathinfo($post->guid);
|
1150 |
-
wp_update_post(array('ID' => $post->ID,'post_title' => $i_info_url['filename']));
|
1151 |
}
|
1152 |
-
}else{
|
1153 |
wp_send_json(false);
|
1154 |
}
|
1155 |
-
|
1156 |
}
|
1157 |
wp_send_json(true);
|
1158 |
-
|
1159 |
-
}else{
|
1160 |
wp_send_json(false);
|
1161 |
}
|
1162 |
}
|
1163 |
-
|
1164 |
-
|
1165 |
}
|
1166 |
|
1167 |
-
|
1168 |
-
|
|
|
|
|
|
|
1169 |
unset($post_types['attachment']);
|
1170 |
-
if(isset($_POST['sl_bulk']) && $_POST['sl_bulk'] == 'all'){
|
1171 |
$margs = array(
|
1172 |
'posts_per_page' => -1,
|
1173 |
-
'post_type'
|
1174 |
-
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
|
1175 |
'meta_query' => array(
|
1176 |
'relation' => 'OR',
|
1177 |
array(
|
@@ -1183,14 +1285,14 @@ class MetaSeo_Admin {
|
|
1183 |
'value' => false,
|
1184 |
'type' => 'BOOLEAN'
|
1185 |
),
|
1186 |
-
));
|
1187 |
-
}else{
|
1188 |
-
if(isset($_POST['ids'])){
|
1189 |
$ids = $_POST['ids'];
|
1190 |
$margs = array(
|
1191 |
'posts_per_page' => -1,
|
1192 |
-
'post_type'
|
1193 |
-
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
|
1194 |
'post__in' => $ids,
|
1195 |
'meta_query' => array(
|
1196 |
'relation' => 'OR',
|
@@ -1203,55 +1305,54 @@ class MetaSeo_Admin {
|
|
1203 |
'value' => false,
|
1204 |
'type' => 'BOOLEAN'
|
1205 |
),
|
1206 |
-
));
|
1207 |
-
}else{
|
1208 |
wp_send_json(false);
|
1209 |
}
|
1210 |
-
|
1211 |
}
|
1212 |
-
|
1213 |
-
$m_newquery = new WP_Query(
|
1214 |
$mposts = $m_newquery->get_posts();
|
1215 |
-
if(!empty($mposts)){
|
1216 |
-
foreach ($mposts as $post){
|
1217 |
-
update_post_meta($post->ID
|
1218 |
}
|
1219 |
wp_send_json(true);
|
1220 |
-
}else{
|
1221 |
-
|
1222 |
wp_send_json(false);
|
1223 |
}
|
1224 |
-
|
1225 |
-
|
1226 |
}
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
|
|
|
|
1256 |
|
1257 |
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Class that holds most of the admin functionality for Meta SEO.
|
4 |
+
*/
|
5 |
+
|
6 |
class MetaSeo_Admin {
|
7 |
+
|
8 |
private $options;
|
9 |
private $pagenow;
|
10 |
public static $desc_length = 156;
|
11 |
public static $title_length = 69;
|
12 |
+
|
13 |
function __construct() {
|
14 |
$this->settings = array(
|
15 |
+
"metaseo_title_home" => "",
|
16 |
+
"metaseo_desc_home" => "",
|
17 |
+
"metaseo_showfacebook" => "",
|
18 |
+
"metaseo_showtwitter" => "",
|
19 |
+
"metaseo_twitter_card" => "summary",
|
20 |
+
"metaseo_showkeywords" => 0,
|
21 |
+
"metaseo_showtmetablock" => 1,
|
22 |
"metaseo_showsocial" => 1,
|
23 |
"metaseo_seovalidate" => 0,
|
24 |
"metaseo_linkfield" => 1,
|
25 |
"metaseo_metatitle_tab" => 0,
|
26 |
"metaseo_follow" => 0,
|
27 |
"metaseo_index" => 0
|
28 |
+
);
|
29 |
+
$settings = get_option('_metaseo_settings');
|
30 |
+
|
31 |
+
if (is_array($settings)) {
|
32 |
+
$this->settings = array_merge($this->settings, $settings);
|
33 |
+
}
|
34 |
+
|
35 |
$this->pagenow = $GLOBALS['pagenow'];
|
36 |
+
if ((isset($this->settings['metaseo_showtmetablock']) && $this->settings['metaseo_showtmetablock'] == 1)) {
|
37 |
$this->load_meta_boxes();
|
38 |
}
|
39 |
+
|
40 |
add_action('admin_menu', array($this, 'register_menu_page'));
|
41 |
|
42 |
/** Load admin js * */
|
43 |
add_action('admin_enqueue_scripts', array($this, 'loadAdminScripts'));
|
|
|
|
|
|
|
44 |
$this->ajaxHandle();
|
45 |
+
|
46 |
//register ajax update meta handler...
|
47 |
+
add_action('wp_ajax_updateContentMeta', array($this, 'updateContentMeta_callback'));
|
48 |
+
add_action('admin_init', array($this, 'metaseo_field_settings'));
|
49 |
+
|
50 |
+
add_action('admin_init', array($this, 'metaseo_create_db'));
|
51 |
+
|
52 |
+
add_action('init', array($this, 'wpms_load_langguage'));
|
53 |
+
|
54 |
+
if (!get_option('wpms_set_ignore', false)) {
|
55 |
+
add_option('wpms_set_ignore', 1, '', 'yes');
|
56 |
}
|
57 |
+
|
58 |
+
add_action('wp_ajax_wpms_set_ignore', array($this, 'wpms_set_ignore'));
|
59 |
+
if ('0' == get_option('blog_public')) {
|
60 |
+
add_action('admin_notices', array($this, 'wpms_public_warning'));
|
61 |
}
|
62 |
+
add_action('wp_enqueue_editor', array($this, 'wpms_link_title_field'), 20);
|
63 |
+
add_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'), 10, 3);
|
64 |
+
add_action('delete_post', array('MetaSeo_Broken_Link_Table', 'wpms_delete_post'));
|
65 |
+
add_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
66 |
+
add_action('deleted_comment', array('MetaSeo_Broken_Link_Table', 'wpms_deleted_comment'));
|
67 |
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* Create wpms_links table
|
71 |
+
*/
|
72 |
+
function metaseo_create_db() {
|
73 |
global $wpdb;
|
74 |
$option_v = 'metaseo_db_version2.2.0';
|
75 |
+
$db_installed = get_option($option_v, false);
|
76 |
+
|
77 |
+
if (!$db_installed) {
|
78 |
// create table wpms_links
|
79 |
$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wpms_links`(
|
80 |
`id` int(20) unsigned NOT NULL AUTO_INCREMENT,
|
95 |
PRIMARY KEY (id))";
|
96 |
|
97 |
|
98 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
99 |
dbDelta($sql);
|
100 |
|
101 |
|
102 |
+
$sql = $wpdb->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
|
103 |
+
WHERE table_name = %s AND column_name = %s AND TABLE_SCHEMA = %s",array($wpdb->prefix . 'wpms_links','follow',$wpdb->dbname));
|
104 |
+
$row = $wpdb->get_results($sql);
|
105 |
|
106 |
+
if (empty($row)) {
|
107 |
+
$wpdb->query("ALTER TABLE " . $wpdb->prefix . "wpms_links ADD follow tinyint(1) DEFAULT 1");
|
|
|
|
|
|
|
108 |
}
|
109 |
+
|
110 |
+
$sql = $wpdb->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
|
111 |
+
WHERE table_name = %s AND column_name = %s AND TABLE_SCHEMA = %s",array($wpdb->prefix . 'wpms_links','meta_title',$wpdb->dbname));
|
112 |
+
$row = $wpdb->get_results($sql);
|
113 |
|
114 |
+
if (empty($row)) {
|
115 |
+
$wpdb->query("ALTER TABLE " . $wpdb->prefix . "wpms_links ADD meta_title varchar(250) DEFAULT ''");
|
|
|
|
|
|
|
116 |
}
|
117 |
+
|
118 |
+
$sql = $wpdb->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
|
119 |
+
WHERE table_name = %s AND column_name = %s AND TABLE_SCHEMA = %s",array($wpdb->prefix . 'wpms_links','internal',$wpdb->dbname));
|
120 |
+
$row = $wpdb->get_results($sql);
|
121 |
|
122 |
+
if (empty($row)) {
|
123 |
+
$wpdb->query("ALTER TABLE " . $wpdb->prefix . "wpms_links ADD internal tinyint(1) DEFAULT 1");
|
|
|
|
|
|
|
124 |
}
|
125 |
+
|
126 |
// create page 404
|
127 |
+
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s", array("WP Meta SEO 404 Page", "metaseo_404_page", "page"));
|
128 |
$post_if = $wpdb->get_var($sql);
|
129 |
+
if ($post_if < 1) {
|
130 |
$content = '<div class="wall" style="background-color: #F2F3F7; border: 30px solid #fff; width: 90%; height: 90%; margin: 0 auto;">
|
131 |
|
132 |
<h1 style="text-align: center; font-family:\'open-sans\', arial; color: #444; font-size: 60px; padding: 50px;">ERROR 404 <br />-<br />NOT FOUND</h1>
|
134 |
// You may have mis-typed the URL,<br />
|
135 |
// Or the page has been removed,<br />
|
136 |
// Actually, there is nothing to see here...</p>
|
137 |
+
<p style="text-align: center;"><a style=" font-family:\'open-sans\', arial; color: #444; font-size: 20px; padding: 20px; line-height: 30px; text-decoration: none;" href="' . get_home_url() . '"><< Go back to home page >></a></p>
|
138 |
</div>';
|
139 |
$_page404 = array(
|
140 |
+
'post_title' => 'WP Meta SEO 404 Page',
|
141 |
+
'post_content' => $content,
|
142 |
+
'post_status' => 'publish',
|
143 |
+
'post_excerpt' => 'metaseo_404_page',
|
144 |
+
'post_type' => 'page',
|
145 |
);
|
146 |
+
wp_insert_post($_page404);
|
147 |
}
|
148 |
|
149 |
+
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s", array("WPMS HTML Sitemap", "metaseo_html_sitemap", "page"));
|
150 |
$post_if = $wpdb->get_var($sql);
|
151 |
+
if ($post_if < 1) {
|
152 |
$_sitemap_page = array(
|
153 |
+
'post_title' => 'WPMS HTML Sitemap',
|
154 |
+
'post_content' => '',
|
155 |
+
'post_status' => 'publish',
|
156 |
+
'post_excerpt' => 'metaseo_html_sitemap',
|
157 |
+
'post_type' => 'page',
|
158 |
);
|
159 |
+
wp_insert_post($_sitemap_page);
|
160 |
}
|
161 |
+
|
162 |
update_option($option_v, true);
|
163 |
}
|
164 |
}
|
165 |
|
166 |
+
/*
|
167 |
+
* Add field title in dialog link when edit a link
|
168 |
+
*/
|
169 |
function wpms_link_title_field() {
|
170 |
+
if (isset($this->settings['metaseo_linkfield']) && $this->settings['metaseo_linkfield'] == 1) {
|
171 |
+
wp_enqueue_script('wpmslinkTitle', plugins_url('js/wpms-link-title-field.js', dirname(__FILE__)), array('wplink'), WPMSEO_VERSION, true);
|
172 |
+
wp_localize_script('wpmslinkTitle', 'wpmsLinkTitleL10n', array(
|
173 |
+
'titleLabel' => __('Title', 'wp-meta-seo'),
|
174 |
+
));
|
175 |
}
|
176 |
}
|
177 |
|
178 |
+
/*
|
179 |
+
* Update option wpms_set_ignore
|
180 |
+
*/
|
181 |
+
function wpms_set_ignore() {
|
182 |
update_option('wpms_set_ignore', 0);
|
183 |
wp_send_json(true);
|
184 |
}
|
185 |
|
186 |
+
/*
|
187 |
+
* Render message error when disable search engines from indexing this site
|
188 |
+
*/
|
189 |
function wpms_public_warning() {
|
190 |
+
if (( function_exists('is_network_admin') && is_network_admin())) {
|
191 |
+
return;
|
192 |
+
}
|
193 |
+
|
194 |
+
if (get_option('wpms_set_ignore') == 0) {
|
195 |
+
return;
|
196 |
+
}
|
197 |
+
|
198 |
+
echo '<script type="text/javascript">' . PHP_EOL
|
199 |
+
. 'function wpmsSetIgnore(option, hide, nonce){' . PHP_EOL
|
200 |
+
. 'jQuery.post( ajaxurl, {' . PHP_EOL
|
201 |
+
. 'action: "wpms_set_ignore"' . PHP_EOL
|
202 |
+
. '}, function( data ) {' . PHP_EOL
|
203 |
+
. 'if ( data ) {' . PHP_EOL
|
204 |
+
. 'jQuery( "#" + hide ).hide();' . PHP_EOL
|
205 |
+
. '}' . PHP_EOL
|
206 |
+
. '}' . PHP_EOL
|
207 |
+
. ');' . PHP_EOL
|
208 |
+
. '}' . PHP_EOL
|
209 |
+
. '</script>';
|
210 |
+
|
211 |
+
printf('
|
212 |
<div id="robotsmessage" class="error">
|
213 |
<p>
|
214 |
<strong>%1$s</strong>
|
215 |
%2$s
|
216 |
<a href="javascript:wpmsSetIgnore(\'wpms_public_warning\',\'robotsmessage\',\'%3$s\');" class="button">%4$s</a>
|
217 |
</p>
|
218 |
+
</div>', __('Your website is not indexed by search engine because of your WordPress settings.', 'wp-meta-seo'), sprintf(__('%sFix it now%s', 'wp-meta-seo'), sprintf('<a href="%s">', esc_url(admin_url('options-reading.php'))), '</a>'), esc_js(wp_create_nonce('wpseo-ignore')), __('OK I know that.', 'wp-meta-seo')
|
219 |
+
);
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
|
222 |
+
/*
|
223 |
+
* Loads translated strings.
|
224 |
+
*/
|
225 |
+
function wpms_load_langguage() {
|
226 |
+
load_plugin_textdomain('wp-meta-seo', false, dirname(plugin_basename(WPMSEO_FILE)) . '/languages/');
|
227 |
}
|
228 |
+
|
229 |
+
function metaseo_create_field($data_title, $alt, $dashicon, $label, $value_hidden) {
|
230 |
+
$output = '<div class="metaseo_analysis metaseo_tool" data-title="' . $data_title . '" alt="' . $alt . '"><i class="metaseo-dashicons material-icons dashicons-before" style="' . ($dashicon == 'done' ? 'color:#46B450' : 'color:#FFB900') . '">' . $dashicon . '</i>' . $label . '</div>';
|
231 |
+
$output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms[' . $data_title . ']" value="' . $value_hidden . '">';
|
232 |
return $output;
|
233 |
}
|
234 |
|
235 |
+
/*
|
236 |
+
* Ajax load page analysis
|
237 |
+
*/
|
238 |
function metaseo_reload_analysis() {
|
239 |
$tooltip_page = array();
|
240 |
+
$tooltip_page['title_in_heading'] = __('Check if a word of this content title is also in a title heading (h1, h2...)', 'wp-meta-seo');
|
241 |
+
$tooltip_page['title_in_content'] = __('Check if a word of this content title is also in the text', 'wp-meta-seo');
|
242 |
+
$tooltip_page['page_url'] = __('Does the page title match with the permalink (URL structure)', 'wp-meta-seo');
|
243 |
+
$tooltip_page['meta_title'] = __('Is the meta title of this page filled?', 'wp-meta-seo');
|
244 |
+
$tooltip_page['meta_desc'] = __('Is the meta description of this page filled?', 'wp-meta-seo');
|
245 |
+
$tooltip_page['image_resize'] = __('Check for image HTML resizing in content (usually image resized using handles)', 'wp-meta-seo');
|
246 |
+
$tooltip_page['image_alt'] = __('Check for image Alt text and title', 'wp-meta-seo');
|
247 |
+
if (empty($_POST['datas'])) {
|
248 |
wp_send_json(false);
|
249 |
}
|
250 |
+
|
251 |
+
if (isset($_POST['datas']['post_id'])) {
|
252 |
update_post_meta($_POST['datas']['post_id'], 'wpms_validate_analysis', '');
|
253 |
}
|
254 |
+
|
255 |
$check = 0;
|
256 |
$output = '';
|
257 |
+
|
258 |
// title heading
|
259 |
+
$words_post_title = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($_POST['datas']['title']));
|
260 |
+
if ($_POST['datas']['content'] == '') {
|
261 |
+
$output .= $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
262 |
+
} else {
|
263 |
$dom = new DOMDocument;
|
264 |
+
libxml_use_internal_errors(true);
|
265 |
+
if ($dom->loadHTML('<div>' . html_entity_decode(stripcslashes($_POST['datas']['content'])) . '</div>')) {
|
266 |
// Extracting the specified elements from the web page
|
267 |
$tags_h1 = $dom->getElementsByTagName('h1');
|
268 |
$tags_h2 = $dom->getElementsByTagName('h2');
|
272 |
$tags_h6 = $dom->getElementsByTagName('h6');
|
273 |
|
274 |
$test = false;
|
275 |
+
if (count($tags_h1) == 0 && count($tags_h2) == 0 && count($tags_h3) == 0 && count($tags_h4) == 0 && count($tags_h5) == 0 && count($tags_h6) == 0) {
|
276 |
$test = false;
|
277 |
+
} else {
|
278 |
+
// check tag h1
|
279 |
+
if (!empty($tags_h1)) {
|
280 |
+
foreach ($tags_h1 as $order => $tagh1) {
|
281 |
+
$words_tagh1 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh1->nodeValue)));
|
282 |
+
if (is_array($words_tagh1) && is_array($words_post_title)) {
|
283 |
+
foreach ($words_tagh1 as $mh) {
|
284 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
285 |
$test = true;
|
286 |
}
|
287 |
}
|
289 |
}
|
290 |
}
|
291 |
|
292 |
+
// check tag h2
|
293 |
+
if (!empty($tags_h2)) {
|
294 |
+
foreach ($tags_h2 as $order => $tagh2) {
|
295 |
+
$words_tagh2 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh2->nodeValue)));
|
296 |
+
if (is_array($words_tagh2) && is_array($words_post_title)) {
|
297 |
+
foreach ($words_tagh2 as $mh) {
|
298 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
299 |
$test = true;
|
300 |
}
|
301 |
}
|
302 |
}
|
303 |
}
|
304 |
}
|
305 |
+
|
306 |
+
// check tag h3
|
307 |
+
if (!empty($tags_h3)) {
|
308 |
+
foreach ($tags_h3 as $order => $tagh3) {
|
309 |
+
$words_tagh3 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh3->nodeValue)));
|
310 |
+
if (is_array($words_tagh3) && is_array($words_post_title)) {
|
311 |
+
foreach ($words_tagh3 as $mh) {
|
312 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
313 |
$test = true;
|
314 |
}
|
315 |
}
|
316 |
}
|
317 |
}
|
318 |
}
|
319 |
+
|
320 |
+
// check tag h4
|
321 |
+
if (!empty($tags_h4)) {
|
322 |
+
foreach ($tags_h4 as $order => $tagh4) {
|
323 |
+
$words_tagh4 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh4->nodeValue)));
|
324 |
+
if (is_array($words_tagh4) && is_array($words_post_title)) {
|
325 |
+
foreach ($words_tagh4 as $mh) {
|
326 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
327 |
$test = true;
|
328 |
}
|
329 |
}
|
330 |
}
|
331 |
}
|
332 |
}
|
333 |
+
|
334 |
+
// check tag h5
|
335 |
+
if (!empty($tags_h5)) {
|
336 |
+
foreach ($tags_h5 as $order => $tagh5) {
|
337 |
+
$words_tagh5 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh5->nodeValue)));
|
338 |
+
if (is_array($words_tagh5) && is_array($words_post_title)) {
|
339 |
+
foreach ($words_tagh5 as $mh) {
|
340 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
341 |
$test = true;
|
342 |
}
|
343 |
}
|
344 |
}
|
345 |
}
|
346 |
}
|
347 |
+
|
348 |
+
// check tag h6
|
349 |
+
if (!empty($tags_h6)) {
|
350 |
+
foreach ($tags_h6 as $order => $tagh6) {
|
351 |
+
$words_tagh6 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh6->nodeValue)));
|
352 |
+
if (is_array($words_tagh6) && is_array($words_post_title)) {
|
353 |
+
foreach ($words_tagh6 as $mh) {
|
354 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
355 |
$test = true;
|
356 |
}
|
357 |
}
|
360 |
}
|
361 |
}
|
362 |
|
363 |
+
if ($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))) {
|
364 |
+
$output .= $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
365 |
$check ++;
|
366 |
+
} else {
|
367 |
+
$output .= $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
368 |
}
|
369 |
+
} else {
|
370 |
+
$output .= $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
|
|
371 |
}
|
372 |
}
|
373 |
+
|
374 |
// title content
|
375 |
+
$words_title = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($_POST['datas']['title']));
|
376 |
+
$words_post_content = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($_POST['datas']['content']));
|
377 |
+
|
378 |
$test1 = false;
|
379 |
+
if (is_array($words_title) && is_array($words_post_content)) {
|
380 |
+
foreach ($words_title as $mtitle) {
|
381 |
+
if (in_array($mtitle, $words_post_content) && $mtitle != '') {
|
382 |
$test1 = true;
|
383 |
break;
|
384 |
}
|
385 |
}
|
386 |
+
} else {
|
387 |
$test1 = false;
|
388 |
}
|
389 |
+
|
390 |
+
if ($test1) {
|
391 |
+
$output .= $this->metaseo_create_field('content_title', $tooltip_page['title_in_content'], 'done', __('Page title word in content', 'wp-meta-seo'), 1);
|
392 |
$check ++;
|
393 |
+
} else {
|
394 |
+
$output .= $this->metaseo_create_field('content_title', $tooltip_page['title_in_content'], 'warning', __('Page title word in content', 'wp-meta-seo'), 0);
|
395 |
}
|
396 |
+
|
397 |
// page url matches page title
|
398 |
$mtitle = $_POST['datas']['title'];
|
399 |
+
if ($_POST['datas']['mpageurl'] == sanitize_title($mtitle)) {
|
400 |
+
$output .= $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'done', __('Page url matches with page title', 'wp-meta-seo'), 1);
|
401 |
$check ++;
|
402 |
+
} else {
|
403 |
+
$output .= $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'warning', __('Page url matches with page title', 'wp-meta-seo'), 0);
|
404 |
}
|
405 |
+
|
406 |
// meta title filled
|
407 |
+
if (($_POST['datas']['meta_title'] != '' && strlen($_POST['datas']['meta_title']) <= self::$title_length)) {
|
408 |
+
$output .= $this->metaseo_create_field('metatitle', $tooltip_page['meta_title'], 'done', __('Meta title filled', 'wp-meta-seo'), 1);
|
409 |
$check++;
|
410 |
+
} else {
|
411 |
+
$output .= $this->metaseo_create_field('metatitle', $tooltip_page['meta_title'], 'warning', __('Meta title filled', 'wp-meta-seo'), 0);
|
412 |
}
|
413 |
+
|
414 |
// desc filled
|
415 |
+
if (($_POST['datas']['meta_desc'] != '' && strlen($_POST['datas']['meta_desc']) <= self::$desc_length)) {
|
416 |
+
$output .= $this->metaseo_create_field('metadesc', $tooltip_page['meta_desc'], 'done', __('Meta description filled', 'wp-meta-seo'), 1);
|
417 |
$check++;
|
418 |
+
} else {
|
419 |
+
$output .= $this->metaseo_create_field('metadesc', $tooltip_page['meta_desc'], 'warning', __('Meta description filled', 'wp-meta-seo'), 0);
|
420 |
}
|
421 |
+
|
422 |
// image resize
|
423 |
+
if ($_POST['datas']['content'] == '') {
|
424 |
+
$output .= $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'done', __('Wrong image resize', 'wp-meta-seo'), 1);
|
425 |
+
$output .= $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'done', __('Image have meta title or alt', 'wp-meta-seo'), 1);
|
426 |
$check += 2;
|
427 |
+
} else {
|
428 |
$dom = new DOMDocument;
|
429 |
+
libxml_use_internal_errors(true);
|
430 |
+
if ($dom->loadHTML('<div>' . html_entity_decode(stripcslashes($_POST['datas']['content'])) . '</div>')) {
|
431 |
// Extracting the specified elements from the web page
|
432 |
$tags = $dom->getElementsByTagName('img');
|
433 |
$img_wrong = false;
|
434 |
$img_wrong_alt = false;
|
435 |
+
foreach ($tags as $order => $tag) {
|
436 |
$src = $tag->getAttribute('src');
|
437 |
$b = strrpos($src, '-');
|
438 |
$e = strrpos($src, '.');
|
439 |
+
$string_wh = substr($src, $b + 1, $e - $b - 1);
|
440 |
$array_wh = explode('x', $string_wh);
|
441 |
+
if (!empty($array_wh[0]) && !empty($array_wh[1])) {
|
442 |
+
if (((int) $array_wh[0] != (int) $tag->getAttribute('width')) || ((int) $array_wh[1] != (int) $tag->getAttribute('height'))) {
|
443 |
$img_wrong = true;
|
444 |
}
|
445 |
}
|
446 |
+
|
447 |
$image_title = $tag->getAttribute('title');
|
448 |
$image_alt = $tag->getAttribute('alt');
|
449 |
+
if ($image_title == '' || $image_alt == '') {
|
450 |
$img_wrong_alt = true;
|
451 |
}
|
452 |
}
|
453 |
+
|
454 |
+
if ($img_wrong == false) {
|
455 |
+
$output .= $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'done', __('Wrong image resize', 'wp-meta-seo'), 1);
|
456 |
$check++;
|
457 |
+
} else {
|
458 |
+
$output .= $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'warning', __('Wrong image resize', 'wp-meta-seo'), 0);
|
459 |
}
|
460 |
+
|
461 |
+
if ($img_wrong_alt == false) {
|
462 |
+
$output .= $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'done', __('Image have meta title or alt', 'wp-meta-seo'), 1);
|
463 |
$check++;
|
464 |
+
} else {
|
465 |
+
$output .= $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'warning', __('Image have meta title or alt', 'wp-meta-seo'), 0);
|
466 |
}
|
467 |
+
} else {
|
468 |
+
$output .= $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'warning', __('Wrong image resize', 'wp-meta-seo'), 0);
|
469 |
+
$output .= $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'warning', __('Image have meta title or alt', 'wp-meta-seo'), 0);
|
470 |
}
|
471 |
}
|
472 |
+
|
473 |
+
$circliful = ceil(100 * ($check) / 7);
|
474 |
+
wp_send_json(array('circliful' => $circliful, 'output' => $output, 'check' => $check));
|
|
|
475 |
}
|
476 |
|
477 |
+
/*
|
478 |
+
* validate propertyin page optimization
|
479 |
+
*/
|
480 |
+
function metaseo_validate_analysis() {
|
481 |
$post_id = $_POST['post_id'];
|
482 |
$key = 'wpms_validate_analysis';
|
483 |
+
$analysis = get_post_meta($post_id, $key, true);
|
484 |
+
if (empty($analysis)) {
|
485 |
$analysis = array();
|
486 |
}
|
487 |
+
|
488 |
$analysis[$_POST['field']] = 1;
|
489 |
update_post_meta($post_id, $key, $analysis);
|
490 |
wp_send_json(true);
|
491 |
}
|
492 |
|
493 |
+
/*
|
494 |
+
* Ajax update link meta title and content editor
|
495 |
+
*/
|
496 |
+
function metaseo_update_link() {
|
497 |
if (isset($_POST['link_id'])) {
|
498 |
global $wpdb;
|
499 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
|
508 |
|
509 |
|
510 |
$post = get_post($link_detail->source_id);
|
511 |
+
if (!empty($post)) {
|
512 |
$old_value = $post->post_content;
|
513 |
+
$edit_result = $this->wpms_edit_linkhtml($old_value, $link_detail->link_url, $link_detail->link_url, $_POST['meta_title']);
|
514 |
$my_post = array(
|
515 |
'ID' => $link_detail->source_id,
|
516 |
'post_content' => $edit_result['content']
|
519 |
wp_update_post($my_post);
|
520 |
wp_send_json(array('status' => true));
|
521 |
}
|
|
|
522 |
}
|
523 |
wp_send_json(false);
|
524 |
+
}
|
525 |
|
526 |
+
/*
|
527 |
+
* Ajax update meta index for page
|
528 |
+
*/
|
529 |
+
function metaseo_update_pageindex() {
|
530 |
+
if (isset($_POST['page_id']) && isset($_POST['index'])) {
|
531 |
update_post_meta($_POST['page_id'], '_metaseo_metaindex', $_POST['index']);
|
532 |
wp_send_json(array('status' => true));
|
533 |
}
|
534 |
wp_send_json(array('status' => false));
|
535 |
}
|
536 |
|
537 |
+
/*
|
538 |
+
* Ajax update meta follow for page
|
539 |
+
*/
|
540 |
+
function metaseo_update_pagefollow() {
|
541 |
+
if (isset($_POST['page_id']) && isset($_POST['follow'])) {
|
542 |
update_post_meta($_POST['page_id'], '_metaseo_metafollow', $_POST['follow']);
|
543 |
wp_send_json(array('status' => true));
|
544 |
}
|
545 |
wp_send_json(array('status' => false));
|
546 |
}
|
547 |
|
548 |
+
/*
|
549 |
+
* Ajax update meta follow for link
|
550 |
+
*/
|
551 |
+
function metaseo_update_follow() {
|
552 |
if (isset($_POST['link_id'])) {
|
553 |
+
$this->update_follow($_POST['link_id'], $_POST['follow']);
|
554 |
wp_send_json(array('status' => true));
|
555 |
}
|
556 |
wp_send_json(array('status' => false));
|
557 |
}
|
558 |
|
559 |
+
/*
|
560 |
+
* Ajax update multitle meta follow for link
|
561 |
+
*/
|
562 |
+
function metaseo_update_multiplefollow() {
|
563 |
global $wpdb;
|
564 |
$follow_value = $_POST['follow_value'];
|
565 |
$limit = 20;
|
566 |
+
|
567 |
+
switch ($follow_value) {
|
568 |
case 'follow_selected':
|
569 |
+
if (empty($_POST['linkids']))
|
570 |
+
wp_send_json(array('status' => true));
|
571 |
$follow = 1;
|
572 |
+
foreach ($_POST['linkids'] as $linkId) {
|
573 |
+
$this->update_follow($linkId, $follow);
|
574 |
}
|
575 |
break;
|
576 |
|
577 |
case 'follow_all':
|
578 |
$follow = 1;
|
579 |
$i = 0;
|
580 |
+
$links = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE follow=0 AND type='url'");
|
581 |
+
foreach ($links as $link) {
|
582 |
+
if ($i > $limit) {
|
583 |
+
wp_send_json(array('status' => false, 'message' => 'limit'));
|
584 |
+
} else {
|
585 |
+
$this->update_follow($link->id, $follow);
|
|
|
586 |
$i++;
|
587 |
}
|
588 |
}
|
589 |
+
|
590 |
break;
|
591 |
|
592 |
case 'nofollow_selected':
|
593 |
$follow = 0;
|
594 |
+
if (empty($_POST['linkids']))
|
595 |
+
wp_send_json(array('status' => true));
|
596 |
+
foreach ($_POST['linkids'] as $linkId) {
|
597 |
+
$this->update_follow($linkId, $follow);
|
598 |
}
|
599 |
break;
|
600 |
|
601 |
case 'nofollow_all':
|
602 |
$follow = 0;
|
603 |
$i = 0;
|
604 |
+
$links = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE follow=1 AND type='url'");
|
605 |
+
foreach ($links as $link) {
|
606 |
+
if ($i > $limit) {
|
607 |
+
wp_send_json(array('status' => false, 'message' => 'limit'));
|
608 |
+
} else {
|
609 |
+
$this->update_follow($link->id, $follow);
|
|
|
610 |
$i++;
|
611 |
}
|
612 |
}
|
615 |
wp_send_json(array('status' => true));
|
616 |
}
|
617 |
|
618 |
+
/*
|
619 |
+
* Ajax update meta follow for link
|
620 |
+
*/
|
621 |
+
function update_follow($linkId, $follow) {
|
622 |
global $wpdb;
|
623 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($linkId));
|
624 |
$link_detail = $wpdb->get_row($sql);
|
631 |
);
|
632 |
|
633 |
$post = get_post($link_detail->source_id);
|
634 |
+
if (!empty($post)) {
|
635 |
$old_value = $post->post_content;
|
636 |
+
$edit_result = $this->wpms_edit_linkhtml($old_value, $link_detail->link_url, $link_detail->link_url, $link_detail->meta_title, $follow);
|
637 |
$my_post = array(
|
638 |
'ID' => $link_detail->source_id,
|
639 |
'post_content' => $edit_result['content']
|
643 |
}
|
644 |
}
|
645 |
|
646 |
+
/*
|
647 |
+
* Render new content when edit a link
|
648 |
+
*/
|
649 |
+
public function wpms_edit_linkhtml($content, $new_url, $old_url, $meta_title, $follow, $new_text = null) {
|
650 |
//Save the old & new URLs for use in the edit callback.
|
651 |
$args = array(
|
652 |
'old_url' => $old_url,
|
668 |
}
|
669 |
return $result;
|
670 |
}
|
671 |
+
|
672 |
+
/*
|
673 |
+
* Update option wpms_settings_404
|
674 |
+
*/
|
675 |
+
function wpms_save_settings404() {
|
676 |
+
if (isset($_POST['wpms_redirect'])) {
|
677 |
update_option('wpms_settings_404', $_POST['wpms_redirect']);
|
678 |
wp_send_json(true);
|
679 |
}
|
680 |
}
|
681 |
+
|
682 |
+
/*
|
683 |
+
* Add a new field to a section of a settings page
|
684 |
+
*/
|
685 |
+
function metaseo_field_settings() {
|
686 |
+
register_setting('Wp Meta SEO', '_metaseo_settings');
|
687 |
+
add_settings_section('metaseo_dashboard', '', array($this, 'showSettings'), 'metaseo_settings');
|
688 |
+
add_settings_field('metaseo_title_home', __('Homepage meta title', 'wp-meta-seo'), array($this, 'metaseo_title_home'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('You can define your home page meta title in the content itself (a page, a post category…), if for some reason it’s not possible, use this setting', 'wp-meta-seo')));
|
689 |
+
add_settings_field('metaseo_desc_home', __('Homepage meta description', 'wp-meta-seo'), array($this, 'metaseo_desc_home'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('You can define your home page meta description in the content itself (a page, a post category…), if for some reason it’s not possible, use this setting', 'wp-meta-seo')));
|
690 |
+
add_settings_field('metaseo_showfacebook', __('Facebook profile URL', 'wp-meta-seo'), array($this, 'showfacebook'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Used as profile in case of social sharing content on Facebook', 'wp-meta-seo')));
|
691 |
+
add_settings_field('metaseo_showtwitter', __('Twitter Username', 'wp-meta-seo'), array($this, 'showtwitter'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Used as profile in case of social sharing content on Twitter', 'wp-meta-seo')));
|
692 |
+
add_settings_field('metaseo_twitter_card', __('The default card type to use', 'wp-meta-seo'), array($this, 'showtwittercard'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Choose the Twitter card size generated when sharing a content', 'wp-meta-seo')));
|
693 |
+
add_settings_field('metaseo_metatitle_tab', __('Meta title as page title', 'wp-meta-seo'), array($this, 'showmetatitletab'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Usually not recommended as meta information is for search engines and content title for readers, but in some case... :)', 'wp-meta-seo')));
|
694 |
+
add_settings_field('metaseo_showkeywords', __('Meta keywords', 'wp-meta-seo'), array($this, 'showkeywords'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Not used directly by search engine to index content, but in some case it can be helpful (multilingual is an example)', 'wp-meta-seo')));
|
695 |
+
add_settings_field('metaseo_showtmetablock', __('Meta block edition', 'wp-meta-seo'), array($this, 'showtmetablock'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Load the onpage meta edition and analysis block', 'wp-meta-seo')));
|
696 |
+
add_settings_field('metaseo_showsocial', __('Social sharing block', 'wp-meta-seo'), array($this, 'showsocial'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Activate the custom social sharing tool, above the meta block', 'wp-meta-seo')));
|
697 |
+
add_settings_field('metaseo_seovalidate', __('Force SEO validation', 'wp-meta-seo'), array($this, 'showseovalidate'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Possibility to force a criteria validation in the content analysis tool', 'wp-meta-seo')));
|
698 |
+
add_settings_field('metaseo_linkfield', __('Link text field', 'wp-meta-seo'), array($this, 'showlinkfield'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Add the link title field in the text editor and in the bulk link edition view', 'wp-meta-seo')));
|
699 |
+
add_settings_field('metaseo_follow', __('Post/Page follow', 'wp-meta-seo'), array($this, 'showfollow'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Add an option to setup Follow/Nofollow instruction for each content', 'wp-meta-seo')));
|
700 |
+
add_settings_field('metaseo_index', __('Post/Page index', 'wp-meta-seo'), array($this, 'showindex'), 'metaseo_settings', 'metaseo_dashboard', array('label_for' => __('Add an option to say to search engine: hey! Do not index this content', 'wp-meta-seo')));
|
701 |
}
|
702 |
|
703 |
+
/*
|
704 |
+
* Display metatitle_tab input
|
705 |
+
*/
|
706 |
+
public function showmetatitletab() {
|
707 |
echo '<input name="_metaseo_settings[metaseo_metatitle_tab]" type="hidden" value="0"/>';
|
708 |
?>
|
709 |
+
<label><input name="_metaseo_settings[metaseo_metatitle_tab]" type="checkbox" id="metaseo_metatitle_tab" value="1" <?php checked(1, $this->settings['metaseo_metatitle_tab']); ?> />
|
710 |
+
<?php _e('When meta title is filled use it as page title instead of the content title', 'wp-meta-seo'); ?></label>
|
711 |
<?php
|
712 |
}
|
713 |
|
714 |
+
public function showSettings() {
|
715 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
716 |
}
|
717 |
|
718 |
+
/*
|
719 |
+
* Display title_home input
|
720 |
+
*/
|
721 |
+
public function metaseo_title_home() {
|
722 |
+
$home_title = isset($this->settings['metaseo_title_home']) ? $this->settings['metaseo_title_home'] : '';
|
723 |
+
echo '<input id="metaseo_title_home" name="_metaseo_settings[metaseo_title_home]" type="text" value="' . esc_attr($home_title) . '" size="50"/>';
|
724 |
}
|
725 |
|
726 |
+
/*
|
727 |
+
* Display desc_home input
|
728 |
+
*/
|
729 |
+
public function metaseo_desc_home() {
|
730 |
+
$home_desc = isset($this->settings['metaseo_desc_home']) ? $this->settings['metaseo_desc_home'] : '';
|
731 |
+
echo '<input id="metaseo_desc_home" name="_metaseo_settings[metaseo_desc_home]" type="text" value="' . esc_attr($home_desc) . '" size="50"/>';
|
732 |
+
}
|
733 |
+
|
734 |
+
/*
|
735 |
+
* Display showkeywords input
|
736 |
+
*/
|
737 |
+
public function showkeywords() {
|
738 |
echo '<input name="_metaseo_settings[metaseo_showkeywords]" type="hidden" value="0"/>';
|
739 |
?>
|
740 |
+
<label><input name="_metaseo_settings[metaseo_showkeywords]" type="checkbox" id="metaseo_showkeywords" value="1" <?php checked(1, $this->settings['metaseo_showkeywords']); ?> />
|
741 |
+
<?php _e('Active meta keywords', 'wp-meta-seo'); ?></label>
|
742 |
<?php
|
743 |
}
|
744 |
|
745 |
+
/*
|
746 |
+
* Display showtmetablock input
|
747 |
+
*/
|
748 |
+
public function showtmetablock() {
|
749 |
+
echo '<input name="_metaseo_settings[metaseo_showtmetablock]" type="hidden" value="0"/>';
|
750 |
?>
|
751 |
+
<label><input name="_metaseo_settings[metaseo_showtmetablock]" type="checkbox" id="metaseo_showtmetablock" value="1" <?php checked(1, $this->settings['metaseo_showtmetablock']); ?> />
|
752 |
+
<?php _e('Activate meta block edition below content', 'wp-meta-seo'); ?></label>
|
753 |
<?php
|
754 |
}
|
755 |
|
756 |
+
/*
|
757 |
+
* Display showsocial input
|
758 |
+
*/
|
759 |
+
public function showsocial() {
|
760 |
echo '<input name="_metaseo_settings[metaseo_showsocial]" type="hidden" value="0"/>';
|
761 |
?>
|
762 |
+
<label><input name="_metaseo_settings[metaseo_showsocial]" type="checkbox" id="metaseo_showsocial" value="1" <?php checked(1, $this->settings['metaseo_showsocial']); ?> />
|
763 |
+
<?php _e('Activate social edition', 'wp-meta-seo'); ?></label>
|
764 |
<?php
|
765 |
}
|
766 |
|
767 |
+
/*
|
768 |
+
* Display seovalidate input
|
769 |
+
*/
|
770 |
+
public function showseovalidate() {
|
771 |
echo '<input name="_metaseo_settings[metaseo_seovalidate]" type="hidden" value="0"/>';
|
772 |
?>
|
773 |
+
<label><input name="_metaseo_settings[metaseo_seovalidate]" type="checkbox" id="metaseo_seovalidate" value="1" <?php checked(1, $this->settings['metaseo_seovalidate']); ?> />
|
774 |
+
<?php _e('Allow user to force on page SEO criteria validation by clicking on the icon', 'wp-meta-seo'); ?></label>
|
775 |
<?php
|
776 |
}
|
777 |
|
778 |
+
/*
|
779 |
+
* Display linkfield input
|
780 |
+
*/
|
781 |
+
public function showlinkfield() {
|
782 |
echo '<input name="_metaseo_settings[metaseo_linkfield]" type="hidden" value="0"/>';
|
783 |
?>
|
784 |
+
<label><input name="_metaseo_settings[metaseo_linkfield]" type="checkbox" id="metaseo_linkfield" value="1" <?php checked(1, $this->settings['metaseo_linkfield']); ?> />
|
785 |
+
<?php _e("Adds back the missing 'title' field in the Insert/Edit URL box", "wp-meta-seo"); ?></label>
|
786 |
<?php
|
787 |
}
|
788 |
|
789 |
+
/*
|
790 |
+
* Display follow input
|
791 |
+
*/
|
792 |
+
public function showfollow() {
|
793 |
echo '<input name="_metaseo_settings[metaseo_follow]" type="hidden" value="0"/>';
|
794 |
?>
|
795 |
+
<label><input name="_metaseo_settings[metaseo_follow]" type="checkbox" id="metaseo_follow" value="1" <?php checked(1, $this->settings['metaseo_follow']); ?> />
|
796 |
+
<?php _e("Provides a way for webmasters to tell search engines don't follow links on the page.", "wp-meta-seo"); ?></label>
|
797 |
<?php
|
798 |
}
|
799 |
|
800 |
+
/*
|
801 |
+
* Display index input
|
802 |
+
*/
|
803 |
+
public function showindex() {
|
804 |
echo '<input name="_metaseo_settings[metaseo_index]" type="hidden" value="0"/>';
|
805 |
?>
|
806 |
+
<label><input name="_metaseo_settings[metaseo_index]" type="checkbox" id="metaseo_index" value="1" <?php checked(1, $this->settings['metaseo_index']); ?> />
|
807 |
+
<?php _e("Provides show or do not show this page in search results in search results.", "wp-meta-seo"); ?></label>
|
808 |
<?php
|
809 |
}
|
810 |
+
|
811 |
+
/*
|
812 |
+
* Display showfacebook input
|
813 |
+
*/
|
814 |
+
public function showfacebook() {
|
815 |
+
$face = isset($this->settings['metaseo_showfacebook']) ? $this->settings['metaseo_showfacebook'] : '';
|
816 |
+
echo '<input id="metaseo_showfacebook" name="_metaseo_settings[metaseo_showfacebook]" type="text" value="' . esc_attr($face) . '" size="50"/>';
|
817 |
}
|
818 |
|
819 |
+
/*
|
820 |
+
* Display showtwitter input
|
821 |
+
*/
|
822 |
+
public function showtwitter() {
|
823 |
+
$twitter = isset($this->settings['metaseo_showtwitter']) ? $this->settings['metaseo_showtwitter'] : '';
|
824 |
+
echo '<input id="metaseo_showtwitter" name="_metaseo_settings[metaseo_showtwitter]" type="text" value="' . esc_attr($twitter) . '" size="50"/>';
|
825 |
}
|
826 |
|
827 |
+
/*
|
828 |
+
* Display twitter_card input
|
829 |
+
*/
|
830 |
+
public function showtwittercard() {
|
831 |
+
$twitter_card = isset($this->settings['metaseo_twitter_card']) ? $this->settings['metaseo_twitter_card'] : 'summary';
|
832 |
?>
|
833 |
<select class="select" name="_metaseo_settings[metaseo_twitter_card]" id="metaseo_twitter_card">
|
834 |
+
<option <?php if ($twitter_card == 'summary') echo 'selected' ?> value="summary"><?php _e('Summary', 'wp-meta-seo'); ?></option>
|
835 |
+
<option <?php if ($twitter_card == 'summary_large_image') echo 'selected' ?> value="summary_large_image"><?php _e('Summary with large image', 'wp-meta-seo'); ?></option>
|
836 |
</select>
|
837 |
<?php
|
838 |
}
|
839 |
+
|
840 |
private function load_meta_boxes() {
|
841 |
+
if (in_array($this->pagenow, array(
|
842 |
+
'edit.php',
|
843 |
+
'post.php',
|
844 |
+
'post-new.php',
|
845 |
+
)) || apply_filters('wpmseo_always_register_metaboxes_on_admin', false)
|
846 |
+
) {
|
847 |
+
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-metabox.php' );
|
848 |
+
$GLOBALS['wpmseo_metabox'] = new WPMSEO_Metabox;
|
849 |
+
}
|
850 |
}
|
851 |
+
|
852 |
function stop_heartbeat() {
|
853 |
+
global $pagenow;
|
854 |
+
if ('post.php' != $pagenow && 'post-new.php' != $pagenow)
|
855 |
wp_deregister_script('heartbeat');
|
856 |
}
|
857 |
+
|
858 |
+
/*
|
859 |
+
* Update meta title , meta description , meta keyword for content
|
860 |
+
*/
|
861 |
function updateContentMeta_callback() {
|
862 |
+
global $wpdb;
|
863 |
+
$_POST = stripslashes_deep($_POST);
|
864 |
+
$response = new stdClass();
|
865 |
+
|
866 |
+
if (!empty($_POST['metakey']) && !empty($_POST['postid']) && !empty($_POST['value']))
|
867 |
+
;
|
868 |
+
$metakey = strtolower(trim($_POST['metakey']));
|
869 |
+
$postID = intval($_POST['postid']);
|
870 |
+
$value = trim($_POST['value']);
|
871 |
+
$response->msg = __('Modification was saved', 'wp-meta-seo');
|
872 |
+
if ($metakey == 'metatitle') {
|
873 |
+
if (!update_post_meta($postID, '_metaseo_metatitle', $value)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
874 |
$response->updated = false;
|
875 |
+
$response->msg = __('Meta title was not saved', 'wp-meta-seo');
|
876 |
+
} else {
|
877 |
+
$response->updated = true;
|
878 |
+
$response->msg = __('Meta title was saved', 'wp-meta-seo');
|
879 |
}
|
880 |
+
}
|
|
|
|
|
|
|
|
|
881 |
|
882 |
+
if ($metakey == 'metadesc') {
|
883 |
+
if (!update_post_meta($postID, '_metaseo_metadesc', $value)) {
|
884 |
$response->updated = false;
|
885 |
+
$response->msg = __('Meta description was not saved', 'wp-meta-seo');
|
886 |
+
} else {
|
887 |
$response->updated = true;
|
888 |
+
$response->msg = __('Meta description was saved', 'wp-meta-seo');
|
889 |
+
}
|
890 |
}
|
891 |
+
|
892 |
if ($metakey == 'metakeywords') {
|
893 |
if (!update_post_meta($postID, '_metaseo_metakeywords', $value)) {
|
894 |
$response->updated = false;
|
902 |
echo json_encode($response);
|
903 |
wp_die();
|
904 |
}
|
905 |
+
|
906 |
/**
|
907 |
* Loads js/ajax scripts
|
|
|
908 |
*/
|
909 |
public function loadAdminScripts($hook) {
|
910 |
+
global $pagenow , $current_screen;
|
911 |
+
wp_enqueue_script('jquery');
|
912 |
+
$array_menu = array(
|
913 |
+
'wp-meta-seo_page_metaseo_dashboard',
|
914 |
+
'wp-meta-seo_page_metaseo_image_optimize',
|
915 |
+
'wp-meta-seo_page_metaseo_google_sitemap',
|
916 |
+
'wp-meta-seo_page_metaseo_image_compression',
|
917 |
+
'wp-meta-seo_page_metaseo_broken_link',
|
918 |
+
'wp-meta-seo_page_metaseo_settings',
|
919 |
+
'wp-meta-seo_page_metaseo_content_meta',
|
920 |
+
'wp-meta-seo_page_metaseo_image_meta',
|
921 |
+
'wp-meta-seo_page_metaseo_link_meta'
|
922 |
+
);
|
923 |
+
|
924 |
+
if(in_array($current_screen->base, $array_menu) || $pagenow == 'post.php'){
|
925 |
+
wp_enqueue_script(
|
926 |
+
'wpmetaseoAdmin', plugins_url('js/metaseo_admin.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true
|
927 |
+
);
|
928 |
+
wp_enqueue_style('wpmetaseoAdmin', plugins_url('css/metaseo_admin.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
929 |
+
wp_enqueue_style('tooltip-metaimage', plugins_url('/css/tooltip-metaimage.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
930 |
+
wp_enqueue_style('style', plugins_url('/css/style.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
931 |
+
}
|
932 |
|
933 |
+
if ($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta' || $current_screen->base == 'wp-meta-seo_page_metaseo_content_meta') {
|
934 |
wp_enqueue_script('wpms-bulk', plugins_url('js/wpms-bulk-action.js', dirname(__FILE__)), array('jquery'), time(), true);
|
935 |
wp_localize_script('wpms-bulk', 'wpmseobulkL10n', $this->meta_seo_localize_script());
|
936 |
}
|
937 |
+
|
938 |
+
if ($current_screen->base == 'toplevel_page_metaseo_dashboard') {
|
939 |
wp_enqueue_script('Chart', plugins_url('js/Chart.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
940 |
wp_enqueue_script('jquery-knob', plugins_url('js/jquery.knob.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
941 |
wp_enqueue_script('metaseo-dashboard', plugins_url('js/dashboard.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
942 |
+
wp_enqueue_style('chart', plugins_url('/css/chart.css', dirname(__FILE__)));
|
943 |
+
wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__)));
|
944 |
+
wp_enqueue_style('metaseo-quirk', plugins_url('/css/metaseo-quirk.css', dirname(__FILE__)));
|
945 |
}
|
946 |
+
|
947 |
wp_register_style('m-style-qtip', plugins_url('css/jquery.qtip.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
948 |
wp_register_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
|
949 |
+
wp_register_script('wpms-broken-link', plugins_url('js/wpms-broken-link.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
950 |
+
|
951 |
wp_register_style('metaseo-google-icon', '//fonts.googleapis.com/icon?family=Material+Icons');
|
952 |
+
if ($current_screen->base == 'wp-meta-seo_page_metaseo_image_meta') {
|
953 |
wp_enqueue_script('mautosize', plugins_url('js/autosize.js', dirname(__FILE__)), array('jquery'), '0.1', true);
|
954 |
}
|
955 |
// in JavaScript, object properties are accessed as ajax_object.ajax_url, ajax_object.we_value
|
956 |
+
wp_localize_script('wpmetaseoAdmin', 'myAjax', array('ajax_url' => admin_url('admin-ajax.php')));
|
|
|
957 |
}
|
958 |
|
959 |
+
/**
|
960 |
+
* Localize a script.
|
961 |
+
*
|
962 |
+
* Works only if the script has already been added.
|
963 |
+
*/
|
964 |
public function meta_seo_localize_script() {
|
965 |
return array(
|
966 |
+
'metaseo_message_false_copy' => __('Warning, you\'re about to replace existing image alt or tile content, are you sire about that?', 'wp-meta-seo'),
|
967 |
);
|
968 |
}
|
969 |
|
970 |
/**
|
971 |
+
* Add a top-level menu page.
|
972 |
+
*
|
973 |
+
* This function takes a capability which will be used to determine whether
|
974 |
+
* or not a page is included in the menu.
|
975 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
976 |
function register_menu_page() {
|
977 |
|
978 |
// Add main page
|
979 |
$admin_page = add_menu_page(__('WP Meta SEO:', 'wp-meta-seo') . ' ' . __('Dashboard', 'wp-meta-seo'), __('WP Meta SEO', 'wp-meta-seo'), 'manage_options', 'metaseo_dashboard', array(
|
980 |
+
$this, 'load_page',), 'dashicons-chart-area');
|
981 |
|
982 |
/**
|
983 |
* Filter: 'metaseo_manage_options_capability' - Allow changing the capability users need to view the settings pages
|
1090 |
if (!class_exists('MetaSeo_Content_List_Table')) {
|
1091 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-sitemap.php' );
|
1092 |
}
|
1093 |
+
|
1094 |
$metaseo_sitemap = new MetaSeo_Sitemap();
|
1095 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/metaseo-google-sitemap.php' );
|
1096 |
break;
|
1103 |
case 'metaseo_settings':
|
1104 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/settings.php' );
|
1105 |
break;
|
1106 |
+
|
1107 |
case 'metaseo_content_meta':
|
1108 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/content-meta.php' );
|
1109 |
break;
|
1112 |
case 'metaseo_image_meta':
|
1113 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/image-meta.php' );
|
1114 |
break;
|
1115 |
+
|
1116 |
case 'metaseo_link_meta':
|
1117 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/link-meta.php' );
|
1118 |
break;
|
1119 |
+
|
1120 |
case 'metaseo_image_optimize':
|
1121 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/image-optimize.php' );
|
1122 |
break;
|
1129 |
}
|
1130 |
}
|
1131 |
|
1132 |
+
/*
|
1133 |
+
* Ajax check attachment have alt empty
|
1134 |
+
*/
|
1135 |
+
function wpms_ajax_check_exist() {
|
1136 |
+
if (isset($_POST['type'])) {
|
1137 |
+
if ($_POST['type'] == 'alt') {
|
1138 |
$margs = array(
|
1139 |
+
'posts_per_page' => -1, 'post_type' => 'attachment', 'post_status' => 'any',
|
1140 |
'meta_query' => array(
|
1141 |
'relation' => 'OR',
|
|
|
1142 |
array(
|
1143 |
'key' => '_wp_attachment_image_alt',
|
1144 |
'value' => '',
|
1145 |
'compare' => '!='
|
1146 |
),
|
1147 |
)
|
1148 |
+
);
|
1149 |
|
1150 |
+
$m_newquery = new WP_Query($margs);
|
1151 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1152 |
+
if (!empty($mposts_empty_alt)) {
|
1153 |
wp_send_json(true);
|
1154 |
+
} else {
|
1155 |
wp_send_json(false);
|
1156 |
}
|
1157 |
+
} else {
|
1158 |
global $wpdb;
|
1159 |
+
$sql = $wpdb->prepare("SELECT COUNT(posts.ID) as total FROM " . $wpdb->prefix . "posts as posts WHERE posts.post_type = %s AND post_title != %s",array('attachment',''));
|
1160 |
+
$check_title = $wpdb->get_var($sql);
|
1161 |
+
if ($check_title > 0) {
|
1162 |
wp_send_json(true);
|
1163 |
+
} else {
|
1164 |
wp_send_json(false);
|
1165 |
}
|
1166 |
}
|
1167 |
}
|
|
|
1168 |
}
|
1169 |
|
1170 |
+
/*
|
1171 |
+
* Ajax update image alt and image title
|
1172 |
+
*/
|
1173 |
+
function wpms_bulk_image_copy() {
|
1174 |
global $wpdb;
|
1175 |
+
if (empty($_POST['mtype']))
|
1176 |
+
wp_send_json(false);
|
1177 |
+
if (isset($_POST['sl_bulk']) && $_POST['sl_bulk'] == 'all') {
|
1178 |
// select all
|
1179 |
$limit = 500;
|
1180 |
// check image alt and title empty
|
1181 |
$margs = array(
|
1182 |
+
'posts_per_page' => -1, 'post_type' => 'attachment', 'post_status' => 'any'
|
1183 |
+
);
|
1184 |
+
|
1185 |
+
$m_newquery = new WP_Query($margs);
|
1186 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1187 |
+
$sql = $wpdb->prepare("SELECT COUNT(posts.ID) as total FROM " . $wpdb->prefix . "posts as posts WHERE posts.post_type = %s AND post_title = %s",array('attachment',''));
|
1188 |
+
$check_title = $wpdb->get_var($sql);
|
1189 |
+
|
1190 |
// query attachment and update meta
|
1191 |
+
$sql = $wpdb->prepare("SELECT COUNT(posts.ID) as total FROM " . $wpdb->prefix . "posts as posts WHERE posts.post_type = %s",array('attachment'));
|
1192 |
+
$total = $wpdb->get_var($sql);
|
1193 |
+
|
1194 |
+
$j = ceil((int) $total / $limit);
|
1195 |
+
for ($i = 0; $i <= $j; $i++) {
|
1196 |
+
$ofset = $i * $limit;
|
1197 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts as posts
|
1198 |
+
WHERE posts.post_type = %s LIMIT %d OFFSET %d",array('attachment',$limit,$ofset));
|
1199 |
+
$attachments = $wpdb->get_results($sql);
|
1200 |
+
|
1201 |
+
foreach ($attachments as $attachment) {
|
1202 |
$i_info_url = pathinfo($attachment->guid);
|
1203 |
+
switch ($_POST['mtype']) {
|
1204 |
case 'image_alt':
|
1205 |
+
update_post_meta($attachment->ID, '_wp_attachment_image_alt', $i_info_url['filename']);
|
1206 |
+
break;
|
1207 |
+
|
1208 |
case 'image_title':
|
1209 |
+
wp_update_post(array('ID' => $attachment->ID, 'post_title' => $i_info_url['filename']));
|
1210 |
+
break;
|
1211 |
}
|
1212 |
}
|
1213 |
}
|
1214 |
+
|
1215 |
wp_send_json(true);
|
1216 |
+
} else {
|
|
|
1217 |
// selected
|
1218 |
+
if (isset($_POST['ids'])) {
|
1219 |
$ids = $_POST['ids'];
|
1220 |
$margs = array(
|
1221 |
'posts_per_page' => -1,
|
1222 |
+
'post_type' => 'attachment',
|
1223 |
'post_status' => 'any',
|
1224 |
'post__in' => $ids
|
1225 |
+
);
|
1226 |
+
|
1227 |
$query = "SELECT *
|
1228 |
FROM $wpdb->posts
|
1229 |
WHERE `post_type` = 'attachment'
|
1230 |
+
AND `post_mime_type` LIKE '%image%' AND `ID` IN (" . implode(',', esc_sql($ids)) . ")
|
1231 |
";
|
1232 |
+
|
1233 |
+
$m_newquery = new WP_Query($margs);
|
1234 |
$mposts_empty_alt = $m_newquery->get_posts();
|
1235 |
$mposts_empty_title = $wpdb->get_results($query);
|
1236 |
+
switch ($_POST['mtype']) {
|
|
|
1237 |
case 'image_alt':
|
1238 |
+
if (!empty($mposts_empty_alt)) {
|
1239 |
+
foreach ($mposts_empty_alt as $post) {
|
1240 |
$i_info_url = pathinfo($post->guid);
|
1241 |
+
update_post_meta($post->ID, '_wp_attachment_image_alt', $i_info_url['filename']);
|
1242 |
}
|
1243 |
+
} else {
|
1244 |
wp_send_json(false);
|
1245 |
}
|
1246 |
+
break;
|
1247 |
|
1248 |
case 'image_title':
|
1249 |
+
if (!empty($mposts_empty_title)) {
|
1250 |
+
foreach ($mposts_empty_title as $post) {
|
1251 |
$i_info_url = pathinfo($post->guid);
|
1252 |
+
wp_update_post(array('ID' => $post->ID, 'post_title' => $i_info_url['filename']));
|
1253 |
}
|
1254 |
+
} else {
|
1255 |
wp_send_json(false);
|
1256 |
}
|
1257 |
+
break;
|
1258 |
}
|
1259 |
wp_send_json(true);
|
1260 |
+
} else {
|
|
|
1261 |
wp_send_json(false);
|
1262 |
}
|
1263 |
}
|
|
|
|
|
1264 |
}
|
1265 |
|
1266 |
+
/*
|
1267 |
+
* Ajax bulk update meta title for a post/page
|
1268 |
+
*/
|
1269 |
+
function wpms_bulk_post_copy_title() {
|
1270 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
1271 |
unset($post_types['attachment']);
|
1272 |
+
if (isset($_POST['sl_bulk']) && $_POST['sl_bulk'] == 'all') {
|
1273 |
$margs = array(
|
1274 |
'posts_per_page' => -1,
|
1275 |
+
'post_type' => $post_types,
|
1276 |
+
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
|
1277 |
'meta_query' => array(
|
1278 |
'relation' => 'OR',
|
1279 |
array(
|
1285 |
'value' => false,
|
1286 |
'type' => 'BOOLEAN'
|
1287 |
),
|
1288 |
+
));
|
1289 |
+
} else {
|
1290 |
+
if (isset($_POST['ids'])) {
|
1291 |
$ids = $_POST['ids'];
|
1292 |
$margs = array(
|
1293 |
'posts_per_page' => -1,
|
1294 |
+
'post_type' => $post_types,
|
1295 |
+
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'),
|
1296 |
'post__in' => $ids,
|
1297 |
'meta_query' => array(
|
1298 |
'relation' => 'OR',
|
1305 |
'value' => false,
|
1306 |
'type' => 'BOOLEAN'
|
1307 |
),
|
1308 |
+
));
|
1309 |
+
} else {
|
1310 |
wp_send_json(false);
|
1311 |
}
|
|
|
1312 |
}
|
1313 |
+
|
1314 |
+
$m_newquery = new WP_Query($margs);
|
1315 |
$mposts = $m_newquery->get_posts();
|
1316 |
+
if (!empty($mposts)) {
|
1317 |
+
foreach ($mposts as $post) {
|
1318 |
+
update_post_meta($post->ID, '_metaseo_metatitle', $post->post_title);
|
1319 |
}
|
1320 |
wp_send_json(true);
|
1321 |
+
} else {
|
1322 |
+
|
1323 |
wp_send_json(false);
|
1324 |
}
|
|
|
|
|
1325 |
}
|
1326 |
+
|
1327 |
+
/*
|
1328 |
+
* Add ajax
|
1329 |
+
*/
|
1330 |
+
private function ajaxHandle() {
|
1331 |
+
add_action('wp_ajax_scanPosts', array('MetaSeo_Image_List_Table', 'scan_posts_callback'));
|
1332 |
+
add_action('wp_ajax_load_posts', array('MetaSeo_Image_List_Table', 'load_posts_callback'));
|
1333 |
+
add_action('wp_ajax_optimize_imgs', array('MetaSeo_Image_List_Table', 'optimizeImages'));
|
1334 |
+
add_action('wp_ajax_updateMeta', array('MetaSeo_Image_List_Table', 'updateMeta_callback'));
|
1335 |
+
add_action('wp_ajax_import_meta_data', array('MetaSeo_Content_List_Table', 'importMetaData'));
|
1336 |
+
add_action('wp_ajax_dismiss_import_meta', array('MetaSeo_Content_List_Table', 'dismissImport'));
|
1337 |
+
add_action('wp_ajax_wpms_bulk_post_copy', array($this, 'wpms_bulk_post_copy_title'));
|
1338 |
+
add_action('wp_ajax_wpms_bulk_image_copy', array($this, 'wpms_bulk_image_copy'));
|
1339 |
+
add_action('wp_ajax_wpms_ajax_check_exist', array($this, 'wpms_ajax_check_exist'));
|
1340 |
+
add_action('added_post_meta', array('MetaSeo_Content_List_Table', 'updateMetaSync'), 99, 4);
|
1341 |
+
add_action('updated_post_meta', array('MetaSeo_Content_List_Table', 'updateMetaSync'), 99, 4);
|
1342 |
+
add_action('deleted_post_meta', array('MetaSeo_Content_List_Table', 'deleteMetaSync'), 99, 4);
|
1343 |
+
add_action('wp_ajax_metaseo_reload_analysis', array($this, 'metaseo_reload_analysis'));
|
1344 |
+
add_action('wp_ajax_metaseo_validate_analysis', array($this, 'metaseo_validate_analysis'));
|
1345 |
+
add_action('wp_ajax_metaseo_update_link', array($this, 'metaseo_update_link'));
|
1346 |
+
add_action('wp_ajax_wpms_save_settings404', array($this, 'wpms_save_settings404'));
|
1347 |
+
add_action('wp_ajax_wpms_update_link', array('MetaSeo_Broken_Link_Table', 'wpms_update_link'));
|
1348 |
+
add_action('wp_ajax_wpms_unlink', array('MetaSeo_Broken_Link_Table', 'wpms_unlink'));
|
1349 |
+
add_action('wp_ajax_wpms_recheck_link', array('MetaSeo_Broken_Link_Table', 'wpms_recheck_link'));
|
1350 |
+
add_action('wp_ajax_wpms_scan_link', array('MetaSeo_Broken_Link_Table', 'wpms_scan_link'));
|
1351 |
+
add_action('wp_ajax_wpms_flush_link', array('MetaSeo_Broken_Link_Table', 'wpms_flush_link'));
|
1352 |
+
add_action('wp_ajax_metaseo_update_follow', array($this, 'metaseo_update_follow'));
|
1353 |
+
add_action('wp_ajax_metaseo_update_multiplefollow', array($this, 'metaseo_update_multiplefollow'));
|
1354 |
+
add_action('wp_ajax_metaseo_update_pagefollow', array($this, 'metaseo_update_pagefollow'));
|
1355 |
+
add_action('wp_ajax_metaseo_update_pageindex', array($this, 'metaseo_update_pageindex'));
|
1356 |
+
}
|
1357 |
|
1358 |
}
|
inc/class.metaseo-broken-link-table.php
CHANGED
@@ -1,10 +1,8 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
*/
|
7 |
-
|
8 |
if (!class_exists('WP_List_Table')) {
|
9 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
10 |
}
|
@@ -23,7 +21,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
23 |
'ajax' => true
|
24 |
));
|
25 |
}
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
function display_tablenav($which) {
|
28 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
29 |
if (!empty($post_types['attachment']))
|
@@ -34,7 +36,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
34 |
|
35 |
<?php if ($which == 'top'): ?>
|
36 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
37 |
-
|
38 |
<div class="alignleft actions bulkactions">
|
39 |
<?php $this->broken_fillter('sl_broken'); ?>
|
40 |
<?php $this->redirect_fillter('sl_redirect'); ?>
|
@@ -55,8 +57,6 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
55 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
56 |
<?php endif ?>
|
57 |
|
58 |
-
<?php //$this->extra_tablenav($which); ?>
|
59 |
-
|
60 |
<div style="float:right;margin-left:8px;">
|
61 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_broken_link_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
62 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
@@ -68,10 +68,12 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
68 |
|
69 |
<?php
|
70 |
}
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
function extra_tablenav($which) {
|
73 |
-
|
74 |
-
#if ('top' == $which) {
|
75 |
echo '<div class="alignleft actions">';
|
76 |
global $wpdb;
|
77 |
|
@@ -95,10 +97,13 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
95 |
}
|
96 |
|
97 |
echo "</div>";
|
98 |
-
#echo "</form>";
|
99 |
-
#}
|
100 |
}
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
102 |
function get_columns() {
|
103 |
return $columns = array(
|
104 |
'col_link_url' => __('URL', 'wp-meta-seo'),
|
@@ -108,7 +113,16 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
108 |
'col_source' => __('Source', 'wp-meta-seo'),
|
109 |
);
|
110 |
}
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
function get_sortable_columns() {
|
113 |
return $sortable = array(
|
114 |
'col_status' => array('status_text', true),
|
@@ -189,7 +203,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
189 |
}
|
190 |
}
|
191 |
}
|
192 |
-
|
|
|
|
|
|
|
|
|
193 |
function prepare_items() {
|
194 |
global $wpdb, $_wp_column_headers;
|
195 |
$where = array('1=1');
|
@@ -204,7 +222,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
204 |
if (!empty($_REQUEST['sl_broken']) && $_REQUEST['sl_broken'] != 'all') {
|
205 |
if ($_REQUEST['sl_broken'] == 'valid_links') {
|
206 |
$where[] = "broken_internal = 0 AND broken_indexed = 0";
|
207 |
-
}elseif ($_REQUEST['sl_broken'] == 'internal_broken_links') {
|
208 |
$where[] = "broken_internal = 1";
|
209 |
} else {
|
210 |
$where[] = "broken_indexed = 1";
|
@@ -242,15 +260,18 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
242 |
}
|
243 |
|
244 |
if (!empty($orderby) & !empty($order)) {
|
245 |
-
$orderStr = ' ORDER BY '
|
|
|
246 |
}
|
247 |
|
248 |
-
$query = "SELECT
|
|
|
249 |
$columns = $this->get_columns();
|
250 |
$hidden = array();
|
251 |
$sortable = $this->get_sortable_columns();
|
252 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
253 |
-
|
|
|
254 |
if (!empty($_REQUEST['metaseo_broken_link_per_page'])) {
|
255 |
$_per_page = intval($_REQUEST['metaseo_broken_link_per_page']);
|
256 |
} else {
|
@@ -293,7 +314,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
293 |
|
294 |
$this->items = $wpdb->get_results($query);
|
295 |
}
|
296 |
-
|
|
|
|
|
|
|
297 |
function search_box1() {
|
298 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
299 |
return;
|
@@ -314,7 +338,8 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
314 |
</p>
|
315 |
<?php
|
316 |
}
|
317 |
-
|
|
|
318 |
function redirect_fillter($name) {
|
319 |
$redirects = array('not_yet_redirect' => __('Not yet redirected', 'wp-meta-seo'), 'already_redirect' => __('Already redirected', 'wp-meta-seo'));
|
320 |
$curent_redirect = isset($_REQUEST['sl_redirect']) ? $_REQUEST['sl_redirect'] : 'all';
|
@@ -335,9 +360,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
335 |
|
336 |
<?php
|
337 |
}
|
338 |
-
|
|
|
339 |
function broken_fillter($name) {
|
340 |
-
$brokens = array('valid_links' => __('Valid links', 'wp-meta-seo')
|
341 |
$curent_broken = isset($_REQUEST['sl_broken']) ? $_REQUEST['sl_broken'] : 'all';
|
342 |
?>
|
343 |
<label for="filter-by-broken" class="screen-reader-text"><?php _e('Filter by broken', 'wp-meta-seo'); ?></label>
|
@@ -357,6 +383,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
357 |
<?php
|
358 |
}
|
359 |
|
|
|
360 |
function type_fillter($name) {
|
361 |
$types = array('url' => 'URL', 'image' => 'Image', 'other' => 'Other');
|
362 |
$curent_type = isset($_REQUEST['sltype']) ? $_REQUEST['sltype'] : 'all';
|
@@ -380,11 +407,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
380 |
echo '<div style="float:left;padding-left: 5px;"><div class="wpmf_process" data-w="0"></div>';
|
381 |
echo '<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link">' . __('Index internal broken links', 'wp-meta-seo') . '</div></div>';
|
382 |
echo '<span class="spinner"></span>';
|
383 |
-
|
384 |
}
|
385 |
|
|
|
386 |
function flush_fillter($name) {
|
387 |
-
$flushs = array('automaticaly_indexed' => __('Automatic indexed 404', 'wp-meta-seo'), 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo')
|
388 |
?>
|
389 |
<label for="filter-by-flush" class="screen-reader-text"><?php _e('Filter by flush', 'wp-meta-seo'); ?></label>
|
390 |
<select name="<?php echo $name ?>" id="filter-by-flush">
|
@@ -397,17 +424,19 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
397 |
</select>
|
398 |
|
399 |
<?php
|
400 |
-
|
401 |
-
|
402 |
}
|
403 |
|
|
|
|
|
|
|
404 |
function display_rows() {
|
405 |
$url = URL;
|
406 |
$url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
|
407 |
$records = $this->items;
|
408 |
$i = 0;
|
409 |
$alternate = "";
|
410 |
-
|
411 |
list( $columns, $hidden ) = $this->get_column_info();
|
412 |
if (!empty($records)) {
|
413 |
foreach ($records as $rec) {
|
@@ -426,9 +455,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
426 |
|
427 |
switch ($column_name) {
|
428 |
case 'col_link_url':
|
429 |
-
if($rec->type == 'url'){
|
430 |
$value_url = $rec->link_final_url;
|
431 |
-
}else{
|
432 |
$value_url = $rec->link_url;
|
433 |
}
|
434 |
echo '<td class="wpms_link_html" colspan="3">';
|
@@ -440,33 +469,31 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
440 |
'recheck' => '<a class="wpms_action_link wpms-recheck-button" data-link_id="' . $rec->id . '" data-type="' . $rec->type . '" data-source_id="' . $rec->source_id . '" title="' . __('Recheck this link', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">loop</i></div><span>' . __('Recheck', 'wp-meta-seo') . '</span></a>'
|
441 |
);
|
442 |
echo $this->row_actions($row_action, false);
|
443 |
-
if(!empty($rec->source_id)){
|
444 |
-
if($rec->type == 'url'){
|
445 |
$iii = 0;
|
446 |
$pos = get_post($rec->source_id);
|
447 |
-
if(!empty($pos)){
|
448 |
preg_match_all("#<a[^>]*>.*?</a>#si", $pos->post_content, $matches, PREG_PATTERN_ORDER);
|
449 |
foreach ($matches[0] as $i => $content) {
|
450 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
451 |
$href = $matches[1];
|
452 |
-
if($href == $rec->link_url){
|
453 |
$iii++;
|
454 |
}
|
455 |
-
|
456 |
}
|
457 |
}
|
458 |
-
}elseif($rec->type == 'comment_content_url'){
|
459 |
$jjj = 0;
|
460 |
$com = get_comment($rec->source_id);
|
461 |
-
if(!empty($pos)){
|
462 |
preg_match_all("#<a[^>]*>.*?</a>#si", $com->comment_content, $matches, PREG_PATTERN_ORDER);
|
463 |
foreach ($matches[0] as $i => $content) {
|
464 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
465 |
$href = $matches[1];
|
466 |
-
if($href == $rec->link_url){
|
467 |
$jjj++;
|
468 |
}
|
469 |
-
|
470 |
}
|
471 |
}
|
472 |
}
|
@@ -474,24 +501,24 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
474 |
?>
|
475 |
<div class="wpms-inline-editor-content">
|
476 |
<h4><?php echo _x('Edit Link', 'inline editor title', 'wp-meta-seo'); ?></h4>
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
<span class="wpms-input-text-wrap"><span class="title"><?php _e('URL', 'wp-meta-seo'); ?></span><input <?php echo ($rec->type == '404_automaticaly') ? 'readonly' : '' ?> type="text" name="link_url" class="wpms-link-url-field" value="<?php echo esc_attr($value_url); ?>" /></span>
|
496 |
<span class="wpms-input-text-wrap"><span class="title"><?php _e('Redirect', 'wp-meta-seo'); ?></span><input type="text" name="link_url_redirect" class="wpms-link-redirect-field" value="<?php echo esc_attr($rec->link_url_redirect); ?>" /></span>
|
497 |
</label>
|
@@ -504,7 +531,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
504 |
<?php
|
505 |
echo '</td>';
|
506 |
break;
|
507 |
-
|
508 |
case 'col_hit':
|
509 |
echo '<td colspan="3" style="text-align:center;">';
|
510 |
echo $rec->hit;
|
@@ -512,24 +539,24 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
512 |
break;
|
513 |
case 'col_status':
|
514 |
echo '<td colspan="3" class="col_status">';
|
515 |
-
|
516 |
-
if(strpos($rec->status_text, '200') !== false){
|
517 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>';
|
518 |
-
}elseif(strpos($rec->status_text, '301') !== false){
|
519 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
|
520 |
-
}elseif(strpos($rec->status_text, '302') !== false){
|
521 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>';
|
522 |
-
}elseif(strpos($rec->status_text, '404') !== false || $rec->status_text == 'Server Not Found'){
|
523 |
$wpms_settings_404 = get_option('wpms_settings_404');
|
524 |
-
if((isset($wpms_settings_404['wpms_redirect_homepage']) && $wpms_settings_404['wpms_redirect_homepage'] == 1) || $rec->link_url_redirect != ''){
|
525 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
|
526 |
-
}else{
|
527 |
echo '<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>';
|
528 |
}
|
529 |
-
}else{
|
530 |
echo $rec->status_text;
|
531 |
}
|
532 |
-
|
533 |
echo '</td>';
|
534 |
break;
|
535 |
|
@@ -542,7 +569,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
542 |
if (strip_tags($rec->link_text) != '') {
|
543 |
echo '<td colspan="3" class="link_text">' . strip_tags($rec->link_text) . '</td>';
|
544 |
} else {
|
545 |
-
echo '<td colspan="3" class="link_text"><i>'.__('No text on this link','wp-meta-seo').'</i></td>';
|
546 |
}
|
547 |
}
|
548 |
|
@@ -556,38 +583,38 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
556 |
} else {
|
557 |
if ($rec->type == 'comment' || $rec->type == 'comment_content_url' || $rec->type == 'comment_content_image') {
|
558 |
$source = get_comment($rec->source_id);
|
559 |
-
if(!empty($source)){
|
560 |
$row_action = array(
|
561 |
'edit' => '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '" title="Edit this item">Edit</a>',
|
562 |
'view' => '<a target="_blank" href="' . get_comment_link($rec->source_id) . '" title="View “test”" rel="permalink">View</a>'
|
563 |
);
|
564 |
-
|
565 |
-
if($rec->type == 'comment'){
|
566 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Comments">person_outline</i></span>';
|
567 |
-
}else{
|
568 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Comments content">chat_bubble</i></span>';
|
569 |
}
|
570 |
$source_inner .= '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '">' . $source->comment_author . '</a>';
|
571 |
}
|
572 |
} else {
|
573 |
$source = get_post($rec->source_id);
|
574 |
-
if(!empty($source)){
|
575 |
$row_action = array(
|
576 |
'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="Edit this item">Edit</a>',
|
577 |
'view' => '<a target="_blank" href="' . get_post_permalink($rec->source_id) . '" title="View “test”" rel="permalink">View</a>'
|
578 |
);
|
579 |
-
|
580 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Post , Page , Custom post">layers</i></span>';
|
581 |
$source_inner .= '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '">' . $source->post_title . '</a>';
|
582 |
}
|
583 |
}
|
584 |
|
585 |
echo '<td colspan="3">';
|
586 |
-
if(!empty($source)){
|
587 |
echo $source_inner;
|
588 |
echo $this->row_actions($row_action, false);
|
589 |
-
}else{
|
590 |
-
echo '<a>'.__('Source Not Found','wp-meta-seo').'</a>';
|
591 |
}
|
592 |
echo '</td>';
|
593 |
break;
|
@@ -599,7 +626,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
599 |
}
|
600 |
}
|
601 |
}
|
602 |
-
|
|
|
|
|
|
|
603 |
public function process_action() {
|
604 |
global $wpdb;
|
605 |
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
@@ -631,7 +661,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
631 |
exit();
|
632 |
}
|
633 |
}
|
634 |
-
|
|
|
|
|
|
|
635 |
public static function wpms_get_links() {
|
636 |
global $wpdb, $_wp_column_headers;
|
637 |
|
@@ -646,7 +679,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
646 |
if (!empty($post_type) && !in_array($post_type, $post_types))
|
647 |
$post_type = '\'post\'';
|
648 |
else if (empty($post_type)) {
|
649 |
-
$post_type = "'" . implode("', '", $post_types) . "'";
|
650 |
} else {
|
651 |
$post_type = "'" . $post_type . "'";
|
652 |
}
|
@@ -654,7 +687,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
654 |
$where[] = "post_type IN ($post_type)";
|
655 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
656 |
$states['trash'] = 'trash';
|
657 |
-
$all_states = "'" . implode("', '", $states) . "'";
|
658 |
|
659 |
if (empty($_REQUEST['post_status'])) {
|
660 |
$where[] = "post_status IN ($all_states)";
|
@@ -674,23 +707,20 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
674 |
$results = $wpdb->get_results($query);
|
675 |
$list_link = array();
|
676 |
|
|
|
677 |
$comments = get_comments();
|
678 |
foreach ($comments as $comment) {
|
679 |
if (!empty($comment->comment_author_url)) {
|
680 |
-
|
681 |
-
$row_action = array(
|
682 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
683 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
684 |
-
);
|
685 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
686 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
|
687 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
688 |
-
$list_link[$comment->comment_author_url . $comment->comment_ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
689 |
}
|
690 |
}
|
691 |
|
|
|
692 |
foreach ($results as $post) {
|
693 |
-
if($post->post_excerpt != 'metaseo_404_page'){
|
694 |
$dom = new DOMDocument;
|
695 |
libxml_use_internal_errors(true);
|
696 |
if (isset($post->post_content) && $post->post_content != '') {
|
@@ -701,27 +731,18 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
701 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
702 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
703 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
704 |
-
$row_action = array(
|
705 |
-
'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
|
706 |
-
'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View “test”" rel="permalink">View</a>'
|
707 |
-
);
|
708 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
709 |
-
$list_link[$href.'url'
|
710 |
}
|
711 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
712 |
foreach (array_unique($matches[0]) as $content) {
|
713 |
-
|
714 |
-
$row_action = array(
|
715 |
-
'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
|
716 |
-
'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View “test”" rel="permalink">View</a>'
|
717 |
-
);
|
718 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
719 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
720 |
$src = $matches[1];
|
721 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
722 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
723 |
$link_text = '';
|
724 |
-
$list_link[$src.'img'
|
725 |
}
|
726 |
}
|
727 |
}
|
@@ -730,69 +751,78 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
730 |
return $list_link;
|
731 |
}
|
732 |
|
733 |
-
|
|
|
|
|
|
|
734 |
$res = array(
|
735 |
'source_link' => $source_link,
|
736 |
-
'row_action' => $row_action,
|
737 |
'source_id' => (int) $source_id,
|
738 |
'link_url' => $url,
|
739 |
'link_text' => $link_text,
|
740 |
'type' => $type,
|
741 |
'status' => $status,
|
742 |
'status_type' => $status_type);
|
743 |
-
|
744 |
-
if(isset($meta_title)){
|
745 |
$res['meta_title'] = $meta_title;
|
746 |
-
}else{
|
747 |
$res['meta_title'] = '';
|
748 |
}
|
749 |
-
|
750 |
-
if(isset($rel) && $rel == 'nofollow'){
|
751 |
$res['follow'] = 0;
|
752 |
-
}else{
|
753 |
$res['follow'] = 1;
|
754 |
}
|
755 |
-
|
756 |
-
if(strpos($url, 'mailto:') !== false){
|
757 |
$res['link_final_url'] = $url;
|
758 |
-
}else{
|
759 |
-
if($type == 'url'){
|
760 |
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
|
761 |
$perlink = get_option('permalink_structure');
|
762 |
-
if(empty($perlink)){
|
763 |
-
$res['link_final_url'] = get_site_url().'/'
|
764 |
-
}else{
|
765 |
-
if(!empty($postID)){
|
766 |
-
$res['link_final_url'] = get_permalink($postID)
|
767 |
-
}else{
|
768 |
-
$res['link_final_url'] = $perlink.'/'
|
769 |
}
|
770 |
}
|
771 |
-
}else{
|
772 |
$res['link_final_url'] = $url;
|
773 |
}
|
774 |
-
}else{
|
775 |
$res['link_final_url'] = $url;
|
776 |
}
|
777 |
}
|
778 |
-
|
779 |
-
|
780 |
return $res;
|
781 |
}
|
782 |
|
|
|
|
|
|
|
783 |
public static function get_urlstatus($url) {
|
784 |
$status = @get_headers($url, 0);
|
785 |
-
if(strpos($url,'mailto:') !== false)
|
|
|
786 |
if (isset($status[0])) {
|
787 |
return $status[0];
|
788 |
} else {
|
789 |
return 'Server Not Found';
|
790 |
}
|
791 |
-
|
792 |
}
|
793 |
-
|
|
|
|
|
|
|
794 |
public static function get_urlstatus_type($status) {
|
795 |
-
if(isset($status) && $status == 'Not checked')
|
|
|
796 |
if (isset($status) && $status != 'Server Not Found') {
|
797 |
if (((int) substr($status, 9, 3) >= 200 && (int) substr($status, 9, 3) <= 204) || (int) substr($status, 9, 3) == 401) {
|
798 |
$type = 'ok';
|
@@ -812,7 +842,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
812 |
}
|
813 |
return $type;
|
814 |
}
|
815 |
-
|
|
|
|
|
|
|
816 |
public static function wpms_deleted_comment($comment_ID) {
|
817 |
|
818 |
global $wpdb;
|
@@ -820,11 +853,14 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
820 |
$wpdb->prepare(
|
821 |
"DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d
|
822 |
AND (type = %s || type = %s || type = %s)
|
823 |
-
", $comment_ID, 'comment','comment_content_url','comment_content_image'
|
824 |
)
|
825 |
);
|
826 |
}
|
827 |
-
|
|
|
|
|
|
|
828 |
public static function wpms_delete_post($post_id) {
|
829 |
global $wpdb;
|
830 |
$wpdb->query(
|
@@ -835,12 +871,15 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
835 |
)
|
836 |
);
|
837 |
}
|
838 |
-
|
|
|
|
|
|
|
839 |
public static function wpms_update_comment($comment_ID) {
|
840 |
global $wpdb;
|
841 |
$comment = get_comment($comment_ID);
|
842 |
-
$status = wp_get_comment_status(
|
843 |
-
if($status == 'approved'){
|
844 |
if (!empty($comment->comment_author_url)) {
|
845 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus(($comment->comment_author_url));
|
846 |
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
|
@@ -886,13 +925,13 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
886 |
$wpdb->prefix . 'wpms_links', $value, array('source_id' => $comment_ID, 'type' => 'comment'), array('%s', '%s', '%s', '%d', '%d', '%d', '%d'), array('%d', '%s')
|
887 |
);
|
888 |
}
|
889 |
-
}else{
|
890 |
-
$wpdb->query(
|
891 |
-
$wpdb->prepare("DELETE FROM "
|
892 |
);
|
893 |
}
|
894 |
-
|
895 |
-
|
896 |
if (isset($comment->comment_content) && $comment->comment_content != '') {
|
897 |
preg_match_all("#<a[^>]*>.*?</a>#si", $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
898 |
foreach (array_unique($matches[0]) as $i => $content) {
|
@@ -901,12 +940,8 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
901 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
902 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
903 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
904 |
-
$row_action = array(
|
905 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
906 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
907 |
-
);
|
908 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
909 |
-
$links_in_content[$href.'comment_content_url'
|
910 |
}
|
911 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
912 |
foreach (array_unique($matches[0]) as $content) {
|
@@ -915,49 +950,46 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
915 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
916 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
917 |
$link_text = '';
|
918 |
-
$row_action = array(
|
919 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
920 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
921 |
-
);
|
922 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
923 |
-
$links_in_content[$src.'comment_content_image'
|
924 |
}
|
925 |
}
|
926 |
|
927 |
global $wpdb;
|
928 |
-
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND (type = %s || type = %s)", array($comment->comment_ID, "comment_content_url"
|
929 |
$links = $wpdb->get_results($sql);
|
930 |
foreach ($links as $link) {
|
931 |
-
if (empty($links_in_content[$link->link_url
|
932 |
$wpdb->delete($wpdb->prefix . "wpms_links", array('id' => $link->id), array('%d'));
|
933 |
} else {
|
934 |
-
unset($links_in_content[$link->link_url
|
935 |
}
|
936 |
}
|
937 |
|
938 |
if (!empty($links_in_content)) {
|
939 |
-
foreach ($links_in_content as $link){
|
940 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link, $wpdb);
|
941 |
}
|
942 |
}
|
943 |
-
|
944 |
-
|
945 |
-
}else{
|
946 |
global $wpdb;
|
947 |
-
$wpdb->query(
|
948 |
-
$wpdb->prepare("DELETE FROM "
|
949 |
);
|
950 |
}
|
951 |
}
|
952 |
-
|
|
|
|
|
|
|
953 |
public static function wpms_update_post($post_ID, $post_after, $post_before) {
|
954 |
$post = $post_after;
|
955 |
$dom = new DOMDocument;
|
956 |
libxml_use_internal_errors(true);
|
957 |
$links_in_content = array();
|
958 |
-
|
959 |
-
if($post->post_excerpt != 'metaseo_404_page'){
|
960 |
-
if($post->post_status == 'publish'){
|
961 |
if (isset($post->post_content) && $post->post_content != '') {
|
962 |
|
963 |
preg_match_all("#<a[^>]*>.*?</a>#si", $post->post_content, $matches, PREG_PATTERN_ORDER);
|
@@ -966,14 +998,14 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
966 |
$tags = $dom->getElementsByTagName('a');
|
967 |
$meta_title = $tags->item(0)->getAttribute('title');
|
968 |
$rel = $tags->item(0)->getAttribute('rel');
|
969 |
-
|
970 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
971 |
$href = $matches[1];
|
972 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
973 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
974 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
975 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
976 |
-
$links_in_content[$href.'url'
|
977 |
}
|
978 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
979 |
foreach (array_unique($matches[0]) as $content) {
|
@@ -983,7 +1015,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
983 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
984 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
985 |
$link_text = '';
|
986 |
-
$links_in_content[$src.'img'
|
987 |
}
|
988 |
}
|
989 |
|
@@ -991,29 +1023,32 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
991 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND type != %s", array($post->ID, "comment"));
|
992 |
$links = $wpdb->get_results($sql);
|
993 |
foreach ($links as $link) {
|
994 |
-
if (empty($links_in_content[$link->link_url
|
995 |
$wpdb->delete($wpdb->prefix . "wpms_links", array('id' => $link->id), array('%d'));
|
996 |
} else {
|
997 |
-
unset($links_in_content[$link->link_url
|
998 |
}
|
999 |
}
|
1000 |
|
1001 |
if (!empty($links_in_content)) {
|
1002 |
-
foreach ($links_in_content as $link){
|
1003 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link, $wpdb);
|
1004 |
}
|
1005 |
}
|
1006 |
-
}else{
|
1007 |
global $wpdb;
|
1008 |
-
$wpdb->query(
|
1009 |
-
$wpdb->prepare("DELETE FROM "
|
1010 |
);
|
1011 |
}
|
1012 |
}
|
1013 |
}
|
|
|
|
|
|
|
|
|
|
|
1014 |
|
1015 |
-
public static function wpms_scan_link() {
|
1016 |
-
|
1017 |
global $wpdb, $_wp_column_headers;
|
1018 |
$limit_comment_content = 1;
|
1019 |
$limit_comment = 10;
|
@@ -1042,39 +1077,40 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1042 |
$total_posts = $wpdb->get_var("SELECT COUNT(*)"
|
1043 |
. " FROM $wpdb->posts "
|
1044 |
. " WHERE " . implode(' AND ', $where));
|
1045 |
-
|
1046 |
-
$total_link = (int)$total_comments + (int) $total_posts;
|
1047 |
$percent_comment_content = 33.33;
|
1048 |
$percent_comment = 33.33;
|
1049 |
$percent_post = 33.33;
|
1050 |
-
|
1051 |
-
if(!empty($total_comments))
|
1052 |
-
|
1053 |
-
if(
|
1054 |
-
|
1055 |
-
if(!empty($
|
1056 |
-
|
1057 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1058 |
// scan link in comment url
|
1059 |
$comments = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "comments WHERE comment_approved = 1 AND comment_author_url != '' AND comment_author_url NOT IN (SELECT link_url FROM " . $wpdb->prefix . "wpms_links WHERE type='comment') LIMIT $limit_comment");
|
1060 |
if (!empty($comments)) {
|
1061 |
foreach ($comments as $comment) {
|
1062 |
if (!empty($comment->comment_author_url)) {
|
1063 |
-
|
1064 |
-
$row_action = array(
|
1065 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
1066 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
1067 |
-
);
|
1068 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1069 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
|
1070 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1071 |
-
$coms = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
1072 |
MetaSeo_Broken_Link_Table::wpms_insert_link($coms, $wpdb);
|
1073 |
}
|
1074 |
}
|
1075 |
-
wp_send_json(array('status' => false, 'type' => 'limit'
|
1076 |
}
|
1077 |
-
|
1078 |
// scan link in comment content
|
1079 |
$k = 0;
|
1080 |
$off_set = ($_POST['comment_paged'] - 1) * $limit_comment_content;
|
@@ -1092,39 +1128,30 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1092 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
1093 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1094 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
1095 |
-
$row_action = array(
|
1096 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
1097 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
1098 |
-
);
|
1099 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1100 |
-
$link_a = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
1101 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_a, $wpdb);
|
1102 |
}
|
1103 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
1104 |
foreach (array_unique($matches[0]) as $content) {
|
1105 |
-
|
1106 |
-
$row_action = array(
|
1107 |
-
'edit' => '<a href="' . get_edit_comment_link($comment->comment_ID) . '" title="Edit this item">Edit</a>',
|
1108 |
-
'view' => '<a href="' . get_comment_link($comment->comment_ID) . '" title="View “test”" rel="permalink">View</a>'
|
1109 |
-
);
|
1110 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1111 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
1112 |
$src = $matches[1];
|
1113 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
1114 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1115 |
$link_text = '';
|
1116 |
-
$link_sou = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
1117 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_sou, $wpdb);
|
1118 |
}
|
1119 |
}
|
1120 |
}
|
1121 |
-
|
1122 |
$k++;
|
1123 |
if ($k >= $limit_comment_content) {
|
1124 |
-
wp_send_json(array('status' => false, 'type' => 'limit_comment_content', 'paged' => $_POST['comment_paged']
|
1125 |
}
|
1126 |
}
|
1127 |
-
|
1128 |
// scan link in post
|
1129 |
$j = 0;
|
1130 |
$off_set = ($_POST['paged'] - 1) * $limit_post;
|
@@ -1152,147 +1179,149 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1152 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
1153 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1154 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
1155 |
-
$row_action = array(
|
1156 |
-
'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
|
1157 |
-
'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View “test”" rel="permalink">View</a>'
|
1158 |
-
);
|
1159 |
-
|
1160 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
1161 |
-
$link_a = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
1162 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_a, $wpdb);
|
1163 |
}
|
1164 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
1165 |
foreach (array_unique($matches[0]) as $content) {
|
1166 |
-
|
1167 |
-
$row_action = array(
|
1168 |
-
'edit' => '<a href="' . get_edit_post_link($post->ID) . '" title="Edit this item">Edit</a>',
|
1169 |
-
'view' => '<a href="' . get_post_permalink($post->ID) . '" title="View “test”" rel="permalink">View</a>'
|
1170 |
-
);
|
1171 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
1172 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
1173 |
$src = $matches[1];
|
1174 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
1175 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1176 |
$link_text = '';
|
1177 |
-
$link_sou = MetaSeo_Broken_Link_Table::get_result_link($source_link, $
|
1178 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_sou, $wpdb);
|
1179 |
}
|
1180 |
}
|
1181 |
}
|
1182 |
$j++;
|
1183 |
if ($j >= $limit_post) {
|
1184 |
-
wp_send_json(array('status' => false, 'type' => 'limit_post', 'paged' => $_POST['paged']
|
1185 |
}
|
1186 |
}
|
1187 |
wp_send_json(array('status' => true));
|
1188 |
}
|
1189 |
-
|
|
|
|
|
|
|
1190 |
public static function wpms_insert_link($link, $wpdb) {
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1225 |
);
|
1226 |
-
$site_url = get_site_url();
|
1227 |
-
$value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($links[0]->link_url,$site_url,$value);
|
1228 |
-
|
1229 |
-
if($links[0]->follow != $link['follow'] || $links[0]->meta_title != $link['meta_title'] || $links[0]->internal != $value['internal']){
|
1230 |
-
$wpdb->update(
|
1231 |
-
$wpdb->prefix . 'wpms_links', $value, array('id' => $links[0]->id)
|
1232 |
-
);
|
1233 |
-
}
|
1234 |
}
|
|
|
1235 |
}
|
1236 |
|
1237 |
-
|
|
|
|
|
|
|
1238 |
$info_link = parse_url($link);
|
1239 |
$info_site_url = parse_url($siteUrl);
|
1240 |
-
$domain_link = $info_link['host']
|
1241 |
-
$domain_site = $info_site_url['host']
|
1242 |
-
if(strpos($domain_link, $domain_site) !== false){
|
1243 |
$value['internal'] = 1;
|
1244 |
-
}else{
|
1245 |
$value['internal'] = 0;
|
1246 |
}
|
1247 |
-
|
1248 |
return $value;
|
1249 |
}
|
1250 |
|
|
|
|
|
|
|
1251 |
public static function wpms_flush_link() {
|
1252 |
global $wpdb;
|
1253 |
-
if(isset($_POST['type']) && $_POST['type'] != 'none'){
|
1254 |
-
switch ($_POST['type']){
|
1255 |
case 'automaticaly_indexed':
|
1256 |
-
$wpdb->query(
|
1257 |
-
$wpdb->prepare(
|
1258 |
"
|
1259 |
-
DELETE FROM "
|
1260 |
WHERE broken_indexed = %d AND link_url_redirect = %s
|
1261 |
-
"
|
1262 |
)
|
1263 |
);
|
1264 |
break;
|
1265 |
case 'internal_broken_links':
|
1266 |
-
$wpdb->query(
|
1267 |
-
$wpdb->prepare(
|
1268 |
"
|
1269 |
-
DELETE FROM "
|
1270 |
WHERE broken_internal = %d AND link_url_redirect = %s
|
1271 |
-
"
|
1272 |
)
|
1273 |
);
|
1274 |
break;
|
1275 |
case 'all':
|
1276 |
-
$wpdb->query(
|
1277 |
-
$wpdb->prepare(
|
1278 |
"
|
1279 |
-
DELETE FROM "
|
1280 |
WHERE (broken_internal = %d
|
1281 |
OR broken_indexed = %d) AND link_url_redirect = %s
|
1282 |
-
"
|
1283 |
)
|
1284 |
);
|
1285 |
-
|
1286 |
break;
|
1287 |
}
|
1288 |
wp_send_json(true);
|
1289 |
-
|
1290 |
}
|
1291 |
wp_send_json(false);
|
1292 |
}
|
1293 |
|
|
|
|
|
|
|
1294 |
public static function wpms_get_status_text($status) {
|
1295 |
-
if($status == 'Not checked')
|
|
|
1296 |
if ($status == 'Server Not Found') {
|
1297 |
$status_text = 'Server Not Found';
|
1298 |
} else {
|
@@ -1301,8 +1330,11 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1301 |
return $status_text;
|
1302 |
}
|
1303 |
|
|
|
|
|
|
|
1304 |
public static function wpms_update_link() {
|
1305 |
-
|
1306 |
if (isset($_POST['link_id'])) {
|
1307 |
global $wpdb;
|
1308 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
|
@@ -1325,25 +1357,25 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1325 |
'warning' => 0,
|
1326 |
'dismissed' => 0,
|
1327 |
);
|
1328 |
-
if(strpos($_POST['new_link'], 'mailto:') !== false){
|
1329 |
$value['link_final_url'] = $_POST['new_link'];
|
1330 |
-
}else{
|
1331 |
if (!preg_match("~^(?:f|ht)tps?://~i", $_POST['new_link'])) {
|
1332 |
$perlink = get_option('permalink_structure');
|
1333 |
-
if(empty($perlink)){
|
1334 |
-
$value['link_final_url'] = get_site_url().'/'
|
1335 |
-
}else{
|
1336 |
-
if(!empty($link_detail->source_id)){
|
1337 |
-
$value['link_final_url'] = get_permalink($link_detail->source_id)
|
1338 |
-
}else{
|
1339 |
-
$value['link_final_url'] = $perlink.'/'
|
1340 |
}
|
1341 |
}
|
1342 |
-
}else{
|
1343 |
$value['link_final_url'] = $_POST['new_link'];
|
1344 |
}
|
1345 |
}
|
1346 |
-
|
1347 |
if (!empty($_POST['link_redirect']))
|
1348 |
$value['link_url_redirect'] = ($_POST['link_redirect']);
|
1349 |
if (isset($status_type) && $status_type != 'ok') {
|
@@ -1360,9 +1392,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1360 |
'broken_indexed' => 1
|
1361 |
);
|
1362 |
}
|
1363 |
-
|
1364 |
$site_url = get_site_url();
|
1365 |
-
$value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($_POST['new_link']
|
1366 |
|
1367 |
$wpdb->update(
|
1368 |
$wpdb->prefix . 'wpms_links', $value, array('id' => $_POST['link_id'])
|
@@ -1374,7 +1406,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1374 |
break;
|
1375 |
case 'comment_content_image':
|
1376 |
$comment = get_comment($link_detail->source_id);
|
1377 |
-
if(!empty($comment)){
|
1378 |
$old_value = $comment->comment_content;
|
1379 |
$edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
|
1380 |
$my_comment = array(
|
@@ -1383,12 +1415,12 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1383 |
);
|
1384 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1385 |
wp_update_comment($my_comment);
|
1386 |
-
wp_send_json(array('status' => true, 'type' => 'image', 'status_text' => $status_text, 'new_link' => esc_url($edit_result['raw_url'])
|
1387 |
}
|
1388 |
break;
|
1389 |
case 'image':
|
1390 |
$post = get_post($link_detail->source_id);
|
1391 |
-
if(!empty($post)){
|
1392 |
$old_value = $post->post_content;
|
1393 |
$edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
|
1394 |
$my_post = array(
|
@@ -1397,18 +1429,18 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1397 |
);
|
1398 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1399 |
wp_update_post($my_post);
|
1400 |
-
wp_send_json(array('status' => true, 'type' => 'image', 'status_text' => $status_text, 'new_link' => esc_url($edit_result['raw_url'])
|
1401 |
}
|
1402 |
break;
|
1403 |
-
|
1404 |
case 'comment_content_url':
|
1405 |
$comment = get_comment($link_detail->source_id);
|
1406 |
-
if(!empty($comment)){
|
1407 |
$old_value = $comment->comment_content;
|
1408 |
-
if(isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == ''){
|
1409 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
|
1410 |
$new_text = '';
|
1411 |
-
}else{
|
1412 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
|
1413 |
$new_text = strip_tags($edit_result['link_text']);
|
1414 |
}
|
@@ -1419,19 +1451,19 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1419 |
);
|
1420 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1421 |
wp_update_comment($my_comment);
|
1422 |
-
wp_send_json(array('status' => true, 'type' => 'url', 'status_text' => $status_text, 'new_link' => $edit_result['raw_url'], 'new_text' => $new_text
|
1423 |
}
|
1424 |
-
|
1425 |
break;
|
1426 |
-
|
1427 |
case 'url':
|
1428 |
$post = get_post($link_detail->source_id);
|
1429 |
-
if(!empty($post)){
|
1430 |
$old_value = $post->post_content;
|
1431 |
-
if(isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == ''){
|
1432 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
|
1433 |
$new_text = '';
|
1434 |
-
}else{
|
1435 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
|
1436 |
$new_text = strip_tags($edit_result['link_text']);
|
1437 |
}
|
@@ -1442,9 +1474,9 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1442 |
);
|
1443 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1444 |
wp_update_post($my_post);
|
1445 |
-
wp_send_json(array('status' => true, 'type' => 'url', 'status_text' => $status_text, 'new_link' => $edit_result['raw_url'], 'new_text' => $new_text
|
1446 |
}
|
1447 |
-
|
1448 |
break;
|
1449 |
case 'comment':
|
1450 |
wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => $_POST['new_link']));
|
@@ -1454,7 +1486,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1454 |
}
|
1455 |
wp_send_json(false);
|
1456 |
}
|
1457 |
-
|
|
|
|
|
|
|
1458 |
public static function wpms_unlink() {
|
1459 |
if (isset($_POST['link_id'])) {
|
1460 |
global $wpdb;
|
@@ -1467,10 +1502,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1467 |
case '404_automaticaly':
|
1468 |
wp_send_json(true);
|
1469 |
break;
|
1470 |
-
|
1471 |
case 'comment_content_image':
|
1472 |
$comment = get_comment($link_detail->source_id);
|
1473 |
-
if(!empty($comment)){
|
1474 |
$old_value = $comment->comment_content;
|
1475 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_img($old_value, $link_detail->link_url);
|
1476 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
@@ -1482,10 +1517,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1482 |
}
|
1483 |
wp_send_json(true);
|
1484 |
break;
|
1485 |
-
|
1486 |
case 'image':
|
1487 |
$post = get_post($link_detail->source_id);
|
1488 |
-
if(!empty($post)){
|
1489 |
$old_value = $post->post_content;
|
1490 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_img($old_value, $link_detail->link_url);
|
1491 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
@@ -1497,10 +1532,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1497 |
}
|
1498 |
wp_send_json(true);
|
1499 |
break;
|
1500 |
-
|
1501 |
case 'comment_content_url':
|
1502 |
$comment = get_comment($link_detail->source_id);
|
1503 |
-
if(!empty($comment)){
|
1504 |
$old_value = $comment->comment_content;
|
1505 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_html($old_value, $link_detail->link_url);
|
1506 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
@@ -1512,10 +1547,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1512 |
}
|
1513 |
wp_send_json(true);
|
1514 |
break;
|
1515 |
-
|
1516 |
case 'url':
|
1517 |
$post = get_post($link_detail->source_id);
|
1518 |
-
if(!empty($post)){
|
1519 |
$old_value = $post->post_content;
|
1520 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_html($old_value, $link_detail->link_url);
|
1521 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
@@ -1536,17 +1571,28 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1536 |
wp_send_json(false);
|
1537 |
}
|
1538 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1539 |
public static function edit_linkimg($content, $new_url, $old_url) {
|
1540 |
self::$old_url = $old_url;
|
1541 |
self::$new_url = htmlentities($new_url);
|
1542 |
$content = preg_replace_callback(self::$img_pattern, array('MetaSeo_Broken_Link_Table', 'editimg_callback'), $content);
|
1543 |
-
|
1544 |
return array(
|
1545 |
'content' => $content,
|
1546 |
'raw_url' => self::$new_url,
|
1547 |
);
|
1548 |
}
|
1549 |
-
|
1550 |
public static function editimg_callback($matches) {
|
1551 |
$url = $matches[3];
|
1552 |
if (($url) == self::$old_url) {
|
@@ -1556,39 +1602,64 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1556 |
}
|
1557 |
}
|
1558 |
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1563 |
}
|
1564 |
|
1565 |
-
public static function wpms_unlink_img_callback($matches){
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
}
|
1573 |
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1578 |
|
1579 |
-
|
1580 |
|
1581 |
-
|
1582 |
}
|
|
|
|
|
|
|
|
|
|
|
1583 |
|
1584 |
-
|
1585 |
-
if ($link['href'] != $params['old_url']){
|
1586 |
-
return $link['#raw'];
|
1587 |
-
}
|
1588 |
-
|
1589 |
-
return $link['#link_text'];
|
1590 |
}
|
1591 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1592 |
public static function wpms_edit_linkhtml($content, $new_url, $old_url, $new_text = null) {
|
1593 |
//Save the old & new URLs for use in the edit callback.
|
1594 |
$args = array(
|
@@ -1609,7 +1680,7 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1609 |
}
|
1610 |
return $result;
|
1611 |
}
|
1612 |
-
|
1613 |
public static function wpms_edithtml_callback($link, $params) {
|
1614 |
if ($link['href'] == $params['old_url']) {
|
1615 |
$modified = array(
|
@@ -1618,14 +1689,14 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1618 |
if (isset($params['new_text'])) {
|
1619 |
$modified['#link_text'] = $params['new_text'];
|
1620 |
}
|
1621 |
-
|
1622 |
if (isset($params['meta_title'])) {
|
1623 |
$modified['title'] = $params['meta_title'];
|
1624 |
}
|
1625 |
-
|
1626 |
if (isset($params['follow']) && $params['follow'] == 0) {
|
1627 |
$modified['rel'] = 'nofollow';
|
1628 |
-
}else{
|
1629 |
$modified['rel'] = '';
|
1630 |
}
|
1631 |
return $modified;
|
@@ -1633,7 +1704,20 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1633 |
return $link['#raw'];
|
1634 |
}
|
1635 |
}
|
1636 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1637 |
public static function wpms_edit_callback($link, $info) {
|
1638 |
list($callback, $extra) = $info;
|
1639 |
|
@@ -1653,7 +1737,19 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1653 |
|
1654 |
return $link;
|
1655 |
}
|
1656 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1657 |
public static function wpms_multi_edit($content, $callback, $extra = null) {
|
1658 |
//Just reuse map() + a little helper func. to apply the callback to all links and get modified links
|
1659 |
$modified_links = MetaSeo_Broken_Link_Table::map($content, array('MetaSeo_Broken_Link_Table', 'wpms_edit_callback'), array($callback, $extra));
|
@@ -1683,7 +1779,32 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1683 |
|
1684 |
return $content;
|
1685 |
}
|
1686 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1687 |
public static function extract_tags($html, $tag, $selfclosing = null, $return_the_entire_tag = false, $charset = 'ISO-8859-1') {
|
1688 |
|
1689 |
if (is_array($tag)) {
|
@@ -1768,7 +1889,23 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1768 |
|
1769 |
return $tags;
|
1770 |
}
|
1771 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1772 |
public static function map($content, $callback, $extra = null) {
|
1773 |
$results = array();
|
1774 |
|
@@ -1801,7 +1938,10 @@ class MetaSeo_Broken_Link_Table extends WP_List_Table {
|
|
1801 |
|
1802 |
return $results;
|
1803 |
}
|
1804 |
-
|
|
|
|
|
|
|
1805 |
public static function wpms_recheck_link() {
|
1806 |
if (isset($_POST['link_id'])) {
|
1807 |
global $wpdb;
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Base class for displaying a list of links in an ajaxified HTML table.
|
|
|
4 |
*
|
5 |
*/
|
|
|
6 |
if (!class_exists('WP_List_Table')) {
|
7 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
8 |
}
|
21 |
'ajax' => true
|
22 |
));
|
23 |
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Generate the table navigation above or below the table
|
27 |
+
* @param string $which
|
28 |
+
*/
|
29 |
function display_tablenav($which) {
|
30 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
31 |
if (!empty($post_types['attachment']))
|
36 |
|
37 |
<?php if ($which == 'top'): ?>
|
38 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
39 |
+
|
40 |
<div class="alignleft actions bulkactions">
|
41 |
<?php $this->broken_fillter('sl_broken'); ?>
|
42 |
<?php $this->redirect_fillter('sl_redirect'); ?>
|
57 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
58 |
<?php endif ?>
|
59 |
|
|
|
|
|
60 |
<div style="float:right;margin-left:8px;">
|
61 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_broken_link_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
62 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
68 |
|
69 |
<?php
|
70 |
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Extra controls to be displayed between bulk actions and pagination
|
74 |
+
* @param string $which
|
75 |
+
*/
|
76 |
function extra_tablenav($which) {
|
|
|
|
|
77 |
echo '<div class="alignleft actions">';
|
78 |
global $wpdb;
|
79 |
|
97 |
}
|
98 |
|
99 |
echo "</div>";
|
|
|
|
|
100 |
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get a list of columns. The format is:
|
104 |
+
* 'internal-name' => 'Title'
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
function get_columns() {
|
108 |
return $columns = array(
|
109 |
'col_link_url' => __('URL', 'wp-meta-seo'),
|
113 |
'col_source' => __('Source', 'wp-meta-seo'),
|
114 |
);
|
115 |
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Get a list of sortable columns. The format is:
|
119 |
+
* 'internal-name' => 'orderby'
|
120 |
+
* or
|
121 |
+
* 'internal-name' => array( 'orderby', true )
|
122 |
+
*
|
123 |
+
* The second format will make the initial sorting order be descending
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
function get_sortable_columns() {
|
127 |
return $sortable = array(
|
128 |
'col_status' => array('status_text', true),
|
203 |
}
|
204 |
}
|
205 |
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Prepares the list of items for displaying.
|
209 |
+
* @uses WP_List_Table::set_pagination_args()
|
210 |
+
*/
|
211 |
function prepare_items() {
|
212 |
global $wpdb, $_wp_column_headers;
|
213 |
$where = array('1=1');
|
222 |
if (!empty($_REQUEST['sl_broken']) && $_REQUEST['sl_broken'] != 'all') {
|
223 |
if ($_REQUEST['sl_broken'] == 'valid_links') {
|
224 |
$where[] = "broken_internal = 0 AND broken_indexed = 0";
|
225 |
+
} elseif ($_REQUEST['sl_broken'] == 'internal_broken_links') {
|
226 |
$where[] = "broken_internal = 1";
|
227 |
} else {
|
228 |
$where[] = "broken_indexed = 1";
|
260 |
}
|
261 |
|
262 |
if (!empty($orderby) & !empty($order)) {
|
263 |
+
$orderStr = $wpdb->prepare(' ORDER BY %s ', $orderStr);
|
264 |
+
$orderStr = str_replace("'", "", $orderStr);
|
265 |
}
|
266 |
|
267 |
+
$query = "SELECT COUNT(id) FROM " . $wpdb->prefix . "wpms_links WHERE " . implode(' AND ', $where) . $orderStr;
|
268 |
+
$total_items = $wpdb->get_var($query);
|
269 |
$columns = $this->get_columns();
|
270 |
$hidden = array();
|
271 |
$sortable = $this->get_sortable_columns();
|
272 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
273 |
+
|
274 |
+
$query = "SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE " . implode(' AND ', $where) . $orderStr;
|
275 |
if (!empty($_REQUEST['metaseo_broken_link_per_page'])) {
|
276 |
$_per_page = intval($_REQUEST['metaseo_broken_link_per_page']);
|
277 |
} else {
|
314 |
|
315 |
$this->items = $wpdb->get_results($query);
|
316 |
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Displays the search box.
|
320 |
+
*/
|
321 |
function search_box1() {
|
322 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
323 |
return;
|
338 |
</p>
|
339 |
<?php
|
340 |
}
|
341 |
+
|
342 |
+
/* Add fillter redirect */
|
343 |
function redirect_fillter($name) {
|
344 |
$redirects = array('not_yet_redirect' => __('Not yet redirected', 'wp-meta-seo'), 'already_redirect' => __('Already redirected', 'wp-meta-seo'));
|
345 |
$curent_redirect = isset($_REQUEST['sl_redirect']) ? $_REQUEST['sl_redirect'] : 'all';
|
360 |
|
361 |
<?php
|
362 |
}
|
363 |
+
|
364 |
+
/* Add fillter broken */
|
365 |
function broken_fillter($name) {
|
366 |
+
$brokens = array('valid_links' => __('Valid links', 'wp-meta-seo'), 'automaticaly_indexed' => __('404 automaticaly indexed', 'wp-meta-seo'), 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo'));
|
367 |
$curent_broken = isset($_REQUEST['sl_broken']) ? $_REQUEST['sl_broken'] : 'all';
|
368 |
?>
|
369 |
<label for="filter-by-broken" class="screen-reader-text"><?php _e('Filter by broken', 'wp-meta-seo'); ?></label>
|
383 |
<?php
|
384 |
}
|
385 |
|
386 |
+
/* Add fillter type */
|
387 |
function type_fillter($name) {
|
388 |
$types = array('url' => 'URL', 'image' => 'Image', 'other' => 'Other');
|
389 |
$curent_type = isset($_REQUEST['sltype']) ? $_REQUEST['sltype'] : 'all';
|
407 |
echo '<div style="float:left;padding-left: 5px;"><div class="wpmf_process" data-w="0"></div>';
|
408 |
echo '<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link">' . __('Index internal broken links', 'wp-meta-seo') . '</div></div>';
|
409 |
echo '<span class="spinner"></span>';
|
|
|
410 |
}
|
411 |
|
412 |
+
/* Add fillter flush */
|
413 |
function flush_fillter($name) {
|
414 |
+
$flushs = array('automaticaly_indexed' => __('Automatic indexed 404', 'wp-meta-seo'), 'internal_broken_links' => __('Internal broken links', 'wp-meta-seo'), 'all' => __('Flush all 404', 'wp-meta-seo'));
|
415 |
?>
|
416 |
<label for="filter-by-flush" class="screen-reader-text"><?php _e('Filter by flush', 'wp-meta-seo'); ?></label>
|
417 |
<select name="<?php echo $name ?>" id="filter-by-flush">
|
424 |
</select>
|
425 |
|
426 |
<?php
|
427 |
+
echo '<div class="button wpms_flush_link">' . __('Flush', 'wp-meta-seo') . '</div>';
|
|
|
428 |
}
|
429 |
|
430 |
+
/**
|
431 |
+
* Generate the table rows
|
432 |
+
*/
|
433 |
function display_rows() {
|
434 |
$url = URL;
|
435 |
$url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
|
436 |
$records = $this->items;
|
437 |
$i = 0;
|
438 |
$alternate = "";
|
439 |
+
|
440 |
list( $columns, $hidden ) = $this->get_column_info();
|
441 |
if (!empty($records)) {
|
442 |
foreach ($records as $rec) {
|
455 |
|
456 |
switch ($column_name) {
|
457 |
case 'col_link_url':
|
458 |
+
if ($rec->type == 'url') {
|
459 |
$value_url = $rec->link_final_url;
|
460 |
+
} else {
|
461 |
$value_url = $rec->link_url;
|
462 |
}
|
463 |
echo '<td class="wpms_link_html" colspan="3">';
|
469 |
'recheck' => '<a class="wpms_action_link wpms-recheck-button" data-link_id="' . $rec->id . '" data-type="' . $rec->type . '" data-source_id="' . $rec->source_id . '" title="' . __('Recheck this link', 'wp-meta-seo') . '"><div class="wpms_icon_action"><i class="material-icons">loop</i></div><span>' . __('Recheck', 'wp-meta-seo') . '</span></a>'
|
470 |
);
|
471 |
echo $this->row_actions($row_action, false);
|
472 |
+
if (!empty($rec->source_id)) {
|
473 |
+
if ($rec->type == 'url') {
|
474 |
$iii = 0;
|
475 |
$pos = get_post($rec->source_id);
|
476 |
+
if (!empty($pos)) {
|
477 |
preg_match_all("#<a[^>]*>.*?</a>#si", $pos->post_content, $matches, PREG_PATTERN_ORDER);
|
478 |
foreach ($matches[0] as $i => $content) {
|
479 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
480 |
$href = $matches[1];
|
481 |
+
if ($href == $rec->link_url) {
|
482 |
$iii++;
|
483 |
}
|
|
|
484 |
}
|
485 |
}
|
486 |
+
} elseif ($rec->type == 'comment_content_url') {
|
487 |
$jjj = 0;
|
488 |
$com = get_comment($rec->source_id);
|
489 |
+
if (!empty($pos)) {
|
490 |
preg_match_all("#<a[^>]*>.*?</a>#si", $com->comment_content, $matches, PREG_PATTERN_ORDER);
|
491 |
foreach ($matches[0] as $i => $content) {
|
492 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
493 |
$href = $matches[1];
|
494 |
+
if ($href == $rec->link_url) {
|
495 |
$jjj++;
|
496 |
}
|
|
|
497 |
}
|
498 |
}
|
499 |
}
|
501 |
?>
|
502 |
<div class="wpms-inline-editor-content">
|
503 |
<h4><?php echo _x('Edit Link', 'inline editor title', 'wp-meta-seo'); ?></h4>
|
504 |
+
<?php
|
505 |
+
if ($rec->type == 'url') {
|
506 |
+
if ($iii > 1) {
|
507 |
+
echo '<span class="wpms-input-text-wrap"><span class="title">' . __('Text', 'wp-meta-seo') . '</span><input type="text" name="link_text" class="wpms-link-text-field" placeholder="' . __('Multiple link', 'wp-meta-seo') . '" data-type="multi" /></span>';
|
508 |
+
} else {
|
509 |
+
echo '<span class="wpms-input-text-wrap"><span class="title">' . __('Text', 'wp-meta-seo') . '</span><input type="text" name="link_text" class="wpms-link-text-field" value="' . esc_attr($rec->link_text) . '" data-type="only" /></span>';
|
510 |
+
}
|
511 |
+
} elseif ($rec->type == 'comment_content_url') {
|
512 |
+
if ($jjj > 1) {
|
513 |
+
echo '<span class="wpms-input-text-wrap"><span class="title">' . __('Text', 'wp-meta-seo') . '</span><input type="text" name="link_text" class="wpms-link-text-field" placeholder="' . __('Multiple link', 'wp-meta-seo') . '" data-type="multi" /></span>';
|
514 |
+
} else {
|
515 |
+
echo '<span class="wpms-input-text-wrap"><span class="title">' . __('Text', 'wp-meta-seo') . '</span><input type="text" name="link_text" class="wpms-link-text-field" value="' . esc_attr($rec->link_text) . '" data-type="only" /></span>';
|
516 |
+
}
|
517 |
+
} else {
|
518 |
+
echo '<span class="wpms-input-text-wrap"><span class="title">' . __('Text', 'wp-meta-seo') . '</span><input readonly type="text" name="link_text" class="wpms-link-text-field" value="(None)" data-type="only" /></span>';
|
519 |
+
}
|
520 |
+
?>
|
521 |
+
|
522 |
<span class="wpms-input-text-wrap"><span class="title"><?php _e('URL', 'wp-meta-seo'); ?></span><input <?php echo ($rec->type == '404_automaticaly') ? 'readonly' : '' ?> type="text" name="link_url" class="wpms-link-url-field" value="<?php echo esc_attr($value_url); ?>" /></span>
|
523 |
<span class="wpms-input-text-wrap"><span class="title"><?php _e('Redirect', 'wp-meta-seo'); ?></span><input type="text" name="link_url_redirect" class="wpms-link-redirect-field" value="<?php echo esc_attr($rec->link_url_redirect); ?>" /></span>
|
524 |
</label>
|
531 |
<?php
|
532 |
echo '</td>';
|
533 |
break;
|
534 |
+
|
535 |
case 'col_hit':
|
536 |
echo '<td colspan="3" style="text-align:center;">';
|
537 |
echo $rec->hit;
|
539 |
break;
|
540 |
case 'col_status':
|
541 |
echo '<td colspan="3" class="col_status">';
|
542 |
+
|
543 |
+
if (strpos($rec->status_text, '200') !== false) {
|
544 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>';
|
545 |
+
} elseif (strpos($rec->status_text, '301') !== false) {
|
546 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
|
547 |
+
} elseif (strpos($rec->status_text, '302') !== false) {
|
548 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>';
|
549 |
+
} elseif (strpos($rec->status_text, '404') !== false || $rec->status_text == 'Server Not Found') {
|
550 |
$wpms_settings_404 = get_option('wpms_settings_404');
|
551 |
+
if ((isset($wpms_settings_404['wpms_redirect_homepage']) && $wpms_settings_404['wpms_redirect_homepage'] == 1) || $rec->link_url_redirect != '') {
|
552 |
echo '<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>';
|
553 |
+
} else {
|
554 |
echo '<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>';
|
555 |
}
|
556 |
+
} else {
|
557 |
echo $rec->status_text;
|
558 |
}
|
559 |
+
|
560 |
echo '</td>';
|
561 |
break;
|
562 |
|
569 |
if (strip_tags($rec->link_text) != '') {
|
570 |
echo '<td colspan="3" class="link_text">' . strip_tags($rec->link_text) . '</td>';
|
571 |
} else {
|
572 |
+
echo '<td colspan="3" class="link_text"><i>' . __('No text on this link', 'wp-meta-seo') . '</i></td>';
|
573 |
}
|
574 |
}
|
575 |
|
583 |
} else {
|
584 |
if ($rec->type == 'comment' || $rec->type == 'comment_content_url' || $rec->type == 'comment_content_image') {
|
585 |
$source = get_comment($rec->source_id);
|
586 |
+
if (!empty($source)) {
|
587 |
$row_action = array(
|
588 |
'edit' => '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '" title="Edit this item">Edit</a>',
|
589 |
'view' => '<a target="_blank" href="' . get_comment_link($rec->source_id) . '" title="View “test”" rel="permalink">View</a>'
|
590 |
);
|
591 |
+
|
592 |
+
if ($rec->type == 'comment') {
|
593 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Comments">person_outline</i></span>';
|
594 |
+
} else {
|
595 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Comments content">chat_bubble</i></span>';
|
596 |
}
|
597 |
$source_inner .= '<a target="_blank" href="' . get_edit_comment_link($rec->source_id) . '">' . $source->comment_author . '</a>';
|
598 |
}
|
599 |
} else {
|
600 |
$source = get_post($rec->source_id);
|
601 |
+
if (!empty($source)) {
|
602 |
$row_action = array(
|
603 |
'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="Edit this item">Edit</a>',
|
604 |
'view' => '<a target="_blank" href="' . get_post_permalink($rec->source_id) . '" title="View “test”" rel="permalink">View</a>'
|
605 |
);
|
606 |
+
|
607 |
$source_inner = '<span style="float: left;margin-right: 5px;"><i class="material-icons metaseo_help_status" alt="Post , Page , Custom post">layers</i></span>';
|
608 |
$source_inner .= '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '">' . $source->post_title . '</a>';
|
609 |
}
|
610 |
}
|
611 |
|
612 |
echo '<td colspan="3">';
|
613 |
+
if (!empty($source)) {
|
614 |
echo $source_inner;
|
615 |
echo $this->row_actions($row_action, false);
|
616 |
+
} else {
|
617 |
+
echo '<a>' . __('Source Not Found', 'wp-meta-seo') . '</a>';
|
618 |
}
|
619 |
echo '</td>';
|
620 |
break;
|
626 |
}
|
627 |
}
|
628 |
}
|
629 |
+
|
630 |
+
/*
|
631 |
+
* Retrieves a modified URL query string.
|
632 |
+
*/
|
633 |
public function process_action() {
|
634 |
global $wpdb;
|
635 |
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
661 |
exit();
|
662 |
}
|
663 |
}
|
664 |
+
|
665 |
+
/*
|
666 |
+
* Scan link in post content
|
667 |
+
*/
|
668 |
public static function wpms_get_links() {
|
669 |
global $wpdb, $_wp_column_headers;
|
670 |
|
679 |
if (!empty($post_type) && !in_array($post_type, $post_types))
|
680 |
$post_type = '\'post\'';
|
681 |
else if (empty($post_type)) {
|
682 |
+
$post_type = "'" . implode("', '", esc_sql($post_types)) . "'";
|
683 |
} else {
|
684 |
$post_type = "'" . $post_type . "'";
|
685 |
}
|
687 |
$where[] = "post_type IN ($post_type)";
|
688 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
689 |
$states['trash'] = 'trash';
|
690 |
+
$all_states = "'" . implode("', '", esc_sql($states)) . "'";
|
691 |
|
692 |
if (empty($_REQUEST['post_status'])) {
|
693 |
$where[] = "post_status IN ($all_states)";
|
707 |
$results = $wpdb->get_results($query);
|
708 |
$list_link = array();
|
709 |
|
710 |
+
// get link from comments
|
711 |
$comments = get_comments();
|
712 |
foreach ($comments as $comment) {
|
713 |
if (!empty($comment->comment_author_url)) {
|
|
|
|
|
|
|
|
|
|
|
714 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
715 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
|
716 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
717 |
+
$list_link[$comment->comment_author_url . $comment->comment_ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $comment->comment_author_url, $comment->comment_author, 'comment', $status, $status_type);
|
718 |
}
|
719 |
}
|
720 |
|
721 |
+
// get link from posts
|
722 |
foreach ($results as $post) {
|
723 |
+
if ($post->post_excerpt != 'metaseo_404_page') {
|
724 |
$dom = new DOMDocument;
|
725 |
libxml_use_internal_errors(true);
|
726 |
if (isset($post->post_content) && $post->post_content != '') {
|
731 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
732 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
733 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
|
|
|
|
|
|
|
|
734 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
735 |
+
$list_link[$href . 'url' . $post->ID . $link_text] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $href, $link_text, 'url', $status, $status_type);
|
736 |
}
|
737 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
738 |
foreach (array_unique($matches[0]) as $content) {
|
|
|
|
|
|
|
|
|
|
|
739 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
740 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
741 |
$src = $matches[1];
|
742 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
743 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
744 |
$link_text = '';
|
745 |
+
$list_link[$src . 'img' . $post->ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $src, $link_text, 'image', $status, $status_type);
|
746 |
}
|
747 |
}
|
748 |
}
|
751 |
return $list_link;
|
752 |
}
|
753 |
|
754 |
+
/*
|
755 |
+
* Return detail link
|
756 |
+
*/
|
757 |
+
public static function get_result_link($source_link, $source_id, $url, $link_text, $type, $status, $status_type, $meta_title = '', $rel = '', $postID = 0) {
|
758 |
$res = array(
|
759 |
'source_link' => $source_link,
|
|
|
760 |
'source_id' => (int) $source_id,
|
761 |
'link_url' => $url,
|
762 |
'link_text' => $link_text,
|
763 |
'type' => $type,
|
764 |
'status' => $status,
|
765 |
'status_type' => $status_type);
|
766 |
+
|
767 |
+
if (isset($meta_title)) {
|
768 |
$res['meta_title'] = $meta_title;
|
769 |
+
} else {
|
770 |
$res['meta_title'] = '';
|
771 |
}
|
772 |
+
|
773 |
+
if (isset($rel) && $rel == 'nofollow') {
|
774 |
$res['follow'] = 0;
|
775 |
+
} else {
|
776 |
$res['follow'] = 1;
|
777 |
}
|
778 |
+
|
779 |
+
if (strpos($url, 'mailto:') !== false) {
|
780 |
$res['link_final_url'] = $url;
|
781 |
+
} else {
|
782 |
+
if ($type == 'url') {
|
783 |
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
|
784 |
$perlink = get_option('permalink_structure');
|
785 |
+
if (empty($perlink)) {
|
786 |
+
$res['link_final_url'] = get_site_url() . '/' . $url;
|
787 |
+
} else {
|
788 |
+
if (!empty($postID)) {
|
789 |
+
$res['link_final_url'] = get_permalink($postID) . $url;
|
790 |
+
} else {
|
791 |
+
$res['link_final_url'] = $perlink . '/' . $url;
|
792 |
}
|
793 |
}
|
794 |
+
} else {
|
795 |
$res['link_final_url'] = $url;
|
796 |
}
|
797 |
+
} else {
|
798 |
$res['link_final_url'] = $url;
|
799 |
}
|
800 |
}
|
801 |
+
|
802 |
+
|
803 |
return $res;
|
804 |
}
|
805 |
|
806 |
+
/*
|
807 |
+
* Get link status
|
808 |
+
*/
|
809 |
public static function get_urlstatus($url) {
|
810 |
$status = @get_headers($url, 0);
|
811 |
+
if (strpos($url, 'mailto:') !== false)
|
812 |
+
return 'Not checked';
|
813 |
if (isset($status[0])) {
|
814 |
return $status[0];
|
815 |
} else {
|
816 |
return 'Server Not Found';
|
817 |
}
|
|
|
818 |
}
|
819 |
+
|
820 |
+
/*
|
821 |
+
* Get link status type
|
822 |
+
*/
|
823 |
public static function get_urlstatus_type($status) {
|
824 |
+
if (isset($status) && $status == 'Not checked')
|
825 |
+
return 'ok';
|
826 |
if (isset($status) && $status != 'Server Not Found') {
|
827 |
if (((int) substr($status, 9, 3) >= 200 && (int) substr($status, 9, 3) <= 204) || (int) substr($status, 9, 3) == 401) {
|
828 |
$type = 'ok';
|
842 |
}
|
843 |
return $type;
|
844 |
}
|
845 |
+
|
846 |
+
/*
|
847 |
+
* Delete link comment in wpms_links table when delete comment
|
848 |
+
*/
|
849 |
public static function wpms_deleted_comment($comment_ID) {
|
850 |
|
851 |
global $wpdb;
|
853 |
$wpdb->prepare(
|
854 |
"DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d
|
855 |
AND (type = %s || type = %s || type = %s)
|
856 |
+
", $comment_ID, 'comment', 'comment_content_url', 'comment_content_image'
|
857 |
)
|
858 |
);
|
859 |
}
|
860 |
+
|
861 |
+
/*
|
862 |
+
* Delete link post in wpms_links table when delete post
|
863 |
+
*/
|
864 |
public static function wpms_delete_post($post_id) {
|
865 |
global $wpdb;
|
866 |
$wpdb->query(
|
871 |
)
|
872 |
);
|
873 |
}
|
874 |
+
|
875 |
+
/*
|
876 |
+
* Update wpms_links table when update comment
|
877 |
+
*/
|
878 |
public static function wpms_update_comment($comment_ID) {
|
879 |
global $wpdb;
|
880 |
$comment = get_comment($comment_ID);
|
881 |
+
$status = wp_get_comment_status($comment_ID);
|
882 |
+
if ($status == 'approved') {
|
883 |
if (!empty($comment->comment_author_url)) {
|
884 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus(($comment->comment_author_url));
|
885 |
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
|
925 |
$wpdb->prefix . 'wpms_links', $value, array('source_id' => $comment_ID, 'type' => 'comment'), array('%s', '%s', '%s', '%d', '%d', '%d', '%d'), array('%d', '%s')
|
926 |
);
|
927 |
}
|
928 |
+
} else {
|
929 |
+
$wpdb->query(
|
930 |
+
$wpdb->prepare("DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d AND (type = %s)", array($comment_ID, 'comment'))
|
931 |
);
|
932 |
}
|
933 |
+
|
934 |
+
|
935 |
if (isset($comment->comment_content) && $comment->comment_content != '') {
|
936 |
preg_match_all("#<a[^>]*>.*?</a>#si", $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
937 |
foreach (array_unique($matches[0]) as $i => $content) {
|
940 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
941 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
942 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
|
|
|
|
|
|
|
|
943 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
944 |
+
$links_in_content[$href . 'comment_content_url' . $comment->comment_ID . $link_text] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $href, $link_text, 'comment_content_url', $status, $status_type);
|
945 |
}
|
946 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
947 |
foreach (array_unique($matches[0]) as $content) {
|
950 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
951 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
952 |
$link_text = '';
|
|
|
|
|
|
|
|
|
953 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
954 |
+
$links_in_content[$src . 'comment_content_image' . $comment->comment_ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $src, $link_text, 'comment_content_image', $status, $status_type);
|
955 |
}
|
956 |
}
|
957 |
|
958 |
global $wpdb;
|
959 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND (type = %s || type = %s)", array($comment->comment_ID, "comment_content_url", "comment_content_image"));
|
960 |
$links = $wpdb->get_results($sql);
|
961 |
foreach ($links as $link) {
|
962 |
+
if (empty($links_in_content[$link->link_url . $link->type])) {
|
963 |
$wpdb->delete($wpdb->prefix . "wpms_links", array('id' => $link->id), array('%d'));
|
964 |
} else {
|
965 |
+
unset($links_in_content[$link->link_url . $link->type . $link->link_text]);
|
966 |
}
|
967 |
}
|
968 |
|
969 |
if (!empty($links_in_content)) {
|
970 |
+
foreach ($links_in_content as $link) {
|
971 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link, $wpdb);
|
972 |
}
|
973 |
}
|
974 |
+
} else {
|
|
|
|
|
975 |
global $wpdb;
|
976 |
+
$wpdb->query(
|
977 |
+
$wpdb->prepare("DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d AND (type = %s || type = %s || type = %s)", array($comment_ID, 'comment', 'comment_content_url', 'comment_content_image'))
|
978 |
);
|
979 |
}
|
980 |
}
|
981 |
+
|
982 |
+
/*
|
983 |
+
* Update wpms_links table when update post
|
984 |
+
*/
|
985 |
public static function wpms_update_post($post_ID, $post_after, $post_before) {
|
986 |
$post = $post_after;
|
987 |
$dom = new DOMDocument;
|
988 |
libxml_use_internal_errors(true);
|
989 |
$links_in_content = array();
|
990 |
+
|
991 |
+
if ($post->post_excerpt != 'metaseo_404_page') {
|
992 |
+
if ($post->post_status == 'publish') {
|
993 |
if (isset($post->post_content) && $post->post_content != '') {
|
994 |
|
995 |
preg_match_all("#<a[^>]*>.*?</a>#si", $post->post_content, $matches, PREG_PATTERN_ORDER);
|
998 |
$tags = $dom->getElementsByTagName('a');
|
999 |
$meta_title = $tags->item(0)->getAttribute('title');
|
1000 |
$rel = $tags->item(0)->getAttribute('rel');
|
1001 |
+
|
1002 |
preg_match('/< *a[^>]*href *= *["\']?([^"\']*)/i', $content, $matches);
|
1003 |
$href = $matches[1];
|
1004 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
1005 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1006 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
1007 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
1008 |
+
$links_in_content[$href . 'url' . $post->ID . $link_text] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $href, $link_text, 'url', $status, $status_type, $meta_title, $rel);
|
1009 |
}
|
1010 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
1011 |
foreach (array_unique($matches[0]) as $content) {
|
1015 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
1016 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1017 |
$link_text = '';
|
1018 |
+
$links_in_content[$src . 'img' . $post->ID] = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $src, $link_text, 'image', $status, $status_type);
|
1019 |
}
|
1020 |
}
|
1021 |
|
1023 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE source_id=%d AND type != %s", array($post->ID, "comment"));
|
1024 |
$links = $wpdb->get_results($sql);
|
1025 |
foreach ($links as $link) {
|
1026 |
+
if (empty($links_in_content[$link->link_url . $link->type])) {
|
1027 |
$wpdb->delete($wpdb->prefix . "wpms_links", array('id' => $link->id), array('%d'));
|
1028 |
} else {
|
1029 |
+
unset($links_in_content[$link->link_url . $link->type . $link->link_text]);
|
1030 |
}
|
1031 |
}
|
1032 |
|
1033 |
if (!empty($links_in_content)) {
|
1034 |
+
foreach ($links_in_content as $link) {
|
1035 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link, $wpdb);
|
1036 |
}
|
1037 |
}
|
1038 |
+
} else {
|
1039 |
global $wpdb;
|
1040 |
+
$wpdb->query(
|
1041 |
+
$wpdb->prepare("DELETE FROM " . $wpdb->prefix . "wpms_links WHERE source_id = %d AND (type = %s || type = %s)", array($post->ID, 'image', 'url'))
|
1042 |
);
|
1043 |
}
|
1044 |
}
|
1045 |
}
|
1046 |
+
|
1047 |
+
/*
|
1048 |
+
* Scan link in comment , post
|
1049 |
+
*/
|
1050 |
+
public static function wpms_scan_link() {
|
1051 |
|
|
|
|
|
1052 |
global $wpdb, $_wp_column_headers;
|
1053 |
$limit_comment_content = 1;
|
1054 |
$limit_comment = 10;
|
1077 |
$total_posts = $wpdb->get_var("SELECT COUNT(*)"
|
1078 |
. " FROM $wpdb->posts "
|
1079 |
. " WHERE " . implode(' AND ', $where));
|
1080 |
+
|
1081 |
+
$total_link = (int) $total_comments + (int) $total_posts;
|
1082 |
$percent_comment_content = 33.33;
|
1083 |
$percent_comment = 33.33;
|
1084 |
$percent_post = 33.33;
|
1085 |
+
|
1086 |
+
if (!empty($total_comments))
|
1087 |
+
$percent_comment_content = 33.33 / $total_comments;
|
1088 |
+
if ($total_comments < $limit_comment_content)
|
1089 |
+
$percent_comment_content = 33.33;
|
1090 |
+
if (!empty($total_comments))
|
1091 |
+
$percent_comment = 33.33 / $total_comments;
|
1092 |
+
if ($total_comments < $limit_comment)
|
1093 |
+
$percent_comment = 33.33;
|
1094 |
+
if (!empty($total_posts))
|
1095 |
+
$percent_post = 33.33 / $total_posts;
|
1096 |
+
if ($total_posts < $limit_post)
|
1097 |
+
$percent_post = 33.33;
|
1098 |
+
|
1099 |
// scan link in comment url
|
1100 |
$comments = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "comments WHERE comment_approved = 1 AND comment_author_url != '' AND comment_author_url NOT IN (SELECT link_url FROM " . $wpdb->prefix . "wpms_links WHERE type='comment') LIMIT $limit_comment");
|
1101 |
if (!empty($comments)) {
|
1102 |
foreach ($comments as $comment) {
|
1103 |
if (!empty($comment->comment_author_url)) {
|
|
|
|
|
|
|
|
|
|
|
1104 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1105 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($comment->comment_author_url);
|
1106 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1107 |
+
$coms = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $comment->comment_author_url, $comment->comment_author, 'comment', $status, $status_type);
|
1108 |
MetaSeo_Broken_Link_Table::wpms_insert_link($coms, $wpdb);
|
1109 |
}
|
1110 |
}
|
1111 |
+
wp_send_json(array('status' => false, 'type' => 'limit', 'percent' => $percent_comment));
|
1112 |
}
|
1113 |
+
|
1114 |
// scan link in comment content
|
1115 |
$k = 0;
|
1116 |
$off_set = ($_POST['comment_paged'] - 1) * $limit_comment_content;
|
1128 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
1129 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1130 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
|
|
|
|
|
|
|
|
1131 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1132 |
+
$link_a = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $href, $link_text, 'comment_content_url', $status, $status_type);
|
1133 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_a, $wpdb);
|
1134 |
}
|
1135 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $comment->comment_content, $matches, PREG_PATTERN_ORDER);
|
1136 |
foreach (array_unique($matches[0]) as $content) {
|
|
|
|
|
|
|
|
|
|
|
1137 |
$source_link = '<a href="' . get_edit_comment_link($comment->comment_ID) . '"><b>' . $comment->comment_author . '</b></a>';
|
1138 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
1139 |
$src = $matches[1];
|
1140 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
1141 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1142 |
$link_text = '';
|
1143 |
+
$link_sou = MetaSeo_Broken_Link_Table::get_result_link($source_link, $comment->comment_ID, $src, $link_text, 'comment_content_image', $status, $status_type);
|
1144 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_sou, $wpdb);
|
1145 |
}
|
1146 |
}
|
1147 |
}
|
1148 |
+
|
1149 |
$k++;
|
1150 |
if ($k >= $limit_comment_content) {
|
1151 |
+
wp_send_json(array('status' => false, 'type' => 'limit_comment_content', 'paged' => $_POST['comment_paged'], 'percent' => $percent_comment_content * count($comments_content)));
|
1152 |
}
|
1153 |
}
|
1154 |
+
|
1155 |
// scan link in post
|
1156 |
$j = 0;
|
1157 |
$off_set = ($_POST['paged'] - 1) * $limit_post;
|
1179 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($href);
|
1180 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1181 |
$link_text = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "$2", $content);
|
|
|
|
|
|
|
|
|
|
|
1182 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
1183 |
+
$link_a = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $href, $link_text, 'url', $status, $status_type, $meta_title, $rel, $post->ID);
|
1184 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_a, $wpdb);
|
1185 |
}
|
1186 |
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches, PREG_PATTERN_ORDER);
|
1187 |
foreach (array_unique($matches[0]) as $content) {
|
|
|
|
|
|
|
|
|
|
|
1188 |
$source_link = '<a href="' . get_edit_post_link($post->ID) . '"><b>' . $post->post_title . '</b></a>';
|
1189 |
preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $content, $matches);
|
1190 |
$src = $matches[1];
|
1191 |
$status = MetaSeo_Broken_Link_Table::get_urlstatus($src);
|
1192 |
$status_type = MetaSeo_Broken_Link_Table::get_urlstatus_type($status);
|
1193 |
$link_text = '';
|
1194 |
+
$link_sou = MetaSeo_Broken_Link_Table::get_result_link($source_link, $post->ID, $src, $link_text, 'image', $status, $status_type);
|
1195 |
MetaSeo_Broken_Link_Table::wpms_insert_link($link_sou, $wpdb);
|
1196 |
}
|
1197 |
}
|
1198 |
}
|
1199 |
$j++;
|
1200 |
if ($j >= $limit_post) {
|
1201 |
+
wp_send_json(array('status' => false, 'type' => 'limit_post', 'paged' => $_POST['paged'], 'percent' => $percent_post * count($results)));
|
1202 |
}
|
1203 |
}
|
1204 |
wp_send_json(array('status' => true));
|
1205 |
}
|
1206 |
+
|
1207 |
+
/*
|
1208 |
+
* Insert link to wpms_link table
|
1209 |
+
*/
|
1210 |
public static function wpms_insert_link($link, $wpdb) {
|
1211 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE link_url=%s AND type=%s AND source_id=%d ", array($link['link_url'], $link['type'], $link['source_id']));
|
1212 |
+
$links = $wpdb->get_results($sql);
|
1213 |
+
if (count($links) == 0) {
|
1214 |
+
$status = MetaSeo_Broken_Link_Table::get_urlstatus(($link['link_url']));
|
1215 |
+
$status_text = MetaSeo_Broken_Link_Table::wpms_get_status_text($status);
|
1216 |
+
$value = array(
|
1217 |
+
'link_url' => $link['link_url'],
|
1218 |
+
'link_final_url' => $link['link_final_url'],
|
1219 |
+
'link_text' => $link['link_text'],
|
1220 |
+
'source_id' => $link['source_id'],
|
1221 |
+
'type' => $link['type'],
|
1222 |
+
'status_code' => $link['status'],
|
1223 |
+
'status_text' => $status_text,
|
1224 |
+
'broken_indexed' => 0,
|
1225 |
+
'broken_internal' => 0,
|
1226 |
+
'warning' => 0,
|
1227 |
+
'dismissed' => 0,
|
1228 |
+
'meta_title' => $link['meta_title'],
|
1229 |
+
'follow' => $link['follow']
|
1230 |
+
);
|
1231 |
+
if (isset($link['status_type']) && $link['status_type'] != 'ok') {
|
1232 |
+
$value[$link['status_type']] = 1;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
$site_url = get_site_url();
|
1236 |
+
$value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($link['link_url'], $site_url, $value);
|
1237 |
+
|
1238 |
+
$wpdb->insert(
|
1239 |
+
$wpdb->prefix . 'wpms_links', $value
|
1240 |
+
);
|
1241 |
+
} else {
|
1242 |
+
$value = array(
|
1243 |
+
'meta_title' => $link['meta_title'],
|
1244 |
+
'follow' => $link['follow']
|
1245 |
+
);
|
1246 |
+
$site_url = get_site_url();
|
1247 |
+
$value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($links[0]->link_url, $site_url, $value);
|
1248 |
+
|
1249 |
+
if ($links[0]->follow != $link['follow'] || $links[0]->meta_title != $link['meta_title'] || $links[0]->internal != $value['internal']) {
|
1250 |
+
$wpdb->update(
|
1251 |
+
$wpdb->prefix . 'wpms_links', $value, array('id' => $links[0]->id)
|
1252 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1253 |
}
|
1254 |
+
}
|
1255 |
}
|
1256 |
|
1257 |
+
/*
|
1258 |
+
* Check internal link
|
1259 |
+
*/
|
1260 |
+
public static function wpms_check_internal_link($link, $siteUrl, $value) {
|
1261 |
$info_link = parse_url($link);
|
1262 |
$info_site_url = parse_url($siteUrl);
|
1263 |
+
$domain_link = $info_link['host'] . $info_link['path'] . '/';
|
1264 |
+
$domain_site = $info_site_url['host'] . $info_site_url['path'] . '/';
|
1265 |
+
if (strpos($domain_link, $domain_site) !== false) {
|
1266 |
$value['internal'] = 1;
|
1267 |
+
} else {
|
1268 |
$value['internal'] = 0;
|
1269 |
}
|
1270 |
+
|
1271 |
return $value;
|
1272 |
}
|
1273 |
|
1274 |
+
/*
|
1275 |
+
* Flush link
|
1276 |
+
*/
|
1277 |
public static function wpms_flush_link() {
|
1278 |
global $wpdb;
|
1279 |
+
if (isset($_POST['type']) && $_POST['type'] != 'none') {
|
1280 |
+
switch ($_POST['type']) {
|
1281 |
case 'automaticaly_indexed':
|
1282 |
+
$wpdb->query(
|
1283 |
+
$wpdb->prepare(
|
1284 |
"
|
1285 |
+
DELETE FROM " . $wpdb->prefix . "wpms_links
|
1286 |
WHERE broken_indexed = %d AND link_url_redirect = %s
|
1287 |
+
", array(1, '')
|
1288 |
)
|
1289 |
);
|
1290 |
break;
|
1291 |
case 'internal_broken_links':
|
1292 |
+
$wpdb->query(
|
1293 |
+
$wpdb->prepare(
|
1294 |
"
|
1295 |
+
DELETE FROM " . $wpdb->prefix . "wpms_links
|
1296 |
WHERE broken_internal = %d AND link_url_redirect = %s
|
1297 |
+
", array(1, '')
|
1298 |
)
|
1299 |
);
|
1300 |
break;
|
1301 |
case 'all':
|
1302 |
+
$wpdb->query(
|
1303 |
+
$wpdb->prepare(
|
1304 |
"
|
1305 |
+
DELETE FROM " . $wpdb->prefix . "wpms_links
|
1306 |
WHERE (broken_internal = %d
|
1307 |
OR broken_indexed = %d) AND link_url_redirect = %s
|
1308 |
+
", array(1, 1, '')
|
1309 |
)
|
1310 |
);
|
1311 |
+
|
1312 |
break;
|
1313 |
}
|
1314 |
wp_send_json(true);
|
|
|
1315 |
}
|
1316 |
wp_send_json(false);
|
1317 |
}
|
1318 |
|
1319 |
+
/*
|
1320 |
+
* Get status text
|
1321 |
+
*/
|
1322 |
public static function wpms_get_status_text($status) {
|
1323 |
+
if ($status == 'Not checked')
|
1324 |
+
return 'Not checked';
|
1325 |
if ($status == 'Server Not Found') {
|
1326 |
$status_text = 'Server Not Found';
|
1327 |
} else {
|
1330 |
return $status_text;
|
1331 |
}
|
1332 |
|
1333 |
+
/*
|
1334 |
+
* Update link
|
1335 |
+
*/
|
1336 |
public static function wpms_update_link() {
|
1337 |
+
|
1338 |
if (isset($_POST['link_id'])) {
|
1339 |
global $wpdb;
|
1340 |
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE id=%d", array($_POST['link_id']));
|
1357 |
'warning' => 0,
|
1358 |
'dismissed' => 0,
|
1359 |
);
|
1360 |
+
if (strpos($_POST['new_link'], 'mailto:') !== false) {
|
1361 |
$value['link_final_url'] = $_POST['new_link'];
|
1362 |
+
} else {
|
1363 |
if (!preg_match("~^(?:f|ht)tps?://~i", $_POST['new_link'])) {
|
1364 |
$perlink = get_option('permalink_structure');
|
1365 |
+
if (empty($perlink)) {
|
1366 |
+
$value['link_final_url'] = get_site_url() . '/' . $_POST['new_link'];
|
1367 |
+
} else {
|
1368 |
+
if (!empty($link_detail->source_id)) {
|
1369 |
+
$value['link_final_url'] = get_permalink($link_detail->source_id) . $_POST['new_link'];
|
1370 |
+
} else {
|
1371 |
+
$value['link_final_url'] = $perlink . '/' . $_POST['new_link'];
|
1372 |
}
|
1373 |
}
|
1374 |
+
} else {
|
1375 |
$value['link_final_url'] = $_POST['new_link'];
|
1376 |
}
|
1377 |
}
|
1378 |
+
|
1379 |
if (!empty($_POST['link_redirect']))
|
1380 |
$value['link_url_redirect'] = ($_POST['link_redirect']);
|
1381 |
if (isset($status_type) && $status_type != 'ok') {
|
1392 |
'broken_indexed' => 1
|
1393 |
);
|
1394 |
}
|
1395 |
+
|
1396 |
$site_url = get_site_url();
|
1397 |
+
$value = MetaSeo_Broken_Link_Table::wpms_check_internal_link($_POST['new_link'], $site_url, $value);
|
1398 |
|
1399 |
$wpdb->update(
|
1400 |
$wpdb->prefix . 'wpms_links', $value, array('id' => $_POST['link_id'])
|
1406 |
break;
|
1407 |
case 'comment_content_image':
|
1408 |
$comment = get_comment($link_detail->source_id);
|
1409 |
+
if (!empty($comment)) {
|
1410 |
$old_value = $comment->comment_content;
|
1411 |
$edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
|
1412 |
$my_comment = array(
|
1415 |
);
|
1416 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1417 |
wp_update_comment($my_comment);
|
1418 |
+
wp_send_json(array('status' => true, 'type' => 'image', 'status_text' => $status_text, 'new_link' => esc_url($edit_result['raw_url'])));
|
1419 |
}
|
1420 |
break;
|
1421 |
case 'image':
|
1422 |
$post = get_post($link_detail->source_id);
|
1423 |
+
if (!empty($post)) {
|
1424 |
$old_value = $post->post_content;
|
1425 |
$edit_result = MetaSeo_Broken_Link_Table::edit_linkimg($old_value, $_POST['new_link'], $link_detail->link_url);
|
1426 |
$my_post = array(
|
1429 |
);
|
1430 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1431 |
wp_update_post($my_post);
|
1432 |
+
wp_send_json(array('status' => true, 'type' => 'image', 'status_text' => $status_text, 'new_link' => esc_url($edit_result['raw_url'])));
|
1433 |
}
|
1434 |
break;
|
1435 |
+
|
1436 |
case 'comment_content_url':
|
1437 |
$comment = get_comment($link_detail->source_id);
|
1438 |
+
if (!empty($comment)) {
|
1439 |
$old_value = $comment->comment_content;
|
1440 |
+
if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == '') {
|
1441 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
|
1442 |
$new_text = '';
|
1443 |
+
} else {
|
1444 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
|
1445 |
$new_text = strip_tags($edit_result['link_text']);
|
1446 |
}
|
1451 |
);
|
1452 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1453 |
wp_update_comment($my_comment);
|
1454 |
+
wp_send_json(array('status' => true, 'type' => 'url', 'status_text' => $status_text, 'new_link' => $edit_result['raw_url'], 'new_text' => $new_text));
|
1455 |
}
|
1456 |
+
|
1457 |
break;
|
1458 |
+
|
1459 |
case 'url':
|
1460 |
$post = get_post($link_detail->source_id);
|
1461 |
+
if (!empty($post)) {
|
1462 |
$old_value = $post->post_content;
|
1463 |
+
if (isset($_POST['data_type']) && $_POST['data_type'] == 'multi' && $_POST['new_text'] == '') {
|
1464 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url);
|
1465 |
$new_text = '';
|
1466 |
+
} else {
|
1467 |
$edit_result = MetaSeo_Broken_Link_Table::wpms_edit_linkhtml($old_value, $_POST['new_link'], $link_detail->link_url, $_POST['new_text']);
|
1468 |
$new_text = strip_tags($edit_result['link_text']);
|
1469 |
}
|
1474 |
);
|
1475 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1476 |
wp_update_post($my_post);
|
1477 |
+
wp_send_json(array('status' => true, 'type' => 'url', 'status_text' => $status_text, 'new_link' => $edit_result['raw_url'], 'new_text' => $new_text));
|
1478 |
}
|
1479 |
+
|
1480 |
break;
|
1481 |
case 'comment':
|
1482 |
wp_update_comment(array('comment_ID' => $link_detail->source_id, 'comment_author_url' => $_POST['new_link']));
|
1486 |
}
|
1487 |
wp_send_json(false);
|
1488 |
}
|
1489 |
+
|
1490 |
+
/*
|
1491 |
+
* Remove link
|
1492 |
+
*/
|
1493 |
public static function wpms_unlink() {
|
1494 |
if (isset($_POST['link_id'])) {
|
1495 |
global $wpdb;
|
1502 |
case '404_automaticaly':
|
1503 |
wp_send_json(true);
|
1504 |
break;
|
1505 |
+
|
1506 |
case 'comment_content_image':
|
1507 |
$comment = get_comment($link_detail->source_id);
|
1508 |
+
if (!empty($comment)) {
|
1509 |
$old_value = $comment->comment_content;
|
1510 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_img($old_value, $link_detail->link_url);
|
1511 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1517 |
}
|
1518 |
wp_send_json(true);
|
1519 |
break;
|
1520 |
+
|
1521 |
case 'image':
|
1522 |
$post = get_post($link_detail->source_id);
|
1523 |
+
if (!empty($post)) {
|
1524 |
$old_value = $post->post_content;
|
1525 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_img($old_value, $link_detail->link_url);
|
1526 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1532 |
}
|
1533 |
wp_send_json(true);
|
1534 |
break;
|
1535 |
+
|
1536 |
case 'comment_content_url':
|
1537 |
$comment = get_comment($link_detail->source_id);
|
1538 |
+
if (!empty($comment)) {
|
1539 |
$old_value = $comment->comment_content;
|
1540 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_html($old_value, $link_detail->link_url);
|
1541 |
remove_action('edit_comment', array('MetaSeo_Broken_Link_Table', 'wpms_update_comment'));
|
1547 |
}
|
1548 |
wp_send_json(true);
|
1549 |
break;
|
1550 |
+
|
1551 |
case 'url':
|
1552 |
$post = get_post($link_detail->source_id);
|
1553 |
+
if (!empty($post)) {
|
1554 |
$old_value = $post->post_content;
|
1555 |
$new_content = MetaSeo_Broken_Link_Table::wpms_unlink_html($old_value, $link_detail->link_url);
|
1556 |
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1571 |
wp_send_json(false);
|
1572 |
}
|
1573 |
|
1574 |
+
/**
|
1575 |
+
* Change all occurrences of a given plaintext URLs to a new URL.
|
1576 |
+
*
|
1577 |
+
* @param string $content Look for URLs in this string.
|
1578 |
+
* @param string $new_url Change them to this URL.
|
1579 |
+
* @param string $old_url The URL to look for.
|
1580 |
+
*
|
1581 |
+
* @return array|WP_Error If successful, the return value will be an associative array with two
|
1582 |
+
* keys : 'content' - the modified content, and 'raw_url' - the new raw, non-normalized URL used
|
1583 |
+
* for the modified links. In most cases, the returned raw_url will be equal to the new_url.
|
1584 |
+
*/
|
1585 |
public static function edit_linkimg($content, $new_url, $old_url) {
|
1586 |
self::$old_url = $old_url;
|
1587 |
self::$new_url = htmlentities($new_url);
|
1588 |
$content = preg_replace_callback(self::$img_pattern, array('MetaSeo_Broken_Link_Table', 'editimg_callback'), $content);
|
1589 |
+
|
1590 |
return array(
|
1591 |
'content' => $content,
|
1592 |
'raw_url' => self::$new_url,
|
1593 |
);
|
1594 |
}
|
1595 |
+
|
1596 |
public static function editimg_callback($matches) {
|
1597 |
$url = $matches[3];
|
1598 |
if (($url) == self::$old_url) {
|
1602 |
}
|
1603 |
}
|
1604 |
|
1605 |
+
/**
|
1606 |
+
* Remove all occurrences of a specific plaintext URL.
|
1607 |
+
*
|
1608 |
+
* @param string $content Look for URLs in this string.
|
1609 |
+
* @param string $url The URL to look for.
|
1610 |
+
* @return string Input string with all matching plaintext URLs removed.
|
1611 |
+
*/
|
1612 |
+
public static function wpms_unlink_img($content, $url) {
|
1613 |
+
self::$old_url = $url; //used by the callback
|
1614 |
+
$content = preg_replace_callback(self::$img_pattern, array('MetaSeo_Broken_Link_Table', 'wpms_unlink_img_callback'), $content);
|
1615 |
+
return $content;
|
1616 |
}
|
1617 |
|
1618 |
+
public static function wpms_unlink_img_callback($matches) {
|
1619 |
+
$url = $matches[3];
|
1620 |
+
if (($url) == self::$old_url) {
|
1621 |
+
return ''; //Completely remove the IMG tag
|
1622 |
+
} else {
|
1623 |
+
return $matches[0]; //return the image unchanged
|
1624 |
+
}
|
1625 |
}
|
1626 |
|
1627 |
+
/**
|
1628 |
+
* Remove all occurrences of a specific plaintext URL.
|
1629 |
+
*
|
1630 |
+
* @param string $content Look for URLs in this string.
|
1631 |
+
* @param string $url The URL to look for.
|
1632 |
+
* @return string Input string with all matching plaintext URLs removed.
|
1633 |
+
*/
|
1634 |
+
public static function wpms_unlink_html($content, $url) {
|
1635 |
+
$args = array(
|
1636 |
+
'old_url' => $url,
|
1637 |
+
);
|
1638 |
|
1639 |
+
$content = MetaSeo_Broken_Link_Table::wpms_multi_edit($content, array('MetaSeo_Broken_Link_Table', 'wpms_unlink_html_callback'), $args);
|
1640 |
|
1641 |
+
return $content;
|
1642 |
}
|
1643 |
+
|
1644 |
+
public static function wpms_unlink_html_callback($link, $params) {
|
1645 |
+
if ($link['href'] != $params['old_url']) {
|
1646 |
+
return $link['#raw'];
|
1647 |
+
}
|
1648 |
|
1649 |
+
return $link['#link_text'];
|
|
|
|
|
|
|
|
|
|
|
1650 |
}
|
1651 |
|
1652 |
+
/**
|
1653 |
+
* Change all occurrences of a given plaintext URLs to a new URL.
|
1654 |
+
*
|
1655 |
+
* @param string $content Look for URLs in this string.
|
1656 |
+
* @param string $new_url Change them to this URL.
|
1657 |
+
* @param string $old_url The URL to look for.
|
1658 |
+
* @param string $new_text new text of this URL.
|
1659 |
+
* @return array|WP_Error If successful, the return value will be an associative array with two
|
1660 |
+
* keys : 'content' - the modified content, and 'raw_url' - the new raw, non-normalized URL used
|
1661 |
+
* for the modified links. In most cases, the returned raw_url will be equal to the new_url.
|
1662 |
+
*/
|
1663 |
public static function wpms_edit_linkhtml($content, $new_url, $old_url, $new_text = null) {
|
1664 |
//Save the old & new URLs for use in the edit callback.
|
1665 |
$args = array(
|
1680 |
}
|
1681 |
return $result;
|
1682 |
}
|
1683 |
+
|
1684 |
public static function wpms_edithtml_callback($link, $params) {
|
1685 |
if ($link['href'] == $params['old_url']) {
|
1686 |
$modified = array(
|
1689 |
if (isset($params['new_text'])) {
|
1690 |
$modified['#link_text'] = $params['new_text'];
|
1691 |
}
|
1692 |
+
|
1693 |
if (isset($params['meta_title'])) {
|
1694 |
$modified['title'] = $params['meta_title'];
|
1695 |
}
|
1696 |
+
|
1697 |
if (isset($params['follow']) && $params['follow'] == 0) {
|
1698 |
$modified['rel'] = 'nofollow';
|
1699 |
+
} else {
|
1700 |
$modified['rel'] = '';
|
1701 |
}
|
1702 |
return $modified;
|
1704 |
return $link['#raw'];
|
1705 |
}
|
1706 |
}
|
1707 |
+
|
1708 |
+
/**
|
1709 |
+
* Helper function for blcHtmlLink::multi_edit()
|
1710 |
+
* Applies the specified callback function to each link and merges
|
1711 |
+
* the result with the current link attributes. If the callback returns
|
1712 |
+
* a replacement HTML tag instead, it will be stored in the '#new_raw'
|
1713 |
+
* key of the return array.
|
1714 |
+
*
|
1715 |
+
* @access protected
|
1716 |
+
*
|
1717 |
+
* @param array $link
|
1718 |
+
* @param array $info The callback function and the extra argument to pass to that function (if any).
|
1719 |
+
* @return array
|
1720 |
+
*/
|
1721 |
public static function wpms_edit_callback($link, $info) {
|
1722 |
list($callback, $extra) = $info;
|
1723 |
|
1737 |
|
1738 |
return $link;
|
1739 |
}
|
1740 |
+
|
1741 |
+
/**
|
1742 |
+
* Modify all HTML links found in a string using a callback function.
|
1743 |
+
* The callback function should return either an associative array or a string. If
|
1744 |
+
* a string is returned, the parser will replace the current link with the contents
|
1745 |
+
* of that string. If an array is returned, the current link will be modified/rebuilt
|
1746 |
+
* by substituting the new values for the old ones.
|
1747 |
+
* htmlentities() will be automatically applied to attribute values (but not to #link_text).
|
1748 |
+
* @param string $content A text string containing the links to edit.
|
1749 |
+
* @param callback $callback Callback function used to modify the links.
|
1750 |
+
* @param mixed $extra If supplied, $extra will be passed as the second parameter to the function $callback.
|
1751 |
+
* @return string The modified input string.
|
1752 |
+
*/
|
1753 |
public static function wpms_multi_edit($content, $callback, $extra = null) {
|
1754 |
//Just reuse map() + a little helper func. to apply the callback to all links and get modified links
|
1755 |
$modified_links = MetaSeo_Broken_Link_Table::map($content, array('MetaSeo_Broken_Link_Table', 'wpms_edit_callback'), array($callback, $extra));
|
1779 |
|
1780 |
return $content;
|
1781 |
}
|
1782 |
+
|
1783 |
+
/**
|
1784 |
+
* extract_tags()
|
1785 |
+
* Extract specific HTML tags and their attributes from a string.
|
1786 |
+
*
|
1787 |
+
* You can either specify one tag, an array of tag names, or a regular expression that matches the tag name(s).
|
1788 |
+
* If multiple tags are specified you must also set the $selfclosing parameter and it must be the same for
|
1789 |
+
* all specified tags (so you can't extract both normal and self-closing tags in one go).
|
1790 |
+
*
|
1791 |
+
* The function returns a numerically indexed array of extracted tags. Each entry is an associative array
|
1792 |
+
* with these keys :
|
1793 |
+
* tag_name - the name of the extracted tag, e.g. "a" or "img".
|
1794 |
+
* offset - the numberic offset of the first character of the tag within the HTML source.
|
1795 |
+
* contents - the inner HTML of the tag. This is always empty for self-closing tags.
|
1796 |
+
* attributes - a name -> value array of the tag's attributes, or an empty array if the tag has none.
|
1797 |
+
* full_tag - the entire matched tag, e.g. '<a href="http://example.com">example.com</a>'. This key
|
1798 |
+
* will only be present if you set $return_the_entire_tag to true.
|
1799 |
+
*
|
1800 |
+
* @param string $html The HTML code to search for tags.
|
1801 |
+
* @param string|array $tag The tag(s) to extract.
|
1802 |
+
* @param bool $selfclosing Whether the tag is self-closing or not. Setting it to null will force the script to try and make an educated guess.
|
1803 |
+
* @param bool $return_the_entire_tag Return the entire matched tag in 'full_tag' key of the results array.
|
1804 |
+
* @param string $charset The character set of the HTML code. Defaults to ISO-8859-1.
|
1805 |
+
*
|
1806 |
+
* @return array An array of extracted tags, or an empty array if no matching tags were found.
|
1807 |
+
*/
|
1808 |
public static function extract_tags($html, $tag, $selfclosing = null, $return_the_entire_tag = false, $charset = 'ISO-8859-1') {
|
1809 |
|
1810 |
if (is_array($tag)) {
|
1889 |
|
1890 |
return $tags;
|
1891 |
}
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* Apply a callback function to all HTML links found in a string and return the results.
|
1895 |
+
*
|
1896 |
+
* The link data array will contain at least these keys :
|
1897 |
+
* 'href' - the URL of the link (with htmlentitydecode() already applied).
|
1898 |
+
* '#raw' - the raw link code, e.g. the entire '<a href="...">...</a>' tag of a HTML link.
|
1899 |
+
* '#offset' - the offset within $content at which the first character of the link tag was found.
|
1900 |
+
* '#link_text' - the link's anchor text, if any. May contain HTML tags.
|
1901 |
+
*
|
1902 |
+
* Any attributes of the link tag will also be included in the returned array as attr_name => attr_value
|
1903 |
+
* pairs. This function will also automatically decode any HTML entities found in attribute values.
|
1904 |
+
* @param string $content A text string to parse for links.
|
1905 |
+
* @param callback $callback Callback function to apply to all found links.
|
1906 |
+
* @param mixed $extra If the optional $extra param. is supplied, it will be passed as the second parameter to the function $callback.
|
1907 |
+
* @return array An array of all detected links after applying $callback to each of them.
|
1908 |
+
*/
|
1909 |
public static function map($content, $callback, $extra = null) {
|
1910 |
$results = array();
|
1911 |
|
1938 |
|
1939 |
return $results;
|
1940 |
}
|
1941 |
+
|
1942 |
+
/*
|
1943 |
+
* Ajax recheck link
|
1944 |
+
*/
|
1945 |
public static function wpms_recheck_link() {
|
1946 |
if (isset($_POST['link_id'])) {
|
1947 |
global $wpdb;
|
inc/class.metaseo-content-list-table.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
*/
|
7 |
|
@@ -9,43 +8,49 @@ if (!class_exists('WP_List_Table')) {
|
|
9 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
10 |
}
|
11 |
|
12 |
-
class MetaSeo_Content_List_Table extends WP_List_Table {
|
13 |
-
|
|
|
14 |
parent::__construct(array(
|
15 |
'singular' => 'metaseo_content',
|
16 |
'plural' => 'metaseo_contents',
|
17 |
'ajax' => true
|
18 |
));
|
19 |
-
|
20 |
}
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
function display_tablenav($which) {
|
23 |
?>
|
24 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
25 |
-
|
26 |
-
<?php #if($which=='top'): ?>
|
27 |
<input type="hidden" name="page" value="metaseo_content_meta" />
|
28 |
-
<?php #endif ?>
|
29 |
-
|
30 |
<input type="hidden" name="page" value="metaseo_content_meta" />
|
31 |
<?php if (!empty($_REQUEST['post_status'])): ?>
|
32 |
-
|
33 |
<?php endif ?>
|
34 |
-
|
35 |
<?php $this->extra_tablenav($which); ?>
|
36 |
-
|
37 |
-
|
38 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_posts_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
39 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
40 |
</div>
|
41 |
-
|
42 |
-
|
43 |
<br class="clear" />
|
44 |
</div>
|
45 |
|
46 |
<?php
|
47 |
}
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
function get_views() {
|
50 |
global $wpdb;
|
51 |
|
@@ -88,172 +93,202 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
88 |
|
89 |
return $status_links;
|
90 |
}
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
function extra_tablenav($which) {
|
93 |
-
|
94 |
-
|
95 |
-
global $wpdb;
|
96 |
-
|
97 |
-
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
98 |
-
$post_types = "'" . implode("', '", $post_types) . "'";
|
99 |
|
100 |
-
|
101 |
-
$states['trash'] = 'trash';
|
102 |
-
$all_states = "'" . implode("', '", $states) . "'";
|
103 |
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
|
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
$sl_bulk = '<select name="mbulk_copy" class="mbulk_copy"><option value="0">'.__('Bulk copy','wp-meta-seo').'</option><option value="all">'.__('All Posts','wp-meta-seo').'</option><option value="bulk-copy-metatitle">'.__('Selected posts','wp-meta-seo').'</option></select>';
|
117 |
-
$btn_bulk = '<input type="button" name="do_copy" id="post_do_copy" class="button button-primary btn_do_copy post_do_copy" value="'.__('Content title as meta title','wp-meta-seo').'"><span class="spinner"></span>';
|
118 |
-
|
119 |
-
echo sprintf('<select name="post_type_filter" class="metaseo-filter">%1$s</select>', $options);
|
120 |
-
submit_button(__('Filter'), 'button', 'do_filter', false, array('id' => 'post-query-submit'));
|
121 |
-
echo $sl_bulk . $btn_bulk;
|
122 |
-
echo "</div>";
|
123 |
-
#echo "</form>";
|
124 |
-
#}
|
125 |
}
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
function get_columns() {
|
128 |
-
$preview = __(" This is a rendering of what this post might look like in Google's search results.", 'wp-meta-seo');
|
129 |
$info = sprintf('<a class="info-content"><img src=' . WPMETASEO_PLUGIN_URL . 'img/info.png>'
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
$columns = array(
|
135 |
'cb' => '<input id="cb-select-all-1" type="checkbox" style="margin:0">',
|
136 |
'col_id' => __('', 'wp-meta-seo'),
|
137 |
'col_title' => __('Title', 'wp-meta-seo'),
|
138 |
-
'col_snippet' => sprintf(__('Snippet Preview %s', 'wp-meta-seo')
|
139 |
'col_meta_title' => __('Meta Title', 'wp-meta-seo'),
|
140 |
);
|
141 |
-
|
142 |
-
$settings = get_option(
|
143 |
-
if(isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1){
|
144 |
$columns['col_meta_keywords'] = __('Meta Keywords', 'wp-meta-seo');
|
145 |
}
|
146 |
$columns['col_meta_desc'] = __('Meta Description', 'wp-meta-seo');
|
147 |
-
$settings = get_option(
|
148 |
-
if(!empty($settings['metaseo_follow'])){
|
149 |
$columns['col_follow'] = __('Follow', 'wp-meta-seo');
|
150 |
}
|
151 |
-
|
152 |
-
if(!empty($settings['metaseo_index'])){
|
153 |
$columns['col_index'] = __('Index', 'wp-meta-seo');
|
154 |
}
|
155 |
-
|
156 |
return $columns;
|
157 |
}
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
function get_sortable_columns() {
|
160 |
return $sortable = array(
|
161 |
'col_title' => array('post_title', true),
|
162 |
);
|
163 |
}
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
function prepare_items() {
|
166 |
global $wpdb, $_wp_column_headers;
|
167 |
-
|
168 |
-
|
169 |
$screen = get_current_screen();
|
170 |
|
171 |
$where = array();
|
172 |
-
$post_type = isset($_REQUEST['post_type_filter'])? $_REQUEST['post_type_filter'] : "";
|
173 |
-
if($post_type=="-1") {
|
174 |
-
$post_type="";
|
175 |
}
|
176 |
-
|
177 |
-
$post_types = get_post_types(
|
178 |
-
if (
|
179 |
$post_type = '\'post\'';
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
188 |
$states['trash'] = 'trash';
|
189 |
$all_states = "'" . implode("', '", $states) . "'";
|
190 |
|
191 |
if (empty($_REQUEST['post_status'])) {
|
192 |
-
$where[] = "post_status IN ($all_states)";
|
193 |
} else {
|
194 |
$requested_state = $_REQUEST['post_status'];
|
195 |
-
if (in_array($requested_state, $states)) {
|
196 |
-
$where[] = "post_status IN ('$requested_state')";
|
197 |
} else {
|
198 |
-
$where[] = "post_status IN ($all_states)";
|
199 |
}
|
200 |
}
|
201 |
-
|
202 |
$keyword = !empty($_GET["s"]) ? $_GET["s"] : '';
|
203 |
if (isset($keyword) && $keyword != '') {
|
204 |
-
$where[] .= '(post_title LIKE "%' . $keyword .'%" OR mt.meta_value LIKE "%' . $keyword .'%" OR md.meta_value LIKE "%' . $keyword .'%")';
|
205 |
}
|
206 |
-
|
207 |
//Order By block
|
208 |
$orderby = !empty($_GET["orderby"]) ? ($_GET["orderby"]) : 'post_title';
|
209 |
$order = !empty($_GET["order"]) ? ($_GET["order"]) : 'asc';
|
210 |
-
|
211 |
$sortable = $this->get_sortable_columns();
|
212 |
-
if(in_array($orderby, $sortable)) {
|
213 |
$orderStr = $orderby;
|
214 |
-
}else {
|
215 |
$orderStr = 'post_title';
|
216 |
}
|
217 |
|
218 |
-
if($order=="asc") {
|
219 |
$orderStr .= " ASC";
|
220 |
-
}else {
|
221 |
$orderStr .= " DESC";
|
222 |
}
|
223 |
|
224 |
if (!empty($orderby) & !empty($order)) {
|
225 |
-
$orderStr =' ORDER BY '
|
|
|
226 |
}
|
227 |
|
228 |
-
$query = "SELECT ID
|
229 |
. " FROM $wpdb->posts "
|
230 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metatitle') mt ON mt.post_id = $wpdb->posts.ID "
|
231 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metadesc') md ON md.post_id = $wpdb->posts.ID "
|
232 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metakeywords') mk ON mk.post_id = $wpdb->posts.ID "
|
233 |
-
. " WHERE ". implode(' AND ', $where) . $orderStr;
|
234 |
|
235 |
-
$total_items = $wpdb->
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
}
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
$paged = !empty($_GET["paged"]) ? $_GET["paged"] : '';
|
259 |
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
|
@@ -280,21 +315,24 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
280 |
|
281 |
$this->items = $wpdb->get_results($query);
|
282 |
}
|
283 |
-
|
|
|
|
|
|
|
284 |
function display_rows() {
|
285 |
$records = $this->items;
|
286 |
$i = 0;
|
287 |
$alternate = "";
|
288 |
-
|
289 |
|
290 |
list( $columns, $hidden ) = $this->get_column_info();
|
291 |
-
|
292 |
if (!empty($records)) {
|
293 |
foreach ($records as $rec) {
|
294 |
$alternate = 'alternate' == $alternate ? '' : 'alternate';
|
295 |
$i++;
|
296 |
$classes = $alternate;
|
297 |
-
|
298 |
|
299 |
echo '<tr id="record_' . $rec->ID . '" class="' . $classes . '" >';
|
300 |
|
@@ -312,11 +350,11 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
312 |
switch ($column_name) {
|
313 |
case 'cb':
|
314 |
echo '<th scope="row" class="check-column">';
|
315 |
-
echo '<input id="cb-select-'
|
316 |
echo '</th>';
|
317 |
|
318 |
break;
|
319 |
-
|
320 |
case 'col_id':
|
321 |
echo '<td class="col_id" >';
|
322 |
echo $i;
|
@@ -326,9 +364,10 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
326 |
|
327 |
case 'col_title':
|
328 |
$post_title = stripslashes($rec->post_title);
|
329 |
-
if($post_title == '')
|
330 |
-
|
331 |
-
|
|
|
332 |
$post_type_object = get_post_type_object($rec->post_type);
|
333 |
$can_edit_post = current_user_can($post_type_object->cap->edit_post, $rec->ID);
|
334 |
|
@@ -349,9 +388,9 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
349 |
|
350 |
echo $this->row_actions($actions);
|
351 |
echo '</div></td>';
|
352 |
-
|
353 |
break;
|
354 |
-
|
355 |
case 'col_snippet':
|
356 |
echo '<td><div class="snippet-wrapper">';
|
357 |
echo '<div class="snippet">
|
@@ -360,7 +399,7 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
360 |
echo '<span class="snippet_metalink" id="snippet_metalink_' . $rec->ID . '">' . $rec->link . '</span>';
|
361 |
|
362 |
echo '<p id="snippet_desc' . $rec->ID . '" class="snippet_metades">' . $rec->metadesc . '</p></div>';
|
363 |
-
echo '<img class="wpms_loader'
|
364 |
echo '<span id="savedInfo' . $rec->ID . '" style="position: relative; display: block;float:right" class="saved-info metaseo-msg-success"><span style="position:absolute; float:right" class="meta-update"></span></span>';
|
365 |
echo '</div></td>';
|
366 |
break;
|
@@ -371,39 +410,39 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
371 |
break;
|
372 |
|
373 |
case 'col_meta_title':
|
374 |
-
$input = sprintf('</br><textarea class="large-text metaseo-metatitle" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metatitle-' . $rec->ID, 'metatitle['. $rec->ID.']', ( ($rec->metatitle ) ? $rec->metatitle : ''));
|
375 |
$input .= sprintf('<div class="title-len" id="%1$s"></div>', 'metaseo-metatitle-len' . $rec->ID);
|
376 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
377 |
break;
|
378 |
-
|
379 |
case 'col_meta_keywords':
|
380 |
-
$input = sprintf('</br><textarea class="large-text metaseo-metakeywords" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metakeywords-' . $rec->ID, 'metakeywords['. $rec->ID.']', ( ($rec->metakeywords ) ? $rec->metakeywords : ''));
|
381 |
$input .= sprintf('<div class="keywords-len" id="%1$s"></div>', 'metaseo-metakeywords-len' . $rec->ID);
|
382 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
383 |
break;
|
384 |
|
385 |
case 'col_meta_desc':
|
386 |
-
$input = sprintf('</br><textarea class="large-text metaseo-metadesc" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metadesc-' . $rec->ID, ' metades['. $rec->ID.']', (($rec->metadesc ) ? $rec->metadesc : ''));
|
387 |
$input .= sprintf('<div class="desc-len" id="%1$s"></div>', 'metaseo-metadesc-len' . $rec->ID);
|
388 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
389 |
break;
|
390 |
-
|
391 |
case 'col_index':
|
392 |
-
$page_index = get_post_meta($rec->ID,'_metaseo_metaindex',true);
|
393 |
-
if(isset($page_index) && $page_index == 'noindex'){
|
394 |
-
$input = '<input class="metaseo_post_index" name="index[]" type="checkbox" value="'
|
395 |
-
}else{
|
396 |
-
$input = '<input checked class="metaseo_post_index" name="index[]" type="checkbox" value="'
|
397 |
}
|
398 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
399 |
break;
|
400 |
-
|
401 |
case 'col_follow':
|
402 |
-
$page_follow = get_post_meta($rec->ID,'_metaseo_metafollow',true);
|
403 |
-
if(isset($page_follow) && $page_follow == 'nofollow'){
|
404 |
-
$input = '<input class="metaseo_post_follow" name="follow[]" type="checkbox" value="'
|
405 |
-
}else{
|
406 |
-
$input = '<input checked class="metaseo_post_follow" name="follow[]" type="checkbox" value="'
|
407 |
}
|
408 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
409 |
break;
|
@@ -419,258 +458,221 @@ class MetaSeo_Content_List_Table extends WP_List_Table {
|
|
419 |
$actions = array();
|
420 |
$actions = array(
|
421 |
'update' => 'Update',
|
422 |
-
);
|
423 |
|
424 |
return $actions;
|
425 |
}
|
426 |
|
|
|
|
|
|
|
427 |
function process_action() {
|
428 |
-
|
429 |
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
430 |
-
|
431 |
-
|
432 |
if (isset($_POST['do_filter']) and $_POST['do_filter'] === __('Filter')) {
|
433 |
-
$current_url = add_query_arg(array(
|
434 |
-
|
435 |
-
}
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
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 |
FROM $wpdb->postmeta
|
490 |
WHERE $metakeys
|
491 |
ORDER BY `meta_key`";
|
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 |
-
$yoast = 'wordpress-seo/wp-seo.php';
|
637 |
-
$aio = 'all-in-one-seo-pack/all_in_one_seo_pack.php';
|
638 |
-
|
639 |
-
$metakeys = array(
|
640 |
-
'mtitle' => array(
|
641 |
-
$mseo => '_metaseo_metatitle',
|
642 |
-
$yoast => '_yoast_wpseo_title',
|
643 |
-
$aio => '_aioseop_title' ),
|
644 |
-
'mdesciption' => array(
|
645 |
-
$mseo => '_metaseo_metadesc',
|
646 |
-
$yoast => '_yoast_wpseo_metadesc',
|
647 |
-
$aio => '_aioseop_description' )
|
648 |
-
);
|
649 |
-
|
650 |
-
//Update post meta
|
651 |
-
foreach($metakeys as $metakey){
|
652 |
-
if(in_array($meta_key, $metakey)){
|
653 |
-
foreach($metakey as $plg => $mkey){
|
654 |
-
if($mkey !== $meta_key){
|
655 |
-
if($plg === $mseo || is_plugin_active($plg)){
|
656 |
-
update_post_meta($object_id, $mkey, $meta_value);
|
657 |
-
}
|
658 |
-
}
|
659 |
-
}
|
660 |
-
}
|
661 |
-
}
|
662 |
-
|
663 |
-
return null;
|
664 |
-
}
|
665 |
-
|
666 |
-
public static function is_updateSync($meta_key){
|
667 |
-
$mkey_prefix = array('_metaseo_', '_yoast_', '_aio');
|
668 |
-
foreach($mkey_prefix as $prefix){
|
669 |
-
if(strpos($meta_key, $prefix) === 0){
|
670 |
-
return true;
|
671 |
-
}
|
672 |
-
}
|
673 |
-
|
674 |
-
return false;
|
675 |
-
}
|
676 |
-
}
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Base class for displaying a list of posts/pages in an ajaxified HTML table.
|
|
|
4 |
*
|
5 |
*/
|
6 |
|
8 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
9 |
}
|
10 |
|
11 |
+
class MetaSeo_Content_List_Table extends WP_List_Table {
|
12 |
+
public $post_types;
|
13 |
+
function __construct() {
|
14 |
parent::__construct(array(
|
15 |
'singular' => 'metaseo_content',
|
16 |
'plural' => 'metaseo_contents',
|
17 |
'ajax' => true
|
18 |
));
|
|
|
19 |
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Generate the table navigation above or below the table
|
23 |
+
* @param string $which
|
24 |
+
*/
|
25 |
function display_tablenav($which) {
|
26 |
?>
|
27 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
28 |
+
|
|
|
29 |
<input type="hidden" name="page" value="metaseo_content_meta" />
|
|
|
|
|
30 |
<input type="hidden" name="page" value="metaseo_content_meta" />
|
31 |
<?php if (!empty($_REQUEST['post_status'])): ?>
|
32 |
+
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
33 |
<?php endif ?>
|
34 |
+
|
35 |
<?php $this->extra_tablenav($which); ?>
|
36 |
+
|
37 |
+
<div style="float:right;margin-left:8px;">
|
38 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_posts_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
39 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
40 |
</div>
|
41 |
+
|
42 |
+
<?php $this->pagination($which); ?>
|
43 |
<br class="clear" />
|
44 |
</div>
|
45 |
|
46 |
<?php
|
47 |
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get an associative array ( id => link ) with the list
|
51 |
+
* of views available on this table.
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
function get_views() {
|
55 |
global $wpdb;
|
56 |
|
93 |
|
94 |
return $status_links;
|
95 |
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Extra controls to be displayed between bulk actions and pagination
|
99 |
+
* @param string $which
|
100 |
+
*/
|
101 |
function extra_tablenav($which) {
|
102 |
+
echo '<div class="alignleft actions">';
|
103 |
+
$selected = !empty($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : -1;
|
|
|
|
|
|
|
|
|
104 |
|
105 |
+
$options = '<option value="-1">Show All Post Types</option>';
|
|
|
|
|
106 |
|
107 |
+
foreach ($this->post_types as $post_type) {
|
108 |
+
$obj = get_post_type_object($post_type->post_type);
|
109 |
+
$options .= sprintf('<option value="%2$s" %3$s>%1$s</option>', $obj->labels->name, $post_type->post_type, selected($selected, $post_type->post_type, false));
|
110 |
+
}
|
111 |
|
112 |
+
$sl_bulk = '<select name="mbulk_copy" class="mbulk_copy"><option value="0">' . __('Bulk copy', 'wp-meta-seo') . '</option><option value="all">' . __('All Posts', 'wp-meta-seo') . '</option><option value="bulk-copy-metatitle">' . __('Selected posts', 'wp-meta-seo') . '</option></select>';
|
113 |
+
$btn_bulk = '<input type="button" name="do_copy" id="post_do_copy" class="button button-primary btn_do_copy post_do_copy" value="' . __('Content title as meta title', 'wp-meta-seo') . '"><span class="spinner"></span>';
|
114 |
|
115 |
+
echo sprintf('<select name="post_type_filter" class="metaseo-filter">%1$s</select>', $options);
|
116 |
+
submit_button(__('Filter'), 'button', 'do_filter', false, array('id' => 'post-query-submit'));
|
117 |
+
echo $sl_bulk . $btn_bulk;
|
118 |
+
echo "</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get a list of columns. The format is:
|
123 |
+
* 'internal-name' => 'Title'
|
124 |
+
* @return array
|
125 |
+
*/
|
126 |
function get_columns() {
|
127 |
+
$preview = __(" This is a rendering of what this post might look like in Google's search results.", 'wp-meta-seo');
|
128 |
$info = sprintf('<a class="info-content"><img src=' . WPMETASEO_PLUGIN_URL . 'img/info.png>'
|
129 |
+
. '<p class="tooltip-metacontent">'
|
130 |
+
. $preview
|
131 |
+
. '</p></a>');
|
132 |
+
|
133 |
$columns = array(
|
134 |
'cb' => '<input id="cb-select-all-1" type="checkbox" style="margin:0">',
|
135 |
'col_id' => __('', 'wp-meta-seo'),
|
136 |
'col_title' => __('Title', 'wp-meta-seo'),
|
137 |
+
'col_snippet' => sprintf(__('Snippet Preview %s', 'wp-meta-seo'), $info),
|
138 |
'col_meta_title' => __('Meta Title', 'wp-meta-seo'),
|
139 |
);
|
140 |
+
|
141 |
+
$settings = get_option('_metaseo_settings');
|
142 |
+
if (isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1) {
|
143 |
$columns['col_meta_keywords'] = __('Meta Keywords', 'wp-meta-seo');
|
144 |
}
|
145 |
$columns['col_meta_desc'] = __('Meta Description', 'wp-meta-seo');
|
146 |
+
$settings = get_option('_metaseo_settings');
|
147 |
+
if (!empty($settings['metaseo_follow'])) {
|
148 |
$columns['col_follow'] = __('Follow', 'wp-meta-seo');
|
149 |
}
|
150 |
+
|
151 |
+
if (!empty($settings['metaseo_index'])) {
|
152 |
$columns['col_index'] = __('Index', 'wp-meta-seo');
|
153 |
}
|
154 |
+
|
155 |
return $columns;
|
156 |
}
|
157 |
|
158 |
+
/**
|
159 |
+
* Get a list of sortable columns. The format is:
|
160 |
+
* 'internal-name' => 'orderby'
|
161 |
+
* or
|
162 |
+
* 'internal-name' => array( 'orderby', true )
|
163 |
+
*
|
164 |
+
* The second format will make the initial sorting order be descending
|
165 |
+
* @return array
|
166 |
+
*/
|
167 |
function get_sortable_columns() {
|
168 |
return $sortable = array(
|
169 |
'col_title' => array('post_title', true),
|
170 |
);
|
171 |
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Get a list of all registered post type objects.
|
175 |
+
*/
|
176 |
+
function wpmf_get_post_type(){
|
177 |
+
global $wpdb;
|
178 |
+
|
179 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
180 |
+
$post_types = "'" . implode("', '", esc_sql($post_types)) . "'";
|
181 |
+
|
182 |
+
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
183 |
+
$states['trash'] = 'trash';
|
184 |
+
$all_states = "'" . implode("', '", esc_sql($states)) . "'";
|
185 |
+
|
186 |
+
$query = "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types) ORDER BY 'post_type' ASC";
|
187 |
+
$post_types = $wpdb->get_results($query);
|
188 |
+
return $post_types;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Prepares the list of items for displaying.
|
193 |
+
* @uses WP_List_Table::set_pagination_args()
|
194 |
+
*/
|
195 |
function prepare_items() {
|
196 |
global $wpdb, $_wp_column_headers;
|
197 |
+
$this->post_types = $this->wpmf_get_post_type();
|
|
|
198 |
$screen = get_current_screen();
|
199 |
|
200 |
$where = array();
|
201 |
+
$post_type = isset($_REQUEST['post_type_filter']) ? $_REQUEST['post_type_filter'] : "";
|
202 |
+
if ($post_type == "-1") {
|
203 |
+
$post_type = "";
|
204 |
}
|
205 |
+
|
206 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
207 |
+
if (!empty($post_type) && !in_array($post_type, $post_types))
|
208 |
$post_type = '\'post\'';
|
209 |
+
else if (empty($post_type)) {
|
210 |
+
$post_type = "'" . implode("', '", esc_sql($post_types)) . "'";
|
211 |
+
} else {
|
212 |
+
$post_type = "'" . $post_type . "'";
|
213 |
+
}
|
214 |
+
$where[] = "post_type IN ($post_type)";
|
215 |
+
|
216 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
217 |
$states['trash'] = 'trash';
|
218 |
$all_states = "'" . implode("', '", $states) . "'";
|
219 |
|
220 |
if (empty($_REQUEST['post_status'])) {
|
221 |
+
$where[] = "post_status IN ($all_states)";
|
222 |
} else {
|
223 |
$requested_state = $_REQUEST['post_status'];
|
224 |
+
if (in_array($requested_state, $states)) {
|
225 |
+
$where[] = "post_status IN ('$requested_state')";
|
226 |
} else {
|
227 |
+
$where[] = "post_status IN ($all_states)";
|
228 |
}
|
229 |
}
|
230 |
+
|
231 |
$keyword = !empty($_GET["s"]) ? $_GET["s"] : '';
|
232 |
if (isset($keyword) && $keyword != '') {
|
233 |
+
$where[] .= '(post_title LIKE "%' . $keyword . '%" OR mt.meta_value LIKE "%' . $keyword . '%" OR md.meta_value LIKE "%' . $keyword . '%")';
|
234 |
}
|
235 |
+
|
236 |
//Order By block
|
237 |
$orderby = !empty($_GET["orderby"]) ? ($_GET["orderby"]) : 'post_title';
|
238 |
$order = !empty($_GET["order"]) ? ($_GET["order"]) : 'asc';
|
239 |
+
|
240 |
$sortable = $this->get_sortable_columns();
|
241 |
+
if (in_array($orderby, $sortable)) {
|
242 |
$orderStr = $orderby;
|
243 |
+
} else {
|
244 |
$orderStr = 'post_title';
|
245 |
}
|
246 |
|
247 |
+
if ($order == "asc") {
|
248 |
$orderStr .= " ASC";
|
249 |
+
} else {
|
250 |
$orderStr .= " DESC";
|
251 |
}
|
252 |
|
253 |
if (!empty($orderby) & !empty($order)) {
|
254 |
+
$orderStr = $wpdb->prepare(' ORDER BY %s ', $orderStr);
|
255 |
+
$orderStr = str_replace("'", "", $orderStr);
|
256 |
}
|
257 |
|
258 |
+
$query = "SELECT COUNT(ID) "
|
259 |
. " FROM $wpdb->posts "
|
260 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metatitle') mt ON mt.post_id = $wpdb->posts.ID "
|
261 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metadesc') md ON md.post_id = $wpdb->posts.ID "
|
262 |
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metakeywords') mk ON mk.post_id = $wpdb->posts.ID "
|
263 |
+
. " WHERE " . implode(' AND ', $where) . $orderStr;
|
264 |
|
265 |
+
$total_items = $wpdb->get_var($query);
|
266 |
|
267 |
+
$query = "SELECT ID, post_title, post_name, post_type, post_status , mt.meta_value AS metatitle, md.meta_value AS metadesc ,mk.meta_value AS metakeywords "
|
268 |
+
. " FROM $wpdb->posts "
|
269 |
+
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metatitle') mt ON mt.post_id = $wpdb->posts.ID "
|
270 |
+
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metadesc') md ON md.post_id = $wpdb->posts.ID "
|
271 |
+
. " LEFT JOIN (SELECT * FROM $wpdb->postmeta WHERE meta_key = '_metaseo_metakeywords') mk ON mk.post_id = $wpdb->posts.ID "
|
272 |
+
. " WHERE " . implode(' AND ', $where) . $orderStr;
|
273 |
+
if (!empty($_REQUEST['metaseo_posts_per_page'])) {
|
274 |
+
$_per_page = intval($_REQUEST['metaseo_posts_per_page']);
|
275 |
+
} else {
|
276 |
+
$_per_page = 0;
|
277 |
+
}
|
278 |
+
$per_page = get_user_option('metaseo_posts_per_page');
|
279 |
+
if ($per_page !== false) {
|
280 |
+
if ($_per_page && $_per_page !== $per_page) {
|
281 |
+
$per_page = $_per_page;
|
282 |
+
update_user_option(get_current_user_id(), 'metaseo_posts_per_page', $per_page);
|
283 |
}
|
284 |
+
} else {
|
285 |
+
if ($_per_page > 0) {
|
286 |
+
$per_page = $_per_page;
|
287 |
+
} else {
|
288 |
+
$per_page = 10;
|
289 |
+
}
|
290 |
+
add_user_meta(get_current_user_id(), 'metaseo_posts_per_page', $per_page);
|
291 |
+
}
|
292 |
|
293 |
$paged = !empty($_GET["paged"]) ? $_GET["paged"] : '';
|
294 |
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
|
315 |
|
316 |
$this->items = $wpdb->get_results($query);
|
317 |
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Generate the table rows
|
321 |
+
*/
|
322 |
function display_rows() {
|
323 |
$records = $this->items;
|
324 |
$i = 0;
|
325 |
$alternate = "";
|
326 |
+
$url = preg_replace('/(http|https):\/\/[w]*[.]?/', '', network_site_url('/'));
|
327 |
|
328 |
list( $columns, $hidden ) = $this->get_column_info();
|
329 |
+
|
330 |
if (!empty($records)) {
|
331 |
foreach ($records as $rec) {
|
332 |
$alternate = 'alternate' == $alternate ? '' : 'alternate';
|
333 |
$i++;
|
334 |
$classes = $alternate;
|
335 |
+
$rec->link = $url;
|
336 |
|
337 |
echo '<tr id="record_' . $rec->ID . '" class="' . $classes . '" >';
|
338 |
|
350 |
switch ($column_name) {
|
351 |
case 'cb':
|
352 |
echo '<th scope="row" class="check-column">';
|
353 |
+
echo '<input id="cb-select-' . $rec->ID . '" class="metaseo_post" type="checkbox" name="post[]" value="' . $rec->ID . '">';
|
354 |
echo '</th>';
|
355 |
|
356 |
break;
|
357 |
+
|
358 |
case 'col_id':
|
359 |
echo '<td class="col_id" >';
|
360 |
echo $i;
|
364 |
|
365 |
case 'col_title':
|
366 |
$post_title = stripslashes($rec->post_title);
|
367 |
+
if ($post_title == '')
|
368 |
+
$post_title = __('(no title)', 'wp-meta-seo');
|
369 |
+
echo sprintf('<td %2$s><div class="action-wrapper"><strong id="post-title-' . $rec->ID . '">%1$s</strong>', $post_title, $attributes);
|
370 |
+
|
371 |
$post_type_object = get_post_type_object($rec->post_type);
|
372 |
$can_edit_post = current_user_can($post_type_object->cap->edit_post, $rec->ID);
|
373 |
|
388 |
|
389 |
echo $this->row_actions($actions);
|
390 |
echo '</div></td>';
|
391 |
+
|
392 |
break;
|
393 |
+
|
394 |
case 'col_snippet':
|
395 |
echo '<td><div class="snippet-wrapper">';
|
396 |
echo '<div class="snippet">
|
399 |
echo '<span class="snippet_metalink" id="snippet_metalink_' . $rec->ID . '">' . $rec->link . '</span>';
|
400 |
|
401 |
echo '<p id="snippet_desc' . $rec->ID . '" class="snippet_metades">' . $rec->metadesc . '</p></div>';
|
402 |
+
echo '<img class="wpms_loader' . $rec->ID . ' wpms_content_loader" src=' . WPMETASEO_PLUGIN_URL . 'img/update_loading.gif>';
|
403 |
echo '<span id="savedInfo' . $rec->ID . '" style="position: relative; display: block;float:right" class="saved-info metaseo-msg-success"><span style="position:absolute; float:right" class="meta-update"></span></span>';
|
404 |
echo '</div></td>';
|
405 |
break;
|
410 |
break;
|
411 |
|
412 |
case 'col_meta_title':
|
413 |
+
$input = sprintf('</br><textarea class="large-text metaseo-metatitle" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metatitle-' . $rec->ID, 'metatitle[' . $rec->ID . ']', ( ($rec->metatitle ) ? $rec->metatitle : ''));
|
414 |
$input .= sprintf('<div class="title-len" id="%1$s"></div>', 'metaseo-metatitle-len' . $rec->ID);
|
415 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
416 |
break;
|
417 |
+
|
418 |
case 'col_meta_keywords':
|
419 |
+
$input = sprintf('</br><textarea class="large-text metaseo-metakeywords" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metakeywords-' . $rec->ID, 'metakeywords[' . $rec->ID . ']', ( ($rec->metakeywords ) ? $rec->metakeywords : ''));
|
420 |
$input .= sprintf('<div class="keywords-len" id="%1$s"></div>', 'metaseo-metakeywords-len' . $rec->ID);
|
421 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
422 |
break;
|
423 |
|
424 |
case 'col_meta_desc':
|
425 |
+
$input = sprintf('</br><textarea class="large-text metaseo-metadesc" rows="3" id="%1$s" name="%2$s" autocomplete="off">%3$s</textarea>', 'metaseo-metadesc-' . $rec->ID, ' metades[' . $rec->ID . ']', (($rec->metadesc ) ? $rec->metadesc : ''));
|
426 |
$input .= sprintf('<div class="desc-len" id="%1$s"></div>', 'metaseo-metadesc-len' . $rec->ID);
|
427 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
428 |
break;
|
429 |
+
|
430 |
case 'col_index':
|
431 |
+
$page_index = get_post_meta($rec->ID, '_metaseo_metaindex', true);
|
432 |
+
if (isset($page_index) && $page_index == 'noindex') {
|
433 |
+
$input = '<input class="metaseo_post_index" name="index[]" type="checkbox" value="' . $rec->ID . '">';
|
434 |
+
} else {
|
435 |
+
$input = '<input checked class="metaseo_post_index" name="index[]" type="checkbox" value="' . $rec->ID . '">';
|
436 |
}
|
437 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
438 |
break;
|
439 |
+
|
440 |
case 'col_follow':
|
441 |
+
$page_follow = get_post_meta($rec->ID, '_metaseo_metafollow', true);
|
442 |
+
if (isset($page_follow) && $page_follow == 'nofollow') {
|
443 |
+
$input = '<input class="metaseo_post_follow" name="follow[]" type="checkbox" value="' . $rec->ID . '">';
|
444 |
+
} else {
|
445 |
+
$input = '<input checked class="metaseo_post_follow" name="follow[]" type="checkbox" value="' . $rec->ID . '">';
|
446 |
}
|
447 |
echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
|
448 |
break;
|
458 |
$actions = array();
|
459 |
$actions = array(
|
460 |
'update' => 'Update',
|
461 |
+
);
|
462 |
|
463 |
return $actions;
|
464 |
}
|
465 |
|
466 |
+
/*
|
467 |
+
* Retrieves a modified URL query string.
|
468 |
+
*/
|
469 |
function process_action() {
|
470 |
+
|
471 |
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
472 |
+
$redirect = false;
|
473 |
+
|
474 |
if (isset($_POST['do_filter']) and $_POST['do_filter'] === __('Filter')) {
|
475 |
+
$current_url = add_query_arg(array("post_type_filter" => $_POST['post_type_filter']), $current_url);
|
476 |
+
$redirect = true;
|
477 |
+
}
|
478 |
+
|
479 |
+
if (!empty($_POST['paged'])) {
|
480 |
+
$current_url = add_query_arg(array("paged" => intval($_POST['paged'])), $current_url);
|
481 |
+
$redirect = true;
|
482 |
+
}
|
483 |
+
|
484 |
+
if (!empty($_POST['metaseo_posts_per_page'])) {
|
485 |
+
$current_url = add_query_arg(array("metaseo_posts_per_page" => intval($_POST['metaseo_posts_per_page'])), $current_url);
|
486 |
+
$redirect = true;
|
487 |
+
}
|
488 |
+
|
489 |
+
if (isset($_POST['s'])) {
|
490 |
+
$current_url = add_query_arg(array("s" => urlencode($_POST['s'])), $current_url);
|
491 |
+
$redirect = true;
|
492 |
+
}
|
493 |
+
|
494 |
+
if ($redirect === true) {
|
495 |
+
wp_redirect($current_url);
|
496 |
+
ob_end_flush();
|
497 |
+
exit();
|
498 |
+
}
|
499 |
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Get all posts that is public and contain images with a string seperated by comma
|
503 |
+
*/
|
504 |
+
public static function get_post_types() {
|
505 |
+
global $wpdb;
|
506 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
507 |
+
if (!empty($post_types)) {
|
508 |
+
$post_types = "'" . implode("', '", $post_types) . "'";
|
509 |
+
}
|
510 |
+
|
511 |
+
return $post_types;
|
512 |
+
}
|
513 |
+
|
514 |
+
/* import meta from other plugin */
|
515 |
+
public static function importMetaData() {
|
516 |
+
global $wpdb;
|
517 |
+
$meta_metaseo_keys = array('_metaseo_metatitle', '_metaseo_metadesc');
|
518 |
+
$meta_other_keys = array(
|
519 |
+
'_aio_' => array('_aioseop_title', '_aioseop_description'),
|
520 |
+
'_yoast_' => array('_yoast_wpseo_title', '_yoast_wpseo_metadesc')
|
521 |
+
);
|
522 |
+
|
523 |
+
if (!empty($_POST['plugin']) and in_array(strtolower(trim($_POST['plugin'])), array('_aio_', '_yoast_'))) {
|
524 |
+
$plugin = strtolower(trim($_POST['plugin']));
|
525 |
+
$metakeys = '';
|
526 |
+
foreach ($meta_metaseo_keys as $k => $mkey) {
|
527 |
+
$metakeys .= ' OR `meta_key` = \'' . $mkey . '\' OR `meta_key` = \'' . $meta_other_keys[$plugin][$k] . '\'';
|
528 |
+
}
|
529 |
+
|
530 |
+
$metakeys = ltrim($metakeys, ' OR ');
|
531 |
+
$query = "SELECT `post_id` as pID, `meta_key`, `meta_value`
|
532 |
FROM $wpdb->postmeta
|
533 |
WHERE $metakeys
|
534 |
ORDER BY `meta_key`";
|
535 |
+
$posts_metas = $wpdb->get_results($query);
|
536 |
+
|
537 |
+
if (is_array($posts_metas) && count($posts_metas) > 0) {
|
538 |
+
foreach ($posts_metas as $postmeta) {
|
539 |
+
$_posts_metas[$postmeta->pID][$postmeta->meta_key] = $postmeta->meta_value;
|
540 |
+
}
|
541 |
+
unset($posts_metas);
|
542 |
+
foreach ($_posts_metas as $pID => $pmeta) {
|
543 |
+
foreach ($meta_metaseo_keys as $k => $mkey) {
|
544 |
+
$mvalue = $pmeta[$mkey];
|
545 |
+
$msynckey = $meta_other_keys[$plugin][$k];
|
546 |
+
$msyncvalue = $pmeta[$msynckey];
|
547 |
+
|
548 |
+
if (is_null($mvalue) || ( $mvalue == '' && $msynckey != '' )) {
|
549 |
+
update_post_meta($pID, $mkey, $msyncvalue);
|
550 |
+
} elseif (is_null($msyncvalue) || ( $msyncvalue == '' && $mvalue != '' )) {
|
551 |
+
update_post_meta($pID, $msynckey, $mvalue);
|
552 |
+
} elseif ($mvalue != '' && $msyncvalue != '') {
|
553 |
+
update_post_meta($pID, $mkey, $msyncvalue);
|
554 |
+
}
|
555 |
+
}
|
556 |
+
}
|
557 |
+
|
558 |
+
unset($posts_metas);
|
559 |
+
}
|
560 |
+
|
561 |
+
|
562 |
+
$ret['success'] = true;
|
563 |
+
|
564 |
+
update_option('_aio_import_notice_flag', 1);
|
565 |
+
update_option('_yoast_import_notice_flag', 1);
|
566 |
+
update_option('plugin_to_sync_with', $plugin);
|
567 |
+
} else {
|
568 |
+
$ret['success'] = false;
|
569 |
+
}
|
570 |
+
|
571 |
+
echo json_encode($ret);
|
572 |
+
wp_die();
|
573 |
+
}
|
574 |
+
|
575 |
+
/*
|
576 |
+
* Dismiss import message
|
577 |
+
*/
|
578 |
+
public static function dismissImport() {
|
579 |
+
if (!empty($_POST['plugin']) and in_array(strtolower(trim($_POST['plugin'])), array('_aio_', '_yoast_'))) {
|
580 |
+
$plugin = strtolower(trim($_POST['plugin']));
|
581 |
+
|
582 |
+
update_option($plugin . 'import_notice_flag', 1);
|
583 |
+
$ret['success'] = true;
|
584 |
+
} else {
|
585 |
+
$ret['success'] = false;
|
586 |
+
}
|
587 |
+
|
588 |
+
echo json_encode($ret);
|
589 |
+
wp_die();
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
+
* Update meta sync
|
594 |
+
*/
|
595 |
+
public static function updateMetaSync($meta_id, $object_id, $meta_key, $meta_value) {
|
596 |
+
if (!self::is_updateSync($meta_key)) {
|
597 |
+
return null;
|
598 |
+
}
|
599 |
+
|
600 |
+
if (self::_updateMetaSync('update', $object_id, $meta_key, $meta_value)) {
|
601 |
+
return true;
|
602 |
+
}
|
603 |
+
|
604 |
+
return null;
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* deletes all custom fields with the specified key
|
609 |
+
*/
|
610 |
+
public static function deleteMetaSync($meta_ids, $object_id, $meta_key, $meta_value) {
|
611 |
+
|
612 |
+
if (!self::is_updateSync($meta_key)) {
|
613 |
+
return null;
|
614 |
+
}
|
615 |
+
|
616 |
+
if (self::_updateMetaSync('delete', $object_id, $meta_key, $meta_value)) {
|
617 |
+
return true;
|
618 |
+
}
|
619 |
+
|
620 |
+
return null;
|
621 |
+
}
|
622 |
+
|
623 |
+
/**
|
624 |
+
* Update meta sync
|
625 |
+
*/
|
626 |
+
private static function _updateMetaSync($type = '', $object_id, $meta_key, $meta_value) {
|
627 |
+
if (!( $sync = get_option('plugin_to_sync_with') ) or ! in_array($sync, array('_aio_', '_yoast_'))) {
|
628 |
+
return false;
|
629 |
+
}
|
630 |
+
|
631 |
+
$metakeys = array(
|
632 |
+
'_metaseo_' => array('_metaseo_metatitle', '_metaseo_metadesc'),
|
633 |
+
'_aio_' => array('_aioseop_title', '_aioseop_description'),
|
634 |
+
'_yoast_' => array('_yoast_wpseo_title', '_yoast_wpseo_metadesc')
|
635 |
+
);
|
636 |
+
|
637 |
+
$_metakeys = array();
|
638 |
+
$_metakeys['_metaseo_'] = $metakeys['_metaseo_'];
|
639 |
+
$_metakeys[$sync] = $metakeys[$sync];
|
640 |
+
unset($metakeys);
|
641 |
+
|
642 |
+
foreach ($_metakeys as $identify => $mkeys) {
|
643 |
+
foreach ($mkeys as $k => $mkey) {
|
644 |
+
if ($meta_key === $mkey) {
|
645 |
+
if ($identify === '_metaseo_') {
|
646 |
+
$mkeysync = $_metakeys[$sync][$k];
|
647 |
+
} else {
|
648 |
+
$mkeysync = $_metakeys['_metaseo_'][$k];
|
649 |
+
}
|
650 |
+
|
651 |
+
if ($type == 'update') {
|
652 |
+
update_post_meta($object_id, $mkeysync, $meta_value);
|
653 |
+
return true;
|
654 |
+
}
|
655 |
+
|
656 |
+
if ($type == 'delete') {
|
657 |
+
delete_post_meta($object_id, $mkeysync);
|
658 |
+
return true;
|
659 |
+
}
|
660 |
+
}
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
return false;
|
665 |
+
}
|
666 |
+
|
667 |
+
public static function is_updateSync($meta_key) {
|
668 |
+
$mkey_prefix = array('_metaseo_', '_yoast_', '_aio');
|
669 |
+
foreach ($mkey_prefix as $prefix) {
|
670 |
+
if (strpos($meta_key, $prefix) === 0) {
|
671 |
+
return true;
|
672 |
+
}
|
673 |
+
}
|
674 |
+
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
|
678 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/class.metaseo-dashboard.php
CHANGED
@@ -1,15 +1,13 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/*
|
4 |
-
*
|
5 |
-
*
|
6 |
*
|
7 |
*/
|
8 |
|
9 |
class MetaSeo_Dashboard {
|
|
|
10 |
public static $meta_title_length = 69;
|
11 |
public static $meta_desc_length = 156;
|
12 |
-
|
13 |
public static $metatitle_filled = 0;
|
14 |
public static $metadesc_filled = 0;
|
15 |
public static $imageresizing_filled = 0;
|
@@ -21,11 +19,12 @@ class MetaSeo_Dashboard {
|
|
21 |
public static $mlink_complete = 0;
|
22 |
public static $mcount_link = 0;
|
23 |
|
24 |
-
|
|
|
|
|
25 |
public static function moptimizationChecking() {
|
26 |
global $wpdb;
|
27 |
$imgs = 0;
|
28 |
-
#$imgs_metas = 0;
|
29 |
$imgs_metas = array('alt' => 0, 'title' => 0);
|
30 |
$imgs_are_good = 0;
|
31 |
$imgs_metas_are_good = array();
|
@@ -50,12 +49,13 @@ class MetaSeo_Dashboard {
|
|
50 |
$posts = $wpdb->get_results($query);
|
51 |
if (count($posts) > 0) {
|
52 |
$doc = new DOMDocument();
|
53 |
-
libxml_use_internal_errors(
|
54 |
$upload_dir = wp_upload_dir();
|
55 |
|
56 |
foreach ($posts as $post) {
|
57 |
-
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis',true);
|
58 |
-
if(empty($meta_analysis))
|
|
|
59 |
$dom = $doc->loadHTML($post->post_content);
|
60 |
$tags = $doc->getElementsByTagName('img');
|
61 |
foreach ($tags as $tag) {
|
@@ -98,7 +98,7 @@ class MetaSeo_Dashboard {
|
|
98 |
$imgs++;
|
99 |
}
|
100 |
}
|
101 |
-
|
102 |
//Report analytic of images optimization
|
103 |
$response['imgs_statis'][0] = $imgs_are_good;
|
104 |
$response['imgs_statis'][1] = $imgs;
|
@@ -109,6 +109,9 @@ class MetaSeo_Dashboard {
|
|
109 |
return $response;
|
110 |
}
|
111 |
|
|
|
|
|
|
|
112 |
public function displayRank($url) {
|
113 |
$rank = $this->getRank($url);
|
114 |
if ($rank !== '') {
|
@@ -117,7 +120,10 @@ class MetaSeo_Dashboard {
|
|
117 |
echo __('We can\'t get rank of this site from Alexa.com!', 'wp-meta-seo');
|
118 |
}
|
119 |
}
|
120 |
-
|
|
|
|
|
|
|
121 |
public function getRank($url) {
|
122 |
if (!function_exists('curl_version')) {
|
123 |
if (!$content = @file_get_contents($url)) {
|
@@ -130,9 +136,9 @@ class MetaSeo_Dashboard {
|
|
130 |
$contents = $this->get_contents($url);
|
131 |
$content = $contents[0];
|
132 |
}
|
133 |
-
|
134 |
$doc = new DOMDocument();
|
135 |
-
libxml_use_internal_errors(
|
136 |
@$doc->loadHTML($content);
|
137 |
$doc->preserveWhiteSpace = false;
|
138 |
|
@@ -150,12 +156,15 @@ class MetaSeo_Dashboard {
|
|
150 |
}
|
151 |
|
152 |
$html = trim($tmp_dom->saveHTML());
|
153 |
-
$html = str_replace('We don\'t have', __('Alexa doesn\'t have','wp-meta-seo'), $html);
|
154 |
$html = str_replace('Get Certified', '', $html);
|
155 |
$html = str_replace('"/topsites/countries', '"http://www.alexa.com/topsites/countries', $html);
|
156 |
return $html;
|
157 |
}
|
158 |
-
|
|
|
|
|
|
|
159 |
public function get_contents($urls) {
|
160 |
$mh = curl_multi_init();
|
161 |
$curl_array = array();
|
@@ -165,7 +174,6 @@ class MetaSeo_Dashboard {
|
|
165 |
curl_setopt($curl_array[$i], CURLOPT_URL, $url);
|
166 |
curl_setopt($curl_array[$i], CURLOPT_USERAGENT, $useragent); // set user agent
|
167 |
curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, TRUE);
|
168 |
-
//curl_setopt($curl_array[$i], CURLOPT_FOLLOWLOCATION, TRUE);
|
169 |
curl_setopt($curl_array[$i], CURLOPT_CONNECTTIMEOUT, 5);
|
170 |
curl_setopt($curl_array[$i], CURLOPT_ENCODING, "UTF-8");
|
171 |
curl_multi_add_handle($mh, $curl_array[$i]);
|
@@ -189,151 +197,165 @@ class MetaSeo_Dashboard {
|
|
189 |
curl_multi_close($mh);
|
190 |
return $contents;
|
191 |
}
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
197 |
$args = array(
|
198 |
-
'posts_per_page'
|
199 |
-
'post_type'
|
200 |
-
'suppress_filters' => true
|
201 |
);
|
202 |
-
$mposts = get_posts(
|
203 |
-
if(empty($mposts)){
|
204 |
return $results;
|
205 |
-
}else{
|
206 |
-
foreach ($mposts as $post){
|
207 |
-
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis',true);
|
208 |
-
if(empty($meta_analysis))
|
|
|
209 |
|
210 |
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
|
211 |
$meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
|
212 |
-
if(($meta_title != '' && strlen($meta_title) <= self::$meta_title_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle']))){
|
213 |
self::$metatitle_filled++;
|
214 |
}
|
215 |
-
|
216 |
-
if(($meta_desc != '' && strlen($meta_desc) <= self::$meta_desc_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc']))
|
217 |
self::$metadesc_filled++;
|
218 |
}
|
219 |
-
|
220 |
// get link meta
|
221 |
-
|
222 |
$dom = new DOMDocument;
|
223 |
-
libxml_use_internal_errors(
|
224 |
-
if(isset($post->post_content) && $post->post_content != ''){
|
225 |
if ($dom->loadHTML($post->post_content)) {
|
226 |
$tags = $dom->getElementsByTagName('a');
|
227 |
-
foreach ($tags as $tag){
|
228 |
self::$mcount_link++;
|
229 |
$link_title = $tag->getAttribute('title');
|
230 |
-
if(isset($link_title) && $link_title != ''){
|
231 |
self::$mlink_complete++;
|
232 |
}
|
233 |
}
|
234 |
-
|
235 |
}
|
236 |
}
|
237 |
}
|
238 |
-
|
239 |
-
if(self::$mcount_link == 0){
|
240 |
$link_percent = 100;
|
241 |
-
}else{
|
242 |
-
$link_percent = ceil(self::$mlink_complete / self::$mcount_link*100);
|
243 |
}
|
244 |
-
|
245 |
-
$results['metatitle_filled'] = array(ceil(self::$metatitle_filled/(count($mposts))*100)
|
246 |
-
$results['metadesc_filled'] = array(ceil(self::$metadesc_filled/(count($mposts))*100)
|
247 |
-
$results['link_meta'] = array($link_percent
|
248 |
}
|
249 |
-
|
250 |
-
$permalink_structure
|
251 |
-
if(strpos($permalink_structure, 'postname') == false && strpos($permalink_structure, 'category') == false){
|
252 |
self::$mpermalink = 0;
|
253 |
-
}else if(strpos($permalink_structure, 'postname') == true && strpos($permalink_structure, 'category') == true){
|
254 |
self::$mpermalink = 100;
|
255 |
-
}else if(strpos($permalink_structure, 'postname') == true || strpos($permalink_structure, 'category') == true){
|
256 |
self::$mpermalink = 50;
|
257 |
}
|
258 |
-
|
259 |
$results['permalink_setting'] = self::$mpermalink;
|
260 |
$newcontent_args = array(
|
261 |
'date_query' => array(
|
262 |
array(
|
263 |
'column' => 'post_modified_gmt',
|
264 |
-
// 'before' => '1 month ago',
|
265 |
'after' => '30 days ago'
|
266 |
)
|
267 |
),
|
268 |
'posts_per_page' => -1,
|
269 |
-
'post_type'
|
270 |
);
|
271 |
-
|
272 |
-
$newcontent = new WP_Query(
|
273 |
-
|
274 |
-
if(count($newcontent->get_posts()) >= 4){
|
275 |
$count_new = 100;
|
276 |
-
}else{
|
277 |
-
$count_new = ceil(count($newcontent->get_posts()) / 4*100);
|
278 |
}
|
279 |
-
$results['new_content'] = array($count_new
|
280 |
return $results;
|
281 |
}
|
282 |
|
283 |
-
|
|
|
|
|
|
|
284 |
global $wpdb;
|
285 |
-
$sql = $wpdb->prepare(
|
286 |
$count_404 = $wpdb->get_var($sql);
|
287 |
-
|
288 |
-
$sql = $wpdb->prepare(
|
289 |
$count_404_redirected = $wpdb->get_var($sql);
|
290 |
-
if($count_404 != 0){
|
291 |
-
$percent = ceil($count_404_redirected
|
292 |
-
}else{
|
293 |
$percent = 100;
|
294 |
}
|
295 |
-
return array('count_404' => $count_404
|
296 |
}
|
297 |
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
301 |
$files = $wpdb->get_results($query);
|
302 |
$image_optimize = 0;
|
303 |
-
foreach ($files as $file){
|
304 |
-
if(file_exists(str_replace('/', DIRECTORY_SEPARATOR, ABSPATH . $file->file))){
|
305 |
$image_optimize++;
|
306 |
}
|
307 |
}
|
308 |
-
|
309 |
}
|
310 |
|
311 |
-
|
|
|
|
|
|
|
312 |
$wpio_settings = get_option('_wpio_settings');
|
313 |
$include_folders = $wpio_settings['wpio_api_include'];
|
314 |
-
|
315 |
-
|
316 |
$image_optimize = $this->wpmf_getImages_optimizer();
|
317 |
-
|
318 |
-
$allowed_ext = array('jpg','jpeg','jpe','gif','png','pdf');
|
319 |
-
$min_size = (int)$wpio_settings['wpio_api_minfilesize'] *1024;
|
320 |
-
$max_size = (int)$wpio_settings['wpio_api_maxfilesize'] *1024;
|
321 |
-
if($max_size==0)
|
|
|
322 |
$count_image = 0;
|
323 |
-
$scan_dir = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH)
|
324 |
-
foreach (new RecursiveIteratorIterator(new IgnorantRecursiveDirectoryIterator($scan_dir)) as $filename){
|
325 |
-
if(!in_array(strtolower(pathinfo($filename,PATHINFO_EXTENSION))
|
326 |
continue;
|
327 |
-
}
|
328 |
|
329 |
$count_image++;
|
330 |
}
|
331 |
-
|
332 |
-
if($count_image == 0){
|
333 |
$precent = 0;
|
334 |
-
}else{
|
335 |
-
$precent = ceil($image_optimize
|
336 |
}
|
337 |
-
return array('image_optimize' => $image_optimize, 'count_image' => $count_image
|
338 |
}
|
|
|
339 |
}
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
+
* This class implements the statistical criteria of Meta SEO
|
|
|
4 |
*
|
5 |
*/
|
6 |
|
7 |
class MetaSeo_Dashboard {
|
8 |
+
|
9 |
public static $meta_title_length = 69;
|
10 |
public static $meta_desc_length = 156;
|
|
|
11 |
public static $metatitle_filled = 0;
|
12 |
public static $metadesc_filled = 0;
|
13 |
public static $imageresizing_filled = 0;
|
19 |
public static $mlink_complete = 0;
|
20 |
public static $mcount_link = 0;
|
21 |
|
22 |
+
/*
|
23 |
+
* Get image optimize
|
24 |
+
*/
|
25 |
public static function moptimizationChecking() {
|
26 |
global $wpdb;
|
27 |
$imgs = 0;
|
|
|
28 |
$imgs_metas = array('alt' => 0, 'title' => 0);
|
29 |
$imgs_are_good = 0;
|
30 |
$imgs_metas_are_good = array();
|
49 |
$posts = $wpdb->get_results($query);
|
50 |
if (count($posts) > 0) {
|
51 |
$doc = new DOMDocument();
|
52 |
+
libxml_use_internal_errors(true);
|
53 |
$upload_dir = wp_upload_dir();
|
54 |
|
55 |
foreach ($posts as $post) {
|
56 |
+
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
|
57 |
+
if (empty($meta_analysis))
|
58 |
+
$meta_analysis = array();
|
59 |
$dom = $doc->loadHTML($post->post_content);
|
60 |
$tags = $doc->getElementsByTagName('img');
|
61 |
foreach ($tags as $tag) {
|
98 |
$imgs++;
|
99 |
}
|
100 |
}
|
101 |
+
|
102 |
//Report analytic of images optimization
|
103 |
$response['imgs_statis'][0] = $imgs_are_good;
|
104 |
$response['imgs_statis'][1] = $imgs;
|
109 |
return $response;
|
110 |
}
|
111 |
|
112 |
+
/*
|
113 |
+
* Display rank of site
|
114 |
+
*/
|
115 |
public function displayRank($url) {
|
116 |
$rank = $this->getRank($url);
|
117 |
if ($rank !== '') {
|
120 |
echo __('We can\'t get rank of this site from Alexa.com!', 'wp-meta-seo');
|
121 |
}
|
122 |
}
|
123 |
+
|
124 |
+
/*
|
125 |
+
* Get rank of site
|
126 |
+
*/
|
127 |
public function getRank($url) {
|
128 |
if (!function_exists('curl_version')) {
|
129 |
if (!$content = @file_get_contents($url)) {
|
136 |
$contents = $this->get_contents($url);
|
137 |
$content = $contents[0];
|
138 |
}
|
139 |
+
|
140 |
$doc = new DOMDocument();
|
141 |
+
libxml_use_internal_errors(true);
|
142 |
@$doc->loadHTML($content);
|
143 |
$doc->preserveWhiteSpace = false;
|
144 |
|
156 |
}
|
157 |
|
158 |
$html = trim($tmp_dom->saveHTML());
|
159 |
+
$html = str_replace('We don\'t have', __('Alexa doesn\'t have', 'wp-meta-seo'), $html);
|
160 |
$html = str_replace('Get Certified', '', $html);
|
161 |
$html = str_replace('"/topsites/countries', '"http://www.alexa.com/topsites/countries', $html);
|
162 |
return $html;
|
163 |
}
|
164 |
+
|
165 |
+
/*
|
166 |
+
* Get content a file
|
167 |
+
*/
|
168 |
public function get_contents($urls) {
|
169 |
$mh = curl_multi_init();
|
170 |
$curl_array = array();
|
174 |
curl_setopt($curl_array[$i], CURLOPT_URL, $url);
|
175 |
curl_setopt($curl_array[$i], CURLOPT_USERAGENT, $useragent); // set user agent
|
176 |
curl_setopt($curl_array[$i], CURLOPT_RETURNTRANSFER, TRUE);
|
|
|
177 |
curl_setopt($curl_array[$i], CURLOPT_CONNECTTIMEOUT, 5);
|
178 |
curl_setopt($curl_array[$i], CURLOPT_ENCODING, "UTF-8");
|
179 |
curl_multi_add_handle($mh, $curl_array[$i]);
|
197 |
curl_multi_close($mh);
|
198 |
return $contents;
|
199 |
}
|
200 |
+
|
201 |
+
/*
|
202 |
+
* Return params meta title filled , meta description filled , link_meta , permalink_setting for dashboard
|
203 |
+
*/
|
204 |
+
function evolutive_dashboard() {
|
205 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
206 |
+
if (!empty($post_types['attachment']))
|
207 |
+
unset($post_types['attachment']);
|
208 |
+
$results = array('permalink_setting' => 50, 'metatitle_filled' => array(0, array(0, 0)), 'metadesc_filled' => array(0, array(0, 0)), 'new_content' => array(0, array(0, 0)), 'link_meta' => array(0, array(0, 0)));
|
209 |
$args = array(
|
210 |
+
'posts_per_page' => -1,
|
211 |
+
'post_type' => $post_types,
|
212 |
+
'suppress_filters' => true
|
213 |
);
|
214 |
+
$mposts = get_posts($args);
|
215 |
+
if (empty($mposts)) {
|
216 |
return $results;
|
217 |
+
} else {
|
218 |
+
foreach ($mposts as $post) {
|
219 |
+
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
|
220 |
+
if (empty($meta_analysis))
|
221 |
+
$meta_analysis = array();
|
222 |
|
223 |
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
|
224 |
$meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
|
225 |
+
if (($meta_title != '' && strlen($meta_title) <= self::$meta_title_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle']))) {
|
226 |
self::$metatitle_filled++;
|
227 |
}
|
228 |
+
|
229 |
+
if (($meta_desc != '' && strlen($meta_desc) <= self::$meta_desc_length ) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc']))) {
|
230 |
self::$metadesc_filled++;
|
231 |
}
|
232 |
+
|
233 |
// get link meta
|
234 |
+
|
235 |
$dom = new DOMDocument;
|
236 |
+
libxml_use_internal_errors(true);
|
237 |
+
if (isset($post->post_content) && $post->post_content != '') {
|
238 |
if ($dom->loadHTML($post->post_content)) {
|
239 |
$tags = $dom->getElementsByTagName('a');
|
240 |
+
foreach ($tags as $tag) {
|
241 |
self::$mcount_link++;
|
242 |
$link_title = $tag->getAttribute('title');
|
243 |
+
if (isset($link_title) && $link_title != '') {
|
244 |
self::$mlink_complete++;
|
245 |
}
|
246 |
}
|
|
|
247 |
}
|
248 |
}
|
249 |
}
|
250 |
+
|
251 |
+
if (self::$mcount_link == 0) {
|
252 |
$link_percent = 100;
|
253 |
+
} else {
|
254 |
+
$link_percent = ceil(self::$mlink_complete / self::$mcount_link * 100);
|
255 |
}
|
256 |
+
|
257 |
+
$results['metatitle_filled'] = array(ceil(self::$metatitle_filled / (count($mposts)) * 100), array(self::$metatitle_filled, count($mposts)));
|
258 |
+
$results['metadesc_filled'] = array(ceil(self::$metadesc_filled / (count($mposts)) * 100), array(self::$metadesc_filled, count($mposts)));
|
259 |
+
$results['link_meta'] = array($link_percent, array(self::$mlink_complete, self::$mcount_link));
|
260 |
}
|
261 |
+
|
262 |
+
$permalink_structure = get_option('permalink_structure');
|
263 |
+
if (strpos($permalink_structure, 'postname') == false && strpos($permalink_structure, 'category') == false) {
|
264 |
self::$mpermalink = 0;
|
265 |
+
} else if (strpos($permalink_structure, 'postname') == true && strpos($permalink_structure, 'category') == true) {
|
266 |
self::$mpermalink = 100;
|
267 |
+
} else if (strpos($permalink_structure, 'postname') == true || strpos($permalink_structure, 'category') == true) {
|
268 |
self::$mpermalink = 50;
|
269 |
}
|
270 |
+
|
271 |
$results['permalink_setting'] = self::$mpermalink;
|
272 |
$newcontent_args = array(
|
273 |
'date_query' => array(
|
274 |
array(
|
275 |
'column' => 'post_modified_gmt',
|
|
|
276 |
'after' => '30 days ago'
|
277 |
)
|
278 |
),
|
279 |
'posts_per_page' => -1,
|
280 |
+
'post_type' => array('post', 'page'),
|
281 |
);
|
282 |
+
|
283 |
+
$newcontent = new WP_Query($newcontent_args);
|
284 |
+
|
285 |
+
if (count($newcontent->get_posts()) >= 4) {
|
286 |
$count_new = 100;
|
287 |
+
} else {
|
288 |
+
$count_new = ceil(count($newcontent->get_posts()) / 4 * 100);
|
289 |
}
|
290 |
+
$results['new_content'] = array($count_new, array(count($newcontent->get_posts()), count($mposts)));
|
291 |
return $results;
|
292 |
}
|
293 |
|
294 |
+
/*
|
295 |
+
* Return count link 404 , count link 404 is redirected , percent
|
296 |
+
*/
|
297 |
+
function get_404_link() {
|
298 |
global $wpdb;
|
299 |
+
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE (broken_internal=%d OR broken_indexed=%d) ", array(1, 1));
|
300 |
$count_404 = $wpdb->get_var($sql);
|
301 |
+
|
302 |
+
$sql = $wpdb->prepare("SELECT COUNT(*) FROM " . $wpdb->prefix . "wpms_links WHERE link_url_redirect != '' AND (broken_internal=%d OR broken_indexed=%d) ", array(1, 1));
|
303 |
$count_404_redirected = $wpdb->get_var($sql);
|
304 |
+
if ($count_404 != 0) {
|
305 |
+
$percent = ceil($count_404_redirected / $count_404 * 100);
|
306 |
+
} else {
|
307 |
$percent = 100;
|
308 |
}
|
309 |
+
return array('count_404' => $count_404, 'count_404_redirected' => $count_404_redirected, 'percent' => $percent);
|
310 |
}
|
311 |
|
312 |
+
/*
|
313 |
+
* Return count image is optimized
|
314 |
+
*/
|
315 |
+
public function wpmf_getImages_optimizer() {
|
316 |
+
global $wpdb;
|
317 |
+
$query = 'SELECT distinct file FROM ' . $wpdb->prefix . 'wpio_images';
|
318 |
$files = $wpdb->get_results($query);
|
319 |
$image_optimize = 0;
|
320 |
+
foreach ($files as $file) {
|
321 |
+
if (file_exists(str_replace('/', DIRECTORY_SEPARATOR, ABSPATH . $file->file))) {
|
322 |
$image_optimize++;
|
323 |
}
|
324 |
}
|
325 |
+
return $image_optimize;
|
326 |
}
|
327 |
|
328 |
+
/*
|
329 |
+
* Get count image
|
330 |
+
*/
|
331 |
+
public function wpmf_getImages_count() {
|
332 |
$wpio_settings = get_option('_wpio_settings');
|
333 |
$include_folders = $wpio_settings['wpio_api_include'];
|
334 |
+
$allowedPath = explode(',', $include_folders);
|
335 |
+
$images = array();
|
336 |
$image_optimize = $this->wpmf_getImages_optimizer();
|
337 |
+
|
338 |
+
$allowed_ext = array('jpg', 'jpeg', 'jpe', 'gif', 'png', 'pdf');
|
339 |
+
$min_size = (int) $wpio_settings['wpio_api_minfilesize'] * 1024;
|
340 |
+
$max_size = (int) $wpio_settings['wpio_api_maxfilesize'] * 1024;
|
341 |
+
if ($max_size == 0)
|
342 |
+
$max_size = 5 * 1024 * 1024;
|
343 |
$count_image = 0;
|
344 |
+
$scan_dir = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH);
|
345 |
+
foreach (new RecursiveIteratorIterator(new IgnorantRecursiveDirectoryIterator($scan_dir)) as $filename) {
|
346 |
+
if (!in_array(strtolower(pathinfo($filename, PATHINFO_EXTENSION)), $allowed_ext)) {
|
347 |
continue;
|
348 |
+
}
|
349 |
|
350 |
$count_image++;
|
351 |
}
|
352 |
+
|
353 |
+
if ($count_image == 0) {
|
354 |
$precent = 0;
|
355 |
+
} else {
|
356 |
+
$precent = ceil($image_optimize / $count_image * 100);
|
357 |
}
|
358 |
+
return array('image_optimize' => $image_optimize, 'count_image' => $count_image, 'percent' => $precent);
|
359 |
}
|
360 |
+
|
361 |
}
|
inc/class.metaseo-image-list-table.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
*/
|
7 |
|
@@ -9,12 +8,12 @@ if (!class_exists('WP_List_Table')) {
|
|
9 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
10 |
}
|
11 |
|
12 |
-
if (
|
13 |
require_once( 'class.image-helper.php' );
|
14 |
}
|
15 |
|
16 |
class MetaSeo_Image_List_Table extends WP_List_Table {
|
17 |
-
|
18 |
function __construct() {
|
19 |
parent::__construct(array(
|
20 |
'singular' => 'metaseo_image',
|
@@ -22,53 +21,60 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
22 |
'ajax' => true
|
23 |
));
|
24 |
}
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
function display_tablenav($which) {
|
27 |
-
|
28 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
29 |
|
30 |
-
<?php if($which=='top'):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
<?php elseif($which=='bottom')
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
<?php endif
|
41 |
-
|
42 |
<div class="alignleft">
|
43 |
<select name="image_mbulk_copy" class="mbulk_copy">
|
44 |
-
<option value="0"><?php _e('Bulk copy','wp-meta-seo') ?></option>
|
45 |
-
<option value="all"><?php _e('All Images','wp-meta-seo') ?></option>
|
46 |
-
<option value="bulk-copy-title-alt"><?php _e('Selected images','wp-meta-seo') ?></option>
|
47 |
</select>
|
48 |
-
<input type="button" name="image_do_copy_alt" class="button button-primary btn_do_copy image_do_copy_alt" value="<?php _e('Image name as alt text','wp-meta-seo') ?>">
|
49 |
-
<input type="button" name="image_do_copy_title" class="button button-primary btn_do_copy image_do_copy_title" value="<?php _e('Image name as image title','wp-meta-seo') ?>">
|
50 |
<span class="spinner"></span>
|
51 |
</div>
|
52 |
-
|
53 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
54 |
<?php if (!empty($_REQUEST['post_status'])): ?>
|
55 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
56 |
<?php endif ?>
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
<div style="float:right;margin-left:8px;">
|
61 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_imgs_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
62 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
63 |
</div>
|
64 |
-
|
65 |
<?php $this->pagination($which); ?>
|
66 |
<br class="clear" />
|
67 |
</div>
|
68 |
|
69 |
<?php
|
70 |
}
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
72 |
function get_views() {
|
73 |
global $wpdb;
|
74 |
|
@@ -111,19 +117,21 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
111 |
|
112 |
return $status_links;
|
113 |
}
|
114 |
-
|
|
|
|
|
|
|
|
|
115 |
function extra_tablenav($which) {
|
116 |
-
|
117 |
-
#if ('top' == $which) {
|
118 |
echo '<div class="alignleft actions">';
|
119 |
global $wpdb;
|
120 |
|
121 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
122 |
-
$post_types = "'" . implode("', '", $post_types) . "'";
|
123 |
|
124 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
125 |
$states['trash'] = 'trash';
|
126 |
-
$all_states = "'" . implode("', '", $states) . "'";
|
127 |
|
128 |
$query = "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types) ORDER BY 'post_type' ASC";
|
129 |
$post_types = $wpdb->get_results($query);
|
@@ -136,12 +144,15 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
136 |
$obj = get_post_type_object($post_type->post_type);
|
137 |
$options .= sprintf('<option value="%2$s" %3$s>%1$s</option>', $obj->labels->name, $post_type->post_type, selected($selected, $post_type->post_type, false));
|
138 |
}
|
139 |
-
|
140 |
echo "</div>";
|
141 |
-
#echo "</form>";
|
142 |
-
#}
|
143 |
}
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
145 |
function get_columns() {
|
146 |
return $columns = array(
|
147 |
'cb' => '<input id="cb-select-all-1" type="checkbox">',
|
@@ -156,6 +167,15 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
156 |
);
|
157 |
}
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
function get_sortable_columns() {
|
160 |
return $sortable = array(
|
161 |
'col_image_name' => array('post_name', true),
|
@@ -163,148 +183,169 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
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 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
function prepare_items() {
|
251 |
global $wpdb, $_wp_column_headers;
|
|
|
252 |
$screen = get_current_screen();
|
253 |
-
|
254 |
-
$where=array();
|
255 |
-
$post_type='attachment';
|
256 |
$where[] = " post_type='$post_type' ";
|
257 |
$where[] = " ((post_mime_type='image/jpeg') OR (post_mime_type='image/jpg') OR (post_mime_type='image/png') OR (post_mime_type='image/gif')) ";
|
258 |
-
|
259 |
if (!empty($_REQUEST["search"])) {
|
260 |
-
if (!empty($_REQUEST["txtkeyword"])){
|
261 |
$_REQUEST["txtkeyword"] = stripslashes($_REQUEST["txtkeyword"]);
|
262 |
-
$_REQUEST["txtkeyword"] = $wpdb->esc_like(
|
263 |
-
$where[] = $wpdb->prepare(" (post_title Like %s or post_name Like %s)",
|
264 |
-
|
265 |
}
|
266 |
}
|
267 |
-
|
268 |
-
if(!empty($_REQUEST['sldate'])){
|
269 |
-
$where[]
|
270 |
}
|
271 |
-
|
272 |
-
$
|
273 |
-
$
|
|
|
|
|
|
|
274 |
if (!empty($orderby) & !empty($order)) {
|
275 |
-
$orderStr
|
276 |
-
$orderStr = str_replace("'",""
|
277 |
}
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
280 |
|
281 |
$query = "SELECT ID, post_title as title, post_name as name, post_content as des, post_excerpt as legend, guid, post_type , post_mime_type, post_status, mt.meta_value AS alt
|
282 |
FROM $wpdb->posts as posts
|
283 |
LEFT JOIN (SELECT * FROM {$wpdb->prefix}postmeta WHERE meta_key = '_wp_attachment_image_alt') mt ON mt.post_id = posts.ID
|
284 |
-
WHERE ". implode(" and ", $where)
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
if( $per_page !== false) {
|
296 |
-
if($_per_page && $_per_page !== $per_page ){
|
297 |
-
$per_page = $_per_page;
|
298 |
-
update_user_option(get_current_user_id(), 'metaseo_imgs_per_page', $per_page);
|
299 |
-
}
|
300 |
-
}
|
301 |
-
else{
|
302 |
-
if($_per_page > 0) {
|
303 |
-
$per_page = $_per_page;
|
304 |
}
|
305 |
-
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
$paged = !empty($_GET["paged"]) ? ($_GET["paged"]) : '';
|
310 |
|
@@ -330,13 +371,15 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
330 |
$sortable = $this->get_sortable_columns();
|
331 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
332 |
$this->items = $wpdb->get_results($query);
|
333 |
-
|
334 |
}
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
337 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
338 |
return;
|
339 |
-
$txtkeyword = (!empty($_REQUEST['txtkeyword'])) ? urldecode(stripslashes($_REQUEST['txtkeyword'])
|
340 |
if (!empty($_REQUEST['orderby']))
|
341 |
echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
|
342 |
if (!empty($_REQUEST['order']))
|
@@ -347,56 +390,45 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
347 |
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
|
348 |
?>
|
349 |
<p class="search-box">
|
350 |
-
|
351 |
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
|
352 |
<?php submit_button('Search', 'button', 'search', false, array('id' => 'search-submit')); ?>
|
353 |
</p>
|
354 |
<?php
|
355 |
}
|
356 |
|
357 |
-
|
358 |
-
function months_fillter($
|
359 |
global $wpdb, $wp_locale;
|
360 |
-
|
361 |
-
|
362 |
-
$months = $wpdb->get_results($wpdb->prepare("
|
363 |
-
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
364 |
-
FROM $wpdb->posts
|
365 |
-
WHERE post_type = %s".$where."
|
366 |
-
ORDER BY post_date DESC
|
367 |
-
", $post_type));
|
368 |
-
|
369 |
-
$months = apply_filters('months_dropdown_results', $months, $post_type);
|
370 |
-
|
371 |
-
$month_count = count($months);
|
372 |
-
|
373 |
-
if (!$month_count || ( 1 == $month_count && 0 == $months[0]->month ))
|
374 |
return;
|
375 |
|
376 |
$m = isset($_REQUEST['sldate']) ? $_REQUEST['sldate'] : 0;
|
377 |
?>
|
378 |
-
|
379 |
-
|
380 |
-
<option<?php selected($m, 0); ?> value="0"><?php _e('All dates','wp-meta-seo'); ?></option>
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
</select>
|
395 |
-
|
396 |
<?php
|
397 |
submit_button(__('Filter'), 'button', $namebutton, false, array('id' => 'image-submit'));
|
398 |
}
|
399 |
-
|
|
|
|
|
|
|
400 |
function display_rows() {
|
401 |
$url = URL;
|
402 |
$url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
|
@@ -412,13 +444,13 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
412 |
$i++;
|
413 |
$classes = $alternate;
|
414 |
$img_meta = get_post_meta($rec->ID, '_wp_attachment_metadata', TRUE);
|
415 |
-
|
416 |
-
|
417 |
$thumb_url = $rec->guid;
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
if (strrpos($img_meta['file'], '/') !== false) {
|
423 |
$img_name = substr($img_meta['file'], strrpos($img_meta['file'], '/') + 1);
|
424 |
} else {
|
@@ -426,614 +458,631 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
426 |
}
|
427 |
$type = substr($img_meta['file'], strrpos($img_meta['file'], '.'));
|
428 |
$img_name = str_replace($type, '', $img_name);
|
429 |
-
|
430 |
$upload_dir = wp_upload_dir();
|
431 |
$img_path = $upload_dir['basedir'] . '/' . $img_meta['file'];
|
432 |
-
if
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
$
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
|
|
|
|
|
|
|
|
|
|
442 |
}
|
443 |
-
$img_size=round($img_size,1);
|
444 |
-
//Get the date that image was uploaded
|
445 |
-
$img_date = get_the_date("", $rec->ID);
|
446 |
-
}
|
447 |
|
448 |
-
|
449 |
-
|
450 |
|
451 |
-
|
452 |
-
|
453 |
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
$attributes = $class . $style;
|
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 |
<div class="popup-content"></div>
|
503 |
</div>
|
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 |
-
if(!empty($metaseo_imgs_sizes)){
|
553 |
-
foreach($metaseo_imgs_sizes as $key => $size){
|
554 |
-
$response['sizes'][$key] = $size;
|
555 |
-
}
|
556 |
-
}
|
557 |
-
|
558 |
-
return $response;
|
559 |
-
}
|
560 |
-
|
561 |
-
public static function add_more_attachment_sizes_choose($sizes){
|
562 |
-
global $wpdb;
|
563 |
-
$query = "SELECT `meta_value` FROM $wpdb->postmeta WHERE `meta_key` = '_metaseo_sizes_optional' AND `meta_value` <> ''";
|
564 |
-
|
565 |
-
$metaseo_imgs_sizes = $wpdb->get_results($query);
|
566 |
-
if(!empty($metaseo_imgs_sizes)){
|
567 |
-
$_sizes = array();
|
568 |
-
foreach($metaseo_imgs_sizes as $metaseo_img_sizes){
|
569 |
-
$metaseo_img_sizes = @unserialize($metaseo_img_sizes->meta_value);
|
570 |
-
if(!empty($metaseo_img_sizes)){
|
571 |
-
foreach($metaseo_img_sizes as $key => $size){
|
572 |
-
add_image_size($key, $size['width'], $size['height'], false);
|
573 |
-
}
|
574 |
-
}
|
575 |
-
}
|
576 |
-
|
577 |
-
}
|
578 |
-
|
579 |
-
$new_sizes = array();
|
580 |
-
|
581 |
-
$added_sizes = get_intermediate_image_sizes();
|
582 |
-
|
583 |
-
// $added_sizes is an indexed array, therefore need to convert it
|
584 |
-
// to associative array, using $value for $key and $value
|
585 |
-
foreach( $added_sizes as $value) {
|
586 |
-
if(strpos($value, '-metaseo') !== false){
|
587 |
-
$_value = substr($value, 0, strrpos($value, '-metaseo'));
|
588 |
-
}else{
|
589 |
-
$_value = $value;
|
590 |
-
}
|
591 |
-
$new_sizes[$value] = ucwords(str_replace(array('-','_'), ' – ', $_value));
|
592 |
-
}
|
593 |
-
|
594 |
-
// This preserves the labels in $sizes, and merges the two arrays
|
595 |
-
$new_sizes = array_merge( $new_sizes, $sizes );
|
596 |
-
|
597 |
-
return $new_sizes;
|
598 |
-
}
|
599 |
-
|
600 |
-
private static function display_fix_metas_list($img_post_id, $posts, $meta_counter, $p, $im){
|
601 |
-
if($meta_counter){
|
602 |
-
$header = sprintf(__('We found %s image which needed to add or change meta information', 'wp-meta-seo'),$meta_counter . $im . $p);
|
603 |
-
}else{
|
604 |
-
$header = __('We found 0 image which needed to add or change meta information', 'wp-meta-seo');//__('We found 0 image which needed to add or change meta information', 'wp-meta-seo');
|
605 |
-
}
|
606 |
-
|
607 |
-
//Get default meta information of the image
|
608 |
-
$img_post = get_post($img_post_id);
|
609 |
-
$alt = get_post_meta($img_post_id, '_wp_attachment_image_alt', true);
|
610 |
-
$title = $img_post->post_title;
|
611 |
-
?>
|
612 |
-
<h3 class="content-header"><?php echo $header ?></h3>
|
613 |
-
<div class="content-box">
|
614 |
-
<table class="wp-list-table widefat fixed posts">
|
615 |
-
<thead></thead>
|
616 |
-
<tbody>
|
617 |
-
<?php $alternate = '';?>
|
618 |
-
<?php if(count($posts) < 1): ?>
|
619 |
-
<tr><td colspan="10" style="height:95%"><?php echo __('This image has still not been inserted in any post!', 'wp-meta-seo') ?></td></tr>
|
620 |
-
<?php else: ?>
|
621 |
-
<tr class="metaseo-border-bottom">
|
622 |
-
<td colspan="1">ID</td>
|
623 |
-
<td colspan="2">Title</td>
|
624 |
-
<td colspan="2">Image</td>
|
625 |
-
<td colspan="5">Image Meta</td>
|
626 |
-
</tr>
|
627 |
-
<?php foreach($posts as $post): ?>
|
628 |
-
<?php foreach($post['meta'] as $k => $meta): ?>
|
629 |
-
<?php $alternate = 'alternate' == $alternate ? '' : 'alternate';
|
630 |
-
$file_name = substr($meta['img_src'], strrpos($meta['img_src'], '/')+1);
|
631 |
-
?>
|
632 |
-
<tr class="<?php echo $alternate ?>">
|
633 |
-
<td colspan="1"><?php echo $post['ID'] ?></td>
|
634 |
-
<td colspan="2">
|
635 |
-
<p><?php echo $post['title'] ?></p>
|
636 |
-
</td>
|
637 |
-
<td colspan="2">
|
638 |
-
<div class="metaseo-img-wrapper">
|
639 |
-
<img src="<?php echo $meta['img_src'] ?>" />
|
640 |
-
</div>
|
641 |
-
</td>
|
642 |
-
<td colspan="5">
|
643 |
-
<?php foreach($meta['type'] as $type => $value): ?>
|
644 |
-
<div class="metaseo-img-wrapper">
|
645 |
-
<?php
|
646 |
-
$specialChr = array('"', '\'');
|
647 |
-
foreach($specialChr as $chr){
|
648 |
-
$value = str_replace($chr, htmlentities2($chr), $value);
|
649 |
-
}
|
650 |
-
?>
|
651 |
-
<input type="text" value="<?php echo ($value != '' ? $value : ''); ?>" id="metaseo-img-<?php echo $type. '-' .$post['ID'] ?>" class="metaseo-fix-meta metaseo-img-<?php echo $type ?>" data-meta-key="_metaseo_fix_metas" data-post-id="<?php echo $post['ID'] ?>" data-img-post-id="<?php echo $img_post_id ?>" data-meta-type="<?php echo $type ?>" data-meta-order="<?php echo $k ?>" data-file-name="<?php echo $file_name; ?>" placeholder="<?php echo ($value == '' ? __(ucfirst($type) . ' is empty', 'wp-meta-seo') : '') ?>" onfocus="metaseo_fix_meta(this);" onblur="updateInputBlur(this)" onkeydown="return checkeyCode(event,this)" />
|
652 |
-
<span class="meta-update"></span>
|
653 |
-
<?php if(trim($$type) != '' && trim($$type) != $value): ?>
|
654 |
-
<a class="button meta-default" href="#" data-default-value="<?php echo esc_attr($$type) ?>" title="Add to input box" onclick="add_meta_default(this)"> <?php echo '<img src= "' . WPMETASEO_PLUGIN_URL . 'img/img-arrow.png" />' ?> Copy </a>
|
655 |
-
<span class="img_seo_type"><?php echo $$type; ?></span>
|
656 |
-
<?php endif ?>
|
657 |
-
</div>
|
658 |
-
<?php endforeach ?>
|
659 |
-
<span class="saved-info"></span>
|
660 |
-
</td>
|
661 |
-
</tr>
|
662 |
-
<?php endforeach ?>
|
663 |
-
<?php endforeach ?>
|
664 |
-
<?php endif ?>
|
665 |
-
</tbody>
|
666 |
-
<tfoot></tfoot>
|
667 |
-
</table>
|
668 |
-
</div>
|
669 |
-
<div style="padding:5px"></div>
|
670 |
-
<?php
|
671 |
-
|
672 |
-
}
|
673 |
-
|
674 |
-
private static function display_resize_image_list($img_post_id,$posts, $img_counter, $p, $im){
|
675 |
-
|
676 |
-
$header = sprintf(__('We found %s which needed to optimize', 'wp-meta-seo'), $img_counter . $im . $p);
|
677 |
-
?>
|
678 |
-
<h3 class="content-header"><?php echo $header ?></h3>
|
679 |
-
<div class="content-box">
|
680 |
-
<table class="wp-list-table widefat fixed posts">
|
681 |
-
<thead></thead>
|
682 |
-
<tbody>
|
683 |
-
<tr class="metaseo-border-bottom">
|
684 |
-
<td colspan="1">ID</td>
|
685 |
-
<td colspan="3">Title</td>
|
686 |
-
<td colspan="4">Current Images</td>
|
687 |
-
<td colspan="2" class="metaseo-action">Action</td>
|
688 |
-
<td colspan="4">After Replacing</td>
|
689 |
-
</tr>
|
690 |
-
<?php $alternate ="";
|
691 |
-
foreach($posts as $post): ?>
|
692 |
-
<?php $alternate = 'alternate' == $alternate ? '' : 'alternate'; ?>
|
693 |
-
<tr class="<?php echo $alternate ?>">
|
694 |
-
<td colspan="1"><?php echo $post['ID'] ?></td>
|
695 |
-
<td colspan="3">
|
696 |
-
<p><?php echo $post['title'] ?></p>
|
697 |
-
</td>
|
698 |
-
<td colspan="4" style="overflow: hidden;">
|
699 |
-
<?php foreach($post['img_before_optm'] as $key => $src):?>
|
700 |
-
<div class="metaseo-img-wrapper">
|
701 |
-
<div class="metaseo-img">
|
702 |
-
<img width="<?php echo @$src['width'] ;?>" height="<?php #echo @$src['height'] ;?>" src="<?php echo $src['src'] ?>" />
|
703 |
-
<div class="img-choosen">
|
704 |
-
<input type="checkbox" checked="true" class="metaseo-checkin checkin-<?php echo $post['ID'] ?>" value="<?php echo $key ?>" id="checkin-<?php echo $post['ID'].'-'.$key ?>" onclick="uncheck(this)" />
|
705 |
-
</div>
|
706 |
-
<p class="metaseo-msg"></p>
|
707 |
-
</div>
|
708 |
-
<div class="dimension">
|
709 |
-
Orig. </br>
|
710 |
-
<span>Dimensions</span>: <?php echo $src['dimension'] ?></br>
|
711 |
-
<span>File size</span>: <?php echo $src['size'].' '.$src['sizes'] ?>
|
712 |
-
</div>
|
713 |
-
</div>
|
714 |
-
<?php endforeach ?>
|
715 |
-
</td>
|
716 |
-
<td colspan="2" class="metaseo-action">
|
717 |
-
<a href="javascript:void(0);" class="metaseo-optimize button" data-img-post-id="<?php echo $img_post_id ?>" data-post-id="<?php echo $post['ID'] ?>" onclick="optimize_imgs(this)"><?php echo __('Replace?', 'wp-meta-seo') ?></a>
|
718 |
-
<span class="optimizing spinner"></span>
|
719 |
-
</td>
|
720 |
-
<td colspan="4">
|
721 |
-
<?php foreach($post['img_after_optm'] as $src):?>
|
722 |
-
<div class="metaseo-img-wrapper">
|
723 |
-
<div class="metaseo-img">
|
724 |
-
<img src="<?php echo $src['src'] ?>" />
|
725 |
-
</div>
|
726 |
-
<div class="dimension">
|
727 |
-
OPT </br>
|
728 |
-
<span>Dimensions</span>: <?php echo $src['dimension'] ?></br>
|
729 |
-
<span>File size</span>: <?php echo $src['size'].' '.$src['sizes'] ?>
|
730 |
-
</div>
|
731 |
-
</div>
|
732 |
-
<?php endforeach ?>
|
733 |
-
</td>
|
734 |
-
</tr>
|
735 |
-
|
736 |
-
<?php endforeach ?>
|
737 |
-
<tr class="metaseo-border-top">
|
738 |
-
<td colspan="8"></td>
|
739 |
-
<td colspan="2">
|
740 |
-
<a href="javascript:void(0);" id="metaseo-replace-all" class="button button-primary" onclick="optimize_imgs_group(this)">
|
741 |
-
<?php echo __('Replace All') ?>
|
742 |
-
</a>
|
743 |
-
<span class="optimizing spinner"></span>
|
744 |
-
</td>
|
745 |
-
<td colspan="4"></td>
|
746 |
-
</tr>
|
747 |
-
</tbody>
|
748 |
-
<tfoot></tfoot>
|
749 |
-
</table>
|
750 |
-
</div>
|
751 |
-
<div style="padding:5px"></div>
|
752 |
-
<?php
|
753 |
-
}
|
754 |
-
|
755 |
-
public static function optimizeImages(){
|
756 |
-
if(!empty($_POST['post_id']) && !empty($_POST['img_post_id'])){
|
757 |
-
$post_id = intval($_POST['post_id']);
|
758 |
-
$img_post_id = intval($_POST['img_post_id']);
|
759 |
-
if(!empty($_POST['img_exclude'])){
|
760 |
-
$img_exclude = $_POST['img_exclude'];
|
761 |
-
}
|
762 |
-
else{
|
763 |
-
$img_exclude = array();
|
764 |
-
}
|
765 |
-
|
766 |
-
$ret = ImageHelper::_optimizeImages($post_id, $img_post_id, $img_exclude);
|
767 |
-
}
|
768 |
-
else{
|
769 |
-
$ret = array(
|
770 |
-
'success' => false,
|
771 |
-
'msg' => __('The post is not existed, please choose one another!', 'wp-meta-seo')
|
772 |
-
);
|
773 |
-
}
|
774 |
-
|
775 |
-
echo json_encode($ret);
|
776 |
-
wp_die();
|
777 |
-
|
778 |
-
}
|
779 |
-
|
780 |
public function process_action() {
|
781 |
global $wpdb;
|
782 |
-
|
783 |
-
|
784 |
|
785 |
if (isset($_POST['search']) and $_POST['search'] === 'Search') {
|
786 |
-
$current_url = add_query_arg(array("search" => "Search", "txtkeyword" =>
|
787 |
$redirect = true;
|
788 |
}
|
789 |
-
|
790 |
if (isset($_POST['filter_date_action']) and $_POST['filter_date_action'] === 'Filter') {
|
791 |
$current_url = add_query_arg(array("sldate" => $_POST["sldate"]), $current_url);
|
792 |
-
|
793 |
}
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
exit();
|
809 |
-
|
810 |
}
|
811 |
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
}
|
1028 |
-
else{
|
1029 |
$response->msg = __('There is a problem when update image meta!', 'wp-meta-seo');
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
wp_die();
|
1034 |
-
|
1035 |
|
1036 |
-
|
|
|
|
|
|
|
1037 |
|
1038 |
global $wpdb;
|
1039 |
$postID = (int) $_POST['post_id'];
|
@@ -1047,210 +1096,245 @@ class MetaSeo_Image_List_Table extends WP_List_Table {
|
|
1047 |
|
1048 |
$upload_dirs = wp_upload_dir();
|
1049 |
$upload_dir = $upload_dirs['basedir'];
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
if ($name !== "") {
|
1054 |
if (file_exists($upload_dir . "/" . $linkold)) {
|
1055 |
$newFileName = $oldpart->base_path . $iname . $oldpart->ext;
|
1056 |
-
|
1057 |
-
|
1058 |
if (rename($upload_dir . "/" . $linkold, $upload_dir . "/" . $newFileName)) {
|
1059 |
-
|
1060 |
$data_post = array('ID' => $postID, 'post_name' => $name);
|
1061 |
//if (wp_update_post($data_post)) {
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
if($id){
|
1072 |
$attached_metadata = get_post_meta($postID, "_wp_attachment_metadata", true);
|
1073 |
$attached_metadata["file"] = $newFileName;
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1144 |
update_post_meta($postID, '_wp_attached_file', $newFileName);
|
1145 |
update_post_meta($postID, '_wp_attachment_metadata', $attached_metadata);
|
1146 |
-
|
1147 |
$response->updated = true;
|
1148 |
$response->msg = __('Image name was changed', 'wp-meta-seo');
|
1149 |
} else {
|
1150 |
-
|
1151 |
$response->msg = __('There is a problem when update image name', 'wp-meta-seo');
|
1152 |
}
|
1153 |
}
|
1154 |
} else {
|
1155 |
|
1156 |
$response->msg = __('Name is existing', 'wp-meta-seo');
|
1157 |
-
|
1158 |
}
|
1159 |
} else {
|
1160 |
-
|
1161 |
$response->msg = __('File is not existed', 'wp-meta-seo');
|
1162 |
}
|
1163 |
} else {
|
1164 |
-
|
1165 |
$response->msg = __('Should not be empty', 'wp-meta-seo');
|
1166 |
}
|
1167 |
echo json_encode($response);
|
1168 |
wp_die();
|
1169 |
}
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Base class for displaying a list of image files in an ajaxified HTML table.
|
|
|
4 |
*
|
5 |
*/
|
6 |
|
8 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
9 |
}
|
10 |
|
11 |
+
if (!class_exists('ImageHelper')) {
|
12 |
require_once( 'class.image-helper.php' );
|
13 |
}
|
14 |
|
15 |
class MetaSeo_Image_List_Table extends WP_List_Table {
|
16 |
+
public $months;
|
17 |
function __construct() {
|
18 |
parent::__construct(array(
|
19 |
'singular' => 'metaseo_image',
|
21 |
'ajax' => true
|
22 |
));
|
23 |
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Generate the table navigation above or below the table
|
27 |
+
* @param string $which
|
28 |
+
*/
|
29 |
function display_tablenav($which) {
|
30 |
+
?>
|
31 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
32 |
|
33 |
+
<?php if ($which == 'top'): ?>
|
34 |
+
<input type="hidden" name="page" value="metaseo_image_meta" />
|
35 |
+
<div class="alignleft actions bulkactions">
|
36 |
+
<?php $this->months_fillter('sldate', 'filter_date_action'); ?>
|
37 |
+
</div>
|
38 |
+
<?php elseif ($which == 'bottom'): ?>
|
39 |
+
<input type="hidden" name="page" value="metaseo_image_meta" />
|
40 |
+
<div class="alignleft actions bulkactions">
|
41 |
+
<?php $this->months_fillter('sldate1', 'filter_date_action'); ?>
|
42 |
+
</div>
|
43 |
+
<?php endif ?>
|
44 |
+
|
45 |
<div class="alignleft">
|
46 |
<select name="image_mbulk_copy" class="mbulk_copy">
|
47 |
+
<option value="0"><?php _e('Bulk copy', 'wp-meta-seo') ?></option>
|
48 |
+
<option value="all"><?php _e('All Images', 'wp-meta-seo') ?></option>
|
49 |
+
<option value="bulk-copy-title-alt"><?php _e('Selected images', 'wp-meta-seo') ?></option>
|
50 |
</select>
|
51 |
+
<input type="button" name="image_do_copy_alt" class="button button-primary btn_do_copy image_do_copy_alt" value="<?php _e('Image name as alt text', 'wp-meta-seo') ?>">
|
52 |
+
<input type="button" name="image_do_copy_title" class="button button-primary btn_do_copy image_do_copy_title" value="<?php _e('Image name as image title', 'wp-meta-seo') ?>">
|
53 |
<span class="spinner"></span>
|
54 |
</div>
|
55 |
+
|
56 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
57 |
<?php if (!empty($_REQUEST['post_status'])): ?>
|
58 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
59 |
<?php endif ?>
|
60 |
|
61 |
+
<div style="float:right;margin-left:8px;">
|
|
|
|
|
62 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_imgs_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
63 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
64 |
</div>
|
65 |
+
|
66 |
<?php $this->pagination($which); ?>
|
67 |
<br class="clear" />
|
68 |
</div>
|
69 |
|
70 |
<?php
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get an associative array ( id => link ) with the list
|
75 |
+
* of views available on this table.
|
76 |
+
* @return array
|
77 |
+
*/
|
78 |
function get_views() {
|
79 |
global $wpdb;
|
80 |
|
117 |
|
118 |
return $status_links;
|
119 |
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Extra controls to be displayed between bulk actions and pagination
|
123 |
+
* @param string $which
|
124 |
+
*/
|
125 |
function extra_tablenav($which) {
|
|
|
|
|
126 |
echo '<div class="alignleft actions">';
|
127 |
global $wpdb;
|
128 |
|
129 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
130 |
+
$post_types = "'" . implode("', '", esc_sql($post_types)) . "'";
|
131 |
|
132 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
133 |
$states['trash'] = 'trash';
|
134 |
+
$all_states = "'" . implode("', '", esc_sql($states)) . "'";
|
135 |
|
136 |
$query = "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types) ORDER BY 'post_type' ASC";
|
137 |
$post_types = $wpdb->get_results($query);
|
144 |
$obj = get_post_type_object($post_type->post_type);
|
145 |
$options .= sprintf('<option value="%2$s" %3$s>%1$s</option>', $obj->labels->name, $post_type->post_type, selected($selected, $post_type->post_type, false));
|
146 |
}
|
147 |
+
|
148 |
echo "</div>";
|
|
|
|
|
149 |
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Get a list of columns. The format is:
|
153 |
+
* 'internal-name' => 'Title'
|
154 |
+
* @return array
|
155 |
+
*/
|
156 |
function get_columns() {
|
157 |
return $columns = array(
|
158 |
'cb' => '<input id="cb-select-all-1" type="checkbox">',
|
167 |
);
|
168 |
}
|
169 |
|
170 |
+
/**
|
171 |
+
* Get a list of sortable columns. The format is:
|
172 |
+
* 'internal-name' => 'orderby'
|
173 |
+
* or
|
174 |
+
* 'internal-name' => array( 'orderby', true )
|
175 |
+
*
|
176 |
+
* The second format will make the initial sorting order be descending
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
function get_sortable_columns() {
|
180 |
return $sortable = array(
|
181 |
'col_image_name' => array('post_name', true),
|
183 |
);
|
184 |
}
|
185 |
|
186 |
+
/**
|
187 |
+
* Print column headers, accounting for hidden and sortable columns.
|
188 |
+
*
|
189 |
+
* @since 3.1.0
|
190 |
+
* @access public
|
191 |
+
*
|
192 |
+
* @param bool $with_id Whether to set the id attribute or not
|
193 |
+
*/
|
194 |
+
public function print_column_headers($with_id = true) {
|
195 |
+
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
196 |
+
|
197 |
+
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
198 |
+
$current_url = remove_query_arg('paged', $current_url);
|
199 |
+
|
200 |
+
if (isset($_GET['orderby']))
|
201 |
+
$current_orderby = $_GET['orderby'];
|
202 |
+
else
|
203 |
+
$current_orderby = '';
|
204 |
+
|
205 |
+
if (isset($_GET['order']) && 'desc' == $_GET['order'])
|
206 |
+
$current_order = 'desc';
|
207 |
+
else
|
208 |
+
$current_order = 'asc';
|
209 |
+
|
210 |
+
if (!empty($columns['cb'])) {
|
211 |
+
static $cb_counter = 1;
|
212 |
+
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __('Select All') . '</label>'
|
213 |
+
. '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" style="margin:0;" />';
|
214 |
+
$cb_counter++;
|
215 |
+
}
|
216 |
+
|
217 |
+
foreach ($columns as $column_key => $column_display_name) {
|
218 |
+
$class = array('manage-column', "column-$column_key");
|
219 |
+
|
220 |
+
$style = '';
|
221 |
+
if (in_array($column_key, $hidden))
|
222 |
+
$style = 'display:none;';
|
223 |
+
|
224 |
+
$style = ' style="' . $style . '"';
|
225 |
+
|
226 |
+
if ('cb' == $column_key)
|
227 |
+
$class[] = 'check-column';
|
228 |
+
elseif (in_array($column_key, array('posts', 'comments', 'links')))
|
229 |
+
$class[] = 'num';
|
230 |
+
|
231 |
+
if (isset($sortable[$column_key])) {
|
232 |
+
list( $orderby, $desc_first ) = $sortable[$column_key];
|
233 |
+
|
234 |
+
if ($current_orderby == $orderby) {
|
235 |
+
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
236 |
+
$class[] = 'sorted';
|
237 |
+
$class[] = $current_order;
|
238 |
+
} else {
|
239 |
+
$order = $desc_first ? 'desc' : 'asc';
|
240 |
+
$class[] = 'sortable';
|
241 |
+
$class[] = $desc_first ? 'asc' : 'desc';
|
242 |
+
}
|
243 |
+
|
244 |
+
$column_display_name = '<a href="' . esc_url(add_query_arg(compact('orderby', 'order'), $current_url)) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
245 |
+
}
|
246 |
+
|
247 |
+
$id = $with_id ? "id='$column_key'" : '';
|
248 |
+
|
249 |
+
if (!empty($class))
|
250 |
+
$class = "class='" . join(' ', $class) . "'";
|
251 |
+
|
252 |
+
if ($column_key === 'col_id') {
|
253 |
+
echo "<th scope='col' $id $class $style colspan=\"1\">$column_display_name</th>";
|
254 |
+
} elseif ($column_key === 'col_image_name') {
|
255 |
+
echo "<th scope='col' $id $class $style colspan=\"4\">$column_display_name</th>";
|
256 |
+
} elseif ($column_key === 'col_image_info') {
|
257 |
+
echo "<th scope='col' $id $class $style colspan=\"5\">$column_display_name</th>";
|
258 |
+
} elseif ($column_key === 'cb') {
|
259 |
+
echo "<th scope='col' $id $class style='padding:8px 10px;'>$column_display_name</th>";
|
260 |
+
} else {
|
261 |
+
echo "<th scope='col' $id $class $style colspan=\"3\">$column_display_name</th>";
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Get months
|
268 |
+
*/
|
269 |
+
function wpmf_get_months(){
|
270 |
+
global $wpdb;
|
271 |
+
$where = " AND ((post_mime_type='image/jpeg') OR (post_mime_type='image/jpg') OR (post_mime_type='image/png') OR (post_mime_type='image/gif')) ";
|
272 |
+
$months = $wpdb->get_results($wpdb->prepare("
|
273 |
+
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
274 |
+
FROM $wpdb->posts
|
275 |
+
WHERE post_type = %s" . $where . "
|
276 |
+
ORDER BY post_date DESC
|
277 |
+
", 'attachment'));
|
278 |
+
|
279 |
+
$months = apply_filters('months_dropdown_results', $months, 'attachment');
|
280 |
+
return $months;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Prepares the list of items for displaying.
|
285 |
+
* @uses WP_List_Table::set_pagination_args()
|
286 |
+
*/
|
287 |
function prepare_items() {
|
288 |
global $wpdb, $_wp_column_headers;
|
289 |
+
$this->months = $this->wpmf_get_months();
|
290 |
$screen = get_current_screen();
|
291 |
+
|
292 |
+
$where = array();
|
293 |
+
$post_type = 'attachment';
|
294 |
$where[] = " post_type='$post_type' ";
|
295 |
$where[] = " ((post_mime_type='image/jpeg') OR (post_mime_type='image/jpg') OR (post_mime_type='image/png') OR (post_mime_type='image/gif')) ";
|
296 |
+
|
297 |
if (!empty($_REQUEST["search"])) {
|
298 |
+
if (!empty($_REQUEST["txtkeyword"])) {
|
299 |
$_REQUEST["txtkeyword"] = stripslashes($_REQUEST["txtkeyword"]);
|
300 |
+
$_REQUEST["txtkeyword"] = $wpdb->esc_like($_REQUEST["txtkeyword"]);
|
301 |
+
$where[] = $wpdb->prepare(" (post_title Like %s or post_name Like %s)", "%" . $_REQUEST["txtkeyword"] . "%", "%" . $_REQUEST["txtkeyword"] . "%");
|
|
|
302 |
}
|
303 |
}
|
304 |
+
|
305 |
+
if (!empty($_REQUEST['sldate'])) {
|
306 |
+
$where[] = $wpdb->prepare(" post_date Like %s", "%" . $_REQUEST['sldate'] . "%");
|
307 |
}
|
308 |
+
|
309 |
+
$sortable = $this->get_sortable_columns();
|
310 |
+
$order_array = array('ASC','asc','DESC','desc');
|
311 |
+
$orderby = (!empty($_GET["orderby"]) && in_array($_GET["orderby"], $sortable)) ? ($_GET["orderby"]) : 'post_name';
|
312 |
+
$order = (!empty($_GET["order"]) && in_array($_GET["order"], $order_array)) ? ($_GET["order"]) : 'ASC';
|
313 |
+
|
314 |
if (!empty($orderby) & !empty($order)) {
|
315 |
+
$orderStr = $wpdb->prepare(' ORDER BY %s %s', $orderby, $order);
|
316 |
+
$orderStr = str_replace("'", "", $orderStr);
|
317 |
}
|
318 |
+
|
319 |
+
$query = "SELECT COUNT(ID)
|
320 |
+
FROM $wpdb->posts as posts
|
321 |
+
LEFT JOIN (SELECT * FROM {$wpdb->prefix}postmeta WHERE meta_key = '_wp_attachment_image_alt') mt ON mt.post_id = posts.ID
|
322 |
+
WHERE " . implode(" and ", $where) . $orderStr;
|
323 |
+
|
324 |
+
$total_items = $wpdb->get_var($query);
|
325 |
|
326 |
$query = "SELECT ID, post_title as title, post_name as name, post_content as des, post_excerpt as legend, guid, post_type , post_mime_type, post_status, mt.meta_value AS alt
|
327 |
FROM $wpdb->posts as posts
|
328 |
LEFT JOIN (SELECT * FROM {$wpdb->prefix}postmeta WHERE meta_key = '_wp_attachment_image_alt') mt ON mt.post_id = posts.ID
|
329 |
+
WHERE " . implode(" and ", $where) . $orderStr;
|
330 |
+
if (!empty($_REQUEST['metaseo_imgs_per_page'])) {
|
331 |
+
$_per_page = intval($_REQUEST['metaseo_imgs_per_page']);
|
332 |
+
} else {
|
333 |
+
$_per_page = 0;
|
334 |
+
}
|
335 |
+
$per_page = get_user_option('metaseo_imgs_per_page');
|
336 |
+
if ($per_page !== false) {
|
337 |
+
if ($_per_page && $_per_page !== $per_page) {
|
338 |
+
$per_page = $_per_page;
|
339 |
+
update_user_option(get_current_user_id(), 'metaseo_imgs_per_page', $per_page);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
341 |
+
} else {
|
342 |
+
if ($_per_page > 0) {
|
343 |
+
$per_page = $_per_page;
|
344 |
+
} else {
|
345 |
+
$per_page = 10;
|
346 |
+
}
|
347 |
+
add_user_meta(get_current_user_id(), 'metaseo_imgs_per_page', $per_page);
|
348 |
+
}
|
349 |
|
350 |
$paged = !empty($_GET["paged"]) ? ($_GET["paged"]) : '';
|
351 |
|
371 |
$sortable = $this->get_sortable_columns();
|
372 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
373 |
$this->items = $wpdb->get_results($query);
|
|
|
374 |
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Displays the search box.
|
378 |
+
*/
|
379 |
+
function search_box1() {
|
380 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
381 |
return;
|
382 |
+
$txtkeyword = (!empty($_REQUEST['txtkeyword'])) ? urldecode(stripslashes($_REQUEST['txtkeyword'])) : "";
|
383 |
if (!empty($_REQUEST['orderby']))
|
384 |
echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
|
385 |
if (!empty($_REQUEST['order']))
|
390 |
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
|
391 |
?>
|
392 |
<p class="search-box">
|
393 |
+
|
394 |
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
|
395 |
<?php submit_button('Search', 'button', 'search', false, array('id' => 'search-submit')); ?>
|
396 |
</p>
|
397 |
<?php
|
398 |
}
|
399 |
|
400 |
+
/* Add fillter month */
|
401 |
+
function months_fillter($name, $namebutton) {
|
402 |
global $wpdb, $wp_locale;
|
403 |
+
$month_count = count($this->months);
|
404 |
+
if (!$month_count || ( 1 == $month_count && 0 == $this->months[0]->month ))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
return;
|
406 |
|
407 |
$m = isset($_REQUEST['sldate']) ? $_REQUEST['sldate'] : 0;
|
408 |
?>
|
409 |
+
<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date', 'wp-meta-seo'); ?></label>
|
410 |
+
<select name="<?php echo $name ?>" id="filter-by-date" class="metaseo-filter">
|
411 |
+
<option<?php selected($m, 0); ?> value="0"><?php _e('All dates', 'wp-meta-seo'); ?></option>
|
412 |
+
<?php
|
413 |
+
foreach ($this->months as $arc_row) {
|
414 |
+
|
415 |
+
if (0 == $arc_row->year)
|
416 |
+
continue;
|
417 |
+
$month = zeroise($arc_row->month, 2);
|
418 |
+
$year = $arc_row->year;
|
419 |
+
printf("<option %s value='%s' >%s</option>\n", selected($m, "$year-$month", false), esc_attr("$arc_row->year-$month"), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
|
420 |
+
);
|
421 |
+
}
|
422 |
+
?>
|
423 |
+
</select>
|
424 |
+
|
|
|
|
|
425 |
<?php
|
426 |
submit_button(__('Filter'), 'button', $namebutton, false, array('id' => 'image-submit'));
|
427 |
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* Generate the table rows
|
431 |
+
*/
|
432 |
function display_rows() {
|
433 |
$url = URL;
|
434 |
$url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
|
444 |
$i++;
|
445 |
$classes = $alternate;
|
446 |
$img_meta = get_post_meta($rec->ID, '_wp_attachment_metadata', TRUE);
|
447 |
+
$thumb = wp_get_attachment_image_src($rec->ID, 'thumbnail');
|
448 |
+
if (!$thumb) {
|
449 |
$thumb_url = $rec->guid;
|
450 |
+
} else {
|
451 |
+
$thumb_url = $thumb['0'];
|
452 |
+
}
|
453 |
+
|
454 |
if (strrpos($img_meta['file'], '/') !== false) {
|
455 |
$img_name = substr($img_meta['file'], strrpos($img_meta['file'], '/') + 1);
|
456 |
} else {
|
458 |
}
|
459 |
$type = substr($img_meta['file'], strrpos($img_meta['file'], '.'));
|
460 |
$img_name = str_replace($type, '', $img_name);
|
461 |
+
|
462 |
$upload_dir = wp_upload_dir();
|
463 |
$img_path = $upload_dir['basedir'] . '/' . $img_meta['file'];
|
464 |
+
if(file_exists($img_path)){
|
465 |
+
if (is_readable($img_path)) {
|
466 |
+
//Get image attributes including width and height
|
467 |
+
list($img_width, $img_height, $img_type) = getimagesize($img_path);
|
468 |
+
//Get image size
|
469 |
+
if (($size = filesize($img_path) / 1024) > 1024) {
|
470 |
+
$img_size = ($size / 1024);
|
471 |
+
$img_sizes = ' MB';
|
472 |
+
} else {
|
473 |
+
$img_size = ($size);
|
474 |
+
$img_sizes = ' KB';
|
475 |
+
}
|
476 |
+
$img_size = round($img_size, 1);
|
477 |
+
//Get the date that image was uploaded
|
478 |
+
$img_date = get_the_date("", $rec->ID);
|
479 |
}
|
|
|
|
|
|
|
|
|
480 |
|
481 |
+
echo '<tr id="record_' . $rec->ID . '" class="' . $classes . '" >';
|
482 |
+
foreach ($columns as $column_name => $column_display_name) {
|
483 |
|
484 |
+
$class = sprintf('class="%1$s column-%1$s"', $column_name);
|
485 |
+
$style = "";
|
486 |
|
487 |
+
if (in_array($column_name, $hidden)) {
|
488 |
+
$style = ' style="display:none;"';
|
489 |
+
}
|
|
|
|
|
490 |
|
491 |
+
$attributes = $class . $style;
|
492 |
+
|
493 |
+
switch ($column_name) {
|
494 |
+
case 'cb':
|
495 |
+
echo '<td scope="row" class="check-column" style="padding:8px 10px;">';
|
496 |
+
echo '<input id="cb-select-1" class="metaseo_post" type="checkbox" name="post[]" value="' . $rec->ID . '">';
|
497 |
+
echo '</td>';
|
498 |
+
break;
|
499 |
+
|
500 |
+
case 'col_id':
|
501 |
+
echo '<td class="col_id" colspan="1">';
|
502 |
+
echo $i;
|
503 |
+
echo '</td>';
|
504 |
+
break;
|
505 |
+
|
506 |
+
case 'col_image':
|
507 |
+
$img = sprintf("<img src='$thumb_url' width='100px' height='100px' class=\"metaseo-image\" data-name=\"$img_name$type\" data-img-post-id=\"$rec->ID\" />");
|
508 |
+
|
509 |
+
echo sprintf('<td %2$s colspan="3">%1$s</td>', $img, $attributes);
|
510 |
+
break;
|
511 |
+
|
512 |
+
case 'col_image_name':
|
513 |
+
$info = '<div class="img-name-wrapper">';
|
514 |
+
$info .= '<textarea name="name_image[' . $rec->ID . ']" class="metaseo-img-meta metaseo-img-name" data-meta-type="change_image_name" id="img-name-' . $rec->ID . '" data-post-id="' . $rec->ID . '" rows="2" data-extension="' . $type . '">' . $img_name . '</textarea><span class="img_type">' . $type . '</span>';
|
515 |
+
$info .= '<p>size: ' . $img_size . $img_sizes . '</p>';
|
516 |
+
$info .= '<p>' . $img_width . 'x' . $img_height . '</p>';
|
517 |
+
$info .= '<p>' . $img_date . '</p>';
|
518 |
+
$info .= '<span class="saved-info" style="position:relative">
|
519 |
+
<span class="meta-update" style="position:absolute"></span>
|
520 |
+
</span>';
|
521 |
+
$info .= '</div>';
|
522 |
+
echo sprintf('<td %2$s colspan="4">%1$s</td>', $info, $attributes);
|
523 |
+
break;
|
524 |
+
|
525 |
+
case 'col_image_info':
|
526 |
+
$icon = '<img src= "' . WPMETASEO_PLUGIN_URL . 'img/view.png" />';
|
527 |
+
$icon = '';
|
528 |
+
$info = "<div class=\"opt-info\" id=\"opt-info-$rec->ID\"></div>";
|
529 |
+
$info .= '<span class="metaseo-loading"></span>';
|
530 |
+
$info .= '
|
531 |
+
<div class="popup-bg"></div>
|
532 |
+
<div class="popup post-list">
|
533 |
+
<span class="popup-close" title="Close">x</span>
|
534 |
<div class="popup-content"></div>
|
535 |
</div>
|
536 |
+
';
|
537 |
+
|
538 |
+
echo sprintf('<td %2$s colspan="5" style="position:relative">%1$s</td>', $info, $attributes);
|
539 |
+
break;
|
540 |
+
|
541 |
+
case 'col_image_alternative':
|
542 |
+
$input = ("<textarea name='img_alternative[$rec->ID]' class='metaseo-img-meta' data-meta-type='alt_text' id='img-alt-$rec->ID' data-post-id='$rec->ID' rows='2'>" . esc_attr($rec->alt) . "</textarea>");
|
543 |
+
$input .= ('<span class="saved-info" style="position:relative">
|
544 |
+
<span class="meta-update" style="position:absolute"></span>
|
545 |
+
</span>');
|
546 |
+
echo sprintf('<td %2$s colspan="3">%1$s</td>', $input, $attributes);
|
547 |
+
break;
|
548 |
+
|
549 |
+
case 'col_image_title':
|
550 |
+
$input = ("<textarea name='img_title[$rec->ID]' class='metaseo-img-meta' data-meta-type='image_title' id='img-title-$rec->ID' data-post-id='$rec->ID' rows='2'>" . esc_attr($rec->title) . "</textarea>");
|
551 |
+
$input .= ('<span class="saved-info" style="position:relative">
|
552 |
+
<span class="meta-update" style="position:absolute"></span>
|
553 |
+
</span>');
|
554 |
+
echo sprintf('<td %2$s colspan="3">%1$s</td>', $input, $attributes);
|
555 |
+
break;
|
556 |
+
|
557 |
+
case 'col_image_legend':
|
558 |
+
$input = ("<textarea name='img_legend[$rec->ID]' class='metaseo-img-meta' data-meta-type='image_caption' id='img-legend-$rec->ID' data-post-id='$rec->ID' rows='2'>" . esc_attr($rec->legend) . "</textarea>");
|
559 |
+
$input .= ('<span class="saved-info" style="position:relative">
|
560 |
+
<span class="meta-update" style="position:absolute"></span>
|
561 |
+
</span>');
|
562 |
+
echo sprintf('<td %2$s colspan="3">%1$s</td>', $input, $attributes);
|
563 |
+
break;
|
564 |
+
|
565 |
+
case 'col_image_desc':
|
566 |
+
$input = ("<textarea name='img_desc[$rec->ID]' class='metaseo-img-meta' data-meta-type='image_description' id='img-desc-$rec->ID' data-post-id='$rec->ID' rows='2'>" . esc_attr($rec->des) . "</textarea>");
|
567 |
+
$input .= ('<span class="saved-info" style="position:relative">
|
568 |
+
<span class="meta-update" style="position:absolute"></span>
|
569 |
+
</span>');
|
570 |
+
echo sprintf('<td %2$s colspan="3">%1$s</td>', $input, $attributes);
|
571 |
+
break;
|
572 |
+
}
|
573 |
}
|
574 |
+
|
575 |
+
echo '</tr>';
|
576 |
}
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
/*
|
582 |
+
* Add a size for image
|
583 |
+
*/
|
584 |
+
public static function add_more_attachment_sizes_js($response, $attachment) {
|
585 |
+
$metaseo_imgs_sizes = get_post_meta($attachment->ID, '_metaseo_sizes_optional', true);
|
586 |
+
|
587 |
+
if (!empty($metaseo_imgs_sizes)) {
|
588 |
+
foreach ($metaseo_imgs_sizes as $key => $size) {
|
589 |
+
$response['sizes'][$key] = $size;
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
return $response;
|
594 |
+
}
|
595 |
+
|
596 |
+
/*
|
597 |
+
* Add to the list of image sizes that are available to administrators in the WordPress Media Library.
|
598 |
+
*/
|
599 |
+
public static function add_more_attachment_sizes_choose($sizes) {
|
600 |
+
global $wpdb;
|
601 |
+
$query = "SELECT `meta_value` FROM $wpdb->postmeta WHERE `meta_key` = '_metaseo_sizes_optional' AND `meta_value` <> ''";
|
602 |
+
|
603 |
+
$metaseo_imgs_sizes = $wpdb->get_results($query);
|
604 |
+
if (!empty($metaseo_imgs_sizes)) {
|
605 |
+
$_sizes = array();
|
606 |
+
foreach ($metaseo_imgs_sizes as $metaseo_img_sizes) {
|
607 |
+
$metaseo_img_sizes = @unserialize($metaseo_img_sizes->meta_value);
|
608 |
+
if (!empty($metaseo_img_sizes)) {
|
609 |
+
foreach ($metaseo_img_sizes as $key => $size) {
|
610 |
+
add_image_size($key, $size['width'], $size['height'], false);
|
611 |
+
}
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
$new_sizes = array();
|
617 |
+
|
618 |
+
$added_sizes = get_intermediate_image_sizes();
|
619 |
+
|
620 |
+
// $added_sizes is an indexed array, therefore need to convert it
|
621 |
+
// to associative array, using $value for $key and $value
|
622 |
+
foreach ($added_sizes as $value) {
|
623 |
+
if (strpos($value, '-metaseo') !== false) {
|
624 |
+
$_value = substr($value, 0, strrpos($value, '-metaseo'));
|
625 |
+
} else {
|
626 |
+
$_value = $value;
|
627 |
+
}
|
628 |
+
$new_sizes[$value] = ucwords(str_replace(array('-', '_'), ' – ', $_value));
|
629 |
+
}
|
630 |
+
|
631 |
+
// This preserves the labels in $sizes, and merges the two arrays
|
632 |
+
$new_sizes = array_merge($new_sizes, $sizes);
|
633 |
+
|
634 |
+
return $new_sizes;
|
635 |
+
}
|
636 |
+
|
637 |
+
/*
|
638 |
+
* Display page fix meta list
|
639 |
+
*/
|
640 |
+
private static function display_fix_metas_list($img_post_id, $posts, $meta_counter, $p, $im) {
|
641 |
+
if ($meta_counter) {
|
642 |
+
$header = sprintf(__('We found %s image which needed to add or change meta information', 'wp-meta-seo'), $meta_counter . $im . $p);
|
643 |
+
} else {
|
644 |
+
$header = __('We found 0 image which needed to add or change meta information', 'wp-meta-seo'); //__('We found 0 image which needed to add or change meta information', 'wp-meta-seo');
|
645 |
+
}
|
646 |
+
|
647 |
+
//Get default meta information of the image
|
648 |
+
$img_post = get_post($img_post_id);
|
649 |
+
$alt = get_post_meta($img_post_id, '_wp_attachment_image_alt', true);
|
650 |
+
$title = $img_post->post_title;
|
651 |
+
?>
|
652 |
+
<h3 class="content-header"><?php echo $header ?></h3>
|
653 |
+
<div class="content-box">
|
654 |
+
<table class="wp-list-table widefat fixed posts">
|
655 |
+
<thead></thead>
|
656 |
+
<tbody>
|
657 |
+
<?php $alternate = ''; ?>
|
658 |
+
<?php if (count($posts) < 1): ?>
|
659 |
+
<tr><td colspan="10" style="height:95%"><?php echo __('This image has still not been inserted in any post!', 'wp-meta-seo') ?></td></tr>
|
660 |
+
<?php else: ?>
|
661 |
+
<tr class="metaseo-border-bottom">
|
662 |
+
<td colspan="1">ID</td>
|
663 |
+
<td colspan="2">Title</td>
|
664 |
+
<td colspan="2">Image</td>
|
665 |
+
<td colspan="5">Image Meta</td>
|
666 |
+
</tr>
|
667 |
+
<?php foreach ($posts as $post): ?>
|
668 |
+
<?php foreach ($post['meta'] as $k => $meta): ?>
|
669 |
+
<?php
|
670 |
+
$alternate = 'alternate' == $alternate ? '' : 'alternate';
|
671 |
+
$file_name = substr($meta['img_src'], strrpos($meta['img_src'], '/') + 1);
|
672 |
+
?>
|
673 |
+
<tr class="<?php echo $alternate ?>">
|
674 |
+
<td colspan="1"><?php echo $post['ID'] ?></td>
|
675 |
+
<td colspan="2">
|
676 |
+
<p><?php echo $post['title'] ?></p>
|
677 |
+
</td>
|
678 |
+
<td colspan="2">
|
679 |
+
<div class="metaseo-img-wrapper">
|
680 |
+
<img src="<?php echo $meta['img_src'] ?>" />
|
681 |
+
</div>
|
682 |
+
</td>
|
683 |
+
<td colspan="5">
|
684 |
+
<?php foreach ($meta['type'] as $type => $value): ?>
|
685 |
+
<div class="metaseo-img-wrapper">
|
686 |
+
<?php
|
687 |
+
$specialChr = array('"', '\'');
|
688 |
+
foreach ($specialChr as $chr) {
|
689 |
+
$value = str_replace($chr, htmlentities2($chr), $value);
|
690 |
+
}
|
691 |
+
?>
|
692 |
+
<input type="text" value="<?php echo ($value != '' ? $value : ''); ?>" id="metaseo-img-<?php echo $type . '-' . $post['ID'] ?>" class="metaseo-fix-meta metaseo-img-<?php echo $type ?>" data-meta-key="_metaseo_fix_metas" data-post-id="<?php echo $post['ID'] ?>" data-img-post-id="<?php echo $img_post_id ?>" data-meta-type="<?php echo $type ?>" data-meta-order="<?php echo $k ?>" data-file-name="<?php echo $file_name; ?>" placeholder="<?php echo ($value == '' ? __(ucfirst($type) . ' is empty', 'wp-meta-seo') : '') ?>" onfocus="metaseo_fix_meta(this);" onblur="updateInputBlur(this)" onkeydown="return checkeyCode(event, this)" />
|
693 |
+
<span class="meta-update"></span>
|
694 |
+
<?php if (trim($$type) != '' && trim($$type) != $value): ?>
|
695 |
+
<a class="button meta-default" href="#" data-default-value="<?php echo esc_attr($$type) ?>" title="Add to input box" onclick="add_meta_default(this)"> <?php echo '<img src= "' . WPMETASEO_PLUGIN_URL . 'img/img-arrow.png" />' ?> Copy </a>
|
696 |
+
<span class="img_seo_type"><?php echo $$type; ?></span>
|
697 |
+
<?php endif ?>
|
698 |
+
</div>
|
699 |
+
<?php endforeach ?>
|
700 |
+
<span class="saved-info"></span>
|
701 |
+
</td>
|
702 |
+
</tr>
|
703 |
+
<?php endforeach ?>
|
704 |
+
<?php endforeach ?>
|
705 |
+
<?php endif ?>
|
706 |
+
</tbody>
|
707 |
+
<tfoot></tfoot>
|
708 |
+
</table>
|
709 |
+
</div>
|
710 |
+
<div style="padding:5px"></div>
|
711 |
+
<?php
|
712 |
+
}
|
713 |
+
|
714 |
+
/*
|
715 |
+
* Display page resize image list
|
716 |
+
*/
|
717 |
+
private static function display_resize_image_list($img_post_id, $posts, $img_counter, $p, $im) {
|
718 |
|
719 |
+
$header = sprintf(__('We found %s which needed to optimize', 'wp-meta-seo'), $img_counter . $im . $p);
|
720 |
+
?>
|
721 |
+
<h3 class="content-header"><?php echo $header ?></h3>
|
722 |
+
<div class="content-box">
|
723 |
+
<table class="wp-list-table widefat fixed posts">
|
724 |
+
<thead></thead>
|
725 |
+
<tbody>
|
726 |
+
<tr class="metaseo-border-bottom">
|
727 |
+
<td colspan="1">ID</td>
|
728 |
+
<td colspan="3">Title</td>
|
729 |
+
<td colspan="4">Current Images</td>
|
730 |
+
<td colspan="2" class="metaseo-action">Action</td>
|
731 |
+
<td colspan="4">After Replacing</td>
|
732 |
+
</tr>
|
733 |
+
<?php
|
734 |
+
$alternate = "";
|
735 |
+
foreach ($posts as $post):
|
736 |
+
?>
|
737 |
+
<?php $alternate = 'alternate' == $alternate ? '' : 'alternate'; ?>
|
738 |
+
<tr class="<?php echo $alternate ?>">
|
739 |
+
<td colspan="1"><?php echo $post['ID'] ?></td>
|
740 |
+
<td colspan="3">
|
741 |
+
<p><?php echo $post['title'] ?></p>
|
742 |
+
</td>
|
743 |
+
<td colspan="4" style="overflow: hidden;">
|
744 |
+
<?php foreach ($post['img_before_optm'] as $key => $src): ?>
|
745 |
+
<div class="metaseo-img-wrapper">
|
746 |
+
<div class="metaseo-img">
|
747 |
+
<img width="<?php echo @$src['width']; ?>" height="<?php #echo @$src['height'] ; ?>" src="<?php echo $src['src'] ?>" />
|
748 |
+
<div class="img-choosen">
|
749 |
+
<input type="checkbox" checked="true" class="metaseo-checkin checkin-<?php echo $post['ID'] ?>" value="<?php echo $key ?>" id="checkin-<?php echo $post['ID'] . '-' . $key ?>" onclick="uncheck(this)" />
|
750 |
+
</div>
|
751 |
+
<p class="metaseo-msg"></p>
|
752 |
+
</div>
|
753 |
+
<div class="dimension">
|
754 |
+
Orig. </br>
|
755 |
+
<span>Dimensions</span>: <?php echo $src['dimension'] ?></br>
|
756 |
+
<span>File size</span>: <?php echo $src['size'] . ' ' . $src['sizes'] ?>
|
757 |
+
</div>
|
758 |
+
</div>
|
759 |
+
<?php endforeach ?>
|
760 |
+
</td>
|
761 |
+
<td colspan="2" class="metaseo-action">
|
762 |
+
<a href="javascript:void(0);" class="metaseo-optimize button" data-img-post-id="<?php echo $img_post_id ?>" data-post-id="<?php echo $post['ID'] ?>" onclick="optimize_imgs(this)"><?php echo __('Replace?', 'wp-meta-seo') ?></a>
|
763 |
+
<span class="optimizing spinner"></span>
|
764 |
+
</td>
|
765 |
+
<td colspan="4">
|
766 |
+
<?php foreach ($post['img_after_optm'] as $src): ?>
|
767 |
+
<div class="metaseo-img-wrapper">
|
768 |
+
<div class="metaseo-img">
|
769 |
+
<img src="<?php echo $src['src'] ?>" />
|
770 |
+
</div>
|
771 |
+
<div class="dimension">
|
772 |
+
OPT </br>
|
773 |
+
<span>Dimensions</span>: <?php echo $src['dimension'] ?></br>
|
774 |
+
<span>File size</span>: <?php echo $src['size'] . ' ' . $src['sizes'] ?>
|
775 |
+
</div>
|
776 |
+
</div>
|
777 |
+
<?php endforeach ?>
|
778 |
+
</td>
|
779 |
+
</tr>
|
780 |
+
|
781 |
+
<?php endforeach ?>
|
782 |
+
<tr class="metaseo-border-top">
|
783 |
+
<td colspan="8"></td>
|
784 |
+
<td colspan="2">
|
785 |
+
<a href="javascript:void(0);" id="metaseo-replace-all" class="button button-primary" onclick="optimize_imgs_group(this)">
|
786 |
+
<?php echo __('Replace All') ?>
|
787 |
+
</a>
|
788 |
+
<span class="optimizing spinner"></span>
|
789 |
+
</td>
|
790 |
+
<td colspan="4"></td>
|
791 |
+
</tr>
|
792 |
+
</tbody>
|
793 |
+
<tfoot></tfoot>
|
794 |
+
</table>
|
795 |
+
</div>
|
796 |
+
<div style="padding:5px"></div>
|
797 |
+
<?php
|
798 |
+
}
|
799 |
+
|
800 |
+
/*
|
801 |
+
* Ajax optimize image and update content
|
802 |
+
*/
|
803 |
+
public static function optimizeImages() {
|
804 |
+
if (!empty($_POST['post_id']) && !empty($_POST['img_post_id'])) {
|
805 |
+
$post_id = intval($_POST['post_id']);
|
806 |
+
$img_post_id = intval($_POST['img_post_id']);
|
807 |
+
if (!empty($_POST['img_exclude'])) {
|
808 |
+
$img_exclude = $_POST['img_exclude'];
|
809 |
+
} else {
|
810 |
+
$img_exclude = array();
|
811 |
}
|
812 |
+
|
813 |
+
$ret = ImageHelper::_optimizeImages($post_id, $img_post_id, $img_exclude);
|
814 |
+
} else {
|
815 |
+
$ret = array(
|
816 |
+
'success' => false,
|
817 |
+
'msg' => __('The post is not existed, please choose one another!', 'wp-meta-seo')
|
818 |
+
);
|
819 |
}
|
820 |
+
|
821 |
+
echo json_encode($ret);
|
822 |
+
wp_die();
|
823 |
}
|
824 |
+
|
825 |
+
/*
|
826 |
+
* Retrieves a modified URL query string.
|
827 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
828 |
public function process_action() {
|
829 |
global $wpdb;
|
830 |
+
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
831 |
+
$redirect = false;
|
832 |
|
833 |
if (isset($_POST['search']) and $_POST['search'] === 'Search') {
|
834 |
+
$current_url = add_query_arg(array("search" => "Search", "txtkeyword" => urlencode(stripslashes($_POST["txtkeyword"]))), $current_url);
|
835 |
$redirect = true;
|
836 |
}
|
837 |
+
|
838 |
if (isset($_POST['filter_date_action']) and $_POST['filter_date_action'] === 'Filter') {
|
839 |
$current_url = add_query_arg(array("sldate" => $_POST["sldate"]), $current_url);
|
840 |
+
$redirect = true;
|
841 |
}
|
842 |
+
|
843 |
+
if (!empty($_POST['paged'])) {
|
844 |
+
$current_url = add_query_arg(array("paged" => intval($_POST['paged'])), $current_url);
|
845 |
+
$redirect = true;
|
846 |
+
}
|
847 |
+
|
848 |
+
if (!empty($_POST['metaseo_imgs_per_page'])) {
|
849 |
+
$current_url = add_query_arg(array("metaseo_imgs_per_page" => intval($_POST['metaseo_imgs_per_page'])), $current_url);
|
850 |
+
$redirect = true;
|
851 |
+
}
|
852 |
+
|
853 |
+
if ($redirect === true) {
|
854 |
+
wp_redirect($current_url);
|
855 |
+
ob_end_flush();
|
856 |
exit();
|
857 |
+
}
|
858 |
}
|
859 |
|
860 |
+
/*
|
861 |
+
* Ajax get list of posts contain this image and its clones
|
862 |
+
*/
|
863 |
+
public static function load_posts_callback() {
|
864 |
+
global $wpdb;
|
865 |
+
$_POST = stripslashes_deep($_POST);
|
866 |
+
$post_id = intval($_POST['post_id']);
|
867 |
+
$img = trim($_POST['img_name']);
|
868 |
+
$opt_key = strtolower(trim($_POST['opt_key']));
|
869 |
+
$btn = preg_replace('/[_]+/i', ' ', $opt_key);
|
870 |
+
$btn = ucwords($btn);
|
871 |
+
$gotIt = false;
|
872 |
+
|
873 |
+
if ($post_id && !empty($img) && !empty($opt_key)) {
|
874 |
+
$fn = "display_{$opt_key}_list";
|
875 |
+
if (method_exists('MetaSeo_Image_List_Table', $fn)) {
|
876 |
+
//Get list of posts contain this image and its clones
|
877 |
+
$posts = ImageHelper::_get_post_list($post_id, $opt_key);
|
878 |
+
|
879 |
+
if (count($posts) > 0) {
|
880 |
+
$img_counter = 0;
|
881 |
+
//Now the time to resize the images
|
882 |
+
if ($opt_key === 'resize_image') {
|
883 |
+
$upload_dir = wp_upload_dir();
|
884 |
+
$metaseo_sizes_optional = get_post_meta($post_id, '_metaseo_sizes_optional', TRUE);
|
885 |
+
if (!is_array($metaseo_sizes_optional)) {
|
886 |
+
$metaseo_sizes_optional = array();
|
887 |
+
}
|
888 |
+
$attachment_meta_data = wp_get_attachment_metadata($post_id);
|
889 |
+
|
890 |
+
foreach ($posts as &$post) {
|
891 |
+
foreach ($post['img_after_optm'] as &$img) {
|
892 |
+
$img_counter++;
|
893 |
+
$destination = $upload_dir['basedir'] . '/' . $img['path'];
|
894 |
+
if (@ImageHelper::IResize($img['src_origin'], $img['width'], $img['height'], $destination)) {
|
895 |
+
|
896 |
+
$size = (filesize($destination) / 1024);
|
897 |
+
if ($size > 1024) {
|
898 |
+
$size = $size / 1024;
|
899 |
+
$sizes = 'MB';
|
900 |
+
} else {
|
901 |
+
$sizes = 'KB';
|
902 |
+
}
|
903 |
+
$size = @round($size, 1);
|
904 |
+
$img['size'] = $size;
|
905 |
+
$img['sizes'] = $sizes;
|
906 |
+
}
|
907 |
+
|
908 |
+
$kpart = ImageHelper::IGetPart($img['path']);
|
909 |
+
$key = preg_replace('/\-(\d+)x(\d+)$/i', '-metaseo${1}${2}', $kpart->name);
|
910 |
+
$key = strtolower($key);
|
911 |
+
$file = substr($img['path'], strrpos($img['path'], '/') + 1);
|
912 |
+
if (!in_array($key, array_keys($metaseo_sizes_optional))) {
|
913 |
+
$metaseo_sizes_optional[$key] = array(
|
914 |
+
'url' => $img['src'],
|
915 |
+
'width' => $img['width'],
|
916 |
+
'height' => $img['height'],
|
917 |
+
'orientation' => 'landscape',
|
918 |
+
);
|
919 |
+
}
|
920 |
+
|
921 |
+
if (!isset($attachment_meta_data['sizes'][$key])) {
|
922 |
+
$attachment_meta_data['sizes'][$key] = array(
|
923 |
+
'file' => $file,
|
924 |
+
'width' => $img['width'],
|
925 |
+
'height' => $img['height'],
|
926 |
+
'mime-type' => 'image/jpeg'
|
927 |
+
);
|
928 |
+
}
|
929 |
+
}
|
930 |
+
}
|
931 |
+
|
932 |
+
wp_update_attachment_metadata($post_id, $attachment_meta_data);
|
933 |
+
update_post_meta($post_id, '_metaseo_sizes_optional', $metaseo_sizes_optional);
|
934 |
+
} elseif ($opt_key === 'fix_metas') {
|
935 |
+
$toEdit = false;
|
936 |
+
$pIDs = array();
|
937 |
+
foreach ($posts as $ID => &$post) {
|
938 |
+
$img_counter += count($post['meta']);
|
939 |
+
foreach ($post['meta'] as $order => $meta) {
|
940 |
+
if ($meta['type']['alt'] == '' || $meta['type']['title'] == '') {
|
941 |
+
$toEdit = true;
|
942 |
+
}
|
943 |
+
|
944 |
+
if ($meta['type']['alt'] != '' && $meta['type']['title'] != '') {
|
945 |
+
$pIDs[$ID][] = $order;
|
946 |
+
}
|
947 |
+
}
|
948 |
+
}
|
949 |
+
|
950 |
+
if ($toEdit === true) {
|
951 |
+
foreach ($pIDs as $ID => $orders) {
|
952 |
+
foreach ($orders as $order) {
|
953 |
+
unset($posts[$ID]['meta'][$order]);
|
954 |
+
if ($img_counter > 0) {
|
955 |
+
$img_counter--;
|
956 |
+
}
|
957 |
+
}
|
958 |
+
|
959 |
+
if (empty($posts[$ID]['meta'])) {
|
960 |
+
unset($posts[$ID]);
|
961 |
+
}
|
962 |
+
}
|
963 |
+
}
|
964 |
+
}
|
965 |
+
//-----------------------------
|
966 |
+
}
|
967 |
+
}
|
968 |
+
}
|
969 |
+
|
970 |
+
//This is a bit crazy but could give more exact information
|
971 |
+
if (count($posts) > 1) {
|
972 |
+
$p = ' in ' . count($posts) . ' posts ';
|
973 |
+
} else {
|
974 |
+
$p = '';
|
975 |
+
}
|
976 |
+
|
977 |
+
if (isset($img_counter) and $img_counter > 1) {
|
978 |
+
$im = ' images ';
|
979 |
+
} else {
|
980 |
+
if (!isset($img_counter)) {
|
981 |
+
$img_counter = 0;
|
982 |
+
}
|
983 |
+
$im = ' image ';
|
984 |
+
}
|
985 |
+
|
986 |
+
self::$fn($post_id, $posts, $img_counter, $p, $im);
|
987 |
+
wp_die();
|
988 |
+
}
|
989 |
+
|
990 |
+
/*
|
991 |
+
* Scan post to find image good and not good
|
992 |
+
*/
|
993 |
+
public static function scan_posts_callback() {
|
994 |
+
$_POST = stripslashes_deep($_POST);
|
995 |
+
$imgs = $_POST['imgs'];
|
996 |
+
if (!empty($imgs)) {
|
997 |
+
if (!is_array($imgs)) {
|
998 |
+
$ret['success'] = false;
|
999 |
+
$ret['msg'] = 'No images are available, please check again!';
|
1000 |
+
return $ret;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
$_imgs = array();
|
1004 |
+
$_imgs[trim($imgs['name'])] = $imgs['img_post_id'];
|
1005 |
+
unset($imgs);
|
1006 |
+
|
1007 |
+
if (!count($_imgs)) {
|
1008 |
+
$ret['success'] = false;
|
1009 |
+
$ret['msg'] = 'No images are available, please check again!';
|
1010 |
+
return $ret;
|
1011 |
+
}
|
1012 |
+
|
1013 |
+
$msg = ImageHelper::IScanPosts($_imgs, true);
|
1014 |
+
$ret['msg'] = $msg;
|
1015 |
+
$ret['success'] = true;
|
1016 |
+
} else {
|
1017 |
+
$ret['success'] = false;
|
1018 |
+
$ret['msg'] = 'No images are available, please check again!';
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
echo json_encode($ret);
|
1022 |
+
wp_die();
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
/*
|
1026 |
+
* Ajax update image meta
|
1027 |
+
*/
|
1028 |
+
public static function updateMeta_callback() {
|
1029 |
+
global $wpdb;
|
1030 |
+
$response = new stdClass();
|
1031 |
+
$response->updated = false;
|
1032 |
+
if (!empty($_POST['addition']['meta_key'])) {
|
1033 |
+
self::updateImgMeta_call_back($_POST['addition']);
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
if (!empty($_POST['meta_type']) and $_POST['meta_type'] == 'change_image_name') {
|
1037 |
+
self::updateImageName_callback($_POST);
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
if (!empty($_POST['meta_type']) && !empty($_POST['post_id'])) {
|
1041 |
+
$meta_type = strtolower(trim($_POST['meta_type']));
|
1042 |
+
$post_id = intval($_POST['post_id']);
|
1043 |
+
|
1044 |
+
if (!isset($_POST['meta_value'])) {
|
1045 |
+
$meta_value = '';
|
1046 |
+
} else {
|
1047 |
+
$meta_value = trim($_POST['meta_value']);
|
1048 |
+
if (preg_match('/[<>\/\'\"]+/', $meta_value)) {
|
1049 |
+
$response->updated = false;
|
1050 |
+
$response->message = 'Should not html tag or special char';
|
1051 |
+
|
1052 |
+
echo json_encode($response);
|
1053 |
+
wp_die();
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
|
1057 |
+
$label = str_replace('_', ' ', $meta_type);
|
1058 |
+
$label = ucfirst($label);
|
1059 |
+
|
1060 |
+
$aliases = array('image_title' => 'post_title', 'image_caption' => 'post_excerpt', 'image_description' => 'post_content', 'alt_text' => '_wp_attachment_image_alt');
|
1061 |
+
|
1062 |
+
if ($meta_type != 'alt_text') {
|
1063 |
+
$data = array('ID' => $post_id, $aliases[$meta_type] => $meta_value);
|
1064 |
+
|
1065 |
+
if (wp_update_post($data)) {
|
1066 |
+
$response->updated = true;
|
1067 |
+
$response->msg = __($label . ' was saved', 'wp-meta-seo');
|
1068 |
+
}
|
1069 |
+
} else {
|
1070 |
+
update_post_meta($post_id, $aliases[$meta_type], $meta_value);
|
1071 |
+
$response->updated = true;
|
1072 |
+
$response->msg = __($label . ' was saved', 'wp-meta-seo');
|
1073 |
+
}
|
1074 |
+
} else {
|
|
|
|
|
1075 |
$response->msg = __('There is a problem when update image meta!', 'wp-meta-seo');
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
echo json_encode($response);
|
1079 |
wp_die();
|
1080 |
+
}
|
1081 |
|
1082 |
+
/*
|
1083 |
+
* Update image name
|
1084 |
+
*/
|
1085 |
+
public static function updateImageName_callback() {
|
1086 |
|
1087 |
global $wpdb;
|
1088 |
$postID = (int) $_POST['post_id'];
|
1096 |
|
1097 |
$upload_dirs = wp_upload_dir();
|
1098 |
$upload_dir = $upload_dirs['basedir'];
|
1099 |
+
$oldpart = ImageHelper::IGetPart($linkold);
|
1100 |
+
$old_name = $oldpart->name;
|
1101 |
+
|
1102 |
if ($name !== "") {
|
1103 |
if (file_exists($upload_dir . "/" . $linkold)) {
|
1104 |
$newFileName = $oldpart->base_path . $iname . $oldpart->ext;
|
1105 |
+
// check file not exist
|
1106 |
+
if (!file_exists($upload_dir . "/" . $newFileName)) {
|
1107 |
if (rename($upload_dir . "/" . $linkold, $upload_dir . "/" . $newFileName)) {
|
1108 |
+
$post_title = get_the_title($postID);
|
1109 |
$data_post = array('ID' => $postID, 'post_name' => $name);
|
1110 |
//if (wp_update_post($data_post)) {
|
1111 |
+
$where = array('ID' => $postID);
|
1112 |
+
$guid = $upload_dirs['baseurl'] . "/" . $newFileName;
|
1113 |
+
if (!$post_title) {
|
1114 |
+
$id = $wpdb->update($wpdb->posts, array('guid' => $guid, 'post_title' => $name, 'post_name' => strtolower($iname)), $where);
|
1115 |
+
} else {
|
1116 |
+
$id = $wpdb->update($wpdb->posts, array('guid' => $guid), $where);
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
if ($id) {
|
|
|
1120 |
$attached_metadata = get_post_meta($postID, "_wp_attachment_metadata", true);
|
1121 |
$attached_metadata["file"] = $newFileName;
|
1122 |
+
|
1123 |
+
$images_to_rename = array($oldpart->name . $oldpart->ext => $iname . $oldpart->ext);
|
1124 |
+
$old_path = $upload_dir . "/" . $linkold;
|
1125 |
+
|
1126 |
+
foreach ($attached_metadata['sizes'] as &$clone) {
|
1127 |
+
$clone_file_new = ImageHelper::IReplace($iname, $clone['file']);
|
1128 |
+
$clone_path = $upload_dir . '/' . $oldpart->base_path . $clone['file'];
|
1129 |
+
$clone_path_new = $upload_dir . '/' . $oldpart->base_path . $clone_file_new;
|
1130 |
+
|
1131 |
+
if (@rename($clone_path, $clone_path_new)) {
|
1132 |
+
$images_to_rename[$clone['file']] = $clone_file_new;
|
1133 |
+
$clone['file'] = $clone_file_new;
|
1134 |
+
}
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
$metadats = get_post_meta($postID, '_wp_attachment_metadata', true);
|
1138 |
+
$sizes = $metadats['sizes'];
|
1139 |
+
|
1140 |
+
// get list image url and image thumbnail url
|
1141 |
+
$list_thum_url = array();
|
1142 |
+
$imageUrl = wp_get_attachment_url($postID);
|
1143 |
+
$list_thum_url[] = $imageUrl;
|
1144 |
+
foreach ($sizes as $key => $size){
|
1145 |
+
$thum_url = wp_get_attachment_image_src($postID,$key);
|
1146 |
+
$list_thum_url[] = $thum_url[0];
|
1147 |
+
}
|
1148 |
+
|
1149 |
+
$w = '';
|
1150 |
+
$w .= '(';
|
1151 |
+
|
1152 |
+
$i = 0;
|
1153 |
+
foreach ($list_thum_url as $url){
|
1154 |
+
$i++;
|
1155 |
+
if($i == count($list_thum_url)){
|
1156 |
+
$w .= ' post_content LIKE "%' . $url . '%"';
|
1157 |
+
}else{
|
1158 |
+
$w .= ' post_content LIKE "%' . $url . '%" OR';
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
$w .= ')';
|
1164 |
+
$where = array();
|
1165 |
+
$where[] = "(`post_type` = 'post' or `post_type` = 'page')";
|
1166 |
+
$where[] = "post_content LIKE '%<img%>%'";
|
1167 |
+
$where[] = $w;
|
1168 |
+
$query = "SELECT `ID`, `post_title`, `post_content`, `post_type`, `post_date`
|
1169 |
+
FROM $wpdb->posts
|
1170 |
+
WHERE ".implode(' AND ', $where)." ORDER BY ID";
|
1171 |
+
// query post
|
1172 |
+
$posts = $wpdb->get_results($query);
|
1173 |
+
$imgs = array($old_name . $oldpart->ext => $postID);
|
1174 |
+
$posts_contain_img = array();
|
1175 |
+
foreach ($posts as $post) {
|
1176 |
+
$ifound = ImageHelper::IScan($imgs, $post->post_content);
|
1177 |
+
if (count($ifound) > 0) {
|
1178 |
+
$posts_contain_img[] = $post->ID;
|
1179 |
+
}
|
1180 |
+
}
|
1181 |
+
|
1182 |
+
// update post
|
1183 |
+
foreach ($posts_contain_img as $id) {
|
1184 |
+
if ($post = get_post($id)) {
|
1185 |
+
foreach ($images_to_rename as $src_before => $src_after) {
|
1186 |
+
$src_before = '/' . $src_before;
|
1187 |
+
$src_after = '/' . $src_after;
|
1188 |
+
$post->post_content = str_replace($src_before, $src_after, $post->post_content);
|
1189 |
+
}
|
1190 |
+
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1191 |
+
wp_update_post(array(
|
1192 |
+
'ID' => $post->ID,
|
1193 |
+
'post_content' => $post->post_content)
|
1194 |
+
);
|
1195 |
+
|
1196 |
+
unset($post, $posts_contain_img);
|
1197 |
+
//---------------------------------
|
1198 |
+
}
|
1199 |
+
}
|
1200 |
+
|
1201 |
+
/* * ************************************************** */
|
1202 |
+
/** Update Image registered to Attachment sizes on Add media page* */
|
1203 |
+
$sizeOptional = get_post_meta($postID, '_metaseo_sizes_optional', true);
|
1204 |
+
$newOptional = array();
|
1205 |
+
if (!empty($sizeOptional) && is_array($sizeOptional)) {
|
1206 |
+
foreach ($sizeOptional as $key => $detail) {
|
1207 |
+
$pattern = '/^' . strtolower($old_name) . '(-metaseo\d+)$/';
|
1208 |
+
$key = preg_replace($pattern, strtolower($iname) . '${1}', $key);
|
1209 |
+
$detail['url'] = ImageHelper::IReplace($iname, $detail['url']);
|
1210 |
+
$newOptional[$key] = $detail;
|
1211 |
+
}
|
1212 |
+
|
1213 |
+
update_post_meta($postID, '_metaseo_sizes_optional', $newOptional);
|
1214 |
+
unset($sizeOptional, $newOptional);
|
1215 |
+
}
|
1216 |
+
/* * ************************************************* */
|
1217 |
+
//Need to update optimization info of this image
|
1218 |
+
ImageHelper::IScanPosts(array($iname . $oldpart->ext => $postID), true);
|
1219 |
+
|
1220 |
update_post_meta($postID, '_wp_attached_file', $newFileName);
|
1221 |
update_post_meta($postID, '_wp_attachment_metadata', $attached_metadata);
|
1222 |
+
|
1223 |
$response->updated = true;
|
1224 |
$response->msg = __('Image name was changed', 'wp-meta-seo');
|
1225 |
} else {
|
1226 |
+
$response->iname = $old_name;
|
1227 |
$response->msg = __('There is a problem when update image name', 'wp-meta-seo');
|
1228 |
}
|
1229 |
}
|
1230 |
} else {
|
1231 |
|
1232 |
$response->msg = __('Name is existing', 'wp-meta-seo');
|
1233 |
+
$response->iname = $old_name;
|
1234 |
}
|
1235 |
} else {
|
1236 |
+
$response->iname = $old_name;
|
1237 |
$response->msg = __('File is not existed', 'wp-meta-seo');
|
1238 |
}
|
1239 |
} else {
|
1240 |
+
$response->iname = $old_name;
|
1241 |
$response->msg = __('Should not be empty', 'wp-meta-seo');
|
1242 |
}
|
1243 |
echo json_encode($response);
|
1244 |
wp_die();
|
1245 |
}
|
1246 |
+
|
1247 |
+
/*
|
1248 |
+
* Update image meta
|
1249 |
+
*/
|
1250 |
+
public static function updateImgMeta_call_back($wpmspost) {
|
1251 |
+
global $wpdb;
|
1252 |
+
$response = new stdClass();
|
1253 |
+
$response->updated = false;
|
1254 |
+
foreach ($wpmspost as $k => $v) {
|
1255 |
+
if (!$v && !in_array($k, array('meta_value', 'meta_order'))) {
|
1256 |
+
$response->msg = __('There is a problem when update image meta!', 'wp-meta-seo');
|
1257 |
+
|
1258 |
+
echo json_encode($response);
|
1259 |
+
wp_die();
|
1260 |
+
}
|
1261 |
+
}
|
1262 |
+
|
1263 |
+
$meta_key = strtolower(trim($wpmspost['meta_key']));
|
1264 |
+
$meta_type = strtolower(trim($wpmspost['meta_type']));
|
1265 |
+
$meta_value = htmlspecialchars(trim($wpmspost['meta_value']));
|
1266 |
+
$meta_order = intval($wpmspost['meta_order']);
|
1267 |
+
$img_post_id = intval($wpmspost['img_post_id']);
|
1268 |
+
$post_id = intval($wpmspost['post_id']);
|
1269 |
+
|
1270 |
+
$meta = get_post_meta($img_post_id, $meta_key, true);
|
1271 |
+
//Update new value for meta info of this image in wp_postmeta
|
1272 |
+
$meta[$post_id]['meta'][$meta_order]['type'][$meta_type] = metaseo_utf8($meta_value);
|
1273 |
+
update_post_meta($img_post_id, $meta_key, $meta);
|
1274 |
+
$meta = get_post_meta($img_post_id, $meta_key, true);
|
1275 |
+
|
1276 |
+
//Then we must update this meta info in the appropriate post content
|
1277 |
+
if (!$post = get_post($post_id)) {
|
1278 |
+
$response->msg = __('The post has been deleted before, please check again!', 'wp-meta-seo');
|
1279 |
+
} else {
|
1280 |
+
if ($post->post_content !== '') {
|
1281 |
+
//Split content part that do not contain img tag
|
1282 |
+
$post_content_split = preg_split('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content);
|
1283 |
+
//Get all img tag from the content
|
1284 |
+
preg_match_all('/(<img[\s]+[^>]*src\s*=\s*)([\"\'])([^>]+?)\2([^<>]*>)/i', $post->post_content, $matches);
|
1285 |
+
$img_tags = $matches[0];
|
1286 |
+
|
1287 |
+
if (isset($img_tags[$meta_order])) {
|
1288 |
+
$pattern = '/' . $meta_type . '\s*?\=?\"[^\"]*\"/i';
|
1289 |
+
$replacement = $meta_type . '="' . $meta_value . '"';
|
1290 |
+
|
1291 |
+
if (!preg_match($pattern, $img_tags[$meta_order], $match)) {
|
1292 |
+
$pattern = '/\/>/i';
|
1293 |
+
$replacement = $meta_type . '="' . $meta_value . '" />';
|
1294 |
+
}
|
1295 |
+
|
1296 |
+
$doc = new DOMDocument();
|
1297 |
+
libxml_use_internal_errors(true);
|
1298 |
+
@$doc->loadHtml($img_tags[$meta_order]);
|
1299 |
+
$tags = $doc->getElementsByTagName('img');
|
1300 |
+
if($tags->length > 0){
|
1301 |
+
if(!empty($tags)){
|
1302 |
+
$tags->item(0)->setAttribute($meta_type, $meta_value);
|
1303 |
+
$img_tags[$meta_order] = $doc->saveHtml();
|
1304 |
+
}
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
// create new post content
|
1308 |
+
$post_content = '';
|
1309 |
+
foreach ($post_content_split as $key => $split) {
|
1310 |
+
if (isset($img_tags[$key])) {
|
1311 |
+
$img_tag = $img_tags[$key];
|
1312 |
+
} else {
|
1313 |
+
$img_tag = '';
|
1314 |
+
}
|
1315 |
+
$post_content .= $split . $img_tag;
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
remove_action('post_updated', array('MetaSeo_Broken_Link_Table', 'wpms_update_post'));
|
1319 |
+
|
1320 |
+
//Update content of this post.
|
1321 |
+
if (!wp_update_post(array('ID' => $post->ID, 'post_content' => $post_content))) {
|
1322 |
+
$response->msg = __('The post haven\'t been updated, please check again!', 'wp-meta-seo');
|
1323 |
+
} else {
|
1324 |
+
$response->updated = true;
|
1325 |
+
$response->msg = __(ucfirst($meta_type) . ' was saved', 'wp-meta-seo');
|
1326 |
+
}
|
1327 |
+
} else {
|
1328 |
+
$response->msg = __('This image has been removed from the post, please check again!', 'wp-meta-seo');
|
1329 |
+
}
|
1330 |
+
} else {
|
1331 |
+
$response->msg = __('Content of the post is empty, please check again', 'wpms!');
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
|
1336 |
+
echo json_encode($response);
|
1337 |
+
wp_die();
|
1338 |
+
}
|
1339 |
+
|
1340 |
+
}
|
inc/class.metaseo-link-list-table.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
*
|
4 |
-
*
|
5 |
*
|
6 |
*/
|
7 |
|
@@ -9,8 +8,9 @@ if (!class_exists('WP_List_Table')) {
|
|
9 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
10 |
}
|
11 |
wp_enqueue_style('metaseo-google-icon');
|
12 |
-
class MetaSeo_Link_List_Table extends WP_List_Table {
|
13 |
|
|
|
|
|
14 |
function __construct() {
|
15 |
parent::__construct(array(
|
16 |
'singular' => 'metaseo_image',
|
@@ -19,25 +19,26 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
19 |
));
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
22 |
function display_tablenav($which) {
|
23 |
-
$post_types = get_post_types( array('public' => true, 'exclude_from_search' => false) ) ;
|
24 |
-
if(!empty($post_types['attachment'])) unset($post_types['attachment']);
|
25 |
-
$p_type = "('".implode("','", $post_types)."')";
|
26 |
?>
|
27 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
28 |
|
29 |
-
|
30 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
31 |
<div class="alignleft actions bulkactions">
|
32 |
-
|
33 |
-
|
34 |
</div>
|
35 |
-
|
36 |
-
|
37 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
38 |
<div class="alignleft actions bulkactions">
|
39 |
-
|
40 |
-
|
41 |
</div>
|
42 |
<?php endif ?>
|
43 |
|
@@ -46,30 +47,33 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
46 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
47 |
<?php endif ?>
|
48 |
|
49 |
-
<?php //$this->extra_tablenav($which); ?>
|
50 |
-
|
51 |
<div style="float:right;margin-left:8px;">
|
52 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_link_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
53 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
54 |
</div>
|
55 |
-
|
56 |
-
|
57 |
<div class="alignleft actions bulkactions">
|
58 |
-
|
59 |
</div>
|
60 |
-
|
61 |
<div class="alignleft actions bulkactions">
|
62 |
-
|
63 |
</div>
|
64 |
<?php endif ?>
|
65 |
-
|
66 |
-
|
67 |
<br class="clear" />
|
68 |
</div>
|
69 |
|
70 |
<?php
|
71 |
}
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
function get_views() {
|
74 |
global $wpdb;
|
75 |
|
@@ -77,11 +81,11 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
77 |
$status_links = array();
|
78 |
|
79 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
80 |
-
$post_types = "'" . implode("', '", $post_types) . "'";
|
81 |
|
82 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
83 |
$states['trash'] = 'trash';
|
84 |
-
$all_states = "'" . implode("', '", $states) . "'";
|
85 |
|
86 |
$total_posts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types)");
|
87 |
|
@@ -112,10 +116,12 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
112 |
|
113 |
return $status_links;
|
114 |
}
|
115 |
-
|
|
|
|
|
|
|
|
|
116 |
function extra_tablenav($which) {
|
117 |
-
|
118 |
-
#if ('top' == $which) {
|
119 |
echo '<div class="alignleft actions">';
|
120 |
global $wpdb;
|
121 |
|
@@ -139,10 +145,13 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
139 |
}
|
140 |
|
141 |
echo "</div>";
|
142 |
-
#echo "</form>";
|
143 |
-
#}
|
144 |
}
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
146 |
function get_columns() {
|
147 |
return $columns = array(
|
148 |
'cb' => '<input id="cb-select-all-1" type="checkbox">',
|
@@ -153,7 +162,16 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
153 |
'col_follow' => __('Follow', 'wp-meta-seo')
|
154 |
);
|
155 |
}
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
function get_sortable_columns() {
|
158 |
return $sortable = array(
|
159 |
'post_id' => array('post_title', true),
|
@@ -243,8 +261,34 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
243 |
}
|
244 |
}
|
245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
function prepare_items() {
|
247 |
global $wpdb, $_wp_column_headers;
|
|
|
|
|
248 |
$where = array('1=1');
|
249 |
|
250 |
$keyword = !empty($_GET["txtkeyword"]) ? $_GET["txtkeyword"] : '';
|
@@ -255,13 +299,13 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
255 |
if (isset($_GET['metaseo_link_source']) && $_GET['metaseo_link_source'] == 'internal') {
|
256 |
$where[] .= 'internal = 1';
|
257 |
}
|
258 |
-
|
259 |
if (isset($_GET['metaseo_link_source']) && $_GET['metaseo_link_source'] == 'external') {
|
260 |
$where[] .= 'internal = 0';
|
261 |
}
|
262 |
-
|
263 |
$where[] .= 'type="url"';
|
264 |
-
|
265 |
$orderby = !empty($_GET["orderby"]) ? ($_GET["orderby"]) : 'id';
|
266 |
$order = !empty($_GET["order"]) ? ($_GET["order"]) : 'asc';
|
267 |
$sortable = $this->get_sortable_columns();
|
@@ -278,15 +322,18 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
278 |
}
|
279 |
|
280 |
if (!empty($orderby) & !empty($order)) {
|
281 |
-
$orderStr = ' ORDER BY '
|
|
|
282 |
}
|
283 |
|
284 |
-
$query = "SELECT
|
|
|
285 |
$columns = $this->get_columns();
|
286 |
$hidden = array();
|
287 |
$sortable = $this->get_sortable_columns();
|
288 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
289 |
-
|
|
|
290 |
if (!empty($_REQUEST['metaseo_broken_link_per_page'])) {
|
291 |
$_per_page = intval($_REQUEST['metaseo_broken_link_per_page']);
|
292 |
} else {
|
@@ -329,6 +376,9 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
329 |
$this->items = $wpdb->get_results($query);
|
330 |
}
|
331 |
|
|
|
|
|
|
|
332 |
function search_box1() {
|
333 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
334 |
return;
|
@@ -343,190 +393,190 @@ class MetaSeo_Link_List_Table extends WP_List_Table {
|
|
343 |
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
|
344 |
?>
|
345 |
<p class="search-box">
|
346 |
-
|
347 |
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
|
348 |
-
|
349 |
</p>
|
350 |
<?php
|
351 |
}
|
352 |
|
353 |
-
|
|
|
354 |
?>
|
355 |
<select name="metaseo_follow_action" class="metaseo_follow_action">
|
356 |
-
<option value="0"><?php _e('-- Selection --','wp-meta-seo') ?></option>
|
357 |
-
<option value="follow_selected"><?php _e('Follow selected','wp-meta-seo') ?></option>
|
358 |
-
<option value="nofollow_selected"><?php _e('Nofollow selected','wp-meta-seo') ?></option>
|
359 |
-
<option value="follow_all"><?php _e('Follow all','wp-meta-seo') ?></option>
|
360 |
-
<option value="nofollow_all"><?php _e('Nofollow all','wp-meta-seo') ?></option>
|
361 |
</select>
|
362 |
-
<input type="button" class="button btn_apply_follow" value="<?php _e('Apply','wp-meta-seo') ?>">
|
363 |
<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link page_link_meta"><?php _e('Re-index content links', 'wp-meta-seo') ?></div>
|
364 |
<span class="spinner spinner_apply_follow"></span>
|
365 |
<?php
|
366 |
}
|
367 |
|
368 |
-
|
369 |
-
|
|
|
370 |
$link_source = $_GET['metaseo_link_source'];
|
371 |
-
}else{
|
372 |
$link_source = 0;
|
373 |
}
|
374 |
?>
|
375 |
<select name="metaseo_link_source" class="metaseo_link_source">
|
376 |
-
<option value="0" <?php selected($link_source, 0) ?>><?php _e('Link source','wp-meta-seo') ?></option>
|
377 |
-
<option value="internal" <?php selected($link_source, 'internal') ?>><?php _e('Internal','wp-meta-seo') ?></option>
|
378 |
-
<option value="external" <?php selected($link_source, 'external') ?>><?php _e('External','wp-meta-seo') ?></option>
|
379 |
</select>
|
380 |
<?php
|
381 |
}
|
382 |
-
|
383 |
-
|
|
|
384 |
global $wpdb, $wp_locale;
|
|
|
385 |
|
386 |
-
$
|
387 |
-
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
388 |
-
FROM $wpdb->posts
|
389 |
-
WHERE post_type IN $post_type
|
390 |
-
ORDER BY post_date DESC
|
391 |
-
");
|
392 |
-
|
393 |
-
$months = apply_filters('months_dropdown_results', $months, $post_type);
|
394 |
-
$month_count = count($months);
|
395 |
-
|
396 |
-
if (!$month_count || ( 1 == $month_count && 0 == $months[0]->month ))
|
397 |
return;
|
398 |
|
399 |
$m = isset($_REQUEST['sldate']) ? $_REQUEST['sldate'] : 0;
|
400 |
?>
|
401 |
-
<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date','wp-meta-seo'); ?></label>
|
402 |
<select name="<?php echo $name ?>" id="filter-by-date" class="metaseo-filter">
|
403 |
-
<option<?php selected($m, 0); ?> value="0"><?php _e('All dates','wp-meta-seo'); ?></option>
|
404 |
-
<?php
|
405 |
-
foreach ($months as $arc_row) {
|
406 |
-
|
407 |
-
if (0 == $arc_row->year)
|
408 |
-
continue;
|
409 |
-
$month = zeroise($arc_row->month, 2);
|
410 |
-
$year = $arc_row->year;
|
411 |
-
printf("<option %s value='%s' >%s</option>\n", selected($m, "$year-$month", false), esc_attr("$arc_row->year-$month"), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
|
412 |
-
);
|
413 |
-
}
|
414 |
-
?>
|
415 |
-
</select>
|
416 |
-
|
417 |
<?php
|
418 |
-
|
419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
echo '<input id="cb-select-'.$rec->id.'" class="metaseo_link" type="checkbox" name="link['.$rec->id.']" value="'.$rec->id.'">';
|
446 |
-
echo '</td>';
|
447 |
-
break;
|
448 |
-
|
449 |
-
case 'post_id':
|
450 |
-
$post = get_post($rec->source_id);
|
451 |
-
$row_action = array (
|
452 |
-
'edit' => '<a target="_blank" href="'.get_edit_post_link( $rec->source_id ).'" title="Edit this item">Edit</a>',
|
453 |
-
'view' => '<a target="_blank" href="'.get_permalink( $rec->source_id ).'" title="View “test”" rel="permalink">View</a>'
|
454 |
-
);
|
455 |
-
echo '<td class="col_id" colspan="3">';
|
456 |
-
echo '<a target="_blank" href="'.get_edit_post_link( $rec->source_id ).'">'.$post->post_title.'</a>';
|
457 |
-
echo $this->row_actions($row_action ,false);
|
458 |
-
echo '</td>';
|
459 |
-
break;
|
460 |
-
|
461 |
-
case 'col_link_url':
|
462 |
-
echo '<td class="wpms_link_html" colspan="3">';
|
463 |
-
echo '<a target="_blank" href="'.$rec->link_url.'">'.$rec->link_url.'</a>';
|
464 |
-
echo '</td>';
|
465 |
-
break;
|
466 |
-
|
467 |
-
case 'col_link_title':
|
468 |
-
echo '<td colspan="3">';
|
469 |
-
echo '<input type="text" data-post_id="'.$rec->source_id.'" name="metaseo_link_title" id="metaseo_link_title" class="metaseo_link_title" value="'.$rec->meta_title.'">';
|
470 |
-
echo '<div data-post_id="'.$rec->source_id.'" class="wpms_update_link">'.__('Update','wp-meta-seo').'</div>';
|
471 |
-
echo '<strong class="wpms_mesage_link">'.__('Saved.','wp-meta-seo').'</strong>';
|
472 |
-
echo '<strong class="wpms_error_mesage_link">'.__('Error.','wp-meta-seo').'</strong>';
|
473 |
-
echo '</td>';
|
474 |
-
break;
|
475 |
-
|
476 |
-
case 'col_link_label':
|
477 |
-
echo '<td colspan="3">'.strip_tags($rec->link_text).'</td>';
|
478 |
-
break;
|
479 |
-
|
480 |
-
case 'col_follow':
|
481 |
-
if($rec->follow==1){
|
482 |
-
$follow = '<i class="material-icons wpms_ok wpms_change_follow" data-type="done">done</i>';
|
483 |
-
}else{
|
484 |
-
$follow = '<i class="material-icons wpms_warning wpms_change_follow" data-type="warning">warning</i>';
|
485 |
-
}
|
486 |
-
echo '<td colspan="3">'.$follow.'</td>';
|
487 |
-
break;
|
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 |
-
if (isset($_POST['metaseo_link_source'])) {
|
517 |
-
$current_url = add_query_arg(array("metaseo_link_source" => $_POST['metaseo_link_source']), $current_url);
|
518 |
-
$redirect = true;
|
519 |
-
}
|
520 |
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
}
|
531 |
}
|
532 |
-
}
|
|
|
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Base class for displaying a list of links in an ajaxified HTML table.
|
|
|
4 |
*
|
5 |
*/
|
6 |
|
8 |
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
9 |
}
|
10 |
wp_enqueue_style('metaseo-google-icon');
|
|
|
11 |
|
12 |
+
class MetaSeo_Link_List_Table extends WP_List_Table {
|
13 |
+
public $months;
|
14 |
function __construct() {
|
15 |
parent::__construct(array(
|
16 |
'singular' => 'metaseo_image',
|
19 |
));
|
20 |
}
|
21 |
|
22 |
+
/**
|
23 |
+
* Generate the table navigation above or below the table
|
24 |
+
* @param string $which
|
25 |
+
*/
|
26 |
function display_tablenav($which) {
|
|
|
|
|
|
|
27 |
?>
|
28 |
<div class="tablenav <?php echo esc_attr($which); ?>">
|
29 |
|
30 |
+
<?php if ($which == 'top'): ?>
|
31 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
32 |
<div class="alignleft actions bulkactions">
|
33 |
+
<?php $this->months_fillter('sldate', 'filter_date_action'); ?>
|
34 |
+
<?php $this->link_source_fillter(); ?>
|
35 |
</div>
|
36 |
+
|
37 |
+
<?php elseif ($which == 'bottom'): ?>
|
38 |
<input type="hidden" name="page" value="metaseo_image_meta" />
|
39 |
<div class="alignleft actions bulkactions">
|
40 |
+
<?php $this->months_fillter('sldate1', 'filter_date_action'); ?>
|
41 |
+
<?php $this->link_source_fillter(); ?>
|
42 |
</div>
|
43 |
<?php endif ?>
|
44 |
|
47 |
<input type="hidden" name="post_status" value="<?php echo esc_attr($_REQUEST['post_status']); ?>" />
|
48 |
<?php endif ?>
|
49 |
|
|
|
|
|
50 |
<div style="float:right;margin-left:8px;">
|
51 |
<input type="number" required min="1" value="<?php echo $this->_pagination_args['per_page'] ?>" maxlength="3" name="metaseo_link_per_page" class="metaseo_imgs_per_page screen-per-page" max="999" min="1" step="1">
|
52 |
<input type="submit" name="btn_perpage" class="button_perpage button" id="button_perpage" value="Apply" >
|
53 |
</div>
|
54 |
+
|
55 |
+
<?php if ($which == 'top'): ?>
|
56 |
<div class="alignleft actions bulkactions">
|
57 |
+
<?php $this->follow_action(); ?>
|
58 |
</div>
|
59 |
+
<?php elseif ($which == 'bottom'): ?>
|
60 |
<div class="alignleft actions bulkactions">
|
61 |
+
<?php $this->follow_action(); ?>
|
62 |
</div>
|
63 |
<?php endif ?>
|
64 |
+
|
65 |
+
<?php $this->pagination($which); ?>
|
66 |
<br class="clear" />
|
67 |
</div>
|
68 |
|
69 |
<?php
|
70 |
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get an associative array ( id => link ) with the list
|
74 |
+
* of views available on this table.
|
75 |
+
* @return array
|
76 |
+
*/
|
77 |
function get_views() {
|
78 |
global $wpdb;
|
79 |
|
81 |
$status_links = array();
|
82 |
|
83 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
84 |
+
$post_types = "'" . implode("', '", esc_sql($post_types)) . "'";
|
85 |
|
86 |
$states = get_post_stati(array('show_in_admin_all_list' => true));
|
87 |
$states['trash'] = 'trash';
|
88 |
+
$all_states = "'" . implode("', '", esc_sql($states)) . "'";
|
89 |
|
90 |
$total_posts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status IN ($all_states) AND post_type IN ($post_types)");
|
91 |
|
116 |
|
117 |
return $status_links;
|
118 |
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Extra controls to be displayed between bulk actions and pagination
|
122 |
+
* @param string $which
|
123 |
+
*/
|
124 |
function extra_tablenav($which) {
|
|
|
|
|
125 |
echo '<div class="alignleft actions">';
|
126 |
global $wpdb;
|
127 |
|
145 |
}
|
146 |
|
147 |
echo "</div>";
|
|
|
|
|
148 |
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Get a list of columns. The format is:
|
152 |
+
* 'internal-name' => 'Title'
|
153 |
+
* @return array
|
154 |
+
*/
|
155 |
function get_columns() {
|
156 |
return $columns = array(
|
157 |
'cb' => '<input id="cb-select-all-1" type="checkbox">',
|
162 |
'col_follow' => __('Follow', 'wp-meta-seo')
|
163 |
);
|
164 |
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Get a list of sortable columns. The format is:
|
168 |
+
* 'internal-name' => 'orderby'
|
169 |
+
* or
|
170 |
+
* 'internal-name' => array( 'orderby', true )
|
171 |
+
*
|
172 |
+
* The second format will make the initial sorting order be descending
|
173 |
+
* @return array
|
174 |
+
*/
|
175 |
function get_sortable_columns() {
|
176 |
return $sortable = array(
|
177 |
'post_id' => array('post_title', true),
|
261 |
}
|
262 |
}
|
263 |
|
264 |
+
/**
|
265 |
+
* Get months
|
266 |
+
*/
|
267 |
+
function wpmf_get_months(){
|
268 |
+
global $wpdb;
|
269 |
+
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
270 |
+
if (!empty($post_types['attachment']))
|
271 |
+
unset($post_types['attachment']);
|
272 |
+
$p_type = "('" . implode("','", $post_types) . "')";
|
273 |
+
$months = $wpdb->get_results("
|
274 |
+
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
275 |
+
FROM $wpdb->posts
|
276 |
+
WHERE post_type IN $p_type
|
277 |
+
ORDER BY post_date DESC
|
278 |
+
");
|
279 |
+
|
280 |
+
$months = apply_filters('months_dropdown_results', $months, $p_type);
|
281 |
+
return $months;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Prepares the list of items for displaying.
|
286 |
+
* @uses WP_List_Table::set_pagination_args()
|
287 |
+
*/
|
288 |
function prepare_items() {
|
289 |
global $wpdb, $_wp_column_headers;
|
290 |
+
$this->months = $this->wpmf_get_months();
|
291 |
+
|
292 |
$where = array('1=1');
|
293 |
|
294 |
$keyword = !empty($_GET["txtkeyword"]) ? $_GET["txtkeyword"] : '';
|
299 |
if (isset($_GET['metaseo_link_source']) && $_GET['metaseo_link_source'] == 'internal') {
|
300 |
$where[] .= 'internal = 1';
|
301 |
}
|
302 |
+
|
303 |
if (isset($_GET['metaseo_link_source']) && $_GET['metaseo_link_source'] == 'external') {
|
304 |
$where[] .= 'internal = 0';
|
305 |
}
|
306 |
+
|
307 |
$where[] .= 'type="url"';
|
308 |
+
|
309 |
$orderby = !empty($_GET["orderby"]) ? ($_GET["orderby"]) : 'id';
|
310 |
$order = !empty($_GET["order"]) ? ($_GET["order"]) : 'asc';
|
311 |
$sortable = $this->get_sortable_columns();
|
322 |
}
|
323 |
|
324 |
if (!empty($orderby) & !empty($order)) {
|
325 |
+
$orderStr = $wpdb->prepare(' ORDER BY %s ', $orderStr);
|
326 |
+
$orderStr = str_replace("'", "", $orderStr);
|
327 |
}
|
328 |
|
329 |
+
$query = "SELECT COUNT(id) FROM " . $wpdb->prefix . "wpms_links WHERE " . implode(' AND ', $where) . $orderStr;
|
330 |
+
$total_items = $wpdb->get_var($query);
|
331 |
$columns = $this->get_columns();
|
332 |
$hidden = array();
|
333 |
$sortable = $this->get_sortable_columns();
|
334 |
$this->_column_headers = array($columns, $hidden, $sortable);
|
335 |
+
|
336 |
+
$query = "SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE " . implode(' AND ', $where) . $orderStr;
|
337 |
if (!empty($_REQUEST['metaseo_broken_link_per_page'])) {
|
338 |
$_per_page = intval($_REQUEST['metaseo_broken_link_per_page']);
|
339 |
} else {
|
376 |
$this->items = $wpdb->get_results($query);
|
377 |
}
|
378 |
|
379 |
+
/**
|
380 |
+
* Displays the search box.
|
381 |
+
*/
|
382 |
function search_box1() {
|
383 |
if (empty($_REQUEST['txtkeyword']) && !$this->has_items())
|
384 |
return;
|
393 |
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
|
394 |
?>
|
395 |
<p class="search-box">
|
|
|
396 |
<input type="search" id="image-search-input" name="txtkeyword" value="<?php echo esc_attr(stripslashes($txtkeyword)); ?>" />
|
397 |
+
<?php submit_button('Search', 'button', 'search', false, array('id' => 'search-submit')); ?>
|
398 |
</p>
|
399 |
<?php
|
400 |
}
|
401 |
|
402 |
+
/* Add fillter follow */
|
403 |
+
function follow_action() {
|
404 |
?>
|
405 |
<select name="metaseo_follow_action" class="metaseo_follow_action">
|
406 |
+
<option value="0"><?php _e('-- Selection --', 'wp-meta-seo') ?></option>
|
407 |
+
<option value="follow_selected"><?php _e('Follow selected', 'wp-meta-seo') ?></option>
|
408 |
+
<option value="nofollow_selected"><?php _e('Nofollow selected', 'wp-meta-seo') ?></option>
|
409 |
+
<option value="follow_all"><?php _e('Follow all', 'wp-meta-seo') ?></option>
|
410 |
+
<option value="nofollow_all"><?php _e('Nofollow all', 'wp-meta-seo') ?></option>
|
411 |
</select>
|
412 |
+
<input type="button" class="button btn_apply_follow" value="<?php _e('Apply', 'wp-meta-seo') ?>">
|
413 |
<div data-comment_paged="1" data-paged="1" class="button wpms_scan_link page_link_meta"><?php _e('Re-index content links', 'wp-meta-seo') ?></div>
|
414 |
<span class="spinner spinner_apply_follow"></span>
|
415 |
<?php
|
416 |
}
|
417 |
|
418 |
+
/* Add fillter link source */
|
419 |
+
function link_source_fillter() {
|
420 |
+
if (isset($_GET['metaseo_link_source'])) {
|
421 |
$link_source = $_GET['metaseo_link_source'];
|
422 |
+
} else {
|
423 |
$link_source = 0;
|
424 |
}
|
425 |
?>
|
426 |
<select name="metaseo_link_source" class="metaseo_link_source">
|
427 |
+
<option value="0" <?php selected($link_source, 0) ?>><?php _e('Link source', 'wp-meta-seo') ?></option>
|
428 |
+
<option value="internal" <?php selected($link_source, 'internal') ?>><?php _e('Internal', 'wp-meta-seo') ?></option>
|
429 |
+
<option value="external" <?php selected($link_source, 'external') ?>><?php _e('External', 'wp-meta-seo') ?></option>
|
430 |
</select>
|
431 |
<?php
|
432 |
}
|
433 |
+
|
434 |
+
/* Add fillter months */
|
435 |
+
function months_fillter($name, $namebutton) {
|
436 |
global $wpdb, $wp_locale;
|
437 |
+
$month_count = count($this->months);
|
438 |
|
439 |
+
if (!$month_count || ( 1 == $month_count && 0 == $this->months[0]->month ))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
return;
|
441 |
|
442 |
$m = isset($_REQUEST['sldate']) ? $_REQUEST['sldate'] : 0;
|
443 |
?>
|
444 |
+
<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date', 'wp-meta-seo'); ?></label>
|
445 |
<select name="<?php echo $name ?>" id="filter-by-date" class="metaseo-filter">
|
446 |
+
<option<?php selected($m, 0); ?> value="0"><?php _e('All dates', 'wp-meta-seo'); ?></option>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
447 |
<?php
|
448 |
+
foreach ($this->months as $arc_row) {
|
449 |
+
|
450 |
+
if (0 == $arc_row->year)
|
451 |
+
continue;
|
452 |
+
$month = zeroise($arc_row->month, 2);
|
453 |
+
$year = $arc_row->year;
|
454 |
+
printf("<option %s value='%s' >%s</option>\n", selected($m, "$year-$month", false), esc_attr("$arc_row->year-$month"), sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
|
455 |
+
);
|
456 |
+
}
|
457 |
+
?>
|
458 |
+
</select>
|
459 |
|
460 |
+
<?php
|
461 |
+
submit_button(__('Filter'), 'button', $namebutton, false, array('id' => 'image-submit'));
|
462 |
+
}
|
463 |
+
|
464 |
+
/**
|
465 |
+
* Generate the table rows
|
466 |
+
*/
|
467 |
+
function display_rows() {
|
468 |
+
$url = URL;
|
469 |
+
$url = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', $url);
|
470 |
+
$records = $this->items;
|
471 |
+
$alternate = "";
|
472 |
+
|
473 |
+
list( $columns, $hidden ) = $this->get_column_info();
|
474 |
+
if (!empty($records)) {
|
475 |
+
foreach ($records as $rec) {
|
476 |
+
echo '<tr id="record_' . $rec->id . '" data-link="' . $rec->id . '" data-post_id="' . $rec->source_id . '">';
|
477 |
+
foreach ($columns as $column_name => $column_display_name) {
|
478 |
+
|
479 |
+
$class = sprintf('class="%1$s column-%1$s"', $column_name);
|
480 |
+
$style = "";
|
481 |
+
|
482 |
+
if (in_array($column_name, $hidden)) {
|
483 |
+
$style = ' style="display:none;"';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
}
|
485 |
|
486 |
+
$attributes = $class . $style;
|
487 |
+
|
488 |
+
switch ($column_name) {
|
489 |
+
case 'cb':
|
490 |
+
echo '<td scope="row" class="check-column" style="padding:8px 10px;">';
|
491 |
+
echo '<input id="cb-select-' . $rec->id . '" class="metaseo_link" type="checkbox" name="link[' . $rec->id . ']" value="' . $rec->id . '">';
|
492 |
+
echo '</td>';
|
493 |
+
break;
|
494 |
+
|
495 |
+
case 'post_id':
|
496 |
+
$post = get_post($rec->source_id);
|
497 |
+
$row_action = array(
|
498 |
+
'edit' => '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '" title="Edit this item">Edit</a>',
|
499 |
+
'view' => '<a target="_blank" href="' . get_permalink($rec->source_id) . '" title="View “test”" rel="permalink">View</a>'
|
500 |
+
);
|
501 |
+
echo '<td class="col_id" colspan="3">';
|
502 |
+
echo '<a target="_blank" href="' . get_edit_post_link($rec->source_id) . '">' . $post->post_title . '</a>';
|
503 |
+
echo $this->row_actions($row_action, false);
|
504 |
+
echo '</td>';
|
505 |
+
break;
|
506 |
+
|
507 |
+
case 'col_link_url':
|
508 |
+
echo '<td class="wpms_link_html" colspan="3">';
|
509 |
+
echo '<a target="_blank" href="' . $rec->link_url . '">' . $rec->link_url . '</a>';
|
510 |
+
echo '</td>';
|
511 |
+
break;
|
512 |
+
|
513 |
+
case 'col_link_title':
|
514 |
+
echo '<td colspan="3">';
|
515 |
+
echo '<input type="text" data-post_id="' . $rec->source_id . '" name="metaseo_link_title" id="metaseo_link_title" class="metaseo_link_title" value="' . $rec->meta_title . '">';
|
516 |
+
echo '<div data-post_id="' . $rec->source_id . '" class="wpms_update_link">' . __('Update', 'wp-meta-seo') . '</div>';
|
517 |
+
echo '<strong class="wpms_mesage_link">' . __('Saved.', 'wp-meta-seo') . '</strong>';
|
518 |
+
echo '<strong class="wpms_error_mesage_link">' . __('Error.', 'wp-meta-seo') . '</strong>';
|
519 |
+
echo '</td>';
|
520 |
+
break;
|
521 |
+
|
522 |
+
case 'col_link_label':
|
523 |
+
echo '<td colspan="3">' . strip_tags($rec->link_text) . '</td>';
|
524 |
+
break;
|
525 |
+
|
526 |
+
case 'col_follow':
|
527 |
+
if ($rec->follow == 1) {
|
528 |
+
$follow = '<i class="material-icons wpms_ok wpms_change_follow" data-type="done">done</i>';
|
529 |
+
} else {
|
530 |
+
$follow = '<i class="material-icons wpms_warning wpms_change_follow" data-type="warning">warning</i>';
|
531 |
+
}
|
532 |
+
echo '<td colspan="3">' . $follow . '</td>';
|
533 |
+
break;
|
534 |
+
}
|
535 |
}
|
536 |
+
|
537 |
+
echo '</tr>';
|
538 |
}
|
539 |
}
|
540 |
+
}
|
541 |
+
|
542 |
+
/*
|
543 |
+
* Retrieves a modified URL query string.
|
544 |
+
*/
|
545 |
+
public function process_action() {
|
546 |
+
global $wpdb;
|
547 |
+
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
548 |
+
$redirect = false;
|
549 |
|
550 |
+
if (isset($_POST['search']) and $_POST['search'] === 'Search') {
|
551 |
+
$current_url = add_query_arg(array("search" => "Search", "txtkeyword" => urlencode(stripslashes($_POST["txtkeyword"]))), $current_url);
|
552 |
+
$redirect = true;
|
553 |
+
}
|
554 |
|
555 |
+
if (isset($_POST['filter_date_action']) and $_POST['filter_date_action'] === 'Filter') {
|
556 |
+
$current_url = add_query_arg(array("sldate" => $_POST["sldate"]), $current_url);
|
557 |
+
$redirect = true;
|
558 |
+
}
|
559 |
|
560 |
+
if (!empty($_POST['paged'])) {
|
561 |
+
$current_url = add_query_arg(array("paged" => intval($_POST['paged'])), $current_url);
|
562 |
+
$redirect = true;
|
563 |
+
}
|
564 |
|
565 |
+
if (isset($_POST['metaseo_link_source'])) {
|
566 |
+
$current_url = add_query_arg(array("metaseo_link_source" => $_POST['metaseo_link_source']), $current_url);
|
567 |
+
$redirect = true;
|
568 |
+
}
|
|
|
|
|
|
|
|
|
|
|
569 |
|
570 |
+
if (!empty($_POST['metaseo_link_per_page'])) {
|
571 |
+
$current_url = add_query_arg(array("metaseo_link_per_page" => intval($_POST['metaseo_link_per_page'])), $current_url);
|
572 |
+
$redirect = true;
|
573 |
+
}
|
574 |
|
575 |
+
if ($redirect === true) {
|
576 |
+
wp_redirect($current_url);
|
577 |
+
ob_end_flush();
|
578 |
+
exit();
|
|
|
579 |
}
|
580 |
+
}
|
581 |
+
|
582 |
+
}
|
inc/class.metaseo-meta.php
CHANGED
@@ -1,5 +1,11 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
class WPMSEO_Meta {
|
4 |
|
5 |
public static $meta_prefix = '_metaseo_meta';
|
@@ -8,7 +14,6 @@ class WPMSEO_Meta {
|
|
8 |
public static $meta_title_length = 69;
|
9 |
public static $meta_keywords_length = 256;
|
10 |
public static $meta_length_reason = '';
|
11 |
-
|
12 |
public static $meta_fields = array(
|
13 |
'general' => array(
|
14 |
'snippetpreview' => array(
|
@@ -76,7 +81,6 @@ class WPMSEO_Meta {
|
|
76 |
'description' => '',
|
77 |
'help' => '',
|
78 |
),
|
79 |
-
|
80 |
'twitter-title' => array(
|
81 |
'type' => 'text',
|
82 |
'title' => '',
|
@@ -101,9 +105,7 @@ class WPMSEO_Meta {
|
|
101 |
'description' => '',
|
102 |
'help' => '',
|
103 |
),
|
104 |
-
|
105 |
),
|
106 |
-
|
107 |
'non_form' => array(
|
108 |
'linkdex' => array(
|
109 |
'type' => null,
|
@@ -129,6 +131,16 @@ class WPMSEO_Meta {
|
|
129 |
add_filter('add_post_metadata', array(__CLASS__, 'dont_save_meta_if_default'), 10, 4);
|
130 |
}
|
131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
public static function get_meta_field_defs($tab, $post_type = 'post') {
|
133 |
if (!isset(self::$meta_fields[$tab])) {
|
134 |
return array();
|
@@ -148,7 +160,7 @@ class WPMSEO_Meta {
|
|
148 |
} else {
|
149 |
unset($field_defs['metakeywords']);
|
150 |
}
|
151 |
-
|
152 |
$field_defs = apply_filters('wpmseo_metabox_entries', $field_defs);
|
153 |
break;
|
154 |
|
@@ -159,7 +171,27 @@ class WPMSEO_Meta {
|
|
159 |
|
160 |
return apply_filters('wpmseo_metabox_entries_' . $tab, $field_defs, $post_type);
|
161 |
}
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
public static function get_value($key, $postid = 0) {
|
164 |
global $post;
|
165 |
|
@@ -189,10 +221,22 @@ class WPMSEO_Meta {
|
|
189 |
return '';
|
190 |
}
|
191 |
}
|
192 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
public static function set_value($key, $meta_value, $post_id) {
|
194 |
return update_post_meta($post_id, self::$meta_prefix . $key, $meta_value);
|
195 |
}
|
|
|
196 |
}
|
197 |
|
198 |
/* End of class */
|
1 |
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* This class implements defaults and value validation for all WPMSEO Post Meta values.
|
5 |
+
*
|
6 |
+
* Based on some work of Yoast SEO plugin
|
7 |
+
*/
|
8 |
+
|
9 |
class WPMSEO_Meta {
|
10 |
|
11 |
public static $meta_prefix = '_metaseo_meta';
|
14 |
public static $meta_title_length = 69;
|
15 |
public static $meta_keywords_length = 256;
|
16 |
public static $meta_length_reason = '';
|
|
|
17 |
public static $meta_fields = array(
|
18 |
'general' => array(
|
19 |
'snippetpreview' => array(
|
81 |
'description' => '',
|
82 |
'help' => '',
|
83 |
),
|
|
|
84 |
'twitter-title' => array(
|
85 |
'type' => 'text',
|
86 |
'title' => '',
|
105 |
'description' => '',
|
106 |
'help' => '',
|
107 |
),
|
|
|
108 |
),
|
|
|
109 |
'non_form' => array(
|
110 |
'linkdex' => array(
|
111 |
'type' => null,
|
131 |
add_filter('add_post_metadata', array(__CLASS__, 'dont_save_meta_if_default'), 10, 4);
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
+
* Retrieve the meta box form field definitions for the given tab and post type.
|
136 |
+
*
|
137 |
+
* @static
|
138 |
+
*
|
139 |
+
* @param string $tab Tab for which to retrieve the field definitions.
|
140 |
+
* @param string $post_type Post type of the current post.
|
141 |
+
*
|
142 |
+
* @return array Array containing the meta box field definitions
|
143 |
+
*/
|
144 |
public static function get_meta_field_defs($tab, $post_type = 'post') {
|
145 |
if (!isset(self::$meta_fields[$tab])) {
|
146 |
return array();
|
160 |
} else {
|
161 |
unset($field_defs['metakeywords']);
|
162 |
}
|
163 |
+
|
164 |
$field_defs = apply_filters('wpmseo_metabox_entries', $field_defs);
|
165 |
break;
|
166 |
|
171 |
|
172 |
return apply_filters('wpmseo_metabox_entries_' . $tab, $field_defs, $post_type);
|
173 |
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Get a custom post meta value
|
177 |
+
* Returns the default value if the meta value has not been set
|
178 |
+
*
|
179 |
+
* @internal Unfortunately there isn't a filter available to hook into before returning the results
|
180 |
+
* for get_post_meta(), get_post_custom() and the likes. That would have been the preferred solution.
|
181 |
+
*
|
182 |
+
* @static
|
183 |
+
*
|
184 |
+
* @param string $key Internal key of the value to get (without prefix).
|
185 |
+
* @param int $postid Post ID of the post to get the value for.
|
186 |
+
*
|
187 |
+
* @return string All 'normal' values returned from get_post_meta() are strings.
|
188 |
+
* Objects and arrays are possible, but not used by this plugin
|
189 |
+
* and therefore discarted (except when the special 'serialized' field def
|
190 |
+
* value is set to true - only used by add-on plugins for now).
|
191 |
+
* Will return the default value if no value was found..
|
192 |
+
* Will return empty string if no default was found (not one of our keys) or
|
193 |
+
* if the post does not exist.
|
194 |
+
*/
|
195 |
public static function get_value($key, $postid = 0) {
|
196 |
global $post;
|
197 |
|
221 |
return '';
|
222 |
}
|
223 |
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Update a meta value for a post
|
227 |
+
*
|
228 |
+
* @static
|
229 |
+
*
|
230 |
+
* @param string $key The internal key of the meta value to change (without prefix).
|
231 |
+
* @param mixed $meta_value The value to set the meta to.
|
232 |
+
* @param int $post_id The ID of the post to change the meta for.
|
233 |
+
*
|
234 |
+
* @return bool whether the value was changed
|
235 |
+
*/
|
236 |
public static function set_value($key, $meta_value, $post_id) {
|
237 |
return update_post_meta($post_id, self::$meta_prefix . $key, $meta_value);
|
238 |
}
|
239 |
+
|
240 |
}
|
241 |
|
242 |
/* End of class */
|
inc/class.metaseo-metabox.php
CHANGED
@@ -1,10 +1,15 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-meta.php' );
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-snippet-preview.php' );
|
4 |
|
5 |
class WPMSEO_Metabox extends WPMSEO_Meta {
|
6 |
|
7 |
public $perc_score = 0;
|
|
|
8 |
public function __construct() {
|
9 |
add_action('add_meta_boxes', array($this, 'add_meta_box'));
|
10 |
add_action('admin_enqueue_scripts', array($this, 'metaseo_enqueue'));
|
@@ -14,12 +19,15 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
14 |
add_action('admin_init', array($this, 'translate_meta_boxes'));
|
15 |
}
|
16 |
|
|
|
|
|
|
|
17 |
function metaseo_save_postdata($post_id) {
|
18 |
-
|
19 |
if ($post_id === null) {
|
20 |
return false;
|
21 |
}
|
22 |
-
|
23 |
if (wp_is_post_revision($post_id)) {
|
24 |
$post_id = wp_is_post_revision($post_id);
|
25 |
}
|
@@ -34,7 +42,7 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
34 |
do_action('wpmseo_save_compare_data', $post);
|
35 |
|
36 |
$meta_boxes = apply_filters('wpmseo_save_metaboxes', array());
|
37 |
-
$meta_boxes = array_merge($meta_boxes, $this->get_meta_field_defs('general', $post->post_type), $this->get_meta_field_defs('advanced')
|
38 |
foreach ($meta_boxes as $key => $meta_box) {
|
39 |
$data = null;
|
40 |
if ('checkbox' === $meta_box['type']) {
|
@@ -51,49 +59,53 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
51 |
do_action('wpmseo_saved_postdata');
|
52 |
}
|
53 |
|
|
|
|
|
|
|
54 |
public static function translate_meta_boxes() {
|
55 |
self::$meta_fields['general']['snippetpreview']['title'] = __('Results preview', 'wp-meta-seo');
|
56 |
self::$meta_fields['general']['snippetpreview']['help'] = sprintf(__('This is a preview of what your content will looks like in search engine results: title, description and URL', 'wp-meta-seo'), '<a target="_blank" href="https://www.joomunited.com/wordpress-products/wpms">', '</a>');
|
57 |
|
58 |
self::$meta_fields['general']['title']['title'] = __('Search engine title', 'wp-meta-seo');
|
59 |
-
self::$meta_fields['general']['title']['description'] = sprintf(__('<span id="metaseo_wpmseo_title-length">%s</span>'),self::$meta_length_reason);
|
60 |
self::$meta_fields['general']['title']['help'] = __('This is the title of your content that may be displayed in search engine results (meta title). By default it’s the content title (page title, post title…). 69 characters max allowed.', 'wp-meta-seo');
|
61 |
-
|
62 |
-
$settings = get_option(
|
63 |
-
if(isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1){
|
64 |
self::$meta_fields['general']['keywords']['title'] = __('Search engine keywords', 'wp-meta-seo');
|
65 |
self::$meta_fields['general']['keywords']['description'] = '<span id="metaseo_wpmseo_keywords-length"></span>';
|
66 |
self::$meta_fields['general']['keywords']['help'] = __('This is the keywords of your content that may be displayed in search engine results (meta keywords).', 'wp-meta-seo');
|
67 |
-
}else{
|
68 |
unset(self::$meta_fields['general']['keywords']);
|
69 |
}
|
70 |
-
|
71 |
|
72 |
self::$meta_fields['general']['desc']['title'] = __('Search engine description', 'wp-meta-seo');
|
73 |
-
self::$meta_fields['general']['desc']['description'] = sprintf(__('<span id="metaseo_wpmseo_desc-length">%s</span>'),self::$meta_length_reason);
|
74 |
self::$meta_fields['general']['desc']['help'] = __('The description of your content that may be displayed in search engine results aka meta description. By default search engine take an excerpt from your content (depending on the search query). 156 characters max allowed.', 'wp-meta-seo');
|
75 |
-
|
76 |
-
self::$meta_fields['social']['opengraph-title']['title']
|
77 |
-
self::$meta_fields['social']['opengraph-title']['description']
|
78 |
-
|
79 |
-
self::$meta_fields['social']['opengraph-desc']['title']
|
80 |
-
self::$meta_fields['social']['opengraph-desc']['description']
|
81 |
-
|
82 |
-
self::$meta_fields['social']['opengraph-image']['title']
|
83 |
-
self::$meta_fields['social']['opengraph-image']['description']
|
84 |
-
|
85 |
-
self::$meta_fields['social']['twitter-title']['title']
|
86 |
-
self::$meta_fields['social']['twitter-title']['description']
|
87 |
-
|
88 |
-
self::$meta_fields['social']['twitter-desc']['title']
|
89 |
-
self::$meta_fields['social']['twitter-desc']['description']
|
90 |
-
|
91 |
-
self::$meta_fields['social']['twitter-image']['title']
|
92 |
-
self::$meta_fields['social']['twitter-image']['description']
|
93 |
-
|
94 |
do_action('wpmseo_tab_translate');
|
95 |
}
|
96 |
-
|
|
|
97 |
public function metaseo_enqueue() {
|
98 |
global $pagenow;
|
99 |
if ((!in_array($pagenow, array(
|
@@ -118,39 +130,42 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
118 |
wp_enqueue_style('m-metabox-tabs', plugins_url('css/metabox-tabs.css', WPMSEO_FILE), array(), WPMSEO_VERSION);
|
119 |
wp_enqueue_style('m-style-qtip', plugins_url('css/jquery.qtip.css', WPMSEO_FILE), array(), WPMSEO_VERSION);
|
120 |
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', WPMSEO_FILE), array('jquery'), '2.2.1', true);
|
121 |
-
wp_enqueue_script('m-wp-seo-metabox', plugins_url('js/wp-metaseo-metabox.js', WPMSEO_FILE), array('jquery','jquery-ui-core',), WPMSEO_VERSION, true);
|
122 |
-
wp_enqueue_script(
|
123 |
-
wp_enqueue_script('metaseo-cliffpyles', plugins_url('js/cliffpyles.js', WPMSEO_FILE), array('jquery'),WPMSEO_VERSION, true);
|
124 |
wp_localize_script('m-wp-seo-metabox', 'wpmseoMetaboxL10n', $this->meta_seo_localize_script());
|
125 |
-
|
126 |
-
wp_localize_script(
|
|
|
127 |
}
|
128 |
}
|
129 |
|
|
|
130 |
public function metaseo_localize_media_script() {
|
131 |
$this->settings = array(
|
132 |
-
"metaseo_title_home"=>"",
|
133 |
-
"metaseo_desc_home"=>"",
|
134 |
-
|
135 |
-
"metaseo_showtwitter"=>"",
|
136 |
-
"metaseo_twitter_card"=>"summary",
|
137 |
-
"metaseo_showkeywords"=>0,
|
138 |
-
"metaseo_showtmetablock"=>1,
|
139 |
"metaseo_showsocial" => 1,
|
140 |
"metaseo_seovalidate" => 0
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
return array(
|
149 |
-
|
150 |
-
|
151 |
);
|
152 |
}
|
153 |
|
|
|
154 |
public function meta_seo_localize_script() {
|
155 |
$post = $this->get_metabox_post();
|
156 |
|
@@ -198,11 +213,11 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
198 |
'sep',
|
199 |
'page',
|
200 |
);
|
201 |
-
|
202 |
foreach ($vars_to_cache as $var) {
|
203 |
$cached_replacement_vars[$var] = $var;
|
204 |
}
|
205 |
-
|
206 |
$cached_replacement_vars['sitename'] = get_option('blogname');
|
207 |
$array_keyword = array(
|
208 |
'field_prefix' => self::$form_prefix,
|
@@ -218,14 +233,24 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
218 |
'no_parent_text' => __('(no parent)', 'wp-meta-seo'),
|
219 |
'show_keywords' => 0
|
220 |
);
|
221 |
-
$settings = get_option(
|
222 |
-
if(isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1){
|
223 |
$array_keyword['show_keywords'] = 1;
|
224 |
}
|
225 |
-
|
226 |
return array_merge($cached_replacement_vars, $array_keyword);
|
227 |
}
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
function is_metabox_hidden($post_type = null) {
|
230 |
if (!isset($post_type)) {
|
231 |
if (isset($GLOBALS['post']) && ( is_object($GLOBALS['post']) && isset($GLOBALS['post']->post_type) )) {
|
@@ -244,14 +269,17 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
244 |
}
|
245 |
return false;
|
246 |
}
|
247 |
-
|
|
|
|
|
|
|
248 |
public function add_meta_box() {
|
249 |
$post_types = get_post_types(array('public' => true));
|
250 |
|
251 |
if (is_array($post_types) && $post_types !== array()) {
|
252 |
foreach ($post_types as $post_type) {
|
253 |
if ($this->is_metabox_hidden($post_type) === false) {
|
254 |
-
add_meta_box('wpmseo_meta', __('WP Meta SEO - Page optimization','wp-meta-seo'), array(
|
255 |
$this,
|
256 |
'meta_box',
|
257 |
), $post_type, 'normal', apply_filters('wpmseo_metabox_prio', 'core'));
|
@@ -259,33 +287,35 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
259 |
}
|
260 |
}
|
261 |
}
|
262 |
-
|
|
|
|
|
|
|
263 |
function meta_box() {
|
264 |
$post = $this->get_metabox_post();
|
265 |
$default_settings = array(
|
266 |
-
"metaseo_title_home"=>"",
|
267 |
-
"metaseo_desc_home"=>"",
|
268 |
-
|
269 |
-
"metaseo_showtwitter"=>"",
|
270 |
-
"metaseo_twitter_card"=>"summary",
|
271 |
-
"metaseo_showtmetablock"=>1,
|
272 |
"metaseo_showsocial" => 1
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
?>
|
280 |
<div class="wpmseo-metabox-tabs-div">
|
281 |
<ul class="wpmseo-metabox-tabs" id="wpmseo-metabox-tabs">
|
282 |
<li class="general">
|
283 |
<a class="wpmseo_tablink" data-link="wpmseo_general"><?php _e('SEO Page optimization', 'wp-meta-seo'); ?></a>
|
284 |
</li>
|
285 |
-
|
286 |
-
<?php if((isset($default_settings['metaseo_showsocial']) && $default_settings['metaseo_showsocial'] == 1)): ?>
|
287 |
<li class="social">
|
288 |
-
<a class="wpmseo_tablink" data-link="wpmseo_social"><?php
|
289 |
</li>
|
290 |
<?php endif; ?>
|
291 |
<?php do_action('wpmseo_tab_header'); ?>
|
@@ -301,551 +331,564 @@ class WPMSEO_Metabox extends WPMSEO_Meta {
|
|
301 |
$this->do_tab('general', __('General', 'wp-meta-seo'), $content);
|
302 |
|
303 |
$content = '';
|
304 |
-
foreach (
|
305 |
-
|
306 |
}
|
307 |
-
|
308 |
-
if((isset($default_settings['metaseo_showsocial']) && $default_settings['metaseo_showsocial'] == 1)){
|
309 |
-
$this->do_tab(
|
310 |
}
|
311 |
-
|
312 |
do_action('wpmseo_tab_content');
|
313 |
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
return $output;
|
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 |
-
if(is_array($words_tagh1) && is_array($words_post_title)){
|
348 |
-
foreach ($words_tagh1 as $mh){
|
349 |
-
if(in_array($mh, $words_post_title) && $mh!=''){
|
350 |
-
$test = true;
|
351 |
-
$output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
|
352 |
-
$this->perc_score++;
|
353 |
-
return $output;
|
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 |
-
if($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))){
|
442 |
-
$output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'done',__('Page title word in content heading','wp-meta-seo'),1);
|
443 |
-
$this->perc_score++;
|
444 |
-
}else{
|
445 |
-
$output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'warning',__('Page title word in content heading','wp-meta-seo'),0);
|
446 |
-
}
|
447 |
-
|
448 |
-
}else{
|
449 |
-
$output = $this->metaseo_create_field('heading_title',$tooltip_page['title_in_heading'],'warning',__('Page title word in content heading','wp-meta-seo'),0);
|
450 |
-
}
|
451 |
-
|
452 |
-
return $output;
|
453 |
-
}
|
454 |
-
|
455 |
-
function metaseo_check_content($post,$tooltip_page,$meta_analysis){
|
456 |
-
$words_meta_title = preg_split('~[^\p{L}\p{N}\']+~u',strtolower($post->post_title));
|
457 |
-
$words_post_content = preg_split('~[^\p{L}\p{N}\']+~u',strtolower($post->post_content));
|
458 |
-
$test1 = false;
|
459 |
-
if(is_array($words_meta_title) && is_array($words_post_content)){
|
460 |
-
foreach ($words_meta_title as $mtitle){
|
461 |
-
if(in_array($mtitle, $words_post_content) && $mtitle!=''){
|
462 |
-
$test1 = true;
|
463 |
-
break;
|
464 |
-
}
|
465 |
-
}
|
466 |
-
}else{
|
467 |
-
$test1 = false;
|
468 |
}
|
469 |
-
|
470 |
-
if($
|
471 |
-
$output = $this->metaseo_create_field('
|
472 |
$this->perc_score++;
|
473 |
-
}else{
|
474 |
-
$output = $this->metaseo_create_field('
|
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 |
-
$output = $this->metaseo_create_field('metatitle',$tooltip_page['meta_title'],'warning',__('Meta title filled','wp-meta-seo'),0);
|
500 |
-
}
|
501 |
-
return $output;
|
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 |
-
}else{
|
547 |
-
$output = $this->metaseo_create_field('imgresize',$tooltip_page['image_resize'],'warning',__('Wrong image resize','wp-meta-seo'),0);
|
548 |
-
}
|
549 |
return $output;
|
550 |
}
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
$
|
563 |
-
$
|
564 |
-
|
565 |
-
$image_title = $tag->getAttribute('title');
|
566 |
-
$image_alt = $tag->getAttribute('alt');
|
567 |
-
if($image_title == '' || $image_alt == ''){
|
568 |
$img_wrong = true;
|
569 |
}
|
570 |
}
|
571 |
-
|
572 |
-
if($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgalt']))){
|
573 |
-
$output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'done',__('Image have meta title or alt','wp-meta-seo'),1);
|
574 |
-
$this->perc_score++;
|
575 |
-
}else{
|
576 |
-
$output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
|
577 |
-
}
|
578 |
-
|
579 |
-
}else{
|
580 |
-
$output = $this->metaseo_create_field('imgalt',$tooltip_page['image_alt'],'warning',__('Image have meta title or alt','wp-meta-seo'),0);
|
581 |
}
|
582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
583 |
}
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
$tooltip_page['
|
591 |
-
$
|
592 |
-
$tooltip_page['image_resize'] = __('Check for image HTML resizing in content (usually image resized using handles)','wp-meta-seo');
|
593 |
-
$tooltip_page['image_alt'] = __('Check for image Alt text and title','wp-meta-seo');
|
594 |
-
|
595 |
-
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
|
596 |
-
$meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
|
597 |
-
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis',true);
|
598 |
-
if(empty($meta_analysis)) $meta_analysis = array();
|
599 |
-
$headingtitle = $this->metaseo_check_headingtitle($post,$meta_title,$tooltip_page,$meta_analysis);
|
600 |
-
$contenttitle = $this->metaseo_check_content($post,$tooltip_page,$meta_analysis);
|
601 |
-
$output_pageurl = $this->metaseo_check_pageurl($post,$tooltip_page,$meta_analysis);
|
602 |
-
$output_metatitle = $this->metaseo_check_metatitle($meta_title,$tooltip_page,$meta_analysis);
|
603 |
-
$output_metadesc = $this->metaseo_check_metadesc($meta_desc,$tooltip_page,$meta_analysis);
|
604 |
-
$output_imagewrong = $this->metaseo_check_imageresize($post->post_content,$tooltip_page,$meta_analysis);
|
605 |
-
$output_imagealt = $this->metaseo_check_imagealt($post->post_content,$tooltip_page,$meta_analysis);
|
606 |
-
|
607 |
-
$output = '';
|
608 |
-
$circliful = ceil(100*($this->perc_score)/7);
|
609 |
-
$output .= '<div style="width:100%;float:left;">';
|
610 |
-
$output .= '<div class="metaseo_left">
|
611 |
-
<div class="metaseo-progress-bar" data-post_id="'.$post->ID.'">
|
612 |
-
<canvas id="inactiveProgress" class="metaseo-progress-inactive" height="275px" width="275px"></canvas>
|
613 |
-
<canvas id="activeProgress" class="metaseo-progress-active" height="275px" width="275px"></canvas>
|
614 |
-
<p>0%</p>
|
615 |
-
</div>
|
616 |
-
<input type="hidden" id="progressController" value="'.$circliful.'" />
|
617 |
-
<input type="hidden" id="metaseo_alanysis_ok" value="'.$this->perc_score.'" />
|
618 |
-
</div>';
|
619 |
-
|
620 |
-
$output .= '<div class="metaseo_right">';
|
621 |
-
$output .= $headingtitle . $contenttitle . $output_pageurl . $output_metatitle . $output_metadesc . $output_imagewrong . $output_imagealt;
|
622 |
-
$output .= '</div>';
|
623 |
-
$output .= '</div>';
|
624 |
return $output;
|
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 |
-
|
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 |
</div>
|
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 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
}
|
712 |
-
if ($placeholder !== '') {
|
713 |
-
$placeholder = ' placeholder="' . esc_attr($placeholder) . '"';
|
714 |
-
}
|
715 |
-
$content .= '<input type="text"' . $placeholder . ' id="' . $esc_form_key . '" ' . $ac . 'name="' . $esc_form_key . '" value="' . esc_attr($meta_value) . '" class="large-text' . $class . '"/><br />';
|
716 |
-
break;
|
717 |
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
}
|
723 |
-
$content .= '<textarea class="large-text' . $class . '" rows="' . esc_attr($rows) . '" id="' . $esc_form_key . '" name="' . $esc_form_key . '">' . esc_textarea($meta_value) . '</textarea>';
|
724 |
-
break;
|
725 |
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
$selected = selected($meta_value, $val, false);
|
731 |
-
$content .= '<option ' . $selected . ' value="' . esc_attr($val) . '">' . esc_html($option) . '</option>';
|
732 |
-
}
|
733 |
-
unset($val, $option, $selected);
|
734 |
-
$content .= '</select>';
|
735 |
-
}
|
736 |
-
break;
|
737 |
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
|
|
|
|
|
|
|
|
744 |
|
745 |
-
|
746 |
-
|
747 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
748 |
|
749 |
-
|
|
|
|
|
|
|
|
|
|
|
750 |
|
751 |
-
|
752 |
-
|
753 |
-
$selected = '';
|
754 |
-
if (in_array($val, $selected_arr)) {
|
755 |
-
$selected = ' selected="selected"';
|
756 |
-
}
|
757 |
-
$content .= '<option ' . $selected . ' value="' . esc_attr($val) . '">' . esc_html($option) . '</option>';
|
758 |
-
}
|
759 |
-
$content .= '</select>';
|
760 |
-
unset($val, $option, $selected, $selected_arr, $options_count);
|
761 |
}
|
762 |
-
break;
|
763 |
|
764 |
-
|
765 |
-
$checked = checked($meta_value, 'on', false);
|
766 |
-
$expl = ( isset($meta_field_def['expl']) ) ? esc_html($meta_field_def['expl']) : '';
|
767 |
-
$content .= '<label for="' . $esc_form_key . '"><input type="checkbox" id="' . $esc_form_key . '" name="' . $esc_form_key . '" ' . $checked . ' value="on" class="metaseo' . $class . '"/> ' . $expl . '</label><br />';
|
768 |
-
unset($checked, $expl);
|
769 |
-
break;
|
770 |
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
$
|
776 |
}
|
777 |
-
|
778 |
}
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
786 |
|
|
|
|
|
|
|
|
|
|
|
787 |
|
788 |
-
$html = '';
|
789 |
-
if ($content === '') {
|
790 |
-
$content = apply_filters('wpmseo_do_meta_box_field_' . $key, $content, $meta_value, $esc_form_key, $meta_field_def, $key);
|
791 |
-
}
|
792 |
|
793 |
-
|
|
|
|
|
|
|
794 |
|
795 |
-
|
796 |
-
if (in_array($meta_field_def['type'], array(
|
797 |
-
'snippetpreview',
|
798 |
-
'radio',
|
799 |
-
'checkbox',
|
800 |
-
), true) === false
|
801 |
-
) {
|
802 |
-
$label = '<label for="' . $esc_form_key . '">' . $label . ':</label>';
|
803 |
-
}
|
804 |
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
|
|
|
|
|
|
|
|
|
|
809 |
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
|
815 |
-
|
|
|
|
|
|
|
816 |
|
817 |
-
|
818 |
-
$html .= '<div>' . $meta_field_def['description'] . '</div>';
|
819 |
-
}
|
820 |
|
821 |
-
|
822 |
-
|
823 |
-
</tr>';
|
824 |
}
|
825 |
-
return $html;
|
826 |
-
}
|
827 |
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
}
|
835 |
|
836 |
-
|
|
|
|
|
|
|
|
|
|
|
837 |
}
|
838 |
|
839 |
-
|
840 |
-
|
841 |
-
$title = self::get_value('title', $post->ID);
|
842 |
-
$description = self::get_value('desc', $post->ID);
|
843 |
|
844 |
-
|
|
|
|
|
|
|
845 |
|
846 |
-
|
847 |
-
}
|
848 |
|
|
|
849 |
}
|
|
|
850 |
|
851 |
-
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* This class generates the metabox on the edit post / page as well as contains all page analysis functionality.
|
4 |
+
*/
|
5 |
+
|
6 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-meta.php' );
|
7 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-snippet-preview.php' );
|
8 |
|
9 |
class WPMSEO_Metabox extends WPMSEO_Meta {
|
10 |
|
11 |
public $perc_score = 0;
|
12 |
+
|
13 |
public function __construct() {
|
14 |
add_action('add_meta_boxes', array($this, 'add_meta_box'));
|
15 |
add_action('admin_enqueue_scripts', array($this, 'metaseo_enqueue'));
|
19 |
add_action('admin_init', array($this, 'translate_meta_boxes'));
|
20 |
}
|
21 |
|
22 |
+
/*
|
23 |
+
* Update post meta data
|
24 |
+
*/
|
25 |
function metaseo_save_postdata($post_id) {
|
26 |
+
|
27 |
if ($post_id === null) {
|
28 |
return false;
|
29 |
}
|
30 |
+
|
31 |
if (wp_is_post_revision($post_id)) {
|
32 |
$post_id = wp_is_post_revision($post_id);
|
33 |
}
|
42 |
do_action('wpmseo_save_compare_data', $post);
|
43 |
|
44 |
$meta_boxes = apply_filters('wpmseo_save_metaboxes', array());
|
45 |
+
$meta_boxes = array_merge($meta_boxes, $this->get_meta_field_defs('general', $post->post_type), $this->get_meta_field_defs('advanced'), $this->get_meta_field_defs('social'));
|
46 |
foreach ($meta_boxes as $key => $meta_box) {
|
47 |
$data = null;
|
48 |
if ('checkbox' === $meta_box['type']) {
|
59 |
do_action('wpmseo_saved_postdata');
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
+
* Translate text strings for use in the meta box
|
64 |
+
*/
|
65 |
public static function translate_meta_boxes() {
|
66 |
self::$meta_fields['general']['snippetpreview']['title'] = __('Results preview', 'wp-meta-seo');
|
67 |
self::$meta_fields['general']['snippetpreview']['help'] = sprintf(__('This is a preview of what your content will looks like in search engine results: title, description and URL', 'wp-meta-seo'), '<a target="_blank" href="https://www.joomunited.com/wordpress-products/wpms">', '</a>');
|
68 |
|
69 |
self::$meta_fields['general']['title']['title'] = __('Search engine title', 'wp-meta-seo');
|
70 |
+
self::$meta_fields['general']['title']['description'] = sprintf(__('<span id="metaseo_wpmseo_title-length">%s</span>'), self::$meta_length_reason);
|
71 |
self::$meta_fields['general']['title']['help'] = __('This is the title of your content that may be displayed in search engine results (meta title). By default it’s the content title (page title, post title…). 69 characters max allowed.', 'wp-meta-seo');
|
72 |
+
|
73 |
+
$settings = get_option('_metaseo_settings');
|
74 |
+
if (isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1) {
|
75 |
self::$meta_fields['general']['keywords']['title'] = __('Search engine keywords', 'wp-meta-seo');
|
76 |
self::$meta_fields['general']['keywords']['description'] = '<span id="metaseo_wpmseo_keywords-length"></span>';
|
77 |
self::$meta_fields['general']['keywords']['help'] = __('This is the keywords of your content that may be displayed in search engine results (meta keywords).', 'wp-meta-seo');
|
78 |
+
} else {
|
79 |
unset(self::$meta_fields['general']['keywords']);
|
80 |
}
|
81 |
+
|
82 |
|
83 |
self::$meta_fields['general']['desc']['title'] = __('Search engine description', 'wp-meta-seo');
|
84 |
+
self::$meta_fields['general']['desc']['description'] = sprintf(__('<span id="metaseo_wpmseo_desc-length">%s</span>'), self::$meta_length_reason);
|
85 |
self::$meta_fields['general']['desc']['help'] = __('The description of your content that may be displayed in search engine results aka meta description. By default search engine take an excerpt from your content (depending on the search query). 156 characters max allowed.', 'wp-meta-seo');
|
86 |
+
|
87 |
+
self::$meta_fields['social']['opengraph-title']['title'] = __('Facebook Title', 'wp-meta-seo');
|
88 |
+
self::$meta_fields['social']['opengraph-title']['description'] = __('Custom title to display when sharing this content on facebook, content title override', 'wp-meta-seo');
|
89 |
+
|
90 |
+
self::$meta_fields['social']['opengraph-desc']['title'] = __('Facebook Description', 'wp-meta-seo');
|
91 |
+
self::$meta_fields['social']['opengraph-desc']['description'] = __('Custom description to display when sharing this content on facebook, content description override', 'wp-meta-seo');
|
92 |
+
|
93 |
+
self::$meta_fields['social']['opengraph-image']['title'] = __('Facebook Image', 'wp-meta-seo');
|
94 |
+
self::$meta_fields['social']['opengraph-image']['description'] = __('Custom image to display when sharing this content on facebook, content description override, recommended size is 1200px x 630px', 'wp-meta-seo');
|
95 |
+
|
96 |
+
self::$meta_fields['social']['twitter-title']['title'] = __('Twitter Title', 'wp-meta-seo');
|
97 |
+
self::$meta_fields['social']['twitter-title']['description'] = __('Custom title to display when sharing this content on twitter, content title override', 'wp-meta-seo');
|
98 |
+
|
99 |
+
self::$meta_fields['social']['twitter-desc']['title'] = __('Twitter Description', 'wp-meta-seo');
|
100 |
+
self::$meta_fields['social']['twitter-desc']['description'] = __('Custom description to display when sharing this content on twitter, content description override', 'wp-meta-seo');
|
101 |
+
|
102 |
+
self::$meta_fields['social']['twitter-image']['title'] = __('Twitter Image', 'wp-meta-seo');
|
103 |
+
self::$meta_fields['social']['twitter-image']['description'] = __('Custom image to display when sharing this content on facebook, content description override, recommended min size 440px X 220px', 'wp-meta-seo');
|
104 |
+
|
105 |
do_action('wpmseo_tab_translate');
|
106 |
}
|
107 |
+
|
108 |
+
/* load script and style */
|
109 |
public function metaseo_enqueue() {
|
110 |
global $pagenow;
|
111 |
if ((!in_array($pagenow, array(
|
130 |
wp_enqueue_style('m-metabox-tabs', plugins_url('css/metabox-tabs.css', WPMSEO_FILE), array(), WPMSEO_VERSION);
|
131 |
wp_enqueue_style('m-style-qtip', plugins_url('css/jquery.qtip.css', WPMSEO_FILE), array(), WPMSEO_VERSION);
|
132 |
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', WPMSEO_FILE), array('jquery'), '2.2.1', true);
|
133 |
+
wp_enqueue_script('m-wp-seo-metabox', plugins_url('js/wp-metaseo-metabox.js', WPMSEO_FILE), array('jquery', 'jquery-ui-core',), WPMSEO_VERSION, true);
|
134 |
+
wp_enqueue_script('mwpseo-admin-media', plugins_url('js/wp-metaseo-admin-media.js', WPMSEO_FILE), array('jquery', 'jquery-ui-core',), WPMSEO_VERSION, true);
|
135 |
+
wp_enqueue_script('metaseo-cliffpyles', plugins_url('js/cliffpyles.js', WPMSEO_FILE), array('jquery'), WPMSEO_VERSION, true);
|
136 |
wp_localize_script('m-wp-seo-metabox', 'wpmseoMetaboxL10n', $this->meta_seo_localize_script());
|
137 |
+
$localize = $this->metaseo_localize_media_script();
|
138 |
+
wp_localize_script('mwpseo-admin-media', 'wpmseoMediaL10n', $localize);
|
139 |
+
wp_localize_script('metaseo-cliffpyles', 'wpmscliffpyles', $localize);
|
140 |
}
|
141 |
}
|
142 |
|
143 |
+
/* Localize a script */
|
144 |
public function metaseo_localize_media_script() {
|
145 |
$this->settings = array(
|
146 |
+
"metaseo_title_home" => "",
|
147 |
+
"metaseo_desc_home" => "",
|
148 |
+
"metaseo_showfacebook" => "",
|
149 |
+
"metaseo_showtwitter" => "",
|
150 |
+
"metaseo_twitter_card" => "summary",
|
151 |
+
"metaseo_showkeywords" => 0,
|
152 |
+
"metaseo_showtmetablock" => 1,
|
153 |
"metaseo_showsocial" => 1,
|
154 |
"metaseo_seovalidate" => 0
|
155 |
+
);
|
156 |
+
$settings = get_option('_metaseo_settings');
|
157 |
+
|
158 |
+
if (is_array($settings)) {
|
159 |
+
$this->settings = array_merge($this->settings, $settings);
|
160 |
+
}
|
161 |
+
|
162 |
return array(
|
163 |
+
'choose_image' => __('Use Image', 'wp-meta-seo'),
|
164 |
+
'use_validate' => $this->settings['metaseo_seovalidate']
|
165 |
);
|
166 |
}
|
167 |
|
168 |
+
/* Localize a script */
|
169 |
public function meta_seo_localize_script() {
|
170 |
$post = $this->get_metabox_post();
|
171 |
|
213 |
'sep',
|
214 |
'page',
|
215 |
);
|
216 |
+
|
217 |
foreach ($vars_to_cache as $var) {
|
218 |
$cached_replacement_vars[$var] = $var;
|
219 |
}
|
220 |
+
|
221 |
$cached_replacement_vars['sitename'] = get_option('blogname');
|
222 |
$array_keyword = array(
|
223 |
'field_prefix' => self::$form_prefix,
|
233 |
'no_parent_text' => __('(no parent)', 'wp-meta-seo'),
|
234 |
'show_keywords' => 0
|
235 |
);
|
236 |
+
$settings = get_option('_metaseo_settings');
|
237 |
+
if (isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1) {
|
238 |
$array_keyword['show_keywords'] = 1;
|
239 |
}
|
240 |
+
|
241 |
return array_merge($cached_replacement_vars, $array_keyword);
|
242 |
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Test whether the metabox should be hidden either by choice of the admin or because
|
246 |
+
* the post type is not a public post type
|
247 |
+
*
|
248 |
+
* @since 1.5.0
|
249 |
+
*
|
250 |
+
* @param string $post_type (optional) The post type to test, defaults to the current post post_type.
|
251 |
+
*
|
252 |
+
* @return bool Whether or not the meta box (and associated columns etc) should be hidden
|
253 |
+
*/
|
254 |
function is_metabox_hidden($post_type = null) {
|
255 |
if (!isset($post_type)) {
|
256 |
if (isset($GLOBALS['post']) && ( is_object($GLOBALS['post']) && isset($GLOBALS['post']->post_type) )) {
|
269 |
}
|
270 |
return false;
|
271 |
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Adds the Meta SEO meta box to the edit boxes in the edit post / page / cpt pages.
|
275 |
+
*/
|
276 |
public function add_meta_box() {
|
277 |
$post_types = get_post_types(array('public' => true));
|
278 |
|
279 |
if (is_array($post_types) && $post_types !== array()) {
|
280 |
foreach ($post_types as $post_type) {
|
281 |
if ($this->is_metabox_hidden($post_type) === false) {
|
282 |
+
add_meta_box('wpmseo_meta', __('WP Meta SEO - Page optimization', 'wp-meta-seo'), array(
|
283 |
$this,
|
284 |
'meta_box',
|
285 |
), $post_type, 'normal', apply_filters('wpmseo_metabox_prio', 'core'));
|
287 |
}
|
288 |
}
|
289 |
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Output the meta box
|
293 |
+
*/
|
294 |
function meta_box() {
|
295 |
$post = $this->get_metabox_post();
|
296 |
$default_settings = array(
|
297 |
+
"metaseo_title_home" => "",
|
298 |
+
"metaseo_desc_home" => "",
|
299 |
+
"metaseo_showfacebook" => "",
|
300 |
+
"metaseo_showtwitter" => "",
|
301 |
+
"metaseo_twitter_card" => "summary",
|
302 |
+
"metaseo_showtmetablock" => 1,
|
303 |
"metaseo_showsocial" => 1
|
304 |
+
);
|
305 |
+
$settings = get_option('_metaseo_settings');
|
306 |
+
if (is_array($settings)) {
|
307 |
+
$default_settings = array_merge($default_settings, $settings);
|
308 |
+
}
|
|
|
309 |
?>
|
310 |
<div class="wpmseo-metabox-tabs-div">
|
311 |
<ul class="wpmseo-metabox-tabs" id="wpmseo-metabox-tabs">
|
312 |
<li class="general">
|
313 |
<a class="wpmseo_tablink" data-link="wpmseo_general"><?php _e('SEO Page optimization', 'wp-meta-seo'); ?></a>
|
314 |
</li>
|
315 |
+
|
316 |
+
<?php if ((isset($default_settings['metaseo_showsocial']) && $default_settings['metaseo_showsocial'] == 1)): ?>
|
317 |
<li class="social">
|
318 |
+
<a class="wpmseo_tablink" data-link="wpmseo_social"><?php _e('Social for search engine', 'wp-meta-seo') ?></a>
|
319 |
</li>
|
320 |
<?php endif; ?>
|
321 |
<?php do_action('wpmseo_tab_header'); ?>
|
331 |
$this->do_tab('general', __('General', 'wp-meta-seo'), $content);
|
332 |
|
333 |
$content = '';
|
334 |
+
foreach ($this->get_meta_field_defs('social') as $meta_key => $meta_field) {
|
335 |
+
$content .= $this->do_meta_box($meta_field, $meta_key);
|
336 |
}
|
337 |
+
|
338 |
+
if ((isset($default_settings['metaseo_showsocial']) && $default_settings['metaseo_showsocial'] == 1)) {
|
339 |
+
$this->do_tab('social', __('Social', 'wp-meta-seo'), $content);
|
340 |
}
|
341 |
+
|
342 |
do_action('wpmseo_tab_content');
|
343 |
|
344 |
+
echo '</div>';
|
345 |
+
}
|
346 |
+
|
347 |
+
/*
|
348 |
+
* return html field settings
|
349 |
+
*/
|
350 |
+
function metaseo_create_field($data_title, $alt, $dashicon, $label, $value_hidden) {
|
351 |
+
$output = '<div class="metaseo_analysis metaseo_tool" data-title="' . $data_title . '" alt="' . $alt . '"><i class="metaseo-dashicons material-icons dashicons-before" style="' . ($dashicon == 'done' ? 'color:#46B450' : 'color:#FFB900') . '">' . $dashicon . '</i>' . $label . '</div>';
|
352 |
+
$output .= '<input type="hidden" class="wpms_analysis_hidden" name="wpms[' . $data_title . ']" value="' . $value_hidden . '">';
|
353 |
+
return $output;
|
354 |
+
}
|
355 |
+
|
356 |
+
/* load param heading title */
|
357 |
+
function metaseo_check_headingtitle($post, $meta_title, $tooltip_page, $meta_analysis) {
|
358 |
+
$words_post_title = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($post->post_title));
|
359 |
+
if ($post->post_content == '') {
|
360 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
361 |
return $output;
|
362 |
}
|
363 |
+
$dom = new DOMDocument;
|
364 |
+
libxml_use_internal_errors(true);
|
365 |
+
if ($dom->loadHTML($post->post_content)) {
|
366 |
+
// Extracting the specified elements from the web page
|
367 |
+
$tags_h1 = $dom->getElementsByTagName('h1');
|
368 |
+
$tags_h2 = $dom->getElementsByTagName('h2');
|
369 |
+
$tags_h3 = $dom->getElementsByTagName('h3');
|
370 |
+
$tags_h4 = $dom->getElementsByTagName('h4');
|
371 |
+
$tags_h5 = $dom->getElementsByTagName('h5');
|
372 |
+
$tags_h6 = $dom->getElementsByTagName('h6');
|
373 |
+
|
374 |
+
$test = false;
|
375 |
+
if (count($tags_h1) == 0 && count($tags_h2) == 0 && count($tags_h3) == 0 && count($tags_h4) == 0 && count($tags_h5) == 0 && count($tags_h6) == 0) {
|
376 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
377 |
+
} else {
|
378 |
+
if (!empty($tags_h1)) {
|
379 |
+
foreach ($tags_h1 as $order => $tagh1) {
|
380 |
+
$words_tagh1 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh1->nodeValue)));
|
381 |
+
if (is_array($words_tagh1) && is_array($words_post_title)) {
|
382 |
+
foreach ($words_tagh1 as $mh) {
|
383 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
384 |
+
$test = true;
|
385 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
386 |
+
$this->perc_score++;
|
387 |
+
return $output;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
}
|
389 |
}
|
390 |
}
|
391 |
}
|
392 |
+
}
|
393 |
+
|
394 |
+
if (!empty($tags_h2)) {
|
395 |
+
foreach ($tags_h2 as $order => $tagh2) {
|
396 |
+
$words_tagh2 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh2->nodeValue)));
|
397 |
+
if (is_array($words_tagh2) && is_array($words_post_title)) {
|
398 |
+
foreach ($words_tagh2 as $mh) {
|
399 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
400 |
+
$test = true;
|
401 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
402 |
+
$this->perc_score++;
|
403 |
+
return $output;
|
404 |
}
|
405 |
}
|
406 |
}
|
407 |
}
|
408 |
+
}
|
409 |
+
|
410 |
+
if (!empty($tags_h3)) {
|
411 |
+
foreach ($tags_h3 as $order => $tagh3) {
|
412 |
+
$words_tagh3 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh3->nodeValue)));
|
413 |
+
if (is_array($words_tagh3) && is_array($words_post_title)) {
|
414 |
+
foreach ($words_tagh3 as $mh) {
|
415 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
416 |
+
$test = true;
|
417 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
418 |
+
$this->perc_score++;
|
419 |
+
return $output;
|
420 |
}
|
421 |
}
|
422 |
}
|
423 |
}
|
424 |
+
}
|
425 |
+
|
426 |
+
if (!empty($tags_h4)) {
|
427 |
+
foreach ($tags_h4 as $order => $tagh4) {
|
428 |
+
$words_tagh4 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh4->nodeValue)));
|
429 |
+
if (is_array($words_tagh4) && is_array($words_post_title)) {
|
430 |
+
foreach ($words_tagh4 as $mh) {
|
431 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
432 |
+
$test = true;
|
433 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
434 |
+
$this->perc_score++;
|
435 |
+
return $output;
|
436 |
}
|
437 |
}
|
438 |
}
|
439 |
}
|
440 |
+
}
|
441 |
+
|
442 |
+
if (!empty($tags_h5)) {
|
443 |
+
foreach ($tags_h5 as $order => $tagh5) {
|
444 |
+
$words_tagh5 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh5->nodeValue)));
|
445 |
+
if (is_array($words_tagh5) && is_array($words_post_title)) {
|
446 |
+
foreach ($words_tagh5 as $mh) {
|
447 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
448 |
+
$test = true;
|
449 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
450 |
+
$this->perc_score++;
|
451 |
+
return $output;
|
452 |
}
|
453 |
}
|
454 |
}
|
455 |
}
|
456 |
+
}
|
457 |
+
|
458 |
+
if (!empty($tags_h6)) {
|
459 |
+
foreach ($tags_h6 as $order => $tagh6) {
|
460 |
+
$words_tagh6 = preg_split('~[^\p{L}\p{N}\']+~u', utf8_decode(strtolower($tagh6->nodeValue)));
|
461 |
+
if (is_array($words_tagh6) && is_array($words_post_title)) {
|
462 |
+
foreach ($words_tagh6 as $mh) {
|
463 |
+
if (in_array($mh, $words_post_title) && $mh != '') {
|
464 |
+
$test = true;
|
465 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
466 |
+
$this->perc_score++;
|
467 |
+
return $output;
|
468 |
}
|
469 |
}
|
470 |
}
|
471 |
}
|
472 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
}
|
474 |
+
|
475 |
+
if ($test || (!empty($meta_analysis) && !empty($meta_analysis['heading_title']))) {
|
476 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'done', __('Page title word in content heading', 'wp-meta-seo'), 1);
|
477 |
$this->perc_score++;
|
478 |
+
} else {
|
479 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
480 |
}
|
481 |
+
} else {
|
482 |
+
$output = $this->metaseo_create_field('heading_title', $tooltip_page['title_in_heading'], 'warning', __('Page title word in content heading', 'wp-meta-seo'), 0);
|
483 |
}
|
484 |
+
|
485 |
+
return $output;
|
486 |
+
}
|
487 |
+
|
488 |
+
/* load param word content */
|
489 |
+
function metaseo_check_content($post, $tooltip_page, $meta_analysis) {
|
490 |
+
$words_meta_title = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($post->post_title));
|
491 |
+
$words_post_content = preg_split('~[^\p{L}\p{N}\']+~u', strtolower($post->post_content));
|
492 |
+
$test1 = false;
|
493 |
+
if (is_array($words_meta_title) && is_array($words_post_content)) {
|
494 |
+
foreach ($words_meta_title as $mtitle) {
|
495 |
+
if (in_array($mtitle, $words_post_content) && $mtitle != '') {
|
496 |
+
$test1 = true;
|
497 |
+
break;
|
498 |
+
}
|
499 |
}
|
500 |
+
} else {
|
501 |
+
$test1 = false;
|
502 |
}
|
503 |
+
|
504 |
+
if ($test1 || (!empty($meta_analysis) && !empty($meta_analysis['content_title']))) {
|
505 |
+
$output = $this->metaseo_create_field('content_title', $tooltip_page['title_in_content'], 'done', __('Page title word in content', 'wp-meta-seo'), 1);
|
506 |
+
$this->perc_score++;
|
507 |
+
} else {
|
508 |
+
$output = $this->metaseo_create_field('content_title', $tooltip_page['title_in_content'], 'warning', __('Page title word in content', 'wp-meta-seo'), 0);
|
|
|
|
|
|
|
509 |
}
|
510 |
+
|
511 |
+
return $output;
|
512 |
+
}
|
513 |
+
|
514 |
+
/* load param page url */
|
515 |
+
function metaseo_check_pageurl($post, $tooltip_page, $meta_analysis) {
|
516 |
+
$pageurl = get_permalink($post->ID);
|
517 |
+
$info = pathinfo($pageurl);
|
518 |
+
|
519 |
+
if ($info['filename'] == sanitize_title($post->post_title) || (!empty($meta_analysis) && !empty($meta_analysis['pageurl']))) {
|
520 |
+
$output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'done', __('Page url matches with page title', 'wp-meta-seo'), 1);
|
521 |
+
$this->perc_score++;
|
522 |
+
} else {
|
523 |
+
$output = $this->metaseo_create_field('pageurl', $tooltip_page['page_url'], 'warning', __('Page url matches with page title', 'wp-meta-seo'), 0);
|
524 |
}
|
525 |
+
|
526 |
+
return $output;
|
527 |
+
}
|
528 |
+
|
529 |
+
/* load param meta title */
|
530 |
+
function metaseo_check_metatitle($meta_title, $tooltip_page, $meta_analysis) {
|
531 |
+
if (($meta_title != '' && strlen($meta_title) <= self::$meta_title_length) || (!empty($meta_analysis) && !empty($meta_analysis['metatitle']))) {
|
532 |
+
$output = $this->metaseo_create_field('metatitle', $tooltip_page['meta_title'], 'done', __('Meta title filled', 'wp-meta-seo'), 1);
|
533 |
+
$this->perc_score++;
|
534 |
+
} else {
|
535 |
+
$output = $this->metaseo_create_field('metatitle', $tooltip_page['meta_title'], 'warning', __('Meta title filled', 'wp-meta-seo'), 0);
|
536 |
+
}
|
537 |
+
return $output;
|
538 |
+
}
|
539 |
+
|
540 |
+
/* load param meta description */
|
541 |
+
function metaseo_check_metadesc($meta_desc, $tooltip_page, $meta_analysis) {
|
542 |
+
if (($meta_desc != '' && strlen($meta_desc) <= self::$meta_length) || (!empty($meta_analysis) && !empty($meta_analysis['metadesc']))) {
|
543 |
+
$output = $this->metaseo_create_field('metadesc', $tooltip_page['meta_desc'], 'done', __('Meta description filled', 'wp-meta-seo'), 1);
|
544 |
+
$this->perc_score++;
|
545 |
+
} else {
|
546 |
+
$output = $this->metaseo_create_field('metadesc', $tooltip_page['meta_desc'], 'warning', __('Meta description filled', 'wp-meta-seo'), 0);
|
547 |
+
}
|
548 |
+
return $output;
|
549 |
+
}
|
550 |
+
|
551 |
+
/* load param image resize */
|
552 |
+
function metaseo_check_imageresize($content, $tooltip_page, $meta_analysis) {
|
553 |
+
if ($content == '') {
|
554 |
+
$output = $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'done', __('Wrong image resize', 'wp-meta-seo'), 1);
|
555 |
+
$this->perc_score++;
|
|
|
|
|
|
|
|
|
|
|
556 |
return $output;
|
557 |
}
|
558 |
+
$dom = new DOMDocument;
|
559 |
+
libxml_use_internal_errors(true);
|
560 |
+
if ($dom->loadHTML($content)) {
|
561 |
+
// Extracting the specified elements from the web page
|
562 |
+
$tags = $dom->getElementsByTagName('img');
|
563 |
+
$img_wrong = false;
|
564 |
+
foreach ($tags as $order => $tag) {
|
565 |
+
$src = $tag->getAttribute('src');
|
566 |
+
$b = strrpos($src, '-');
|
567 |
+
$e = strrpos($src, '.');
|
568 |
+
$string_wh = substr($src, $b + 1, $e - $b - 1);
|
569 |
+
$array_wh = explode('x', $string_wh);
|
570 |
+
if (!empty($array_wh[0]) && !empty($array_wh[1])) {
|
571 |
+
if (((int) $array_wh[0] != (int) $tag->getAttribute('width')) || ((int) $array_wh[1] != (int) $tag->getAttribute('height'))) {
|
|
|
|
|
|
|
572 |
$img_wrong = true;
|
573 |
}
|
574 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
}
|
576 |
+
|
577 |
+
if ($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgresize']))) {
|
578 |
+
$output = $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'done', __('Wrong image resize', 'wp-meta-seo'), 1);
|
579 |
+
$this->perc_score++;
|
580 |
+
} else {
|
581 |
+
$output = $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'warning', __('Wrong image resize', 'wp-meta-seo'), 0);
|
582 |
+
}
|
583 |
+
} else {
|
584 |
+
$output = $this->metaseo_create_field('imgresize', $tooltip_page['image_resize'], 'warning', __('Wrong image resize', 'wp-meta-seo'), 0);
|
585 |
}
|
586 |
+
return $output;
|
587 |
+
}
|
588 |
+
|
589 |
+
/* load param image alt */
|
590 |
+
function metaseo_check_imagealt($content, $tooltip_page, $meta_analysis) {
|
591 |
+
if ($content == '') {
|
592 |
+
$output = $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'done', __('Image have meta title or alt', 'wp-meta-seo'), 1);
|
593 |
+
$this->perc_score++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
return $output;
|
595 |
}
|
596 |
+
$dom = new DOMDocument;
|
597 |
+
libxml_use_internal_errors(true);
|
598 |
+
if ($dom->loadHTML($content)) {
|
599 |
+
// Extracting the specified elements from the web page
|
600 |
+
$tags = $dom->getElementsByTagName('img');
|
601 |
+
$img_wrong = false;
|
602 |
+
foreach ($tags as $order => $tag) {
|
603 |
+
$image_title = $tag->getAttribute('title');
|
604 |
+
$image_alt = $tag->getAttribute('alt');
|
605 |
+
if ($image_title == '' || $image_alt == '') {
|
606 |
+
$img_wrong = true;
|
607 |
+
}
|
608 |
}
|
609 |
|
610 |
+
if ($img_wrong == false || (!empty($meta_analysis) && !empty($meta_analysis['imgalt']))) {
|
611 |
+
$output = $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'done', __('Image have meta title or alt', 'wp-meta-seo'), 1);
|
612 |
+
$this->perc_score++;
|
613 |
+
} else {
|
614 |
+
$output = $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'warning', __('Image have meta title or alt', 'wp-meta-seo'), 0);
|
615 |
+
}
|
616 |
+
} else {
|
617 |
+
$output = $this->metaseo_create_field('imgalt', $tooltip_page['image_alt'], 'warning', __('Image have meta title or alt', 'wp-meta-seo'), 0);
|
618 |
+
}
|
619 |
+
return $output;
|
620 |
+
}
|
621 |
+
|
622 |
+
/*
|
623 |
+
* Load page analysis
|
624 |
+
*/
|
625 |
+
function metaseo_page_analysis($post) {
|
626 |
+
$tooltip_page = array();
|
627 |
+
$tooltip_page['title_in_heading'] = __('Check if a word of this content title is also in a title heading (h1, h2...)', 'wp-meta-seo');
|
628 |
+
$tooltip_page['title_in_content'] = __('Check if a word of this content title is also in the text', 'wp-meta-seo');
|
629 |
+
$tooltip_page['page_url'] = __('Does the page title match with the permalink (URL structure)', 'wp-meta-seo');
|
630 |
+
$tooltip_page['meta_title'] = __('Is the meta title of this page filled?', 'wp-meta-seo');
|
631 |
+
$tooltip_page['meta_desc'] = __('Is the meta description of this page filled?', 'wp-meta-seo');
|
632 |
+
$tooltip_page['image_resize'] = __('Check for image HTML resizing in content (usually image resized using handles)', 'wp-meta-seo');
|
633 |
+
$tooltip_page['image_alt'] = __('Check for image Alt text and title', 'wp-meta-seo');
|
634 |
+
|
635 |
+
$meta_title = get_post_meta($post->ID, '_metaseo_metatitle', true);
|
636 |
+
$meta_desc = get_post_meta($post->ID, '_metaseo_metadesc', true);
|
637 |
+
$meta_analysis = get_post_meta($post->ID, 'wpms_validate_analysis', true);
|
638 |
+
if (empty($meta_analysis))
|
639 |
+
$meta_analysis = array();
|
640 |
+
$headingtitle = $this->metaseo_check_headingtitle($post, $meta_title, $tooltip_page, $meta_analysis);
|
641 |
+
$contenttitle = $this->metaseo_check_content($post, $tooltip_page, $meta_analysis);
|
642 |
+
$output_pageurl = $this->metaseo_check_pageurl($post, $tooltip_page, $meta_analysis);
|
643 |
+
$output_metatitle = $this->metaseo_check_metatitle($meta_title, $tooltip_page, $meta_analysis);
|
644 |
+
$output_metadesc = $this->metaseo_check_metadesc($meta_desc, $tooltip_page, $meta_analysis);
|
645 |
+
$output_imagewrong = $this->metaseo_check_imageresize($post->post_content, $tooltip_page, $meta_analysis);
|
646 |
+
$output_imagealt = $this->metaseo_check_imagealt($post->post_content, $tooltip_page, $meta_analysis);
|
647 |
+
|
648 |
+
$output = '';
|
649 |
+
$circliful = ceil(100 * ($this->perc_score) / 7);
|
650 |
+
$output .= '<div style="width:100%;float:left;">';
|
651 |
+
$output .= '<div class="metaseo_left">
|
652 |
+
<div class="metaseo-progress-bar" data-post_id="' . $post->ID . '">
|
653 |
+
<canvas id="inactiveProgress" class="metaseo-progress-inactive" height="275px" width="275px"></canvas>
|
654 |
+
<canvas id="activeProgress" class="metaseo-progress-active" height="275px" width="275px"></canvas>
|
655 |
+
<p>0%</p>
|
|
|
|
|
|
|
656 |
</div>
|
657 |
+
<input type="hidden" id="progressController" value="' . $circliful . '" />
|
658 |
+
<input type="hidden" id="metaseo_alanysis_ok" value="' . $this->perc_score . '" />
|
659 |
+
</div>';
|
660 |
+
|
661 |
+
$output .= '<div class="metaseo_right">';
|
662 |
+
$output .= $headingtitle . $contenttitle . $output_pageurl . $output_metatitle . $output_metadesc . $output_imagewrong . $output_imagealt;
|
663 |
+
$output .= '</div>';
|
664 |
+
$output .= '</div>';
|
665 |
+
return $output;
|
666 |
+
}
|
667 |
+
|
668 |
+
/**
|
669 |
+
* Get a sample permalink based off of the post name.
|
670 |
+
*/
|
671 |
+
function get_sample_permalink($post) {
|
672 |
+
if (!function_exists('get_sample_permalink')) {
|
673 |
+
include_once( ABSPATH . 'wp-admin/includes/post.php' );
|
674 |
}
|
675 |
|
676 |
+
return get_sample_permalink($post);
|
677 |
+
}
|
678 |
+
|
679 |
+
/* Display html content for current tab */
|
680 |
+
public function do_tab($id, $heading, $content) {
|
681 |
+
global $post;
|
682 |
+
?>
|
683 |
+
<div class="wpmseotab <?php echo esc_attr($id) ?>">
|
684 |
+
<?php if ($id == 'general'): ?>
|
685 |
+
<p class="reload_analysis"><span class="spinner" style="float: left;"></span><input type="button" name="reload_analysis" id="reload_analysis" class="button button-primary" value="<?php _e('Reload analysis', 'wp-meta-seo'); ?>"></p>
|
686 |
+
<?php endif; ?>
|
687 |
+
<table class="form-table">
|
688 |
+
<?php echo $content ?>
|
689 |
+
</table>
|
690 |
+
<?php
|
691 |
+
if ($id == 'general') {
|
692 |
+
echo $this->metaseo_page_analysis($post);
|
693 |
+
$settings = get_option('_metaseo_settings');
|
694 |
+
if (!empty($settings['metaseo_follow'])) {
|
695 |
+
$page_follow = get_post_meta($post->ID, '_metaseo_metafollow', true);
|
696 |
+
$select_follow = '<select class="metaseo_metabox_follow" data-post_id="' . $post->ID . '">';
|
697 |
+
if ($page_follow == 'nofollow') {
|
698 |
+
$select_follow .= '<option value="follow">' . __('Follow', 'wp-meta-seo') . '</option>';
|
699 |
+
$select_follow .= '<option selected value="nofollow">' . __('Nofollow', 'wp-meta-seo') . '</option>';
|
700 |
+
} else {
|
701 |
+
$select_follow .= '<option selected value="follow">' . __('Follow', 'wp-meta-seo') . '</option>';
|
702 |
+
$select_follow .= '<option value="nofollow">' . __('Nofollow', 'wp-meta-seo') . '</option>';
|
703 |
+
}
|
704 |
+
$select_follow .= '</select>';
|
705 |
+
echo '<p><span class="wpmslabel">' . __('Follow', 'wp-meta-seo') . '<i class="material-icons alignright metaseo_help" id="deschelp" alt="' . __('Nofollow provides a way for webmasters to tell search engines: don\'t follow this link. So it may influence the link target’s ranking', 'wp-meta-seo') . '" style="color:#32373C" data-hasqtip="2">chat_bubble</i></span>' . $select_follow . '</p>';
|
706 |
+
}
|
707 |
|
708 |
+
if (!empty($settings['metaseo_index'])) {
|
709 |
+
$page_index = get_post_meta($post->ID, '_metaseo_metaindex', true);
|
710 |
+
$select_index = '<select class="metaseo_metabox_index" data-post_id="' . $post->ID . '">';
|
711 |
+
if ($page_index == 'noindex') {
|
712 |
+
$select_index .= '<option value="index">' . __('Index', 'wp-meta-seo') . '</option>';
|
713 |
+
$select_index .= '<option selected value="noindex">' . __('Noindex', 'wp-meta-seo') . '</option>';
|
714 |
+
} else {
|
715 |
+
$select_index .= '<option selected value="index">' . __('Index', 'wp-meta-seo') . '</option>';
|
716 |
+
$select_index .= '<option value="noindex">' . __('Noindex', 'wp-meta-seo') . '</option>';
|
717 |
+
}
|
718 |
|
719 |
+
$select_index .= '</select>';
|
720 |
+
echo '<p><span class="wpmslabel">' . __('Index', 'wp-meta-seo') . '<i class="material-icons alignright metaseo_help" id="deschelp" alt="' . __('Allow search engines robots to index this content, as default your content is indexed', 'wp-meta-seo') . '" style="color:#32373C" data-hasqtip="2">chat_bubble</i></span>' . $select_index . '</p>';
|
721 |
+
}
|
722 |
}
|
723 |
+
?>
|
724 |
+
</div>
|
725 |
+
<?php
|
726 |
+
}
|
727 |
+
|
728 |
+
/* Display html content for current tab */
|
729 |
+
function do_meta_box($meta_field_def, $key = '') {
|
730 |
+
wp_enqueue_style('metaseo-google-icon');
|
731 |
+
$content = '';
|
732 |
+
$esc_form_key = esc_attr(self::$form_prefix . $key);
|
733 |
+
$post = $this->get_metabox_post();
|
734 |
+
$meta_value = self::get_value($key, $post->ID);
|
735 |
|
736 |
+
$class = '';
|
737 |
+
if (isset($meta_field_def['class']) && $meta_field_def['class'] !== '') {
|
738 |
+
$class = ' ' . $meta_field_def['class'];
|
739 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
|
741 |
+
$placeholder = '';
|
742 |
+
if (isset($meta_field_def['placeholder']) && $meta_field_def['placeholder'] !== '') {
|
743 |
+
$placeholder = $meta_field_def['placeholder'];
|
744 |
+
}
|
|
|
|
|
|
|
745 |
|
746 |
+
switch ($meta_field_def['type']) {
|
747 |
+
case 'snippetpreview':
|
748 |
+
$content .= $this->snippet();
|
749 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
750 |
|
751 |
+
case 'text':
|
752 |
+
$ac = '';
|
753 |
+
if (isset($meta_field_def['autocomplete']) && $meta_field_def['autocomplete'] === false) {
|
754 |
+
$ac = 'autocomplete="off" ';
|
755 |
+
}
|
756 |
+
if ($placeholder !== '') {
|
757 |
+
$placeholder = ' placeholder="' . esc_attr($placeholder) . '"';
|
758 |
+
}
|
759 |
+
$content .= '<input type="text"' . $placeholder . ' id="' . $esc_form_key . '" ' . $ac . 'name="' . $esc_form_key . '" value="' . esc_attr($meta_value) . '" class="large-text' . $class . '"/><br />';
|
760 |
+
break;
|
761 |
|
762 |
+
case 'textarea':
|
763 |
+
$rows = 3;
|
764 |
+
if (isset($meta_field_def['rows']) && $meta_field_def['rows'] > 0) {
|
765 |
+
$rows = $meta_field_def['rows'];
|
766 |
+
}
|
767 |
+
$content .= '<textarea class="large-text' . $class . '" rows="' . esc_attr($rows) . '" id="' . $esc_form_key . '" name="' . $esc_form_key . '">' . esc_textarea($meta_value) . '</textarea>';
|
768 |
+
break;
|
769 |
+
|
770 |
+
case 'select':
|
771 |
+
if (isset($meta_field_def['options']) && is_array($meta_field_def['options']) && $meta_field_def['options'] !== array()) {
|
772 |
+
$content .= '<select name="' . $esc_form_key . '" id="' . $esc_form_key . '" class="metaseo' . $class . '">';
|
773 |
+
foreach ($meta_field_def['options'] as $val => $option) {
|
774 |
+
$selected = selected($meta_value, $val, false);
|
775 |
+
$content .= '<option ' . $selected . ' value="' . esc_attr($val) . '">' . esc_html($option) . '</option>';
|
776 |
+
}
|
777 |
+
unset($val, $option, $selected);
|
778 |
+
$content .= '</select>';
|
779 |
+
}
|
780 |
+
break;
|
781 |
|
782 |
+
case 'multiselect':
|
783 |
+
if (isset($meta_field_def['options']) && is_array($meta_field_def['options']) && $meta_field_def['options'] !== array()) {
|
784 |
+
$selected_arr = $meta_value;
|
785 |
+
if ('meta-robots-adv' === $key) {
|
786 |
+
$selected_arr = explode(',', $meta_value);
|
787 |
+
}
|
788 |
|
789 |
+
if (!is_array($selected_arr)) {
|
790 |
+
$selected_arr = (array) $selected_arr;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
}
|
|
|
792 |
|
793 |
+
$options_count = count($meta_field_def['options']);
|
|
|
|
|
|
|
|
|
|
|
794 |
|
795 |
+
$content .= '<select multiple="multiple" size="' . esc_attr($options_count) . '" style="height: ' . esc_attr(( $options_count * 20 ) + 4) . 'px;" name="' . $esc_form_key . '[]" id="' . $esc_form_key . '" class="metaseo' . $class . '">';
|
796 |
+
foreach ($meta_field_def['options'] as $val => $option) {
|
797 |
+
$selected = '';
|
798 |
+
if (in_array($val, $selected_arr)) {
|
799 |
+
$selected = ' selected="selected"';
|
800 |
}
|
801 |
+
$content .= '<option ' . $selected . ' value="' . esc_attr($val) . '">' . esc_html($option) . '</option>';
|
802 |
}
|
803 |
+
$content .= '</select>';
|
804 |
+
unset($val, $option, $selected, $selected_arr, $options_count);
|
805 |
+
}
|
806 |
+
break;
|
807 |
+
|
808 |
+
case 'checkbox':
|
809 |
+
$checked = checked($meta_value, 'on', false);
|
810 |
+
$expl = ( isset($meta_field_def['expl']) ) ? esc_html($meta_field_def['expl']) : '';
|
811 |
+
$content .= '<label for="' . $esc_form_key . '"><input type="checkbox" id="' . $esc_form_key . '" name="' . $esc_form_key . '" ' . $checked . ' value="on" class="metaseo' . $class . '"/> ' . $expl . '</label><br />';
|
812 |
+
unset($checked, $expl);
|
813 |
+
break;
|
814 |
+
|
815 |
+
case 'radio':
|
816 |
+
if (isset($meta_field_def['options']) && is_array($meta_field_def['options']) && $meta_field_def['options'] !== array()) {
|
817 |
+
foreach ($meta_field_def['options'] as $val => $option) {
|
818 |
+
$checked = checked($meta_value, $val, false);
|
819 |
+
$content .= '<input type="radio" ' . $checked . ' id="' . $esc_form_key . '_' . esc_attr($val) . '" name="' . $esc_form_key . '" value="' . esc_attr($val) . '"/> <label for="' . $esc_form_key . '_' . esc_attr($val) . '">' . esc_html($option) . '</label> ';
|
820 |
+
}
|
821 |
+
unset($val, $option, $checked);
|
822 |
+
}
|
823 |
+
break;
|
824 |
|
825 |
+
case 'upload':
|
826 |
+
$content .= '<input id="' . $esc_form_key . '" type="text" size="36" class="' . $class . '" name="' . $esc_form_key . '" value="' . esc_attr($meta_value) . '" />';
|
827 |
+
$content .= '<input id="' . $esc_form_key . '_button" class="wpmseo_image_upload_button button" type="button" value="' . __('Upload Image', 'wp-meta-seo') . '" />';
|
828 |
+
break;
|
829 |
+
}
|
830 |
|
|
|
|
|
|
|
|
|
831 |
|
832 |
+
$html = '';
|
833 |
+
if ($content === '') {
|
834 |
+
$content = apply_filters('wpmseo_do_meta_box_field_' . $key, $content, $meta_value, $esc_form_key, $meta_field_def, $key);
|
835 |
+
}
|
836 |
|
837 |
+
if ($content !== '') {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
838 |
|
839 |
+
$label = esc_html($meta_field_def['title']);
|
840 |
+
if (in_array($meta_field_def['type'], array(
|
841 |
+
'snippetpreview',
|
842 |
+
'radio',
|
843 |
+
'checkbox',
|
844 |
+
), true) === false
|
845 |
+
) {
|
846 |
+
$label = '<label for="' . $esc_form_key . '">' . $label . ':</label>';
|
847 |
+
}
|
848 |
|
849 |
+
$help = '';
|
850 |
+
if (isset($meta_field_def['help']) && $meta_field_def['help'] !== '') {
|
851 |
+
$help = '<i class="material-icons alignright metaseo_help" id="' . esc_attr($key . 'help') . '" alt="' . esc_attr($meta_field_def['help']) . '" style="color:#32373C">chat_bubble</i>';
|
852 |
+
}
|
853 |
|
854 |
+
$html = '
|
855 |
+
<tr>
|
856 |
+
<th scope="row">' . $label . $help . '</th>
|
857 |
+
<td>';
|
858 |
|
859 |
+
$html .= $content;
|
|
|
|
|
860 |
|
861 |
+
if (isset($meta_field_def['description'])) {
|
862 |
+
$html .= '<div>' . $meta_field_def['description'] . '</div>';
|
|
|
863 |
}
|
|
|
|
|
864 |
|
865 |
+
$html .= '
|
866 |
+
</td>
|
867 |
+
</tr>';
|
868 |
+
}
|
869 |
+
return $html;
|
870 |
+
}
|
|
|
871 |
|
872 |
+
private function get_metabox_post() {
|
873 |
+
if (isset($_GET['post'])) {
|
874 |
+
$post_id = (int) $_GET['post'];
|
875 |
+
$post = get_post($post_id);
|
876 |
+
} else {
|
877 |
+
$post = $GLOBALS['post'];
|
878 |
}
|
879 |
|
880 |
+
return $post;
|
881 |
+
}
|
|
|
|
|
882 |
|
883 |
+
function snippet() {
|
884 |
+
$post = $this->get_metabox_post();
|
885 |
+
$title = self::get_value('title', $post->ID);
|
886 |
+
$description = self::get_value('desc', $post->ID);
|
887 |
|
888 |
+
$snippet_preview = new WPMSEO_Snippet_Preview($post, $title, $description);
|
|
|
889 |
|
890 |
+
return $snippet_preview->get_content();
|
891 |
}
|
892 |
+
}
|
893 |
|
894 |
+
/* End of class */
|
inc/class.metaseo-sitemap.php
CHANGED
@@ -5,9 +5,9 @@ class MetaSeo_Sitemap {
|
|
5 |
public $html = '';
|
6 |
public $wpms_sitemap_name = 'wpms-sitemap.xml';
|
7 |
public $wpms_sitemap_default_name = 'sitemap.xml';
|
8 |
-
public $columns = array('Zezo'
|
9 |
public $level = array();
|
10 |
-
|
11 |
function __construct() {
|
12 |
$this->settings_sitemap = array(
|
13 |
"wpms_sitemap_add" => 0,
|
@@ -18,16 +18,26 @@ class MetaSeo_Sitemap {
|
|
18 |
"wpms_html_sitemap_page" => 0,
|
19 |
"wpms_html_sitemap_column" => 1,
|
20 |
"wpms_html_sitemap_position" => "after",
|
21 |
-
"wpms_display_column_menus" =>
|
22 |
"wpms_display_column_posts" => 1,
|
23 |
"wpms_display_column_pages" => 1,
|
|
|
|
|
|
|
|
|
24 |
);
|
25 |
|
26 |
if (is_multisite()) {
|
27 |
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
|
28 |
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/wpms-sitemap_' . $home_url . '.xml';
|
29 |
} else {
|
30 |
-
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/'
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
$settings = get_option('_metaseo_settings_sitemap');
|
@@ -35,85 +45,76 @@ class MetaSeo_Sitemap {
|
|
35 |
$this->settings_sitemap = array_merge($this->settings_sitemap, $settings);
|
36 |
}
|
37 |
|
|
|
|
|
38 |
add_action('admin_init', array($this, 'metaseo_field_settings_sitemap'));
|
39 |
add_action('admin_enqueue_scripts', array($this, 'metaseo_sitemap_scripts'));
|
40 |
add_action('wp_enqueue_scripts', array($this, 'site_metaseo_sitemap_scripts'));
|
41 |
add_filter('the_content', array($this, 'wpms_html_sitemap_content'));
|
42 |
add_shortcode('wpms_html_sitemap', array($this, 'wpms_sitemap_shortcode'));
|
43 |
-
add_action('wp_ajax_wpms_regenerate_sitemaps',array($this,'wpms_regenerate_sitemaps'));
|
44 |
-
add_action('wp_ajax_wpms_save_sitemap_settings',array($this,'wpms_save_sitemap_settings'));
|
45 |
}
|
46 |
|
47 |
-
|
|
|
48 |
global $post;
|
49 |
-
if(empty($post))
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
);
|
54 |
wp_localize_script('site-jPages-js', 'wpms_avarible', $this->wpms_localize_script());
|
55 |
-
wp_enqueue_script(
|
56 |
-
|
57 |
-
);
|
58 |
-
|
59 |
-
wp_enqueue_style(
|
60 |
-
'jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION
|
61 |
-
);
|
62 |
}
|
63 |
|
64 |
-
|
|
|
65 |
$arrays = array('wpms_display_column_menus' => $this->settings_sitemap['wpms_display_column_menus']);
|
66 |
return $arrays;
|
67 |
}
|
68 |
-
|
69 |
-
|
|
|
70 |
global $current_screen;
|
71 |
-
if(!empty($current_screen) && $current_screen->base != 'wp-meta-seo_page_metaseo_google_sitemap')
|
72 |
-
|
73 |
-
|
74 |
-
);
|
75 |
-
|
76 |
-
|
77 |
-
'jpage-js', plugins_url('js/jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true
|
78 |
-
);
|
79 |
-
|
80 |
-
wp_enqueue_style(
|
81 |
-
'metaseositemapstyle', plugins_url('css/metaseo_sitemap.css', dirname(__FILE__)), array(), WPMSEO_VERSION
|
82 |
-
);
|
83 |
-
|
84 |
-
wp_enqueue_style(
|
85 |
-
'jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION
|
86 |
-
);
|
87 |
-
|
88 |
wp_enqueue_style('m-style-qtip', plugins_url('css/jquery.qtip.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
89 |
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
|
90 |
-
|
91 |
}
|
92 |
|
|
|
93 |
public function metaseo_field_settings_sitemap() {
|
94 |
register_setting('MetaSEO Sitemap', '_metaseo_settings_sitemap');
|
95 |
add_settings_section('metaseo_sitemap', '', array($this, 'showSettingSitemap'), 'metaseo_settings_sitemap');
|
96 |
-
add_settings_field('wpms_sitemap_link', __('XML sitemap link', 'wp-meta-seo'), array($this, 'wpms_sitemap_link'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
97 |
-
add_settings_field('wpms_html_sitemap_page', __('HTML Sitemap page', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_page'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
98 |
-
add_settings_field('wpms_sitemap_taxonomies', __('Additional content', 'wp-meta-seo'), array($this, 'wpms_sitemap_taxonomies'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
99 |
-
add_settings_field('wpms_sitemap_author', __('Display author posts', 'wp-meta-seo'), array($this, 'wpms_sitemap_author'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
100 |
-
add_settings_field('wpms_html_sitemap_column', __('HTML Sitemap display', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_column'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
101 |
add_settings_field('wpms_html_sitemap_position', __('HTML Sitemap Position', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_position'), 'metaseo_settings_sitemap', 'metaseo_sitemap');
|
102 |
-
add_settings_field('wpms_sitemap_add', __('Sitemap and robot.txt', 'wp-meta-seo'), array($this, 'wpms_sitemap_add'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
103 |
-
add_settings_field('wpms_sitemap_root', __('Sitemap root', 'wp-meta-seo'), array($this, 'wpms_sitemap_root'), 'metaseo_settings_sitemap', 'metaseo_sitemap'
|
104 |
}
|
105 |
|
106 |
public function showSettingSitemap() {
|
107 |
|
108 |
}
|
109 |
-
|
|
|
110 |
public function wpms_sitemap_link() {
|
111 |
echo '<input id="wpms_check_firstsave" name="_metaseo_settings_sitemap[wpms_check_firstsave]" type="hidden" value="1">';
|
112 |
$wpms_sitemap_link = isset($this->settings_sitemap['wpms_sitemap_link']) ? $this->settings_sitemap['wpms_sitemap_link'] : '';
|
113 |
echo '<input readonly id="wpms_sitemap_link" name="_metaseo_settings_sitemap[wpms_sitemap_link]" type="text" value="' . esc_attr($wpms_sitemap_link) . '" size="50"/>';
|
114 |
echo '<a class="button" href="' . $wpms_sitemap_link . '" target="_blank">' . __('Open', 'wp-meta-seo') . '</a>';
|
115 |
}
|
116 |
-
|
|
|
117 |
public function wpms_sitemap_add() {
|
118 |
?>
|
119 |
<?php if (is_multisite()) { ?>
|
@@ -126,32 +127,34 @@ class MetaSeo_Sitemap {
|
|
126 |
}
|
127 |
}
|
128 |
|
|
|
129 |
public function wpms_sitemap_root() {
|
130 |
?>
|
131 |
-
<!-- for robots.txt we need to use site_url instead home_url ! -->
|
132 |
<label><input id="wpms_sitemap_root" type='checkbox' name='_metaseo_settings_sitemap[wpms_sitemap_root]' value="1" <?php checked(1, $this->settings_sitemap['wpms_sitemap_root']); ?> /> <?php _e("Add a sitemap.xml copy @ the site root", 'wp-meta-seo'); ?></label>
|
133 |
<?php
|
134 |
}
|
135 |
|
|
|
136 |
public function wpms_sitemap_author() {
|
137 |
?>
|
138 |
-
<!-- for robots.txt we need to use site_url instead home_url ! -->
|
139 |
<label><input id="wpms_sitemap_author" type='checkbox' name='_metaseo_settings_sitemap[wpms_sitemap_author]' value="1" <?php checked(1, $this->settings_sitemap['wpms_sitemap_author']); ?> /> <?php _e("Display author post archive", 'wp-meta-seo'); ?></label>
|
140 |
<?php
|
141 |
}
|
142 |
-
|
|
|
143 |
public function wpms_sitemap_taxonomies() {
|
144 |
$wpms_taxonomies = array(
|
145 |
'category' => 'Post category',
|
146 |
'post_tag' => 'Post tag'
|
147 |
);
|
148 |
foreach ($wpms_taxonomies as $key => $value) {
|
149 |
-
|
150 |
-
|
151 |
<?php
|
152 |
}
|
153 |
}
|
154 |
|
|
|
155 |
public function wpms_html_sitemap_page() {
|
156 |
global $wpdb;
|
157 |
$pages = get_pages();
|
@@ -160,25 +163,26 @@ class MetaSeo_Sitemap {
|
|
160 |
|
161 |
if (empty($this->settings_sitemap['wpms_html_sitemap_page']) && !empty($sitemap_page))
|
162 |
$this->settings_sitemap['wpms_html_sitemap_page'] = $sitemap_page->ID;
|
163 |
-
?>
|
164 |
-
<select id="wpms_html_sitemap_page" name="_metaseo_settings_sitemap[wpms_html_sitemap_page]">
|
165 |
-
<option value="0"><?php _e('- Choose Your Sitemap Page -', 'wp-meta-seo') ?></option>
|
166 |
-
<?php
|
167 |
-
foreach ($pages as $page) {
|
168 |
-
if ($this->settings_sitemap['wpms_html_sitemap_page'] == $page->ID) {
|
169 |
-
echo '<option selected value="' . $page->ID . '">' . $page->post_title . '</option>';
|
170 |
-
} else {
|
171 |
-
echo '<option value="' . $page->ID . '">' . $page->post_title . '</option>';
|
172 |
-
}
|
173 |
-
}
|
174 |
?>
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
<?php
|
177 |
if (!empty($this->settings_sitemap['wpms_html_sitemap_page'])) {
|
178 |
echo '<a class="button" href="' . get_post_permalink($this->settings_sitemap['wpms_html_sitemap_page']) . '" target="_blank">' . __('Open', 'wp-meta-seo') . '</a>';
|
179 |
}
|
180 |
}
|
181 |
|
|
|
182 |
public function wpms_html_sitemap_column() {
|
183 |
?>
|
184 |
<select id="wpms_html_sitemap_column" name="_metaseo_settings_sitemap[wpms_html_sitemap_column]">
|
@@ -188,7 +192,8 @@ class MetaSeo_Sitemap {
|
|
188 |
</select>
|
189 |
<?php
|
190 |
}
|
191 |
-
|
|
|
192 |
public function wpms_html_sitemap_position() {
|
193 |
?>
|
194 |
<select id="wpms_html_sitemap_position" name="_metaseo_settings_sitemap[wpms_html_sitemap_position]">
|
@@ -198,7 +203,7 @@ class MetaSeo_Sitemap {
|
|
198 |
</select>
|
199 |
<?php
|
200 |
}
|
201 |
-
|
202 |
function wpms_get_path_filename_sitemap() {
|
203 |
if (is_multisite()) {
|
204 |
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
|
@@ -209,7 +214,8 @@ class MetaSeo_Sitemap {
|
|
209 |
$xml_path = ABSPATH . $xml_file;
|
210 |
return array('path' => $xml_path, 'name' => $xml_file);
|
211 |
}
|
212 |
-
|
|
|
213 |
function metaseo_create_sitemap($sitemap_xml_name) {
|
214 |
global $wpdb;
|
215 |
$taxonomies = array();
|
@@ -238,96 +244,109 @@ class MetaSeo_Sitemap {
|
|
238 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
239 |
$priority = $url->appendChild($xml->createElement('priority'));
|
240 |
$priority->appendChild($xml->createTextNode(1.0));
|
241 |
-
|
242 |
-
// menus post custom
|
243 |
$menus = $this->wpms_get_menus_all();
|
244 |
$res = $menus['posts_custom'];
|
245 |
if (!empty($res)) {
|
246 |
foreach ($res as $val) {
|
247 |
-
$sql = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key
|
248 |
$menu_object = $wpdb->get_results($sql);
|
249 |
-
if(!empty($menu_object)){
|
250 |
-
foreach ($menu_object as $menu){
|
251 |
$menu_id = $menu->post_id;
|
252 |
$type = get_post_meta($menu_id, '_menu_item_type', true);
|
253 |
-
$check_type = get_post_meta($menu_id, '_menu_item_object',true);
|
254 |
-
$permalink = $this->wpms_get_permalink_sitemap($check_type
|
255 |
-
if($permalink != '#'){
|
256 |
-
if(!in_array($permalink, $list_links)){
|
257 |
$list_links[] = $permalink;
|
258 |
-
if($type != 'taxonomy'){
|
259 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
260 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
261 |
-
|
262 |
-
|
263 |
$loc->appendChild($xml->createTextNode($permalink));
|
264 |
$lastmod = $gglstmp_url->appendChild($xml->createElement('lastmod'));
|
265 |
$now = $val->post_modified;
|
266 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
267 |
$lastmod->appendChild($xml->createTextNode($date));
|
268 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
269 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
270 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
271 |
-
}else{
|
272 |
-
|
|
|
|
|
|
|
273 |
}
|
274 |
|
275 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
276 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
277 |
$priority->appendChild($xml->createTextNode('1.0'));
|
278 |
-
}else{
|
279 |
-
|
|
|
|
|
|
|
280 |
}
|
281 |
}
|
282 |
}
|
283 |
}
|
284 |
-
|
285 |
-
|
286 |
}
|
287 |
}
|
288 |
}
|
289 |
}
|
290 |
-
|
291 |
-
// menus category
|
292 |
$res = $menus['categories'];
|
293 |
if (!empty($res)) {
|
294 |
foreach ($res as $k => $val) {
|
295 |
-
$sql = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key
|
296 |
$menu_object = $wpdb->get_results($sql);
|
297 |
-
if(!empty($menu_object)){
|
298 |
-
foreach ($menu_object as $menu){
|
299 |
$menu_id = $menu->post_id;
|
300 |
$type = get_post_meta($menu_id, '_menu_item_type', true);
|
301 |
-
$check_type = get_post_meta($menu_id, '_menu_item_object',true);
|
302 |
-
$permalink = get_term_link((int)$val
|
303 |
-
if(empty($permalink))
|
304 |
-
|
|
|
305 |
$list_links[] = $permalink;
|
306 |
-
if($type == 'taxonomy'){
|
307 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
308 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
309 |
$loc->appendChild($xml->createTextNode($permalink));
|
310 |
$lastmod = $gglstmp_url->appendChild($xml->createElement('lastmod'));
|
311 |
$ps = get_post($menu_id);
|
312 |
-
|
313 |
-
if(!empty($ps)){
|
314 |
$now = $ps->post_modified;
|
315 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
316 |
$lastmod->appendChild($xml->createTextNode($date));
|
317 |
}
|
318 |
|
319 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
320 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
321 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
322 |
-
}else{
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
324 |
}
|
325 |
|
326 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
327 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
328 |
$priority->appendChild($xml->createTextNode('1.0'));
|
329 |
-
}else{
|
330 |
-
|
|
|
|
|
|
|
|
|
|
|
331 |
}
|
332 |
}
|
333 |
}
|
@@ -335,13 +354,13 @@ class MetaSeo_Sitemap {
|
|
335 |
}
|
336 |
}
|
337 |
}
|
338 |
-
|
339 |
-
// posts
|
340 |
$res = $this->wpms_get_posts_sitemap();
|
341 |
if (!empty($res)) {
|
342 |
foreach ($res as $val) {
|
343 |
$permalink = get_permalink($val->ID);
|
344 |
-
if(!in_array($permalink, $list_links)){
|
345 |
$list_links[] = $permalink;
|
346 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
347 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
@@ -351,29 +370,39 @@ class MetaSeo_Sitemap {
|
|
351 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
352 |
$lastmod->appendChild($xml->createTextNode($date));
|
353 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
354 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
355 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
356 |
-
}else{
|
357 |
-
|
|
|
|
|
|
|
|
|
|
|
358 |
}
|
359 |
|
360 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
361 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
362 |
$priority->appendChild($xml->createTextNode('1.0'));
|
363 |
-
}else{
|
364 |
-
|
|
|
|
|
|
|
|
|
|
|
365 |
}
|
366 |
}
|
367 |
}
|
368 |
}
|
369 |
-
|
370 |
-
// pages
|
371 |
$res = $this->wpms_get_pages_sitemap();
|
372 |
if (!empty($res)) {
|
373 |
-
$page_on_front = get_option(
|
374 |
foreach ($res as $val) {
|
375 |
$permalink = get_permalink($val->ID);
|
376 |
-
if(!in_array($permalink, $list_links)){
|
377 |
$list_links[] = $permalink;
|
378 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
379 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
@@ -384,29 +413,39 @@ class MetaSeo_Sitemap {
|
|
384 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
385 |
$lastmod->appendChild($xml->createTextNode($date));
|
386 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
387 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
388 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
389 |
-
}else{
|
390 |
-
|
|
|
|
|
|
|
|
|
|
|
391 |
}
|
392 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
393 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
394 |
$priority->appendChild($xml->createTextNode('1.0'));
|
395 |
-
}else{
|
396 |
-
|
|
|
|
|
|
|
|
|
|
|
397 |
}
|
398 |
}
|
399 |
}
|
400 |
}
|
401 |
|
402 |
-
//
|
403 |
if (!empty($taxonomies)) {
|
404 |
foreach ($taxonomies as $value) {
|
405 |
$terms = get_terms($value, 'hide_empty=1');
|
406 |
if (!empty($terms) && !is_wp_error($terms)) {
|
407 |
foreach ($terms as $term_value) {
|
408 |
$permalink = get_term_link((int) $term_value->term_id, $value);
|
409 |
-
if(!in_array($permalink, $list_links)){
|
410 |
$list_links[] = $permalink;
|
411 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
412 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
@@ -440,18 +479,20 @@ class MetaSeo_Sitemap {
|
|
440 |
}
|
441 |
$this->wpms_sitemap_info();
|
442 |
}
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
|
|
448 |
$permalink = get_category_link($id);
|
449 |
-
}else{
|
450 |
$permalink = get_permalink($id);
|
451 |
}
|
452 |
return $permalink;
|
453 |
}
|
454 |
-
|
|
|
455 |
function wpms_sitemap_info() {
|
456 |
$info_file = $this->wpms_get_path_filename_sitemap();
|
457 |
$xml_url = site_url('/') . $info_file['name'];
|
@@ -466,122 +507,122 @@ class MetaSeo_Sitemap {
|
|
466 |
}
|
467 |
}
|
468 |
|
|
|
469 |
public function wpms_display_column_posts() {
|
470 |
$html = '';
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
}
|
486 |
-
|
487 |
-
|
488 |
-
|
|
|
|
|
|
|
|
|
489 |
} else {
|
490 |
-
$
|
491 |
}
|
492 |
-
$html .= '</
|
493 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
if(!empty($v->post_id)){
|
500 |
-
$ids[] = $k;
|
501 |
}
|
502 |
}
|
|
|
|
|
503 |
}
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
foreach ($cats as $cat) {
|
508 |
-
if(in_array($cat->cat_ID, $this->settings_sitemap['wpms_category_link'])){
|
509 |
-
$cat_link = "<a href='" . esc_url(get_term_link($cat)) . "'>" . $cat->cat_name . "</a>";
|
510 |
-
}else{
|
511 |
-
$cat_link = $cat->cat_name;
|
512 |
-
}
|
513 |
-
$html .= "<li class='wpms_li_cate'><div class='cat_name'>$cat_link</div>";
|
514 |
-
if(!empty($this->settings_sitemap['wpms_sitemap_posts'])){
|
515 |
-
$html .= "<ul>";
|
516 |
-
query_posts(array('post__in' => $ids,'posts_per_page' => -1 , 'cat' => $cat->cat_ID ));
|
517 |
-
while (have_posts()) {
|
518 |
-
the_post();
|
519 |
-
if (( get_post_meta(get_the_ID(), '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta(get_the_ID(), '_yoast_wpms_redirect', true) !== '' )) {
|
520 |
-
continue;
|
521 |
-
}
|
522 |
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
}
|
532 |
-
$
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
$
|
542 |
-
'
|
543 |
-
'post_type' => $post_type,
|
544 |
-
'post__in' => $ids,
|
545 |
-
'post_status' => 'publish'
|
546 |
-
);
|
547 |
-
$query = new WP_Query($args);
|
548 |
-
$postsTest = $query->get_posts();
|
549 |
-
if (!empty($postsTest)) {
|
550 |
-
$checkSitemap = 'post_types-' . $post_type . '-not_in_sitemap';
|
551 |
-
if (( in_array($post_type, array('post', 'page', 'attachment')))) {
|
552 |
continue;
|
553 |
}
|
554 |
-
$
|
555 |
-
$postTypeLink = get_post_type_archive_link($postType->name);
|
556 |
-
$html .= '<div id="sitemap_' . str_replace(' ', '', strtolower($postType->labels->name)) . '">';
|
557 |
-
if (!empty($postTypeLink)) {
|
558 |
-
$html .= '<h3><a href="' . $postTypeLink . '">' . $postType->labels->name . '</a></h3>';
|
559 |
-
} else {
|
560 |
-
$html .= '<h3>' . $postType->labels->name . '</h3>';
|
561 |
-
}
|
562 |
-
$html .= '<ul>';
|
563 |
-
foreach ($postsTest as $post){
|
564 |
-
if (( get_post_meta(get_the_ID(), '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta(get_the_ID(), '_yoast_wpms_redirect', true) !== '' )) {
|
565 |
-
continue;
|
566 |
-
}
|
567 |
-
$html .= '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></li>';
|
568 |
-
}
|
569 |
-
$html .= '</ul></div>';
|
570 |
}
|
|
|
571 |
}
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
return $html;
|
576 |
}
|
577 |
|
|
|
578 |
public function wpms_display_column_pages() {
|
579 |
$html = '';
|
580 |
-
if(!empty($this->settings_sitemap['wpms_sitemap_pages'])){
|
581 |
-
|
|
|
582 |
$pageTitle = get_post_type_object('page');
|
583 |
$pageTitle = $pageTitle->label;
|
584 |
-
if(!empty($this->settings_sitemap['wpms_public_name_pages'])){
|
585 |
$pageTitle = $this->settings_sitemap['wpms_public_name_pages'];
|
586 |
}
|
587 |
$html .= '<div id="sitemap_pages" class="wpms_sitemap_pages"><h4>' . $pageTitle . '</h4>
|
@@ -589,7 +630,7 @@ class MetaSeo_Sitemap {
|
|
589 |
$pageInc = '';
|
590 |
$getPages = $this->wpms_get_pages_sitemap();
|
591 |
foreach ($getPages as $page) {
|
592 |
-
if ($page->ID !==
|
593 |
if (( get_post_meta($page->ID, '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta($page->ID, '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta($page->ID, '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta($page->ID, '_yoast_wpms_redirect', true) !== '' )) {
|
594 |
continue;
|
595 |
}
|
@@ -601,30 +642,31 @@ class MetaSeo_Sitemap {
|
|
601 |
}
|
602 |
}
|
603 |
|
604 |
-
if($pageInc != ''){
|
605 |
$html .= wp_list_pages(array('include' => $pageInc, 'title_li' => '', 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'echo' => false));
|
606 |
}
|
607 |
|
608 |
$html .= '</ul></div>';
|
609 |
-
$html .= '<div class="holder holder_sitemaps_pages"></div>';
|
610 |
}
|
611 |
return $html;
|
612 |
}
|
613 |
-
|
|
|
614 |
public function wpms_sitemap_shortcode() {
|
615 |
$html = '';
|
616 |
// include style
|
617 |
echo '<link rel="stylesheet" type="text/css" href="' . plugin_dir_url(dirname(__FILE__)) . 'css/html_sitemap.css" media="screen" />';
|
618 |
$html .= '<div id="wpms_sitemap" class="columns_' . $this->settings_sitemap['wpms_html_sitemap_column'] . '">';
|
619 |
-
|
620 |
-
|
621 |
-
$arrs = array("wpms_display_column_posts"
|
622 |
$checkColumn = array();
|
623 |
-
for($i = 1
|
624 |
-
$html .= '<div class="wpms_column wpms_column_'
|
625 |
-
if($i == 1){
|
626 |
// Authors
|
627 |
-
if($this->settings_sitemap['wpms_sitemap_author'] == 1){
|
628 |
$html .= '<div id="sitemap_authors"><h3>' . __('Authors') . '</h3>
|
629 |
<ul>';
|
630 |
|
@@ -633,74 +675,78 @@ class MetaSeo_Sitemap {
|
|
633 |
$html .= '</ul></div>';
|
634 |
}
|
635 |
}
|
636 |
-
|
637 |
-
foreach ($arrs as $arr){
|
638 |
-
if(empty($this->settings_sitemap[$arr]))
|
639 |
-
|
640 |
-
|
|
|
641 |
$checkColumn[] = $arr;
|
642 |
$output = $this->{$arr}();
|
643 |
$html .= $output;
|
644 |
}
|
645 |
}
|
646 |
}
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
$ids_menu = array(0);
|
651 |
$check_menu = array();
|
652 |
-
$terms = get_terms(array('taxonomy' => 'nav_menu'
|
653 |
-
foreach ($terms as $term){
|
654 |
$list_submenu_id = get_objects_in_term($term->term_id, 'nav_menu');
|
655 |
-
$ids_menu = array_merge($ids_menu
|
656 |
}
|
657 |
-
|
658 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
659 |
$this->settings_sitemap['wpms_sitemap_menus'] = $ids_menu;
|
660 |
}
|
661 |
|
662 |
-
if(!empty($this->settings_sitemap['wpms_sitemap_menus'])){
|
663 |
-
$terms = get_terms(array('taxonomy' => 'nav_menu'
|
664 |
-
if(!empty($terms)){
|
665 |
-
|
666 |
-
|
667 |
-
foreach ($terms as $term){
|
668 |
-
if(!in_array('sitemap_menus_'
|
669 |
-
if(empty($this->settings_sitemap['wpms_display_column_menus']
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
$
|
674 |
-
$
|
|
|
675 |
$html .= $viewmenu;
|
676 |
|
677 |
$html .= '</div>';
|
678 |
-
$html .= '<div class="holder holder_sitemaps_menus_'
|
679 |
}
|
680 |
}
|
681 |
}
|
682 |
}
|
683 |
}
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
$html .= '</div>';
|
688 |
}
|
689 |
|
690 |
// ==============================================================================
|
691 |
-
|
692 |
$html .= '</div>';
|
693 |
$html .= '<div class="wpms_clearRow"></div>';
|
694 |
-
|
695 |
return $html;
|
696 |
}
|
697 |
|
|
|
698 |
public function wpms_html_sitemap_content($content) {
|
699 |
global $wpdb;
|
700 |
-
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s"
|
701 |
$sitemap_page = $wpdb->get_row($sql);
|
702 |
|
703 |
-
if(empty($this->settings_sitemap['wpms_html_sitemap_page']) && !empty($sitemap_page))
|
|
|
704 |
if (!empty($this->settings_sitemap['wpms_html_sitemap_page']) && is_page($this->settings_sitemap['wpms_html_sitemap_page'])) {
|
705 |
$sitemap = '[wpms_html_sitemap]';
|
706 |
switch ($this->settings_sitemap['wpms_html_sitemap_position']) {
|
@@ -720,15 +766,16 @@ class MetaSeo_Sitemap {
|
|
720 |
return $content;
|
721 |
}
|
722 |
|
|
|
723 |
public function wpms_get_menus_all() {
|
724 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
725 |
-
$post_types = get_post_types(
|
726 |
-
unset(
|
727 |
-
unset(
|
728 |
$ids_posts_custom = array(0);
|
729 |
$ids_categories = array();
|
730 |
-
|
731 |
-
if(empty($settings_sitemap['wpms_check_firstsave'])){
|
732 |
$args = array(
|
733 |
'posts_per_page' => -1,
|
734 |
'post_type' => 'nav_menu_item',
|
@@ -736,33 +783,33 @@ class MetaSeo_Sitemap {
|
|
736 |
);
|
737 |
$query = new WP_Query($args);
|
738 |
$posts_menu = $query->get_posts();
|
739 |
-
foreach ($posts_menu as $k => $v){
|
740 |
$type = get_post_meta($v->ID, '_menu_item_type', true);
|
741 |
$type_menu = get_post_meta($v->ID, '_menu_item_object', true);
|
742 |
-
$post_meta_object_id = get_post_meta($v->ID, '_menu_item_object_id',true);
|
743 |
-
if($type != 'taxonomy'){
|
744 |
$ids_posts_custom[] = $post_meta_object_id;
|
745 |
-
}else{
|
746 |
$ids_categories[] = $post_meta_object_id;
|
747 |
}
|
748 |
}
|
749 |
-
}else{
|
750 |
-
if(!empty($settings_sitemap['wpms_sitemap_menus'])){
|
751 |
-
foreach ($settings_sitemap['wpms_sitemap_menus'] as $k => $v){
|
752 |
-
if(!empty($v
|
753 |
$type = get_post_meta($k, '_menu_item_type', true);
|
754 |
$type_menu = get_post_meta($k, '_menu_item_object', true);
|
755 |
-
$post_meta_object_id = get_post_meta($k, '_menu_item_object_id',true);
|
756 |
-
if($type != 'taxonomy'){
|
757 |
$ids_posts_custom[] = $post_meta_object_id;
|
758 |
-
}else{
|
759 |
$ids_categories[] = $post_meta_object_id;
|
760 |
}
|
761 |
}
|
762 |
}
|
763 |
}
|
764 |
}
|
765 |
-
|
766 |
$args = array(
|
767 |
'posts_per_page' => -1,
|
768 |
'post_type' => $post_types,
|
@@ -771,21 +818,22 @@ class MetaSeo_Sitemap {
|
|
771 |
);
|
772 |
$query = new WP_Query($args);
|
773 |
$menus_post_custom = $query->get_posts();
|
774 |
-
return array('posts_custom' => $menus_post_custom
|
775 |
}
|
776 |
-
|
|
|
777 |
public function wpms_get_posts_sitemap() {
|
778 |
$post_types = $this->wpms_get_post_type();
|
779 |
$ids = array(0);
|
780 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
781 |
-
if(!empty($settings_sitemap['wpms_sitemap_posts'])){
|
782 |
-
foreach ((array)$settings_sitemap['wpms_sitemap_posts'] as $k => $v){
|
783 |
-
if(!empty($v
|
784 |
$ids[] = $k;
|
785 |
}
|
786 |
}
|
787 |
}
|
788 |
-
|
789 |
$args = array(
|
790 |
'posts_per_page' => -1,
|
791 |
'post_type' => $post_types,
|
@@ -797,24 +845,28 @@ class MetaSeo_Sitemap {
|
|
797 |
return $posts;
|
798 |
}
|
799 |
|
800 |
-
|
|
|
|
|
|
|
801 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
802 |
unset($post_types['attachment']);
|
803 |
unset($post_types['page']);
|
804 |
return $post_types;
|
805 |
}
|
806 |
|
|
|
807 |
public function wpms_get_pages_sitemap() {
|
808 |
$ids = array(0);
|
809 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
810 |
-
if(!empty($settings_sitemap['wpms_sitemap_pages'])){
|
811 |
-
foreach ($settings_sitemap['wpms_sitemap_pages'] as $k => $v){
|
812 |
-
if(!empty($v
|
813 |
$ids[] = $k;
|
814 |
}
|
815 |
}
|
816 |
}
|
817 |
-
|
818 |
$args = array(
|
819 |
'posts_per_page' => -1,
|
820 |
'post_type' => 'page',
|
@@ -825,51 +877,47 @@ class MetaSeo_Sitemap {
|
|
825 |
$pages = $query->get_posts();
|
826 |
return $pages;
|
827 |
}
|
828 |
-
|
|
|
829 |
public function wpms_get_posts() {
|
830 |
-
// $taxonomies = get_taxonomies();
|
831 |
-
// if(!empty($taxonomies['nav_menu'])){
|
832 |
-
// unset($taxonomies['nav_menu']);
|
833 |
-
// }
|
834 |
$posts = array();
|
835 |
$taxo = 'category';
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
$posts[$cat->cat_name.'||'.$cat->cat_ID.'||'.$taxo.'||'.$cat->slug] = $results;
|
854 |
-
}
|
855 |
}
|
856 |
-
|
857 |
-
|
858 |
return $posts;
|
859 |
}
|
860 |
|
861 |
-
|
|
|
862 |
$html = '';
|
863 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
864 |
$list_menus = $ids_menu;
|
865 |
-
}else{
|
866 |
-
if(!empty($this->settings_sitemap['wpms_sitemap_menus'])){
|
867 |
-
foreach ($this->settings_sitemap['wpms_sitemap_menus'] as $k => $v){
|
868 |
$list_menus[] = $k;
|
869 |
}
|
870 |
}
|
871 |
}
|
872 |
-
|
873 |
$args = array(
|
874 |
'orderby' => 'menu_order',
|
875 |
'order' => 'ASC',
|
@@ -878,18 +926,18 @@ class MetaSeo_Sitemap {
|
|
878 |
'post_status' => 'any',
|
879 |
'post__in' => $list_menus,
|
880 |
'tax_query' => array(
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
),
|
887 |
);
|
888 |
-
|
889 |
$query = new WP_Query($args);
|
890 |
$submenus = $query->get_posts();
|
891 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
892 |
-
if(!empty($submenus)){
|
893 |
$html .= '<h4>' . $term->name . '</h4>';
|
894 |
$html .= '<ul class="wpms_frontend_menus_sitemap">';
|
895 |
foreach ($submenus as $menu) {
|
@@ -898,60 +946,62 @@ class MetaSeo_Sitemap {
|
|
898 |
$id_menu = get_post_meta($menu->ID, '_menu_item_object_id', true);
|
899 |
$this->level[$menu->ID] = 0;
|
900 |
$level = $this->wpms_count_parent($menu->ID);
|
901 |
-
if($type == 'taxonomy'){
|
902 |
$post_submenu = get_post($menu->ID);
|
903 |
$title = $post_submenu->post_title;
|
904 |
-
if(empty($title)) {
|
905 |
-
$term = get_term($id_menu
|
906 |
$title = $term->name;
|
907 |
}
|
908 |
-
}else{
|
909 |
$post = get_post($menu->ID);
|
910 |
$title = $post->post_title;
|
911 |
-
if(empty($title)) {
|
912 |
$post_submenu = get_post($id_menu);
|
913 |
$title = $post_submenu->post_title;
|
914 |
}
|
915 |
}
|
916 |
$type = get_post_meta($menu->ID, '_menu_item_type', true);
|
917 |
-
$check_type = get_post_meta($menu->ID, '_menu_item_object',true);
|
918 |
-
$permalink = $this->wpms_get_permalink_sitemap($type
|
919 |
$margin = $level * 10;
|
920 |
$style = '';
|
921 |
-
if($level != 0)
|
922 |
-
$style = 'style="margin-left:'
|
923 |
-
$html .= '<li class="wpms_menu_level_'
|
924 |
-
$html .= '<a href="'
|
925 |
$html .= '</li>';
|
926 |
}
|
927 |
-
|
928 |
$html .= '</ul>';
|
929 |
}
|
930 |
return $html;
|
931 |
}
|
932 |
|
|
|
933 |
public function wpms_count_parent($menuID) {
|
934 |
$parent = get_post_meta($menuID, '_menu_item_menu_item_parent', true);
|
935 |
$parent_1 = get_post_meta($parent, '_menu_item_menu_item_parent', true);
|
936 |
-
if(!empty($this->settings_sitemap['wpms_sitemap_menus']->{$parent}) && !empty($parent)){
|
937 |
$this->level[$menuID]+=1;
|
938 |
-
$this->loop_parent($parent
|
939 |
-
}else{
|
940 |
-
$this->loop_parent($parent
|
941 |
}
|
942 |
-
|
943 |
-
return (int)$this->level[$menuID];
|
944 |
}
|
945 |
-
|
946 |
-
public function loop_parent($menuID
|
947 |
$parent = get_post_meta($menuID, '_menu_item_menu_item_parent', true);
|
948 |
$parent_1 = get_post_meta($parent, '_menu_item_menu_item_parent', true);
|
949 |
-
if((!empty($this->settings_sitemap['wpms_sitemap_menus']
|
950 |
$this->level[$menuIDroot]+=1;
|
951 |
-
$this->loop_parent($parent
|
952 |
}
|
953 |
}
|
954 |
|
|
|
955 |
public function wpms_view_menus($term) {
|
956 |
$list_submenu_id = get_objects_in_term($term->term_id, 'nav_menu');
|
957 |
$args = array(
|
@@ -967,38 +1017,39 @@ class MetaSeo_Sitemap {
|
|
967 |
$query = new WP_Query($args);
|
968 |
$submenus = $query->get_posts();
|
969 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
970 |
-
|
971 |
-
$this->html .= '<h3><input type="checkbox" class="sitemap_check_all_posts_categories" data-category="nav_menu'
|
972 |
-
|
973 |
-
$this->html .= __('Display in column'
|
974 |
-
$this->html .= '<select class="wpms_display_column wpms_display_column_menus" data-menu_id="'
|
975 |
-
for($i = 1
|
976 |
-
if(
|
977 |
-
$this->html .= '<option selected value="'
|
978 |
-
}else{
|
979 |
-
$this->html .= '<option value="'
|
980 |
}
|
981 |
-
|
982 |
-
}
|
983 |
$this->html .= '</select>';
|
984 |
foreach ($submenus as $menu) {
|
985 |
-
$
|
986 |
-
$
|
987 |
-
|
|
|
|
|
988 |
$type = get_post_meta($menu->ID, '_menu_item_type', true);
|
989 |
$type_menu = get_post_meta($menu->ID, '_menu_item_object', true);
|
990 |
$id_menu = get_post_meta($menu->ID, '_menu_item_object_id', true);
|
991 |
-
if($type == 'taxonomy'){
|
992 |
$post_submenu = get_post($menu->ID);
|
993 |
$title = $post_submenu->post_title;
|
994 |
-
if(empty($title)) {
|
995 |
-
$term = get_term($id_menu
|
996 |
$title = $term->name;
|
997 |
}
|
998 |
-
}else{
|
999 |
$post = get_post($menu->ID);
|
1000 |
$title = $post->post_title;
|
1001 |
-
if(empty($title)) {
|
1002 |
$post_submenu = get_post($id_menu);
|
1003 |
$title = $post_submenu->post_title;
|
1004 |
}
|
@@ -1006,73 +1057,78 @@ class MetaSeo_Sitemap {
|
|
1006 |
$level = 1;
|
1007 |
$this->html .= '<div class="wpms_row">';
|
1008 |
$this->html .= '<div style="float:left;line-height:30px">';
|
1009 |
-
if(empty($this->settings_sitemap['wpms_check_firstsave'])){
|
1010 |
-
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1011 |
-
}else{
|
1012 |
-
if(isset($this->settings_sitemap['wpms_sitemap_menus']
|
1013 |
-
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1014 |
-
}else{
|
1015 |
-
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1016 |
}
|
1017 |
}
|
1018 |
-
|
1019 |
$this->html .= $checkbox . $title;
|
1020 |
$this->html .= '</div>';
|
1021 |
-
$this->html .= '<div style="margin-left:200px">'
|
1022 |
$this->html .= '</div>';
|
1023 |
-
$this->html .= $this->wpms_loop($menu->ID, $level + 1
|
1024 |
}
|
1025 |
-
|
1026 |
return $this->html;
|
1027 |
}
|
1028 |
-
|
1029 |
-
|
|
|
|
|
|
|
1030 |
global $wpdb;
|
1031 |
$args = array(
|
1032 |
'post_type' => 'nav_menu_item',
|
1033 |
'posts_per_page' => -1,
|
1034 |
-
'meta_key'
|
1035 |
'meta_value' => $menuID,
|
1036 |
'orderby' => 'menu_order',
|
1037 |
'order' => 'ASC'
|
1038 |
);
|
1039 |
-
$query = new WP_Query(
|
1040 |
$submenus = $query->get_posts();
|
1041 |
if (!empty($submenus)) {
|
1042 |
-
foreach ($submenus as $submenu){
|
1043 |
$type = get_post_meta($submenu->ID, '_menu_item_type', true);
|
1044 |
$type_menu = get_post_meta($submenu->ID, '_menu_item_object', true);
|
1045 |
$post_subid = get_post_meta($submenu->ID, '_menu_item_object_id', true);
|
1046 |
-
if($
|
|
|
|
|
1047 |
$post_submenu = get_post($submenu->ID);
|
1048 |
$title = $post_submenu->post_title;
|
1049 |
-
if(empty($title)) {
|
1050 |
-
$term = get_term($post_subid
|
1051 |
$title = $term->name;
|
1052 |
}
|
1053 |
-
}else{
|
1054 |
$post_submenu = get_post($submenu->ID);
|
1055 |
$title = $post_submenu->post_title;
|
1056 |
-
if(empty($title)) {
|
1057 |
$post_submenu = get_post($post_subid);
|
1058 |
$title = $post_submenu->post_title;
|
1059 |
}
|
1060 |
}
|
1061 |
-
|
1062 |
$space = '';
|
1063 |
for ($i = 1; $i <= $level * 3; $i++) {
|
1064 |
$space .= ' ';
|
1065 |
}
|
1066 |
-
$select_priority = $this->wpms_view_select_priority('priority_menu_'
|
1067 |
-
$select_frequency = $this->wpms_view_select_frequency('frequency_menu_'
|
1068 |
-
|
1069 |
-
if(empty($settings_sitemap['wpms_check_firstsave'])){
|
1070 |
-
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1071 |
-
}else{
|
1072 |
-
if(isset($settings_sitemap['wpms_sitemap_menus']
|
1073 |
-
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1074 |
-
}else{
|
1075 |
-
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu'
|
1076 |
}
|
1077 |
}
|
1078 |
|
@@ -1080,20 +1136,21 @@ class MetaSeo_Sitemap {
|
|
1080 |
$this->html .= '<div style="float:left;line-height:30px">';
|
1081 |
$this->html .= $checkbox . $title;
|
1082 |
$this->html .= '</div>';
|
1083 |
-
$this->html .= '<div style="margin-left:200px">'
|
1084 |
$this->html .= '</div>';
|
1085 |
-
$this->wpms_loop($submenu->ID, $level + 1
|
1086 |
}
|
1087 |
}
|
1088 |
}
|
1089 |
-
|
1090 |
-
|
|
|
1091 |
$info_file = $this->wpms_get_path_filename_sitemap();
|
1092 |
$wpms_url_robot = ABSPATH . "robots.txt";
|
1093 |
$wpms_url_home = site_url('/');
|
1094 |
$xml_url = site_url('/') . $info_file['name'];
|
1095 |
$this->metaseo_create_sitemap($this->wpms_sitemap_name);
|
1096 |
-
if($this->settings_sitemap['wpms_sitemap_root'] == 1){
|
1097 |
$this->metaseo_create_sitemap($this->wpms_sitemap_default_name);
|
1098 |
}
|
1099 |
|
@@ -1102,51 +1159,54 @@ class MetaSeo_Sitemap {
|
|
1102 |
@chmod($wpms_url_robot, 0755);
|
1103 |
if (is_writable($wpms_url_robot)) {
|
1104 |
$file_content = file_get_contents($wpms_url_robot);
|
1105 |
-
if (isset($this->settings_sitemap['wpms_sitemap_add']) && $this->settings_sitemap['wpms_sitemap_add'] == 1 && !preg_match('|Sitemap: ' . $wpms_url_home . $this->wpms_sitemap_name.'|', $file_content)) {
|
1106 |
file_put_contents($wpms_url_robot, $file_content . "\nSitemap: " . $wpms_url_home . $this->wpms_sitemap_name);
|
1107 |
-
} elseif (preg_match("|Sitemap: " . $wpms_url_home . $this->wpms_sitemap_name."|", $file_content) && !isset($_POST['gglstmp_checkbox'])) {
|
1108 |
-
$file_content = preg_replace("|\nSitemap: " . $wpms_url_home . $this->wpms_sitemap_name."|", '', $file_content);
|
1109 |
file_put_contents($wpms_url_robot, $file_content);
|
1110 |
}
|
1111 |
} else {
|
1112 |
$error = __('Cannot edit "robots.txt". Check your permissions', 'wp-meta-seo');
|
1113 |
-
wp_send_json(array('status' => false
|
1114 |
}
|
1115 |
}
|
1116 |
-
wp_send_json(array('status' => true
|
1117 |
}
|
1118 |
|
1119 |
-
|
1120 |
-
|
1121 |
-
$
|
1122 |
-
$select
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
|
|
1128 |
}
|
1129 |
}
|
1130 |
$select .= '</select>';
|
1131 |
return $select;
|
1132 |
}
|
1133 |
|
1134 |
-
|
1135 |
-
|
1136 |
-
$
|
1137 |
-
$select
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
|
|
1143 |
}
|
1144 |
}
|
1145 |
$select .= '</select>';
|
1146 |
return $select;
|
1147 |
}
|
1148 |
|
1149 |
-
|
|
|
1150 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
1151 |
$lists = array(
|
1152 |
"wpms_sitemap_add" => 0,
|
@@ -1161,40 +1221,42 @@ class MetaSeo_Sitemap {
|
|
1161 |
"wpms_display_column_pages" => 1,
|
1162 |
"wpms_category_link" => array()
|
1163 |
);
|
1164 |
-
|
1165 |
-
$wpms_display_column_menus = json_decode(stripslashes($_POST['wpms_display_column_menus']));
|
1166 |
-
if(!empty($wpms_display_column_menus)){
|
1167 |
$settings_sitemap['wpms_display_column_menus'] = $wpms_display_column_menus;
|
1168 |
}
|
1169 |
-
|
1170 |
-
foreach ($lists as $k => $v){
|
1171 |
-
if(isset($_POST[$k])){
|
1172 |
$settings_sitemap[$k] = $_POST[$k];
|
1173 |
-
}else{
|
1174 |
$settings_sitemap[$k] = $lists[$k];
|
1175 |
}
|
1176 |
}
|
1177 |
-
|
1178 |
$lists_selected = array(
|
1179 |
"wpms_sitemap_posts" => array(),
|
1180 |
"wpms_sitemap_pages" => array(),
|
1181 |
"wpms_sitemap_menus" => array()
|
1182 |
);
|
1183 |
-
|
1184 |
-
foreach ($lists_selected as $k => $v){
|
1185 |
-
if(isset($_POST[$k]) && $_POST[$k] != '{}'){
|
1186 |
-
$values = json_decode(stripslashes($_POST[$k]));
|
1187 |
$settings_sitemap[$k] = $values;
|
1188 |
-
}else{
|
1189 |
$settings_sitemap[$k] = array();
|
1190 |
}
|
1191 |
}
|
1192 |
-
|
1193 |
-
if(isset($_POST['wpms_public_name_posts']))
|
1194 |
-
|
1195 |
-
|
|
|
1196 |
update_option('_metaseo_settings_sitemap', $settings_sitemap);
|
1197 |
-
|
1198 |
wp_send_json(true);
|
1199 |
}
|
|
|
1200 |
}
|
5 |
public $html = '';
|
6 |
public $wpms_sitemap_name = 'wpms-sitemap.xml';
|
7 |
public $wpms_sitemap_default_name = 'sitemap.xml';
|
8 |
+
public $columns = array('Zezo', 'One', 'Two', 'Three');
|
9 |
public $level = array();
|
10 |
+
|
11 |
function __construct() {
|
12 |
$this->settings_sitemap = array(
|
13 |
"wpms_sitemap_add" => 0,
|
18 |
"wpms_html_sitemap_page" => 0,
|
19 |
"wpms_html_sitemap_column" => 1,
|
20 |
"wpms_html_sitemap_position" => "after",
|
21 |
+
"wpms_display_column_menus" => array(0),
|
22 |
"wpms_display_column_posts" => 1,
|
23 |
"wpms_display_column_pages" => 1,
|
24 |
+
"wpms_public_name_pages" => "",
|
25 |
+
"wpms_public_name_posts" => "",
|
26 |
+
"wpms_sitemap_posts" => array(),
|
27 |
+
"wpms_sitemap_pages" => array(),
|
28 |
);
|
29 |
|
30 |
if (is_multisite()) {
|
31 |
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
|
32 |
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/wpms-sitemap_' . $home_url . '.xml';
|
33 |
} else {
|
34 |
+
$this->settings_sitemap['wpms_sitemap_link'] = site_url() . '/' . $this->wpms_sitemap_name;
|
35 |
+
}
|
36 |
+
|
37 |
+
$settings = get_option('_metaseo_settings_sitemap');
|
38 |
+
if(is_object($settings['wpms_sitemap_pages']) || is_object($settings['wpms_sitemap_posts']) || is_object($settings['wpms_sitemap_menus'])){
|
39 |
+
$settings_array = json_decode(json_encode($settings),true);
|
40 |
+
update_option('$settings_array', $settings_array);
|
41 |
}
|
42 |
|
43 |
$settings = get_option('_metaseo_settings_sitemap');
|
45 |
$this->settings_sitemap = array_merge($this->settings_sitemap, $settings);
|
46 |
}
|
47 |
|
48 |
+
|
49 |
+
|
50 |
add_action('admin_init', array($this, 'metaseo_field_settings_sitemap'));
|
51 |
add_action('admin_enqueue_scripts', array($this, 'metaseo_sitemap_scripts'));
|
52 |
add_action('wp_enqueue_scripts', array($this, 'site_metaseo_sitemap_scripts'));
|
53 |
add_filter('the_content', array($this, 'wpms_html_sitemap_content'));
|
54 |
add_shortcode('wpms_html_sitemap', array($this, 'wpms_sitemap_shortcode'));
|
55 |
+
add_action('wp_ajax_wpms_regenerate_sitemaps', array($this, 'wpms_regenerate_sitemaps'));
|
56 |
+
add_action('wp_ajax_wpms_save_sitemap_settings', array($this, 'wpms_save_sitemap_settings'));
|
57 |
}
|
58 |
|
59 |
+
/* load metaseo script and style front-end */
|
60 |
+
public function site_metaseo_sitemap_scripts() {
|
61 |
global $post;
|
62 |
+
if (empty($post))
|
63 |
+
return;
|
64 |
+
if (!empty($this->settings_sitemap) && $this->settings_sitemap['wpms_html_sitemap_page'] != $post->ID)
|
65 |
+
return;
|
66 |
+
wp_enqueue_script('site-jPages-js', plugins_url('js/site-jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
67 |
wp_localize_script('site-jPages-js', 'wpms_avarible', $this->wpms_localize_script());
|
68 |
+
wp_enqueue_script('jpage-js', plugins_url('js/jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
69 |
+
wp_enqueue_style('jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
+
/* Localize a script */
|
73 |
+
public function wpms_localize_script() {
|
74 |
$arrays = array('wpms_display_column_menus' => $this->settings_sitemap['wpms_display_column_menus']);
|
75 |
return $arrays;
|
76 |
}
|
77 |
+
|
78 |
+
/* load metaseo script and style back-end */
|
79 |
+
public function metaseo_sitemap_scripts() {
|
80 |
global $current_screen;
|
81 |
+
if (!empty($current_screen) && $current_screen->base != 'wp-meta-seo_page_metaseo_google_sitemap')
|
82 |
+
return;
|
83 |
+
wp_enqueue_script('metaseositemap', plugins_url('js/metaseo_sitemap.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
84 |
+
wp_enqueue_script('jpage-js', plugins_url('js/jPages.js', dirname(__FILE__)), array('jquery'), WPMSEO_VERSION, true);
|
85 |
+
wp_enqueue_style('metaseositemapstyle', plugins_url('css/metaseo_sitemap.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
86 |
+
wp_enqueue_style('jpage-css', plugins_url('css/jPages.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
wp_enqueue_style('m-style-qtip', plugins_url('css/jquery.qtip.css', dirname(__FILE__)), array(), WPMSEO_VERSION);
|
88 |
wp_enqueue_script('jquery-qtip', plugins_url('js/jquery.qtip.min.js', dirname(__FILE__)), array('jquery'), '2.2.1', true);
|
|
|
89 |
}
|
90 |
|
91 |
+
/* Add a new field to a section of a sitemap settings page */
|
92 |
public function metaseo_field_settings_sitemap() {
|
93 |
register_setting('MetaSEO Sitemap', '_metaseo_settings_sitemap');
|
94 |
add_settings_section('metaseo_sitemap', '', array($this, 'showSettingSitemap'), 'metaseo_settings_sitemap');
|
95 |
+
add_settings_field('wpms_sitemap_link', __('XML sitemap link', 'wp-meta-seo'), array($this, 'wpms_sitemap_link'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('Link to the xml file generated. It’s highly recommended to add this sitemap link to your Google search console', 'wp-meta-seo')));
|
96 |
+
add_settings_field('wpms_html_sitemap_page', __('HTML Sitemap page', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_page'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('A page is automatically generated to display your HTML sitemap. You can also use any of the existing pages', 'wp-meta-seo')));
|
97 |
+
add_settings_field('wpms_sitemap_taxonomies', __('Additional content', 'wp-meta-seo'), array($this, 'wpms_sitemap_taxonomies'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('The additional WordPress taxonomies that you want to load in your sitemaps', 'wp-meta-seo')));
|
98 |
+
add_settings_field('wpms_sitemap_author', __('Display author posts', 'wp-meta-seo'), array($this, 'wpms_sitemap_author'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('You can include a list of posts by author in your sitemaps', 'wp-meta-seo')));
|
99 |
+
add_settings_field('wpms_html_sitemap_column', __('HTML Sitemap display', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_column'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('Number of columns of the HTML sitemap. You can also setup where your content will be displayed using the tabs above', 'wp-meta-seo')));
|
100 |
add_settings_field('wpms_html_sitemap_position', __('HTML Sitemap Position', 'wp-meta-seo'), array($this, 'wpms_html_sitemap_position'), 'metaseo_settings_sitemap', 'metaseo_sitemap');
|
101 |
+
add_settings_field('wpms_sitemap_add', __('Sitemap and robot.txt', 'wp-meta-seo'), array($this, 'wpms_sitemap_add'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('You can include a link to your xml sitemap in the robot.txt. It helps some search engines to find it', 'wp-meta-seo')));
|
102 |
+
add_settings_field('wpms_sitemap_root', __('Sitemap root', 'wp-meta-seo'), array($this, 'wpms_sitemap_root'), 'metaseo_settings_sitemap', 'metaseo_sitemap', array('label_for' => __('Add a copy of the lastest version of your .xml sitemap at the root of your WordPress install named sitemap.xml. Some SEO tools and search engines bots are searching for it.', 'wp-meta-seo')));
|
103 |
}
|
104 |
|
105 |
public function showSettingSitemap() {
|
106 |
|
107 |
}
|
108 |
+
|
109 |
+
/* Display field sitemap link */
|
110 |
public function wpms_sitemap_link() {
|
111 |
echo '<input id="wpms_check_firstsave" name="_metaseo_settings_sitemap[wpms_check_firstsave]" type="hidden" value="1">';
|
112 |
$wpms_sitemap_link = isset($this->settings_sitemap['wpms_sitemap_link']) ? $this->settings_sitemap['wpms_sitemap_link'] : '';
|
113 |
echo '<input readonly id="wpms_sitemap_link" name="_metaseo_settings_sitemap[wpms_sitemap_link]" type="text" value="' . esc_attr($wpms_sitemap_link) . '" size="50"/>';
|
114 |
echo '<a class="button" href="' . $wpms_sitemap_link . '" target="_blank">' . __('Open', 'wp-meta-seo') . '</a>';
|
115 |
}
|
116 |
+
|
117 |
+
/* Display field add sitemap robots */
|
118 |
public function wpms_sitemap_add() {
|
119 |
?>
|
120 |
<?php if (is_multisite()) { ?>
|
127 |
}
|
128 |
}
|
129 |
|
130 |
+
/* Display field sitemap root */
|
131 |
public function wpms_sitemap_root() {
|
132 |
?>
|
|
|
133 |
<label><input id="wpms_sitemap_root" type='checkbox' name='_metaseo_settings_sitemap[wpms_sitemap_root]' value="1" <?php checked(1, $this->settings_sitemap['wpms_sitemap_root']); ?> /> <?php _e("Add a sitemap.xml copy @ the site root", 'wp-meta-seo'); ?></label>
|
134 |
<?php
|
135 |
}
|
136 |
|
137 |
+
/* Display field sitemap author */
|
138 |
public function wpms_sitemap_author() {
|
139 |
?>
|
|
|
140 |
<label><input id="wpms_sitemap_author" type='checkbox' name='_metaseo_settings_sitemap[wpms_sitemap_author]' value="1" <?php checked(1, $this->settings_sitemap['wpms_sitemap_author']); ?> /> <?php _e("Display author post archive", 'wp-meta-seo'); ?></label>
|
141 |
<?php
|
142 |
}
|
143 |
+
|
144 |
+
/* Display field sitemap taxonomies */
|
145 |
public function wpms_sitemap_taxonomies() {
|
146 |
$wpms_taxonomies = array(
|
147 |
'category' => 'Post category',
|
148 |
'post_tag' => 'Post tag'
|
149 |
);
|
150 |
foreach ($wpms_taxonomies as $key => $value) {
|
151 |
+
?>
|
152 |
+
<label><input class="wpms_sitemap_taxonomies" id="wpms_sitemap_taxonomies_<?php echo $key; ?>" type="checkbox" name="_metaseo_settings_sitemap[wpms_sitemap_taxonomies][]" value="<?php echo $key; ?>" <?php if (in_array($key, $this->settings_sitemap['wpms_sitemap_taxonomies'])) echo 'checked' ?>/><span style="padding-left: 5px;"><?php echo $value; ?></span></label><br />
|
153 |
<?php
|
154 |
}
|
155 |
}
|
156 |
|
157 |
+
/* Display field sitemap list page */
|
158 |
public function wpms_html_sitemap_page() {
|
159 |
global $wpdb;
|
160 |
$pages = get_pages();
|
163 |
|
164 |
if (empty($this->settings_sitemap['wpms_html_sitemap_page']) && !empty($sitemap_page))
|
165 |
$this->settings_sitemap['wpms_html_sitemap_page'] = $sitemap_page->ID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
?>
|
167 |
+
<select id="wpms_html_sitemap_page" name="_metaseo_settings_sitemap[wpms_html_sitemap_page]">
|
168 |
+
<option value="0"><?php _e('- Choose Your Sitemap Page -', 'wp-meta-seo') ?></option>
|
169 |
+
<?php
|
170 |
+
foreach ($pages as $page) {
|
171 |
+
if ($this->settings_sitemap['wpms_html_sitemap_page'] == $page->ID) {
|
172 |
+
echo '<option selected value="' . $page->ID . '">' . $page->post_title . '</option>';
|
173 |
+
} else {
|
174 |
+
echo '<option value="' . $page->ID . '">' . $page->post_title . '</option>';
|
175 |
+
}
|
176 |
+
}
|
177 |
+
?>
|
178 |
+
</select>
|
179 |
<?php
|
180 |
if (!empty($this->settings_sitemap['wpms_html_sitemap_page'])) {
|
181 |
echo '<a class="button" href="' . get_post_permalink($this->settings_sitemap['wpms_html_sitemap_page']) . '" target="_blank">' . __('Open', 'wp-meta-seo') . '</a>';
|
182 |
}
|
183 |
}
|
184 |
|
185 |
+
/* Display field sitemap column */
|
186 |
public function wpms_html_sitemap_column() {
|
187 |
?>
|
188 |
<select id="wpms_html_sitemap_column" name="_metaseo_settings_sitemap[wpms_html_sitemap_column]">
|
192 |
</select>
|
193 |
<?php
|
194 |
}
|
195 |
+
|
196 |
+
/* Display field sitemap position */
|
197 |
public function wpms_html_sitemap_position() {
|
198 |
?>
|
199 |
<select id="wpms_html_sitemap_position" name="_metaseo_settings_sitemap[wpms_html_sitemap_position]">
|
203 |
</select>
|
204 |
<?php
|
205 |
}
|
206 |
+
|
207 |
function wpms_get_path_filename_sitemap() {
|
208 |
if (is_multisite()) {
|
209 |
$home_url = preg_replace("/[^a-zA-ZА-Яа-я0-9\s]/", "_", str_replace('http://', '', str_replace('https://', '', site_url())));
|
214 |
$xml_path = ABSPATH . $xml_file;
|
215 |
return array('path' => $xml_path, 'name' => $xml_file);
|
216 |
}
|
217 |
+
|
218 |
+
/* create sitemap */
|
219 |
function metaseo_create_sitemap($sitemap_xml_name) {
|
220 |
global $wpdb;
|
221 |
$taxonomies = array();
|
244 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
245 |
$priority = $url->appendChild($xml->createElement('priority'));
|
246 |
$priority->appendChild($xml->createTextNode(1.0));
|
247 |
+
|
248 |
+
// add menus post custom
|
249 |
$menus = $this->wpms_get_menus_all();
|
250 |
$res = $menus['posts_custom'];
|
251 |
if (!empty($res)) {
|
252 |
foreach ($res as $val) {
|
253 |
+
$sql = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key=%s AND meta_value=%d", array("_menu_item_object_id", $val->ID));
|
254 |
$menu_object = $wpdb->get_results($sql);
|
255 |
+
if (!empty($menu_object)) {
|
256 |
+
foreach ($menu_object as $menu) {
|
257 |
$menu_id = $menu->post_id;
|
258 |
$type = get_post_meta($menu_id, '_menu_item_type', true);
|
259 |
+
$check_type = get_post_meta($menu_id, '_menu_item_object', true);
|
260 |
+
$permalink = $this->wpms_get_permalink_sitemap($check_type, $val->ID);
|
261 |
+
if ($permalink != '#') {
|
262 |
+
if (!in_array($permalink, $list_links)) {
|
263 |
$list_links[] = $permalink;
|
264 |
+
if ($type != 'taxonomy') {
|
265 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
266 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
|
|
|
|
267 |
$loc->appendChild($xml->createTextNode($permalink));
|
268 |
$lastmod = $gglstmp_url->appendChild($xml->createElement('lastmod'));
|
269 |
$now = $val->post_modified;
|
270 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
271 |
$lastmod->appendChild($xml->createTextNode($date));
|
272 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
273 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
274 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
275 |
+
} else {
|
276 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['frequency'])){
|
277 |
+
$this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['frequency'] = 'monthly';
|
278 |
+
}
|
279 |
+
$changefreq->appendChild($xml->createTextNode($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['frequency']));
|
280 |
}
|
281 |
|
282 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
283 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
284 |
$priority->appendChild($xml->createTextNode('1.0'));
|
285 |
+
} else {
|
286 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['priority'])){
|
287 |
+
$this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['priority'] = '1.0';
|
288 |
+
}
|
289 |
+
$priority->appendChild($xml->createTextNode($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['priority']));
|
290 |
}
|
291 |
}
|
292 |
}
|
293 |
}
|
|
|
|
|
294 |
}
|
295 |
}
|
296 |
}
|
297 |
}
|
298 |
+
|
299 |
+
// add menus category
|
300 |
$res = $menus['categories'];
|
301 |
if (!empty($res)) {
|
302 |
foreach ($res as $k => $val) {
|
303 |
+
$sql = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key=%s AND meta_value=%d", array("_menu_item_object_id", $val));
|
304 |
$menu_object = $wpdb->get_results($sql);
|
305 |
+
if (!empty($menu_object)) {
|
306 |
+
foreach ($menu_object as $menu) {
|
307 |
$menu_id = $menu->post_id;
|
308 |
$type = get_post_meta($menu_id, '_menu_item_type', true);
|
309 |
+
$check_type = get_post_meta($menu_id, '_menu_item_object', true);
|
310 |
+
$permalink = get_term_link((int) $val, $check_type);
|
311 |
+
if (empty($permalink))
|
312 |
+
$permalink = get_permalink($menu_id);
|
313 |
+
if (!in_array($permalink, $list_links)) {
|
314 |
$list_links[] = $permalink;
|
315 |
+
if ($type == 'taxonomy') {
|
316 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
317 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
318 |
$loc->appendChild($xml->createTextNode($permalink));
|
319 |
$lastmod = $gglstmp_url->appendChild($xml->createElement('lastmod'));
|
320 |
$ps = get_post($menu_id);
|
321 |
+
|
322 |
+
if (!empty($ps)) {
|
323 |
$now = $ps->post_modified;
|
324 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
325 |
$lastmod->appendChild($xml->createTextNode($date));
|
326 |
}
|
327 |
|
328 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
329 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
330 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
331 |
+
} else {
|
332 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['frequency'])){
|
333 |
+
$menufrequency = 'monthly';
|
334 |
+
}else{
|
335 |
+
$menufrequency = $this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['frequency'];
|
336 |
+
}
|
337 |
+
$changefreq->appendChild($xml->createTextNode($menufrequency));
|
338 |
}
|
339 |
|
340 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
341 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
342 |
$priority->appendChild($xml->createTextNode('1.0'));
|
343 |
+
} else {
|
344 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['priority'])){
|
345 |
+
$menupriority = '1.0';
|
346 |
+
}else{
|
347 |
+
$menupriority = $this->settings_sitemap['wpms_sitemap_menus'][$menu_id]['priority'];
|
348 |
+
}
|
349 |
+
$priority->appendChild($xml->createTextNode($menupriority));
|
350 |
}
|
351 |
}
|
352 |
}
|
354 |
}
|
355 |
}
|
356 |
}
|
357 |
+
|
358 |
+
// add posts
|
359 |
$res = $this->wpms_get_posts_sitemap();
|
360 |
if (!empty($res)) {
|
361 |
foreach ($res as $val) {
|
362 |
$permalink = get_permalink($val->ID);
|
363 |
+
if (!in_array($permalink, $list_links)) {
|
364 |
$list_links[] = $permalink;
|
365 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
366 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
370 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
371 |
$lastmod->appendChild($xml->createTextNode($date));
|
372 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
373 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
374 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
375 |
+
} else {
|
376 |
+
if(empty($this->settings_sitemap['wpms_sitemap_posts'][$val->ID]['frequency'])){
|
377 |
+
$postfrequency = 'monthly';
|
378 |
+
}else{
|
379 |
+
$postfrequency = $this->settings_sitemap['wpms_sitemap_posts'][$val->ID]['frequency'];
|
380 |
+
}
|
381 |
+
$changefreq->appendChild($xml->createTextNode($postfrequency));
|
382 |
}
|
383 |
|
384 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
385 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
386 |
$priority->appendChild($xml->createTextNode('1.0'));
|
387 |
+
} else {
|
388 |
+
if(empty($this->settings_sitemap['wpms_sitemap_posts'][$val->ID]['priority'])){
|
389 |
+
$postpriority = '1.0';
|
390 |
+
}else{
|
391 |
+
$postpriority = $this->settings_sitemap['wpms_sitemap_posts'][$val->ID]['priority'];
|
392 |
+
}
|
393 |
+
$priority->appendChild($xml->createTextNode($postpriority));
|
394 |
}
|
395 |
}
|
396 |
}
|
397 |
}
|
398 |
+
|
399 |
+
// add pages
|
400 |
$res = $this->wpms_get_pages_sitemap();
|
401 |
if (!empty($res)) {
|
402 |
+
$page_on_front = get_option('page_on_front');
|
403 |
foreach ($res as $val) {
|
404 |
$permalink = get_permalink($val->ID);
|
405 |
+
if (!in_array($permalink, $list_links)) {
|
406 |
$list_links[] = $permalink;
|
407 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
408 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
413 |
$date = date('Y-m-d\TH:i:sP', strtotime($now));
|
414 |
$lastmod->appendChild($xml->createTextNode($date));
|
415 |
$changefreq = $gglstmp_url->appendChild($xml->createElement('changefreq'));
|
416 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
417 |
$changefreq->appendChild($xml->createTextNode('monthly'));
|
418 |
+
} else {
|
419 |
+
if(empty($this->settings_sitemap['wpms_sitemap_pages'][$val->ID]['frequency'])){
|
420 |
+
$pagefrequency = 'monthly';
|
421 |
+
}else{
|
422 |
+
$pagefrequency = $this->settings_sitemap['wpms_sitemap_pages'][$val->ID]['frequency'];
|
423 |
+
}
|
424 |
+
$changefreq->appendChild($xml->createTextNode($pagefrequency));
|
425 |
}
|
426 |
$priority = $gglstmp_url->appendChild($xml->createElement('priority'));
|
427 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
428 |
$priority->appendChild($xml->createTextNode('1.0'));
|
429 |
+
} else {
|
430 |
+
if(empty($this->settings_sitemap['wpms_sitemap_pages'][$val->ID]['priority'])){
|
431 |
+
$pagepriority = '1.0';
|
432 |
+
}else{
|
433 |
+
$pagepriority = $this->settings_sitemap['wpms_sitemap_pages'][$val->ID]['priority'];
|
434 |
+
}
|
435 |
+
$priority->appendChild($xml->createTextNode($pagepriority));
|
436 |
}
|
437 |
}
|
438 |
}
|
439 |
}
|
440 |
|
441 |
+
// add category
|
442 |
if (!empty($taxonomies)) {
|
443 |
foreach ($taxonomies as $value) {
|
444 |
$terms = get_terms($value, 'hide_empty=1');
|
445 |
if (!empty($terms) && !is_wp_error($terms)) {
|
446 |
foreach ($terms as $term_value) {
|
447 |
$permalink = get_term_link((int) $term_value->term_id, $value);
|
448 |
+
if (!in_array($permalink, $list_links)) {
|
449 |
$list_links[] = $permalink;
|
450 |
$gglstmp_url = $gglstmp_urlset->appendChild($xml->createElement('url'));
|
451 |
$loc = $gglstmp_url->appendChild($xml->createElement('loc'));
|
479 |
}
|
480 |
$this->wpms_sitemap_info();
|
481 |
}
|
482 |
+
|
483 |
+
/* Retrieves the full permalink for the current post or post ID */
|
484 |
+
public function wpms_get_permalink_sitemap($type, $id) {
|
485 |
+
if (isset($type) && $type == 'custom') {
|
486 |
+
$permalink = get_post_meta($id, '_menu_item_url', true);
|
487 |
+
} elseif ($type == 'taxonomy') {
|
488 |
$permalink = get_category_link($id);
|
489 |
+
} else {
|
490 |
$permalink = get_permalink($id);
|
491 |
}
|
492 |
return $permalink;
|
493 |
}
|
494 |
+
|
495 |
+
/* update sitemap setting */
|
496 |
function wpms_sitemap_info() {
|
497 |
$info_file = $this->wpms_get_path_filename_sitemap();
|
498 |
$xml_url = site_url('/') . $info_file['name'];
|
507 |
}
|
508 |
}
|
509 |
|
510 |
+
/* display sitemap posts by column in front-end */
|
511 |
public function wpms_display_column_posts() {
|
512 |
$html = '';
|
513 |
+
$postsTest = get_posts();
|
514 |
+
$postTitle = get_post_type_object('post');
|
515 |
+
$postTitle = $postTitle->label;
|
516 |
+
|
517 |
+
if (get_option('show_on_front') == 'page') {
|
518 |
+
$postsURL = get_permalink(get_option('page_for_posts'));
|
519 |
+
$postTitle = get_the_title(get_option('page_for_posts'));
|
520 |
+
} else {
|
521 |
+
$postsURL = get_bloginfo('url');
|
522 |
+
}
|
523 |
+
|
524 |
+
if (!empty($this->settings_sitemap['wpms_public_name_posts'])) {
|
525 |
+
$postTitle = $this->settings_sitemap['wpms_public_name_posts'];
|
526 |
+
}
|
527 |
+
$html .= '<div id="sitemap_posts" class="wpms_sitemap_posts"><h4>';
|
528 |
+
if ($postsURL !== '' && $postsURL !== get_permalink($this->settings_sitemap['wpms_html_sitemap_page'])) {
|
529 |
+
$html .= '<a href="' . $postsURL . '">' . $postTitle . '</a>';
|
530 |
+
} else {
|
531 |
+
$html .= $postTitle;
|
532 |
+
}
|
533 |
+
$html .= '</h4><ul>';
|
534 |
+
|
535 |
+
|
536 |
+
//Categories
|
537 |
+
$ids = array(0);
|
538 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_posts'])) {
|
539 |
+
foreach ((array) $this->settings_sitemap['wpms_sitemap_posts'] as $k => $v) {
|
540 |
+
if (!empty($v->post_id)) {
|
541 |
+
$ids[] = $k;
|
542 |
+
}
|
543 |
}
|
544 |
+
}
|
545 |
+
|
546 |
+
$posts = array();
|
547 |
+
$cats = get_categories();
|
548 |
+
foreach ($cats as $cat) {
|
549 |
+
if (in_array($cat->cat_ID, $this->settings_sitemap['wpms_category_link'])) {
|
550 |
+
$cat_link = "<a href='" . esc_url(get_term_link($cat)) . "'>" . $cat->cat_name . "</a>";
|
551 |
} else {
|
552 |
+
$cat_link = $cat->cat_name;
|
553 |
}
|
554 |
+
$html .= "<li class='wpms_li_cate'><div class='cat_name'>$cat_link</div>";
|
555 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_posts'])) {
|
556 |
+
$html .= "<ul>";
|
557 |
+
query_posts(array('post__in' => $ids, 'posts_per_page' => -1, 'cat' => $cat->cat_ID));
|
558 |
+
while (have_posts()) {
|
559 |
+
the_post();
|
560 |
+
if (( get_post_meta(get_the_ID(), '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta(get_the_ID(), '_yoast_wpms_redirect', true) !== '' )) {
|
561 |
+
continue;
|
562 |
+
}
|
563 |
|
564 |
+
$category = get_the_category();
|
565 |
+
// Only display a post link once, even if it's in multiple categories
|
566 |
+
if ($category[0]->cat_ID == $cat->cat_ID) {
|
567 |
+
$html .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
|
|
|
|
|
568 |
}
|
569 |
}
|
570 |
+
wp_reset_query();
|
571 |
+
$html .= "</ul>";
|
572 |
}
|
573 |
+
$html .= "</li>";
|
574 |
+
}
|
575 |
+
$html .= '</ul></div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
|
577 |
+
|
578 |
+
// ==============================================================================
|
579 |
+
// Custom Post Types
|
580 |
+
foreach (get_post_types(array('public' => true)) as $post_type) {
|
581 |
+
$args = array(
|
582 |
+
'posts_per_page' => -1,
|
583 |
+
'post_type' => $post_type,
|
584 |
+
'post__in' => $ids,
|
585 |
+
'post_status' => 'publish'
|
586 |
+
);
|
587 |
+
$query = new WP_Query($args);
|
588 |
+
$postsTest = $query->get_posts();
|
589 |
+
if (!empty($postsTest)) {
|
590 |
+
$checkSitemap = 'post_types-' . $post_type . '-not_in_sitemap';
|
591 |
+
if (( in_array($post_type, array('post', 'page', 'attachment')))) {
|
592 |
+
continue;
|
593 |
}
|
594 |
+
$postType = get_post_type_object($post_type);
|
595 |
+
$postTypeLink = get_post_type_archive_link($postType->name);
|
596 |
+
$html .= '<div id="sitemap_' . str_replace(' ', '', strtolower($postType->labels->name)) . '">';
|
597 |
+
if (!empty($postTypeLink)) {
|
598 |
+
$html .= '<h3><a href="' . $postTypeLink . '">' . $postType->labels->name . '</a></h3>';
|
599 |
+
} else {
|
600 |
+
$html .= '<h3>' . $postType->labels->name . '</h3>';
|
601 |
+
}
|
602 |
+
$html .= '<ul>';
|
603 |
+
foreach ($postsTest as $post) {
|
604 |
+
if (( get_post_meta(get_the_ID(), '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta(get_the_ID(), '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta(get_the_ID(), '_yoast_wpms_redirect', true) !== '' )) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
605 |
continue;
|
606 |
}
|
607 |
+
$html .= '<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></li>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
}
|
609 |
+
$html .= '</ul></div>';
|
610 |
}
|
611 |
+
}
|
612 |
+
$html .= '<div class="holder holder_sitemaps_posts"></div>';
|
613 |
+
|
614 |
return $html;
|
615 |
}
|
616 |
|
617 |
+
/* display sitemap pages by column in front-end */
|
618 |
public function wpms_display_column_pages() {
|
619 |
$html = '';
|
620 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_pages'])) {
|
621 |
+
|
622 |
+
$pageCheck = get_pages(array('exclude' => $this->settings_sitemap['wpms_html_sitemap_page']));
|
623 |
$pageTitle = get_post_type_object('page');
|
624 |
$pageTitle = $pageTitle->label;
|
625 |
+
if (!empty($this->settings_sitemap['wpms_public_name_pages'])) {
|
626 |
$pageTitle = $this->settings_sitemap['wpms_public_name_pages'];
|
627 |
}
|
628 |
$html .= '<div id="sitemap_pages" class="wpms_sitemap_pages"><h4>' . $pageTitle . '</h4>
|
630 |
$pageInc = '';
|
631 |
$getPages = $this->wpms_get_pages_sitemap();
|
632 |
foreach ($getPages as $page) {
|
633 |
+
if (isset($this->settings_sitemap['wpms_html_sitemap_page']) && $page->ID !== $this->settings_sitemap['wpms_html_sitemap_page']) {
|
634 |
if (( get_post_meta($page->ID, '_yoast_wpseo_meta-robots-noindex', true) === '1' && get_post_meta($page->ID, '_yoast_wpseo_sitemap-include', true) !== 'always' ) || ( get_post_meta($page->ID, '_yoast_wpseo_sitemap-include', true) === 'never' ) || ( get_post_meta($page->ID, '_yoast_wpms_redirect', true) !== '' )) {
|
635 |
continue;
|
636 |
}
|
642 |
}
|
643 |
}
|
644 |
|
645 |
+
if ($pageInc != '') {
|
646 |
$html .= wp_list_pages(array('include' => $pageInc, 'title_li' => '', 'sort_column' => 'post_title', 'sort_order' => 'ASC', 'echo' => false));
|
647 |
}
|
648 |
|
649 |
$html .= '</ul></div>';
|
650 |
+
$html .= '<div class="holder holder_sitemaps_pages"></div>';
|
651 |
}
|
652 |
return $html;
|
653 |
}
|
654 |
+
|
655 |
+
/* display html sitemap in front-end */
|
656 |
public function wpms_sitemap_shortcode() {
|
657 |
$html = '';
|
658 |
// include style
|
659 |
echo '<link rel="stylesheet" type="text/css" href="' . plugin_dir_url(dirname(__FILE__)) . 'css/html_sitemap.css" media="screen" />';
|
660 |
$html .= '<div id="wpms_sitemap" class="columns_' . $this->settings_sitemap['wpms_html_sitemap_column'] . '">';
|
661 |
+
|
662 |
+
|
663 |
+
$arrs = array("wpms_display_column_posts", "wpms_display_column_pages");
|
664 |
$checkColumn = array();
|
665 |
+
for ($i = 1; $i <= $this->settings_sitemap['wpms_html_sitemap_column']; $i++) {
|
666 |
+
$html .= '<div class="wpms_column wpms_column_' . $i . '" style="width:33%;float:left;">';
|
667 |
+
if ($i == 1) {
|
668 |
// Authors
|
669 |
+
if ($this->settings_sitemap['wpms_sitemap_author'] == 1) {
|
670 |
$html .= '<div id="sitemap_authors"><h3>' . __('Authors') . '</h3>
|
671 |
<ul>';
|
672 |
|
675 |
$html .= '</ul></div>';
|
676 |
}
|
677 |
}
|
678 |
+
|
679 |
+
foreach ($arrs as $arr) {
|
680 |
+
if (empty($this->settings_sitemap[$arr]))
|
681 |
+
$this->settings_sitemap[$arr] = 1;
|
682 |
+
if (!in_array($arr, $checkColumn)) {
|
683 |
+
if ($i == (int) $this->settings_sitemap[$arr]) {
|
684 |
$checkColumn[] = $arr;
|
685 |
$output = $this->{$arr}();
|
686 |
$html .= $output;
|
687 |
}
|
688 |
}
|
689 |
}
|
690 |
+
|
691 |
+
|
692 |
+
|
693 |
$ids_menu = array(0);
|
694 |
$check_menu = array();
|
695 |
+
$terms = get_terms(array('taxonomy' => 'nav_menu', 'hide_empty' => true));
|
696 |
+
foreach ($terms as $term) {
|
697 |
$list_submenu_id = get_objects_in_term($term->term_id, 'nav_menu');
|
698 |
+
$ids_menu = array_merge($ids_menu, $list_submenu_id);
|
699 |
}
|
700 |
+
|
701 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
702 |
$this->settings_sitemap['wpms_sitemap_menus'] = $ids_menu;
|
703 |
}
|
704 |
|
705 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_menus'])) {
|
706 |
+
$terms = get_terms(array('taxonomy' => 'nav_menu', 'hide_empty' => true));
|
707 |
+
if (!empty($terms)) {
|
708 |
+
|
709 |
+
|
710 |
+
foreach ($terms as $term) {
|
711 |
+
if (!in_array('sitemap_menus_' . $term->term_id, $check_menu)) {
|
712 |
+
if (empty($this->settings_sitemap['wpms_display_column_menus'][$term->term_id]))
|
713 |
+
$this->settings_sitemap['wpms_display_column_menus'][$term->term_id] = 1;
|
714 |
+
if ($i == (int) $this->settings_sitemap['wpms_display_column_menus'][$term->term_id]) {
|
715 |
+
|
716 |
+
$check_menu[] = 'sitemap_menus_' . $term->term_id;
|
717 |
+
$html .= '<div id="sitemap_menus_' . $term->term_id . '" class="wpms_sitemap_menus">';
|
718 |
+
$viewmenu = $this->wpms_view_menus_frontend($term, $ids_menu);
|
719 |
$html .= $viewmenu;
|
720 |
|
721 |
$html .= '</div>';
|
722 |
+
$html .= '<div class="holder holder_sitemaps_menus_' . $term->term_id . '"></div>';
|
723 |
}
|
724 |
}
|
725 |
}
|
726 |
}
|
727 |
}
|
728 |
+
|
729 |
+
|
730 |
+
|
731 |
$html .= '</div>';
|
732 |
}
|
733 |
|
734 |
// ==============================================================================
|
735 |
+
|
736 |
$html .= '</div>';
|
737 |
$html .= '<div class="wpms_clearRow"></div>';
|
738 |
+
|
739 |
return $html;
|
740 |
}
|
741 |
|
742 |
+
/* add wpms_html_sitemap shortcode in content */
|
743 |
public function wpms_html_sitemap_content($content) {
|
744 |
global $wpdb;
|
745 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s AND post_type = %s", array("WPMS HTML Sitemap", "metaseo_html_sitemap", "page"));
|
746 |
$sitemap_page = $wpdb->get_row($sql);
|
747 |
|
748 |
+
if (empty($this->settings_sitemap['wpms_html_sitemap_page']) && !empty($sitemap_page))
|
749 |
+
$this->settings_sitemap['wpms_html_sitemap_page'] = $sitemap_page->ID;
|
750 |
if (!empty($this->settings_sitemap['wpms_html_sitemap_page']) && is_page($this->settings_sitemap['wpms_html_sitemap_page'])) {
|
751 |
$sitemap = '[wpms_html_sitemap]';
|
752 |
switch ($this->settings_sitemap['wpms_html_sitemap_position']) {
|
766 |
return $content;
|
767 |
}
|
768 |
|
769 |
+
/* get all menu */
|
770 |
public function wpms_get_menus_all() {
|
771 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
772 |
+
$post_types = get_post_types('', 'names');
|
773 |
+
unset($post_types['revision']);
|
774 |
+
unset($post_types['attachment']);
|
775 |
$ids_posts_custom = array(0);
|
776 |
$ids_categories = array();
|
777 |
+
|
778 |
+
if (empty($settings_sitemap['wpms_check_firstsave'])) {
|
779 |
$args = array(
|
780 |
'posts_per_page' => -1,
|
781 |
'post_type' => 'nav_menu_item',
|
783 |
);
|
784 |
$query = new WP_Query($args);
|
785 |
$posts_menu = $query->get_posts();
|
786 |
+
foreach ($posts_menu as $k => $v) {
|
787 |
$type = get_post_meta($v->ID, '_menu_item_type', true);
|
788 |
$type_menu = get_post_meta($v->ID, '_menu_item_object', true);
|
789 |
+
$post_meta_object_id = get_post_meta($v->ID, '_menu_item_object_id', true);
|
790 |
+
if ($type != 'taxonomy') {
|
791 |
$ids_posts_custom[] = $post_meta_object_id;
|
792 |
+
} else {
|
793 |
$ids_categories[] = $post_meta_object_id;
|
794 |
}
|
795 |
}
|
796 |
+
} else {
|
797 |
+
if (!empty($settings_sitemap['wpms_sitemap_menus'])) {
|
798 |
+
foreach ($settings_sitemap['wpms_sitemap_menus'] as $k => $v) {
|
799 |
+
if (!empty($v['menu_id'])) {
|
800 |
$type = get_post_meta($k, '_menu_item_type', true);
|
801 |
$type_menu = get_post_meta($k, '_menu_item_object', true);
|
802 |
+
$post_meta_object_id = get_post_meta($k, '_menu_item_object_id', true);
|
803 |
+
if ($type != 'taxonomy') {
|
804 |
$ids_posts_custom[] = $post_meta_object_id;
|
805 |
+
} else {
|
806 |
$ids_categories[] = $post_meta_object_id;
|
807 |
}
|
808 |
}
|
809 |
}
|
810 |
}
|
811 |
}
|
812 |
+
|
813 |
$args = array(
|
814 |
'posts_per_page' => -1,
|
815 |
'post_type' => $post_types,
|
818 |
);
|
819 |
$query = new WP_Query($args);
|
820 |
$menus_post_custom = $query->get_posts();
|
821 |
+
return array('posts_custom' => $menus_post_custom, 'categories' => $ids_categories);
|
822 |
}
|
823 |
+
|
824 |
+
/* get posts selected in sitemap setting */
|
825 |
public function wpms_get_posts_sitemap() {
|
826 |
$post_types = $this->wpms_get_post_type();
|
827 |
$ids = array(0);
|
828 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
829 |
+
if (!empty($settings_sitemap['wpms_sitemap_posts'])) {
|
830 |
+
foreach ((array) $settings_sitemap['wpms_sitemap_posts'] as $k => $v) {
|
831 |
+
if (!empty($v['post_id'])) {
|
832 |
$ids[] = $k;
|
833 |
}
|
834 |
}
|
835 |
}
|
836 |
+
|
837 |
$args = array(
|
838 |
'posts_per_page' => -1,
|
839 |
'post_type' => $post_types,
|
845 |
return $posts;
|
846 |
}
|
847 |
|
848 |
+
/*
|
849 |
+
* Get a list of all registered post type objects.
|
850 |
+
*/
|
851 |
+
public function wpms_get_post_type() {
|
852 |
$post_types = get_post_types(array('public' => true, 'exclude_from_search' => false));
|
853 |
unset($post_types['attachment']);
|
854 |
unset($post_types['page']);
|
855 |
return $post_types;
|
856 |
}
|
857 |
|
858 |
+
/* get pages selected in sitemap setting */
|
859 |
public function wpms_get_pages_sitemap() {
|
860 |
$ids = array(0);
|
861 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
862 |
+
if (!empty($settings_sitemap['wpms_sitemap_pages'])) {
|
863 |
+
foreach ($settings_sitemap['wpms_sitemap_pages'] as $k => $v) {
|
864 |
+
if (!empty($v['post_id'])) {
|
865 |
$ids[] = $k;
|
866 |
}
|
867 |
}
|
868 |
}
|
869 |
+
|
870 |
$args = array(
|
871 |
'posts_per_page' => -1,
|
872 |
'post_type' => 'page',
|
877 |
$pages = $query->get_posts();
|
878 |
return $pages;
|
879 |
}
|
880 |
+
|
881 |
+
/* get posts by category */
|
882 |
public function wpms_get_posts() {
|
|
|
|
|
|
|
|
|
883 |
$posts = array();
|
884 |
$taxo = 'category';
|
885 |
+
$categorys = get_categories(array('hide_empty' => false, 'taxonomy' => $taxo));
|
886 |
+
|
887 |
+
foreach ($categorys as $cat) {
|
888 |
+
$args = array(
|
889 |
+
'posts_per_page' => -1,
|
890 |
+
'tax_query' => array(
|
891 |
+
array(
|
892 |
+
'taxonomy' => $taxo,
|
893 |
+
'field' => 'slug',
|
894 |
+
'terms' => $cat->slug,
|
895 |
+
),
|
896 |
+
),
|
897 |
+
);
|
898 |
+
$query = new WP_Query($args);
|
899 |
+
$results = $query->get_posts();
|
900 |
+
if (!empty($results)) {
|
901 |
+
$posts[$cat->cat_name . '||' . $cat->cat_ID . '||' . $taxo . '||' . $cat->slug] = $results;
|
|
|
|
|
902 |
}
|
903 |
+
}
|
904 |
+
|
905 |
return $posts;
|
906 |
}
|
907 |
|
908 |
+
/* Display sitemap menu in front-end */
|
909 |
+
public function wpms_view_menus_frontend($term, $ids_menu) {
|
910 |
$html = '';
|
911 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
912 |
$list_menus = $ids_menu;
|
913 |
+
} else {
|
914 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_menus'])) {
|
915 |
+
foreach ($this->settings_sitemap['wpms_sitemap_menus'] as $k => $v) {
|
916 |
$list_menus[] = $k;
|
917 |
}
|
918 |
}
|
919 |
}
|
920 |
+
|
921 |
$args = array(
|
922 |
'orderby' => 'menu_order',
|
923 |
'order' => 'ASC',
|
926 |
'post_status' => 'any',
|
927 |
'post__in' => $list_menus,
|
928 |
'tax_query' => array(
|
929 |
+
array(
|
930 |
+
'taxonomy' => 'nav_menu',
|
931 |
+
'field' => 'slug',
|
932 |
+
'terms' => $term->slug,
|
933 |
+
),
|
934 |
),
|
935 |
);
|
936 |
+
|
937 |
$query = new WP_Query($args);
|
938 |
$submenus = $query->get_posts();
|
939 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
940 |
+
if (!empty($submenus)) {
|
941 |
$html .= '<h4>' . $term->name . '</h4>';
|
942 |
$html .= '<ul class="wpms_frontend_menus_sitemap">';
|
943 |
foreach ($submenus as $menu) {
|
946 |
$id_menu = get_post_meta($menu->ID, '_menu_item_object_id', true);
|
947 |
$this->level[$menu->ID] = 0;
|
948 |
$level = $this->wpms_count_parent($menu->ID);
|
949 |
+
if ($type == 'taxonomy') {
|
950 |
$post_submenu = get_post($menu->ID);
|
951 |
$title = $post_submenu->post_title;
|
952 |
+
if (empty($title)) {
|
953 |
+
$term = get_term($id_menu, $type_menu);
|
954 |
$title = $term->name;
|
955 |
}
|
956 |
+
} else {
|
957 |
$post = get_post($menu->ID);
|
958 |
$title = $post->post_title;
|
959 |
+
if (empty($title)) {
|
960 |
$post_submenu = get_post($id_menu);
|
961 |
$title = $post_submenu->post_title;
|
962 |
}
|
963 |
}
|
964 |
$type = get_post_meta($menu->ID, '_menu_item_type', true);
|
965 |
+
$check_type = get_post_meta($menu->ID, '_menu_item_object', true);
|
966 |
+
$permalink = $this->wpms_get_permalink_sitemap($type, $id_menu);
|
967 |
$margin = $level * 10;
|
968 |
$style = '';
|
969 |
+
if ($level != 0)
|
970 |
+
$style = 'style="margin-left:' . $margin . 'px"';
|
971 |
+
$html .= '<li class="wpms_menu_level_' . $level . '" ' . $style . '>';
|
972 |
+
$html .= '<a href="' . $permalink . '">' . $title . '</a>';
|
973 |
$html .= '</li>';
|
974 |
}
|
975 |
+
|
976 |
$html .= '</ul>';
|
977 |
}
|
978 |
return $html;
|
979 |
}
|
980 |
|
981 |
+
/* get count parent for a menu */
|
982 |
public function wpms_count_parent($menuID) {
|
983 |
$parent = get_post_meta($menuID, '_menu_item_menu_item_parent', true);
|
984 |
$parent_1 = get_post_meta($parent, '_menu_item_menu_item_parent', true);
|
985 |
+
if (!empty($this->settings_sitemap['wpms_sitemap_menus']->{$parent}) && !empty($parent)) {
|
986 |
$this->level[$menuID]+=1;
|
987 |
+
$this->loop_parent($parent, $this->level[$menuID], $menuID);
|
988 |
+
} else {
|
989 |
+
$this->loop_parent($parent, $this->level[$menuID], $menuID);
|
990 |
}
|
991 |
+
|
992 |
+
return (int) $this->level[$menuID];
|
993 |
}
|
994 |
+
|
995 |
+
public function loop_parent($menuID, $level, $menuIDroot) {
|
996 |
$parent = get_post_meta($menuID, '_menu_item_menu_item_parent', true);
|
997 |
$parent_1 = get_post_meta($parent, '_menu_item_menu_item_parent', true);
|
998 |
+
if ((!empty($this->settings_sitemap['wpms_sitemap_menus'][$parent]) && !empty($parent)) || (!empty($parent_1) && !empty($parent))) {
|
999 |
$this->level[$menuIDroot]+=1;
|
1000 |
+
$this->loop_parent($parent, $this->level[$menuIDroot], $menuIDroot);
|
1001 |
}
|
1002 |
}
|
1003 |
|
1004 |
+
/* Display list menu in sitemap settings */
|
1005 |
public function wpms_view_menus($term) {
|
1006 |
$list_submenu_id = get_objects_in_term($term->term_id, 'nav_menu');
|
1007 |
$args = array(
|
1017 |
$query = new WP_Query($args);
|
1018 |
$submenus = $query->get_posts();
|
1019 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
1020 |
+
|
1021 |
+
$this->html .= '<h3><input type="checkbox" class="sitemap_check_all_posts_categories" data-category="nav_menu' . $term->slug . '">' . $term->name . '</h3>';
|
1022 |
+
|
1023 |
+
$this->html .= __('Display in column', 'wp-meta-seo');
|
1024 |
+
$this->html .= '<select class="wpms_display_column wpms_display_column_menus" data-menu_id="' . $term->term_id . '">';
|
1025 |
+
for ($i = 1; $i <= $this->settings_sitemap['wpms_html_sitemap_column']; $i++) {
|
1026 |
+
if (isset($this->settings_sitemap['wpms_display_column_menus'][$term->term_id]) && $this->settings_sitemap['wpms_display_column_menus'][$term->term_id] == $i) {
|
1027 |
+
$this->html .= '<option selected value="' . $i . '">' . $this->columns[$i] . '</option>';
|
1028 |
+
} else {
|
1029 |
+
$this->html .= '<option value="' . $i . '">' . $this->columns[$i] . '</option>';
|
1030 |
}
|
1031 |
+
}
|
|
|
1032 |
$this->html .= '</select>';
|
1033 |
foreach ($submenus as $menu) {
|
1034 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['frequency'])) $this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['frequency'] = 'monthly';
|
1035 |
+
if(empty($this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['priority'])) $this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['priority'] = '1.0';
|
1036 |
+
$select_priority = $this->wpms_view_select_priority('priority_menu_' . $menu->ID, '_metaseo_settings_sitemap[wpms_sitemap_menus][' . $menu->ID . '][priority]', $this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['priority']);
|
1037 |
+
$select_frequency = $this->wpms_view_select_frequency('frequency_menu_' . $menu->ID, '_metaseo_settings_sitemap[wpms_sitemap_menus][' . $menu->ID . '][frequency]', $this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['frequency']);
|
1038 |
+
|
1039 |
$type = get_post_meta($menu->ID, '_menu_item_type', true);
|
1040 |
$type_menu = get_post_meta($menu->ID, '_menu_item_object', true);
|
1041 |
$id_menu = get_post_meta($menu->ID, '_menu_item_object_id', true);
|
1042 |
+
if ($type == 'taxonomy') {
|
1043 |
$post_submenu = get_post($menu->ID);
|
1044 |
$title = $post_submenu->post_title;
|
1045 |
+
if (empty($title)) {
|
1046 |
+
$term = get_term($id_menu, $type_menu);
|
1047 |
$title = $term->name;
|
1048 |
}
|
1049 |
+
} else {
|
1050 |
$post = get_post($menu->ID);
|
1051 |
$title = $post->post_title;
|
1052 |
+
if (empty($title)) {
|
1053 |
$post_submenu = get_post($id_menu);
|
1054 |
$title = $post_submenu->post_title;
|
1055 |
}
|
1057 |
$level = 1;
|
1058 |
$this->html .= '<div class="wpms_row">';
|
1059 |
$this->html .= '<div style="float:left;line-height:30px">';
|
1060 |
+
if (empty($this->settings_sitemap['wpms_check_firstsave'])) {
|
1061 |
+
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" checked name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $menu->ID . '][menu_id]" type="checkbox" value="' . $menu->ID . '">';
|
1062 |
+
} else {
|
1063 |
+
if (isset($this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['menu_id']) && $this->settings_sitemap['wpms_sitemap_menus'][$menu->ID]['menu_id'] == $menu->ID) {
|
1064 |
+
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" checked name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $menu->ID . '][menu_id]" type="checkbox" value="' . $menu->ID . '">';
|
1065 |
+
} else {
|
1066 |
+
$checkbox = '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $menu->ID . '][menu_id]" type="checkbox" value="' . $menu->ID . '">';
|
1067 |
}
|
1068 |
}
|
1069 |
+
|
1070 |
$this->html .= $checkbox . $title;
|
1071 |
$this->html .= '</div>';
|
1072 |
+
$this->html .= '<div style="margin-left:200px">' . $select_priority . $select_frequency . '</div>';
|
1073 |
$this->html .= '</div>';
|
1074 |
+
$this->html .= $this->wpms_loop($menu->ID, $level + 1, $this->settings_sitemap, $term);
|
1075 |
}
|
1076 |
+
|
1077 |
return $this->html;
|
1078 |
}
|
1079 |
+
|
1080 |
+
/*
|
1081 |
+
* Display list menu in sitemap settings
|
1082 |
+
*/
|
1083 |
+
public function wpms_loop($menuID, $level, $settings_sitemap, $term) {
|
1084 |
global $wpdb;
|
1085 |
$args = array(
|
1086 |
'post_type' => 'nav_menu_item',
|
1087 |
'posts_per_page' => -1,
|
1088 |
+
'meta_key' => '_menu_item_menu_item_parent',
|
1089 |
'meta_value' => $menuID,
|
1090 |
'orderby' => 'menu_order',
|
1091 |
'order' => 'ASC'
|
1092 |
);
|
1093 |
+
$query = new WP_Query($args);
|
1094 |
$submenus = $query->get_posts();
|
1095 |
if (!empty($submenus)) {
|
1096 |
+
foreach ($submenus as $submenu) {
|
1097 |
$type = get_post_meta($submenu->ID, '_menu_item_type', true);
|
1098 |
$type_menu = get_post_meta($submenu->ID, '_menu_item_object', true);
|
1099 |
$post_subid = get_post_meta($submenu->ID, '_menu_item_object_id', true);
|
1100 |
+
if(empty($settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['frequency'])) $settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['frequency'] = 'monthly';
|
1101 |
+
if(empty($settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['priority'])) $settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['priority'] = '1.0';
|
1102 |
+
if ($type == 'taxonomy') {
|
1103 |
$post_submenu = get_post($submenu->ID);
|
1104 |
$title = $post_submenu->post_title;
|
1105 |
+
if (empty($title)) {
|
1106 |
+
$term = get_term($post_subid, $type_menu);
|
1107 |
$title = $term->name;
|
1108 |
}
|
1109 |
+
} else {
|
1110 |
$post_submenu = get_post($submenu->ID);
|
1111 |
$title = $post_submenu->post_title;
|
1112 |
+
if (empty($title)) {
|
1113 |
$post_submenu = get_post($post_subid);
|
1114 |
$title = $post_submenu->post_title;
|
1115 |
}
|
1116 |
}
|
1117 |
+
|
1118 |
$space = '';
|
1119 |
for ($i = 1; $i <= $level * 3; $i++) {
|
1120 |
$space .= ' ';
|
1121 |
}
|
1122 |
+
$select_priority = $this->wpms_view_select_priority('priority_menu_' . $submenu->ID, '_metaseo_settings_sitemap[wpms_sitemap_menus][' . $submenu->post_id . '][priority]', $settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['priority']);
|
1123 |
+
$select_frequency = $this->wpms_view_select_frequency('frequency_menu_' . $submenu->ID, '_metaseo_settings_sitemap[wpms_sitemap_menus][' . $submenu->post_id . '][frequency]', $settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['frequency']);
|
1124 |
+
|
1125 |
+
if (empty($settings_sitemap['wpms_check_firstsave'])) {
|
1126 |
+
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" checked name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $submenu->ID . '][menu_id]" type="checkbox" value="' . $submenu->ID . '">';
|
1127 |
+
} else {
|
1128 |
+
if (isset($settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['menu_id']) && $settings_sitemap['wpms_sitemap_menus'][$submenu->ID]['menu_id'] == $submenu->ID) {
|
1129 |
+
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" checked name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $submenu->ID . '][menu_id]" type="checkbox" value="' . $submenu->ID . '">';
|
1130 |
+
} else {
|
1131 |
+
$checkbox = $space . '<input class="cb_sitemaps_menu wpms_xmap_menu nav_menu' . $term->slug . '" name="_metaseo_settings_sitemap[wpms_sitemap_menus][' . $submenu->ID . '][menu_id]" type="checkbox" value="' . $submenu->ID . '">';
|
1132 |
}
|
1133 |
}
|
1134 |
|
1136 |
$this->html .= '<div style="float:left;line-height:30px">';
|
1137 |
$this->html .= $checkbox . $title;
|
1138 |
$this->html .= '</div>';
|
1139 |
+
$this->html .= '<div style="margin-left:200px">' . $select_priority . $select_frequency . '</div>';
|
1140 |
$this->html .= '</div>';
|
1141 |
+
$this->wpms_loop($submenu->ID, $level + 1, $settings_sitemap, $term);
|
1142 |
}
|
1143 |
}
|
1144 |
}
|
1145 |
+
|
1146 |
+
/* Ajax generate sitemap to xml file */
|
1147 |
+
public function wpms_regenerate_sitemaps() {
|
1148 |
$info_file = $this->wpms_get_path_filename_sitemap();
|
1149 |
$wpms_url_robot = ABSPATH . "robots.txt";
|
1150 |
$wpms_url_home = site_url('/');
|
1151 |
$xml_url = site_url('/') . $info_file['name'];
|
1152 |
$this->metaseo_create_sitemap($this->wpms_sitemap_name);
|
1153 |
+
if ($this->settings_sitemap['wpms_sitemap_root'] == 1) {
|
1154 |
$this->metaseo_create_sitemap($this->wpms_sitemap_default_name);
|
1155 |
}
|
1156 |
|
1159 |
@chmod($wpms_url_robot, 0755);
|
1160 |
if (is_writable($wpms_url_robot)) {
|
1161 |
$file_content = file_get_contents($wpms_url_robot);
|
1162 |
+
if (isset($this->settings_sitemap['wpms_sitemap_add']) && $this->settings_sitemap['wpms_sitemap_add'] == 1 && !preg_match('|Sitemap: ' . $wpms_url_home . $this->wpms_sitemap_name . '|', $file_content)) {
|
1163 |
file_put_contents($wpms_url_robot, $file_content . "\nSitemap: " . $wpms_url_home . $this->wpms_sitemap_name);
|
1164 |
+
} elseif (preg_match("|Sitemap: " . $wpms_url_home . $this->wpms_sitemap_name . "|", $file_content) && !isset($_POST['gglstmp_checkbox'])) {
|
1165 |
+
$file_content = preg_replace("|\nSitemap: " . $wpms_url_home . $this->wpms_sitemap_name . "|", '', $file_content);
|
1166 |
file_put_contents($wpms_url_robot, $file_content);
|
1167 |
}
|
1168 |
} else {
|
1169 |
$error = __('Cannot edit "robots.txt". Check your permissions', 'wp-meta-seo');
|
1170 |
+
wp_send_json(array('status' => false, 'message' => $error));
|
1171 |
}
|
1172 |
}
|
1173 |
+
wp_send_json(array('status' => true, 'message' => 'success'));
|
1174 |
}
|
1175 |
|
1176 |
+
/* Display priority for each item */
|
1177 |
+
public function wpms_view_select_priority($id, $name, $selected) {
|
1178 |
+
$values = array('1' => '100%', '0.9' => '90%', '0.8' => '80%', '0.7' => '70%', '0.6' => '60%', '0.5' => '50%');
|
1179 |
+
$select = '<select id="' . $id . '" name="' . $name . '">';
|
1180 |
+
$select .= '<option value="1">' . __('Priority', 'wp-meta-seo') . '</option>';
|
1181 |
+
foreach ($values as $k => $v) {
|
1182 |
+
if ($k == $selected) {
|
1183 |
+
$select .= '<option selected value="' . $k . '">' . $v . '</option>';
|
1184 |
+
} else {
|
1185 |
+
$select .= '<option value="' . $k . '">' . $v . '</option>';
|
1186 |
}
|
1187 |
}
|
1188 |
$select .= '</select>';
|
1189 |
return $select;
|
1190 |
}
|
1191 |
|
1192 |
+
/* Display frequency for each item */
|
1193 |
+
public function wpms_view_select_frequency($id, $name, $selected) {
|
1194 |
+
$values = array('always' => 'Always', 'hourly' => 'Hourly', 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthly', 'yearly' => 'Yearly', 'never' => 'Never');
|
1195 |
+
$select = '<select id="' . $id . '" name="' . $name . '">';
|
1196 |
+
$select .= '<option value="monthly">' . __('Frequency', 'wp-meta-seo') . '</option>';
|
1197 |
+
foreach ($values as $k => $v) {
|
1198 |
+
if ($k == $selected) {
|
1199 |
+
$select .= '<option selected value="' . $k . '">' . $v . '</option>';
|
1200 |
+
} else {
|
1201 |
+
$select .= '<option value="' . $k . '">' . $v . '</option>';
|
1202 |
}
|
1203 |
}
|
1204 |
$select .= '</select>';
|
1205 |
return $select;
|
1206 |
}
|
1207 |
|
1208 |
+
/* Ajax update sitemap settings */
|
1209 |
+
public function wpms_save_sitemap_settings() {
|
1210 |
$settings_sitemap = get_option('_metaseo_settings_sitemap');
|
1211 |
$lists = array(
|
1212 |
"wpms_sitemap_add" => 0,
|
1221 |
"wpms_display_column_pages" => 1,
|
1222 |
"wpms_category_link" => array()
|
1223 |
);
|
1224 |
+
|
1225 |
+
$wpms_display_column_menus = json_decode(stripslashes($_POST['wpms_display_column_menus']),true);
|
1226 |
+
if (!empty($wpms_display_column_menus)) {
|
1227 |
$settings_sitemap['wpms_display_column_menus'] = $wpms_display_column_menus;
|
1228 |
}
|
1229 |
+
|
1230 |
+
foreach ($lists as $k => $v) {
|
1231 |
+
if (isset($_POST[$k])) {
|
1232 |
$settings_sitemap[$k] = $_POST[$k];
|
1233 |
+
} else {
|
1234 |
$settings_sitemap[$k] = $lists[$k];
|
1235 |
}
|
1236 |
}
|
1237 |
+
|
1238 |
$lists_selected = array(
|
1239 |
"wpms_sitemap_posts" => array(),
|
1240 |
"wpms_sitemap_pages" => array(),
|
1241 |
"wpms_sitemap_menus" => array()
|
1242 |
);
|
1243 |
+
|
1244 |
+
foreach ($lists_selected as $k => $v) {
|
1245 |
+
if (isset($_POST[$k]) && $_POST[$k] != '{}') {
|
1246 |
+
$values = json_decode(stripslashes($_POST[$k]),true);
|
1247 |
$settings_sitemap[$k] = $values;
|
1248 |
+
} else {
|
1249 |
$settings_sitemap[$k] = array();
|
1250 |
}
|
1251 |
}
|
1252 |
+
|
1253 |
+
if (isset($_POST['wpms_public_name_posts']))
|
1254 |
+
$settings_sitemap['wpms_public_name_posts'] = $_POST['wpms_public_name_posts'];
|
1255 |
+
if (isset($_POST['wpms_public_name_pages']))
|
1256 |
+
$settings_sitemap['wpms_public_name_pages'] = $_POST['wpms_public_name_pages'];
|
1257 |
update_option('_metaseo_settings_sitemap', $settings_sitemap);
|
1258 |
+
|
1259 |
wp_send_json(true);
|
1260 |
}
|
1261 |
+
|
1262 |
}
|
inc/class.metaseo-snippet-preview.php
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
class WPMSEO_Snippet_Preview {
|
4 |
|
@@ -20,18 +28,32 @@ class WPMSEO_Snippet_Preview {
|
|
20 |
$this->set_url();
|
21 |
$this->set_content();
|
22 |
}
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
public function get_content() {
|
25 |
return $this->content;
|
26 |
}
|
27 |
|
|
|
|
|
|
|
28 |
protected function set_date() {
|
29 |
if (is_object($this->post) && isset($this->options['showdate-' . $this->post->post_type]) && $this->options['showdate-' . $this->post->post_type] === true) {
|
30 |
$date = $this->get_post_date();
|
31 |
$this->date = '<span class="date">' . $date . ' - </span>';
|
32 |
}
|
33 |
}
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
protected function get_post_date() {
|
36 |
if (isset($this->post->post_date) && $this->post->post_status == 'publish') {
|
37 |
$date = date_i18n('j M Y', strtotime($this->post->post_date));
|
@@ -41,12 +63,20 @@ class WPMSEO_Snippet_Preview {
|
|
41 |
|
42 |
return (string) $date;
|
43 |
}
|
44 |
-
|
|
|
|
|
|
|
45 |
protected function set_url() {
|
46 |
$this->url = str_replace(array('http://', 'https://'), '', get_bloginfo('url')) . '/';
|
47 |
$this->set_slug();
|
48 |
}
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
protected function set_slug() {
|
51 |
$frontpage_post_id = (int) ( get_option('page_on_front') );
|
52 |
|
@@ -55,7 +85,10 @@ class WPMSEO_Snippet_Preview {
|
|
55 |
$this->url .= esc_html($this->slug);
|
56 |
}
|
57 |
}
|
58 |
-
|
|
|
|
|
|
|
59 |
protected function set_content() {
|
60 |
$content = <<<HTML
|
61 |
<div id="wpmseosnippet">
|
@@ -66,7 +99,12 @@ class WPMSEO_Snippet_Preview {
|
|
66 |
HTML;
|
67 |
$this->set_content_through_filter($content);
|
68 |
}
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
70 |
protected function set_content_through_filter($content) {
|
71 |
$properties = get_object_vars($this);
|
72 |
$properties['desc'] = $properties['description'];
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Class WPMSEO_Snippet_Preview
|
4 |
+
*
|
5 |
+
* Generates a Google Search snippet preview.
|
6 |
+
*
|
7 |
+
* Takes a $post, $title and $description
|
8 |
+
*
|
9 |
+
*/
|
10 |
|
11 |
class WPMSEO_Snippet_Preview {
|
12 |
|
28 |
$this->set_url();
|
29 |
$this->set_content();
|
30 |
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Getter for $this->content
|
34 |
+
*
|
35 |
+
* @return string html for snippet preview
|
36 |
+
*/
|
37 |
public function get_content() {
|
38 |
return $this->content;
|
39 |
}
|
40 |
|
41 |
+
/*
|
42 |
+
* Sets date if available
|
43 |
+
*/
|
44 |
protected function set_date() {
|
45 |
if (is_object($this->post) && isset($this->options['showdate-' . $this->post->post_type]) && $this->options['showdate-' . $this->post->post_type] === true) {
|
46 |
$date = $this->get_post_date();
|
47 |
$this->date = '<span class="date">' . $date . ' - </span>';
|
48 |
}
|
49 |
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Retrieves a post date when post is published, or return current date when it's not.
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*
|
56 |
+
*/
|
57 |
protected function get_post_date() {
|
58 |
if (isset($this->post->post_date) && $this->post->post_status == 'publish') {
|
59 |
$date = date_i18n('j M Y', strtotime($this->post->post_date));
|
63 |
|
64 |
return (string) $date;
|
65 |
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Generates the url that is displayed in the snippet preview.
|
69 |
+
*/
|
70 |
protected function set_url() {
|
71 |
$this->url = str_replace(array('http://', 'https://'), '', get_bloginfo('url')) . '/';
|
72 |
$this->set_slug();
|
73 |
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Sets the slug and adds it to the url if the post has been published and the post name exists.
|
77 |
+
*
|
78 |
+
* If the post is set to be the homepage the slug is also not included.
|
79 |
+
*/
|
80 |
protected function set_slug() {
|
81 |
$frontpage_post_id = (int) ( get_option('page_on_front') );
|
82 |
|
85 |
$this->url .= esc_html($this->slug);
|
86 |
}
|
87 |
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Generates the html for the snippet preview and assign it to $this->content.
|
91 |
+
*/
|
92 |
protected function set_content() {
|
93 |
$content = <<<HTML
|
94 |
<div id="wpmseosnippet">
|
99 |
HTML;
|
100 |
$this->set_content_through_filter($content);
|
101 |
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Sets the html for the snippet preview through a filter
|
105 |
+
*
|
106 |
+
* @param string $content Content string.
|
107 |
+
*/
|
108 |
protected function set_content_through_filter($content) {
|
109 |
$properties = get_object_vars($this);
|
110 |
$properties['desc'] = $properties['description'];
|
inc/class.wp-metaseo.php
CHANGED
@@ -1,33 +1,29 @@
|
|
1 |
<?php
|
|
|
2 |
//Main plugin functions here
|
3 |
class WpMetaSeo {
|
4 |
-
|
5 |
private static $initiated = false;
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
public static function init() {
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
}
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
-
* Initializes WordPress hooks
|
20 |
-
*/
|
21 |
-
private static function init_hooks() {
|
22 |
-
self::$initiated = true;
|
23 |
-
}
|
24 |
-
|
25 |
-
public static function new_title($title){
|
26 |
-
global $wp_query;
|
27 |
-
return $title;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
* Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
|
32 |
* @static
|
33 |
*/
|
@@ -36,31 +32,23 @@ class WpMetaSeo {
|
|
36 |
deactivate_plugins(basename(__FILE__));
|
37 |
wp_die('<p>The <strong>WP Meta SEO</strong> plugin requires WordPress ' . WPMETASEO_MINIMUM_WP_VERSION . ' or higher.</p>', 'Plugin Activation Error', array('response' => 200, 'back_link' => TRUE));
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
global $wpdb;
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
self::install_db();
|
48 |
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Removes all connection options
|
52 |
-
* @static
|
53 |
-
*/
|
54 |
-
public static function plugin_deactivation() {
|
55 |
-
//tidy up
|
56 |
-
}
|
57 |
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
`id` int(11) NOT NULL AUTO_INCREMENT,
|
65 |
`post_id` int(11) NOT NULL,
|
66 |
`posts_optimized_id` text COLLATE utf8_unicode_ci NOT NULL,
|
@@ -74,8 +62,9 @@ class WpMetaSeo {
|
|
74 |
PRIMARY KEY (`id`)
|
75 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
1 |
<?php
|
2 |
+
|
3 |
//Main plugin functions here
|
4 |
class WpMetaSeo {
|
5 |
+
|
6 |
private static $initiated = false;
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
add_action('admin_notices', array($this, 'plugin_activation_notices'));
|
10 |
+
}
|
11 |
+
|
12 |
public static function init() {
|
13 |
+
ob_start();
|
14 |
+
if (!self::$initiated) {
|
15 |
+
self::init_hooks();
|
16 |
+
}
|
17 |
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Initializes WordPress hooks
|
21 |
+
*/
|
22 |
+
private static function init_hooks() {
|
23 |
+
self::$initiated = true;
|
24 |
+
}
|
25 |
+
|
26 |
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
* Attached to activate_{ plugin_basename( __FILES__ ) } by register_activation_hook()
|
28 |
* @static
|
29 |
*/
|
32 |
deactivate_plugins(basename(__FILE__));
|
33 |
wp_die('<p>The <strong>WP Meta SEO</strong> plugin requires WordPress ' . WPMETASEO_MINIMUM_WP_VERSION . ' or higher.</p>', 'Plugin Activation Error', array('response' => 200, 'back_link' => TRUE));
|
34 |
}
|
35 |
+
|
36 |
+
|
37 |
global $wpdb;
|
38 |
+
//Set two param as flags that determine whether show import meta data from other SEO plugin button or not to 0
|
39 |
+
update_option('_aio_import_notice_flag', 0);
|
40 |
+
update_option('_yoast_import_notice_flag', 0);
|
41 |
+
update_option('plugin_to_sync_with', 0);
|
42 |
+
|
43 |
self::install_db();
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
/* create metaseo_images table */
|
47 |
+
public static function install_db() {
|
48 |
+
global $wpdb;
|
49 |
+
$table_name = $wpdb->prefix . 'metaseo_images';
|
50 |
+
|
51 |
+
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
52 |
`id` int(11) NOT NULL AUTO_INCREMENT,
|
53 |
`post_id` int(11) NOT NULL,
|
54 |
`posts_optimized_id` text COLLATE utf8_unicode_ci NOT NULL,
|
62 |
PRIMARY KEY (`id`)
|
63 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";
|
64 |
|
65 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
66 |
+
|
67 |
+
dbDelta($sql);
|
68 |
+
}
|
69 |
+
|
70 |
+
}
|
inc/pages/content-meta.php
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Meta tags content
|
4 |
-
*/
|
5 |
-
|
6 |
if (!class_exists('MetaSeo_Content_List_Table')) {
|
7 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-content-list-table.php' );
|
8 |
}
|
@@ -15,92 +11,89 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
|
|
15 |
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
|
16 |
exit;
|
17 |
}
|
18 |
-
|
19 |
?>
|
20 |
|
21 |
<div class="wrap seo_extended_table_page">
|
22 |
<div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
|
23 |
-
|
24 |
<?php echo '<h1>' . __('Content Meta', 'wp-meta-seo') . '</h1>'; ?>
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
$metaseo_list_table->
|
29 |
-
|
30 |
-
?>
|
31 |
</form>
|
32 |
|
33 |
</div>
|
34 |
<script type="text/javascript">
|
35 |
-
jQuery(document).ready(function($){
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
$('.metaseo_post_index').on('click',function(){
|
47 |
-
var page_id = $(this).val();
|
48 |
-
if($(this).is(':checked')){
|
49 |
-
var index = 'index';
|
50 |
-
}else{
|
51 |
-
var index = 'noindex';
|
52 |
-
}
|
53 |
-
metaseo_update_pageindex(page_id,index);
|
54 |
-
});
|
55 |
-
|
56 |
-
$('.metaseo-metatitle').each(function() {
|
57 |
-
metaseo_titlelength(this.id, false , false);
|
58 |
-
metaseo_updateTitle(this.id, false, false);
|
59 |
-
});
|
60 |
-
|
61 |
-
$('.metaseo-metakeywords').each(function() {
|
62 |
-
metaseo_keywordlength(this.id, false , false);
|
63 |
-
metaseo_updatekeywords(this.id, false, false);
|
64 |
-
});
|
65 |
-
|
66 |
-
$('.metaseo-metadesc').each(function() {
|
67 |
-
metaseo_desclength(this.id, false , false);
|
68 |
-
metaseo_updateDesc(this.id,false);
|
69 |
-
});
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
metaseo_keywordlength(this.id, true);
|
81 |
-
});
|
82 |
-
|
83 |
-
$('.metaseo-metakeywords').blur(function() {
|
84 |
-
metaseo_updatekeywords(this.id, true);
|
85 |
-
});
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
});
|
105 |
-
});
|
106 |
</script>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
if (!class_exists('MetaSeo_Content_List_Table')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-content-list-table.php' );
|
4 |
}
|
11 |
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
|
12 |
exit;
|
13 |
}
|
|
|
14 |
?>
|
15 |
|
16 |
<div class="wrap seo_extended_table_page">
|
17 |
<div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
|
|
|
18 |
<?php echo '<h1>' . __('Content Meta', 'wp-meta-seo') . '</h1>'; ?>
|
19 |
+
<form id="wp-seo-meta-form" action="" method="post">
|
20 |
+
<?php
|
21 |
+
$metaseo_list_table->search_box(__('Search Posts', 'wp-meta-seo'), 'wpms_content');
|
22 |
+
$metaseo_list_table->display();
|
23 |
+
?>
|
|
|
24 |
</form>
|
25 |
|
26 |
</div>
|
27 |
<script type="text/javascript">
|
28 |
+
jQuery(document).ready(function ($) {
|
29 |
+
$('.metaseo_post_follow').on('click', function () {
|
30 |
+
var page_id = $(this).val();
|
31 |
+
if ($(this).is(':checked')) {
|
32 |
+
var follow = 'follow';
|
33 |
+
} else {
|
34 |
+
var follow = 'nofollow';
|
35 |
+
}
|
36 |
+
metaseo_update_pagefollow(page_id, follow);
|
37 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
+
$('.metaseo_post_index').on('click', function () {
|
40 |
+
var page_id = $(this).val();
|
41 |
+
if ($(this).is(':checked')) {
|
42 |
+
var index = 'index';
|
43 |
+
} else {
|
44 |
+
var index = 'noindex';
|
45 |
+
}
|
46 |
+
metaseo_update_pageindex(page_id, index);
|
47 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
$('.metaseo-metatitle').each(function () {
|
50 |
+
metaseo_titlelength(this.id, false, false);
|
51 |
+
metaseo_updateTitle(this.id, false, false);
|
52 |
+
});
|
53 |
+
|
54 |
+
$('.metaseo-metakeywords').each(function () {
|
55 |
+
metaseo_keywordlength(this.id, false, false);
|
56 |
+
metaseo_updatekeywords(this.id, false, false);
|
57 |
+
});
|
58 |
+
|
59 |
+
$('.metaseo-metadesc').each(function () {
|
60 |
+
metaseo_desclength(this.id, false, false);
|
61 |
+
metaseo_updateDesc(this.id, false);
|
62 |
+
});
|
63 |
+
|
64 |
+
$('.metaseo-metatitle').bind('input propertychange', function () {
|
65 |
+
metaseo_titlelength(this.id, true);
|
66 |
+
});
|
67 |
+
|
68 |
+
$('.metaseo-metatitle').blur(function () {
|
69 |
+
metaseo_updateTitle(this.id, true);
|
70 |
+
});
|
71 |
+
|
72 |
+
$('.metaseo-metakeywords').bind('input propertychange', function () {
|
73 |
+
metaseo_keywordlength(this.id, true);
|
74 |
+
});
|
75 |
+
|
76 |
+
$('.metaseo-metakeywords').blur(function () {
|
77 |
+
metaseo_updatekeywords(this.id, true);
|
78 |
+
});
|
79 |
+
|
80 |
+
$('.metaseo-metadesc').bind('input propertychange', function () {
|
81 |
+
metaseo_keywordlength(this.id, true);
|
82 |
+
});
|
83 |
+
|
84 |
+
$('.metaseo-metadesc').blur(function () {
|
85 |
+
metaseo_updateDesc(this.id, true);
|
86 |
+
});
|
87 |
+
|
88 |
+
$('.metaseo-metadesc, .metaseo-metatitle').bind('input propertychange', function () {
|
89 |
+
var idNumber = this.id.substr(this.id.lastIndexOf('-') + 1);
|
90 |
+
if (this.id == 'metaseo-metatitle-' + idNumber) {
|
91 |
+
if (!$(this).val()) {
|
92 |
+
var post_title = $('#post-title-' + idNumber).text();
|
93 |
+
$('#snippet_title' + idNumber).text(post_title);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
});
|
98 |
});
|
|
|
99 |
</script>
|
inc/pages/dashboard.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<?php
|
2 |
if (!class_exists('MetaSeo_Dashboard')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-dashboard.php' );
|
4 |
}
|
@@ -7,44 +7,42 @@ wp_enqueue_style('m-style-qtip');
|
|
7 |
wp_enqueue_script('jquery-qtip');
|
8 |
|
9 |
$site_name = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', get_site_url());
|
10 |
-
//$site_name = 'testdev-united.com';
|
11 |
$url = 'http://www.alexa.com/siteinfo/' . $site_name;
|
12 |
$dashboard = new MetaSeo_Dashboard();
|
13 |
$results = $dashboard->evolutive_dashboard();
|
14 |
$link_errors = $dashboard->get_404_link();
|
15 |
$results_image = $dashboard->moptimizationChecking();
|
16 |
-
if(!empty($results_image['imgs_statis'][1])){
|
17 |
-
$percent_iresizing = ceil($results_image['imgs_statis'][0]
|
18 |
-
}else{
|
19 |
$percent_iresizing = 100;
|
20 |
}
|
21 |
|
22 |
-
if(!empty($results_image['imgs_metas_statis'][1])){
|
23 |
-
$percent_imeta = ceil($results_image['imgs_metas_statis'][0]
|
24 |
-
}else{
|
25 |
$percent_imeta = 100;
|
26 |
}
|
27 |
|
28 |
$plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.php';
|
29 |
-
|
30 |
?>
|
31 |
<h1 style="text-align: center;"><?php _e('WP Meta SEO dashboard', 'wp-meta-seo') ?></h1>
|
32 |
<div class="dashboard">
|
33 |
<div class="col-md-9">
|
34 |
<div class="row panel-statistics">
|
35 |
-
<div class="col-sm-6 metaseo_tool" alt="<?php _e('It’s better using a permalink structure that is adding in your URL the category name and content title. This parameter can be changed in Settings > Permalinks WordPress menu. Tag recommended is %category%/%postname%','wp-meta-seo') ?>">
|
36 |
<div class="panel panel-updates">
|
37 |
<div class="panel-body">
|
38 |
<div class="row">
|
39 |
<div class="col-xs-7 col-lg-8">
|
40 |
-
<h4 class="panel-title text-success"><?php _e('Permalinks settings','wp-meta-seo') ?></h4>
|
41 |
-
<h3><?php echo $results['permalink_setting'].'%' ?></h3>
|
42 |
<div class="progress">
|
43 |
-
<div style="width: <?php echo $results['permalink_setting'].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['permalink_setting'] ?>" role="progressbar" class="progress-bar progress-bar-success">
|
44 |
-
<span class="sr-only"><?php echo $results['permalink_setting'].'%' ?> Complete (success)</span>
|
45 |
</div>
|
46 |
</div>
|
47 |
-
<p><?php _e('Optimized at','wp-meta-seo') ?>: <?php echo $results['permalink_setting'].'%' ?></p>
|
48 |
</div>
|
49 |
<div class="col-xs-5 col-lg-4 text-right">
|
50 |
<input type="text" value="<?php echo $results['permalink_setting'] ?>" class="dial-success">
|
@@ -54,19 +52,19 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
54 |
</div>
|
55 |
</div>
|
56 |
|
57 |
-
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('Meta titles are displayed in search engine results as a page title. It’s a good thing for SEO to have some custom and attractive ones. Be sure to fill at least the met information on your most popular pages','wp-meta-seo') ?>">
|
58 |
<div class="panel panel-danger-full panel-updates">
|
59 |
<div class="panel-body">
|
60 |
<div class="row">
|
61 |
<div class="col-xs-7 col-lg-8">
|
62 |
-
<h4 class="panel-title text-warning"><?php _e('Meta Title','wp-meta-seo') ?></h4>
|
63 |
-
<h3><?php echo $results['metatitle_filled'][0].'%' ?></h3>
|
64 |
<div class="progress">
|
65 |
-
<div style="width: <?php echo $results['metatitle_filled'][0].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['metatitle_filled'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
66 |
-
<span class="sr-only"><?php echo $results['metatitle_filled'][0].'%' ?> Complete (success)</span>
|
67 |
</div>
|
68 |
</div>
|
69 |
-
<p><?php _e('Meta title filled','wp-meta-seo') ?>: <?php echo $results['metatitle_filled'][1][0].'/'
|
70 |
</div>
|
71 |
<div class="col-xs-5 col-lg-4 text-right">
|
72 |
<input type="text" value="<?php echo $results['metatitle_filled'][0] ?>" class="dial-warning">
|
@@ -76,19 +74,19 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
76 |
</div>
|
77 |
</div>
|
78 |
|
79 |
-
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('Meta descriptions are displayed in search engine results as a page description. It’s a good thing for SEO to have some custom and attractive ones. Be sure to fill at least the meta information on your most popular pages.','wp-meta-seo') ?>">
|
80 |
<div class="panel panel-success-full panel-updates">
|
81 |
<div class="panel-body">
|
82 |
<div class="row">
|
83 |
<div class="col-xs-7 col-lg-8">
|
84 |
-
<h4 class="panel-title text-success"><?php _e('Meta Description','wp-meta-seo') ?></h4>
|
85 |
-
<h3><?php echo $results['metadesc_filled'][0].'%' ?></h3>
|
86 |
<div class="progress">
|
87 |
-
<div style="width: <?php echo $results['metadesc_filled'][0].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['metadesc_filled'][0] ?>" role="progressbar" class="progress-bar progress-bar-info">
|
88 |
-
<span class="sr-only"><?php echo $results['metadesc_filled'][0].'%' ?> Complete (success)</span>
|
89 |
</div>
|
90 |
</div>
|
91 |
-
<p><?php _e('Meta description filled','wp-meta-seo') ?>: <?php echo $results['metadesc_filled'][1][0].'/'
|
92 |
</div>
|
93 |
<div class="col-xs-5 col-lg-4 text-right">
|
94 |
<input type="text" value="<?php echo $results['metadesc_filled'][0] ?>" class="dial-info">
|
@@ -98,19 +96,19 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
98 |
</div>
|
99 |
</div>
|
100 |
|
101 |
-
<div class="col-sm-6 metaseo_tool" alt="<?php _e('Display image at its natural size, do not use HTML resize. It happens usually when you use handles to resize an image. You have a bulk edition tool to fix that.','wp-meta-seo') ?>">
|
102 |
<div class="panel panel-updates">
|
103 |
<div class="panel-body">
|
104 |
<div class="row">
|
105 |
<div class="col-xs-7 col-lg-8">
|
106 |
-
<h4 class="panel-title text-danger"><?php _e('HTML image resizing','wp-meta-seo') ?></h4>
|
107 |
-
<h3><?php echo $percent_iresizing.'%' ?></h3>
|
108 |
<div class="progress">
|
109 |
-
<div style="width: <?php echo $percent_iresizing.'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $percent_iresizing ?>" role="progressbar" class="progress-bar progress-bar-danger">
|
110 |
-
<span class="sr-only"><?php echo $percent_iresizing.'%' ?> Complete (success)</span>
|
111 |
</div>
|
112 |
</div>
|
113 |
-
<p><?php _e('Wrong resized images','wp-meta-seo') ?>: <?php echo $results_image['imgs_statis'][0].'/'
|
114 |
</div>
|
115 |
<div class="col-xs-5 col-lg-4 text-right">
|
116 |
<input type="text" value="<?php echo $percent_iresizing ?>" class="dial-danger">
|
@@ -119,20 +117,20 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
119 |
</div>
|
120 |
</div>
|
121 |
</div>
|
122 |
-
|
123 |
-
<div class="col-sm-6 metaseo_tool" alt="<?php _e('We recommend to use both alt text and image title. The main advantage is that it helps search engines discover your images and display them in image search results. Plus, these tags improve the accessibility of your site and give more information about your images. Use our bulk image tool to quickly check and fix that.','wp-meta-seo') ?>">
|
124 |
<div class="panel panel-updates">
|
125 |
<div class="panel-body">
|
126 |
<div class="row">
|
127 |
<div class="col-xs-7 col-lg-8">
|
128 |
-
<h4 class="panel-title text-success"><?php _e('Image title/alt','wp-meta-seo') ?></h4>
|
129 |
-
<h3><?php echo $percent_imeta.'%' ?></h3>
|
130 |
<div class="progress">
|
131 |
-
<div style="width: <?php echo $percent_imeta.'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $percent_imeta ?>" role="progressbar" class="progress-bar progress-bar-success">
|
132 |
-
<span class="sr-only"><?php echo $percent_imeta.'%' ?> Complete (success)</span>
|
133 |
</div>
|
134 |
</div>
|
135 |
-
<p><?php _e('Image data filled (in content)','wp-meta-seo') ?>: <?php echo $results_image['imgs_metas_statis'][0].'/'
|
136 |
</div>
|
137 |
<div class="col-xs-5 col-lg-4 text-right">
|
138 |
<input type="text" value="<?php echo $percent_imeta ?>" class="dial-success">
|
@@ -141,20 +139,20 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
141 |
</div>
|
142 |
</div>
|
143 |
</div>
|
144 |
-
|
145 |
-
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('It is highly recommended to update or add new content on your website quite frequently. At least 3 updated or new content per month would be great :)','wp-meta-seo') ?>">
|
146 |
<div class="panel panel-danger-full panel-updates">
|
147 |
<div class="panel-body">
|
148 |
<div class="row">
|
149 |
<div class="col-xs-7 col-lg-8">
|
150 |
-
<h4 class="panel-title text-warning"><?php _e('New or updated content','wp-meta-seo') ?></h4>
|
151 |
-
<h3><?php echo $results['new_content'][0].'%' ?></h3>
|
152 |
<div class="progress">
|
153 |
-
<div style="width: <?php echo $results['new_content'][0].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['new_content'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
154 |
-
<span class="sr-only"><?php echo $results['new_content'][0].'%' ?> Complete (success)</span>
|
155 |
</div>
|
156 |
</div>
|
157 |
-
<p><?php _e('Latest month new or updated content','wp-meta-seo') ?>: <?php echo $results['new_content'][1][0]
|
158 |
</div>
|
159 |
<div class="col-xs-5 col-lg-4 text-right">
|
160 |
<input type="text" value="<?php echo $results['new_content'][0] ?>" class="dial-warning">
|
@@ -163,20 +161,20 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
163 |
</div>
|
164 |
</div>
|
165 |
</div>
|
166 |
-
|
167 |
-
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('The link title attribute does not have any SEO value for links. BUT links titles can influence click behavior for users, which may indirectly affect your SEO performance','wp-meta-seo') ?>">
|
168 |
<div class="panel panel-danger-full panel-updates">
|
169 |
<div class="panel-body">
|
170 |
<div class="row">
|
171 |
<div class="col-xs-7 col-lg-8">
|
172 |
-
<h4 class="panel-title text-warning"><?php _e('Link titles','wp-meta-seo') ?></h4>
|
173 |
-
<h3><?php echo $results['link_meta'][0].'%' ?></h3>
|
174 |
<div class="progress">
|
175 |
-
<div style="width: <?php echo $results['link_meta'][0].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['link_meta'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
176 |
-
<span class="sr-only"><?php echo $results['link_meta'][0].'%' ?> Complete (success)</span>
|
177 |
</div>
|
178 |
</div>
|
179 |
-
<p><?php _e('Links title completed','wp-meta-seo') ?>: <?php echo $results['link_meta'][1][0].'/'
|
180 |
</div>
|
181 |
<div class="col-xs-5 col-lg-4 text-right">
|
182 |
<input type="text" value="<?php echo $results['link_meta'][0] ?>" class="dial-warning">
|
@@ -185,20 +183,20 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
185 |
</div>
|
186 |
</div>
|
187 |
</div>
|
188 |
-
|
189 |
-
<div class="col-sm-6 metaseo_tool" alt="<?php _e('A website with a bunch of 404 errors doesn’t provide a good user experience, which is significantly important in content marketing and SEO. We recommend to use our internal broken link checker and redirect tool to fix all the 404 error you can periodically.','wp-meta-seo') ?>">
|
190 |
<div class="panel panel-updates">
|
191 |
<div class="panel-body">
|
192 |
<div class="row">
|
193 |
<div class="col-xs-7 col-lg-8">
|
194 |
-
<h4 class="panel-title text-success"><?php _e('404 ERRORS','wp-meta-seo') ?></h4>
|
195 |
-
<h3><?php echo $link_errors['percent'].'%' ?></h3>
|
196 |
<div class="progress">
|
197 |
-
<div style="width: <?php echo $link_errors['percent'].'%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $link_errors['percent'] ?>" role="progressbar" class="progress-bar progress-bar-success">
|
198 |
-
<span class="sr-only"><?php echo $link_errors['percent'].'%' ?> Complete (success)</span>
|
199 |
</div>
|
200 |
</div>
|
201 |
-
<p><?php _e('Redirected 404 errors','wp-meta-seo') ?>: <?php echo $link_errors['count_404_redirected'].'/'
|
202 |
</div>
|
203 |
<div class="col-xs-5 col-lg-4 text-right">
|
204 |
<input type="text" value="<?php echo $link_errors['percent'] ?>" class="dial-success">
|
@@ -207,63 +205,63 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
207 |
</div>
|
208 |
</div>
|
209 |
</div>
|
210 |
-
|
211 |
<?php if (file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression')) : ?>
|
212 |
-
|
213 |
if (!is_plugin_active($plugin_imgRecycle_file)) :
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
</div>
|
227 |
</div>
|
228 |
-
<p><?php _e('Use ImageRecycle image compression plugin to activate this feature','wp-meta-seo') ?>: 0%</p>
|
229 |
-
</div>
|
230 |
-
<div class="col-xs-5 col-lg-4 text-right">
|
231 |
-
<input type="text" value="0" class="dial-success">
|
232 |
</div>
|
233 |
</div>
|
234 |
</div>
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
250 |
</div>
|
251 |
</div>
|
252 |
-
<p><?php _e('Compressed images','wp-meta-seo') ?>: <?php echo $optimizer_results['image_optimize'].'/'.$optimizer_results['count_image'] ?></p>
|
253 |
-
</div>
|
254 |
-
<div class="col-xs-5 col-lg-4 text-right">
|
255 |
-
<input type="text" value="<?php echo $optimizer_results['percent'] ?>" class="dial-success">
|
256 |
</div>
|
257 |
</div>
|
258 |
</div>
|
259 |
-
|
260 |
-
</div>
|
261 |
-
<?php endif; ?>
|
262 |
<?php endif; ?>
|
263 |
-
|
264 |
</div>
|
265 |
</div>
|
266 |
-
|
267 |
<div style="width:75%;margin: 0px auto;min-height: 200px;padding: 0px 10px 0px 10px;">
|
268 |
<div class="left">
|
269 |
<div class="dashboard-left" id='dashboard-left'>
|
@@ -275,13 +273,13 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
275 |
|
276 |
<div class="right">
|
277 |
<div class="dashboard-right">
|
278 |
-
<div style="display: none"><?php _e("We can't get rank of this site from Alexa.com!","wp-meta-seo") ?></div>
|
279 |
<div style="clear:left"></div>
|
280 |
<div id="wpmetaseo-update-version">
|
281 |
<h4><?php echo __('Latest WP Meta SEO News', 'wp-meta-seo') ?></h4>
|
282 |
<ul>
|
283 |
-
<li><a target="_blank" href="https://www.joomunited.com/wordpress-products/wp-meta-seo"><?php _e('More information about WP Meta SEO','wp-meta-seo'); ?></a></li>
|
284 |
-
<li><a target="_blank" href="https://www.joomunited.com/"><?php _e('Other plugins from JoomUnited','wp-meta-seo'); ?></a></li>
|
285 |
</ul>
|
286 |
</div>
|
287 |
</div>
|
@@ -289,17 +287,17 @@ $plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.p
|
|
289 |
</div>
|
290 |
</div>
|
291 |
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
1 |
+
<?php
|
2 |
if (!class_exists('MetaSeo_Dashboard')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-dashboard.php' );
|
4 |
}
|
7 |
wp_enqueue_script('jquery-qtip');
|
8 |
|
9 |
$site_name = preg_replace('/(^(http|https):\/\/[w]*\.*)/', '', get_site_url());
|
|
|
10 |
$url = 'http://www.alexa.com/siteinfo/' . $site_name;
|
11 |
$dashboard = new MetaSeo_Dashboard();
|
12 |
$results = $dashboard->evolutive_dashboard();
|
13 |
$link_errors = $dashboard->get_404_link();
|
14 |
$results_image = $dashboard->moptimizationChecking();
|
15 |
+
if (!empty($results_image['imgs_statis'][1])) {
|
16 |
+
$percent_iresizing = ceil($results_image['imgs_statis'][0] / $results_image['imgs_statis'][1] * 100);
|
17 |
+
} else {
|
18 |
$percent_iresizing = 100;
|
19 |
}
|
20 |
|
21 |
+
if (!empty($results_image['imgs_metas_statis'][1])) {
|
22 |
+
$percent_imeta = ceil($results_image['imgs_metas_statis'][0] / $results_image['imgs_metas_statis'][1] * 100);
|
23 |
+
} else {
|
24 |
$percent_imeta = 100;
|
25 |
}
|
26 |
|
27 |
$plugin_imgRecycle_file = 'imagerecycle-pdf-image-compression/wp-image-recycle.php';
|
|
|
28 |
?>
|
29 |
<h1 style="text-align: center;"><?php _e('WP Meta SEO dashboard', 'wp-meta-seo') ?></h1>
|
30 |
<div class="dashboard">
|
31 |
<div class="col-md-9">
|
32 |
<div class="row panel-statistics">
|
33 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('It’s better using a permalink structure that is adding in your URL the category name and content title. This parameter can be changed in Settings > Permalinks WordPress menu. Tag recommended is %category%/%postname%', 'wp-meta-seo') ?>">
|
34 |
<div class="panel panel-updates">
|
35 |
<div class="panel-body">
|
36 |
<div class="row">
|
37 |
<div class="col-xs-7 col-lg-8">
|
38 |
+
<h4 class="panel-title text-success"><?php _e('Permalinks settings', 'wp-meta-seo') ?></h4>
|
39 |
+
<h3><?php echo $results['permalink_setting'] . '%' ?></h3>
|
40 |
<div class="progress">
|
41 |
+
<div style="width: <?php echo $results['permalink_setting'] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['permalink_setting'] ?>" role="progressbar" class="progress-bar progress-bar-success">
|
42 |
+
<span class="sr-only"><?php echo $results['permalink_setting'] . '%' ?> Complete (success)</span>
|
43 |
</div>
|
44 |
</div>
|
45 |
+
<p><?php _e('Optimized at', 'wp-meta-seo') ?>: <?php echo $results['permalink_setting'] . '%' ?></p>
|
46 |
</div>
|
47 |
<div class="col-xs-5 col-lg-4 text-right">
|
48 |
<input type="text" value="<?php echo $results['permalink_setting'] ?>" class="dial-success">
|
52 |
</div>
|
53 |
</div>
|
54 |
|
55 |
+
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('Meta titles are displayed in search engine results as a page title. It’s a good thing for SEO to have some custom and attractive ones. Be sure to fill at least the met information on your most popular pages', 'wp-meta-seo') ?>">
|
56 |
<div class="panel panel-danger-full panel-updates">
|
57 |
<div class="panel-body">
|
58 |
<div class="row">
|
59 |
<div class="col-xs-7 col-lg-8">
|
60 |
+
<h4 class="panel-title text-warning"><?php _e('Meta Title', 'wp-meta-seo') ?></h4>
|
61 |
+
<h3><?php echo $results['metatitle_filled'][0] . '%' ?></h3>
|
62 |
<div class="progress">
|
63 |
+
<div style="width: <?php echo $results['metatitle_filled'][0] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['metatitle_filled'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
64 |
+
<span class="sr-only"><?php echo $results['metatitle_filled'][0] . '%' ?> Complete (success)</span>
|
65 |
</div>
|
66 |
</div>
|
67 |
+
<p><?php _e('Meta title filled', 'wp-meta-seo') ?>: <?php echo $results['metatitle_filled'][1][0] . '/' . $results['metatitle_filled'][1][1] ?></p>
|
68 |
</div>
|
69 |
<div class="col-xs-5 col-lg-4 text-right">
|
70 |
<input type="text" value="<?php echo $results['metatitle_filled'][0] ?>" class="dial-warning">
|
74 |
</div>
|
75 |
</div>
|
76 |
|
77 |
+
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('Meta descriptions are displayed in search engine results as a page description. It’s a good thing for SEO to have some custom and attractive ones. Be sure to fill at least the meta information on your most popular pages.', 'wp-meta-seo') ?>">
|
78 |
<div class="panel panel-success-full panel-updates">
|
79 |
<div class="panel-body">
|
80 |
<div class="row">
|
81 |
<div class="col-xs-7 col-lg-8">
|
82 |
+
<h4 class="panel-title text-success"><?php _e('Meta Description', 'wp-meta-seo') ?></h4>
|
83 |
+
<h3><?php echo $results['metadesc_filled'][0] . '%' ?></h3>
|
84 |
<div class="progress">
|
85 |
+
<div style="width: <?php echo $results['metadesc_filled'][0] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['metadesc_filled'][0] ?>" role="progressbar" class="progress-bar progress-bar-info">
|
86 |
+
<span class="sr-only"><?php echo $results['metadesc_filled'][0] . '%' ?> Complete (success)</span>
|
87 |
</div>
|
88 |
</div>
|
89 |
+
<p><?php _e('Meta description filled', 'wp-meta-seo') ?>: <?php echo $results['metadesc_filled'][1][0] . '/' . $results['metadesc_filled'][1][1] ?></p>
|
90 |
</div>
|
91 |
<div class="col-xs-5 col-lg-4 text-right">
|
92 |
<input type="text" value="<?php echo $results['metadesc_filled'][0] ?>" class="dial-info">
|
96 |
</div>
|
97 |
</div>
|
98 |
|
99 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('Display image at its natural size, do not use HTML resize. It happens usually when you use handles to resize an image. You have a bulk edition tool to fix that.', 'wp-meta-seo') ?>">
|
100 |
<div class="panel panel-updates">
|
101 |
<div class="panel-body">
|
102 |
<div class="row">
|
103 |
<div class="col-xs-7 col-lg-8">
|
104 |
+
<h4 class="panel-title text-danger"><?php _e('HTML image resizing', 'wp-meta-seo') ?></h4>
|
105 |
+
<h3><?php echo $percent_iresizing . '%' ?></h3>
|
106 |
<div class="progress">
|
107 |
+
<div style="width: <?php echo $percent_iresizing . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $percent_iresizing ?>" role="progressbar" class="progress-bar progress-bar-danger">
|
108 |
+
<span class="sr-only"><?php echo $percent_iresizing . '%' ?> Complete (success)</span>
|
109 |
</div>
|
110 |
</div>
|
111 |
+
<p><?php _e('Wrong resized images', 'wp-meta-seo') ?>: <?php echo $results_image['imgs_statis'][0] . '/' . $results_image['imgs_statis'][1] ?></p>
|
112 |
</div>
|
113 |
<div class="col-xs-5 col-lg-4 text-right">
|
114 |
<input type="text" value="<?php echo $percent_iresizing ?>" class="dial-danger">
|
117 |
</div>
|
118 |
</div>
|
119 |
</div>
|
120 |
+
|
121 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('We recommend to use both alt text and image title. The main advantage is that it helps search engines discover your images and display them in image search results. Plus, these tags improve the accessibility of your site and give more information about your images. Use our bulk image tool to quickly check and fix that.', 'wp-meta-seo') ?>">
|
122 |
<div class="panel panel-updates">
|
123 |
<div class="panel-body">
|
124 |
<div class="row">
|
125 |
<div class="col-xs-7 col-lg-8">
|
126 |
+
<h4 class="panel-title text-success"><?php _e('Image title/alt', 'wp-meta-seo') ?></h4>
|
127 |
+
<h3><?php echo $percent_imeta . '%' ?></h3>
|
128 |
<div class="progress">
|
129 |
+
<div style="width: <?php echo $percent_imeta . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $percent_imeta ?>" role="progressbar" class="progress-bar progress-bar-success">
|
130 |
+
<span class="sr-only"><?php echo $percent_imeta . '%' ?> Complete (success)</span>
|
131 |
</div>
|
132 |
</div>
|
133 |
+
<p><?php _e('Image data filled (in content)', 'wp-meta-seo') ?>: <?php echo $results_image['imgs_metas_statis'][0] . '/' . $results_image['imgs_metas_statis'][1] ?></p>
|
134 |
</div>
|
135 |
<div class="col-xs-5 col-lg-4 text-right">
|
136 |
<input type="text" value="<?php echo $percent_imeta ?>" class="dial-success">
|
139 |
</div>
|
140 |
</div>
|
141 |
</div>
|
142 |
+
|
143 |
+
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('It is highly recommended to update or add new content on your website quite frequently. At least 3 updated or new content per month would be great :)', 'wp-meta-seo') ?>">
|
144 |
<div class="panel panel-danger-full panel-updates">
|
145 |
<div class="panel-body">
|
146 |
<div class="row">
|
147 |
<div class="col-xs-7 col-lg-8">
|
148 |
+
<h4 class="panel-title text-warning"><?php _e('New or updated content', 'wp-meta-seo') ?></h4>
|
149 |
+
<h3><?php echo $results['new_content'][0] . '%' ?></h3>
|
150 |
<div class="progress">
|
151 |
+
<div style="width: <?php echo $results['new_content'][0] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['new_content'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
152 |
+
<span class="sr-only"><?php echo $results['new_content'][0] . '%' ?> Complete (success)</span>
|
153 |
</div>
|
154 |
</div>
|
155 |
+
<p><?php _e('Latest month new or updated content', 'wp-meta-seo') ?>: <?php echo $results['new_content'][1][0] ?></p>
|
156 |
</div>
|
157 |
<div class="col-xs-5 col-lg-4 text-right">
|
158 |
<input type="text" value="<?php echo $results['new_content'][0] ?>" class="dial-warning">
|
161 |
</div>
|
162 |
</div>
|
163 |
</div>
|
164 |
+
|
165 |
+
<div class="col-sm-6 metaseo_tool-000" alt="<?php _e('The link title attribute does not have any SEO value for links. BUT links titles can influence click behavior for users, which may indirectly affect your SEO performance', 'wp-meta-seo') ?>">
|
166 |
<div class="panel panel-danger-full panel-updates">
|
167 |
<div class="panel-body">
|
168 |
<div class="row">
|
169 |
<div class="col-xs-7 col-lg-8">
|
170 |
+
<h4 class="panel-title text-warning"><?php _e('Link titles', 'wp-meta-seo') ?></h4>
|
171 |
+
<h3><?php echo $results['link_meta'][0] . '%' ?></h3>
|
172 |
<div class="progress">
|
173 |
+
<div style="width: <?php echo $results['link_meta'][0] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $results['link_meta'][0] ?>" role="progressbar" class="progress-bar progress-bar-warning">
|
174 |
+
<span class="sr-only"><?php echo $results['link_meta'][0] . '%' ?> Complete (success)</span>
|
175 |
</div>
|
176 |
</div>
|
177 |
+
<p><?php _e('Links title completed', 'wp-meta-seo') ?>: <?php echo $results['link_meta'][1][0] . '/' . $results['link_meta'][1][1]; ?></p>
|
178 |
</div>
|
179 |
<div class="col-xs-5 col-lg-4 text-right">
|
180 |
<input type="text" value="<?php echo $results['link_meta'][0] ?>" class="dial-warning">
|
183 |
</div>
|
184 |
</div>
|
185 |
</div>
|
186 |
+
|
187 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('A website with a bunch of 404 errors doesn’t provide a good user experience, which is significantly important in content marketing and SEO. We recommend to use our internal broken link checker and redirect tool to fix all the 404 error you can periodically.', 'wp-meta-seo') ?>">
|
188 |
<div class="panel panel-updates">
|
189 |
<div class="panel-body">
|
190 |
<div class="row">
|
191 |
<div class="col-xs-7 col-lg-8">
|
192 |
+
<h4 class="panel-title text-success"><?php _e('404 ERRORS', 'wp-meta-seo') ?></h4>
|
193 |
+
<h3><?php echo $link_errors['percent'] . '%' ?></h3>
|
194 |
<div class="progress">
|
195 |
+
<div style="width: <?php echo $link_errors['percent'] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $link_errors['percent'] ?>" role="progressbar" class="progress-bar progress-bar-success">
|
196 |
+
<span class="sr-only"><?php echo $link_errors['percent'] . '%' ?> Complete (success)</span>
|
197 |
</div>
|
198 |
</div>
|
199 |
+
<p><?php _e('Redirected 404 errors', 'wp-meta-seo') ?>: <?php echo $link_errors['count_404_redirected'] . '/' . $link_errors['count_404'] ?></p>
|
200 |
</div>
|
201 |
<div class="col-xs-5 col-lg-4 text-right">
|
202 |
<input type="text" value="<?php echo $link_errors['percent'] ?>" class="dial-success">
|
205 |
</div>
|
206 |
</div>
|
207 |
</div>
|
208 |
+
|
209 |
<?php if (file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression')) : ?>
|
210 |
+
<?php
|
211 |
if (!is_plugin_active($plugin_imgRecycle_file)) :
|
212 |
+
?>
|
213 |
+
|
214 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('Images represent around 60% of a web page weight. An image compression reduce the image size by up to 70% while preserving the same visual quality. Small loading time is great for SEO!', 'wp-meta-seo') ?>">
|
215 |
+
<div class="panel panel-updates">
|
216 |
+
<div class="panel-body">
|
217 |
+
<div class="row">
|
218 |
+
<div class="col-xs-7 col-lg-8">
|
219 |
+
<h4 class="panel-title text-success"><?php _e('Image compression', 'wp-meta-seo') ?></h4>
|
220 |
+
<h3>0%</h3>
|
221 |
+
<div class="progress">
|
222 |
+
<div style="width:0%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="0" role="progressbar" class="progress-bar progress-bar-success">
|
223 |
+
<span class="sr-only">0% Complete (success)</span>
|
224 |
+
</div>
|
225 |
+
</div>
|
226 |
+
<p><?php _e('Use ImageRecycle image compression plugin to activate this feature', 'wp-meta-seo') ?>: 0%</p>
|
227 |
+
</div>
|
228 |
+
<div class="col-xs-5 col-lg-4 text-right">
|
229 |
+
<input type="text" value="0" class="dial-success">
|
230 |
</div>
|
231 |
</div>
|
|
|
|
|
|
|
|
|
232 |
</div>
|
233 |
</div>
|
234 |
</div>
|
235 |
+
|
236 |
+
<?php else: ?>
|
237 |
+
<?php $optimizer_results = $dashboard->wpmf_getImages_count(); ?>
|
238 |
+
<div class="col-sm-6 metaseo_tool" alt="<?php _e('Images represent around 60% of a web page weight. An image compression reduce the image size by up to 70% while preserving the same visual quality. Small loading time is great for SEO!', 'wp-meta-seo') ?>">
|
239 |
+
<div class="panel panel-updates">
|
240 |
+
<div class="panel-body">
|
241 |
+
<div class="row">
|
242 |
+
<div class="col-xs-7 col-lg-8">
|
243 |
+
<h4 class="panel-title text-success"><?php _e('Image compression', 'wp-meta-seo') ?></h4>
|
244 |
+
<h3><?php echo $optimizer_results['percent'] . '%' ?></h3>
|
245 |
+
<div class="progress">
|
246 |
+
<div style="width: <?php echo $optimizer_results['percent'] . '%' ?>" aria-valuemax="100" aria-valuemin="0" aria-valuenow="<?php echo $optimizer_results['percent'] ?>" role="progressbar" class="progress-bar progress-bar-success">
|
247 |
+
<span class="sr-only"><?php echo $optimizer_results['percent'] . '%' ?> Complete (success)</span>
|
248 |
+
</div>
|
249 |
+
</div>
|
250 |
+
<p><?php _e('Compressed images', 'wp-meta-seo') ?>: <?php echo $optimizer_results['image_optimize'] . '/' . $optimizer_results['count_image'] ?></p>
|
251 |
+
</div>
|
252 |
+
<div class="col-xs-5 col-lg-4 text-right">
|
253 |
+
<input type="text" value="<?php echo $optimizer_results['percent'] ?>" class="dial-success">
|
254 |
</div>
|
255 |
</div>
|
|
|
|
|
|
|
|
|
256 |
</div>
|
257 |
</div>
|
258 |
</div>
|
259 |
+
<?php endif; ?>
|
|
|
|
|
260 |
<?php endif; ?>
|
261 |
+
|
262 |
</div>
|
263 |
</div>
|
264 |
+
|
265 |
<div style="width:75%;margin: 0px auto;min-height: 200px;padding: 0px 10px 0px 10px;">
|
266 |
<div class="left">
|
267 |
<div class="dashboard-left" id='dashboard-left'>
|
273 |
|
274 |
<div class="right">
|
275 |
<div class="dashboard-right">
|
276 |
+
<div style="display: none"><?php _e("We can't get rank of this site from Alexa.com!", "wp-meta-seo") ?></div>
|
277 |
<div style="clear:left"></div>
|
278 |
<div id="wpmetaseo-update-version">
|
279 |
<h4><?php echo __('Latest WP Meta SEO News', 'wp-meta-seo') ?></h4>
|
280 |
<ul>
|
281 |
+
<li><a target="_blank" href="https://www.joomunited.com/wordpress-products/wp-meta-seo"><?php _e('More information about WP Meta SEO', 'wp-meta-seo'); ?></a></li>
|
282 |
+
<li><a target="_blank" href="https://www.joomunited.com/"><?php _e('Other plugins from JoomUnited', 'wp-meta-seo'); ?></a></li>
|
283 |
</ul>
|
284 |
</div>
|
285 |
</div>
|
287 |
</div>
|
288 |
</div>
|
289 |
|
290 |
+
<script type="text/javascript">
|
291 |
+
jQuery(document).ready(function () {
|
292 |
+
replace_url_img();
|
293 |
+
});
|
294 |
+
|
295 |
+
function replace_url_img() {
|
296 |
+
var url = '<?php echo WPMETASEO_PLUGIN_URL; ?>';
|
297 |
+
var icon_tip = url + 'img/icon_tip.png';
|
298 |
+
var globe_sm = url + 'img/globe-sm.jpg';
|
299 |
+
jQuery('.img-inline').attr('src', globe_sm);
|
300 |
+
jQuery('#alexa-ranking .tt img').attr('src', icon_tip);
|
301 |
+
}
|
302 |
+
|
303 |
+
</script>
|
inc/pages/image-meta.php
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Meta image
|
4 |
-
*/
|
5 |
-
|
6 |
if (!class_exists('MetaSeo_Image_List_Table')) {
|
7 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-image-list-table.php' );
|
8 |
}
|
@@ -19,22 +15,18 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
|
|
19 |
|
20 |
<div class="wrap seo_extended_table_page">
|
21 |
<div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
|
22 |
-
|
23 |
<?php echo '<h1>' . __('Image Meta', 'wp-meta-seo') . '</h1>'; ?>
|
24 |
-
|
25 |
<form id="wp-seo-meta-form" action="" method="post">
|
26 |
-
|
27 |
<?php $metaseo_list_table->search_box1(); ?>
|
28 |
-
|
29 |
<?php $metaseo_list_table->display(); ?>
|
30 |
</form>
|
31 |
|
32 |
</div>
|
33 |
<script type="text/javascript">
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
</script>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
if (!class_exists('MetaSeo_Image_List_Table')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-image-list-table.php' );
|
4 |
}
|
15 |
|
16 |
<div class="wrap seo_extended_table_page">
|
17 |
<div id="icon-edit-pages" class="icon32 icon32-posts-page"></div>
|
|
|
18 |
<?php echo '<h1>' . __('Image Meta', 'wp-meta-seo') . '</h1>'; ?>
|
|
|
19 |
<form id="wp-seo-meta-form" action="" method="post">
|
|
|
20 |
<?php $metaseo_list_table->search_box1(); ?>
|
|
|
21 |
<?php $metaseo_list_table->display(); ?>
|
22 |
</form>
|
23 |
|
24 |
</div>
|
25 |
<script type="text/javascript">
|
26 |
+
jQuery(document).ready(function () {
|
27 |
+
//Scan all posts to find a group of images in their content
|
28 |
+
metaSeoScanImages();
|
29 |
+
autosize(document.querySelectorAll('.metaseo-img-meta'));
|
30 |
+
});
|
31 |
+
|
32 |
</script>
|
inc/pages/link-meta.php
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Meta image
|
4 |
-
*/
|
5 |
-
|
6 |
if (!class_exists('MetaSeo_Link_List_Table')) {
|
7 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-link-list-table.php' );
|
8 |
}
|
@@ -23,35 +19,35 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
|
|
23 |
<?php echo '<h1>' . __('Link editor', 'wp-meta-seo') . '</h1>'; ?>
|
24 |
|
25 |
<form id="wp-seo-meta-form" action="" method="post">
|
26 |
-
|
27 |
<?php $metaseo_list_table->search_box1(); ?>
|
28 |
-
|
29 |
<?php $metaseo_list_table->display(); ?>
|
30 |
</form>
|
31 |
|
32 |
</div>
|
33 |
<script type="text/javascript">
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
</script>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
if (!class_exists('MetaSeo_Link_List_Table')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-link-list-table.php' );
|
4 |
}
|
19 |
<?php echo '<h1>' . __('Link editor', 'wp-meta-seo') . '</h1>'; ?>
|
20 |
|
21 |
<form id="wp-seo-meta-form" action="" method="post">
|
22 |
+
|
23 |
<?php $metaseo_list_table->search_box1(); ?>
|
24 |
+
|
25 |
<?php $metaseo_list_table->display(); ?>
|
26 |
</form>
|
27 |
|
28 |
</div>
|
29 |
<script type="text/javascript">
|
30 |
+
jQuery(document).ready(function ($) {
|
31 |
+
$('.metaseo_link_title').bind('input propertychange', function () {
|
32 |
+
$(this).closest('tr').find('.wpms_update_link').show();
|
33 |
+
});
|
34 |
+
|
35 |
+
$('.wpms_update_link').on('click', function () {
|
36 |
+
saveMetaLinkChanges(this);
|
37 |
+
});
|
38 |
+
|
39 |
+
$('.wpms_change_follow').on('click', function () {
|
40 |
+
wpmsChangeFollow(this);
|
41 |
+
});
|
42 |
+
|
43 |
+
$('.btn_apply_follow').on('click', function () {
|
44 |
+
wpmsUpdateFollow(this);
|
45 |
+
});
|
46 |
+
|
47 |
+
$('.wpms_scan_link').on('click', function () {
|
48 |
+
var $this = $(this);
|
49 |
+
wpms_scan_link($this);
|
50 |
+
});
|
51 |
+
});
|
52 |
+
|
53 |
</script>
|
inc/pages/metaseo-broken-link.php
CHANGED
@@ -1,8 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Meta image
|
4 |
-
*/
|
5 |
-
|
6 |
if (!class_exists('MetaSeo_Broken_Link_Table')) {
|
7 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-broken-link-table.php' );
|
8 |
}
|
@@ -31,198 +27,6 @@ if (!empty($_REQUEST['_wp_http_referer'])) {
|
|
31 |
</form>
|
32 |
|
33 |
</div>
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
$('.wpms-link-url-field').on('keyup',function(){
|
38 |
-
var url = $.trim( $(this).val() );
|
39 |
-
if ( url && correctedURL !== url && ! /^(?:[a-z]+:|#|\?|\.|\/)/.test( url ) ) {
|
40 |
-
$(this).val( 'http://' + url );
|
41 |
-
correctedURL = url;
|
42 |
-
}
|
43 |
-
});
|
44 |
-
|
45 |
-
$('.wpms_scan_link').on('click',function(){
|
46 |
-
var $this = $(this);
|
47 |
-
wpms_scan_link($this);
|
48 |
-
});
|
49 |
-
|
50 |
-
$('.wpms_flush_link').on('click',function(){
|
51 |
-
var $this = $(this);
|
52 |
-
var flush_val = $('#filter-by-flush').val();
|
53 |
-
if(flush_val != 'none'){
|
54 |
-
$('#wp-seo-meta-form .spinner').css('visibility','visible').show();
|
55 |
-
$.ajax({
|
56 |
-
url: ajaxurl,
|
57 |
-
method: 'POST',
|
58 |
-
dataType: 'json',
|
59 |
-
data: {
|
60 |
-
'action': 'wpms_flush_link',
|
61 |
-
'type' : $('#filter-by-flush').val()
|
62 |
-
},
|
63 |
-
success: function (res) {
|
64 |
-
$('#wp-seo-meta-form .spinner').hide();
|
65 |
-
window.location.assign(document.URL);
|
66 |
-
}
|
67 |
-
});
|
68 |
-
}
|
69 |
-
});
|
70 |
-
|
71 |
-
$('.wpms-edit-button').on('click', function () {
|
72 |
-
$(this).closest('td').find('.wpms-inline-editor-content').show();
|
73 |
-
});
|
74 |
-
|
75 |
-
$('.wpms-cancel-button').on('click', function () {
|
76 |
-
$(this).closest('td').find('.wpms-inline-editor-content').hide();
|
77 |
-
});
|
78 |
-
|
79 |
-
$('.wpms-update-link-button').on('click', function () {
|
80 |
-
var $this = $(this);
|
81 |
-
var link_id = $this.data('link_id');
|
82 |
-
var new_link = $this.closest('td').find('.wpms-link-url-field').val();
|
83 |
-
var new_text = $this.closest('td').find('.wpms-link-text-field').val();
|
84 |
-
var link_redirect = $this.closest('td').find('.wpms-link-redirect-field').val();
|
85 |
-
var data_type = $this.closest('td').find('.wpms-link-text-field').data('type');
|
86 |
-
if (new_link == '') {
|
87 |
-
alert('Error: Link URL must not be empty');
|
88 |
-
} else {
|
89 |
-
wpms_update_link($this, link_id, new_link,new_text,link_redirect,data_type);
|
90 |
-
}
|
91 |
-
});
|
92 |
-
|
93 |
-
$('.wpms-unlink-button').on('click', function () {
|
94 |
-
var $this = $(this);
|
95 |
-
var link_id = $this.data('link_id');
|
96 |
-
wpms_unlink($this, link_id);
|
97 |
-
});
|
98 |
-
|
99 |
-
$('.wpms-recheck-button').on('click', function () {
|
100 |
-
var $this = $(this);
|
101 |
-
var link_id = $this.data('link_id');
|
102 |
-
wpms_recheck_link($this, link_id);
|
103 |
-
});
|
104 |
-
|
105 |
-
function wpms_recheck_link($this,link_id) {
|
106 |
-
var oldColor = $this.closest('tr').css('background-color');
|
107 |
-
$this.closest('tr').css({ 'background-color' : "rgba(0, 115, 170, 0.1)" });
|
108 |
-
$.ajax({
|
109 |
-
url: ajaxurl,
|
110 |
-
method: 'POST',
|
111 |
-
dataType: 'json',
|
112 |
-
data: {
|
113 |
-
'action': 'wpms_recheck_link',
|
114 |
-
'link_id': link_id,
|
115 |
-
},
|
116 |
-
success: function (res) {
|
117 |
-
if(res.status){
|
118 |
-
var status = res.status_text;
|
119 |
-
if(status.indexOf('404') != -1 || status == 'Server Not Found'){
|
120 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
|
121 |
-
}else if(status.indexOf('200') != -1){
|
122 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
|
123 |
-
}else if(status.indexOf('301') != -1){
|
124 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
|
125 |
-
}else if(status.indexOf('302') != -1){
|
126 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
|
127 |
-
}else{
|
128 |
-
$this.closest('tr').find('.col_status').html(res.status_text);
|
129 |
-
}
|
130 |
-
wpms_tooltip();
|
131 |
-
$this.closest('tr').css({ 'background-color' : oldColor });
|
132 |
-
}
|
133 |
-
}
|
134 |
-
});
|
135 |
-
}
|
136 |
-
|
137 |
-
|
138 |
-
function wpms_unlink($this,link_id) {
|
139 |
-
$this.closest('tr').css({ 'background-color' : "rgba(0, 115, 170, 0.1)" });
|
140 |
-
$.ajax({
|
141 |
-
url: ajaxurl,
|
142 |
-
method: 'POST',
|
143 |
-
dataType: 'json',
|
144 |
-
data: {
|
145 |
-
'action': 'wpms_unlink',
|
146 |
-
'link_id': link_id,
|
147 |
-
},
|
148 |
-
success: function (res) {
|
149 |
-
if (res) {
|
150 |
-
$this.closest('tr').remove();
|
151 |
-
}
|
152 |
-
}
|
153 |
-
});
|
154 |
-
}
|
155 |
-
|
156 |
-
|
157 |
-
function wpms_update_link($this, link_id, new_link,new_text,link_redirect,data_type) {
|
158 |
-
$.ajax({
|
159 |
-
url: ajaxurl,
|
160 |
-
method: 'POST',
|
161 |
-
dataType: 'json',
|
162 |
-
data: {
|
163 |
-
'action': 'wpms_update_link',
|
164 |
-
'link_id': link_id,
|
165 |
-
'new_link': new_link,
|
166 |
-
'new_text': new_text,
|
167 |
-
'link_redirect' : link_redirect,
|
168 |
-
'data_type' : data_type
|
169 |
-
},
|
170 |
-
success: function (res) {
|
171 |
-
if (res.status) {
|
172 |
-
$this.closest('td').find('.wpms-inline-editor-content').hide();
|
173 |
-
//if(res.type != '404_automaticaly'){
|
174 |
-
$this.closest('td').find('.link_html').html(res.new_link).attr('href', res.new_link);
|
175 |
-
$this.closest('tr').find('.col_status').html(res.status_text);
|
176 |
-
|
177 |
-
var status = res.status_text;
|
178 |
-
if(status.indexOf('404') != -1 || status == 'Server Not Found'){
|
179 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
|
180 |
-
}else if(status.indexOf('200') != -1){
|
181 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
|
182 |
-
}else if(status.indexOf('301') != -1){
|
183 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
|
184 |
-
}else if(status.indexOf('302') != -1){
|
185 |
-
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
|
186 |
-
}else{
|
187 |
-
$this.closest('tr').find('.col_status').html(res.status_text);
|
188 |
-
}
|
189 |
-
wpms_tooltip();
|
190 |
-
//}
|
191 |
-
|
192 |
-
if(res.type == 'url'){
|
193 |
-
if(res.new_text != ''){
|
194 |
-
$this.closest('tr').find('.link_text').html(new_text);
|
195 |
-
}
|
196 |
-
}
|
197 |
-
}
|
198 |
-
}
|
199 |
-
});
|
200 |
-
}
|
201 |
-
|
202 |
-
function wpms_tooltip(){
|
203 |
-
jQuery('.metaseo_help_status').qtip({
|
204 |
-
content: {
|
205 |
-
attr: 'alt'
|
206 |
-
},
|
207 |
-
position: {
|
208 |
-
my: 'bottom left',
|
209 |
-
at: 'top center'
|
210 |
-
},
|
211 |
-
style: {
|
212 |
-
tip: {
|
213 |
-
corner: true
|
214 |
-
},
|
215 |
-
classes: 'metaseo-qtip qtip-rounded'
|
216 |
-
},
|
217 |
-
show: 'hover',
|
218 |
-
hide: {
|
219 |
-
fixed: true,
|
220 |
-
delay: 500
|
221 |
-
}
|
222 |
-
|
223 |
-
});
|
224 |
-
}
|
225 |
-
wpms_tooltip();
|
226 |
-
});
|
227 |
-
|
228 |
-
</script>
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
if (!class_exists('MetaSeo_Broken_Link_Table')) {
|
3 |
require_once( WPMETASEO_PLUGIN_DIR . '/inc/class.metaseo-broken-link-table.php' );
|
4 |
}
|
27 |
</form>
|
28 |
|
29 |
</div>
|
30 |
+
<?php
|
31 |
+
wp_enqueue_script('wpms-broken-link');
|
32 |
+
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/pages/metaseo-image-compression.php
CHANGED
@@ -43,7 +43,6 @@ if (isset($_GET['action'])) {
|
|
43 |
$title = __('Plugin Install');
|
44 |
$parent_file = 'plugins.php';
|
45 |
$submenu_file = 'plugin-install.php';
|
46 |
-
// require_once(ABSPATH . 'wp-admin/admin-header.php');
|
47 |
|
48 |
$title = sprintf(__('Installing Plugin: %s'), $api->name . ' ' . $api->version);
|
49 |
$nonce = 'install-plugin_' . $plugin;
|
@@ -55,7 +54,6 @@ if (isset($_GET['action'])) {
|
|
55 |
|
56 |
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
|
57 |
$upgrader->install($api->download_link);
|
58 |
-
// include(ABSPATH . 'wp-admin/admin-footer.php');
|
59 |
}elseif ('activate' == $action) {
|
60 |
if (!current_user_can('activate_plugins'))
|
61 |
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
|
@@ -123,30 +121,30 @@ if (!file_exists(WP_PLUGIN_DIR . '/imagerecycle-pdf-image-compression')) {
|
|
123 |
}
|
124 |
?>
|
125 |
|
126 |
-
<?php if($check_install == true): ?>
|
127 |
-
<div class="main-presentation" style="margin: 0px auto; max-width: 1200px; background-color:#f0f1f4;font-family: helvetica,arial,sans-serif;">
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
136 |
</div>
|
137 |
-
</div>
|
138 |
<?php else: ?>
|
139 |
|
140 |
-
<div class="main-presentation" style="margin: 0px auto; max-width: 1200px; background-color:#f0f1f4;font-family: helvetica,arial,sans-serif;">
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
149 |
</div>
|
150 |
-
</div>
|
151 |
|
152 |
<?php endif; ?>
|
43 |
$title = __('Plugin Install');
|
44 |
$parent_file = 'plugins.php';
|
45 |
$submenu_file = 'plugin-install.php';
|
|
|
46 |
|
47 |
$title = sprintf(__('Installing Plugin: %s'), $api->name . ' ' . $api->version);
|
48 |
$nonce = 'install-plugin_' . $plugin;
|
54 |
|
55 |
$upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(compact('title', 'url', 'nonce', 'plugin', 'api')));
|
56 |
$upgrader->install($api->download_link);
|
|
|
57 |
}elseif ('activate' == $action) {
|
58 |
if (!current_user_can('activate_plugins'))
|
59 |
wp_die(__('You do not have sufficient permissions to activate plugins for this site.'));
|
121 |
}
|
122 |
?>
|
123 |
|
124 |
+
<?php if ($check_install == true): ?>
|
125 |
+
<div class="main-presentation" style="margin: 0px auto; max-width: 1200px; background-color:#f0f1f4;font-family: helvetica,arial,sans-serif;">
|
126 |
+
<div class="main-textcontent" style="margin: 0px auto; min-height: 400px; border-left: 1px dotted #d2d3d5; border-right: 1px dotted #d2d3d5; width: 840px; background-color:#fff;border-top: 5px solid #544766;" cellspacing="0" cellpadding="0" align="center">
|
127 |
+
<a href="https://www.imagerecycle.com/" target="_blank"> <img src="https://www.imagerecycle.com/images/Notification-mail/logo-image-recycle.png" alt="logo image recycle" width="500" height="84" class="CToWUd" style="display: block; outline: medium none; text-decoration: none; margin-left: auto; margin-right: auto; margin-top:15px;"> </a>
|
128 |
+
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif; font-size: 24px; line-height: 24px; padding-right: 10px; padding-left: 10px;" align="center"><strong>Great! ImageRecycle is installed<br></strong></p>
|
129 |
+
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 22px; padding-left: 20px; padding-right: 20px; text-align: center;">
|
130 |
+
<strong>Speed optimization of your WordPress website is highly recommended for SEO. The image compression is one of the tools that help to reduce your page size significantly while preserving the image quality.<br /><br />You can now manage all you images and compression from the ImageRecycle plugin, menu Media > ImageRecycle.<br /><br /></strong> ImageRecycle got a dedicated plugin for WordPress that run the images optimization automatically on your website & PDF
|
131 |
+
<br />In order to start the optimization process, please install the WordPress plugin. Enjoy!</p>
|
132 |
+
<p></p>
|
133 |
+
<p><?php echo $button; ?></p>
|
134 |
+
</div>
|
135 |
</div>
|
|
|
136 |
<?php else: ?>
|
137 |
|
138 |
+
<div class="main-presentation" style="margin: 0px auto; max-width: 1200px; background-color:#f0f1f4;font-family: helvetica,arial,sans-serif;">
|
139 |
+
<div class="main-textcontent" style="margin: 0px auto; min-height: 400px; border-left: 1px dotted #d2d3d5; border-right: 1px dotted #d2d3d5; width: 840px; background-color:#fff;border-top: 5px solid #544766;" cellspacing="0" cellpadding="0" align="center">
|
140 |
+
<a href="https://www.imagerecycle.com/" target="_blank"> <img src="https://www.imagerecycle.com/images/Notification-mail/logo-image-recycle.png" alt="logo image recycle" width="500" height="84" class="CToWUd" style="display: block; outline: medium none; text-decoration: none; margin-left: auto; margin-right: auto; margin-top:15px;"> </a>
|
141 |
+
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif; font-size: 24px; line-height: 24px; padding-right: 10px; padding-left: 10px;" align="center"><strong>Welcome on board!<br></strong></p>
|
142 |
+
<p style="background-color: #ffffff; color: #445566; font-family: helvetica,arial,sans-serif; font-size: 14px; line-height: 22px; padding-left: 20px; padding-right: 20px; text-align: center;">
|
143 |
+
<strong>Speed optimization of your WordPress website is highly recommended for SEO. The image compression is one of the tools that help to reduce your page size significantly while preserving the image quality.<br /><br />WP Meta SEO is fully integrated with ImageRecycle service, give a try, you have a free trial with no engagement or just make a test on an image here: <a href="https://www.imagerecycle.com/" target="_blank">www.imagerecycle.com</a><br /><br /></strong>
|
144 |
+
ImageRecycle got a dedicated plugin for WordPress that run the images optimization automatically on your website & PDF<br />In order to start the optimization process, please install the WordPress plugin. Enjoy!</p>
|
145 |
+
<p></p>
|
146 |
+
<p><?php echo $button; ?></p>
|
147 |
+
</div>
|
148 |
</div>
|
|
|
149 |
|
150 |
<?php endif; ?>
|
inc/pages/settings.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
?>
|
13 |
<div class="wrap wrap_wpms_settings">
|
14 |
-
<h1><?php _e('WP Meta SEO global settings','wp-meta-seo') ?></h1>
|
15 |
<div class="tab-header">
|
16 |
<div class="wpms-tabs">
|
17 |
-
<div class="wpms-tab-header active" data-label="wpms-global"><?php _e('Global','wp-meta-seo') ?></div>
|
18 |
-
<div class="wpms-tab-header" data-label="wpms-redirection"><?php _e('Redirections and 404','wp-meta-seo') ?></div>
|
19 |
</div>
|
20 |
</div>
|
21 |
<div class="wpms_content_settings">
|
22 |
<div class="content-box content-wpms-global">
|
23 |
<form method="post" action="options.php">
|
24 |
<?php
|
25 |
-
settings_fields(
|
26 |
do_settings_sections('metaseo_settings');
|
27 |
submit_button();
|
28 |
?>
|
@@ -33,34 +33,34 @@
|
|
33 |
<table class="form-table">
|
34 |
<tbody>
|
35 |
<tr>
|
36 |
-
<th scope="row"><?php _e('Global home redirect','wp-meta-seo') ?></th>
|
37 |
<td><label>
|
38 |
<input <?php checked($defaul_settings_404['wpms_redirect_homepage'], 1) ?> data-label="wpms_redirect_homepage" type="checkbox" class="cb_option" id="wpms_redirect_homepage">
|
39 |
-
<?php _e('Redirect all 404 errors to home page','wp-meta-seo') ?>
|
40 |
<input type="hidden" class="wpms_redirect_homepage" name="wpms_redirect[wpms_redirect_homepage]" value="<?php echo $defaul_settings_404['wpms_redirect_homepage'] ?>">
|
41 |
</label>
|
42 |
</td>
|
43 |
</tr>
|
44 |
<tr>
|
45 |
-
<th scope="row"><?php _e('Custom 404 page','wp-meta-seo') ?></th>
|
46 |
<td>
|
47 |
-
<select name="wpms_redirect[wpms_type_404]" class="wpms_type_404" <?php echo ($defaul_settings_404['wpms_redirect_homepage']==1)?"disabled":"" ?>>
|
48 |
<?php foreach ($types_404 as $k => $type_404): ?>
|
49 |
-
|
50 |
<?php endforeach; ?>
|
51 |
</select>
|
52 |
-
<select name="wpms_redirect[wpms_page_redirected]" class="wpms_page_redirected" <?php echo (($defaul_settings_404['wpms_redirect_homepage']==1) || $defaul_settings_404['wpms_type_404'] != 'custom_page')?"disabled":"" ?>>
|
53 |
-
<option value="none"><?php _e('— Select —','wp-meta-seo') ?></option>
|
54 |
<?php foreach ($posts as $post): ?>
|
55 |
-
|
56 |
<?php endforeach; ?>
|
57 |
</select>
|
58 |
</td>
|
59 |
</tr>
|
60 |
</tbody>
|
61 |
</table>
|
62 |
-
<div class="button wpms_save_settings404"><?php _e('Save','wp-meta-seo') ?></div>
|
63 |
-
<span class="message_saved"><?php _e('Saved','wp-meta-seo') ?></span>
|
64 |
</div>
|
65 |
|
66 |
</div>
|
@@ -88,17 +88,17 @@
|
|
88 |
}
|
89 |
|
90 |
});
|
91 |
-
|
92 |
-
$('.wpms-tab-header').on('click',function(){
|
93 |
var $this = $(this);
|
94 |
var label = $this.data('label');
|
95 |
$('.wpms-tab-header').removeClass('active');
|
96 |
$this.addClass('active');
|
97 |
$('.content-box').addClass('content-noactive').removeClass('content-active').hide();
|
98 |
-
$('.content-'+ label +'').addClass('content-active').removeClass('content-noactive').slideDown();
|
99 |
});
|
100 |
-
|
101 |
-
$('.wpms_save_settings404').on('click',function(){
|
102 |
var home_redirected = $('.wpms_redirect_homepage').val();
|
103 |
var type_404 = $('.wpms_type_404').val();
|
104 |
var page_redirected = $('.wpms_page_redirected').val();
|
@@ -109,29 +109,29 @@
|
|
109 |
data: {
|
110 |
'action': 'wpms_save_settings404',
|
111 |
'wpms_redirect[wpms_redirect_homepage]': home_redirected,
|
112 |
-
'wpms_redirect[wpms_type_404]'
|
113 |
'wpms_redirect[wpms_page_redirected]': page_redirected
|
114 |
},
|
115 |
success: function (res) {
|
116 |
-
if(res == true){
|
117 |
$('.message_saved').fadeIn(10).delay(2000).fadeOut(2000);
|
118 |
-
}else{
|
119 |
alert('Save errors !')
|
120 |
}
|
121 |
}
|
122 |
});
|
123 |
});
|
124 |
-
|
125 |
-
$('.wpms_type_404').on('change',function(){
|
126 |
var type_404 = $(this).val();
|
127 |
-
if(type_404 == 'wp-meta-seo-page' || type_404 == 'none'){
|
128 |
-
$('.wpms_page_redirected').prop('disabled',true);
|
129 |
-
}else if(type_404 == 'custom_page'){
|
130 |
-
$('.wpms_page_redirected').prop('disabled',false);
|
131 |
}
|
132 |
});
|
133 |
-
|
134 |
-
$('.cb_option').unbind('click').bind('click', function() {
|
135 |
var check = $(this).attr('checked');
|
136 |
var type = $(this).attr('type');
|
137 |
var value;
|
@@ -142,13 +142,13 @@
|
|
142 |
} else {
|
143 |
value = 0;
|
144 |
}
|
145 |
-
$('input[name="wpms_redirect['+ $(this).data('label') +']"]').val(value);
|
146 |
-
|
147 |
-
if($(this).data('label') == 'wpms_redirect_homepage'){
|
148 |
if (check == 'checked') {
|
149 |
-
$('.wpms_type_404,.wpms_page_redirected').prop('disabled',true);
|
150 |
} else {
|
151 |
-
$('.wpms_type_404,.wpms_page_redirected').prop('disabled',false);
|
152 |
}
|
153 |
}
|
154 |
}
|
1 |
<?php
|
2 |
+
wp_enqueue_style('m-style-qtip');
|
3 |
+
wp_enqueue_script('jquery-qtip');
|
4 |
+
$posts = get_posts(array('post_type' => 'page', 'posts_per_page' => -1, 'numberposts' => -1));
|
5 |
+
$types_404 = array('none' => 'None', 'wp-meta-seo-page' => __('WP Meta SEO page', 'wp-meta-seo'), 'custom_page' => __('Custom page', 'wp-meta-seo'));
|
6 |
+
|
7 |
+
$defaul_settings_404 = array('wpms_redirect_homepage' => 0, 'wpms_type_404' => 'none', 'wpms_page_redirected' => 'none');
|
8 |
+
$wpms_settings_404 = get_option('wpms_settings_404');
|
9 |
+
if (is_array($wpms_settings_404)) {
|
10 |
+
$defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
|
11 |
+
}
|
12 |
?>
|
13 |
<div class="wrap wrap_wpms_settings">
|
14 |
+
<h1><?php _e('WP Meta SEO global settings', 'wp-meta-seo') ?></h1>
|
15 |
<div class="tab-header">
|
16 |
<div class="wpms-tabs">
|
17 |
+
<div class="wpms-tab-header active" data-label="wpms-global"><?php _e('Global', 'wp-meta-seo') ?></div>
|
18 |
+
<div class="wpms-tab-header" data-label="wpms-redirection"><?php _e('Redirections and 404', 'wp-meta-seo') ?></div>
|
19 |
</div>
|
20 |
</div>
|
21 |
<div class="wpms_content_settings">
|
22 |
<div class="content-box content-wpms-global">
|
23 |
<form method="post" action="options.php">
|
24 |
<?php
|
25 |
+
settings_fields('Wp Meta SEO');
|
26 |
do_settings_sections('metaseo_settings');
|
27 |
submit_button();
|
28 |
?>
|
33 |
<table class="form-table">
|
34 |
<tbody>
|
35 |
<tr>
|
36 |
+
<th scope="row"><?php _e('Global home redirect', 'wp-meta-seo') ?></th>
|
37 |
<td><label>
|
38 |
<input <?php checked($defaul_settings_404['wpms_redirect_homepage'], 1) ?> data-label="wpms_redirect_homepage" type="checkbox" class="cb_option" id="wpms_redirect_homepage">
|
39 |
+
<?php _e('Redirect all 404 errors to home page', 'wp-meta-seo') ?>
|
40 |
<input type="hidden" class="wpms_redirect_homepage" name="wpms_redirect[wpms_redirect_homepage]" value="<?php echo $defaul_settings_404['wpms_redirect_homepage'] ?>">
|
41 |
</label>
|
42 |
</td>
|
43 |
</tr>
|
44 |
<tr>
|
45 |
+
<th scope="row"><?php _e('Custom 404 page', 'wp-meta-seo') ?></th>
|
46 |
<td>
|
47 |
+
<select name="wpms_redirect[wpms_type_404]" class="wpms_type_404" <?php echo ($defaul_settings_404['wpms_redirect_homepage'] == 1) ? "disabled" : "" ?>>
|
48 |
<?php foreach ($types_404 as $k => $type_404): ?>
|
49 |
+
<option <?php selected($defaul_settings_404['wpms_type_404'], $k) ?> value="<?php echo $k ?>"><?php echo $type_404 ?></option>
|
50 |
<?php endforeach; ?>
|
51 |
</select>
|
52 |
+
<select name="wpms_redirect[wpms_page_redirected]" class="wpms_page_redirected" <?php echo (($defaul_settings_404['wpms_redirect_homepage'] == 1) || $defaul_settings_404['wpms_type_404'] != 'custom_page') ? "disabled" : "" ?>>
|
53 |
+
<option value="none"><?php _e('— Select —', 'wp-meta-seo') ?></option>
|
54 |
<?php foreach ($posts as $post): ?>
|
55 |
+
<option <?php selected($defaul_settings_404['wpms_page_redirected'], $post->ID) ?> value="<?php echo $post->ID ?>"><?php echo $post->post_title ?></option>
|
56 |
<?php endforeach; ?>
|
57 |
</select>
|
58 |
</td>
|
59 |
</tr>
|
60 |
</tbody>
|
61 |
</table>
|
62 |
+
<div class="button wpms_save_settings404"><?php _e('Save', 'wp-meta-seo') ?></div>
|
63 |
+
<span class="message_saved"><?php _e('Saved', 'wp-meta-seo') ?></span>
|
64 |
</div>
|
65 |
|
66 |
</div>
|
88 |
}
|
89 |
|
90 |
});
|
91 |
+
|
92 |
+
$('.wpms-tab-header').on('click', function () {
|
93 |
var $this = $(this);
|
94 |
var label = $this.data('label');
|
95 |
$('.wpms-tab-header').removeClass('active');
|
96 |
$this.addClass('active');
|
97 |
$('.content-box').addClass('content-noactive').removeClass('content-active').hide();
|
98 |
+
$('.content-' + label + '').addClass('content-active').removeClass('content-noactive').slideDown();
|
99 |
});
|
100 |
+
|
101 |
+
$('.wpms_save_settings404').on('click', function () {
|
102 |
var home_redirected = $('.wpms_redirect_homepage').val();
|
103 |
var type_404 = $('.wpms_type_404').val();
|
104 |
var page_redirected = $('.wpms_page_redirected').val();
|
109 |
data: {
|
110 |
'action': 'wpms_save_settings404',
|
111 |
'wpms_redirect[wpms_redirect_homepage]': home_redirected,
|
112 |
+
'wpms_redirect[wpms_type_404]': type_404,
|
113 |
'wpms_redirect[wpms_page_redirected]': page_redirected
|
114 |
},
|
115 |
success: function (res) {
|
116 |
+
if (res == true) {
|
117 |
$('.message_saved').fadeIn(10).delay(2000).fadeOut(2000);
|
118 |
+
} else {
|
119 |
alert('Save errors !')
|
120 |
}
|
121 |
}
|
122 |
});
|
123 |
});
|
124 |
+
|
125 |
+
$('.wpms_type_404').on('change', function () {
|
126 |
var type_404 = $(this).val();
|
127 |
+
if (type_404 == 'wp-meta-seo-page' || type_404 == 'none') {
|
128 |
+
$('.wpms_page_redirected').prop('disabled', true);
|
129 |
+
} else if (type_404 == 'custom_page') {
|
130 |
+
$('.wpms_page_redirected').prop('disabled', false);
|
131 |
}
|
132 |
});
|
133 |
+
|
134 |
+
$('.cb_option').unbind('click').bind('click', function () {
|
135 |
var check = $(this).attr('checked');
|
136 |
var type = $(this).attr('type');
|
137 |
var value;
|
142 |
} else {
|
143 |
value = 0;
|
144 |
}
|
145 |
+
$('input[name="wpms_redirect[' + $(this).data('label') + ']"]').val(value);
|
146 |
+
|
147 |
+
if ($(this).data('label') == 'wpms_redirect_homepage') {
|
148 |
if (check == 'checked') {
|
149 |
+
$('.wpms_type_404,.wpms_page_redirected').prop('disabled', true);
|
150 |
} else {
|
151 |
+
$('.wpms_type_404,.wpms_page_redirected').prop('disabled', false);
|
152 |
}
|
153 |
}
|
154 |
}
|
inc/pages/sitemaps/metaseo-google-sitemap.php
CHANGED
@@ -1,19 +1,17 @@
|
|
1 |
<div class="wrap wpms_wrap">
|
2 |
<?php
|
3 |
-
|
4 |
?>
|
5 |
<form method="post" id="wpms_xmap_form" action="">
|
6 |
<input type="hidden" name="action" value="wpms_save_sitemap_settings">
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
//submit_button();
|
17 |
-
?>
|
18 |
</form>
|
19 |
</div>
|
1 |
<div class="wrap wpms_wrap">
|
2 |
<?php
|
3 |
+
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/sitemap_menus.php' );
|
4 |
?>
|
5 |
<form method="post" id="wpms_xmap_form" action="">
|
6 |
<input type="hidden" name="action" value="wpms_save_sitemap_settings">
|
7 |
+
<?php
|
8 |
+
echo '<div class="wpms_source wpms_source_sitemaps">';
|
9 |
+
do_settings_sections('metaseo_settings_sitemap');
|
10 |
+
echo '</div>';
|
11 |
+
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/metaseo-source_menu.php' );
|
12 |
+
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/metaseo-source_posts.php' );
|
13 |
+
require_once( WPMETASEO_PLUGIN_DIR . 'inc/pages/sitemaps/metaseo-source_pages.php' );
|
14 |
+
echo '<div class="div_wpms_save_sitemaps"><input type="button" class="button button-primary wpms_save_create_sitemaps" value="' . __('Regenerate and save sitemaps', 'wp-meta-seo') . '"><span class="spinner spinner_save_sitemaps"></span></div>';
|
15 |
+
?>
|
|
|
|
|
16 |
</form>
|
17 |
</div>
|
inc/pages/sitemaps/metaseo-source_pages.php
CHANGED
@@ -2,23 +2,23 @@
|
|
2 |
<div class="div_sitemap_check_all">
|
3 |
<input type="checkbox" class="sitemap_check_all" data-type="pages"><?php _e('Check all pages', 'wp-meta-seo'); ?>
|
4 |
</div>
|
5 |
-
|
6 |
<div class="div_sitemap_check_all">
|
7 |
<input type="checkbox" class="sitemap_check_all_posts_in_page" data-type="pages"><?php _e('Check all pages in current page', 'wp-meta-seo'); ?>
|
8 |
</div>
|
9 |
-
|
10 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
11 |
-
<?php _e('Public name'
|
12 |
-
<input type="text" class="public_name_pages" value="<?php echo
|
13 |
</div>
|
14 |
-
|
15 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
16 |
-
<?php _e('Display in column'
|
17 |
<select class="wpms_display_column wpms_display_column_pages">
|
18 |
-
<?php
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
?>
|
23 |
</select>
|
24 |
</div>
|
@@ -27,12 +27,21 @@
|
|
27 |
<?php
|
28 |
$pages = get_pages();
|
29 |
foreach ($pages as $page) {
|
30 |
-
$
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
echo '<div class="wpms_row">';
|
33 |
echo '<div style="float:left;line-height:30px">';
|
34 |
-
|
35 |
-
if (isset($metaseo_sitemap->settings_sitemap['wpms_sitemap_pages']->{$page->ID}->post_id) && $metaseo_sitemap->settings_sitemap['wpms_sitemap_pages']->{$page->ID}->post_id == $page->ID) {
|
36 |
echo '<input class="cb_sitemaps_pages wpms_xmap_pages" name="_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][post_id]" checked type="checkbox" value="' . $page->ID . '">';
|
37 |
} else {
|
38 |
echo '<input class="cb_sitemaps_pages wpms_xmap_pages" name="_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][post_id]" type="checkbox" value="' . $page->ID . '">';
|
2 |
<div class="div_sitemap_check_all">
|
3 |
<input type="checkbox" class="sitemap_check_all" data-type="pages"><?php _e('Check all pages', 'wp-meta-seo'); ?>
|
4 |
</div>
|
5 |
+
|
6 |
<div class="div_sitemap_check_all">
|
7 |
<input type="checkbox" class="sitemap_check_all_posts_in_page" data-type="pages"><?php _e('Check all pages in current page', 'wp-meta-seo'); ?>
|
8 |
</div>
|
9 |
+
|
10 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
11 |
+
<?php _e('Public name', 'wp-meta-seo'); ?>
|
12 |
+
<input type="text" class="public_name_pages" value="<?php echo $metaseo_sitemap->settings_sitemap['wpms_public_name_pages'] ?>">
|
13 |
</div>
|
14 |
+
|
15 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
16 |
+
<?php _e('Display in column', 'wp-meta-seo'); ?>
|
17 |
<select class="wpms_display_column wpms_display_column_pages">
|
18 |
+
<?php
|
19 |
+
for ($i = 1; $i <= $metaseo_sitemap->settings_sitemap['wpms_html_sitemap_column']; $i++) {
|
20 |
+
echo '<option ' . (selected($metaseo_sitemap->settings_sitemap['wpms_display_column_pages'], $i)) . ' value="' . $i . '">' . $metaseo_sitemap->columns[$i] . '</option>';
|
21 |
+
}
|
22 |
?>
|
23 |
</select>
|
24 |
</div>
|
27 |
<?php
|
28 |
$pages = get_pages();
|
29 |
foreach ($pages as $page) {
|
30 |
+
if(empty($metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['frequency'])){
|
31 |
+
$pagefrequency = 'monthly';
|
32 |
+
}else{
|
33 |
+
$pagefrequency = $metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['frequency'];
|
34 |
+
}
|
35 |
+
if(empty($metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['priority'])){
|
36 |
+
$pagepriority = '1.0';
|
37 |
+
}else{
|
38 |
+
$pagepriority = $metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['priority'];
|
39 |
+
}
|
40 |
+
$select_priority = $metaseo_sitemap->wpms_view_select_priority('priority_pages_' . $page->ID, '_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][priority]', $pagepriority);
|
41 |
+
$select_frequency = $metaseo_sitemap->wpms_view_select_frequency('frequency_pages_' . $page->ID, '_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][frequency]', $pagefrequency);
|
42 |
echo '<div class="wpms_row">';
|
43 |
echo '<div style="float:left;line-height:30px">';
|
44 |
+
if (isset($metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['post_id']) && $metaseo_sitemap->settings_sitemap['wpms_sitemap_pages'][$page->ID]['post_id'] == $page->ID) {
|
|
|
45 |
echo '<input class="cb_sitemaps_pages wpms_xmap_pages" name="_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][post_id]" checked type="checkbox" value="' . $page->ID . '">';
|
46 |
} else {
|
47 |
echo '<input class="cb_sitemaps_pages wpms_xmap_pages" name="_metaseo_settings_sitemap[wpms_sitemap_pages][' . $page->ID . '][post_id]" type="checkbox" value="' . $page->ID . '">';
|
inc/pages/sitemaps/metaseo-source_posts.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
|
10 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
11 |
<?php _e('Public name' , 'wp-meta-seo'); ?>
|
12 |
-
<input type="text" class="public_name_posts" value="<?php echo
|
13 |
</div>
|
14 |
|
15 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
@@ -45,13 +45,21 @@
|
|
45 |
foreach ($post as $p) {
|
46 |
$category = get_the_terms($p, $keys[2]);
|
47 |
if($category[0]->term_id == $keys[1]){
|
48 |
-
$
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
echo '<div class="wpms_row">';
|
51 |
echo '<div style="float:left;line-height:30px">';
|
52 |
-
|
53 |
-
|
54 |
-
if (isset($metaseo_sitemap->settings_sitemap['wpms_sitemap_posts']->{$p->ID}->post_id) && $metaseo_sitemap->settings_sitemap['wpms_sitemap_posts']->{$p->ID}->post_id == $p->ID) {
|
55 |
echo '<input class="cb_sitemaps_posts wpms_xmap_posts '.$keys[2].$keys[3].'" name="_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][post_id]" checked type="checkbox" value="' . $p->ID . '">';
|
56 |
} else {
|
57 |
echo '<input class="cb_sitemaps_posts wpms_xmap_posts '.$keys[2].$keys[3].'" name="_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][post_id]" type="checkbox" value="' . $p->ID . '">';
|
9 |
|
10 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
11 |
<?php _e('Public name' , 'wp-meta-seo'); ?>
|
12 |
+
<input type="text" class="public_name_posts" value="<?php echo $metaseo_sitemap->settings_sitemap['wpms_public_name_posts'] ?>">
|
13 |
</div>
|
14 |
|
15 |
<div class="div_sitemap_check_all" style="font-weight: bold;">
|
45 |
foreach ($post as $p) {
|
46 |
$category = get_the_terms($p, $keys[2]);
|
47 |
if($category[0]->term_id == $keys[1]){
|
48 |
+
if(empty($metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['frequency'])){
|
49 |
+
$postfrequency = 'monthly';
|
50 |
+
}else{
|
51 |
+
$postfrequency = $metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['frequency'];
|
52 |
+
}
|
53 |
+
if(empty($metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['priority'])){
|
54 |
+
$postpriority = '1.0';
|
55 |
+
}else{
|
56 |
+
$postpriority = $metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['priority'];
|
57 |
+
}
|
58 |
+
$select_priority = $metaseo_sitemap->wpms_view_select_priority('priority_posts_'.$p->ID,'_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][priority]', $postpriority);
|
59 |
+
$select_frequency = $metaseo_sitemap->wpms_view_select_frequency('frequency_posts_'.$p->ID,'_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][frequency]', $postfrequency);
|
60 |
echo '<div class="wpms_row">';
|
61 |
echo '<div style="float:left;line-height:30px">';
|
62 |
+
if (isset($metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['post_id']) && $metaseo_sitemap->settings_sitemap['wpms_sitemap_posts'][$p->ID]['post_id'] == $p->ID) {
|
|
|
|
|
63 |
echo '<input class="cb_sitemaps_posts wpms_xmap_posts '.$keys[2].$keys[3].'" name="_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][post_id]" checked type="checkbox" value="' . $p->ID . '">';
|
64 |
} else {
|
65 |
echo '<input class="cb_sitemaps_posts wpms_xmap_posts '.$keys[2].$keys[3].'" name="_metaseo_settings_sitemap[wpms_sitemap_posts][' . $p->ID . '][post_id]" type="checkbox" value="' . $p->ID . '">';
|
js/cliffpyles.js
CHANGED
@@ -5,13 +5,13 @@ jQuery(document).ready(function ($) {
|
|
5 |
var aProgress = document.getElementById('activeProgress');
|
6 |
var iProgressCTX = iProgress.getContext('2d');
|
7 |
var mcheck = 0;
|
8 |
-
if(typeof wpmscliffpyles.use_validate != "undefined" && wpmscliffpyles.use_validate == 1){
|
9 |
wpms_validate_analysis();
|
10 |
}
|
11 |
-
|
12 |
-
|
13 |
-
jQuery('#reload_analysis').on('click',function(){
|
14 |
-
$('.wpmseotab .spinner').css({'visibility':' inherit'}).show();
|
15 |
$('.metaseo_right').html('');
|
16 |
var title = $('#title').val();
|
17 |
var meta_title = $('#metaseo_wpmseo_title').val();
|
@@ -22,18 +22,18 @@ jQuery(document).ready(function ($) {
|
|
22 |
if (typeof tinyMCE !== 'undefined' && tinyMCE.get('content') !== null) {
|
23 |
mcontent = tinyMCE.editors.content.getContent();
|
24 |
}
|
25 |
-
|
26 |
-
var data = {'post_id': jQuery('.metaseo-progress-bar').data('post_id'),'title':title
|
27 |
$.ajax({
|
28 |
-
dataType
|
29 |
-
method
|
30 |
-
url
|
31 |
data: {
|
32 |
-
'action':'metaseo_reload_analysis',
|
33 |
'datas': data
|
34 |
},
|
35 |
-
success: function(res){
|
36 |
-
if(res != false){
|
37 |
$('.wpmseotab .spinner').hide();
|
38 |
$('.metaseo_right').html(res.output);
|
39 |
mcheck = res.check;
|
@@ -58,11 +58,11 @@ jQuery(document).ready(function ($) {
|
|
58 |
delay: 100
|
59 |
}
|
60 |
|
61 |
-
});
|
62 |
}
|
63 |
}
|
64 |
});
|
65 |
-
|
66 |
drawInactive(iProgressCTX);
|
67 |
});
|
68 |
|
@@ -72,7 +72,7 @@ jQuery(document).ready(function ($) {
|
|
72 |
var percentage = $(this).val() / 100;
|
73 |
drawProgress(aProgress, percentage, $pCaption);
|
74 |
});
|
75 |
-
|
76 |
function drawInactive(iProgressCTX) {
|
77 |
iProgressCTX.lineCap = 'square';
|
78 |
|
@@ -118,29 +118,29 @@ jQuery(document).ready(function ($) {
|
|
118 |
|
119 |
var percentage = $pc.val() / 100;
|
120 |
drawProgress(aProgress, percentage, $pCaption);
|
121 |
-
|
122 |
function wpms_validate_analysis() {
|
123 |
-
jQuery(document).on('click', '.metaseo-dashicons.icons-mwarning', function(event) {
|
124 |
var $this = $(this);
|
125 |
jQuery(this).removeClass('icons-mwarning').addClass('dashicons-yes');
|
126 |
-
if(mcheck == 0){
|
127 |
mcheck = jQuery('#metaseo_alanysis_ok').val();
|
128 |
mcheck++;
|
129 |
-
}else{
|
130 |
mcheck++;
|
131 |
}
|
132 |
-
var circliful = Math.ceil((mcheck*100)/7);
|
133 |
jQuery.ajax({
|
134 |
-
dataType
|
135 |
-
method
|
136 |
-
url
|
137 |
data: {
|
138 |
'action': 'metaseo_validate_analysis',
|
139 |
-
'post_id'
|
140 |
-
'field'
|
141 |
},
|
142 |
-
success: function(res){
|
143 |
-
if(res != false){
|
144 |
$('#progressController').val(circliful).change();
|
145 |
}
|
146 |
}
|
5 |
var aProgress = document.getElementById('activeProgress');
|
6 |
var iProgressCTX = iProgress.getContext('2d');
|
7 |
var mcheck = 0;
|
8 |
+
if (typeof wpmscliffpyles.use_validate != "undefined" && wpmscliffpyles.use_validate == 1) {
|
9 |
wpms_validate_analysis();
|
10 |
}
|
11 |
+
|
12 |
+
|
13 |
+
jQuery('#reload_analysis').on('click', function () {
|
14 |
+
$('.wpmseotab .spinner').css({'visibility': ' inherit'}).show();
|
15 |
$('.metaseo_right').html('');
|
16 |
var title = $('#title').val();
|
17 |
var meta_title = $('#metaseo_wpmseo_title').val();
|
22 |
if (typeof tinyMCE !== 'undefined' && tinyMCE.get('content') !== null) {
|
23 |
mcontent = tinyMCE.editors.content.getContent();
|
24 |
}
|
25 |
+
|
26 |
+
var data = {'post_id': jQuery('.metaseo-progress-bar').data('post_id'), 'title': title, 'meta_title': meta_title, 'mpageurl': mpageurl, 'meta_desc': meta_desc, 'content': mcontent};
|
27 |
$.ajax({
|
28 |
+
dataType: 'json',
|
29 |
+
method: 'POST',
|
30 |
+
url: ajaxurl,
|
31 |
data: {
|
32 |
+
'action': 'metaseo_reload_analysis',
|
33 |
'datas': data
|
34 |
},
|
35 |
+
success: function (res) {
|
36 |
+
if (res != false) {
|
37 |
$('.wpmseotab .spinner').hide();
|
38 |
$('.metaseo_right').html(res.output);
|
39 |
mcheck = res.check;
|
58 |
delay: 100
|
59 |
}
|
60 |
|
61 |
+
});
|
62 |
}
|
63 |
}
|
64 |
});
|
65 |
+
|
66 |
drawInactive(iProgressCTX);
|
67 |
});
|
68 |
|
72 |
var percentage = $(this).val() / 100;
|
73 |
drawProgress(aProgress, percentage, $pCaption);
|
74 |
});
|
75 |
+
|
76 |
function drawInactive(iProgressCTX) {
|
77 |
iProgressCTX.lineCap = 'square';
|
78 |
|
118 |
|
119 |
var percentage = $pc.val() / 100;
|
120 |
drawProgress(aProgress, percentage, $pCaption);
|
121 |
+
|
122 |
function wpms_validate_analysis() {
|
123 |
+
jQuery(document).on('click', '.metaseo-dashicons.icons-mwarning', function (event) {
|
124 |
var $this = $(this);
|
125 |
jQuery(this).removeClass('icons-mwarning').addClass('dashicons-yes');
|
126 |
+
if (mcheck == 0) {
|
127 |
mcheck = jQuery('#metaseo_alanysis_ok').val();
|
128 |
mcheck++;
|
129 |
+
} else {
|
130 |
mcheck++;
|
131 |
}
|
132 |
+
var circliful = Math.ceil((mcheck * 100) / 7);
|
133 |
jQuery.ajax({
|
134 |
+
dataType: 'json',
|
135 |
+
method: 'POST',
|
136 |
+
url: ajaxurl,
|
137 |
data: {
|
138 |
'action': 'metaseo_validate_analysis',
|
139 |
+
'post_id': jQuery('.metaseo-progress-bar').data('post_id'),
|
140 |
+
'field': $this.parent('.metaseo_analysis').data('title'),
|
141 |
},
|
142 |
+
success: function (res) {
|
143 |
+
if (res != false) {
|
144 |
$('#progressController').val(circliful).change();
|
145 |
}
|
146 |
}
|
js/dashboard.js
CHANGED
@@ -32,7 +32,7 @@ jQuery(document).ready(function ($) {
|
|
32 |
fgColor: '#fff',
|
33 |
inputColor: '#fff'
|
34 |
});
|
35 |
-
|
36 |
jQuery('.metaseo_tool').qtip({
|
37 |
content: {
|
38 |
attr: 'alt'
|
@@ -53,8 +53,8 @@ jQuery(document).ready(function ($) {
|
|
53 |
delay: 10
|
54 |
}
|
55 |
|
56 |
-
});
|
57 |
-
|
58 |
jQuery('.metaseo_tool-000').qtip({
|
59 |
content: {
|
60 |
attr: 'alt'
|
@@ -75,6 +75,6 @@ jQuery(document).ready(function ($) {
|
|
75 |
delay: 10
|
76 |
}
|
77 |
|
78 |
-
});
|
79 |
|
80 |
});
|
32 |
fgColor: '#fff',
|
33 |
inputColor: '#fff'
|
34 |
});
|
35 |
+
|
36 |
jQuery('.metaseo_tool').qtip({
|
37 |
content: {
|
38 |
attr: 'alt'
|
53 |
delay: 10
|
54 |
}
|
55 |
|
56 |
+
});
|
57 |
+
|
58 |
jQuery('.metaseo_tool-000').qtip({
|
59 |
content: {
|
60 |
attr: 'alt'
|
75 |
delay: 10
|
76 |
}
|
77 |
|
78 |
+
});
|
79 |
|
80 |
});
|
js/metaseo_admin.js
CHANGED
@@ -22,36 +22,35 @@ function metaseo_clean(str) {
|
|
22 |
return str;
|
23 |
}
|
24 |
|
25 |
-
var oldTitleValues = {};
|
26 |
-
var oldKeywordsValues = {};
|
27 |
-
var oldDescValues = {};
|
28 |
var metaContentChangeWait;
|
29 |
|
30 |
function metaseo_titlelength(metatitle_id, needToSave, updateSnippet) {
|
31 |
var title = jQuery.trim(metaseo_clean(jQuery('#' + metatitle_id).val()));
|
32 |
var postid = metatitle_id.replace('metaseo-metatitle-', '');
|
33 |
var counter_id = 'metaseo-metatitle-len' + postid;
|
34 |
-
jQuery('#' + counter_id).text(title_max_len-title.length);
|
35 |
if (title.length >= title_max_len) {
|
36 |
jQuery('#' + counter_id).addClass('word-exceed');//#FEFB04
|
37 |
-
}
|
38 |
-
else {
|
39 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
40 |
}
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
}
|
49 |
}
|
50 |
|
51 |
function metaseo_updateTitle(metatitle_id, needToSave, updateSnippet) {
|
52 |
var title = jQuery.trim(metaseo_clean(jQuery('#' + metatitle_id).val()));
|
53 |
var postid = metatitle_id.replace('metaseo-metatitle-', '');
|
54 |
-
if (needToSave === true && oldTitleValues[postid] != title
|
55 |
saveMetaContentChanges('metatitle', postid, title);
|
56 |
}
|
57 |
|
@@ -62,14 +61,13 @@ function metaseo_updateTitle(metatitle_id, needToSave, updateSnippet) {
|
|
62 |
function metaseo_keywordlength(metakeywords_id, needToSave, updateSnippet) {
|
63 |
var keywords = jQuery.trim(metaseo_clean(jQuery('#' + metakeywords_id).val()));
|
64 |
var postid = metakeywords_id.replace('metaseo-metakeywords-', '');
|
65 |
-
|
66 |
var counter_id = 'metaseo-metakeywords-len' + postid;
|
67 |
-
jQuery('#' + counter_id).text(keywords_max_len-keywords.length);
|
68 |
|
69 |
if (keywords.length >= keywords_max_len) {
|
70 |
jQuery('#' + counter_id).addClass('word-exceed');
|
71 |
-
}
|
72 |
-
else {
|
73 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
74 |
}
|
75 |
}
|
@@ -77,104 +75,104 @@ function metaseo_keywordlength(metakeywords_id, needToSave, updateSnippet) {
|
|
77 |
function metaseo_updatekeywords(metakeywords_id, needToSave, updateSnippet) {
|
78 |
var keywords = jQuery.trim(metaseo_clean(jQuery('#' + metakeywords_id).val()));
|
79 |
var postid = metakeywords_id.replace('metaseo-metakeywords-', '');
|
80 |
-
if (needToSave === true && oldKeywordsValues[postid] != keywords
|
81 |
saveMetaContentChanges('metakeywords', postid, keywords);
|
82 |
}
|
83 |
-
|
84 |
//Push the new value into the array
|
85 |
oldKeywordsValues[postid] = keywords;
|
86 |
}
|
87 |
|
88 |
-
function saveMetaLinkChanges(button_update){
|
89 |
var link_id = jQuery(button_update).closest('tr').data('link');
|
90 |
var meta_title = jQuery(button_update).closest('tr').find('.metaseo_link_title').val();
|
91 |
meta_title = jQuery.trim(metaseo_clean(meta_title));
|
92 |
jQuery.ajax({
|
93 |
-
url
|
94 |
-
method
|
95 |
dataType: 'json',
|
96 |
data: {
|
97 |
-
'action'
|
98 |
-
'link_id'
|
99 |
-
'meta_title'
|
100 |
},
|
101 |
success: function (response) {
|
102 |
jQuery(button_update).closest('tr').find('.wpms_update_link').hide();
|
103 |
-
if(response != false){
|
104 |
jQuery(button_update).closest('tr').find('.wpms_old_link').val(response.link_new).change();
|
105 |
jQuery(button_update).closest('tr').find('.wpms_mesage_link').show().fadeIn(3000).delay(200).fadeOut(3000);
|
106 |
-
}else{
|
107 |
jQuery(button_update).closest('tr').find('.wpms_error_mesage_link').show().fadeIn(3000).delay(200).fadeOut(3000);
|
108 |
}
|
109 |
-
|
110 |
}
|
111 |
});
|
112 |
}
|
113 |
|
114 |
-
function metaseo_update_pageindex(page_id,index){
|
115 |
jQuery.ajax({
|
116 |
-
url
|
117 |
-
method
|
118 |
dataType: 'json',
|
119 |
data: {
|
120 |
-
'action'
|
121 |
-
'page_id'
|
122 |
-
'index'
|
123 |
},
|
124 |
success: function (response) {
|
125 |
-
|
126 |
}
|
127 |
});
|
128 |
}
|
129 |
|
130 |
-
function metaseo_update_pagefollow(page_id,follow){
|
131 |
jQuery.ajax({
|
132 |
-
url
|
133 |
-
method
|
134 |
dataType: 'json',
|
135 |
data: {
|
136 |
-
'action'
|
137 |
-
'page_id'
|
138 |
-
'follow'
|
139 |
},
|
140 |
success: function (response) {
|
141 |
-
|
142 |
}
|
143 |
});
|
144 |
}
|
145 |
|
146 |
-
function wpmsChangeFollow(button){
|
147 |
var link_id = jQuery(button).closest('tr').data('link');
|
148 |
var type = jQuery(button).data('type');
|
149 |
var follow = 1;
|
150 |
-
if(type == 'done'){
|
151 |
-
jQuery(button).data('type','warning').html('warning');
|
152 |
jQuery(button).removeClass('wpms_ok').addClass('wpms_warning');
|
153 |
follow = 0;
|
154 |
-
}else{
|
155 |
-
jQuery(button).data('type','done').html('done');
|
156 |
jQuery(button).removeClass('wpms_warning').addClass('wpms_ok');
|
157 |
follow = 1;
|
158 |
}
|
159 |
-
|
160 |
jQuery.ajax({
|
161 |
-
url
|
162 |
-
method
|
163 |
dataType: 'json',
|
164 |
data: {
|
165 |
-
'action'
|
166 |
-
'link_id'
|
167 |
-
'follow'
|
168 |
},
|
169 |
success: function (response) {
|
170 |
-
|
171 |
}
|
172 |
});
|
173 |
}
|
174 |
|
175 |
-
function wpms_scan_link($this){
|
176 |
-
if($this.hasClass('page_link_meta')){
|
177 |
-
jQuery('.spinner_apply_follow').css('visibility','visible').show();
|
178 |
}
|
179 |
jQuery.ajax({
|
180 |
url: ajaxurl,
|
@@ -182,43 +180,48 @@ function wpms_scan_link($this){
|
|
182 |
dataType: 'json',
|
183 |
data: {
|
184 |
'action': 'wpms_scan_link',
|
185 |
-
'paged'
|
186 |
-
'comment_paged'
|
187 |
},
|
188 |
success: function (res) {
|
189 |
-
if(res.status == false){
|
190 |
|
191 |
-
if(res.type == 'limit'){
|
192 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
193 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
194 |
-
if(wpmf_process_new > 100)
|
195 |
-
|
196 |
-
jQuery('.wpmf_process').
|
|
|
197 |
$this.click();
|
198 |
-
}else if(res.type == 'limit_comment_content'){
|
199 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
200 |
-
if(wpmf_process < 33.33
|
|
|
201 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
202 |
-
if(wpmf_process_new > 100)
|
203 |
-
|
204 |
-
jQuery('.wpmf_process').
|
205 |
-
|
|
|
206 |
$this.click();
|
207 |
-
}else{
|
208 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
209 |
-
if(wpmf_process < 66.66
|
|
|
210 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
211 |
-
if(wpmf_process_new > 100)
|
212 |
-
|
213 |
-
jQuery('.wpmf_process').
|
214 |
-
|
|
|
215 |
$this.click();
|
216 |
}
|
217 |
-
}else{
|
218 |
-
jQuery('.wpmf_process').data('w'
|
219 |
-
jQuery('.wpmf_process').css('width'
|
220 |
jQuery('#wp-seo-meta-form .spinner').hide();
|
221 |
-
if($this.hasClass('page_link_meta')){
|
222 |
jQuery('.spinner_apply_follow').hide();
|
223 |
}
|
224 |
window.location.assign(document.URL);
|
@@ -227,11 +230,11 @@ function wpms_scan_link($this){
|
|
227 |
});
|
228 |
}
|
229 |
|
230 |
-
function wpmsUpdateFollow(button){
|
231 |
var $this = jQuery(button);
|
232 |
-
jQuery('.spinner_apply_follow').css('visibility','visible').show();
|
233 |
var follow_value = jQuery('.metaseo_follow_action').val();
|
234 |
-
if(follow_value == 'follow_selected' || follow_value == 'nofollow_selected'){
|
235 |
if (follow_value == 0)
|
236 |
return;
|
237 |
|
@@ -241,30 +244,31 @@ function wpmsUpdateFollow(button){
|
|
241 |
link_selected.push(jQuery(this).val());
|
242 |
}
|
243 |
});
|
244 |
-
if(link_selected.length == 0)
|
|
|
245 |
var data = {
|
246 |
-
action
|
247 |
-
linkids
|
248 |
-
follow_value
|
249 |
};
|
250 |
-
}else{
|
251 |
var data = {
|
252 |
-
action
|
253 |
-
follow_value
|
254 |
};
|
255 |
}
|
256 |
jQuery.ajax({
|
257 |
-
url
|
258 |
-
method
|
259 |
-
dataType
|
260 |
-
data
|
261 |
success: function (response) {
|
262 |
-
if(response.status == true){
|
263 |
jQuery('.spinner_apply_follow').hide();
|
264 |
window.location.assign(document.URL);
|
265 |
-
}else{
|
266 |
-
if(follow_value == 'follow_all' || follow_value == 'nofollow_all'){
|
267 |
-
if(response.message == 'limit'){
|
268 |
$this.click();
|
269 |
}
|
270 |
}
|
@@ -277,16 +281,15 @@ function metaseo_desclength(metadesc_id, needToSave) {
|
|
277 |
var desc = jQuery.trim(metaseo_clean(jQuery('#' + metadesc_id).val()));
|
278 |
var postid = metadesc_id.replace('metaseo-metadesc-', '');
|
279 |
var counter_id = 'metaseo-metadesc-len' + postid;
|
280 |
-
jQuery('#' + counter_id).text(desc_max_len-desc.length);
|
281 |
|
282 |
if (desc.length >= desc_max_len) {
|
283 |
jQuery('#' + counter_id).addClass('word-exceed');
|
284 |
-
}
|
285 |
-
else {
|
286 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
287 |
}
|
288 |
|
289 |
-
jQuery('#snippet_desc' + postid).text(desc.substr(0, desc_max_len)
|
290 |
}
|
291 |
|
292 |
|
@@ -303,7 +306,7 @@ function metaseo_updateDesc(metadesc_id, needToSave) {
|
|
303 |
|
304 |
var autosaveNotification;
|
305 |
function saveMetaContentChanges(metakey, postid, data) {
|
306 |
-
|
307 |
var postData = {
|
308 |
'action': 'updateContentMeta',
|
309 |
'metakey': metakey,
|
@@ -311,12 +314,12 @@ function saveMetaContentChanges(metakey, postid, data) {
|
|
311 |
'value': data
|
312 |
};
|
313 |
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
|
314 |
-
jQuery.post(myAjax.ajax_url, postData, function(response) {
|
315 |
jQuery('.wpms_loader' + postid).hide();
|
316 |
result = jQuery.parseJSON(response);
|
317 |
-
|
318 |
if (result.updated == true) {
|
319 |
-
autosaveNotification = setTimeout(function() {
|
320 |
jQuery('#savedInfo' + postid).text(result.msg);
|
321 |
jQuery('#savedInfo' + postid).fadeIn(200).delay(2000).fadeOut(1000);
|
322 |
}, 1000);
|
@@ -329,18 +332,18 @@ function saveMetaContentChanges(metakey, postid, data) {
|
|
329 |
|
330 |
}
|
331 |
|
332 |
-
function checkspecial(element_id){
|
333 |
-
var element = jQuery(element_id);
|
334 |
var meta_type = element.data('meta-type');
|
335 |
-
|
336 |
-
if(meta_type=='change_image_name'){
|
337 |
var str = (element.val());
|
338 |
-
if(
|
339 |
return false;
|
340 |
-
}else{
|
341 |
-
|
342 |
}
|
343 |
-
}else{
|
344 |
return true;
|
345 |
}
|
346 |
}
|
@@ -354,662 +357,658 @@ function metaseo_update(element_id) {
|
|
354 |
}
|
355 |
|
356 |
function saveChanges(element_id, post_id, meta_type, meta_value) {
|
357 |
-
|
358 |
var element = jQuery(element_id);
|
359 |
var savedInfo = element.parent().find('span.saved-info');
|
360 |
-
if(savedInfo.length < 1) {
|
|
|
|
|
361 |
var updated = false;
|
362 |
var postData = {
|
363 |
'action': 'updateMeta',
|
364 |
'post_id': post_id,
|
365 |
'meta_type': meta_type,
|
366 |
-
'meta_value':meta_value,
|
367 |
-
'addition'
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
};
|
376 |
-
|
377 |
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
|
378 |
jQuery.ajax({
|
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 |
return updated;
|
437 |
}
|
438 |
|
439 |
//Scan all posts to find a group of images in their content
|
440 |
-
|
441 |
-
|
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 |
-
|
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 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
//Import meta data from other plugin into Wp Meta Seo
|
739 |
-
function importMetaData(that, event){
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
//Update once input changed and blur
|
776 |
-
function updateInputBlur(that){
|
777 |
-
var element = jQuery(that);
|
778 |
var post_id = element.data('post-id');
|
779 |
var meta_type = element.data('meta-type');
|
780 |
var meta_value = element.val();
|
781 |
-
if(saveChanges(that, post_id, meta_type, meta_value)){
|
782 |
-
if(meta_type === 'change_image_name'){
|
783 |
-
|
784 |
}
|
785 |
}
|
786 |
-
|
787 |
|
788 |
-
function checkeyCode(event,that){
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
}
|
793 |
|
794 |
/**
|
795 |
* Check if a name is existed
|
796 |
*/
|
797 |
-
function is_existed(iname){
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
}
|
806 |
|
807 |
/**
|
808 |
* Check if a image name is valid or not
|
809 |
*/
|
810 |
-
function validateiName(iname){
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
}
|
822 |
|
823 |
-
jQuery(document).ready(function($) {
|
824 |
-
|
825 |
//Cursor changes on any ajax start and end
|
826 |
//Thanks to iambriansreed from stacoverflow.com
|
827 |
-
$('body').ajaxStart(function() {
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
$('span.pagination-links a.disabled').click(function(e) {
|
834 |
e.preventDefault();
|
835 |
});
|
836 |
-
|
837 |
-
$('.metaseo_imgs_per_page').bind('input propertychange', function(){
|
838 |
var perpage = $(this).val();
|
839 |
-
$('.metaseo_imgs_per_page').each(function(i,e){
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
});
|
844 |
});
|
845 |
-
|
846 |
-
$('.metaseo_link_source').bind('change', function(){
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
});
|
854 |
-
|
855 |
-
$('.metaseo_follow_action').bind('change', function(){
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
});
|
863 |
|
864 |
-
$('.metaseo-filter').bind('change', function(){
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
});
|
872 |
|
873 |
-
$('.redirect_fillter').bind('change', function(){
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
});
|
881 |
|
882 |
-
$('.broken_fillter').bind('change', function(){
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
});
|
890 |
|
891 |
-
$('.mbulk_copy').bind('change', function(){
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
});
|
899 |
-
|
900 |
-
$('.metaseo-img-name').bind('input propertychange', function() {
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
});
|
919 |
-
|
920 |
-
$('.metaseo-img-meta').each(function(i, element){
|
921 |
-
if($(this).hasClass('metaseo-img-name')){
|
922 |
-
metaseoValueHolder[this.id+'_prev'] = jQuery(this).val();
|
923 |
-
}
|
924 |
-
$(element).bind('keydown', function(event){
|
925 |
-
if(event.which == 13 || event.keyCode == 13){
|
926 |
-
return false;
|
927 |
-
}
|
928 |
-
});
|
929 |
});
|
930 |
-
|
931 |
-
$('.metaseo-img-meta').
|
932 |
-
|
933 |
-
|
934 |
-
$(this).parent().find('span.saved-info').empty().append('<span style="position:absolute" class="meta-update"></span>');
|
935 |
-
}
|
936 |
-
if(checkspecial(this) === true){
|
937 |
-
updateInputBlur(this);
|
938 |
}
|
|
|
|
|
|
|
|
|
|
|
939 |
});
|
940 |
|
941 |
-
$('.
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
if(plugin === '_aio_' || plugin === '_yoast_'){
|
951 |
-
$.ajax({
|
952 |
-
url: myAjax.ajax_url,
|
953 |
-
type: 'post',
|
954 |
-
data: {'action': 'dismiss_import_meta', 'plugin' : plugin},
|
955 |
-
dataType: 'json',
|
956 |
-
beforeSend: function(){
|
957 |
-
|
958 |
-
},
|
959 |
-
success: function(response){
|
960 |
-
if(response.success !== true){
|
961 |
-
alert('Dismiss failed!');
|
962 |
-
}
|
963 |
-
}
|
964 |
-
});
|
965 |
-
}
|
966 |
});
|
967 |
-
|
968 |
-
$('.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
969 |
var page_id = $(this).data('post_id');
|
970 |
var follow = $(this).val();
|
971 |
-
metaseo_update_pagefollow(page_id,follow);
|
972 |
});
|
973 |
-
|
974 |
-
$('.metaseo_metabox_index').on('change',function(){
|
975 |
var page_id = $(this).data('post_id');
|
976 |
var index = $(this).val();
|
977 |
-
metaseo_update_pageindex(page_id,index);
|
978 |
});
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
this.each(function() {
|
983 |
var top = -($(this).outerHeight() / 2) + 'px';
|
984 |
var left = -($(this).outerWidth() / 2) + 'px';
|
985 |
$(this).css({'position': 'fixed', 'top': $('div.wrap').offset().top, 'left': $('div.wrap').offset().left, 'right': '25px', 'bottom': '10px'});
|
986 |
-
|
987 |
return this;
|
988 |
});
|
989 |
};
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
var obj = that.closest('.col_image_info').find('div.popup');
|
994 |
var btnClose = obj.find('.popup-close');
|
995 |
bg.animate({opacity: 0.2}, 0).fadeIn(200);
|
996 |
-
//obj.fadeIn(200).draggable({cursor: 'move', handle: '.popup-header'}).absoluteCenter();
|
997 |
obj.fadeIn(200).absoluteCenter();
|
998 |
-
btnClose.click(function() {
|
999 |
bg.fadeOut(100);
|
1000 |
obj.fadeOut(100).find('div.popup-content').empty();
|
1001 |
});
|
1002 |
-
bg.click(function() {
|
1003 |
btnClose.click();
|
1004 |
});
|
1005 |
-
$(document).keydown(function(e) {
|
1006 |
if (e.keyCode == 27) {
|
1007 |
btnClose.click();
|
1008 |
}
|
1009 |
});
|
1010 |
return false;
|
1011 |
-
|
1012 |
-
$('a.show-popup').bind('click', function() {
|
1013 |
$(this).showPopup($(this));
|
1014 |
});
|
1015 |
});
|
22 |
return str;
|
23 |
}
|
24 |
|
25 |
+
var oldTitleValues = {};
|
26 |
+
var oldKeywordsValues = {};
|
27 |
+
var oldDescValues = {};
|
28 |
var metaContentChangeWait;
|
29 |
|
30 |
function metaseo_titlelength(metatitle_id, needToSave, updateSnippet) {
|
31 |
var title = jQuery.trim(metaseo_clean(jQuery('#' + metatitle_id).val()));
|
32 |
var postid = metatitle_id.replace('metaseo-metatitle-', '');
|
33 |
var counter_id = 'metaseo-metatitle-len' + postid;
|
34 |
+
jQuery('#' + counter_id).text(title_max_len - title.length);
|
35 |
if (title.length >= title_max_len) {
|
36 |
jQuery('#' + counter_id).addClass('word-exceed');//#FEFB04
|
37 |
+
} else {
|
|
|
38 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
39 |
}
|
40 |
+
|
41 |
+
if (title.length > title_max_len) {
|
42 |
+
jQuery('#snippet_title' + postid).empty().text(title.substr(0, title_max_len));
|
43 |
+
}
|
44 |
+
|
45 |
+
if (typeof updateSnippet == "undefined" || updateSnippet !== false) {
|
46 |
+
jQuery('#snippet_title' + postid).text(title.substr(0, title_max_len));
|
47 |
}
|
48 |
}
|
49 |
|
50 |
function metaseo_updateTitle(metatitle_id, needToSave, updateSnippet) {
|
51 |
var title = jQuery.trim(metaseo_clean(jQuery('#' + metatitle_id).val()));
|
52 |
var postid = metatitle_id.replace('metaseo-metatitle-', '');
|
53 |
+
if (needToSave === true && oldTitleValues[postid] != title) {
|
54 |
saveMetaContentChanges('metatitle', postid, title);
|
55 |
}
|
56 |
|
61 |
function metaseo_keywordlength(metakeywords_id, needToSave, updateSnippet) {
|
62 |
var keywords = jQuery.trim(metaseo_clean(jQuery('#' + metakeywords_id).val()));
|
63 |
var postid = metakeywords_id.replace('metaseo-metakeywords-', '');
|
64 |
+
|
65 |
var counter_id = 'metaseo-metakeywords-len' + postid;
|
66 |
+
jQuery('#' + counter_id).text(keywords_max_len - keywords.length);
|
67 |
|
68 |
if (keywords.length >= keywords_max_len) {
|
69 |
jQuery('#' + counter_id).addClass('word-exceed');
|
70 |
+
} else {
|
|
|
71 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
72 |
}
|
73 |
}
|
75 |
function metaseo_updatekeywords(metakeywords_id, needToSave, updateSnippet) {
|
76 |
var keywords = jQuery.trim(metaseo_clean(jQuery('#' + metakeywords_id).val()));
|
77 |
var postid = metakeywords_id.replace('metaseo-metakeywords-', '');
|
78 |
+
if (needToSave === true && oldKeywordsValues[postid] != keywords) {
|
79 |
saveMetaContentChanges('metakeywords', postid, keywords);
|
80 |
}
|
81 |
+
|
82 |
//Push the new value into the array
|
83 |
oldKeywordsValues[postid] = keywords;
|
84 |
}
|
85 |
|
86 |
+
function saveMetaLinkChanges(button_update) {
|
87 |
var link_id = jQuery(button_update).closest('tr').data('link');
|
88 |
var meta_title = jQuery(button_update).closest('tr').find('.metaseo_link_title').val();
|
89 |
meta_title = jQuery.trim(metaseo_clean(meta_title));
|
90 |
jQuery.ajax({
|
91 |
+
url: ajaxurl,
|
92 |
+
method: 'POST',
|
93 |
dataType: 'json',
|
94 |
data: {
|
95 |
+
'action': 'metaseo_update_link',
|
96 |
+
'link_id': link_id,
|
97 |
+
'meta_title': meta_title,
|
98 |
},
|
99 |
success: function (response) {
|
100 |
jQuery(button_update).closest('tr').find('.wpms_update_link').hide();
|
101 |
+
if (response != false) {
|
102 |
jQuery(button_update).closest('tr').find('.wpms_old_link').val(response.link_new).change();
|
103 |
jQuery(button_update).closest('tr').find('.wpms_mesage_link').show().fadeIn(3000).delay(200).fadeOut(3000);
|
104 |
+
} else {
|
105 |
jQuery(button_update).closest('tr').find('.wpms_error_mesage_link').show().fadeIn(3000).delay(200).fadeOut(3000);
|
106 |
}
|
107 |
+
|
108 |
}
|
109 |
});
|
110 |
}
|
111 |
|
112 |
+
function metaseo_update_pageindex(page_id, index) {
|
113 |
jQuery.ajax({
|
114 |
+
url: ajaxurl,
|
115 |
+
method: 'POST',
|
116 |
dataType: 'json',
|
117 |
data: {
|
118 |
+
'action': 'metaseo_update_pageindex',
|
119 |
+
'page_id': page_id,
|
120 |
+
'index': index,
|
121 |
},
|
122 |
success: function (response) {
|
123 |
+
|
124 |
}
|
125 |
});
|
126 |
}
|
127 |
|
128 |
+
function metaseo_update_pagefollow(page_id, follow) {
|
129 |
jQuery.ajax({
|
130 |
+
url: ajaxurl,
|
131 |
+
method: 'POST',
|
132 |
dataType: 'json',
|
133 |
data: {
|
134 |
+
'action': 'metaseo_update_pagefollow',
|
135 |
+
'page_id': page_id,
|
136 |
+
'follow': follow,
|
137 |
},
|
138 |
success: function (response) {
|
139 |
+
|
140 |
}
|
141 |
});
|
142 |
}
|
143 |
|
144 |
+
function wpmsChangeFollow(button) {
|
145 |
var link_id = jQuery(button).closest('tr').data('link');
|
146 |
var type = jQuery(button).data('type');
|
147 |
var follow = 1;
|
148 |
+
if (type == 'done') {
|
149 |
+
jQuery(button).data('type', 'warning').html('warning');
|
150 |
jQuery(button).removeClass('wpms_ok').addClass('wpms_warning');
|
151 |
follow = 0;
|
152 |
+
} else {
|
153 |
+
jQuery(button).data('type', 'done').html('done');
|
154 |
jQuery(button).removeClass('wpms_warning').addClass('wpms_ok');
|
155 |
follow = 1;
|
156 |
}
|
157 |
+
|
158 |
jQuery.ajax({
|
159 |
+
url: ajaxurl,
|
160 |
+
method: 'POST',
|
161 |
dataType: 'json',
|
162 |
data: {
|
163 |
+
'action': 'metaseo_update_follow',
|
164 |
+
'link_id': link_id,
|
165 |
+
'follow': follow,
|
166 |
},
|
167 |
success: function (response) {
|
168 |
+
|
169 |
}
|
170 |
});
|
171 |
}
|
172 |
|
173 |
+
function wpms_scan_link($this) {
|
174 |
+
if ($this.hasClass('page_link_meta')) {
|
175 |
+
jQuery('.spinner_apply_follow').css('visibility', 'visible').show();
|
176 |
}
|
177 |
jQuery.ajax({
|
178 |
url: ajaxurl,
|
180 |
dataType: 'json',
|
181 |
data: {
|
182 |
'action': 'wpms_scan_link',
|
183 |
+
'paged': $this.data('paged'),
|
184 |
+
'comment_paged': $this.data('comment_paged')
|
185 |
},
|
186 |
success: function (res) {
|
187 |
+
if (res.status == false) {
|
188 |
|
189 |
+
if (res.type == 'limit') {
|
190 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
191 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
192 |
+
if (wpmf_process_new > 100)
|
193 |
+
wpmf_process_new = 100;
|
194 |
+
jQuery('.wpmf_process').data('w', wpmf_process_new);
|
195 |
+
jQuery('.wpmf_process').css('width', wpmf_process_new + '%').show();
|
196 |
$this.click();
|
197 |
+
} else if (res.type == 'limit_comment_content') {
|
198 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
199 |
+
if (wpmf_process < 33.33)
|
200 |
+
wpmf_process = 33.33;
|
201 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
202 |
+
if (wpmf_process_new > 100)
|
203 |
+
wpmf_process_new = 100;
|
204 |
+
jQuery('.wpmf_process').data('w', wpmf_process_new);
|
205 |
+
jQuery('.wpmf_process').css('width', wpmf_process_new + '%').show();
|
206 |
+
$this.data('comment_paged', parseInt(res.paged) + 1);
|
207 |
$this.click();
|
208 |
+
} else {
|
209 |
var wpmf_process = jQuery('.wpmf_process').data('w');
|
210 |
+
if (wpmf_process < 66.66)
|
211 |
+
wpmf_process = 66.66;
|
212 |
var wpmf_process_new = parseFloat(wpmf_process) + parseFloat(res.percent);
|
213 |
+
if (wpmf_process_new > 100)
|
214 |
+
wpmf_process_new = 100;
|
215 |
+
jQuery('.wpmf_process').data('w', wpmf_process_new);
|
216 |
+
jQuery('.wpmf_process').css('width', wpmf_process_new + '%').show();
|
217 |
+
$this.data('paged', parseInt(res.paged) + 1);
|
218 |
$this.click();
|
219 |
}
|
220 |
+
} else {
|
221 |
+
jQuery('.wpmf_process').data('w', 100);
|
222 |
+
jQuery('.wpmf_process').css('width', '100%');
|
223 |
jQuery('#wp-seo-meta-form .spinner').hide();
|
224 |
+
if ($this.hasClass('page_link_meta')) {
|
225 |
jQuery('.spinner_apply_follow').hide();
|
226 |
}
|
227 |
window.location.assign(document.URL);
|
230 |
});
|
231 |
}
|
232 |
|
233 |
+
function wpmsUpdateFollow(button) {
|
234 |
var $this = jQuery(button);
|
235 |
+
jQuery('.spinner_apply_follow').css('visibility', 'visible').show();
|
236 |
var follow_value = jQuery('.metaseo_follow_action').val();
|
237 |
+
if (follow_value == 'follow_selected' || follow_value == 'nofollow_selected') {
|
238 |
if (follow_value == 0)
|
239 |
return;
|
240 |
|
244 |
link_selected.push(jQuery(this).val());
|
245 |
}
|
246 |
});
|
247 |
+
if (link_selected.length == 0)
|
248 |
+
return;
|
249 |
var data = {
|
250 |
+
action: 'metaseo_update_multiplefollow',
|
251 |
+
linkids: link_selected,
|
252 |
+
follow_value: follow_value
|
253 |
};
|
254 |
+
} else {
|
255 |
var data = {
|
256 |
+
action: 'metaseo_update_multiplefollow',
|
257 |
+
follow_value: follow_value
|
258 |
};
|
259 |
}
|
260 |
jQuery.ajax({
|
261 |
+
url: ajaxurl,
|
262 |
+
method: 'POST',
|
263 |
+
dataType: 'json',
|
264 |
+
data: data,
|
265 |
success: function (response) {
|
266 |
+
if (response.status == true) {
|
267 |
jQuery('.spinner_apply_follow').hide();
|
268 |
window.location.assign(document.URL);
|
269 |
+
} else {
|
270 |
+
if (follow_value == 'follow_all' || follow_value == 'nofollow_all') {
|
271 |
+
if (response.message == 'limit') {
|
272 |
$this.click();
|
273 |
}
|
274 |
}
|
281 |
var desc = jQuery.trim(metaseo_clean(jQuery('#' + metadesc_id).val()));
|
282 |
var postid = metadesc_id.replace('metaseo-metadesc-', '');
|
283 |
var counter_id = 'metaseo-metadesc-len' + postid;
|
284 |
+
jQuery('#' + counter_id).text(desc_max_len - desc.length);
|
285 |
|
286 |
if (desc.length >= desc_max_len) {
|
287 |
jQuery('#' + counter_id).addClass('word-exceed');
|
288 |
+
} else {
|
|
|
289 |
jQuery('#' + counter_id).removeClass('word-exceed');
|
290 |
}
|
291 |
|
292 |
+
jQuery('#snippet_desc' + postid).text(desc.substr(0, desc_max_len));
|
293 |
}
|
294 |
|
295 |
|
306 |
|
307 |
var autosaveNotification;
|
308 |
function saveMetaContentChanges(metakey, postid, data) {
|
309 |
+
jQuery('.wpms_loader' + postid).show();
|
310 |
var postData = {
|
311 |
'action': 'updateContentMeta',
|
312 |
'metakey': metakey,
|
314 |
'value': data
|
315 |
};
|
316 |
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
|
317 |
+
jQuery.post(myAjax.ajax_url, postData, function (response) {
|
318 |
jQuery('.wpms_loader' + postid).hide();
|
319 |
result = jQuery.parseJSON(response);
|
320 |
+
|
321 |
if (result.updated == true) {
|
322 |
+
autosaveNotification = setTimeout(function () {
|
323 |
jQuery('#savedInfo' + postid).text(result.msg);
|
324 |
jQuery('#savedInfo' + postid).fadeIn(200).delay(2000).fadeOut(1000);
|
325 |
}, 1000);
|
332 |
|
333 |
}
|
334 |
|
335 |
+
function checkspecial(element_id) {
|
336 |
+
var element = jQuery(element_id);
|
337 |
var meta_type = element.data('meta-type');
|
338 |
+
|
339 |
+
if (meta_type == 'change_image_name') {
|
340 |
var str = (element.val());
|
341 |
+
if (/^[\w\d\-\s+_.$]*$/.test(str) == false) {
|
342 |
return false;
|
343 |
+
} else {
|
344 |
+
return true;
|
345 |
}
|
346 |
+
} else {
|
347 |
return true;
|
348 |
}
|
349 |
}
|
357 |
}
|
358 |
|
359 |
function saveChanges(element_id, post_id, meta_type, meta_value) {
|
360 |
+
|
361 |
var element = jQuery(element_id);
|
362 |
var savedInfo = element.parent().find('span.saved-info');
|
363 |
+
if (savedInfo.length < 1) {
|
364 |
+
savedInfo = element.closest('td').find('span.saved-info');
|
365 |
+
}
|
366 |
var updated = false;
|
367 |
var postData = {
|
368 |
'action': 'updateMeta',
|
369 |
'post_id': post_id,
|
370 |
'meta_type': meta_type,
|
371 |
+
'meta_value': meta_value,
|
372 |
+
'addition': {
|
373 |
+
'meta_key': element.data('meta-key'),
|
374 |
+
'meta_type': element.data('meta-type'),
|
375 |
+
'meta_value': element.val(),
|
376 |
+
'meta_order': element.data('meta-order'),
|
377 |
+
'img_post_id': element.data('img-post-id'),
|
378 |
+
'post_id': element.data('post-id'),
|
379 |
+
}
|
380 |
};
|
381 |
+
|
382 |
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
|
383 |
jQuery.ajax({
|
384 |
+
url: myAjax.ajax_url,
|
385 |
+
async: false,
|
386 |
+
type: 'post',
|
387 |
+
data: postData,
|
388 |
+
dataType: 'json',
|
389 |
+
beforeSend: function () {
|
390 |
+
savedInfo.empty().append('<span style="position:absolute" class="meta-update"></span>');
|
391 |
+
element.parent().find('span.meta-update').addClass('update-loader').fadeIn(300);
|
392 |
+
},
|
393 |
+
success: function (response) {
|
394 |
+
if (response == 0) {
|
395 |
+
saveChanges(element_id, post_id, meta_type, meta_value);
|
396 |
+
}
|
397 |
+
|
398 |
+
updated = response.updated;
|
399 |
+
|
400 |
+
if (updated == true) {
|
401 |
+
autosaveNotification = setTimeout(function () {
|
402 |
+
element.parent().find('span.meta-update').removeClass('update-loader');
|
403 |
+
savedInfo.removeClass('metaseo-msg-warning').addClass('metaseo-msg-success')
|
404 |
+
.text(response.msg).fadeIn(200);
|
405 |
+
|
406 |
+
setTimeout(function () {
|
407 |
+
savedInfo.empty().append('<span class="meta-update" style="position:absolute"></span>');
|
408 |
+
}, 3000);
|
409 |
+
|
410 |
+
}, 200);
|
411 |
+
|
412 |
+
//update image's data-name attribute
|
413 |
+
if (typeof element.data('extension') != 'undefined') {
|
414 |
+
jQuery('[data-img-post-id="' + element.data('post-id') + '"]').data('name', element.val() + element.data('extension'));
|
415 |
+
}
|
416 |
+
//Scan post and update post_meta
|
417 |
+
var img = jQuery('[data-img-post-id="' + postData['addition']['img_post_id'] + '"]');
|
418 |
+
|
419 |
+
if (img.length > 0) {
|
420 |
+
_metaSeoScanImages(
|
421 |
+
|
422 |
+
{
|
423 |
+
'name': img.data('name'),
|
424 |
+
'img_post_id': postData['addition']['img_post_id']
|
425 |
+
}
|
426 |
+
|
427 |
+
);
|
428 |
+
}
|
429 |
+
|
430 |
+
} else {
|
431 |
+
element.val(response.iname);
|
432 |
+
savedInfo.removeClass('metaseo-msg-success').addClass('metaseo-msg-warning')
|
433 |
+
.text(response.msg).fadeIn(200).delay(2000).fadeOut(200);
|
434 |
+
}
|
435 |
+
},
|
436 |
+
error: function () {
|
437 |
+
|
438 |
+
}
|
439 |
+
});
|
440 |
+
|
441 |
return updated;
|
442 |
}
|
443 |
|
444 |
//Scan all posts to find a group of images in their content
|
445 |
+
function metaSeoScanImages() {
|
446 |
+
var imgs = [];
|
447 |
+
jQuery('.metaseo-image').each(function (i) {
|
448 |
+
if (jQuery(this).data('name') != '') {
|
449 |
+
imgs[i] = {
|
450 |
+
'name': jQuery(this).data('name'),
|
451 |
+
'img_post_id': jQuery(this).data('img-post-id')
|
452 |
+
};
|
453 |
+
}
|
454 |
+
});
|
455 |
+
|
456 |
+
jQuery.each(imgs,function(i,v){
|
457 |
+
_metaSeoScanImages(v);
|
458 |
+
});
|
459 |
+
|
460 |
+
}
|
461 |
+
|
462 |
+
function _metaSeoScanImages(imgs) {
|
463 |
+
if (imgs.length < 1) {
|
464 |
+
//alert('No images choosen for scanning, please check again!');
|
465 |
+
return false;
|
466 |
+
}
|
467 |
+
|
468 |
+
jQuery.ajax({
|
469 |
+
url: myAjax.ajax_url,
|
470 |
+
method: 'post',
|
471 |
+
data: {'action': 'scanPosts', 'imgs': imgs},
|
472 |
+
dataType: 'json',
|
473 |
+
beforeSend: function () {},
|
474 |
+
success: function (response) {
|
475 |
+
if (response == 0) {
|
476 |
+
_metaSeoScanImages(imgs);
|
477 |
+
}
|
478 |
+
//clog(imgs);
|
479 |
+
if (response.success === true) {
|
480 |
+
//Clear content holder first
|
481 |
+
if (imgs.length === 1) {
|
482 |
+
jQuery('#opt-info-' + imgs[0]['img_post_id']).removeClass('opt-info-warning').empty();
|
483 |
+
}
|
484 |
+
|
485 |
+
//id is refered to image post id
|
486 |
+
for (var iID in response.msg) {
|
487 |
+
jQuery('#opt-info-' + iID).html(null);
|
488 |
+
//Change css position property of td tag to default
|
489 |
+
jQuery('#opt-info-' + iID).parent().css('position', 'static');
|
490 |
+
jQuery('#opt-info-' + iID).append('<p class="btn-wrapper"></p>');
|
491 |
+
|
492 |
+
for (var msgType in response.msg[iID]) {
|
493 |
+
if (response.msg[iID][msgType]['warning'] == true
|
494 |
+
&& !jQuery('#opt-info-' + iID).hasClass('opt-info-warning')) {
|
495 |
+
jQuery('#opt-info-' + iID).addClass('opt-info-warning');
|
496 |
+
}
|
497 |
+
|
498 |
+
jQuery('#opt-info-' + iID).find('p.btn-wrapper').append(response.msg[iID][msgType]['button']);
|
499 |
+
if (typeof response.msg[iID][msgType]['msg'] != 'object') {
|
500 |
+
var hlight = !response.msg[iID][msgType]['warning'] ? 'metaseo-msg-success' : '';
|
501 |
+
jQuery('#opt-info-' + iID).prepend('<p class="' + hlight + '">' + response.msg[iID][msgType]['msg'] + '</p>');
|
502 |
+
} else {
|
503 |
+
for (var k in response.msg[iID][msgType]['msg']) {
|
504 |
+
jQuery('#opt-info-' + iID).prepend('<p>' + response.msg[iID][msgType]['msg'][k] + '</p>');
|
505 |
+
}
|
506 |
+
}
|
507 |
+
}
|
508 |
+
jQuery('#opt-info-' + iID).parent().find('span.metaseo-loading').hide();
|
509 |
+
}
|
510 |
+
|
511 |
+
|
512 |
+
//jQuery('span.metaseo-loading').hide();
|
513 |
+
jQuery('.opt-info-warning').fadeIn(200);
|
514 |
+
jQuery('input.metaseo-checkin').each(function (i, input) {
|
515 |
+
uncheck(input);
|
516 |
+
});
|
517 |
+
}
|
518 |
+
},
|
519 |
+
error: function () {
|
520 |
+
// alert('Errors occured while scanning posts for optimization');
|
521 |
+
}
|
522 |
+
});
|
523 |
+
}
|
524 |
+
|
525 |
+
//To fix meta of a specified image
|
526 |
+
function metaseo_fix_meta(that) {
|
527 |
+
var $this = jQuery(that);
|
528 |
+
|
529 |
+
if (checkspecial(that) === true) {
|
530 |
+
|
531 |
+
if (that.jquery === undefined) {
|
532 |
+
$this.bind('input propertychange', function () {
|
533 |
+
metaseo_update(that);
|
534 |
+
});
|
535 |
+
} else {
|
536 |
+
metaseo_update(that);
|
537 |
+
}
|
538 |
+
|
539 |
+
}
|
540 |
+
}
|
541 |
+
|
542 |
+
function add_meta_default(that) {
|
543 |
+
var $this = jQuery(that);
|
544 |
+
var input = $this.parent().find('input');
|
545 |
+
var id = input.attr('id');
|
546 |
+
|
547 |
+
input.val($this.data('default-value')).focus();
|
548 |
+
}
|
549 |
+
//--------------------------------
|
550 |
+
//Optimize a single post
|
551 |
+
function optimize_imgs(element) {
|
552 |
+
var $this = jQuery(element);
|
553 |
+
var post_id = $this.data('post-id');
|
554 |
+
var img_post_id = $this.data('img-post-id');
|
555 |
+
var checkin = jQuery('.checkin-' + post_id);
|
556 |
+
var img_exclude = [];
|
557 |
+
var not_checked_counter = 0;
|
558 |
+
var updated = false;
|
559 |
+
|
560 |
+
var j = 0;
|
561 |
+
checkin.each(function (i, el) {
|
562 |
+
if (!(jQuery(el).is(':checked'))) {
|
563 |
+
not_checked_counter++;
|
564 |
+
if (jQuery(el).val() != '' || jQuery(el).val() != 'undefined') {
|
565 |
+
img_exclude[j] = parseInt(jQuery(el).val());
|
566 |
+
j++;
|
567 |
+
}
|
568 |
+
}
|
569 |
+
});
|
570 |
+
|
571 |
+
if (checkin.length <= not_checked_counter) {
|
572 |
+
//alert('No images has choosen. \\nPlease click on the checkbox in what image you want to replace!');
|
573 |
+
return false;
|
574 |
+
}
|
575 |
+
|
576 |
+
if (!post_id && !img_post_id) {
|
577 |
+
alert('Cant do the optimization because of missing image ID.\\nPlease check again!');
|
578 |
+
} else {
|
579 |
+
jQuery.ajax({
|
580 |
+
url: myAjax.ajax_url,
|
581 |
+
async: false,
|
582 |
+
data: {
|
583 |
+
'action': 'optimize_imgs',
|
584 |
+
'post_id': post_id,
|
585 |
+
'img_post_id': img_post_id,
|
586 |
+
'img_exclude': img_exclude
|
587 |
+
},
|
588 |
+
dataType: 'json',
|
589 |
+
type: 'post',
|
590 |
+
beforeSend: function () {
|
591 |
+
$this.parent().find('span.spinner').show();
|
592 |
+
},
|
593 |
+
success: function (response) {
|
594 |
+
if (response == 0) {
|
595 |
+
optimize_imgs(element);
|
596 |
+
}
|
597 |
+
|
598 |
+
if (response.success) {
|
599 |
+
updated = true;
|
600 |
+
|
601 |
+
checkin.each(function (i, e) {
|
602 |
+
if (jQuery.inArray(parseInt(jQuery(this).val()), img_exclude) == -1) {
|
603 |
+
|
604 |
+
var img_choosen = jQuery(this).parent();
|
605 |
+
jQuery(this).remove();
|
606 |
+
|
607 |
+
img_choosen.empty().append('<span class="metaseo-checked"></span>');
|
608 |
+
img_choosen.parent().find('p.metaseo-msg').removeClass('msg-error').addClass('msg-success').empty().text(response.msg).fadeIn(200);
|
609 |
+
setTimeout(function () {
|
610 |
+
img_choosen.find('p.metaseo-msg').fadeOut(300);
|
611 |
+
}, 5000);
|
612 |
+
|
613 |
+
}
|
614 |
+
});
|
615 |
+
|
616 |
+
var checked = jQuery('.checkin-' + post_id);
|
617 |
+
if (checked.length == 0) {
|
618 |
+
$this.addClass('disabled');
|
619 |
+
}
|
620 |
+
|
621 |
+
$this.parent().find('span.spinner').fadeOut(300);
|
622 |
+
//Disable Replace all button if all image were resized
|
623 |
+
var metaseo_checkin = jQuery('.metaseo-checkin');
|
624 |
+
|
625 |
+
if (metaseo_checkin.length == 0) {
|
626 |
+
jQuery('#metaseo-replace-all').addClass('disabled');
|
627 |
+
}
|
628 |
+
//Scan post and update post_meta
|
629 |
+
var img = jQuery('[data-img-post-id="' + img_post_id + '"]');
|
630 |
+
_metaSeoScanImages({'name': img.data('name'), 'img_post_id': img_post_id});
|
631 |
+
|
632 |
+
} else {
|
633 |
+
$this.parent().find('span.spinner').hide();
|
634 |
+
$this.parent().find('p.metaseo-msg').removeClass('msg-success').addClass('msg-error');
|
635 |
+
}
|
636 |
+
|
637 |
+
},
|
638 |
+
error: function () {
|
639 |
+
|
640 |
+
}
|
641 |
+
});
|
642 |
+
}
|
643 |
+
|
644 |
+
img_exclude = [];
|
645 |
+
return updated;
|
646 |
+
}
|
647 |
+
|
648 |
+
//Optimize all posts in list displayed
|
649 |
+
function optimize_imgs_group(that) {
|
650 |
+
jQuery('a.metaseo-optimize').each(function (i, el) {
|
651 |
+
if (i == 0) {
|
652 |
+
jQuery(that).parent().find('span.spinner').show();
|
653 |
+
}
|
654 |
+
|
655 |
+
jQuery(this).click();
|
656 |
+
|
657 |
+
if (i == (jQuery(el).length - 1)) {
|
658 |
+
jQuery(that).parent().find('span.spinner').hide();
|
659 |
+
}
|
660 |
+
});
|
661 |
+
|
662 |
+
}
|
663 |
+
|
664 |
+
function uncheck(that) {
|
665 |
+
var $this = jQuery(that);
|
666 |
+
var post_id = that.className.substr(that.className.lastIndexOf('-') + 1);
|
667 |
+
var checked = jQuery('.checkin-' + post_id);
|
668 |
+
var not_checked_counter = 0;
|
669 |
+
|
670 |
+
checked.each(function (i, e) {
|
671 |
+
if (!(jQuery(this).is(':checked'))) {
|
672 |
+
not_checked_counter++;
|
673 |
+
}
|
674 |
+
});
|
675 |
+
|
676 |
+
//Toggle disable Replace button if all images in a post were resized
|
677 |
+
if (not_checked_counter >= checked.length) {
|
678 |
+
jQuery('a.metaseo-optimize[data-post-id="' + post_id + '"]').addClass('disabled');
|
679 |
+
} else {
|
680 |
+
jQuery('a.metaseo-optimize[data-post-id="' + post_id + '"]').removeClass('disabled');
|
681 |
+
}
|
682 |
+
|
683 |
+
//Toggle disable Replace all button if all images in posts were resized
|
684 |
+
var replaceBtns = jQuery('.metaseo-optimize');
|
685 |
+
var disable = true;
|
686 |
+
replaceBtns.each(function (i, btn) {
|
687 |
+
if (!jQuery(btn).hasClass('disabled')) {
|
688 |
+
disable = false;
|
689 |
+
return;
|
690 |
+
}
|
691 |
+
});
|
692 |
+
|
693 |
+
if (disable === true) {
|
694 |
+
jQuery('#metaseo-replace-all').addClass('disabled');
|
695 |
+
} else {
|
696 |
+
jQuery('#metaseo-replace-all').removeClass('disabled');
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
//Show posts list for resizing or update meta info of an image with specified id
|
701 |
+
function showPostsList(element) {
|
702 |
+
var that = jQuery(element);
|
703 |
+
var data = {
|
704 |
+
'action': 'load_posts',
|
705 |
+
'img_name': that.data('img-name'),
|
706 |
+
'post_id': that.data('post-id'),
|
707 |
+
'opt_key': that.data('opt-key')
|
708 |
+
};
|
709 |
+
|
710 |
+
if (that.data('img-name') != '') {
|
711 |
+
jQuery.ajax({
|
712 |
+
url: myAjax.ajax_url,
|
713 |
+
type: 'post',
|
714 |
+
dataType: 'html',
|
715 |
+
data: data,
|
716 |
+
beforeSend: function () {
|
717 |
+
that.find('.spinner-light').show();
|
718 |
+
},
|
719 |
+
success: function (response) {
|
720 |
+
if (response == 0) {
|
721 |
+
showPostsList(element);
|
722 |
+
}
|
723 |
+
that.parent().find('.spinner-light').hide();
|
724 |
+
that.closest('td.col_image_info').find('div.popup > .popup-content').empty().html(response).fadeIn(300);
|
725 |
+
|
726 |
+
//to set background-color of popup-header to like adminmenu active
|
727 |
+
var metaseo_bg = jQuery('#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu').css('background-color');
|
728 |
+
|
729 |
+
if (metaseo_bg !== 'undified') {
|
730 |
+
jQuery('.popup-content .content-header').css({'background-color': metaseo_bg, 'color': '#FFF'});
|
731 |
+
jQuery('span.popup-close').css({'color': '#FFF'});
|
732 |
+
}
|
733 |
+
|
734 |
+
that.showPopup(that);
|
735 |
+
}
|
736 |
+
});
|
737 |
+
} else {
|
738 |
+
alert('Something went wrong, please check Image name if it\'s empty before click Resize button');
|
739 |
+
}
|
740 |
+
}
|
741 |
+
|
|
|
742 |
//Import meta data from other plugin into Wp Meta Seo
|
743 |
+
function importMetaData(that, event) {
|
744 |
+
var plugin = that.id;
|
745 |
+
var element = jQuery('#' + that.id);
|
746 |
+
|
747 |
+
event.preventDefault();
|
748 |
+
if (that.id === '_aio_' || that.id === '_yoast_') {
|
749 |
+
jQuery.ajax({
|
750 |
+
url: myAjax.ajax_url,
|
751 |
+
type: 'post',
|
752 |
+
data: {'action': 'import_meta_data', 'plugin': that.id},
|
753 |
+
dataType: 'json',
|
754 |
+
beforeSend: function () {
|
755 |
+
element.find('span.spinner-light').show();
|
756 |
+
},
|
757 |
+
success: function (response) {
|
758 |
+
if (response.success == true) {
|
759 |
+
element.find('span.spinner-light').fadeOut(500);
|
760 |
+
jQuery('.metaseo-import-wrn').closest('.error').fadeOut(1500);
|
761 |
+
//Refresh the page to see al changed after import Yoast or AIO data into MetaSEO
|
762 |
+
if (location.href.search('page=metaseo_content_meta') != -1) {
|
763 |
+
location.reload();
|
764 |
+
}
|
765 |
+
}
|
766 |
+
},
|
767 |
+
error: function () {
|
768 |
+
alert('Something went wrong in import processing!');
|
769 |
+
}
|
770 |
+
|
771 |
+
});
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
//Update once input changed and blur
|
776 |
+
function updateInputBlur(that) {
|
777 |
+
var element = jQuery(that);
|
|
|
|
|
|
|
|
|
778 |
var post_id = element.data('post-id');
|
779 |
var meta_type = element.data('meta-type');
|
780 |
var meta_value = element.val();
|
781 |
+
if (saveChanges(that, post_id, meta_type, meta_value)) {
|
782 |
+
if (meta_type === 'change_image_name') {
|
783 |
+
jQuery('a.img-resize[data-post-id="' + post_id + '"]').data('img-name', meta_value);
|
784 |
}
|
785 |
}
|
786 |
+
}
|
787 |
|
788 |
+
function checkeyCode(event, that) {
|
789 |
+
if (event.which == 13 || event.keyCode == 13) {
|
790 |
+
return false;
|
791 |
+
}
|
792 |
}
|
793 |
|
794 |
/**
|
795 |
* Check if a name is existed
|
796 |
*/
|
797 |
+
function is_existed(iname) {
|
798 |
+
jQuery.each(metaseoValueHolder, function (i, iName) {
|
799 |
+
for (var id in iName) {
|
800 |
+
if (typeof iName[id + '_prev'] != 'undefined' && iname == iName[id + '_prev']) {
|
801 |
+
return true;
|
802 |
+
}
|
803 |
+
}
|
804 |
+
});
|
805 |
}
|
806 |
|
807 |
/**
|
808 |
* Check if a image name is valid or not
|
809 |
*/
|
810 |
+
function validateiName(iname) {
|
811 |
+
var is_only_spaces = iname.length > 0 ? true : false;
|
812 |
+
iname = iname.trim();
|
813 |
+
var msg = '';
|
814 |
+
|
815 |
+
if (iname.length < 1) {
|
816 |
+
msg = !is_only_spaces ? 'Should not be empty' : 'Should not only spaces';
|
817 |
+
return {msg: msg, name: ''};
|
818 |
+
}
|
819 |
+
|
820 |
+
return {msg: '', name: iname};
|
821 |
}
|
822 |
|
823 |
+
jQuery(document).ready(function ($) {
|
824 |
+
|
825 |
//Cursor changes on any ajax start and end
|
826 |
//Thanks to iambriansreed from stacoverflow.com
|
827 |
+
$('body').ajaxStart(function () {
|
828 |
+
$(this).css({'cursor': 'wait'});
|
829 |
+
}).ajaxStop(function () {
|
830 |
+
$(this).css({'cursor': 'default'});
|
831 |
+
});
|
832 |
+
|
833 |
+
$('span.pagination-links a.disabled').click(function (e) {
|
834 |
e.preventDefault();
|
835 |
});
|
836 |
+
|
837 |
+
$('.metaseo_imgs_per_page').bind('input propertychange', function () {
|
838 |
var perpage = $(this).val();
|
839 |
+
$('.metaseo_imgs_per_page').each(function (i, e) {
|
840 |
+
if ($(e).val() != perpage) {
|
841 |
+
$(e).val(perpage);
|
842 |
+
}
|
843 |
});
|
844 |
});
|
845 |
+
|
846 |
+
$('.metaseo_link_source').bind('change', function () {
|
847 |
+
var value = $(this).val();
|
848 |
+
$('.metaseo_link_source').each(function (i, e) {
|
849 |
+
if ($(e).val() != value) {
|
850 |
+
$(e).val(value);
|
851 |
+
}
|
852 |
+
});
|
853 |
});
|
854 |
+
|
855 |
+
$('.metaseo_follow_action').bind('change', function () {
|
856 |
+
var value = $(this).val();
|
857 |
+
$('.metaseo_follow_action').each(function (i, e) {
|
858 |
+
if ($(e).val() != value) {
|
859 |
+
$(e).val(value);
|
860 |
+
}
|
861 |
+
});
|
862 |
});
|
863 |
|
864 |
+
$('.metaseo-filter').bind('change', function () {
|
865 |
+
var value = $(this).val();
|
866 |
+
$('.metaseo-filter').each(function (i, e) {
|
867 |
+
if ($(e).val() != value) {
|
868 |
+
$(e).val(value);
|
869 |
+
}
|
870 |
+
});
|
871 |
});
|
872 |
|
873 |
+
$('.redirect_fillter').bind('change', function () {
|
874 |
+
var value = $(this).val();
|
875 |
+
$('.redirect_fillter').each(function (i, e) {
|
876 |
+
if ($(e).val() != value) {
|
877 |
+
$(e).val(value);
|
878 |
+
}
|
879 |
+
});
|
880 |
});
|
881 |
|
882 |
+
$('.broken_fillter').bind('change', function () {
|
883 |
+
var value = $(this).val();
|
884 |
+
$('.broken_fillter').each(function (i, e) {
|
885 |
+
if ($(e).val() != value) {
|
886 |
+
$(e).val(value);
|
887 |
+
}
|
888 |
+
});
|
889 |
});
|
890 |
|
891 |
+
$('.mbulk_copy').bind('change', function () {
|
892 |
+
var value = $(this).val();
|
893 |
+
$('.mbulk_copy').each(function (i, e) {
|
894 |
+
if ($(e).val() != value) {
|
895 |
+
$(e).val(value);
|
896 |
+
}
|
897 |
+
});
|
898 |
});
|
899 |
+
|
900 |
+
$('.metaseo-img-name').bind('input propertychange', function () {
|
901 |
+
var savedInfo = $(this).parent().find('span.saved-info');
|
902 |
+
var iname = validateiName($(this).val());
|
903 |
+
var msg = iname.msg;
|
904 |
+
|
905 |
+
if (iname.name.length > 0) {
|
906 |
+
if (!checkspecial(this)) {
|
907 |
+
msg = 'Should not special char';
|
908 |
+
}
|
909 |
+
}
|
910 |
+
|
911 |
+
if (msg.length > 0) {
|
912 |
+
//Set this value to metaseoValueHolder
|
913 |
+
metaseoValueHolder[this.id] = iname.name.substr(0, iname.name.length - 1);
|
914 |
+
|
915 |
+
savedInfo.removeClass('metaseo-msg-success')
|
916 |
+
.addClass('metaseo-msg-warning').empty().text(msg);
|
917 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
918 |
});
|
919 |
+
|
920 |
+
$('.metaseo-img-meta').each(function (i, element) {
|
921 |
+
if ($(this).hasClass('metaseo-img-name')) {
|
922 |
+
metaseoValueHolder[this.id + '_prev'] = jQuery(this).val();
|
|
|
|
|
|
|
|
|
923 |
}
|
924 |
+
$(element).bind('keydown', function (event) {
|
925 |
+
if (event.which == 13 || event.keyCode == 13) {
|
926 |
+
return false;
|
927 |
+
}
|
928 |
+
});
|
929 |
});
|
930 |
|
931 |
+
$('.metaseo-img-meta').blur(function () {
|
932 |
+
if (jQuery(this).val() == '') {
|
933 |
+
jQuery(this).val(metaseoValueHolder[this.id + '_prev']);
|
934 |
+
$(this).parent().find('span.saved-info').empty().append('<span style="position:absolute" class="meta-update"></span>');
|
935 |
+
}
|
936 |
+
if (checkspecial(this) === true) {
|
937 |
+
updateInputBlur(this);
|
938 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
939 |
});
|
940 |
+
|
941 |
+
$('.dissmiss-import').bind('click', function (e) {
|
942 |
+
e.preventDefault();
|
943 |
+
$(this).closest('.error').fadeOut(1000);
|
944 |
+
setTimeout(function () {
|
945 |
+
$(this).closest('.error').remove();
|
946 |
+
}, 5000);
|
947 |
+
|
948 |
+
var plugin = $(this).parent().find('a.button').attr('id');
|
949 |
+
|
950 |
+
if (plugin === '_aio_' || plugin === '_yoast_') {
|
951 |
+
$.ajax({
|
952 |
+
url: myAjax.ajax_url,
|
953 |
+
type: 'post',
|
954 |
+
data: {'action': 'dismiss_import_meta', 'plugin': plugin},
|
955 |
+
dataType: 'json',
|
956 |
+
beforeSend: function () {
|
957 |
+
|
958 |
+
},
|
959 |
+
success: function (response) {
|
960 |
+
if (response.success !== true) {
|
961 |
+
alert('Dismiss failed!');
|
962 |
+
}
|
963 |
+
}
|
964 |
+
});
|
965 |
+
}
|
966 |
+
});
|
967 |
+
|
968 |
+
$('.metaseo_metabox_follow').on('change', function () {
|
969 |
var page_id = $(this).data('post_id');
|
970 |
var follow = $(this).val();
|
971 |
+
metaseo_update_pagefollow(page_id, follow);
|
972 |
});
|
973 |
+
|
974 |
+
$('.metaseo_metabox_index').on('change', function () {
|
975 |
var page_id = $(this).data('post_id');
|
976 |
var index = $(this).val();
|
977 |
+
metaseo_update_pageindex(page_id, index);
|
978 |
});
|
979 |
+
//----------------------------------------------------------
|
980 |
+
//Pop-up declaration
|
981 |
+
$.fn.absoluteCenter = function () {
|
982 |
+
this.each(function () {
|
983 |
var top = -($(this).outerHeight() / 2) + 'px';
|
984 |
var left = -($(this).outerWidth() / 2) + 'px';
|
985 |
$(this).css({'position': 'fixed', 'top': $('div.wrap').offset().top, 'left': $('div.wrap').offset().left, 'right': '25px', 'bottom': '10px'});
|
986 |
+
|
987 |
return this;
|
988 |
});
|
989 |
};
|
990 |
+
|
991 |
+
$.fn.showPopup = function (that) {
|
992 |
+
var bg = $('div.popup-bg');
|
993 |
var obj = that.closest('.col_image_info').find('div.popup');
|
994 |
var btnClose = obj.find('.popup-close');
|
995 |
bg.animate({opacity: 0.2}, 0).fadeIn(200);
|
|
|
996 |
obj.fadeIn(200).absoluteCenter();
|
997 |
+
btnClose.click(function () {
|
998 |
bg.fadeOut(100);
|
999 |
obj.fadeOut(100).find('div.popup-content').empty();
|
1000 |
});
|
1001 |
+
bg.click(function () {
|
1002 |
btnClose.click();
|
1003 |
});
|
1004 |
+
$(document).keydown(function (e) {
|
1005 |
if (e.keyCode == 27) {
|
1006 |
btnClose.click();
|
1007 |
}
|
1008 |
});
|
1009 |
return false;
|
1010 |
+
};
|
1011 |
+
$('a.show-popup').bind('click', function () {
|
1012 |
$(this).showPopup($(this));
|
1013 |
});
|
1014 |
});
|
js/metaseo_sitemap.js
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
-
(function($){
|
2 |
-
$(document).ready(function(){
|
|
|
|
|
|
|
3 |
$(".holder_posts").jPages({
|
4 |
containerID: "wrap_sitemap_option_posts",
|
5 |
previous: "←",
|
@@ -8,6 +11,9 @@
|
|
8 |
delay: 20
|
9 |
});
|
10 |
|
|
|
|
|
|
|
11 |
$(".holder_pages").jPages({
|
12 |
containerID: "wrap_sitemap_option_pages",
|
13 |
previous: "←",
|
@@ -16,6 +22,9 @@
|
|
16 |
delay: 20
|
17 |
});
|
18 |
|
|
|
|
|
|
|
19 |
jQuery('.wpms_source_sitemaps tr label,.wpms_row h3 input').qtip({
|
20 |
content: {
|
21 |
attr: 'for'
|
@@ -36,163 +45,163 @@
|
|
36 |
delay: 10
|
37 |
}
|
38 |
|
39 |
-
});
|
40 |
-
|
41 |
-
$('.wpms_save_create_sitemaps').on('click',function(){
|
42 |
wpms_save_create_sitemaps();
|
43 |
});
|
44 |
|
45 |
-
wpms_save_create_sitemaps = function(){
|
46 |
-
$('.spinner_save_sitemaps').css({'visibility':'visible'}).show();
|
47 |
-
var posts = {}
|
48 |
-
$(".wpms_xmap_posts").each(function(i,v){
|
49 |
-
if($(v).is(':checked')){
|
50 |
var id = $(v).val();
|
51 |
-
var priority = $('#priority_posts_'+id).val();
|
52 |
-
var frequency = $('#frequency_posts_'+id).val();
|
53 |
-
posts[id] = {'post_id':id
|
54 |
}
|
55 |
});
|
56 |
-
|
57 |
-
$(".wpms_xmap_pages").each(function(i,v){
|
58 |
-
if($(v).is(':checked')){
|
59 |
var id = $(v).val();
|
60 |
-
var priority = $('#priority_pages_'+id).val();
|
61 |
-
var frequency = $('#frequency_pages_'+id).val();
|
62 |
-
pages[id] = {'post_id':id
|
63 |
}
|
64 |
});
|
65 |
-
|
66 |
-
$(".wpms_xmap_menu").each(function(i,v){
|
67 |
-
if($(v).is(':checked')){
|
68 |
var id = $(v).val();
|
69 |
-
var priority = $('#priority_menu_'+id).val();
|
70 |
-
var frequency = $('#frequency_menu_'+id).val();
|
71 |
-
menus[id] = {'menu_id':id
|
72 |
}
|
73 |
});
|
74 |
-
|
75 |
-
$('.wpms_sitemap_taxonomies').each(function(i,v){
|
76 |
-
if($(v).is(':checked')){
|
77 |
taxonomies.push($(v).val());
|
78 |
}
|
79 |
});
|
80 |
-
|
81 |
-
$('.sitemap_addlink_categories').each(function(i,v){
|
82 |
-
if($(v).is(':checked')){
|
83 |
wpms_category_link.push($(v).val());
|
84 |
}
|
85 |
});
|
86 |
-
|
87 |
-
if($('#wpms_sitemap_author').is(':checked')){
|
88 |
var wpms_sitemap_author = 1;
|
89 |
-
}else{
|
90 |
var wpms_sitemap_author = 0;
|
91 |
}
|
92 |
-
|
93 |
-
if($('#wpms_sitemap_root').is(':checked')){
|
94 |
var wpms_sitemap_root = 1;
|
95 |
-
}else{
|
96 |
var wpms_sitemap_root = 0;
|
97 |
}
|
98 |
-
|
99 |
-
if($('#wpms_sitemap_add').is(':checked')){
|
100 |
var wpms_sitemap_add = 1;
|
101 |
-
}else{
|
102 |
var wpms_sitemap_add = 0;
|
103 |
}
|
104 |
-
|
105 |
-
$('.wpms_display_column_menus').each(function(i,v){
|
106 |
var menu_id = $(v).data('menu_id');
|
107 |
columns_menu[menu_id] = $(v).val()
|
108 |
});
|
109 |
-
|
110 |
$.ajax({
|
111 |
-
url
|
112 |
-
method
|
113 |
-
dataType
|
114 |
-
data
|
115 |
-
action
|
116 |
-
wpms_sitemap_posts
|
117 |
-
wpms_sitemap_pages
|
118 |
-
wpms_sitemap_menus
|
119 |
-
wpms_html_sitemap_page
|
120 |
-
wpms_html_sitemap_column
|
121 |
-
wpms_html_sitemap_position
|
122 |
-
wpms_check_firstsave
|
123 |
-
wpms_sitemap_author
|
124 |
-
wpms_sitemap_root
|
125 |
-
wpms_sitemap_add
|
126 |
-
wpms_category_link
|
127 |
-
wpms_sitemap_taxonomies
|
128 |
-
wpms_public_name_posts
|
129 |
-
wpms_public_name_pages
|
130 |
-
wpms_display_column_menus
|
131 |
-
wpms_display_column_posts
|
132 |
-
wpms_display_column_pages
|
133 |
},
|
134 |
-
success
|
135 |
wpms_regen_sitemaps();
|
136 |
}
|
137 |
});
|
138 |
}
|
139 |
-
|
140 |
-
wpms_regen_sitemaps = function(){
|
141 |
$.ajax({
|
142 |
-
url
|
143 |
-
method
|
144 |
-
dataType
|
145 |
-
data
|
146 |
-
action
|
147 |
},
|
148 |
-
success
|
149 |
$('.spinner_save_sitemaps').hide();
|
150 |
}
|
151 |
});
|
152 |
}
|
153 |
-
|
154 |
-
var wpms_columns = ['Zezo'
|
155 |
-
$('#wpms_html_sitemap_column').on('change',function(){
|
156 |
$('.wpms_display_column').html(null);
|
157 |
-
for (var i=1
|
158 |
-
$('.wpms_display_column').append('<option value="'+ i +'">'+wpms_columns[i]+'</option>');
|
159 |
}
|
160 |
});
|
161 |
-
|
162 |
-
$('.sitemap_check_all_posts_categories').on('click',function(){
|
163 |
var category = $(this).data('category');
|
164 |
-
if($(this).is(':checked')){
|
165 |
-
$('.'+category).prop('checked',true);
|
166 |
-
}else{
|
167 |
-
$('.'+category).prop('checked',false);
|
168 |
}
|
169 |
});
|
170 |
|
171 |
-
$('.sitemap_check_all').on('click',function(){
|
172 |
var type = $(this).data('type');
|
173 |
-
if($(this).is(':checked')){
|
174 |
-
$('.cb_sitemaps_'+type).prop('checked',true);
|
175 |
-
}else{
|
176 |
-
$('.cb_sitemaps_'+type).prop('checked',false);
|
177 |
}
|
178 |
});
|
179 |
-
|
180 |
-
$('.sitemap_check_all_posts_in_page').on('click',function(){
|
181 |
var type = $(this).data('type');
|
182 |
-
if($(this).is(':checked')){
|
183 |
-
$('.wpms_row').not('.jp-hidden').find('.cb_sitemaps_'+type).prop('checked',true);
|
184 |
-
}else{
|
185 |
-
$('.wpms_row').not('.jp-hidden').find('.cb_sitemaps_'+type).prop('checked',false);
|
186 |
}
|
187 |
});
|
188 |
-
|
189 |
-
$('.nav-tab').on('click',function(){
|
190 |
var tab = $(this).data('tab');
|
191 |
$('.nav-tab').removeClass('nav-tab-active');
|
192 |
$(this).addClass('nav-tab-active');
|
193 |
$('.wpms_source').hide();
|
194 |
-
$('.wpms_source_'+tab).show();
|
195 |
});
|
196 |
-
|
197 |
});
|
198 |
}(jQuery));
|
1 |
+
(function ($) {
|
2 |
+
$(document).ready(function () {
|
3 |
+
/*
|
4 |
+
* Paging list posts in sitemap settings
|
5 |
+
*/
|
6 |
$(".holder_posts").jPages({
|
7 |
containerID: "wrap_sitemap_option_posts",
|
8 |
previous: "←",
|
11 |
delay: 20
|
12 |
});
|
13 |
|
14 |
+
/*
|
15 |
+
* Paging list pages in sitemap settings
|
16 |
+
*/
|
17 |
$(".holder_pages").jPages({
|
18 |
containerID: "wrap_sitemap_option_pages",
|
19 |
previous: "←",
|
22 |
delay: 20
|
23 |
});
|
24 |
|
25 |
+
/*
|
26 |
+
* Open qtip
|
27 |
+
*/
|
28 |
jQuery('.wpms_source_sitemaps tr label,.wpms_row h3 input').qtip({
|
29 |
content: {
|
30 |
attr: 'for'
|
45 |
delay: 10
|
46 |
}
|
47 |
|
48 |
+
});
|
49 |
+
|
50 |
+
$('.wpms_save_create_sitemaps').on('click', function () {
|
51 |
wpms_save_create_sitemaps();
|
52 |
});
|
53 |
|
54 |
+
wpms_save_create_sitemaps = function () {
|
55 |
+
$('.spinner_save_sitemaps').css({'visibility': 'visible'}).show();
|
56 |
+
var posts = {}, pages = {}, menus = {}, taxonomies = [], columns_menu = {}, wpms_category_link = [];
|
57 |
+
$(".wpms_xmap_posts").each(function (i, v) {
|
58 |
+
if ($(v).is(':checked')) {
|
59 |
var id = $(v).val();
|
60 |
+
var priority = $('#priority_posts_' + id).val();
|
61 |
+
var frequency = $('#frequency_posts_' + id).val();
|
62 |
+
posts[id] = {'post_id': id, 'priority': priority, 'frequency': frequency};
|
63 |
}
|
64 |
});
|
65 |
+
|
66 |
+
$(".wpms_xmap_pages").each(function (i, v) {
|
67 |
+
if ($(v).is(':checked')) {
|
68 |
var id = $(v).val();
|
69 |
+
var priority = $('#priority_pages_' + id).val();
|
70 |
+
var frequency = $('#frequency_pages_' + id).val();
|
71 |
+
pages[id] = {'post_id': id, 'priority': priority, 'frequency': frequency};
|
72 |
}
|
73 |
});
|
74 |
+
|
75 |
+
$(".wpms_xmap_menu").each(function (i, v) {
|
76 |
+
if ($(v).is(':checked')) {
|
77 |
var id = $(v).val();
|
78 |
+
var priority = $('#priority_menu_' + id).val();
|
79 |
+
var frequency = $('#frequency_menu_' + id).val();
|
80 |
+
menus[id] = {'menu_id': id, 'priority': priority, 'frequency': frequency};
|
81 |
}
|
82 |
});
|
83 |
+
|
84 |
+
$('.wpms_sitemap_taxonomies').each(function (i, v) {
|
85 |
+
if ($(v).is(':checked')) {
|
86 |
taxonomies.push($(v).val());
|
87 |
}
|
88 |
});
|
89 |
+
|
90 |
+
$('.sitemap_addlink_categories').each(function (i, v) {
|
91 |
+
if ($(v).is(':checked')) {
|
92 |
wpms_category_link.push($(v).val());
|
93 |
}
|
94 |
});
|
95 |
+
|
96 |
+
if ($('#wpms_sitemap_author').is(':checked')) {
|
97 |
var wpms_sitemap_author = 1;
|
98 |
+
} else {
|
99 |
var wpms_sitemap_author = 0;
|
100 |
}
|
101 |
+
|
102 |
+
if ($('#wpms_sitemap_root').is(':checked')) {
|
103 |
var wpms_sitemap_root = 1;
|
104 |
+
} else {
|
105 |
var wpms_sitemap_root = 0;
|
106 |
}
|
107 |
+
|
108 |
+
if ($('#wpms_sitemap_add').is(':checked')) {
|
109 |
var wpms_sitemap_add = 1;
|
110 |
+
} else {
|
111 |
var wpms_sitemap_add = 0;
|
112 |
}
|
113 |
+
|
114 |
+
$('.wpms_display_column_menus').each(function (i, v) {
|
115 |
var menu_id = $(v).data('menu_id');
|
116 |
columns_menu[menu_id] = $(v).val()
|
117 |
});
|
118 |
+
|
119 |
$.ajax({
|
120 |
+
url: ajaxurl,
|
121 |
+
method: 'POST',
|
122 |
+
dataType: 'json',
|
123 |
+
data: {
|
124 |
+
action: 'wpms_save_sitemap_settings',
|
125 |
+
wpms_sitemap_posts: JSON.stringify(posts),
|
126 |
+
wpms_sitemap_pages: JSON.stringify(pages),
|
127 |
+
wpms_sitemap_menus: JSON.stringify(menus),
|
128 |
+
wpms_html_sitemap_page: $('#wpms_html_sitemap_page').val(),
|
129 |
+
wpms_html_sitemap_column: $('#wpms_html_sitemap_column').val(),
|
130 |
+
wpms_html_sitemap_position: $('#wpms_html_sitemap_position').val(),
|
131 |
+
wpms_check_firstsave: $('#wpms_check_firstsave').val(),
|
132 |
+
wpms_sitemap_author: wpms_sitemap_author,
|
133 |
+
wpms_sitemap_root: wpms_sitemap_root,
|
134 |
+
wpms_sitemap_add: wpms_sitemap_add,
|
135 |
+
wpms_category_link: wpms_category_link,
|
136 |
+
wpms_sitemap_taxonomies: taxonomies,
|
137 |
+
wpms_public_name_posts: $('.public_name_posts').val(),
|
138 |
+
wpms_public_name_pages: $('.public_name_pages').val(),
|
139 |
+
wpms_display_column_menus: JSON.stringify(columns_menu),
|
140 |
+
wpms_display_column_posts: $('.wpms_display_column_posts').val(),
|
141 |
+
wpms_display_column_pages: $('.wpms_display_column_pages').val()
|
142 |
},
|
143 |
+
success: function (res) {
|
144 |
wpms_regen_sitemaps();
|
145 |
}
|
146 |
});
|
147 |
}
|
148 |
+
|
149 |
+
wpms_regen_sitemaps = function () {
|
150 |
$.ajax({
|
151 |
+
url: ajaxurl,
|
152 |
+
method: 'POST',
|
153 |
+
dataType: 'json',
|
154 |
+
data: {
|
155 |
+
action: 'wpms_regenerate_sitemaps'
|
156 |
},
|
157 |
+
success: function (res) {
|
158 |
$('.spinner_save_sitemaps').hide();
|
159 |
}
|
160 |
});
|
161 |
}
|
162 |
+
|
163 |
+
var wpms_columns = ['Zezo', 'One', 'Two', 'Three'];
|
164 |
+
$('#wpms_html_sitemap_column').on('change', function () {
|
165 |
$('.wpms_display_column').html(null);
|
166 |
+
for (var i = 1; i <= parseInt($(this).val()); i++) {
|
167 |
+
$('.wpms_display_column').append('<option value="' + i + '">' + wpms_columns[i] + '</option>');
|
168 |
}
|
169 |
});
|
170 |
+
|
171 |
+
$('.sitemap_check_all_posts_categories').on('click', function () {
|
172 |
var category = $(this).data('category');
|
173 |
+
if ($(this).is(':checked')) {
|
174 |
+
$('.' + category).prop('checked', true);
|
175 |
+
} else {
|
176 |
+
$('.' + category).prop('checked', false);
|
177 |
}
|
178 |
});
|
179 |
|
180 |
+
$('.sitemap_check_all').on('click', function () {
|
181 |
var type = $(this).data('type');
|
182 |
+
if ($(this).is(':checked')) {
|
183 |
+
$('.cb_sitemaps_' + type).prop('checked', true);
|
184 |
+
} else {
|
185 |
+
$('.cb_sitemaps_' + type).prop('checked', false);
|
186 |
}
|
187 |
});
|
188 |
+
|
189 |
+
$('.sitemap_check_all_posts_in_page').on('click', function () {
|
190 |
var type = $(this).data('type');
|
191 |
+
if ($(this).is(':checked')) {
|
192 |
+
$('.wpms_row').not('.jp-hidden').find('.cb_sitemaps_' + type).prop('checked', true);
|
193 |
+
} else {
|
194 |
+
$('.wpms_row').not('.jp-hidden').find('.cb_sitemaps_' + type).prop('checked', false);
|
195 |
}
|
196 |
});
|
197 |
+
|
198 |
+
$('.nav-tab').on('click', function () {
|
199 |
var tab = $(this).data('tab');
|
200 |
$('.nav-tab').removeClass('nav-tab-active');
|
201 |
$(this).addClass('nav-tab-active');
|
202 |
$('.wpms_source').hide();
|
203 |
+
$('.wpms_source_' + tab).show();
|
204 |
});
|
205 |
+
|
206 |
});
|
207 |
}(jQuery));
|
js/pop-up.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
jQuery(document).ready(function() {
|
2 |
-
(function($) {
|
3 |
-
$.fn.absoluteCenter = function() {
|
4 |
-
this.each(function() {
|
5 |
var top = -($(this).outerHeight() / 2) + 'px';
|
6 |
var left = -($(this).outerWidth() / 2) + 'px';
|
7 |
$(this).css({'position': 'absolute', 'position':'fixed', 'margin-top': top, 'margin-left': left, 'top': '40%', 'left': '50%'});
|
@@ -10,23 +10,22 @@ jQuery(document).ready(function() {
|
|
10 |
}
|
11 |
})(jQuery);
|
12 |
|
13 |
-
$('a.show-popup').click(function() {
|
14 |
var bg = $('div.popup-bg');
|
15 |
var obj = $(this).parent().find('div.popup');
|
16 |
var btnClose = obj.find('.popup-close');
|
17 |
bg.animate({opacity: 0.2}, 0).fadeIn(200);
|
18 |
obj.fadeIn(200).draggable({cursor: 'move', handle: '.popup-header'}).absoluteCenter();
|
19 |
-
btnClose.click(function() {
|
20 |
bg.fadeOut(100);
|
21 |
obj.fadeOut(100);
|
22 |
});
|
23 |
-
bg.click(function() {
|
24 |
btnClose.click();
|
25 |
});
|
26 |
-
$(document).keydown(function(e) {
|
27 |
if (e.keyCode == 27) {
|
28 |
btnClose.click();
|
29 |
-
n
|
30 |
}
|
31 |
});
|
32 |
return false;
|
1 |
+
jQuery(document).ready(function () {
|
2 |
+
(function ($) {
|
3 |
+
$.fn.absoluteCenter = function () {
|
4 |
+
this.each(function () {
|
5 |
var top = -($(this).outerHeight() / 2) + 'px';
|
6 |
var left = -($(this).outerWidth() / 2) + 'px';
|
7 |
$(this).css({'position': 'absolute', 'position':'fixed', 'margin-top': top, 'margin-left': left, 'top': '40%', 'left': '50%'});
|
10 |
}
|
11 |
})(jQuery);
|
12 |
|
13 |
+
$('a.show-popup').click(function () {
|
14 |
var bg = $('div.popup-bg');
|
15 |
var obj = $(this).parent().find('div.popup');
|
16 |
var btnClose = obj.find('.popup-close');
|
17 |
bg.animate({opacity: 0.2}, 0).fadeIn(200);
|
18 |
obj.fadeIn(200).draggable({cursor: 'move', handle: '.popup-header'}).absoluteCenter();
|
19 |
+
btnClose.click(function () {
|
20 |
bg.fadeOut(100);
|
21 |
obj.fadeOut(100);
|
22 |
});
|
23 |
+
bg.click(function () {
|
24 |
btnClose.click();
|
25 |
});
|
26 |
+
$(document).keydown(function (e) {
|
27 |
if (e.keyCode == 27) {
|
28 |
btnClose.click();
|
|
|
29 |
}
|
30 |
});
|
31 |
return false;
|
js/site-jPages.js
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
(function($){
|
2 |
-
$(document).ready(function(){
|
3 |
|
|
|
|
|
|
|
4 |
$(".holder_sitemaps_pages").jPages({
|
5 |
containerID: "sitemap_pages",
|
6 |
previous: "←",
|
@@ -9,6 +12,9 @@
|
|
9 |
delay: 20
|
10 |
});
|
11 |
|
|
|
|
|
|
|
12 |
$(".holder_sitemaps_posts").jPages({
|
13 |
containerID: "sitemap_posts",
|
14 |
previous: "←",
|
@@ -17,15 +23,18 @@
|
|
17 |
delay: 20
|
18 |
});
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
23 |
previous: "←",
|
24 |
next: "→",
|
25 |
perPage: 50,
|
26 |
delay: 20
|
27 |
});
|
28 |
});
|
29 |
-
|
30 |
});
|
31 |
}(jQuery));
|
1 |
+
(function ($) {
|
2 |
+
$(document).ready(function () {
|
3 |
|
4 |
+
/*
|
5 |
+
* Paging list pages
|
6 |
+
*/
|
7 |
$(".holder_sitemaps_pages").jPages({
|
8 |
containerID: "sitemap_pages",
|
9 |
previous: "←",
|
12 |
delay: 20
|
13 |
});
|
14 |
|
15 |
+
/*
|
16 |
+
* Paging list posts
|
17 |
+
*/
|
18 |
$(".holder_sitemaps_posts").jPages({
|
19 |
containerID: "sitemap_posts",
|
20 |
previous: "←",
|
23 |
delay: 20
|
24 |
});
|
25 |
|
26 |
+
/*
|
27 |
+
* Paging list menus
|
28 |
+
*/
|
29 |
+
$.each(wpms_avarible.wpms_display_column_menus, function (i, v) {
|
30 |
+
$(".holder_sitemaps_menus_" + i).jPages({
|
31 |
+
containerID: "sitemap_menus_" + i,
|
32 |
previous: "←",
|
33 |
next: "→",
|
34 |
perPage: 50,
|
35 |
delay: 20
|
36 |
});
|
37 |
});
|
38 |
+
|
39 |
});
|
40 |
}(jQuery));
|
js/wp-metaseo-admin-media.js
CHANGED
@@ -14,13 +14,13 @@ jQuery(document).ready(function ($) {
|
|
14 |
button: {text: wpmseoMediaL10n.choose_image},
|
15 |
multiple: false
|
16 |
});
|
17 |
-
|
18 |
wpmseo_uploader.on('select', function () {
|
19 |
var attachment = wpmseo_uploader.state().get('selection').first().toJSON();
|
20 |
$('#' + wpmseo_target_id).val(attachment.url);
|
21 |
wpmseo_uploader.close();
|
22 |
});
|
23 |
-
|
24 |
wpmseo_uploader.open();
|
25 |
});
|
26 |
});
|
14 |
button: {text: wpmseoMediaL10n.choose_image},
|
15 |
multiple: false
|
16 |
});
|
17 |
+
|
18 |
wpmseo_uploader.on('select', function () {
|
19 |
var attachment = wpmseo_uploader.state().get('selection').first().toJSON();
|
20 |
$('#' + wpmseo_target_id).val(attachment.url);
|
21 |
wpmseo_uploader.close();
|
22 |
});
|
23 |
+
|
24 |
wpmseo_uploader.open();
|
25 |
});
|
26 |
});
|
js/wp-metaseo-metabox.js
CHANGED
@@ -7,8 +7,7 @@ function msClean(str) {
|
|
7 |
str = str.replace(/<\/?[^>]+>/gi, '');
|
8 |
str = str.replace(/\[(.+?)](.+?\[\/\\1])?/g, '');
|
9 |
str = jQuery('<div/>').html(str).text();
|
10 |
-
}
|
11 |
-
catch (e) {
|
12 |
}
|
13 |
|
14 |
return str;
|
@@ -28,7 +27,7 @@ function msReplaceVariables(str, callback) {
|
|
28 |
str = str.replace(/%%sitename%%/g, wpmseoMetaboxL10n.sitename);
|
29 |
str = str.replace(/%%sep%%/g, wpmseoMetaboxL10n.sep);
|
30 |
str = str.replace(/%%page%%/g, wpmseoMetaboxL10n.page);
|
31 |
-
|
32 |
// excerpt
|
33 |
var excerpt = '';
|
34 |
if (jQuery('#excerpt').length) {
|
@@ -56,8 +55,7 @@ function msReplaceVariables(str, callback) {
|
|
56 |
for (var i = 0; i < matches.length; i++) {
|
57 |
if (typeof (replacedVars[ matches[ i ] ]) === 'undefined') {
|
58 |
str = str.replace(matches[ i ], replacedVars[ matches[ i ] ]);
|
59 |
-
}
|
60 |
-
else {
|
61 |
var replaceableVar = matches[ i ];
|
62 |
|
63 |
// create the cache already, so we don't do the request twice.
|
@@ -84,6 +82,9 @@ function msAjaxReplaceVariables(replaceableVar, callback) {
|
|
84 |
});
|
85 |
}
|
86 |
|
|
|
|
|
|
|
87 |
function msUpdateTitle(force) {
|
88 |
var title = '';
|
89 |
var titleElm = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title');
|
@@ -93,16 +94,15 @@ function msUpdateTitle(force) {
|
|
93 |
|
94 |
if (titleElm.val() !== '') {
|
95 |
var len = wpmseoMetaboxL10n.wpmseo_meta_title_length - titleElm.val().length;
|
96 |
-
metaseo_status_length(len,'#' + wpmseoMetaboxL10n.field_prefix + 'title-length');
|
97 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title-length').html(len);
|
98 |
} else {
|
99 |
-
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">'+ wpmseoMetaboxL10n.wpmseo_meta_title_length +'</span>');
|
100 |
}
|
101 |
|
102 |
if (titleElm.val()) {
|
103 |
title = titleElm.val().replace(/(<([^>]+)>)/ig, '');
|
104 |
-
}
|
105 |
-
else {
|
106 |
title = wpmseoMetaboxL10n.wpmseo_title_template;
|
107 |
title = divHtml.html(title).text();
|
108 |
}
|
@@ -121,8 +121,8 @@ function msUpdateTitle(force) {
|
|
121 |
}
|
122 |
|
123 |
title = msReplaceVariables(title, function (title) {
|
124 |
-
|
125 |
-
|
126 |
jQuery('#wpmseosnippet_title').html(title);
|
127 |
|
128 |
// do the placeholder
|
@@ -133,34 +133,40 @@ function msUpdateTitle(force) {
|
|
133 |
if (titleElement !== null) {
|
134 |
if (titleElement.scrollWidth > titleElement.clientWidth) {
|
135 |
titleLengthError.show();
|
136 |
-
}
|
137 |
-
else {
|
138 |
titleLengthError.hide();
|
139 |
}
|
140 |
}
|
141 |
-
|
142 |
-
//msTestFocusKw();
|
143 |
});
|
144 |
}
|
145 |
|
146 |
-
|
|
|
|
|
|
|
147 |
var keywords = '';
|
148 |
var keywordsElm = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords');
|
149 |
var keywordsLengthError = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length-warning');
|
150 |
if (keywordsElm.val() !== '') {
|
151 |
var len = wpmseoMetaboxL10n.wpmseo_meta_keywords_length - keywordsElm.val().length;
|
152 |
-
metaseo_status_length(len,'#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length');
|
153 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length').html(len);
|
154 |
} else {
|
155 |
-
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">'+ wpmseoMetaboxL10n.wpmseo_meta_keywords_length +'</span>');
|
156 |
}
|
157 |
}
|
158 |
|
|
|
|
|
|
|
159 |
function msSanitizeTitle(title) {
|
160 |
title = msClean(title);
|
161 |
return title;
|
162 |
}
|
163 |
|
|
|
|
|
|
|
164 |
function msUpdateDesc() {
|
165 |
var desc = jQuery.trim(msClean(jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc').val()));
|
166 |
var divHtml = jQuery('<div />');
|
@@ -176,9 +182,9 @@ function msUpdateDesc() {
|
|
176 |
desc = msClean(desc);
|
177 |
|
178 |
var len = wpmseoMetaboxL10n.wpmseo_meta_desc_length - desc.length;
|
179 |
-
metaseo_status_length(len,'#' + wpmseoMetaboxL10n.field_prefix + 'desc-length');
|
180 |
-
|
181 |
-
|
182 |
|
183 |
desc = msSanitizeDesc(desc);
|
184 |
|
@@ -188,10 +194,10 @@ function msUpdateDesc() {
|
|
188 |
snippet.find('.desc span.content').html(desc);
|
189 |
});
|
190 |
} else {
|
191 |
-
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">'+ wpmseoMetaboxL10n.wpmseo_meta_desc_length +'</span>');
|
192 |
// Clear the generated description
|
193 |
snippet.find('.desc span.content').html('');
|
194 |
-
|
195 |
|
196 |
if (typeof tinyMCE !== 'undefined' && tinyMCE.get('excerpt') !== null) {
|
197 |
desc = tinyMCE.get('excerpt').getContent();
|
@@ -211,6 +217,9 @@ function msUpdateDesc() {
|
|
211 |
}
|
212 |
}
|
213 |
|
|
|
|
|
|
|
214 |
function msSanitizeDesc(desc) {
|
215 |
desc = msTrimDesc(desc);
|
216 |
return desc;
|
@@ -221,8 +230,7 @@ function msTrimDesc(desc) {
|
|
221 |
var space;
|
222 |
if (desc.length > wpmseoMetaboxL10n.wpmseo_meta_desc_length) {
|
223 |
space = desc.lastIndexOf(' ', (wpmseoMetaboxL10n.wpmseo_meta_desc_length - 3));
|
224 |
-
}
|
225 |
-
else {
|
226 |
space = wpmseoMetaboxL10n.wpmseo_meta_desc_length;
|
227 |
}
|
228 |
desc = desc.substring(0, space).concat(' ...');
|
@@ -230,6 +238,9 @@ function msTrimDesc(desc) {
|
|
230 |
return desc;
|
231 |
}
|
232 |
|
|
|
|
|
|
|
233 |
function msUpdateURL() {
|
234 |
var url;
|
235 |
if (jQuery('#editable-post-name-full').length) {
|
@@ -241,7 +252,7 @@ function msUpdateURL() {
|
|
241 |
}
|
242 |
|
243 |
function msUpdateSnippet() {
|
244 |
-
if(typeof wpmseoMetaboxL10n.show_keywords !="undefined" && wpmseoMetaboxL10n.show_keywords == 1){
|
245 |
msUpdateKeywords();
|
246 |
}
|
247 |
msUpdateURL();
|
@@ -253,15 +264,15 @@ function msEscapeFocusKw(str) {
|
|
253 |
return str.replace(/[\-\[\]\/\{}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
254 |
}
|
255 |
|
256 |
-
function metaseo_status_length(len,id){
|
257 |
if (len < 0) {
|
258 |
jQuery(id).addClass('length-wrong').removeClass('length-true');
|
259 |
len = '<span class="wrong">' + len + '</span>';
|
260 |
-
}else {
|
261 |
jQuery(id).addClass('length-true').removeClass('length-wrong');
|
262 |
len = '<span class="good">' + len + '</span>';
|
263 |
}
|
264 |
-
|
265 |
jQuery(id).html(len);
|
266 |
}
|
267 |
|
@@ -274,28 +285,13 @@ function metaseo_status_length(len,id){
|
|
274 |
})();
|
275 |
|
276 |
jQuery(document).ready(function ($) {
|
277 |
-
// add countdown for title and description
|
278 |
-
// var titleval = jQuery.trim(msClean(jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title').val()));
|
279 |
-
// var descval = jQuery.trim(msClean(jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc').val()));
|
280 |
-
// if (titleval === '') {
|
281 |
-
// jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title-length').html('<span class="good">'+ wpmseoMetaboxL10n.wpmseo_meta_title_length +'</span>');
|
282 |
-
// }else{
|
283 |
-
// metaseo_status_length(titleval.length,'#' + wpmseoMetaboxL10n.field_prefix + 'title-length');
|
284 |
-
// }
|
285 |
-
// if (descval === '') {
|
286 |
-
// jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc-length').html('<span class="good">'+ wpmseoMetaboxL10n.wpmseo_meta_desc_length +'</span>');
|
287 |
-
// }else{
|
288 |
-
// metaseo_status_length(descval.length,'#' + wpmseoMetaboxL10n.field_prefix + 'desc-length');
|
289 |
-
// }
|
290 |
-
//
|
291 |
var replacedVars = []; // jshint ignore:line
|
292 |
|
293 |
if (jQuery('.wpmseo-metabox-tabs-div').length > 0) {
|
294 |
var active_tab = window.location.hash;
|
295 |
if (active_tab === '' || active_tab.search('wpmseo') === -1) {
|
296 |
active_tab = 'general';
|
297 |
-
}
|
298 |
-
else {
|
299 |
active_tab = active_tab.replace('#wpmseo_', '');
|
300 |
}
|
301 |
jQuery('.' + active_tab).addClass('active');
|
@@ -330,7 +326,7 @@ jQuery(document).ready(function ($) {
|
|
330 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title').keyup(function () {
|
331 |
msUpdateTitle();
|
332 |
});
|
333 |
-
|
334 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords').keyup(function () {
|
335 |
msUpdateKeywords();
|
336 |
});
|
@@ -387,8 +383,8 @@ jQuery(document).ready(function ($) {
|
|
387 |
delay: 500
|
388 |
}
|
389 |
|
390 |
-
});
|
391 |
-
|
392 |
jQuery('.metaseo_tool').qtip({
|
393 |
content: {
|
394 |
attr: 'alt'
|
@@ -409,5 +405,5 @@ jQuery(document).ready(function ($) {
|
|
409 |
delay: 100
|
410 |
}
|
411 |
|
412 |
-
});
|
413 |
});
|
7 |
str = str.replace(/<\/?[^>]+>/gi, '');
|
8 |
str = str.replace(/\[(.+?)](.+?\[\/\\1])?/g, '');
|
9 |
str = jQuery('<div/>').html(str).text();
|
10 |
+
} catch (e) {
|
|
|
11 |
}
|
12 |
|
13 |
return str;
|
27 |
str = str.replace(/%%sitename%%/g, wpmseoMetaboxL10n.sitename);
|
28 |
str = str.replace(/%%sep%%/g, wpmseoMetaboxL10n.sep);
|
29 |
str = str.replace(/%%page%%/g, wpmseoMetaboxL10n.page);
|
30 |
+
|
31 |
// excerpt
|
32 |
var excerpt = '';
|
33 |
if (jQuery('#excerpt').length) {
|
55 |
for (var i = 0; i < matches.length; i++) {
|
56 |
if (typeof (replacedVars[ matches[ i ] ]) === 'undefined') {
|
57 |
str = str.replace(matches[ i ], replacedVars[ matches[ i ] ]);
|
58 |
+
} else {
|
|
|
59 |
var replaceableVar = matches[ i ];
|
60 |
|
61 |
// create the cache already, so we don't do the request twice.
|
82 |
});
|
83 |
}
|
84 |
|
85 |
+
/*
|
86 |
+
* Change meta title in meta box
|
87 |
+
*/
|
88 |
function msUpdateTitle(force) {
|
89 |
var title = '';
|
90 |
var titleElm = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title');
|
94 |
|
95 |
if (titleElm.val() !== '') {
|
96 |
var len = wpmseoMetaboxL10n.wpmseo_meta_title_length - titleElm.val().length;
|
97 |
+
metaseo_status_length(len, '#' + wpmseoMetaboxL10n.field_prefix + 'title-length');
|
98 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title-length').html(len);
|
99 |
} else {
|
100 |
+
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">' + wpmseoMetaboxL10n.wpmseo_meta_title_length + '</span>');
|
101 |
}
|
102 |
|
103 |
if (titleElm.val()) {
|
104 |
title = titleElm.val().replace(/(<([^>]+)>)/ig, '');
|
105 |
+
} else {
|
|
|
106 |
title = wpmseoMetaboxL10n.wpmseo_title_template;
|
107 |
title = divHtml.html(title).text();
|
108 |
}
|
121 |
}
|
122 |
|
123 |
title = msReplaceVariables(title, function (title) {
|
124 |
+
title = msSanitizeTitle(title);
|
125 |
+
|
126 |
jQuery('#wpmseosnippet_title').html(title);
|
127 |
|
128 |
// do the placeholder
|
133 |
if (titleElement !== null) {
|
134 |
if (titleElement.scrollWidth > titleElement.clientWidth) {
|
135 |
titleLengthError.show();
|
136 |
+
} else {
|
|
|
137 |
titleLengthError.hide();
|
138 |
}
|
139 |
}
|
|
|
|
|
140 |
});
|
141 |
}
|
142 |
|
143 |
+
/*
|
144 |
+
* Change meta keywords in meta box
|
145 |
+
*/
|
146 |
+
function msUpdateKeywords() {
|
147 |
var keywords = '';
|
148 |
var keywordsElm = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords');
|
149 |
var keywordsLengthError = jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length-warning');
|
150 |
if (keywordsElm.val() !== '') {
|
151 |
var len = wpmseoMetaboxL10n.wpmseo_meta_keywords_length - keywordsElm.val().length;
|
152 |
+
metaseo_status_length(len, '#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length');
|
153 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length').html(len);
|
154 |
} else {
|
155 |
+
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">' + wpmseoMetaboxL10n.wpmseo_meta_keywords_length + '</span>');
|
156 |
}
|
157 |
}
|
158 |
|
159 |
+
/*
|
160 |
+
* Clean title
|
161 |
+
*/
|
162 |
function msSanitizeTitle(title) {
|
163 |
title = msClean(title);
|
164 |
return title;
|
165 |
}
|
166 |
|
167 |
+
/*
|
168 |
+
* Change meta description in meta box
|
169 |
+
*/
|
170 |
function msUpdateDesc() {
|
171 |
var desc = jQuery.trim(msClean(jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc').val()));
|
172 |
var divHtml = jQuery('<div />');
|
182 |
desc = msClean(desc);
|
183 |
|
184 |
var len = wpmseoMetaboxL10n.wpmseo_meta_desc_length - desc.length;
|
185 |
+
metaseo_status_length(len, '#' + wpmseoMetaboxL10n.field_prefix + 'desc-length');
|
186 |
+
|
187 |
+
|
188 |
|
189 |
desc = msSanitizeDesc(desc);
|
190 |
|
194 |
snippet.find('.desc span.content').html(desc);
|
195 |
});
|
196 |
} else {
|
197 |
+
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'desc-length').addClass('length-true').removeClass('length-wrong').html('<span class="good">' + wpmseoMetaboxL10n.wpmseo_meta_desc_length + '</span>');
|
198 |
// Clear the generated description
|
199 |
snippet.find('.desc span.content').html('');
|
200 |
+
|
201 |
|
202 |
if (typeof tinyMCE !== 'undefined' && tinyMCE.get('excerpt') !== null) {
|
203 |
desc = tinyMCE.get('excerpt').getContent();
|
217 |
}
|
218 |
}
|
219 |
|
220 |
+
/*
|
221 |
+
* Sanitize description
|
222 |
+
*/
|
223 |
function msSanitizeDesc(desc) {
|
224 |
desc = msTrimDesc(desc);
|
225 |
return desc;
|
230 |
var space;
|
231 |
if (desc.length > wpmseoMetaboxL10n.wpmseo_meta_desc_length) {
|
232 |
space = desc.lastIndexOf(' ', (wpmseoMetaboxL10n.wpmseo_meta_desc_length - 3));
|
233 |
+
} else {
|
|
|
234 |
space = wpmseoMetaboxL10n.wpmseo_meta_desc_length;
|
235 |
}
|
236 |
desc = desc.substring(0, space).concat(' ...');
|
238 |
return desc;
|
239 |
}
|
240 |
|
241 |
+
/*
|
242 |
+
* Update Url
|
243 |
+
*/
|
244 |
function msUpdateURL() {
|
245 |
var url;
|
246 |
if (jQuery('#editable-post-name-full').length) {
|
252 |
}
|
253 |
|
254 |
function msUpdateSnippet() {
|
255 |
+
if (typeof wpmseoMetaboxL10n.show_keywords != "undefined" && wpmseoMetaboxL10n.show_keywords == 1) {
|
256 |
msUpdateKeywords();
|
257 |
}
|
258 |
msUpdateURL();
|
264 |
return str.replace(/[\-\[\]\/\{}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
265 |
}
|
266 |
|
267 |
+
function metaseo_status_length(len, id) {
|
268 |
if (len < 0) {
|
269 |
jQuery(id).addClass('length-wrong').removeClass('length-true');
|
270 |
len = '<span class="wrong">' + len + '</span>';
|
271 |
+
} else {
|
272 |
jQuery(id).addClass('length-true').removeClass('length-wrong');
|
273 |
len = '<span class="good">' + len + '</span>';
|
274 |
}
|
275 |
+
|
276 |
jQuery(id).html(len);
|
277 |
}
|
278 |
|
285 |
})();
|
286 |
|
287 |
jQuery(document).ready(function ($) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
var replacedVars = []; // jshint ignore:line
|
289 |
|
290 |
if (jQuery('.wpmseo-metabox-tabs-div').length > 0) {
|
291 |
var active_tab = window.location.hash;
|
292 |
if (active_tab === '' || active_tab.search('wpmseo') === -1) {
|
293 |
active_tab = 'general';
|
294 |
+
} else {
|
|
|
295 |
active_tab = active_tab.replace('#wpmseo_', '');
|
296 |
}
|
297 |
jQuery('.' + active_tab).addClass('active');
|
326 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'title').keyup(function () {
|
327 |
msUpdateTitle();
|
328 |
});
|
329 |
+
|
330 |
jQuery('#' + wpmseoMetaboxL10n.field_prefix + 'keywords').keyup(function () {
|
331 |
msUpdateKeywords();
|
332 |
});
|
383 |
delay: 500
|
384 |
}
|
385 |
|
386 |
+
});
|
387 |
+
|
388 |
jQuery('.metaseo_tool').qtip({
|
389 |
content: {
|
390 |
attr: 'alt'
|
405 |
delay: 100
|
406 |
}
|
407 |
|
408 |
+
});
|
409 |
});
|
js/wpms-broken-link.js
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function ($) {
|
2 |
+
var correctedURL;
|
3 |
+
$('.wpms-link-url-field').on('keyup', function () {
|
4 |
+
var url = $.trim($(this).val());
|
5 |
+
if (url && correctedURL !== url && !/^(?:[a-z]+:|#|\?|\.|\/)/.test(url)) {
|
6 |
+
$(this).val('http://' + url);
|
7 |
+
correctedURL = url;
|
8 |
+
}
|
9 |
+
});
|
10 |
+
|
11 |
+
/*
|
12 |
+
* Scan all link in posts , pages and comments
|
13 |
+
*/
|
14 |
+
$('.wpms_scan_link').on('click', function () {
|
15 |
+
var $this = $(this);
|
16 |
+
wpms_scan_link($this);
|
17 |
+
});
|
18 |
+
|
19 |
+
$('.wpms_flush_link').on('click', function () {
|
20 |
+
var $this = $(this);
|
21 |
+
var flush_val = $('#filter-by-flush').val();
|
22 |
+
if (flush_val != 'none') {
|
23 |
+
$('#wp-seo-meta-form .spinner').css('visibility', 'visible').show();
|
24 |
+
$.ajax({
|
25 |
+
url: ajaxurl,
|
26 |
+
method: 'POST',
|
27 |
+
dataType: 'json',
|
28 |
+
data: {
|
29 |
+
'action': 'wpms_flush_link',
|
30 |
+
'type': $('#filter-by-flush').val()
|
31 |
+
},
|
32 |
+
success: function (res) {
|
33 |
+
$('#wp-seo-meta-form .spinner').hide();
|
34 |
+
window.location.assign(document.URL);
|
35 |
+
}
|
36 |
+
});
|
37 |
+
}
|
38 |
+
});
|
39 |
+
|
40 |
+
/*
|
41 |
+
* Edit a link
|
42 |
+
*/
|
43 |
+
$('.wpms-edit-button').on('click', function () {
|
44 |
+
$(this).closest('td').find('.wpms-inline-editor-content').show();
|
45 |
+
});
|
46 |
+
|
47 |
+
/*
|
48 |
+
* Cancel edit link
|
49 |
+
*/
|
50 |
+
$('.wpms-cancel-button').on('click', function () {
|
51 |
+
$(this).closest('td').find('.wpms-inline-editor-content').hide();
|
52 |
+
});
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Update a link
|
56 |
+
*/
|
57 |
+
$('.wpms-update-link-button').on('click', function () {
|
58 |
+
var $this = $(this);
|
59 |
+
var link_id = $this.data('link_id');
|
60 |
+
var new_link = $this.closest('td').find('.wpms-link-url-field').val();
|
61 |
+
var new_text = $this.closest('td').find('.wpms-link-text-field').val();
|
62 |
+
var link_redirect = $this.closest('td').find('.wpms-link-redirect-field').val();
|
63 |
+
var data_type = $this.closest('td').find('.wpms-link-text-field').data('type');
|
64 |
+
if (new_link == '') {
|
65 |
+
alert('Error: Link URL must not be empty');
|
66 |
+
} else {
|
67 |
+
wpms_update_link($this, link_id, new_link, new_text, link_redirect, data_type);
|
68 |
+
}
|
69 |
+
});
|
70 |
+
|
71 |
+
/*
|
72 |
+
* Remove link
|
73 |
+
*/
|
74 |
+
$('.wpms-unlink-button').on('click', function () {
|
75 |
+
var $this = $(this);
|
76 |
+
var link_id = $this.data('link_id');
|
77 |
+
wpms_unlink($this, link_id);
|
78 |
+
});
|
79 |
+
|
80 |
+
/*
|
81 |
+
* Recheck link
|
82 |
+
*/
|
83 |
+
$('.wpms-recheck-button').on('click', function () {
|
84 |
+
var $this = $(this);
|
85 |
+
var link_id = $this.data('link_id');
|
86 |
+
wpms_recheck_link($this, link_id);
|
87 |
+
});
|
88 |
+
|
89 |
+
/*
|
90 |
+
* Do recheck link
|
91 |
+
*/
|
92 |
+
function wpms_recheck_link($this, link_id) {
|
93 |
+
var oldColor = $this.closest('tr').css('background-color');
|
94 |
+
$this.closest('tr').css({'background-color': "rgba(0, 115, 170, 0.1)"});
|
95 |
+
$.ajax({
|
96 |
+
url: ajaxurl,
|
97 |
+
method: 'POST',
|
98 |
+
dataType: 'json',
|
99 |
+
data: {
|
100 |
+
'action': 'wpms_recheck_link',
|
101 |
+
'link_id': link_id,
|
102 |
+
},
|
103 |
+
success: function (res) {
|
104 |
+
if (res.status) {
|
105 |
+
var status = res.status_text;
|
106 |
+
if (status.indexOf('404') != -1 || status == 'Server Not Found') {
|
107 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
|
108 |
+
} else if (status.indexOf('200') != -1) {
|
109 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
|
110 |
+
} else if (status.indexOf('301') != -1) {
|
111 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
|
112 |
+
} else if (status.indexOf('302') != -1) {
|
113 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
|
114 |
+
} else {
|
115 |
+
$this.closest('tr').find('.col_status').html(res.status_text);
|
116 |
+
}
|
117 |
+
wpms_tooltip();
|
118 |
+
$this.closest('tr').css({'background-color': oldColor});
|
119 |
+
}
|
120 |
+
}
|
121 |
+
});
|
122 |
+
}
|
123 |
+
|
124 |
+
/*
|
125 |
+
* Do remove link
|
126 |
+
*/
|
127 |
+
function wpms_unlink($this, link_id) {
|
128 |
+
$this.closest('tr').css({'background-color': "rgba(0, 115, 170, 0.1)"});
|
129 |
+
$.ajax({
|
130 |
+
url: ajaxurl,
|
131 |
+
method: 'POST',
|
132 |
+
dataType: 'json',
|
133 |
+
data: {
|
134 |
+
'action': 'wpms_unlink',
|
135 |
+
'link_id': link_id,
|
136 |
+
},
|
137 |
+
success: function (res) {
|
138 |
+
if (res) {
|
139 |
+
$this.closest('tr').remove();
|
140 |
+
}
|
141 |
+
}
|
142 |
+
});
|
143 |
+
}
|
144 |
+
|
145 |
+
/*
|
146 |
+
* Do update link
|
147 |
+
*/
|
148 |
+
function wpms_update_link($this, link_id, new_link, new_text, link_redirect, data_type) {
|
149 |
+
$.ajax({
|
150 |
+
url: ajaxurl,
|
151 |
+
method: 'POST',
|
152 |
+
dataType: 'json',
|
153 |
+
data: {
|
154 |
+
'action': 'wpms_update_link',
|
155 |
+
'link_id': link_id,
|
156 |
+
'new_link': new_link,
|
157 |
+
'new_text': new_text,
|
158 |
+
'link_redirect': link_redirect,
|
159 |
+
'data_type': data_type
|
160 |
+
},
|
161 |
+
success: function (res) {
|
162 |
+
if (res.status) {
|
163 |
+
$this.closest('td').find('.wpms-inline-editor-content').hide();
|
164 |
+
//if(res.type != '404_automaticaly'){
|
165 |
+
$this.closest('td').find('.link_html').html(res.new_link).attr('href', res.new_link);
|
166 |
+
$this.closest('tr').find('.col_status').html(res.status_text);
|
167 |
+
|
168 |
+
var status = res.status_text;
|
169 |
+
if (status.indexOf('404') != -1 || status == 'Server Not Found') {
|
170 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_warning metaseo_help_status" alt="404 error, not found">warning</i>');
|
171 |
+
} else if (status.indexOf('200') != -1) {
|
172 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Link is OK">done</i>');
|
173 |
+
} else if (status.indexOf('301') != -1) {
|
174 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Permanent redirect">done</i>');
|
175 |
+
} else if (status.indexOf('302') != -1) {
|
176 |
+
$this.closest('tr').find('.col_status').html('<i class="material-icons wpms_ok metaseo_help_status" alt="Moved temporarily">done</i>');
|
177 |
+
} else {
|
178 |
+
$this.closest('tr').find('.col_status').html(res.status_text);
|
179 |
+
}
|
180 |
+
wpms_tooltip();
|
181 |
+
//}
|
182 |
+
|
183 |
+
if (res.type == 'url') {
|
184 |
+
if (res.new_text != '') {
|
185 |
+
$this.closest('tr').find('.link_text').html(new_text);
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
190 |
+
});
|
191 |
+
}
|
192 |
+
|
193 |
+
/*
|
194 |
+
* Opem qtip
|
195 |
+
*/
|
196 |
+
function wpms_tooltip() {
|
197 |
+
jQuery('.metaseo_help_status').qtip({
|
198 |
+
content: {
|
199 |
+
attr: 'alt'
|
200 |
+
},
|
201 |
+
position: {
|
202 |
+
my: 'bottom left',
|
203 |
+
at: 'top center'
|
204 |
+
},
|
205 |
+
style: {
|
206 |
+
tip: {
|
207 |
+
corner: true
|
208 |
+
},
|
209 |
+
classes: 'metaseo-qtip qtip-rounded'
|
210 |
+
},
|
211 |
+
show: 'hover',
|
212 |
+
hide: {
|
213 |
+
fixed: true,
|
214 |
+
delay: 500
|
215 |
+
}
|
216 |
+
|
217 |
+
});
|
218 |
+
}
|
219 |
+
wpms_tooltip();
|
220 |
+
});
|
js/wpms-bulk-action.js
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
-
|
3 |
$('.tablenav.top #post-query-submit , .tablenav.bottom #post-query-submit').click(function (e) {
|
4 |
if ($('.metaseo-filter').val() == 'bulk-copy-metatitle') {
|
5 |
e.preventDefault();
|
6 |
$('#bulk-copy-metatitle').show();
|
7 |
}
|
8 |
});
|
9 |
-
|
|
|
|
|
|
|
10 |
$('.btn_do_copy').click(function (e) {
|
11 |
var $this = $(this);
|
12 |
var sl_bulk = $('.mbulk_copy').val();
|
@@ -23,54 +26,59 @@ jQuery(document).ready(function ($) {
|
|
23 |
mpost_selected.push($(this).val());
|
24 |
}
|
25 |
});
|
26 |
-
|
27 |
if (sl_bulk != 'all') {
|
28 |
if ($this.hasClass('post_do_copy')) {
|
29 |
var maction = 'wpms_bulk_post_copy';
|
30 |
var mtype = 'post_title';
|
31 |
-
wpms_ajax_coppy($this
|
32 |
} else {
|
33 |
-
if($this.hasClass('image_do_copy_alt')){
|
34 |
var mtype = 'image_alt';
|
35 |
-
$.each(mpost_selected,function(i,v){
|
36 |
-
if($('#img-alt-'+v).val() != '')
|
|
|
37 |
});
|
38 |
|
39 |
-
if(check_alt){
|
40 |
-
if(confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
41 |
-
wpms_ajax_coppy($this
|
42 |
}
|
43 |
-
}else{
|
44 |
-
wpms_ajax_coppy($this
|
45 |
}
|
46 |
|
47 |
-
}else{
|
48 |
var mtype = 'image_title';
|
49 |
-
$.each(mpost_selected,function(i,v){
|
50 |
-
if($('#img-title-'+v).val() != '')
|
|
|
51 |
});
|
52 |
|
53 |
-
if(check_title){
|
54 |
-
if(confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
55 |
-
wpms_ajax_coppy($this
|
56 |
}
|
57 |
-
}else{
|
58 |
-
wpms_ajax_coppy($this
|
59 |
}
|
60 |
}
|
61 |
}
|
62 |
-
}else{
|
63 |
-
if($this.hasClass('image_do_copy_alt')){
|
64 |
-
wpms_ajax_check_exist('alt'
|
65 |
-
}else if($this.hasClass('image_do_copy_title')){
|
66 |
-
wpms_ajax_check_exist('title'
|
67 |
-
}else if($this.hasClass('post_do_copy')){
|
68 |
-
wpms_ajax_coppy($this
|
69 |
}
|
70 |
}
|
71 |
});
|
72 |
|
73 |
-
|
|
|
|
|
|
|
74 |
$this.closest('.tablenav').find('.spinner').show().css('visibility', 'visible');
|
75 |
$.ajax({
|
76 |
url: ajaxurl,
|
@@ -80,35 +88,38 @@ jQuery(document).ready(function ($) {
|
|
80 |
action: maction,
|
81 |
ids: mpost_selected,
|
82 |
sl_bulk: sl_bulk,
|
83 |
-
mtype:mtype
|
84 |
},
|
85 |
success: function (res) {
|
86 |
if (res == true) {
|
87 |
window.location.assign(document.URL);
|
88 |
}
|
89 |
-
|
90 |
$this.closest('.tablenav').find('.spinner').hide();
|
91 |
}
|
92 |
|
93 |
});
|
94 |
}
|
95 |
|
96 |
-
|
|
|
|
|
|
|
97 |
$.ajax({
|
98 |
url: ajaxurl,
|
99 |
method: 'POST',
|
100 |
dataType: 'json',
|
101 |
data: {
|
102 |
action: 'wpms_ajax_check_exist',
|
103 |
-
type
|
104 |
},
|
105 |
success: function (res) {
|
106 |
-
if(res){
|
107 |
-
if(confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
108 |
-
wpms_ajax_coppy($this
|
109 |
}
|
110 |
-
}else{
|
111 |
-
wpms_ajax_coppy($this
|
112 |
}
|
113 |
}
|
114 |
});
|
1 |
jQuery(document).ready(function ($) {
|
2 |
+
|
3 |
$('.tablenav.top #post-query-submit , .tablenav.bottom #post-query-submit').click(function (e) {
|
4 |
if ($('.metaseo-filter').val() == 'bulk-copy-metatitle') {
|
5 |
e.preventDefault();
|
6 |
$('#bulk-copy-metatitle').show();
|
7 |
}
|
8 |
});
|
9 |
+
|
10 |
+
/*
|
11 |
+
* Copy image alt and image title from image name
|
12 |
+
*/
|
13 |
$('.btn_do_copy').click(function (e) {
|
14 |
var $this = $(this);
|
15 |
var sl_bulk = $('.mbulk_copy').val();
|
26 |
mpost_selected.push($(this).val());
|
27 |
}
|
28 |
});
|
29 |
+
|
30 |
if (sl_bulk != 'all') {
|
31 |
if ($this.hasClass('post_do_copy')) {
|
32 |
var maction = 'wpms_bulk_post_copy';
|
33 |
var mtype = 'post_title';
|
34 |
+
wpms_ajax_coppy($this, maction, mpost_selected, sl_bulk, mtype);
|
35 |
} else {
|
36 |
+
if ($this.hasClass('image_do_copy_alt')) {
|
37 |
var mtype = 'image_alt';
|
38 |
+
$.each(mpost_selected, function (i, v) {
|
39 |
+
if ($('#img-alt-' + v).val() != '')
|
40 |
+
check_alt = true;
|
41 |
});
|
42 |
|
43 |
+
if (check_alt) {
|
44 |
+
if (confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
45 |
+
wpms_ajax_coppy($this, maction_img, mpost_selected, sl_bulk, mtype);
|
46 |
}
|
47 |
+
} else {
|
48 |
+
wpms_ajax_coppy($this, maction_img, mpost_selected, sl_bulk, mtype);
|
49 |
}
|
50 |
|
51 |
+
} else {
|
52 |
var mtype = 'image_title';
|
53 |
+
$.each(mpost_selected, function (i, v) {
|
54 |
+
if ($('#img-title-' + v).val() != '')
|
55 |
+
check_title = true;
|
56 |
});
|
57 |
|
58 |
+
if (check_title) {
|
59 |
+
if (confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
60 |
+
wpms_ajax_coppy($this, maction_img, mpost_selected, sl_bulk, mtype);
|
61 |
}
|
62 |
+
} else {
|
63 |
+
wpms_ajax_coppy($this, maction_img, mpost_selected, sl_bulk, mtype);
|
64 |
}
|
65 |
}
|
66 |
}
|
67 |
+
} else {
|
68 |
+
if ($this.hasClass('image_do_copy_alt')) {
|
69 |
+
wpms_ajax_check_exist('alt', $this, maction_img, mpost_selected, sl_bulk, 'image_alt');
|
70 |
+
} else if ($this.hasClass('image_do_copy_title')) {
|
71 |
+
wpms_ajax_check_exist('title', $this, maction_img, mpost_selected, sl_bulk, 'image_title');
|
72 |
+
} else if ($this.hasClass('post_do_copy')) {
|
73 |
+
wpms_ajax_coppy($this, maction_post, mpost_selected, sl_bulk, 'post_title');
|
74 |
}
|
75 |
}
|
76 |
});
|
77 |
|
78 |
+
/*
|
79 |
+
* function copy
|
80 |
+
*/
|
81 |
+
function wpms_ajax_coppy($this, maction, mpost_selected, sl_bulk, mtype) {
|
82 |
$this.closest('.tablenav').find('.spinner').show().css('visibility', 'visible');
|
83 |
$.ajax({
|
84 |
url: ajaxurl,
|
88 |
action: maction,
|
89 |
ids: mpost_selected,
|
90 |
sl_bulk: sl_bulk,
|
91 |
+
mtype: mtype
|
92 |
},
|
93 |
success: function (res) {
|
94 |
if (res == true) {
|
95 |
window.location.assign(document.URL);
|
96 |
}
|
97 |
+
|
98 |
$this.closest('.tablenav').find('.spinner').hide();
|
99 |
}
|
100 |
|
101 |
});
|
102 |
}
|
103 |
|
104 |
+
/*
|
105 |
+
* function check empty title and alt
|
106 |
+
*/
|
107 |
+
function wpms_ajax_check_exist(type, $this, maction, mpost_selected, sl_bulk, mtype) {
|
108 |
$.ajax({
|
109 |
url: ajaxurl,
|
110 |
method: 'POST',
|
111 |
dataType: 'json',
|
112 |
data: {
|
113 |
action: 'wpms_ajax_check_exist',
|
114 |
+
type: type
|
115 |
},
|
116 |
success: function (res) {
|
117 |
+
if (res) {
|
118 |
+
if (confirm(wpmseobulkL10n.metaseo_message_false_copy)) {
|
119 |
+
wpms_ajax_coppy($this, maction, mpost_selected, sl_bulk, mtype);
|
120 |
}
|
121 |
+
} else {
|
122 |
+
wpms_ajax_coppy($this, maction, mpost_selected, sl_bulk, mtype);
|
123 |
}
|
124 |
}
|
125 |
});
|
js/wpms-link-title-field.js
CHANGED
@@ -1,145 +1,137 @@
|
|
1 |
-
/* global ajaxurl, tinymce, wpLinkL10n, setUserSetting, wpActiveEditor */
|
2 |
var wpmsLinkTitle;
|
3 |
|
4 |
-
(
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
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 |
-
inputs.title.val( '' );
|
140 |
-
return wpmsLinkTitle.origsetDefaultValues.apply(this, arguments);
|
141 |
-
}
|
142 |
-
};
|
143 |
-
|
144 |
-
$( document ).ready( wpmsLinkTitle.init );
|
145 |
-
})( jQuery );
|
|
|
1 |
var wpmsLinkTitle;
|
2 |
|
3 |
+
(function ($) {
|
4 |
+
var inputs = {};
|
5 |
+
|
6 |
+
wpmsLinkTitle = {
|
7 |
+
origsetDefaultValues: null,
|
8 |
+
origmceRefresh: null,
|
9 |
+
origgetAttrs: null,
|
10 |
+
origupdateFields: null,
|
11 |
+
orightmlUpdate: null,
|
12 |
+
init: function () {
|
13 |
+
// Put the title field back where it belongs
|
14 |
+
$('.wp-link-text-field').before('<div class="link-title-field"><label><span>' + wpmsLinkTitleL10n.titleLabel + '</span><input id="wp-link-title" type="text" name="linktitle" /></label></div>');
|
15 |
+
|
16 |
+
// Move search results lower to avoid overlapping
|
17 |
+
$('<style type="text/css"> .has-text-field #wp-link #search-panel .query-results { top: 235px; } </style>').appendTo('head');
|
18 |
+
|
19 |
+
inputs.wrap = $('#wp-link-wrap');
|
20 |
+
inputs.submit = $('#wp-link-submit');
|
21 |
+
|
22 |
+
// Input
|
23 |
+
inputs.url = $('#wp-link-url');
|
24 |
+
inputs.title = $('#wp-link-title');
|
25 |
+
inputs.text = $('#wp-link-text');
|
26 |
+
inputs.openInNewTab = $('#wp-link-target');
|
27 |
+
|
28 |
+
// override several functions in wpLink, save the originals
|
29 |
+
if ('undefined' !== typeof wpLink) {
|
30 |
+
wpmsLinkTitle.origsetDefaultValues = wpLink.setDefaultValues;
|
31 |
+
wpmsLinkTitle.origmceRefresh = wpLink.mceRefresh;
|
32 |
+
wpmsLinkTitle.origgetAttrs = wpLink.getAttrs;
|
33 |
+
wpmsLinkTitle.origupdateFields = wpLink.updateFields;
|
34 |
+
wpmsLinkTitle.orightmlUpdate = wpLink.htmlUpdate;
|
35 |
+
|
36 |
+
wpLink.setDefaultValues = wpmsLinkTitle.setDefaultValues;
|
37 |
+
wpLink.mceRefresh = wpmsLinkTitle.mceRefresh;
|
38 |
+
wpLink.getAttrs = wpmsLinkTitle.getAttrs;
|
39 |
+
wpLink.updateFields = wpmsLinkTitle.updateFields;
|
40 |
+
wpLink.htmlUpdate = wpmsLinkTitle.htmlUpdate;
|
41 |
+
}
|
42 |
+
|
43 |
+
$('#wp-link').find('.query-results').on('river-select', wpmsLinkTitle.updateFields);
|
44 |
+
},
|
45 |
+
mceRefresh: function () {
|
46 |
+
var editor = tinymce.get(wpActiveEditor),
|
47 |
+
selectedNode = editor.selection.getNode(),
|
48 |
+
linkNode = editor.dom.getParent(selectedNode, 'a[href]');
|
49 |
+
|
50 |
+
if (linkNode) {
|
51 |
+
inputs.title.val(editor.dom.getAttrib(linkNode, 'title'));
|
52 |
+
}
|
53 |
+
return wpmsLinkTitle.origmceRefresh.apply(this, arguments);
|
54 |
+
},
|
55 |
+
getAttrs: function () {
|
56 |
+
attrs = wpmsLinkTitle.origgetAttrs.apply(this, arguments);
|
57 |
+
attrs.title = $.trim(inputs.title.val());
|
58 |
+
return attrs;
|
59 |
+
},
|
60 |
+
htmlUpdate: function () {
|
61 |
+
var attrs, text, html, begin, end, cursor, selection,
|
62 |
+
textarea = wpLink.textarea;
|
63 |
+
|
64 |
+
if (!textarea) {
|
65 |
+
return;
|
66 |
+
}
|
67 |
+
|
68 |
+
attrs = wpmsLinkTitle.getAttrs();
|
69 |
+
text = inputs.text.val();
|
70 |
+
|
71 |
+
// If there's no href, return.
|
72 |
+
if (!attrs.href) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
// Build HTML
|
77 |
+
html = '<a href="' + attrs.href + '"';
|
78 |
+
|
79 |
+
if (attrs.title) {
|
80 |
+
title = attrs.title.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
81 |
+
html += ' title="' + title + '"';
|
82 |
+
}
|
83 |
+
|
84 |
+
if (attrs.target) {
|
85 |
+
html += ' target="' + attrs.target + '"';
|
86 |
+
}
|
87 |
+
|
88 |
+
html += '>';
|
89 |
+
|
90 |
+
// Insert HTML
|
91 |
+
if (document.selection && wpLink.range) {
|
92 |
+
// IE
|
93 |
+
// Note: If no text is selected, IE will not place the cursor
|
94 |
+
// inside the closing tag.
|
95 |
+
textarea.focus();
|
96 |
+
wpLink.range.text = html + (text || wpLink.range.text) + '</a>';
|
97 |
+
wpLink.range.moveToBookmark(wpLink.range.getBookmark());
|
98 |
+
wpLink.range.select();
|
99 |
+
|
100 |
+
wpLink.range = null;
|
101 |
+
} else if (typeof textarea.selectionStart !== 'undefined') {
|
102 |
+
// W3C
|
103 |
+
begin = textarea.selectionStart;
|
104 |
+
end = textarea.selectionEnd;
|
105 |
+
selection = text || textarea.value.substring(begin, end);
|
106 |
+
html = html + selection + '</a>';
|
107 |
+
cursor = begin + html.length;
|
108 |
+
|
109 |
+
// If no text is selected, place the cursor inside the closing tag.
|
110 |
+
if (begin === end && !selection) {
|
111 |
+
cursor -= 4;
|
112 |
+
}
|
113 |
+
|
114 |
+
textarea.value = (
|
115 |
+
textarea.value.substring(0, begin) +
|
116 |
+
html +
|
117 |
+
textarea.value.substring(end, textarea.value.length)
|
118 |
+
);
|
119 |
+
|
120 |
+
// Update cursor position
|
121 |
+
textarea.selectionStart = textarea.selectionEnd = cursor;
|
122 |
+
}
|
123 |
+
|
124 |
+
wpLink.close();
|
125 |
+
textarea.focus();
|
126 |
+
},
|
127 |
+
updateFields: function (e, li) {
|
128 |
+
inputs.title.val(li.hasClass('no-title') ? '' : li.children('.item-title').text());
|
129 |
+
},
|
130 |
+
setDefaultValues: function () {
|
131 |
+
inputs.title.val('');
|
132 |
+
return wpmsLinkTitle.origsetDefaultValues.apply(this, arguments);
|
133 |
+
}
|
134 |
+
};
|
135 |
+
|
136 |
+
$(document).ready(wpmsLinkTitle.init);
|
137 |
+
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: JoomUnited
|
3 |
Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo, redirect, redirection, 301, broken link
|
4 |
Requires at least: 4.0
|
5 |
-
Tested up to: 4.6.
|
6 |
-
Stable tag: 3.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -227,6 +227,14 @@ It could be! if you have a lot of pages that need to be indexed with no specific
|
|
227 |
|
228 |
== Changelog ==
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
= 3.0.2 =
|
231 |
* Add Import meta from Yoast premium plugin
|
232 |
* Fix font called from http instead of https from dashboard
|
@@ -369,7 +377,7 @@ Sitemap feature with XML for the Google Search console and HTML with display opt
|
|
369 |
|
370 |
= SEO vision =
|
371 |
|
372 |
-
Search engines are a major source of traffic for most websites. That
|
373 |
WP Meta SEO has been created to give to professionals and final users some real SEO tools to get better SEO rank. We think that SEO has to be something logic and durable. Overall SEO optimization requires a lot of time for each website, each client.
|
374 |
|
375 |
WP Meta SEO provides some automatic tools to analyze your content and give to search engine a better content to analyze.
|
2 |
Contributors: JoomUnited
|
3 |
Tags: google, webmaster tools, keywords, meta, meta description, meta keywords, meta title, robots meta, search engine optimization, seo, wordpress seo, yahoo, image optimization, image resize, custom post seo, redirect, redirection, 301, broken link
|
4 |
Requires at least: 4.0
|
5 |
+
Tested up to: 4.6.1
|
6 |
+
Stable tag: 3.1.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
227 |
|
228 |
== Changelog ==
|
229 |
|
230 |
+
= 3.1.0 =
|
231 |
+
* Whole code optimization regarding plugin performance
|
232 |
+
* Add SQL query optimization regarding plugin performance
|
233 |
+
* Add Sanitize elements prints on frontend (XSS)
|
234 |
+
* Test and optimize the plugin to work on website with huge amount of content and small resources
|
235 |
+
* Fix save and generate new sitemap
|
236 |
+
* Fix warning with PHP 7.0
|
237 |
+
|
238 |
= 3.0.2 =
|
239 |
* Add Import meta from Yoast premium plugin
|
240 |
* Fix font called from http instead of https from dashboard
|
377 |
|
378 |
= SEO vision =
|
379 |
|
380 |
+
Search engines are a major source of traffic for most websites. That�s why our users often ask us for SEO tips and plugins that can help improve SEO of their WordPress sites.
|
381 |
WP Meta SEO has been created to give to professionals and final users some real SEO tools to get better SEO rank. We think that SEO has to be something logic and durable. Overall SEO optimization requires a lot of time for each website, each client.
|
382 |
|
383 |
WP Meta SEO provides some automatic tools to analyze your content and give to search engine a better content to analyze.
|
wp-meta-seo.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: WP Meta SEO
|
5 |
* Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
|
6 |
* Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
|
7 |
-
* Version: 3.0
|
8 |
* Text Domain: wp-meta-seo
|
9 |
* Domain Path: /languages
|
10 |
* Author: JoomUnited
|
@@ -30,7 +30,6 @@
|
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32 |
*/
|
33 |
-
|
34 |
// Make sure we don't expose any info if called directly
|
35 |
if (!function_exists('add_action')) {
|
36 |
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
|
@@ -47,15 +46,13 @@ if (!defined('URL'))
|
|
47 |
define('URL', get_site_url());
|
48 |
|
49 |
if (!defined('WPMSEO_VERSION')) {
|
50 |
-
define('WPMSEO_VERSION', '3.0
|
51 |
-
}
|
52 |
|
53 |
if (!defined('WPMSEO_FILE'))
|
54 |
define('WPMSEO_FILE', __FILE__);
|
55 |
|
56 |
register_activation_hook(__FILE__, array('WpMetaSeo', 'plugin_activation'));
|
57 |
-
register_deactivation_hook(__FILE__, array('WpMetaSeo', 'plugin_deactivation'));
|
58 |
-
|
59 |
|
60 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.wp-metaseo.php' );
|
61 |
add_action('init', array('WpMetaSeo', 'init'));
|
@@ -68,494 +65,524 @@ if (is_admin()) {
|
|
68 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-broken-link-table.php' );
|
69 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-admin.php' );
|
70 |
$GLOBALS['metaseo_admin'] = new MetaSeo_Admin;
|
71 |
-
|
72 |
add_filter('wp_prepare_attachment_for_js', array('MetaSeo_Image_List_Table', 'add_more_attachment_sizes_js'), 10, 2);
|
73 |
add_filter('image_size_names_choose', array('MetaSeo_Image_List_Table', 'add_more_attachment_sizes_choose'), 10, 1);
|
74 |
-
add_filter(
|
75 |
-
|
76 |
-
function metaseo_contactuser(
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
}
|
81 |
-
|
82 |
} else {
|
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 |
-
if($twitter_title != maybe_unserialize($twitter_title)) $twitter_title = '';
|
140 |
-
$meta_twitter_title = esc_attr($twitter_title);
|
141 |
-
if($meta_twitter_title == '') $meta_twitter_title = $meta_title_esc;
|
142 |
-
|
143 |
-
// get meta description for twitter
|
144 |
-
$twitter_desc = get_post_meta($wp_query->post->ID, '_metaseo_metatwitter-desc', true);
|
145 |
-
if($twitter_desc != maybe_unserialize($twitter_desc)) $twitter_desc = '';
|
146 |
-
$meta_twitter_desc = esc_attr($twitter_desc);
|
147 |
-
if($meta_twitter_desc == '') $meta_twitter_desc = $meta_description_esc;
|
148 |
-
|
149 |
-
$sitename = get_bloginfo('name');
|
150 |
-
$meta_twitter_site = get_user_meta($wp_query->post->post_author,'mtwitter',true);
|
151 |
-
$facebook_admin = get_user_meta($wp_query->post->post_author,'mfacebook',true);
|
152 |
-
|
153 |
-
$settings = get_option( '_metaseo_settings' );
|
154 |
-
if($settings){
|
155 |
-
if($meta_twitter_site == '' && $settings['metaseo_showtwitter'] != ''){
|
156 |
-
$meta_twitter_site = $settings['metaseo_showtwitter'];
|
157 |
-
}
|
158 |
-
|
159 |
-
if($facebook_admin == '' && $settings['metaseo_showfacebook'] != ''){
|
160 |
-
$facebook_admin = $settings['metaseo_showfacebook'];
|
161 |
-
}
|
162 |
}
|
163 |
-
|
164 |
-
$meta_twitter_card = (!empty($settings['metaseo_twitter_card']))?$settings['metaseo_twitter_card']:'summary';
|
165 |
-
$meta_twitter_image = get_post_meta($wp_query->post->ID,'_metaseo_metatwitter-image',true);
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
if($meta_facebook_title == '') $meta_facebook_title = $meta_title_esc;
|
170 |
-
|
171 |
-
$meta_facebook_desc = get_post_meta($wp_query->post->ID,'_metaseo_metaopengraph-desc',true);
|
172 |
-
if($meta_facebook_desc != maybe_unserialize($meta_facebook_desc)) $meta_facebook_desc = '';
|
173 |
-
if($meta_facebook_desc == '') $meta_facebook_desc = $meta_description_esc;
|
174 |
-
$meta_facebook_image = get_post_meta($wp_query->post->ID,'_metaseo_metaopengraph-image',true);
|
175 |
-
|
176 |
-
// check homepage is latest post
|
177 |
-
if(is_home()){
|
178 |
-
if($mshow_on_front == 'posts'){
|
179 |
-
$settings_title_home = esc_attr($settings['metaseo_title_home']);
|
180 |
-
$settings_desc_home = esc_attr($settings['metaseo_desc_home']);
|
181 |
-
if($settings_title_home != maybe_unserialize($settings_title_home)) $settings_title_home = '';
|
182 |
-
if($settings_desc_home != maybe_unserialize($settings_desc_home)) $settings_desc_home = '';
|
183 |
-
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = $settings_title_home;
|
184 |
-
$meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = $settings_desc_home;
|
185 |
-
|
186 |
-
if($settings['metaseo_title_home'] == ''){
|
187 |
-
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = esc_attr(get_bloginfo('name').' - '.get_bloginfo('description'));
|
188 |
-
}
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
-
}
|
202 |
-
|
203 |
-
// is front page
|
204 |
-
if(is_front_page() && 'page' == get_option( 'show_on_front' ) && is_page( get_option( 'page_on_front' ) ) ){
|
205 |
-
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = esc_attr(get_post_meta($mpage_on_front, '_metaseo_metatitle', true));
|
206 |
-
$meta_description = $meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = esc_attr(get_post_meta($mpage_on_front, '_metaseo_metadesc', true));
|
207 |
-
$page_follow = get_post_meta($mpage_on_front,'_metaseo_metafollow',true);
|
208 |
-
$page_index = get_post_meta($mpage_on_front,'_metaseo_metaindex',true);
|
209 |
-
}
|
210 |
-
|
211 |
-
if ( is_category() || is_tag() || is_tax() ) {
|
212 |
-
$term = $wp_query->get_queried_object();
|
213 |
-
$meta_title = $meta_title_esc = $meta_facebook_title = $meta_twitter_title = esc_attr($term->name);
|
214 |
-
$meta_description_esc = $meta_facebook_desc = $meta_twitter_desc = esc_attr($term->description);
|
215 |
$page_follow = 'follow';
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
$
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
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 |
'#<meta name="description" [^<>]+ ?>#i',
|
274 |
'<meta name="description" content="' . $meta_description_esc . '" />',
|
275 |
($meta_description_esc != '' ? true : false)),
|
276 |
-
|
277 |
'#<meta name="keywords" [^<>]+ ?>#i',
|
278 |
'<meta name="keywords" content="' . $meta_keywords_esc . '" />',
|
279 |
($meta_keywords_esc != '' ? true : false)),
|
280 |
-
|
281 |
'#<meta name="title" [^<>]+ ?>#i',
|
282 |
'<meta name="title" content="' . $meta_title_esc . '" />',
|
283 |
($meta_title_esc != '' ? true : false))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
);
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
if(!empty($settings['metaseo_follow'])){
|
290 |
-
$patterns['follow'] = array(
|
291 |
-
'#<meta name="robots" [^<>]+ ?>#i',
|
292 |
-
'<meta name="robots" content="'.$page_index.','.$page_follow.'" />'
|
293 |
-
);
|
294 |
-
}
|
295 |
-
|
296 |
-
if(get_post_meta($wp_query->post->ID, '_metaseo_metatitle', true) != ''){
|
297 |
-
$patterns['title'] = array(
|
298 |
'#<meta name="title" [^<>]+ ?>#i',
|
299 |
'<meta name="title" content="' . $meta_title_esc . '" />',
|
300 |
($meta_title_esc != '' ? true : false));
|
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 |
* Handle import of meta data from other installed plugins for SEO
|
397 |
*
|
398 |
* @since 1.5.0
|
399 |
*/
|
400 |
function wpmetaseo_aio_yoast_message() {
|
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 |
-
add_action('admin_notices', create_function('$notImportant', 'echo "<div class=\"error metaseo-import-wrn\"><p>". __("Be careful you installed 2 extensions doing almost the same thing, please deactivate AIOSEO or Yoast in order to work more clearly!", "wp-meta-seo") ."</p></div>";'), 1);
|
430 |
-
}
|
431 |
}
|
432 |
|
433 |
-
add_action(
|
434 |
|
435 |
-
function wpmetaseo_import_aio_meta_notice(){
|
436 |
-
|
437 |
}
|
438 |
|
439 |
-
function wpmetaseo_import_yoast_meta_notice(){
|
440 |
-
|
441 |
}
|
442 |
|
443 |
/**
|
444 |
* Encode or decode all values in string format of an array
|
445 |
*/
|
446 |
-
function metaseo_utf8($obj, $action = 'encode'){
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
}elseif (is_object($obj)) {
|
466 |
$vars = array_keys(get_object_vars($obj));
|
467 |
foreach ($vars as $var) {
|
468 |
metaseo_utf8($obj->$var, $action);
|
469 |
}
|
470 |
}
|
471 |
-
|
472 |
-
|
473 |
}
|
474 |
|
475 |
-
function text_link(
|
476 |
echo '<input class="cmb_text_link" type="text" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />';
|
477 |
-
|
478 |
}
|
479 |
-
add_action( 'cmb_render_text_link', 'text_link', 10, 2 );
|
480 |
|
481 |
-
add_action(
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
function wpms_template_redirect() {
|
483 |
-
if (
|
484 |
-
if (
|
485 |
$url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
|
486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
'status_code' => '404 Not Found',
|
495 |
-
'status_text' => '404 Not Found',
|
496 |
-
'type' => '404_automaticaly',
|
497 |
-
'broken_indexed' => 1,
|
498 |
-
'broken_internal' => 0,
|
499 |
-
'warning' => 0,
|
500 |
-
'dismissed' => 0
|
501 |
-
);
|
502 |
|
503 |
-
$
|
504 |
-
|
505 |
-
|
506 |
-
$sql = $wpdb->prepare( "SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE (link_url=%s OR link_url=%s) ",array( $url,esc_url($url) ) );
|
507 |
-
//$sql = $wpdb->prepare("SELECT * FROM ".$wpdb->prefix. "wpms_links WHERE link_url=%s AND (broken_indexed = %d OR broken_internal = %d) AND link_url_redirect != %s ",array(( $url ),1,1,""));
|
508 |
-
$links_broken = $wpdb->get_row($sql);
|
509 |
-
if(!empty($links_broken)){
|
510 |
-
|
511 |
-
$value = array('hit' => (int)$links_broken->hit + 1);
|
512 |
-
$wpdb->update(
|
513 |
$wpdb->prefix . 'wpms_links', $value, array('id' => $links_broken->id), array('%d'), array('%d')
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
}
|
520 |
-
}
|
521 |
-
|
522 |
-
$defaul_settings_404 = array('wpms_redirect_homepage' => 0, 'wpms_type_404' => 'none' , 'wpms_page_redirected' => 'none');
|
523 |
-
$wpms_settings_404 = get_option('wpms_settings_404');
|
524 |
-
if(is_array($wpms_settings_404)){
|
525 |
-
$defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
|
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 |
}
|
4 |
* Plugin Name: WP Meta SEO
|
5 |
* Plugin URI: http://www.joomunited.com/wordpress-products/wp-meta-seo
|
6 |
* Description: WP Meta SEO is a plugin for WordPress to fill meta for content, images and main SEO info in a single view.
|
7 |
+
* Version: 3.1.0
|
8 |
* Text Domain: wp-meta-seo
|
9 |
* Domain Path: /languages
|
10 |
* Author: JoomUnited
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32 |
*/
|
|
|
33 |
// Make sure we don't expose any info if called directly
|
34 |
if (!function_exists('add_action')) {
|
35 |
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
|
46 |
define('URL', get_site_url());
|
47 |
|
48 |
if (!defined('WPMSEO_VERSION')) {
|
49 |
+
define('WPMSEO_VERSION', '3.1.0');
|
50 |
+
}
|
51 |
|
52 |
if (!defined('WPMSEO_FILE'))
|
53 |
define('WPMSEO_FILE', __FILE__);
|
54 |
|
55 |
register_activation_hook(__FILE__, array('WpMetaSeo', 'plugin_activation'));
|
|
|
|
|
56 |
|
57 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.wp-metaseo.php' );
|
58 |
add_action('init', array('WpMetaSeo', 'init'));
|
65 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-broken-link-table.php' );
|
66 |
require_once( WPMETASEO_PLUGIN_DIR . 'inc/class.metaseo-admin.php' );
|
67 |
$GLOBALS['metaseo_admin'] = new MetaSeo_Admin;
|
68 |
+
|
69 |
add_filter('wp_prepare_attachment_for_js', array('MetaSeo_Image_List_Table', 'add_more_attachment_sizes_js'), 10, 2);
|
70 |
add_filter('image_size_names_choose', array('MetaSeo_Image_List_Table', 'add_more_attachment_sizes_choose'), 10, 1);
|
71 |
+
add_filter('user_contactmethods', 'metaseo_contactuser', 10, 1);
|
72 |
+
|
73 |
+
function metaseo_contactuser($contactusers) {
|
74 |
+
$contactusers['mtwitter'] = __('Twitter username (without @)', 'wp-meta-seo');
|
75 |
+
$contactusers['mfacebook'] = __('Facebook profile URL', 'wp-meta-seo');
|
76 |
+
return $contactusers;
|
77 |
}
|
78 |
+
|
79 |
} else {
|
80 |
+
|
81 |
+
/******** Check again and modify title, meta title, meta description before output ********/
|
82 |
+
add_action('init', 'buffer_start');
|
83 |
+
add_action('wp_head', 'buffer_end');
|
84 |
+
|
85 |
+
function buffer_start() {
|
86 |
+
ob_start("wpms_callback");
|
87 |
+
}
|
88 |
+
|
89 |
+
function buffer_end() {
|
90 |
+
ob_end_flush();
|
91 |
+
}
|
92 |
+
|
93 |
+
function wpms_callback($buffer) {
|
94 |
+
// modify buffer here, and then return the updated code
|
95 |
+
global $wp_query;
|
96 |
+
if(empty($wp_query->post->ID)){
|
97 |
+
return $buffer;
|
98 |
+
}
|
99 |
+
|
100 |
+
// get meta title
|
101 |
+
$meta_title = get_post_meta($wp_query->post->ID, '_metaseo_metatitle', true);
|
102 |
+
if ($meta_title != maybe_unserialize($meta_title))
|
103 |
+
$meta_title = '';
|
104 |
+
if ($meta_title == '')
|
105 |
+
$meta_title = $wp_query->post->post_title;
|
106 |
+
$meta_title_esc = esc_attr($meta_title);
|
107 |
+
|
108 |
+
// get meta keyword
|
109 |
+
$settings = get_option('_metaseo_settings');
|
110 |
+
if (isset($settings['metaseo_showkeywords']) && $settings['metaseo_showkeywords'] == 1) {
|
111 |
+
$meta_keywords = get_post_meta($wp_query->post->ID, '_metaseo_metakeywords', true);
|
112 |
+
$meta_keywords_esc = esc_attr($meta_keywords);
|
113 |
+
} else {
|
114 |
+
$meta_keywords_esc = '';
|
115 |
+
}
|
116 |
+
$page_follow = get_post_meta($wp_query->post->ID, '_metaseo_metafollow', true);
|
117 |
+
$page_index = get_post_meta($wp_query->post->ID, '_metaseo_metaindex', true);
|
118 |
+
|
119 |
+
// get meta description
|
120 |
+
$meta_description = get_post_meta($wp_query->post->ID, '_metaseo_metadesc', true);
|
121 |
+
if ($meta_description != maybe_unserialize($meta_description))
|
122 |
+
$meta_description = '';
|
123 |
+
if ($meta_description == '') {
|
124 |
+
$meta_description = (strlen($wp_query->post->post_content) > 156) ? substr($wp_query->post->post_content, 0, 152) . ' ...' : $wp_query->post->post_content;
|
125 |
+
}
|
126 |
+
$meta_description_esc = esc_attr($meta_description);
|
127 |
+
|
128 |
+
// get option reading
|
129 |
+
$mpage_for_posts = get_option('page_for_posts');
|
130 |
+
$mpage_on_front = get_option('page_on_front');
|
131 |
+
$mshow_on_front = get_option('show_on_front');
|
132 |
+
|
133 |
+
// check homepage is a page
|
134 |
+
if (get_post_meta($wp_query->post->ID, '_metaseo_metatitle', true) == '' && is_front_page()) {
|
135 |
+
$meta_title_esc = esc_attr($settings['metaseo_title_home']);
|
136 |
+
if ($meta_title_esc != maybe_unserialize($meta_title_esc))
|
137 |
+
$meta_title_esc = '';
|
138 |
+
}
|
139 |
+
|
140 |
+
if (get_post_meta($wp_query->post->ID, '_metaseo_metadesc', true) == '' && is_front_page()) {
|
141 |
+
$meta_description_esc = esc_attr($settings['metaseo_desc_home']);
|
142 |
+
if ($meta_description_esc != maybe_unserialize($meta_description_esc))
|
143 |
+
$meta_description_esc = '';
|
144 |
+
}
|
145 |
+
|
146 |
+
// get meta title for twitter
|
147 |
+
$twitter_title = get_post_meta($wp_query->post->ID, '_metaseo_metatwitter-title', true);
|
148 |
+
if ($twitter_title != maybe_unserialize($twitter_title))
|
149 |
+
$twitter_title = '';
|
150 |
+
$meta_twitter_title = esc_attr($twitter_title);
|
151 |
+
if ($meta_twitter_title == '')
|
152 |
+
$meta_twitter_title = $meta_title_esc;
|
153 |
+
|
154 |
+
// get meta description for twitter
|
155 |
+
$twitter_desc = get_post_meta($wp_query->post->ID, '_metaseo_metatwitter-desc', true);
|
156 |
+
if ($twitter_desc != maybe_unserialize($twitter_desc))
|
157 |
+
$twitter_desc = '';
|
158 |
+
$meta_twitter_desc = esc_attr($twitter_desc);
|
159 |
+
if ($meta_twitter_desc == '')
|
160 |
+
$meta_twitter_desc = $meta_description_esc;
|
161 |
+
|
162 |
+
$sitename = get_bloginfo('name');
|
163 |
+
$meta_twitter_site = get_user_meta($wp_query->post->post_author, 'mtwitter', true);
|
164 |
+
$facebook_admin = get_user_meta($wp_query->post->post_author, 'mfacebook', true);
|
165 |
+
|
166 |
+
$settings = get_option('_metaseo_settings');
|
167 |
+
if ($settings) {
|
168 |
+
if ($meta_twitter_site == '' && $settings['metaseo_showtwitter'] != '') {
|
169 |
+
$meta_twitter_site = $settings['metaseo_showtwitter'];
|
170 |
}
|
171 |
+
|
172 |
+
if ($facebook_admin == '' && $settings['metaseo_showfacebook'] != '') {
|
173 |
+
$facebook_admin = $settings['metaseo_showfacebook'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
+
}
|
|
|
|
|
176 |
|
177 |
+
$meta_twitter_card = (!empty($settings['metaseo_twitter_card'])) ? $settings['metaseo_twitter_card'] : 'summary';
|
178 |
+
$meta_twitter_image = get_post_meta($wp_query->post->ID, '_metaseo_metatwitter-image', true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
+
$meta_facebook_title = get_post_meta($wp_query->post->ID, '_metaseo_metaopengraph-title', true);
|
181 |
+
if ($meta_facebook_title != maybe_unserialize($meta_facebook_title))
|
182 |
+
$meta_facebook_title = '';
|
183 |
+
if ($meta_facebook_title == '')
|
184 |
+
$meta_facebook_title = $meta_title_esc;
|
185 |
+
|
186 |
+
$meta_facebook_desc = get_post_meta($wp_query->post->ID, '_metaseo_metaopengraph-desc', true);
|
187 |
+
if ($meta_facebook_desc != maybe_unserialize($meta_facebook_desc))
|
188 |
+
$meta_facebook_desc = '';
|
189 |
+
if ($meta_facebook_desc == '')
|
190 |
+
$meta_facebook_desc = $meta_description_esc;
|
191 |
+
$meta_facebook_image = get_post_meta($wp_query->post->ID, '_metaseo_metaopengraph-image', true);
|
192 |
+
|
193 |
+
// check homepage is latest post
|
194 |
+
if (is_home()) {
|
195 |
+
if ($mshow_on_front == 'posts') {
|
196 |
+
$settings_title_home = esc_attr($settings['metaseo_title_home']);
|
197 |
+
$settings_desc_home = esc_attr($settings['metaseo_desc_home']);
|
198 |
+
if ($settings_title_home != maybe_unserialize($settings_title_home))
|
199 |
+
$settings_title_home = '';
|
200 |
+
if ($settings_desc_home != maybe_unserialize($settings_desc_home))
|
201 |
+
$settings_desc_home = '';
|
202 |
+
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = $settings_title_home;
|
203 |
+
$meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = $settings_desc_home;
|
204 |
+
|
205 |
+
if ($settings['metaseo_title_home'] == '') {
|
206 |
+
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = esc_attr(get_bloginfo('name') . ' - ' . get_bloginfo('description'));
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($settings['metaseo_desc_home'] == '') {
|
210 |
+
$meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = esc_attr(get_bloginfo('description'));
|
211 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
$page_follow = 'follow';
|
213 |
+
$page_index = 'index';
|
214 |
+
} elseif ($mshow_on_front == 'page') { // is page posts
|
215 |
+
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = esc_attr(get_post_meta($mpage_for_posts, '_metaseo_metatitle', true));
|
216 |
+
$meta_description = $meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = esc_attr(get_post_meta($mpage_for_posts, '_metaseo_metadesc', true));
|
217 |
+
$page_follow = get_post_meta($mpage_for_posts, '_metaseo_metafollow', true);
|
218 |
+
$page_index = get_post_meta($mpage_for_posts, '_metaseo_metaindex', true);
|
219 |
}
|
220 |
+
}
|
221 |
+
|
222 |
+
// is front page
|
223 |
+
if (is_front_page() && 'page' == get_option('show_on_front') && is_page(get_option('page_on_front'))) {
|
224 |
+
$meta_title = $meta_title_esc = $meta_twitter_title = $meta_facebook_title = esc_attr(get_post_meta($mpage_on_front, '_metaseo_metatitle', true));
|
225 |
+
$meta_description = $meta_description_esc = $meta_twitter_desc = $meta_facebook_desc = esc_attr(get_post_meta($mpage_on_front, '_metaseo_metadesc', true));
|
226 |
+
$page_follow = get_post_meta($mpage_on_front, '_metaseo_metafollow', true);
|
227 |
+
$page_index = get_post_meta($mpage_on_front, '_metaseo_metaindex', true);
|
228 |
+
}
|
229 |
+
|
230 |
+
if (is_category() || is_tag() || is_tax()) {
|
231 |
+
$term = $wp_query->get_queried_object();
|
232 |
+
$meta_title = $meta_title_esc = $meta_facebook_title = $meta_twitter_title = esc_attr($term->name);
|
233 |
+
$meta_description_esc = $meta_facebook_desc = $meta_twitter_desc = esc_attr($term->description);
|
234 |
+
$page_follow = 'follow';
|
235 |
+
}
|
236 |
+
|
237 |
+
$current_url = 'http' . (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
238 |
+
$current_url = esc_url($current_url);
|
239 |
+
|
240 |
+
// create List array meta tag
|
241 |
+
$patterns = array(
|
242 |
+
'twitter_image' => array(
|
243 |
+
'#<meta name="twitter:image" [^<>]+ ?>#i',
|
244 |
+
'<meta name="twitter:image" content="' . $meta_twitter_image . '" />',
|
245 |
+
($meta_twitter_image != '' ? true : false)),
|
246 |
+
'twitter_card' => array(
|
247 |
+
'#<meta name="twitter:card" [^<>]+ ?>#i',
|
248 |
+
'<meta name="twitter:card" content="' . $meta_twitter_card . '" />',
|
249 |
+
($meta_twitter_card != '' ? true : false)),
|
250 |
+
'twitter_site' => array(
|
251 |
+
'#<meta name="twitter:site" [^<>]+ ?>#i',
|
252 |
+
'<meta name="twitter:site" content="@' . $meta_twitter_site . '" />',
|
253 |
+
($meta_twitter_site != '' ? true : false)),
|
254 |
+
'twitter_domain' => array(
|
255 |
+
'#<meta name="twitter:domain" [^<>]+ ?>#i',
|
256 |
+
'<meta name="twitter:domain" content="' . $sitename . '" />',
|
257 |
+
($sitename != '' ? true : false)),
|
258 |
+
'twitter_desc' => array(
|
259 |
+
'#<meta name="twitter:description" [^<>]+ ?>#i',
|
260 |
+
'<meta name="twitter:description" content="' . $meta_twitter_desc . '" />',
|
261 |
+
($meta_twitter_desc != '' ? true : false)),
|
262 |
+
'twitter_title' => array(
|
263 |
+
'#<meta name="twitter:title" [^<>]+ ?>#i',
|
264 |
+
'<meta name="twitter:title" content="' . $meta_twitter_title . '" />',
|
265 |
+
($meta_twitter_title != '' ? true : false)),
|
266 |
+
'_title' => array('/<title.*?\/title>/i', '<title>' . $meta_title . '</title>',
|
267 |
+
($meta_title != '' ? true : false)),
|
268 |
+
'facebook_admin' => array(
|
269 |
+
'#<meta property="fb:admins" [^<>]+ ?>#i',
|
270 |
+
'<meta property="fb:admins" content="' . $facebook_admin . '" />',
|
271 |
+
($facebook_admin != '' ? true : false)),
|
272 |
+
'facebook_image' => array(
|
273 |
+
'#<meta property="og:image" [^<>]+ ?>#i',
|
274 |
+
'<meta property="og:image" content="' . $meta_facebook_image . '" />',
|
275 |
+
($meta_facebook_image != '' ? true : false)),
|
276 |
+
'site_name' => array(
|
277 |
+
'#<meta property="og:site_name" [^<>]+ ?>#i',
|
278 |
+
'<meta property="og:site_name" content="' . $sitename . '" />',
|
279 |
+
($sitename != '' ? true : false)),
|
280 |
+
'og:description' => array(
|
281 |
+
'#<meta property="og:description" [^<>]+ ?>#i',
|
282 |
+
'<meta property="og:description" content="' . $meta_facebook_desc . '" />',
|
283 |
+
($meta_facebook_desc != '' ? true : false)),
|
284 |
+
'og:url' => array(
|
285 |
+
'#<meta property="og:url" [^<>]+ ?>#i',
|
286 |
+
'<meta property="og:url" content="' . $current_url . '" />',
|
287 |
+
($current_url != '' ? true : false)),
|
288 |
+
'og:title' => array(
|
289 |
+
'#<meta property="og:title" [^<>]+ ?>#i',
|
290 |
+
'<meta property="og:title" content="' . $meta_facebook_title . '" />',
|
291 |
+
($meta_facebook_title != '' ? true : false)),
|
292 |
+
'_description' => array(
|
293 |
'#<meta name="description" [^<>]+ ?>#i',
|
294 |
'<meta name="description" content="' . $meta_description_esc . '" />',
|
295 |
($meta_description_esc != '' ? true : false)),
|
296 |
+
'keywords' => array(
|
297 |
'#<meta name="keywords" [^<>]+ ?>#i',
|
298 |
'<meta name="keywords" content="' . $meta_keywords_esc . '" />',
|
299 |
($meta_keywords_esc != '' ? true : false)),
|
300 |
+
'title' => array(
|
301 |
'#<meta name="title" [^<>]+ ?>#i',
|
302 |
'<meta name="title" content="' . $meta_title_esc . '" />',
|
303 |
($meta_title_esc != '' ? true : false))
|
304 |
+
);
|
305 |
+
|
306 |
+
if (empty($page_index))
|
307 |
+
$page_index = 'index';
|
308 |
+
if (empty($page_follow))
|
309 |
+
$page_follow = 'follow';
|
310 |
+
|
311 |
+
if (!empty($settings['metaseo_follow'])) {
|
312 |
+
$patterns['follow'] = array(
|
313 |
+
'#<meta name="robots" [^<>]+ ?>#i',
|
314 |
+
'<meta name="robots" content="' . $page_index . ',' . $page_follow . '" />'
|
315 |
);
|
316 |
+
}
|
317 |
+
|
318 |
+
if (get_post_meta($wp_query->post->ID, '_metaseo_metatitle', true) != '') {
|
319 |
+
$patterns['title'] = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
'#<meta name="title" [^<>]+ ?>#i',
|
321 |
'<meta name="title" content="' . $meta_title_esc . '" />',
|
322 |
($meta_title_esc != '' ? true : false));
|
323 |
+
}
|
324 |
+
|
325 |
+
// unset meta tag if empty value
|
326 |
+
if ($meta_keywords_esc == '') {
|
327 |
+
unset($patterns['keywords']);
|
328 |
+
}
|
329 |
+
|
330 |
+
if ($meta_twitter_site == '') {
|
331 |
+
unset($patterns['twitter_site']);
|
332 |
+
}
|
333 |
+
|
334 |
+
if ($meta_twitter_image == '') {
|
335 |
+
unset($patterns['twitter_image']);
|
336 |
+
}
|
337 |
+
|
338 |
+
if ($meta_twitter_title == '') {
|
339 |
+
unset($patterns['twitter_title']);
|
340 |
+
}
|
341 |
+
|
342 |
+
if ($meta_twitter_desc == '') {
|
343 |
+
unset($patterns['twitter_desc']);
|
344 |
+
}
|
345 |
+
|
346 |
+
if ($meta_facebook_desc == '') {
|
347 |
+
unset($patterns['og:description']);
|
348 |
+
}
|
349 |
+
|
350 |
+
if ($meta_description_esc == '') {
|
351 |
+
unset($patterns['_description']);
|
352 |
+
}
|
353 |
+
|
354 |
+
if ($facebook_admin == '') {
|
355 |
+
unset($patterns['facebook_admin']);
|
356 |
+
}
|
357 |
+
|
358 |
+
if ($meta_facebook_image == '') {
|
359 |
+
unset($patterns['facebook_image']);
|
360 |
+
}
|
361 |
+
|
362 |
+
$default_settings = array(
|
363 |
+
"metaseo_title_home" => "",
|
364 |
+
"metaseo_desc_home" => "",
|
365 |
+
"metaseo_showfacebook" => "",
|
366 |
+
"metaseo_showtwitter" => "",
|
367 |
+
"metaseo_twitter_card" => "summary",
|
368 |
+
"metaseo_showkeywords" => 0,
|
369 |
+
"metaseo_showtmetablock" => 1,
|
370 |
+
"metaseo_showsocial" => 1,
|
371 |
+
"metaseo_metatitle_tab" => 0
|
372 |
+
);
|
373 |
+
|
374 |
+
if (is_array($settings)) {
|
375 |
+
$default_settings = array_merge($default_settings, $settings);
|
376 |
+
}
|
377 |
+
|
378 |
+
if (empty($default_settings['metaseo_metatitle_tab'])) {
|
379 |
+
unset($patterns['_title']);
|
380 |
+
}
|
381 |
+
|
382 |
+
// unset meta tag if empty value
|
383 |
+
if ((isset($default_settings['metaseo_showsocial']) && $default_settings['metaseo_showsocial'] == 0)) {
|
384 |
+
unset($patterns['twitter_image']);
|
385 |
+
unset($patterns['twitter_card']);
|
386 |
+
unset($patterns['twitter_site']);
|
387 |
+
unset($patterns['twitter_domain']);
|
388 |
+
unset($patterns['twitter_desc']);
|
389 |
+
unset($patterns['twitter_title']);
|
390 |
+
unset($patterns['facebook_admin']);
|
391 |
+
unset($patterns['facebook_image']);
|
392 |
+
unset($patterns['site_name']);
|
393 |
+
unset($patterns['og:description']);
|
394 |
+
unset($patterns['og:title']);
|
395 |
+
}
|
396 |
+
|
397 |
+
foreach ($patterns as $k => $pattern) {
|
398 |
+
if (preg_match_all($pattern[0], $buffer, $matches)) {
|
399 |
+
$replacement = array();
|
400 |
+
foreach ($matches[0] as $key => $match) {
|
401 |
+
if ($key < 1) {
|
402 |
+
$replacement[] = $pattern[2] ? $pattern[1] : $match . "\n";
|
403 |
+
} else {
|
404 |
+
$replacement[] = '';
|
405 |
}
|
406 |
+
}
|
407 |
+
|
408 |
+
$buffer = str_ireplace($matches[0], $replacement, $buffer);
|
409 |
+
} else {
|
410 |
+
$buffer = str_ireplace('</title>', "</title>\n" . $pattern[1], $buffer);
|
411 |
}
|
412 |
+
}
|
413 |
|
414 |
+
return $buffer;
|
415 |
+
}
|
416 |
+
|
417 |
+
/* * ******************************************** */
|
418 |
}
|
419 |
|
420 |
+
/* * ****** Check and import meta data from other installed plugins for SEO ******* */
|
421 |
+
|
422 |
/**
|
423 |
* Handle import of meta data from other installed plugins for SEO
|
424 |
*
|
425 |
* @since 1.5.0
|
426 |
*/
|
427 |
function wpmetaseo_aio_yoast_message() {
|
428 |
+
$activated = 0;
|
429 |
+
// Check if All In One Pack is active
|
430 |
+
if (!get_option('_aio_import_notice_flag')) {
|
431 |
+
if (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php')) {
|
432 |
+
add_action('admin_notices', 'wpmetaseo_import_aio_meta_notice', 2);
|
433 |
+
$activated++;
|
434 |
+
}
|
435 |
+
|
436 |
+
if (get_option('_aio_import_notice_flag') === false) {
|
437 |
+
update_option('_aio_import_notice_flag', 0);
|
438 |
+
}
|
439 |
+
}
|
440 |
+
// Check if Yoast is active
|
441 |
+
if (!get_option('_yoast_import_notice_flag', false)) {
|
442 |
+
if (is_plugin_active('wordpress-seo/wp-seo.php') || is_plugin_active('Yoast-SEO-Premium/wp-seo-premium.php') || class_exists('WPSEO_Premium')) {
|
443 |
+
add_action('admin_notices', 'wpmetaseo_import_yoast_meta_notice', 3);
|
444 |
+
$activated++;
|
445 |
+
}
|
446 |
+
|
447 |
+
if (get_option('_yoast_import_notice_flag') === false) {
|
448 |
+
update_option('_yoast_import_notice_flag', 0);
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
|
453 |
+
if ($activated === 2 && !get_option('plugin_to_sync_with', false)) {
|
454 |
+
add_action('admin_notices', create_function('$notImportant', 'echo "<div class=\"error metaseo-import-wrn\"><p>". __("Be careful you installed 2 extensions doing almost the same thing, please deactivate AIOSEO or Yoast in order to work more clearly!", "wp-meta-seo") ."</p></div>";'), 1);
|
455 |
+
}
|
|
|
|
|
456 |
}
|
457 |
|
458 |
+
add_action('admin_init', 'wpmetaseo_aio_yoast_message');
|
459 |
|
460 |
+
function wpmetaseo_import_aio_meta_notice() {
|
461 |
+
echo '<div class="error metaseo-import-wrn"><p>' . sprintf(__('We have found that you’re using All In One Pack Plugin, WP Meta SEO can import the meta from this plugin, %s', 'wp-meta-seo'), '<a href="#" class="button mseo-import-action" style="position:relative" onclick="importMetaData(this, event)" id="_aio_"><span class="spinner-light"></span>Import now</a> or <a href="#" class="dissmiss-import">dismiss this</a>') . '</p></div>';
|
462 |
}
|
463 |
|
464 |
+
function wpmetaseo_import_yoast_meta_notice() {
|
465 |
+
echo '<div class="error metaseo-import-wrn"><p>' . sprintf(__('We have found that you’re using Yoast SEO Plugin, WP Meta SEO can import the meta from this plugin, %s', 'wp-meta-seo'), '<a href="#" class="button mseo-import-action" style="position:relative" onclick="importMetaData(this, event)" id="_yoast_">Import now<span class="spinner-light"></span></a> or <a href="#" class="dissmiss-import">dismiss this</a>') . '</p></div>';
|
466 |
}
|
467 |
|
468 |
/**
|
469 |
* Encode or decode all values in string format of an array
|
470 |
*/
|
471 |
+
function metaseo_utf8($obj, $action = 'encode') {
|
472 |
+
$action = strtolower(trim($action));
|
473 |
+
$fn = "utf8_$action";
|
474 |
+
if (is_array($obj)) {
|
475 |
+
foreach ($obj as &$el) {
|
476 |
+
if (is_array($el)) {
|
477 |
+
if (is_callable($fn)) {
|
478 |
+
$el = metaseo_utf8($el, $action);
|
479 |
+
}
|
480 |
+
} elseif (is_string($el)) {
|
481 |
+
$isASCII = mb_detect_encoding($el, 'ASCII');
|
482 |
+
if ($action === 'encode' && !$isASCII) {
|
483 |
+
$el = mb_convert_encoding($el, "UTF-8", "auto");
|
484 |
+
}
|
485 |
+
|
486 |
+
$el = $fn($el);
|
487 |
+
}
|
488 |
+
}
|
489 |
+
} elseif (is_object($obj)) {
|
|
|
490 |
$vars = array_keys(get_object_vars($obj));
|
491 |
foreach ($vars as $var) {
|
492 |
metaseo_utf8($obj->$var, $action);
|
493 |
}
|
494 |
}
|
495 |
+
|
496 |
+
return $obj;
|
497 |
}
|
498 |
|
499 |
+
function text_link($field, $meta) {
|
500 |
echo '<input class="cmb_text_link" type="text" size="45" id="', $field['id'], '" name="', $field['id'], '" value="', $meta, '" />';
|
501 |
+
echo '<input class="cmb_link_button button" type="button" value="Voeg link toe" />', '<p class="cmb_metabox_description">', $field['desc'], '</p>';
|
502 |
}
|
|
|
503 |
|
504 |
+
add_action('cmb_render_text_link', 'text_link', 10, 2);
|
505 |
+
|
506 |
+
add_action('template_redirect', 'wpms_template_redirect');
|
507 |
+
|
508 |
+
/*
|
509 |
+
* Redirect 404 url and insert url to database
|
510 |
+
*/
|
511 |
function wpms_template_redirect() {
|
512 |
+
if (is_404()) {
|
513 |
+
if (isset($_SERVER['REQUEST_URI']))
|
514 |
$url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
|
515 |
+
global $wpdb;
|
516 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE (link_url=%s OR link_url=%s)", array($url, esc_url($url)));
|
517 |
+
$check = $wpdb->get_results($sql);
|
518 |
+
if (count($check) == 0) {
|
519 |
+
// insert url
|
520 |
+
$insert = array(
|
521 |
+
'link_url' => ( $url ),
|
522 |
+
'status_code' => '404 Not Found',
|
523 |
+
'status_text' => '404 Not Found',
|
524 |
+
'type' => '404_automaticaly',
|
525 |
+
'broken_indexed' => 1,
|
526 |
+
'broken_internal' => 0,
|
527 |
+
'warning' => 0,
|
528 |
+
'dismissed' => 0
|
529 |
+
);
|
530 |
|
531 |
+
$wpdb->insert($wpdb->prefix . 'wpms_links', $insert);
|
532 |
+
} else {
|
533 |
+
// update url
|
534 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "wpms_links WHERE (link_url=%s OR link_url=%s) ", array($url, esc_url($url)));
|
535 |
+
$links_broken = $wpdb->get_row($sql);
|
536 |
+
if (!empty($links_broken)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
|
538 |
+
$value = array('hit' => (int) $links_broken->hit + 1);
|
539 |
+
$wpdb->update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
$wpdb->prefix . 'wpms_links', $value, array('id' => $links_broken->id), array('%d'), array('%d')
|
541 |
+
);
|
542 |
+
if (($url == $links_broken->link_url || esc_url($url) == $links_broken->link_url) && $links_broken->link_url_redirect != '') {
|
543 |
+
wp_redirect(($links_broken->link_url_redirect));
|
544 |
+
exit();
|
545 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
}
|
547 |
+
}
|
548 |
|
549 |
+
$defaul_settings_404 = array('wpms_redirect_homepage' => 0, 'wpms_type_404' => 'none', 'wpms_page_redirected' => 'none');
|
550 |
+
$wpms_settings_404 = get_option('wpms_settings_404');
|
551 |
+
if (is_array($wpms_settings_404)) {
|
552 |
+
$defaul_settings_404 = array_merge($defaul_settings_404, $wpms_settings_404);
|
553 |
+
}
|
554 |
+
|
555 |
+
// redirect url by settings
|
556 |
+
if (isset($defaul_settings_404['wpms_redirect_homepage']) && $defaul_settings_404['wpms_redirect_homepage'] == 1) {
|
557 |
+
wp_redirect(get_home_url());
|
558 |
+
exit();
|
559 |
+
} else {
|
560 |
+
if (isset($defaul_settings_404['wpms_type_404'])) {
|
561 |
+
switch ($defaul_settings_404['wpms_type_404']) {
|
562 |
+
case 'wp-meta-seo-page':
|
563 |
+
global $wpdb;
|
564 |
+
$sql = $wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "posts WHERE post_title = %s AND post_excerpt = %s", array("WP Meta SEO 404 Page", "metaseo_404_page"));
|
565 |
+
$wpms_page = $wpdb->get_row($sql);
|
566 |
+
if (!empty($wpms_page)) {
|
567 |
+
$link_redirect = get_permalink($wpms_page->ID);
|
568 |
+
if ($link_redirect) {
|
569 |
+
wp_redirect($link_redirect);
|
570 |
+
exit();
|
571 |
}
|
572 |
+
}
|
573 |
+
break;
|
574 |
+
|
575 |
+
case 'custom_page':
|
576 |
+
if (isset($defaul_settings_404['wpms_page_redirected']) && $defaul_settings_404['wpms_page_redirected'] != 'none') {
|
577 |
+
$link_redirect = get_permalink($defaul_settings_404['wpms_page_redirected']);
|
578 |
+
if ($link_redirect) {
|
579 |
+
wp_redirect($link_redirect);
|
580 |
+
exit();
|
581 |
}
|
582 |
+
}
|
583 |
+
break;
|
584 |
}
|
|
|
585 |
}
|
586 |
+
}
|
587 |
}
|
588 |
}
|