Version Description
Download this release
Release Info
Developer | qqworld |
Plugin | QQWorld Auto Save Images |
Version | 1.5.7.4 |
Comparing to | |
See all releases |
Code changes from version 1.5.7.2 to 1.5.7.4
- js/script.js +370 -0
- lang/qqworld_auto_save_images-zh_CN.mo +0 -0
- lang/qqworld_auto_save_images-zh_CN.po +6 -3
- qqworld-auto-save-images.php +105 -410
js/script.js
ADDED
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function str_repeat(i, m) {
|
2 |
+
for (var o = []; m > 0; o[--m] = i);
|
3 |
+
return o.join('');
|
4 |
+
}
|
5 |
+
function sprintf() {
|
6 |
+
var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
|
7 |
+
while (f) {
|
8 |
+
if (m = /^[^\x25]+/.exec(f)) {
|
9 |
+
o.push(m[0]);
|
10 |
+
}
|
11 |
+
else if (m = /^\x25{2}/.exec(f)) {
|
12 |
+
o.push('%');
|
13 |
+
}
|
14 |
+
else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
|
15 |
+
if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
|
16 |
+
throw('Too few arguments.');
|
17 |
+
}
|
18 |
+
if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
|
19 |
+
throw('Expecting number but found ' + typeof(a));
|
20 |
+
}
|
21 |
+
switch (m[7]) {
|
22 |
+
case 'b': a = a.toString(2); break;
|
23 |
+
case 'c': a = String.fromCharCode(a); break;
|
24 |
+
case 'd': a = parseInt(a); break;
|
25 |
+
case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
|
26 |
+
case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
|
27 |
+
case 'o': a = a.toString(8); break;
|
28 |
+
case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
|
29 |
+
case 'u': a = Math.abs(a); break;
|
30 |
+
case 'x': a = a.toString(16); break;
|
31 |
+
case 'X': a = a.toString(16).toUpperCase(); break;
|
32 |
+
}
|
33 |
+
a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
|
34 |
+
c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
|
35 |
+
x = m[5] - String(a).length - s.length;
|
36 |
+
p = m[5] ? str_repeat(c, x) : '';
|
37 |
+
o.push(s + (m[4] ? a + p : p + a));
|
38 |
+
}
|
39 |
+
else {
|
40 |
+
throw('Huh ?!');
|
41 |
+
}
|
42 |
+
f = f.substring(m[0].length);
|
43 |
+
}
|
44 |
+
return o.join('');
|
45 |
+
}
|
46 |
+
|
47 |
+
if (!QQWorld_auto_save_images) var QQWorld_auto_save_images = {};
|
48 |
+
QQWorld_auto_save_images.scan_posts = function() {
|
49 |
+
var _this = this,
|
50 |
+
$ = jQuery;
|
51 |
+
|
52 |
+
this.action = {};
|
53 |
+
this.action.catch_errors = function(XMLHttpRequest, textStatus, errorThrown) {
|
54 |
+
var error='', args=new Array;
|
55 |
+
error += '<div style="text-align: left;">';
|
56 |
+
var query = this.data.split('&');
|
57 |
+
var data = new Array;
|
58 |
+
var offset_from_id = $('input[name="offset"]').val();
|
59 |
+
var temp_r = $('body').data('r') + parseInt(offset_from_id);
|
60 |
+
for (var d in query) {
|
61 |
+
var q = query[d].split('=');
|
62 |
+
if (q[0]=='post_id[]') {
|
63 |
+
temp_r++;
|
64 |
+
data.push(q[1]+'(No. '+temp_r+')');
|
65 |
+
}
|
66 |
+
}
|
67 |
+
error += QASI.maybe_problem + data.join(', ');
|
68 |
+
if (XMLHttpRequest) {
|
69 |
+
error += '<hr />';
|
70 |
+
args = new Array;
|
71 |
+
for (var x in XMLHttpRequest) {
|
72 |
+
switch (x) {
|
73 |
+
case 'readyState':
|
74 |
+
case 'responseText':
|
75 |
+
case 'status':
|
76 |
+
args.push( x + ': ' + XMLHttpRequest[x] );
|
77 |
+
break;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
error += args.join('<br />', args);
|
81 |
+
}
|
82 |
+
error += '<br />' + textStatus + ': ' + errorThrown;
|
83 |
+
error += '</div>';
|
84 |
+
$('#form').slideDown('slow');
|
85 |
+
$('body').data('noty').close();
|
86 |
+
noty({
|
87 |
+
text: error,
|
88 |
+
type: 'error',
|
89 |
+
layout: 'bottom',
|
90 |
+
dismissQueue: true,
|
91 |
+
closeWith: ['button']
|
92 |
+
});
|
93 |
+
$('#scan_old_posts').removeAttr('disabled');
|
94 |
+
$('#list_all_posts').removeAttr('disabled');
|
95 |
+
$('body').data('r', $('body').data('r')+$('body').data('speed'));
|
96 |
+
switch ($('body').data('scan-mode')) {
|
97 |
+
case 'scan':
|
98 |
+
_this.action.scan($('body').data('respond'), $('body').data('r'));
|
99 |
+
break;
|
100 |
+
case 'list':
|
101 |
+
_this.action.list($('body').data('respond'), $('body').data('r'));
|
102 |
+
break;
|
103 |
+
}
|
104 |
+
};
|
105 |
+
this.action.scan = function(respond, r) {
|
106 |
+
var $ = jQuery;
|
107 |
+
$('body').data('scan-mode', 'scan').data('r', r);
|
108 |
+
if (typeof respond[r] == 'undefined') {
|
109 |
+
$('#scan-result').effect( 'shake', null, 500 );
|
110 |
+
$('#form').slideDown('slow');
|
111 |
+
$('body').data('noty').close();
|
112 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
113 |
+
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
114 |
+
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
115 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
116 |
+
if (count) {
|
117 |
+
if (count==1) count_html = sprintf(QASI.n_post_has_been_scanned, count);
|
118 |
+
else count_html = sprintf(QASI.n_posts_have_been_scanned, count);
|
119 |
+
if (count_remote_images) {
|
120 |
+
count_remote_images = count_remote_images - count_not_exits_remote_images;
|
121 |
+
if (count_remote_images<=1) count_html += sprintf("<br />"+QASI.n_post_included_remote_images_processed, count_remote_images);
|
122 |
+
else count_html += sprintf("<br />"+QASI.n_posts_included_remote_images_processed, count_remote_images);
|
123 |
+
if (count_not_exits_remote_images) {
|
124 |
+
if (count_not_exits_remote_images==1) count_html += sprintf("<br />"+QASI.n_post_has_missing_images_couldnt_be_processed, count_not_exits_remote_images);
|
125 |
+
else count_html += sprintf("<br />"+QASI.n_posts_have_missing_images_couldnt_be_processed, count_not_exits_remote_images);
|
126 |
+
}
|
127 |
+
} else count_html += '<br />'+QASI.no_posts_processed;
|
128 |
+
} else {
|
129 |
+
$('#scan_old_post_list').slideUp('slow');
|
130 |
+
count_html = QASI.no_posts_found;
|
131 |
+
}
|
132 |
+
noty({
|
133 |
+
text: QASI.all_done+'<br />'+count_html,
|
134 |
+
type: 'success',
|
135 |
+
layout: 'center',
|
136 |
+
dismissQueue: true,
|
137 |
+
modal: true
|
138 |
+
});
|
139 |
+
$('#scan_old_posts').removeAttr('disabled');
|
140 |
+
$('#list_all_posts').removeAttr('disabled');
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
var speed = parseInt($('select[name="speed"]').val());
|
144 |
+
post_id = new Array;
|
145 |
+
$('body').data('speed', speed);
|
146 |
+
var data = 'action=save_remote_images_after_scan';
|
147 |
+
for (var p=r; p<r+speed; p++) {
|
148 |
+
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
149 |
+
}
|
150 |
+
console.log(data);
|
151 |
+
$.ajax({
|
152 |
+
type: 'POST',
|
153 |
+
url: ajaxurl,
|
154 |
+
data: data,
|
155 |
+
success: function(data) {
|
156 |
+
data = $(data);
|
157 |
+
$('#scan_old_post_list tbody').append(data);
|
158 |
+
data.hide().fadeIn('fast');
|
159 |
+
r += speed;
|
160 |
+
_this.action.scan(respond, r);
|
161 |
+
},
|
162 |
+
error: _this.action.catch_errors
|
163 |
+
});
|
164 |
+
};
|
165 |
+
this.action.list = function(respond, r) {
|
166 |
+
var $ = jQuery;
|
167 |
+
$('body').data('scan-mode', 'list').data('r', r);
|
168 |
+
if (typeof respond[r] == 'undefined') {
|
169 |
+
$('#scan-result').effect( 'shake', null, 500 );
|
170 |
+
$('#form').slideDown('slow');
|
171 |
+
$('body').data('noty').close();
|
172 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
173 |
+
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
174 |
+
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
175 |
+
if (count) {
|
176 |
+
if (count==1) count_html = sprintf(QASI.n_post_has_been_scanned, count);
|
177 |
+
else count_html = sprintf(QASI.n_posts_have_been_scanned, count);
|
178 |
+
if (count_remote_images) {
|
179 |
+
if (count_remote_images==1) count_html += sprintf("<br />"+QASI.found_n_post_including_remote_images, count_remote_images);
|
180 |
+
else count_html += sprintf("<br />"+QASI.found_n_posts_including_remote_images, count_remote_images);
|
181 |
+
if (count_not_exits_remote_images) {
|
182 |
+
if (count_not_exits_remote_images==1) count_html += sprintf("<br />"+QASI.and_with_n_post_has_missing_images, count_not_exits_remote_images);
|
183 |
+
else count_html += sprintf("<br />"+QASI.and_with_n_posts_have_missing_images, count_not_exits_remote_images);
|
184 |
+
}
|
185 |
+
} else count_html += '<br />'+QASI.no_post_has_remote_images_found;
|
186 |
+
} else {
|
187 |
+
$('#scan_old_post_list').slideUp('slow');
|
188 |
+
count_html = QASI.no_posts_found;
|
189 |
+
}
|
190 |
+
noty({
|
191 |
+
text: QASI.all_done+'<br />'+count_html,
|
192 |
+
type: 'success',
|
193 |
+
layout: 'center',
|
194 |
+
dismissQueue: true,
|
195 |
+
modal: true
|
196 |
+
});
|
197 |
+
$('#scan_old_posts').removeAttr('disabled');
|
198 |
+
$('#list_all_posts').removeAttr('disabled');
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
var speed = parseInt($('select[name="speed"]').val());
|
202 |
+
post_id = new Array;
|
203 |
+
$('body').data('speed', speed);
|
204 |
+
var data = 'action=save_remote_images_list_all_posts';
|
205 |
+
for (var p=r; p<r+speed; p++) {
|
206 |
+
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
207 |
+
}
|
208 |
+
console.log(data);
|
209 |
+
$.ajax({
|
210 |
+
type: 'POST',
|
211 |
+
url: ajaxurl,
|
212 |
+
data: data,
|
213 |
+
success: function(data) {
|
214 |
+
data = $(data);
|
215 |
+
$('#scan_old_post_list tbody').append(data);
|
216 |
+
data.hide().fadeIn('fast');
|
217 |
+
r += speed;
|
218 |
+
_this.action.list(respond, r);
|
219 |
+
},
|
220 |
+
error: _this.action.catch_errors
|
221 |
+
});
|
222 |
+
};
|
223 |
+
|
224 |
+
|
225 |
+
this.action.if_not_select_post_type = function() {
|
226 |
+
var $ = jQuery;
|
227 |
+
$('#post_types_list').effect( 'shake', null, 500 );
|
228 |
+
var n = noty({
|
229 |
+
text: QASI.pls_select_post_types,
|
230 |
+
type: 'error',
|
231 |
+
dismissQueue: true,
|
232 |
+
layout: 'bottomCenter',
|
233 |
+
timeout: 3000
|
234 |
+
});
|
235 |
+
}
|
236 |
+
|
237 |
+
this.create = {};
|
238 |
+
this.create.events = function() {
|
239 |
+
$(".icon.help").tooltip({
|
240 |
+
show: {
|
241 |
+
effect: "slideDown",
|
242 |
+
delay: 250
|
243 |
+
}
|
244 |
+
});
|
245 |
+
$('select[name="posts_per_page"]').on('change', function() {
|
246 |
+
if ($(this).val() == '-1') $('input[name="offset"]').attr('disabled', true);
|
247 |
+
else $('input[name="offset"]').removeAttr('disabled', true);
|
248 |
+
});
|
249 |
+
$('#auto').on('click', function() {
|
250 |
+
$('#second_level').fadeIn('fast');
|
251 |
+
});
|
252 |
+
$('#manual').on('click', function() {
|
253 |
+
$('#second_level').fadeOut('fast');
|
254 |
+
});
|
255 |
+
$('#scan_old_posts').on('click', function() {
|
256 |
+
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
257 |
+
var n = noty({
|
258 |
+
text: QASI.are_your_sure,
|
259 |
+
type: 'warning',
|
260 |
+
dismissQueue: true,
|
261 |
+
layout: 'center',
|
262 |
+
modal: true,
|
263 |
+
buttons: [
|
264 |
+
{
|
265 |
+
addClass: 'button button-primary',
|
266 |
+
text: QASI.yes,
|
267 |
+
onClick: function ($noty) {
|
268 |
+
$('#form').slideUp('slow');
|
269 |
+
$noty.close();
|
270 |
+
$('#scan_old_posts').attr('disabled', true);
|
271 |
+
$('#list_all_posts').attr('disabled', true);
|
272 |
+
var data = $('#form').serialize()+'&action=get_scan_list';
|
273 |
+
$.ajax({
|
274 |
+
type: 'POST',
|
275 |
+
url: ajaxurl,
|
276 |
+
data: data,
|
277 |
+
dataType: 'json',
|
278 |
+
success: function(respond) {
|
279 |
+
$('body').data('respond', respond);
|
280 |
+
$('#scan-result').html('<table id="scan_old_post_list">\
|
281 |
+
\ <thead>\
|
282 |
+
\ <th>' + QASI.id + '</th>\
|
283 |
+
\ <th>' + QASI.post_type + '</th>\
|
284 |
+
\ <th>' + QASI.title + '</th>\
|
285 |
+
\ <th>' + QASI.status + '</th>\
|
286 |
+
\ </thead>\
|
287 |
+
\ <tbody>\
|
288 |
+
\ </tbody>\
|
289 |
+
\</table>');
|
290 |
+
$('body').data('noty', noty({
|
291 |
+
text: QASI.scanning,
|
292 |
+
type: 'notification',
|
293 |
+
layout: 'center',
|
294 |
+
dismissQueue: true
|
295 |
+
}) );
|
296 |
+
_this.action.scan(respond, 0);
|
297 |
+
},
|
298 |
+
error: _this.action.catch_errors
|
299 |
+
});
|
300 |
+
}
|
301 |
+
},
|
302 |
+
{
|
303 |
+
addClass: 'button button-primary',
|
304 |
+
text: QASI.no,
|
305 |
+
onClick: function ($noty) {
|
306 |
+
$noty.close();
|
307 |
+
}
|
308 |
+
}
|
309 |
+
]
|
310 |
+
});
|
311 |
+
} else _this.action.if_not_select_post_type();
|
312 |
+
});
|
313 |
+
$('#list_all_posts').on('click', function() {
|
314 |
+
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
315 |
+
$('#form').slideUp('slow');
|
316 |
+
$('#scan_old_posts').attr('disabled', true);
|
317 |
+
$('#list_all_posts').attr('disabled', true);
|
318 |
+
var data = $('#form').serialize()+'&action=get_scan_list';
|
319 |
+
$.ajax({
|
320 |
+
type: 'POST',
|
321 |
+
url: ajaxurl,
|
322 |
+
data: data,
|
323 |
+
dataType: 'json',
|
324 |
+
success: function(respond) {
|
325 |
+
$('body').data('respond', respond);
|
326 |
+
$('#scan-result').html('<table id="scan_old_post_list">\
|
327 |
+
\ <thead>\
|
328 |
+
\ <th>' + QASI.id + '</th>\
|
329 |
+
\ <th>' + QASI.post_type + '</th>\
|
330 |
+
\ <th>' + QASI.title + '</th>\
|
331 |
+
\ <th>' + QASI.status + '</th>\
|
332 |
+
\ <th>' + QASI.control + '</th>\
|
333 |
+
\ </thead>\
|
334 |
+
\ <tbody>\
|
335 |
+
\ </tbody>\
|
336 |
+
\</table>');
|
337 |
+
$('body').data('noty', noty({
|
338 |
+
text: QASI.listing,
|
339 |
+
type: 'notification',
|
340 |
+
layout: 'center',
|
341 |
+
dismissQueue: true
|
342 |
+
}) );
|
343 |
+
_this.action.list(respond, 0);
|
344 |
+
},
|
345 |
+
error: _this.action.catch_errors
|
346 |
+
});
|
347 |
+
} else _this.action.if_not_select_post_type();
|
348 |
+
});
|
349 |
+
$(document).on('click', '#scan_old_post_list .fetch-remote-images', function() {
|
350 |
+
var wait = '<img src="data:image/gif;base64,R0lGODlhlAAbAPfvAM/X2L3t+dHj59Xl67/v+6KwssHx/avZ5bTj75bBzaDN2d72/Ojx89nx98jg5s7m7NTs8sXW29/3/ery9bbHy+Lr7drj5eD4/unp6Y7n//T09Ozs7O7u7vHx8fX19aLDy8/h5erq6m18gfPz8/Ly8u/v7/Dw8O3t7evr61uetIXb85GwuHfH33mVm6XHz1SLnovj+4jf963L1mm0y8Xz/53N2cXX27XHy6nZ5ZHBzbPj7+L5/7XN3dzl57rLz7vDxcbd49jv9d7j5tjf4+Xu8LvS4dnw9vP19p3H07rBw+Dj5eHi45O7x7bN3Z6tr7O9v9/i5Mzj6cbMzsHT3svc4LW+we3w8s3V1tHW2OHo7rTg7c/d5tjj687Z4ePk5LTDx5OgpKm4u9nh4+Ps7sfP0YKOk4aVmHGQmL/V5J7J07S6u7jO08fZ3szU1rnIzK27v3WFibrDxsPZ387W17vS2LzS4cDW5Nbu9Obw8t31+7zU5brp9cfNz+Do6p2rr4artMDX3eHp64WTlqXR3NLp76CvsOLq7KevspCZndbt87Lf6Ymwu7XN3rvr93+Wnd3g4a/c6dXd39ff4a+9wcHT38DT38TKzKLBy7PM3b3GyNbs8snd6LnR4XiFibPJzsfZ3L7U2b3U49LW2MTZ58je5IKnsneYoKXN1pWeoq/EyZW0vdHn7bbO3o60v7bP37/V48ba6LnR4L7Hya/Z5dHo7rS9wKXP25a9ybLf68HR1bnQ4Mzg7MPT1sLY5bK9wK/b536gqcXV2dz0+tHm66fT39Pb3dnc3c3k6XyLjtLa3H+TmdDf44GOkZuprc3f47vExsHb4MjO0L7Hypm9x7jJzdni5KW0uJahpYGLjqS/x9HZ28vT1dvk5s3g5bnGyrTFycfJycre4+fw8s/g5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Ys2olECMgACH5BAUKAO8ALBMABQB9ABEAAAj/AAu8G0iwIEGBBhO+Q6iwIMOGAx9ClNiQosICFg1i3FigkJ9rZcqkg0iypMmTKFOqpHCSgkuX3yaFcWIGlcqbOHPqJBnhZISfP4Pl8vHGCbYkO5MqXQpx3MlxUKNSieAjzDVBTLNq3enUZNSvVHh9KSBiq9mzJgWcFMC2LdtPPs6URUu37sABJwfo3Tug26VSpubaHbw1wckEiBMjZrIImGDCkJUqOKmgsuXKSJj8eRy5M84DJw+IHi2aGJJWnD2rPomANYLXsBFAGnQr9erbDQOcDMC7N+89v9LYxk2c4LqT65IrT05Ai61OxaMnPG5yeXIa6wJoyYZIuveB1EtaJaeBvREuM+C+ezdw0oB7A8oJzHJ0SL13AicJ6Nev6JQqOGoMFBAAOw==" />';
|
351 |
+
var post_id = $(this).attr('post-id');
|
352 |
+
$(this).hide().after(wait);
|
353 |
+
var data = 'action=save_remote_images_after_scan&post_id[]='+post_id;
|
354 |
+
$.ajax({
|
355 |
+
type: 'POST',
|
356 |
+
url: ajaxurl,
|
357 |
+
data: data,
|
358 |
+
success: function(data) {
|
359 |
+
$('#list-'+post_id).html('<span class="green">'+QASI.done+'</span>');
|
360 |
+
},
|
361 |
+
error: _this.action.catch_errors
|
362 |
+
});
|
363 |
+
})
|
364 |
+
};
|
365 |
+
|
366 |
+
this.create.init = function() {
|
367 |
+
_this.create.events();
|
368 |
+
};
|
369 |
+
this.create.init();
|
370 |
+
};
|
lang/qqworld_auto_save_images-zh_CN.mo
CHANGED
Binary file
|
lang/qqworld_auto_save_images-zh_CN.po
CHANGED
@@ -3,7 +3,7 @@ msgstr ""
|
|
3 |
"Project-Id-Version: QQworld Auto Save Images\n"
|
4 |
"Report-Msgid-Bugs-To: http://www.qqworld.org\n"
|
5 |
"POT-Creation-Date: 2011-12-10 19:47:15+00:00\n"
|
6 |
-
"PO-Revision-Date: 2014-10-
|
7 |
"Last-Translator: Michael Wang <admin@qqworld.org>\n"
|
8 |
"Language-Team: QQWorld <admin@qqworld.org>\n"
|
9 |
"Language: zh_CN\n"
|
@@ -17,6 +17,9 @@ msgstr ""
|
|
17 |
msgid "QQWorld Auto Save Images"
|
18 |
msgstr "QQWorld自动保存图片"
|
19 |
|
|
|
|
|
|
|
20 |
msgid "Save Remote Images"
|
21 |
msgstr "保存远程图片"
|
22 |
|
@@ -121,8 +124,8 @@ msgstr "抓取"
|
|
121 |
msgid "No post has remote images found."
|
122 |
msgstr "没有文章包含远程图像。"
|
123 |
|
124 |
-
msgid "No
|
125 |
-
msgstr "
|
126 |
|
127 |
msgid "Control"
|
128 |
msgstr "控制"
|
3 |
"Project-Id-Version: QQworld Auto Save Images\n"
|
4 |
"Report-Msgid-Bugs-To: http://www.qqworld.org\n"
|
5 |
"POT-Creation-Date: 2011-12-10 19:47:15+00:00\n"
|
6 |
+
"PO-Revision-Date: 2014-10-08 13:38+0800\n"
|
7 |
"Last-Translator: Michael Wang <admin@qqworld.org>\n"
|
8 |
"Language-Team: QQWorld <admin@qqworld.org>\n"
|
9 |
"Language: zh_CN\n"
|
17 |
msgid "QQWorld Auto Save Images"
|
18 |
msgstr "QQWorld自动保存图片"
|
19 |
|
20 |
+
msgid "Mode"
|
21 |
+
msgstr "模式"
|
22 |
+
|
23 |
msgid "Save Remote Images"
|
24 |
msgstr "保存远程图片"
|
25 |
|
124 |
msgid "No post has remote images found."
|
125 |
msgstr "没有文章包含远程图像。"
|
126 |
|
127 |
+
msgid "No posts processed."
|
128 |
+
msgstr "未处理任何文章。"
|
129 |
|
130 |
msgid "Control"
|
131 |
msgstr "控制"
|
qqworld-auto-save-images.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: QQWorld Auto Save Images
|
4 |
Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
|
5 |
Description: Automatically keep the all remote picture to the local, and automatically set featured image. 自动保存远程图片到本地,自动设置特色图片,并且支持机器人采集软件从外部提交。
|
6 |
-
Version: 1.5.7.
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
*/
|
@@ -42,16 +42,52 @@ class QQWorld_auto_save_images {
|
|
42 |
add_filter( 'plugin_row_meta', array($this, 'registerPluginLinks'),10,2 );
|
43 |
|
44 |
add_action( 'admin_head', array($this, 'options_general_add_js') );
|
45 |
-
|
46 |
}
|
47 |
|
48 |
public function options_general_add_js() {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
public function get_scan_list() {
|
@@ -117,20 +153,24 @@ class QQWorld_auto_save_images {
|
|
117 |
}
|
118 |
wp_update_post(array('ID' => $post_id, 'post_content' => $content));
|
119 |
$post_type_object = get_post_type_object($post_type);
|
120 |
-
if ($has_remote_images
|
121 |
-
|
|
|
|
|
122 |
?>
|
123 |
<tr<?php echo $class; ?>>
|
124 |
<td><?php echo $post_id; ?></td>
|
125 |
<td><?php echo $post_type_object->labels->name; ?></td>
|
126 |
<td><a href="<?php echo get_edit_post_link($post_id); ?>" target="_blank"><?php echo $title; ?> ⇛</a></td>
|
127 |
-
<td><?php
|
128 |
-
if ($has_remote_images) {
|
129 |
-
echo $has_not_exits_remote_images ? '<span class="red">'.__('Has missing images.', 'qqworld_auto_save_images').'</span>' : '<span class="green">'.__('All remote images have been saved.', 'qqworld_auto_save_images').'</span>';
|
130 |
-
} else _e('No remote images found.', 'qqworld_auto_save_images')
|
131 |
-
?></td>
|
132 |
</tr>
|
133 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
endforeach;
|
135 |
exit;
|
136 |
}
|
@@ -239,7 +279,7 @@ class QQWorld_auto_save_images {
|
|
239 |
data: {
|
240 |
action: 'save_remote_images',
|
241 |
post_id: QQWorld_auto_save_images.post_id,
|
242 |
-
content:
|
243 |
},
|
244 |
success: function(respond) {
|
245 |
$('#save-remote-images-button').data('noty').close();
|
@@ -267,7 +307,7 @@ class QQWorld_auto_save_images {
|
|
267 |
data: {
|
268 |
action: 'save_remote_images',
|
269 |
post_id: QQWorld_auto_save_images.post_id,
|
270 |
-
content:
|
271 |
},
|
272 |
success: function(respond) {
|
273 |
$('#save-remote-images-button').data('noty').close();
|
@@ -316,17 +356,17 @@ class QQWorld_auto_save_images {
|
|
316 |
<table class="form-table">
|
317 |
<tbody>
|
318 |
<tr valign="top">
|
319 |
-
<th scope="row"><label><?php _e('
|
320 |
<td><fieldset>
|
321 |
-
<legend class="screen-reader-text"><span><?php _e('
|
322 |
<label for="auto">
|
323 |
<input name="qqworld_auto_save_imagess_type" type="radio" id="auto" value="auto" <?php checked('auto', $this->type); ?> />
|
324 |
-
<?php _e('
|
325 |
-
</label><br />
|
326 |
<label for="manual">
|
327 |
<input name="qqworld_auto_save_imagess_type" type="radio" id="manual" value="manual" <?php checked('manual', $this->type); ?> />
|
328 |
-
<?php _e('
|
329 |
-
</label>
|
330 |
</fieldset></td>
|
331 |
</tr>
|
332 |
|
@@ -407,363 +447,8 @@ class QQWorld_auto_save_images {
|
|
407 |
</tbody>
|
408 |
</table>
|
409 |
<script>
|
410 |
-
function str_repeat(i, m) {
|
411 |
-
for (var o = []; m > 0; o[--m] = i);
|
412 |
-
return o.join('');
|
413 |
-
}
|
414 |
-
function sprintf() {
|
415 |
-
var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = '';
|
416 |
-
while (f) {
|
417 |
-
if (m = /^[^\x25]+/.exec(f)) {
|
418 |
-
o.push(m[0]);
|
419 |
-
}
|
420 |
-
else if (m = /^\x25{2}/.exec(f)) {
|
421 |
-
o.push('%');
|
422 |
-
}
|
423 |
-
else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
|
424 |
-
if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) {
|
425 |
-
throw('Too few arguments.');
|
426 |
-
}
|
427 |
-
if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
|
428 |
-
throw('Expecting number but found ' + typeof(a));
|
429 |
-
}
|
430 |
-
switch (m[7]) {
|
431 |
-
case 'b': a = a.toString(2); break;
|
432 |
-
case 'c': a = String.fromCharCode(a); break;
|
433 |
-
case 'd': a = parseInt(a); break;
|
434 |
-
case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
|
435 |
-
case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
|
436 |
-
case 'o': a = a.toString(8); break;
|
437 |
-
case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
|
438 |
-
case 'u': a = Math.abs(a); break;
|
439 |
-
case 'x': a = a.toString(16); break;
|
440 |
-
case 'X': a = a.toString(16).toUpperCase(); break;
|
441 |
-
}
|
442 |
-
a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a);
|
443 |
-
c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
|
444 |
-
x = m[5] - String(a).length - s.length;
|
445 |
-
p = m[5] ? str_repeat(c, x) : '';
|
446 |
-
o.push(s + (m[4] ? a + p : p + a));
|
447 |
-
}
|
448 |
-
else {
|
449 |
-
throw('Huh ?!');
|
450 |
-
}
|
451 |
-
f = f.substring(m[0].length);
|
452 |
-
}
|
453 |
-
return o.join('');
|
454 |
-
}
|
455 |
-
if (!QQWorld_auto_save_images) var QQWorld_auto_save_images = {};
|
456 |
-
QQWorld_auto_save_images.are_your_sure = '<?php _e('Are you sure?<br />Before you click the yes button, I recommend backup site database.', 'qqworld_auto_save_images'); ?>';
|
457 |
-
QQWorld_auto_save_images.pls_select_post_types = '<?php _e('Please select post types.', 'qqworld_auto_save_images'); ?>';
|
458 |
-
QQWorld_auto_save_images.maybe_problem = '<?php _e('May be a problem with some posts: ', 'qqworld_auto_save_images'); ?>';
|
459 |
-
QQWorld_auto_save_images.catch_errors = function(XMLHttpRequest, textStatus, errorThrown) {
|
460 |
-
var $=jQuery, error='', args=new Array;
|
461 |
-
error += '<div style="text-align: left;">';
|
462 |
-
var query = this.data.split('&');
|
463 |
-
var data = new Array;
|
464 |
-
for (var d in query) {
|
465 |
-
var q = query[d].split('=');
|
466 |
-
if (q[0]=='post_id[]') {
|
467 |
-
data.push(q[1]);
|
468 |
-
}
|
469 |
-
}
|
470 |
-
error += QQWorld_auto_save_images.maybe_problem + data.join(', ');
|
471 |
-
if (XMLHttpRequest) {
|
472 |
-
error += '<hr />';
|
473 |
-
args = new Array;
|
474 |
-
for (var x in XMLHttpRequest) {
|
475 |
-
switch (x) {
|
476 |
-
case 'readyState':
|
477 |
-
case 'responseText':
|
478 |
-
case 'status':
|
479 |
-
args.push( x + ': ' + XMLHttpRequest[x] );
|
480 |
-
break;
|
481 |
-
}
|
482 |
-
}
|
483 |
-
error += args.join('<br />', args);
|
484 |
-
}
|
485 |
-
error += '<br />' + textStatus + ': ' + errorThrown;
|
486 |
-
error += '</div>';
|
487 |
-
$('#form').slideDown('slow');
|
488 |
-
$('body').data('noty').close();
|
489 |
-
noty({
|
490 |
-
text: error,
|
491 |
-
type: 'error',
|
492 |
-
layout: 'bottom',
|
493 |
-
dismissQueue: true,
|
494 |
-
closeWith: ['button']
|
495 |
-
});
|
496 |
-
$('#scan_old_posts').removeAttr('disabled');
|
497 |
-
$('#list_all_posts').removeAttr('disabled');
|
498 |
-
$('body').data('r', $('body').data('r')+$('body').data('speed'));
|
499 |
-
switch ($('body').data('scan-mode')) {
|
500 |
-
case 'scan':
|
501 |
-
QQWorld_auto_save_images.scan($('body').data('respond'), $('body').data('r'));
|
502 |
-
break;
|
503 |
-
case 'list':
|
504 |
-
QQWorld_auto_save_images.list($('body').data('respond'), $('body').data('r'));
|
505 |
-
break;
|
506 |
-
}
|
507 |
-
};
|
508 |
-
QQWorld_auto_save_images.scan = function(respond, r) {
|
509 |
-
var $ = jQuery;
|
510 |
-
$('body').data('scan-mode', 'scan').data('r', r);
|
511 |
-
if (typeof respond[r] == 'undefined') {
|
512 |
-
$('#scan-result').effect( 'shake', null, 500 );
|
513 |
-
$('#form').slideDown('slow');
|
514 |
-
$('body').data('noty').close();
|
515 |
-
var count = $('#scan_old_post_list tbody tr').length;
|
516 |
-
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
517 |
-
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
518 |
-
var count = $('#scan_old_post_list tbody tr').length;
|
519 |
-
if (count) {
|
520 |
-
if (count==1) count_html = sprintf("<?php _e( '%d post has been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
521 |
-
else count_html = sprintf("<?php _e( '%d posts have been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
522 |
-
if (count_remote_images) {
|
523 |
-
count_remote_images = count_remote_images - count_not_exits_remote_images;
|
524 |
-
if (count_remote_images<=1) count_html += sprintf("<br /><?php _e( '%d post included remote images processed.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
525 |
-
else count_html += sprintf("<br /><?php _e( '%d posts included remote images processed.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
526 |
-
if (count_not_exits_remote_images) {
|
527 |
-
if (count_not_exits_remote_images==1) count_html += sprintf("<br /><?php _e( "%d post has missing images couldn't be processed.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
528 |
-
else count_html += sprintf("<br /><?php _e( "%d posts have missing images couldn't be processed.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
529 |
-
}
|
530 |
-
}
|
531 |
-
} else {
|
532 |
-
$('#scan_old_post_list').slideUp('slow');
|
533 |
-
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
534 |
-
}
|
535 |
-
noty({
|
536 |
-
text: '<?php _e('All done.', 'qqworld_auto_save_images'); ?><br />'+count_html,
|
537 |
-
type: 'success',
|
538 |
-
layout: 'center',
|
539 |
-
dismissQueue: true,
|
540 |
-
modal: true
|
541 |
-
});
|
542 |
-
$('#scan_old_posts').removeAttr('disabled');
|
543 |
-
$('#list_all_posts').removeAttr('disabled');
|
544 |
-
return;
|
545 |
-
}
|
546 |
-
var speed = parseInt($('select[name="speed"]').val());
|
547 |
-
post_id = new Array;
|
548 |
-
$('body').data('speed', speed);
|
549 |
-
var data = 'action=save_remote_images_after_scan';
|
550 |
-
for (var p=r; p<r+speed; p++) {
|
551 |
-
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
552 |
-
}
|
553 |
-
console.log(data);
|
554 |
-
$.ajax({
|
555 |
-
type: 'POST',
|
556 |
-
url: ajaxurl,
|
557 |
-
data: data,
|
558 |
-
success: function(data) {
|
559 |
-
data = $(data);
|
560 |
-
$('#scan_old_post_list tbody').append(data);
|
561 |
-
data.hide().fadeIn('fast');
|
562 |
-
r += speed;
|
563 |
-
QQWorld_auto_save_images.scan(respond, r);
|
564 |
-
},
|
565 |
-
error: QQWorld_auto_save_images.catch_errors
|
566 |
-
});
|
567 |
-
};
|
568 |
-
QQWorld_auto_save_images.list = function(respond, r) {
|
569 |
-
var $ = jQuery;
|
570 |
-
$('body').data('scan-mode', 'list').data('r', r);
|
571 |
-
if (typeof respond[r] == 'undefined') {
|
572 |
-
$('#scan-result').effect( 'shake', null, 500 );
|
573 |
-
$('#form').slideDown('slow');
|
574 |
-
$('body').data('noty').close();
|
575 |
-
var count = $('#scan_old_post_list tbody tr').length;
|
576 |
-
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
577 |
-
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
578 |
-
if (count) {
|
579 |
-
if (count==1) count_html = sprintf("<?php _e( '%d post has been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
580 |
-
else count_html = sprintf("<?php _e( '%d posts have been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
581 |
-
if (count_remote_images) {
|
582 |
-
if (count_remote_images==1) count_html += sprintf("<br /><?php _e( 'found %d post including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
583 |
-
else count_html += sprintf("<br /><?php _e( 'found %d posts including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
584 |
-
if (count_not_exits_remote_images) {
|
585 |
-
if (count_not_exits_remote_images==1) count_html += sprintf("<br /><?php _e( "And with %d post has missing images.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
586 |
-
else count_html += sprintf("<br /><?php _e( "And with %d posts have missing images.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
587 |
-
}
|
588 |
-
} else count_html += '<br /><?php _e('No post has remote images found.', 'qqworld_auto_save_images'); ?>';
|
589 |
-
} else {
|
590 |
-
$('#scan_old_post_list').slideUp('slow');
|
591 |
-
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
592 |
-
}
|
593 |
-
noty({
|
594 |
-
text: '<?php _e('All done.', 'qqworld_auto_save_images'); ?><br />'+count_html,
|
595 |
-
type: 'success',
|
596 |
-
layout: 'center',
|
597 |
-
dismissQueue: true,
|
598 |
-
modal: true
|
599 |
-
});
|
600 |
-
$('#scan_old_posts').removeAttr('disabled');
|
601 |
-
$('#list_all_posts').removeAttr('disabled');
|
602 |
-
return;
|
603 |
-
}
|
604 |
-
var speed = parseInt($('select[name="speed"]').val());
|
605 |
-
post_id = new Array;
|
606 |
-
$('body').data('speed', speed);
|
607 |
-
var data = 'action=save_remote_images_list_all_posts';
|
608 |
-
for (var p=r; p<r+speed; p++) {
|
609 |
-
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
610 |
-
}
|
611 |
-
console.log(data);
|
612 |
-
$.ajax({
|
613 |
-
type: 'POST',
|
614 |
-
url: ajaxurl,
|
615 |
-
data: data,
|
616 |
-
success: function(data) {
|
617 |
-
data = $(data);
|
618 |
-
$('#scan_old_post_list tbody').append(data);
|
619 |
-
data.hide().fadeIn('fast');
|
620 |
-
r += speed;
|
621 |
-
QQWorld_auto_save_images.list(respond, r);
|
622 |
-
},
|
623 |
-
error: QQWorld_auto_save_images.catch_errors
|
624 |
-
});
|
625 |
-
};
|
626 |
-
QQWorld_auto_save_images.if_not_select_post_type = function() {
|
627 |
-
var $ = jQuery;
|
628 |
-
$('#post_types_list').effect( 'shake', null, 500 );
|
629 |
-
var n = noty({
|
630 |
-
text: QQWorld_auto_save_images.pls_select_post_types,
|
631 |
-
type: 'error',
|
632 |
-
dismissQueue: true,
|
633 |
-
layout: 'bottomCenter',
|
634 |
-
timeout: 3000
|
635 |
-
});
|
636 |
-
}
|
637 |
-
QQWorld_auto_save_images.events = function() {
|
638 |
-
var $ = jQuery;
|
639 |
-
$(".icon.help").tooltip({
|
640 |
-
show: {
|
641 |
-
effect: "slideDown",
|
642 |
-
delay: 250
|
643 |
-
}
|
644 |
-
});
|
645 |
-
$('select[name="posts_per_page"]').on('change', function() {
|
646 |
-
if ($(this).val() == '-1') $('input[name="offset"]').attr('disabled', true);
|
647 |
-
else $('input[name="offset"]').removeAttr('disabled', true);
|
648 |
-
});
|
649 |
-
$('#auto').on('click', function() {
|
650 |
-
$('#second_level').fadeIn('fast');
|
651 |
-
});
|
652 |
-
$('#manual').on('click', function() {
|
653 |
-
$('#second_level').fadeOut('fast');
|
654 |
-
});
|
655 |
-
$('#scan_old_posts').on('click', function() {
|
656 |
-
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
657 |
-
var n = noty({
|
658 |
-
text: QQWorld_auto_save_images.are_your_sure,
|
659 |
-
type: 'warning',
|
660 |
-
dismissQueue: true,
|
661 |
-
layout: 'center',
|
662 |
-
modal: true,
|
663 |
-
buttons: [
|
664 |
-
{
|
665 |
-
addClass: 'button button-primary',
|
666 |
-
text: '<?php _e('Yes'); ?>',
|
667 |
-
onClick: function ($noty) {
|
668 |
-
$('#form').slideUp('slow');
|
669 |
-
$noty.close();
|
670 |
-
$('#scan_old_posts').attr('disabled', true);
|
671 |
-
$('#list_all_posts').attr('disabled', true);
|
672 |
-
var data = $('#form').serialize()+'&action=get_scan_list';
|
673 |
-
$.ajax({
|
674 |
-
type: 'POST',
|
675 |
-
url: ajaxurl,
|
676 |
-
data: data,
|
677 |
-
dataType: 'json',
|
678 |
-
success: function(respond) {
|
679 |
-
QQWorld_auto_save_images.respond = respond;
|
680 |
-
$('#scan-result').html('<table id="scan_old_post_list">\
|
681 |
-
\ <thead>\
|
682 |
-
\ <th><?php _e('ID'); ?></th>\
|
683 |
-
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
684 |
-
\ <th><?php _e('Title'); ?></th>\
|
685 |
-
\ <th><?php _e('Status'); ?></th>\
|
686 |
-
\ </thead>\
|
687 |
-
\ <tbody>\
|
688 |
-
\ </tbody>\
|
689 |
-
\</table>');
|
690 |
-
$('body').data('noty', noty({
|
691 |
-
text: '<?php _e('Scanning...', 'qqworld_auto_save_images'); ?>',
|
692 |
-
type: 'notification',
|
693 |
-
layout: 'center',
|
694 |
-
dismissQueue: true
|
695 |
-
}) );
|
696 |
-
QQWorld_auto_save_images.scan(QQWorld_auto_save_images.respond, 0);
|
697 |
-
},
|
698 |
-
error: QQWorld_auto_save_images.catch_errors
|
699 |
-
});
|
700 |
-
}
|
701 |
-
},
|
702 |
-
{
|
703 |
-
addClass: 'button button-primary',
|
704 |
-
text: '<?php _e('No'); ?>',
|
705 |
-
onClick: function ($noty) {
|
706 |
-
$noty.close();
|
707 |
-
}
|
708 |
-
}
|
709 |
-
]
|
710 |
-
});
|
711 |
-
} else QQWorld_auto_save_images.if_not_select_post_type();
|
712 |
-
});
|
713 |
-
$('#list_all_posts').on('click', function() {
|
714 |
-
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
715 |
-
$('#form').slideUp('slow');
|
716 |
-
$('#scan_old_posts').attr('disabled', true);
|
717 |
-
$('#list_all_posts').attr('disabled', true);
|
718 |
-
var data = $('#form').serialize()+'&action=get_scan_list';
|
719 |
-
$.ajax({
|
720 |
-
type: 'POST',
|
721 |
-
url: ajaxurl,
|
722 |
-
data: data,
|
723 |
-
dataType: 'json',
|
724 |
-
success: function(respond) {
|
725 |
-
$('body').data('respond', respond);
|
726 |
-
$('#scan-result').html('<table id="scan_old_post_list">\
|
727 |
-
\ <thead>\
|
728 |
-
\ <th><?php _e('ID'); ?></th>\
|
729 |
-
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
730 |
-
\ <th><?php _e('Title'); ?></th>\
|
731 |
-
\ <th><?php _e('Status'); ?></th>\
|
732 |
-
\ <th><?php _e('Control', 'qqworld_auto_save_images'); ?></th>\
|
733 |
-
\ </thead>\
|
734 |
-
\ <tbody>\
|
735 |
-
\ </tbody>\
|
736 |
-
\</table>');
|
737 |
-
$('body').data('noty', noty({
|
738 |
-
text: '<?php _e('Listing...', 'qqworld_auto_save_images'); ?>',
|
739 |
-
type: 'notification',
|
740 |
-
layout: 'center',
|
741 |
-
dismissQueue: true
|
742 |
-
}) );
|
743 |
-
QQWorld_auto_save_images.list(respond, 0);
|
744 |
-
},
|
745 |
-
error: QQWorld_auto_save_images.catch_errors
|
746 |
-
});
|
747 |
-
} else QQWorld_auto_save_images.if_not_select_post_type();
|
748 |
-
});
|
749 |
-
$(document).on('click', '#scan_old_post_list .fetch-remote-images', function() {
|
750 |
-
var wait = '<img src="data:image/gif;base64,R0lGODlhlAAbAPfvAM/X2L3t+dHj59Xl67/v+6KwssHx/avZ5bTj75bBzaDN2d72/Ojx89nx98jg5s7m7NTs8sXW29/3/ery9bbHy+Lr7drj5eD4/unp6Y7n//T09Ozs7O7u7vHx8fX19aLDy8/h5erq6m18gfPz8/Ly8u/v7/Dw8O3t7evr61uetIXb85GwuHfH33mVm6XHz1SLnovj+4jf963L1mm0y8Xz/53N2cXX27XHy6nZ5ZHBzbPj7+L5/7XN3d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6JQqOGoMFBAAOw==" />';
|
751 |
-
var post_id = $(this).attr('post-id');
|
752 |
-
$(this).hide().after(wait);
|
753 |
-
var data = 'action=save_remote_images_after_scan&post_id[]='+post_id;
|
754 |
-
$.ajax({
|
755 |
-
type: 'POST',
|
756 |
-
url: ajaxurl,
|
757 |
-
data: data,
|
758 |
-
success: function(data) {
|
759 |
-
$('#list-'+post_id).html('<span class="green"><?php _e('Done'); ?></span>');
|
760 |
-
},
|
761 |
-
error: QQWorld_auto_save_images.catch_errors
|
762 |
-
});
|
763 |
-
})
|
764 |
-
};
|
765 |
jQuery(function($) {
|
766 |
-
QQWorld_auto_save_images.
|
767 |
});
|
768 |
</script>
|
769 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button-primary" name="Submit" /></p>
|
@@ -777,44 +462,54 @@ class QQWorld_auto_save_images {
|
|
777 |
register_setting('qqworld_auto_save_images_settings', 'qqworld_auto_save_imagess_set_featured_image');
|
778 |
}
|
779 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
780 |
function add_actions() {
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
break;
|
785 |
-
case 'save':
|
786 |
-
add_action('save_post', array($this, 'fetch_images') );
|
787 |
-
break;
|
788 |
}
|
789 |
}
|
790 |
|
791 |
function remove_actions() {
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
break;
|
796 |
-
case 'save':
|
797 |
-
remove_action('save_post', array($this, 'fetch_images') );
|
798 |
-
break;
|
799 |
}
|
800 |
}
|
801 |
|
802 |
-
function
|
803 |
-
$
|
804 |
-
|
805 |
-
for ($i = 0; $i < $len; $i++) {
|
806 |
-
if ($str[$i] == '%' && $str[$i+1] == 'u') {
|
807 |
-
$val = hexdec(substr($str, $i+2, 4));
|
808 |
-
if ($val < 0x7f) $ret .= chr($val);
|
809 |
-
else if($val < 0x800) $ret .= chr(0xc0|($val>>6)).chr(0x80|($val&0x3f));
|
810 |
-
else $ret .= chr(0xe0|($val>>12)).chr(0x80|(($val>>6)&0x3f)).chr(0x80|($val&0x3f));
|
811 |
-
$i += 5;
|
812 |
-
} else if ($str[$i] == '%') {
|
813 |
-
$ret .= urldecode(substr($str, $i, 3));
|
814 |
-
$i += 2;
|
815 |
-
} else $ret .= $str[$i];
|
816 |
-
}
|
817 |
-
return $ret;
|
818 |
}
|
819 |
|
820 |
function save_remote_images() {
|
@@ -828,7 +523,7 @@ class QQWorld_auto_save_images {
|
|
828 |
if ( !current_user_can('edit_post', $post_id) )
|
829 |
return;
|
830 |
|
831 |
-
$content = $this->
|
832 |
|
833 |
$preg=preg_match_all($this->preg,stripslashes($content),$matches);
|
834 |
if($preg){
|
3 |
Plugin Name: QQWorld Auto Save Images
|
4 |
Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
|
5 |
Description: Automatically keep the all remote picture to the local, and automatically set featured image. 自动保存远程图片到本地,自动设置特色图片,并且支持机器人采集软件从外部提交。
|
6 |
+
Version: 1.5.7.4
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
*/
|
42 |
add_filter( 'plugin_row_meta', array($this, 'registerPluginLinks'),10,2 );
|
43 |
|
44 |
add_action( 'admin_head', array($this, 'options_general_add_js') );
|
|
|
45 |
}
|
46 |
|
47 |
public function options_general_add_js() {
|
48 |
+
if (isset($_GET['page']) && $_GET['page'] == 'qqworld-auto-save-images') :
|
49 |
+
wp_register_script('noty', QQWORLD_AUTO_SAVE_IMAGES_URL . 'js/jquery.noty.packaged.min.js', array('jquery') );
|
50 |
+
wp_enqueue_script('noty');
|
51 |
+
wp_register_style('qqworld-auto-save-images-style', QQWORLD_AUTO_SAVE_IMAGES_URL . 'css/style.css' );
|
52 |
+
wp_enqueue_style('qqworld-auto-save-images-style');
|
53 |
+
wp_register_style('jquery-ui-style', QQWORLD_AUTO_SAVE_IMAGES_URL . 'css/jquery-ui/jquery-ui.min.css' );
|
54 |
+
wp_enqueue_style('jquery-ui-style');
|
55 |
+
wp_enqueue_script('jquery-ui-tooltip');
|
56 |
+
wp_enqueue_script('jquery-effects-core');
|
57 |
+
wp_enqueue_script('jquery-effects-shake');
|
58 |
+
wp_register_script('qqworld-auto-save-images-script', QQWORLD_AUTO_SAVE_IMAGES_URL . 'js/script.js', array('jquery') );
|
59 |
+
wp_enqueue_script('qqworld-auto-save-images-script');
|
60 |
+
$translation_array = array(
|
61 |
+
'are_your_sure' => __('Are you sure?<br />Before you click the yes button, I recommend backup site database.', 'qqworld_auto_save_images'),
|
62 |
+
'pls_select_post_types' => __('Please select post types.', 'qqworld_auto_save_images'),
|
63 |
+
'maybe_problem' => __('May be a problem with some posts: ', 'qqworld_auto_save_images'),
|
64 |
+
'n_post_has_been_scanned' => __( '%d post has been scanned.', 'qqworld_auto_save_images'),
|
65 |
+
'n_posts_have_been_scanned' => __( '%d posts have been scanned.', 'qqworld_auto_save_images'),
|
66 |
+
'n_post_included_remote_images_processed' => __( '%d post included remote images processed.', 'qqworld_auto_save_images'),
|
67 |
+
'n_posts_included_remote_images_processed' => __( '%d posts included remote images processed.', 'qqworld_auto_save_images'),
|
68 |
+
'n_post_has_missing_images_couldnt_be_processed' => __( "%d post has missing images couldn't be processed.", 'qqworld_auto_save_images'),
|
69 |
+
'n_posts_have_missing_images_couldnt_be_processed' => __( "%d posts have missing images couldn't be processed.", 'qqworld_auto_save_images'),
|
70 |
+
'found_n_post_including_remote_images' => __( 'found %d post including remote images.', 'qqworld_auto_save_images'),
|
71 |
+
'found_n_posts_including_remote_images' => __( 'found %d posts including remote images.', 'qqworld_auto_save_images'),
|
72 |
+
'and_with_n_post_has_missing_images' => __( "And with %d post has missing images.", 'qqworld_auto_save_images'),
|
73 |
+
'and_with_n_posts_have_missing_images' => __( "And with %d posts have missing images.", 'qqworld_auto_save_images'),
|
74 |
+
'no_posts_processed' => __( "No posts processed.", 'qqworld_auto_save_images'),
|
75 |
+
'no_post_has_remote_images_found' => __('No post has remote images found.', 'qqworld_auto_save_images'),
|
76 |
+
'no_posts_found' => __('No posts found.', 'qqworld_auto_save_images'),
|
77 |
+
'all_done' => __('All done.', 'qqworld_auto_save_images'),
|
78 |
+
'yes' => __('Yes'),
|
79 |
+
'no' => __('No'),
|
80 |
+
'scanning' => __('Scanning...', 'qqworld_auto_save_images'),
|
81 |
+
'listing' => __('Listing...', 'qqworld_auto_save_images'),
|
82 |
+
'id' => __('ID'),
|
83 |
+
'post_type' => __('Post Type', 'qqworld_auto_save_images'),
|
84 |
+
'title' => __('Title'),
|
85 |
+
'status' => __('Status'),
|
86 |
+
'control' => __('Control', 'qqworld_auto_save_images'),
|
87 |
+
'done' => __('Done')
|
88 |
+
);
|
89 |
+
wp_localize_script('qqworld-auto-save-images-script', 'QASI', $translation_array, '3.0.0');
|
90 |
+
endif;
|
91 |
}
|
92 |
|
93 |
public function get_scan_list() {
|
153 |
}
|
154 |
wp_update_post(array('ID' => $post_id, 'post_content' => $content));
|
155 |
$post_type_object = get_post_type_object($post_type);
|
156 |
+
if ($has_remote_images) :
|
157 |
+
$class = 'has_remote_images';
|
158 |
+
if ($has_not_exits_remote_images) $class += ' has_not_exits_remote_images';
|
159 |
+
$class = ' class="' . $class . '"';
|
160 |
?>
|
161 |
<tr<?php echo $class; ?>>
|
162 |
<td><?php echo $post_id; ?></td>
|
163 |
<td><?php echo $post_type_object->labels->name; ?></td>
|
164 |
<td><a href="<?php echo get_edit_post_link($post_id); ?>" target="_blank"><?php echo $title; ?> ⇛</a></td>
|
165 |
+
<td><?php echo $has_not_exits_remote_images ? '<span class="red">'.__('Has missing images.', 'qqworld_auto_save_images').'</span>' : '<span class="green">'.__('All remote images have been saved.', 'qqworld_auto_save_images').'</span>'; ?></td>
|
|
|
|
|
|
|
|
|
166 |
</tr>
|
167 |
<?php
|
168 |
+
else:
|
169 |
+
?>
|
170 |
+
<tr>
|
171 |
+
<td colspan="4" class="hr"></td>
|
172 |
+
</tr>
|
173 |
+
<?php endif;
|
174 |
endforeach;
|
175 |
exit;
|
176 |
}
|
279 |
data: {
|
280 |
action: 'save_remote_images',
|
281 |
post_id: QQWorld_auto_save_images.post_id,
|
282 |
+
content: encodeURI(encodeURI($('#content').val()))
|
283 |
},
|
284 |
success: function(respond) {
|
285 |
$('#save-remote-images-button').data('noty').close();
|
307 |
data: {
|
308 |
action: 'save_remote_images',
|
309 |
post_id: QQWorld_auto_save_images.post_id,
|
310 |
+
content: encodeURI(encodeURI(tinyMCE.activeEditor.getContent()))
|
311 |
},
|
312 |
success: function(respond) {
|
313 |
$('#save-remote-images-button').data('noty').close();
|
356 |
<table class="form-table">
|
357 |
<tbody>
|
358 |
<tr valign="top">
|
359 |
+
<th scope="row"><label><?php _e('Mode', 'qqworld_auto_save_images'); ?></label></th>
|
360 |
<td><fieldset>
|
361 |
+
<legend class="screen-reader-text"><span><?php _e('Mode', 'qqworld_auto_save_images'); ?></span></legend>
|
362 |
<label for="auto">
|
363 |
<input name="qqworld_auto_save_imagess_type" type="radio" id="auto" value="auto" <?php checked('auto', $this->type); ?> />
|
364 |
+
<?php _e('Automatic', 'qqworld_auto_save_images'); ?>
|
365 |
+
</label> <span class="icon help" title="<?php _e('Automatically save all remote images to local media libary when you save or publish post.', 'qqworld_auto_save_images'); ?>"></span><br />
|
366 |
<label for="manual">
|
367 |
<input name="qqworld_auto_save_imagess_type" type="radio" id="manual" value="manual" <?php checked('manual', $this->type); ?> />
|
368 |
+
<?php _e('Manual', 'qqworld_auto_save_images'); ?>
|
369 |
+
</label> <span class="icon help" title="<?php _e('Manually save all remote images to local media libary when you click the button on the top of editor.', 'qqworld_auto_save_images'); ?>"></span>
|
370 |
</fieldset></td>
|
371 |
</tr>
|
372 |
|
447 |
</tbody>
|
448 |
</table>
|
449 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
jQuery(function($) {
|
451 |
+
QQWorld_auto_save_images.scan_posts();
|
452 |
});
|
453 |
</script>
|
454 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button-primary" name="Submit" /></p>
|
462 |
register_setting('qqworld_auto_save_images_settings', 'qqworld_auto_save_imagess_set_featured_image');
|
463 |
}
|
464 |
|
465 |
+
/**
|
466 |
+
* gets the current post type in the WordPress Admin
|
467 |
+
*/
|
468 |
+
public function get_current_post_type() {
|
469 |
+
global $post, $typenow, $current_screen;
|
470 |
+
|
471 |
+
if (isset($_GET['post']) && $_GET['post']) {
|
472 |
+
$post_type = get_post_type($_GET['post']);
|
473 |
+
return $post_type;
|
474 |
+
}
|
475 |
+
|
476 |
+
//we have a post so we can just get the post type from that
|
477 |
+
if ( $post && $post->post_type )
|
478 |
+
return $post->post_type;
|
479 |
+
|
480 |
+
//check the global $typenow - set in admin.php
|
481 |
+
elseif( $typenow )
|
482 |
+
return $typenow;
|
483 |
+
|
484 |
+
//check the global $current_screen object - set in sceen.php
|
485 |
+
elseif( $current_screen && $current_screen->post_type )
|
486 |
+
return $current_screen->post_type;
|
487 |
+
|
488 |
+
//lastly check the post_type querystring
|
489 |
+
elseif( isset( $_REQUEST['post_type'] ) )
|
490 |
+
return sanitize_key( $_REQUEST['post_type'] );
|
491 |
+
|
492 |
+
//we do not know the post type!
|
493 |
+
return null;
|
494 |
+
}
|
495 |
+
|
496 |
function add_actions() {
|
497 |
+
$post_type = $this->get_current_post_type();
|
498 |
+
if ($post_type) {
|
499 |
+
add_action($this->using_action.'_'.$post_type, array($this, 'fetch_images') );
|
|
|
|
|
|
|
|
|
500 |
}
|
501 |
}
|
502 |
|
503 |
function remove_actions() {
|
504 |
+
$post_type = $this->get_current_post_type();
|
505 |
+
if ($post_type) {
|
506 |
+
remove_action($this->using_action.'_'.$post_type, array($this, 'fetch_images') );
|
|
|
|
|
|
|
|
|
507 |
}
|
508 |
}
|
509 |
|
510 |
+
function utf8_urldecode($str) {
|
511 |
+
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\\\1;",urldecode($str));
|
512 |
+
return html_entity_decode($str, null, 'UTF-8');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
513 |
}
|
514 |
|
515 |
function save_remote_images() {
|
523 |
if ( !current_user_can('edit_post', $post_id) )
|
524 |
return;
|
525 |
|
526 |
+
$content = $this->utf8_urldecode($this->utf8_urldecode($_POST['content']));
|
527 |
|
528 |
$preg=preg_match_all($this->preg,stripslashes($content),$matches);
|
529 |
if($preg){
|