Version Description
Download this release
Release Info
Developer | qqworld |
Plugin | QQWorld Auto Save Images |
Version | 1.5.7.3 |
Comparing to | |
See all releases |
Code changes from version 1.5.7 to 1.5.7.3
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"
|
@@ -187,3 +187,6 @@ msgstr ""
|
|
187 |
|
188 |
msgid "If the server is too much stress may be appropriately reduced speed."
|
189 |
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-07 14:37+0800\n"
|
7 |
"Last-Translator: Michael Wang <admin@qqworld.org>\n"
|
8 |
"Language-Team: QQWorld <admin@qqworld.org>\n"
|
9 |
"Language: zh_CN\n"
|
187 |
|
188 |
msgid "If the server is too much stress may be appropriately reduced speed."
|
189 |
msgstr "如果服务器压力过大,可以适当调低速度。"
|
190 |
+
|
191 |
+
msgid "May be a problem with some posts: "
|
192 |
+
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,7 +42,6 @@ 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() {
|
@@ -139,7 +138,6 @@ class QQWorld_auto_save_images {
|
|
139 |
set_time_limit(0);
|
140 |
if ( !current_user_can( 'manage_options' ) ) return;
|
141 |
$post_ids = $_REQUEST['post_id'];
|
142 |
-
echo 1;
|
143 |
if (!empty($post_ids)) foreach ($post_ids as $post_id) :
|
144 |
$post = get_post($post_id);
|
145 |
$post_id = $post->ID;
|
@@ -240,7 +238,7 @@ class QQWorld_auto_save_images {
|
|
240 |
data: {
|
241 |
action: 'save_remote_images',
|
242 |
post_id: QQWorld_auto_save_images.post_id,
|
243 |
-
content:
|
244 |
},
|
245 |
success: function(respond) {
|
246 |
$('#save-remote-images-button').data('noty').close();
|
@@ -268,7 +266,7 @@ class QQWorld_auto_save_images {
|
|
268 |
data: {
|
269 |
action: 'save_remote_images',
|
270 |
post_id: QQWorld_auto_save_images.post_id,
|
271 |
-
content:
|
272 |
},
|
273 |
success: function(respond) {
|
274 |
$('#save-remote-images-button').data('noty').close();
|
@@ -454,260 +452,334 @@ class QQWorld_auto_save_images {
|
|
454 |
return o.join('');
|
455 |
}
|
456 |
if (!QQWorld_auto_save_images) var QQWorld_auto_save_images = {};
|
457 |
-
QQWorld_auto_save_images.
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
var
|
467 |
-
|
468 |
-
var
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
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);
|
478 |
-
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);
|
479 |
-
}
|
480 |
}
|
481 |
-
} else {
|
482 |
-
$('#scan_old_post_list').slideUp('slow');
|
483 |
-
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
484 |
}
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
for (var p=r; p<r+speed; p++) {
|
500 |
-
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
501 |
-
}
|
502 |
-
$.ajax({
|
503 |
-
type: 'POST',
|
504 |
-
url: ajaxurl,
|
505 |
-
data: data,
|
506 |
-
success: function(data) {
|
507 |
-
data = $(data);
|
508 |
-
$('#scan_old_post_list tbody').append(data);
|
509 |
-
data.hide().fadeIn('fast');
|
510 |
-
r += speed;
|
511 |
-
QQWorld_auto_save_images.scan(respond, r);
|
512 |
}
|
513 |
-
|
514 |
-
|
515 |
-
QQWorld_auto_save_images.list = function(respond, r) {
|
516 |
-
var $ = jQuery;
|
517 |
-
if (typeof respond[r] == 'undefined') {
|
518 |
-
$('#scan-result').effect( 'shake', null, 500 );
|
519 |
$('#form').slideDown('slow');
|
520 |
$('body').data('noty').close();
|
521 |
-
var count = $('#scan_old_post_list tbody tr').length;
|
522 |
-
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
523 |
-
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
524 |
-
if (count) {
|
525 |
-
if (count==1) count_html = sprintf("<?php _e( '%d post has been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
526 |
-
else count_html = sprintf("<?php _e( '%d posts have been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
527 |
-
if (count_remote_images) {
|
528 |
-
if (count_remote_images==1) count_html += sprintf("<br /><?php _e( 'found %d post including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
529 |
-
else count_html += sprintf("<br /><?php _e( 'found %d posts including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
530 |
-
if (count_not_exits_remote_images) {
|
531 |
-
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);
|
532 |
-
else count_html += sprintf("<br /><?php _e( "And with %d posts have missing images.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
533 |
-
}
|
534 |
-
} else count_html += '<br /><?php _e('No post has remote images found.', 'qqworld_auto_save_images'); ?>';
|
535 |
-
} else {
|
536 |
-
$('#scan_old_post_list').slideUp('slow');
|
537 |
-
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
538 |
-
}
|
539 |
noty({
|
540 |
-
text:
|
541 |
-
type: '
|
542 |
-
layout: '
|
543 |
dismissQueue: true,
|
544 |
-
|
545 |
});
|
546 |
$('#scan_old_posts').removeAttr('disabled');
|
547 |
$('#list_all_posts').removeAttr('disabled');
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
$.ajax({
|
557 |
-
type: 'POST',
|
558 |
-
url: ajaxurl,
|
559 |
-
data: data,
|
560 |
-
success: function(data) {
|
561 |
-
data = $(data);
|
562 |
-
$('#scan_old_post_list tbody').append(data);
|
563 |
-
data.hide().fadeIn('fast');
|
564 |
-
r += speed;
|
565 |
-
QQWorld_auto_save_images.list(respond, r);
|
566 |
-
},
|
567 |
-
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
568 |
-
if (XMLHttpRequest) console.log('XMLHttpRequest: ' + XMLHttpRequest);
|
569 |
-
else if (textStatus) console.log('textStatus: ' + textStatus);
|
570 |
-
else if (errorThrown) console.log('errorThrown' + errorThrown);
|
571 |
-
console.log(this);
|
572 |
}
|
573 |
-
}
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
if ($(this).val() == '-1') $('input[name="offset"]').attr('disabled', true);
|
596 |
-
else $('input[name="offset"]').removeAttr('disabled', true);
|
597 |
-
});
|
598 |
-
$('#auto').on('click', function() {
|
599 |
-
$('#second_level').fadeIn('fast');
|
600 |
-
});
|
601 |
-
$('#manual').on('click', function() {
|
602 |
-
$('#second_level').fadeOut('fast');
|
603 |
-
});
|
604 |
-
$('#scan_old_posts').on('click', function() {
|
605 |
-
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
606 |
-
var n = noty({
|
607 |
-
text: QQWorld_auto_save_images.are_your_sure,
|
608 |
-
type: 'warning',
|
609 |
-
dismissQueue: true,
|
610 |
-
layout: 'center',
|
611 |
-
modal: true,
|
612 |
-
buttons: [
|
613 |
-
{
|
614 |
-
addClass: 'button button-primary',
|
615 |
-
text: '<?php _e('Yes'); ?>',
|
616 |
-
onClick: function ($noty) {
|
617 |
-
$('#form').slideUp('slow');
|
618 |
-
$noty.close();
|
619 |
-
$('#scan_old_posts').attr('disabled', true);
|
620 |
-
$('#list_all_posts').attr('disabled', true);
|
621 |
-
var data = $('#form').serialize()+'&action=get_scan_list';
|
622 |
-
$.ajax({
|
623 |
-
type: 'POST',
|
624 |
-
url: ajaxurl,
|
625 |
-
data: data,
|
626 |
-
dataType: 'json',
|
627 |
-
success: function(respond) {
|
628 |
-
$('#scan-result').html('<table id="scan_old_post_list">\
|
629 |
-
\ <thead>\
|
630 |
-
\ <th><?php _e('ID'); ?></th>\
|
631 |
-
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
632 |
-
\ <th><?php _e('Title'); ?></th>\
|
633 |
-
\ <th><?php _e('Status'); ?></th>\
|
634 |
-
\ </thead>\
|
635 |
-
\ <tbody>\
|
636 |
-
\ </tbody>\
|
637 |
-
\</table>');
|
638 |
-
$('body').data('noty', noty({
|
639 |
-
text: '<?php _e('Scanning...', 'qqworld_auto_save_images'); ?>',
|
640 |
-
type: 'notification',
|
641 |
-
layout: 'center',
|
642 |
-
dismissQueue: true
|
643 |
-
}) );
|
644 |
-
QQWorld_auto_save_images.scan(respond, 0);
|
645 |
-
}
|
646 |
-
});
|
647 |
-
}
|
648 |
-
},
|
649 |
-
{
|
650 |
-
addClass: 'button button-primary',
|
651 |
-
text: '<?php _e('No'); ?>',
|
652 |
-
onClick: function ($noty) {
|
653 |
-
$noty.close();
|
654 |
-
}
|
655 |
}
|
656 |
-
]
|
657 |
-
});
|
658 |
-
} else QQWorld_auto_save_images.if_not_select_post_type();
|
659 |
-
});
|
660 |
-
$('#list_all_posts').on('click', function() {
|
661 |
-
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
662 |
-
$('#form').slideUp('slow');
|
663 |
-
$('#scan_old_posts').attr('disabled', true);
|
664 |
-
$('#list_all_posts').attr('disabled', true);
|
665 |
-
var data = $('#form').serialize()+'&action=get_scan_list';
|
666 |
-
$.ajax({
|
667 |
-
type: 'POST',
|
668 |
-
url: ajaxurl,
|
669 |
-
data: data,
|
670 |
-
dataType: 'json',
|
671 |
-
success: function(respond) {
|
672 |
-
$('#scan-result').html('<table id="scan_old_post_list">\
|
673 |
-
\ <thead>\
|
674 |
-
\ <th><?php _e('ID'); ?></th>\
|
675 |
-
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
676 |
-
\ <th><?php _e('Title'); ?></th>\
|
677 |
-
\ <th><?php _e('Status'); ?></th>\
|
678 |
-
\ <th><?php _e('Control', 'qqworld_auto_save_images'); ?></th>\
|
679 |
-
\ </thead>\
|
680 |
-
\ <tbody>\
|
681 |
-
\ </tbody>\
|
682 |
-
\</table>');
|
683 |
-
$('body').data('noty', noty({
|
684 |
-
text: '<?php _e('Listing...', 'qqworld_auto_save_images'); ?>',
|
685 |
-
type: 'notification',
|
686 |
-
layout: 'center',
|
687 |
-
dismissQueue: true
|
688 |
-
}) );
|
689 |
-
QQWorld_auto_save_images.list(respond, 0);
|
690 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
});
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
var
|
697 |
-
|
698 |
-
|
|
|
|
|
|
|
|
|
|
|
699 |
$.ajax({
|
700 |
type: 'POST',
|
701 |
url: ajaxurl,
|
702 |
data: data,
|
703 |
success: function(data) {
|
704 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
705 |
}
|
706 |
});
|
707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
};
|
709 |
jQuery(function($) {
|
710 |
-
QQWorld_auto_save_images.
|
711 |
});
|
712 |
</script>
|
713 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button-primary" name="Submit" /></p>
|
@@ -721,44 +793,54 @@ class QQWorld_auto_save_images {
|
|
721 |
register_setting('qqworld_auto_save_images_settings', 'qqworld_auto_save_imagess_set_featured_image');
|
722 |
}
|
723 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
724 |
function add_actions() {
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
break;
|
729 |
-
case 'save':
|
730 |
-
add_action('save_post', array($this, 'fetch_images') );
|
731 |
-
break;
|
732 |
}
|
733 |
}
|
734 |
|
735 |
function remove_actions() {
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
break;
|
740 |
-
case 'save':
|
741 |
-
remove_action('save_post', array($this, 'fetch_images') );
|
742 |
-
break;
|
743 |
}
|
744 |
}
|
745 |
|
746 |
-
function
|
747 |
-
$
|
748 |
-
|
749 |
-
for ($i = 0; $i < $len; $i++) {
|
750 |
-
if ($str[$i] == '%' && $str[$i+1] == 'u') {
|
751 |
-
$val = hexdec(substr($str, $i+2, 4));
|
752 |
-
if ($val < 0x7f) $ret .= chr($val);
|
753 |
-
else if($val < 0x800) $ret .= chr(0xc0|($val>>6)).chr(0x80|($val&0x3f));
|
754 |
-
else $ret .= chr(0xe0|($val>>12)).chr(0x80|(($val>>6)&0x3f)).chr(0x80|($val&0x3f));
|
755 |
-
$i += 5;
|
756 |
-
} else if ($str[$i] == '%') {
|
757 |
-
$ret .= urldecode(substr($str, $i, 3));
|
758 |
-
$i += 2;
|
759 |
-
} else $ret .= $str[$i];
|
760 |
-
}
|
761 |
-
return $ret;
|
762 |
}
|
763 |
|
764 |
function save_remote_images() {
|
@@ -772,7 +854,7 @@ class QQWorld_auto_save_images {
|
|
772 |
if ( !current_user_can('edit_post', $post_id) )
|
773 |
return;
|
774 |
|
775 |
-
$content = $this->
|
776 |
|
777 |
$preg=preg_match_all($this->preg,stripslashes($content),$matches);
|
778 |
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.3
|
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() {
|
138 |
set_time_limit(0);
|
139 |
if ( !current_user_can( 'manage_options' ) ) return;
|
140 |
$post_ids = $_REQUEST['post_id'];
|
|
|
141 |
if (!empty($post_ids)) foreach ($post_ids as $post_id) :
|
142 |
$post = get_post($post_id);
|
143 |
$post_id = $post->ID;
|
238 |
data: {
|
239 |
action: 'save_remote_images',
|
240 |
post_id: QQWorld_auto_save_images.post_id,
|
241 |
+
content: encodeURI(encodeURI($('#content').val()))
|
242 |
},
|
243 |
success: function(respond) {
|
244 |
$('#save-remote-images-button').data('noty').close();
|
266 |
data: {
|
267 |
action: 'save_remote_images',
|
268 |
post_id: QQWorld_auto_save_images.post_id,
|
269 |
+
content: encodeURI(encodeURI(tinyMCE.activeEditor.getContent()))
|
270 |
},
|
271 |
success: function(respond) {
|
272 |
$('#save-remote-images-button').data('noty').close();
|
452 |
return o.join('');
|
453 |
}
|
454 |
if (!QQWorld_auto_save_images) var QQWorld_auto_save_images = {};
|
455 |
+
QQWorld_auto_save_images.scan_posts = function() {
|
456 |
+
var _this = this,
|
457 |
+
$ = jQuery;
|
458 |
+
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'); ?>';
|
459 |
+
QQWorld_auto_save_images.pls_select_post_types = '<?php _e('Please select post types.', 'qqworld_auto_save_images'); ?>';
|
460 |
+
QQWorld_auto_save_images.maybe_problem = '<?php _e('May be a problem with some posts: ', 'qqworld_auto_save_images'); ?>';
|
461 |
+
|
462 |
+
this.action = {};
|
463 |
+
this.action.catch_errors = function(XMLHttpRequest, textStatus, errorThrown) {
|
464 |
+
var error='', args=new Array;
|
465 |
+
error += '<div style="text-align: left;">';
|
466 |
+
var query = this.data.split('&');
|
467 |
+
var data = new Array;
|
468 |
+
var offset_from_id = $('input[name="offset"]').val();
|
469 |
+
var temp_r = $('body').data('r') + parseInt(offset_from_id);
|
470 |
+
for (var d in query) {
|
471 |
+
var q = query[d].split('=');
|
472 |
+
if (q[0]=='post_id[]') {
|
473 |
+
temp_r++;
|
474 |
+
data.push(q[1]+'(No. '+temp_r+')');
|
|
|
|
|
|
|
475 |
}
|
|
|
|
|
|
|
476 |
}
|
477 |
+
error += QQWorld_auto_save_images.maybe_problem + data.join(', ');
|
478 |
+
if (XMLHttpRequest) {
|
479 |
+
error += '<hr />';
|
480 |
+
args = new Array;
|
481 |
+
for (var x in XMLHttpRequest) {
|
482 |
+
switch (x) {
|
483 |
+
case 'readyState':
|
484 |
+
case 'responseText':
|
485 |
+
case 'status':
|
486 |
+
args.push( x + ': ' + XMLHttpRequest[x] );
|
487 |
+
break;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
error += args.join('<br />', args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
+
error += '<br />' + textStatus + ': ' + errorThrown;
|
493 |
+
error += '</div>';
|
|
|
|
|
|
|
|
|
494 |
$('#form').slideDown('slow');
|
495 |
$('body').data('noty').close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
496 |
noty({
|
497 |
+
text: error,
|
498 |
+
type: 'error',
|
499 |
+
layout: 'bottom',
|
500 |
dismissQueue: true,
|
501 |
+
closeWith: ['button']
|
502 |
});
|
503 |
$('#scan_old_posts').removeAttr('disabled');
|
504 |
$('#list_all_posts').removeAttr('disabled');
|
505 |
+
$('body').data('r', $('body').data('r')+$('body').data('speed'));
|
506 |
+
switch ($('body').data('scan-mode')) {
|
507 |
+
case 'scan':
|
508 |
+
_this.action.scan($('body').data('respond'), $('body').data('r'));
|
509 |
+
break;
|
510 |
+
case 'list':
|
511 |
+
_this.action.list($('body').data('respond'), $('body').data('r'));
|
512 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
513 |
}
|
514 |
+
};
|
515 |
+
this.action.scan = function(respond, r) {
|
516 |
+
var $ = jQuery;
|
517 |
+
$('body').data('scan-mode', 'scan').data('r', r);
|
518 |
+
if (typeof respond[r] == 'undefined') {
|
519 |
+
$('#scan-result').effect( 'shake', null, 500 );
|
520 |
+
$('#form').slideDown('slow');
|
521 |
+
$('body').data('noty').close();
|
522 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
523 |
+
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
524 |
+
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
525 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
526 |
+
if (count) {
|
527 |
+
if (count==1) count_html = sprintf("<?php _e( '%d post has been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
528 |
+
else count_html = sprintf("<?php _e( '%d posts have been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
529 |
+
if (count_remote_images) {
|
530 |
+
count_remote_images = count_remote_images - count_not_exits_remote_images;
|
531 |
+
if (count_remote_images<=1) count_html += sprintf("<br /><?php _e( '%d post included remote images processed.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
532 |
+
else count_html += sprintf("<br /><?php _e( '%d posts included remote images processed.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
533 |
+
if (count_not_exits_remote_images) {
|
534 |
+
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);
|
535 |
+
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
537 |
}
|
538 |
+
} else {
|
539 |
+
$('#scan_old_post_list').slideUp('slow');
|
540 |
+
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
541 |
+
}
|
542 |
+
noty({
|
543 |
+
text: '<?php _e('All done.', 'qqworld_auto_save_images'); ?><br />'+count_html,
|
544 |
+
type: 'success',
|
545 |
+
layout: 'center',
|
546 |
+
dismissQueue: true,
|
547 |
+
modal: true
|
548 |
+
});
|
549 |
+
$('#scan_old_posts').removeAttr('disabled');
|
550 |
+
$('#list_all_posts').removeAttr('disabled');
|
551 |
+
return;
|
552 |
+
}
|
553 |
+
var speed = parseInt($('select[name="speed"]').val());
|
554 |
+
post_id = new Array;
|
555 |
+
$('body').data('speed', speed);
|
556 |
+
var data = 'action=save_remote_images_after_scan';
|
557 |
+
for (var p=r; p<r+speed; p++) {
|
558 |
+
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
559 |
+
}
|
560 |
+
console.log(data);
|
561 |
+
$.ajax({
|
562 |
+
type: 'POST',
|
563 |
+
url: ajaxurl,
|
564 |
+
data: data,
|
565 |
+
success: function(data) {
|
566 |
+
data = $(data);
|
567 |
+
$('#scan_old_post_list tbody').append(data);
|
568 |
+
data.hide().fadeIn('fast');
|
569 |
+
r += speed;
|
570 |
+
_this.action.scan(respond, r);
|
571 |
+
},
|
572 |
+
error: _this.action.catch_errors
|
573 |
+
});
|
574 |
+
};
|
575 |
+
this.action.list = function(respond, r) {
|
576 |
+
var $ = jQuery;
|
577 |
+
$('body').data('scan-mode', 'list').data('r', r);
|
578 |
+
if (typeof respond[r] == 'undefined') {
|
579 |
+
$('#scan-result').effect( 'shake', null, 500 );
|
580 |
+
$('#form').slideDown('slow');
|
581 |
+
$('body').data('noty').close();
|
582 |
+
var count = $('#scan_old_post_list tbody tr').length;
|
583 |
+
var count_remote_images = $('#scan_old_post_list tbody tr.has_remote_images').length;
|
584 |
+
var count_not_exits_remote_images = $('#scan_old_post_list tbody tr.has_not_exits_remote_images').length;
|
585 |
+
if (count) {
|
586 |
+
if (count==1) count_html = sprintf("<?php _e( '%d post has been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
587 |
+
else count_html = sprintf("<?php _e( '%d posts have been scanned.', 'qqworld_auto_save_images'); ?>", count);
|
588 |
+
if (count_remote_images) {
|
589 |
+
if (count_remote_images==1) count_html += sprintf("<br /><?php _e( 'found %d post including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
590 |
+
else count_html += sprintf("<br /><?php _e( 'found %d posts including remote images.', 'qqworld_auto_save_images'); ?>", count_remote_images);
|
591 |
+
if (count_not_exits_remote_images) {
|
592 |
+
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);
|
593 |
+
else count_html += sprintf("<br /><?php _e( "And with %d posts have missing images.", 'qqworld_auto_save_images'); ?>", count_not_exits_remote_images);
|
594 |
+
}
|
595 |
+
} else count_html += '<br /><?php _e('No post has remote images found.', 'qqworld_auto_save_images'); ?>';
|
596 |
+
} else {
|
597 |
+
$('#scan_old_post_list').slideUp('slow');
|
598 |
+
count_html = '<?php _e('No posts found.', 'qqworld_auto_save_images'); ?>';
|
599 |
+
}
|
600 |
+
noty({
|
601 |
+
text: '<?php _e('All done.', 'qqworld_auto_save_images'); ?><br />'+count_html,
|
602 |
+
type: 'success',
|
603 |
+
layout: 'center',
|
604 |
+
dismissQueue: true,
|
605 |
+
modal: true
|
606 |
});
|
607 |
+
$('#scan_old_posts').removeAttr('disabled');
|
608 |
+
$('#list_all_posts').removeAttr('disabled');
|
609 |
+
return;
|
610 |
+
}
|
611 |
+
var speed = parseInt($('select[name="speed"]').val());
|
612 |
+
post_id = new Array;
|
613 |
+
$('body').data('speed', speed);
|
614 |
+
var data = 'action=save_remote_images_list_all_posts';
|
615 |
+
for (var p=r; p<r+speed; p++) {
|
616 |
+
if (typeof respond[p] != 'undefined') data += '&post_id[]='+respond[p];
|
617 |
+
}
|
618 |
+
console.log(data);
|
619 |
$.ajax({
|
620 |
type: 'POST',
|
621 |
url: ajaxurl,
|
622 |
data: data,
|
623 |
success: function(data) {
|
624 |
+
data = $(data);
|
625 |
+
$('#scan_old_post_list tbody').append(data);
|
626 |
+
data.hide().fadeIn('fast');
|
627 |
+
r += speed;
|
628 |
+
_this.action.list(respond, r);
|
629 |
+
},
|
630 |
+
error: _this.action.catch_errors
|
631 |
+
});
|
632 |
+
};
|
633 |
+
|
634 |
+
|
635 |
+
this.action.if_not_select_post_type = function() {
|
636 |
+
var $ = jQuery;
|
637 |
+
$('#post_types_list').effect( 'shake', null, 500 );
|
638 |
+
var n = noty({
|
639 |
+
text: QQWorld_auto_save_images.pls_select_post_types,
|
640 |
+
type: 'error',
|
641 |
+
dismissQueue: true,
|
642 |
+
layout: 'bottomCenter',
|
643 |
+
timeout: 3000
|
644 |
+
});
|
645 |
+
}
|
646 |
+
|
647 |
+
this.create = {};
|
648 |
+
this.create.events = function() {
|
649 |
+
$(".icon.help").tooltip({
|
650 |
+
show: {
|
651 |
+
effect: "slideDown",
|
652 |
+
delay: 250
|
653 |
}
|
654 |
});
|
655 |
+
$('select[name="posts_per_page"]').on('change', function() {
|
656 |
+
if ($(this).val() == '-1') $('input[name="offset"]').attr('disabled', true);
|
657 |
+
else $('input[name="offset"]').removeAttr('disabled', true);
|
658 |
+
});
|
659 |
+
$('#auto').on('click', function() {
|
660 |
+
$('#second_level').fadeIn('fast');
|
661 |
+
});
|
662 |
+
$('#manual').on('click', function() {
|
663 |
+
$('#second_level').fadeOut('fast');
|
664 |
+
});
|
665 |
+
$('#scan_old_posts').on('click', function() {
|
666 |
+
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
667 |
+
var n = noty({
|
668 |
+
text: QQWorld_auto_save_images.are_your_sure,
|
669 |
+
type: 'warning',
|
670 |
+
dismissQueue: true,
|
671 |
+
layout: 'center',
|
672 |
+
modal: true,
|
673 |
+
buttons: [
|
674 |
+
{
|
675 |
+
addClass: 'button button-primary',
|
676 |
+
text: '<?php _e('Yes'); ?>',
|
677 |
+
onClick: function ($noty) {
|
678 |
+
$('#form').slideUp('slow');
|
679 |
+
$noty.close();
|
680 |
+
$('#scan_old_posts').attr('disabled', true);
|
681 |
+
$('#list_all_posts').attr('disabled', true);
|
682 |
+
var data = $('#form').serialize()+'&action=get_scan_list';
|
683 |
+
$.ajax({
|
684 |
+
type: 'POST',
|
685 |
+
url: ajaxurl,
|
686 |
+
data: data,
|
687 |
+
dataType: 'json',
|
688 |
+
success: function(respond) {
|
689 |
+
$('body').data('respond', respond);
|
690 |
+
$('#scan-result').html('<table id="scan_old_post_list">\
|
691 |
+
\ <thead>\
|
692 |
+
\ <th><?php _e('ID'); ?></th>\
|
693 |
+
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
694 |
+
\ <th><?php _e('Title'); ?></th>\
|
695 |
+
\ <th><?php _e('Status'); ?></th>\
|
696 |
+
\ </thead>\
|
697 |
+
\ <tbody>\
|
698 |
+
\ </tbody>\
|
699 |
+
\</table>');
|
700 |
+
$('body').data('noty', noty({
|
701 |
+
text: '<?php _e('Scanning...', 'qqworld_auto_save_images'); ?>',
|
702 |
+
type: 'notification',
|
703 |
+
layout: 'center',
|
704 |
+
dismissQueue: true
|
705 |
+
}) );
|
706 |
+
_this.action.scan(respond, 0);
|
707 |
+
},
|
708 |
+
error: _this.action.catch_errors
|
709 |
+
});
|
710 |
+
}
|
711 |
+
},
|
712 |
+
{
|
713 |
+
addClass: 'button button-primary',
|
714 |
+
text: '<?php _e('No'); ?>',
|
715 |
+
onClick: function ($noty) {
|
716 |
+
$noty.close();
|
717 |
+
}
|
718 |
+
}
|
719 |
+
]
|
720 |
+
});
|
721 |
+
} else _this.action.if_not_select_post_type();
|
722 |
+
});
|
723 |
+
$('#list_all_posts').on('click', function() {
|
724 |
+
if (jQuery('input[name="qqworld_auto_save_imagess_post_types[]"]:checked').length) {
|
725 |
+
$('#form').slideUp('slow');
|
726 |
+
$('#scan_old_posts').attr('disabled', true);
|
727 |
+
$('#list_all_posts').attr('disabled', true);
|
728 |
+
var data = $('#form').serialize()+'&action=get_scan_list';
|
729 |
+
$.ajax({
|
730 |
+
type: 'POST',
|
731 |
+
url: ajaxurl,
|
732 |
+
data: data,
|
733 |
+
dataType: 'json',
|
734 |
+
success: function(respond) {
|
735 |
+
$('body').data('respond', respond);
|
736 |
+
$('#scan-result').html('<table id="scan_old_post_list">\
|
737 |
+
\ <thead>\
|
738 |
+
\ <th><?php _e('ID'); ?></th>\
|
739 |
+
\ <th><?php _e('Post Type', 'qqworld_auto_save_images'); ?></th>\
|
740 |
+
\ <th><?php _e('Title'); ?></th>\
|
741 |
+
\ <th><?php _e('Status'); ?></th>\
|
742 |
+
\ <th><?php _e('Control', 'qqworld_auto_save_images'); ?></th>\
|
743 |
+
\ </thead>\
|
744 |
+
\ <tbody>\
|
745 |
+
\ </tbody>\
|
746 |
+
\</table>');
|
747 |
+
$('body').data('noty', noty({
|
748 |
+
text: '<?php _e('Listing...', 'qqworld_auto_save_images'); ?>',
|
749 |
+
type: 'notification',
|
750 |
+
layout: 'center',
|
751 |
+
dismissQueue: true
|
752 |
+
}) );
|
753 |
+
_this.action.list(respond, 0);
|
754 |
+
},
|
755 |
+
error: _this.action.catch_errors
|
756 |
+
});
|
757 |
+
} else _this.action.if_not_select_post_type();
|
758 |
+
});
|
759 |
+
$(document).on('click', '#scan_old_post_list .fetch-remote-images', function() {
|
760 |
+
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/7XN3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ev6JQqOGoMFBAAOw==" />';
|
761 |
+
var post_id = $(this).attr('post-id');
|
762 |
+
$(this).hide().after(wait);
|
763 |
+
var data = 'action=save_remote_images_after_scan&post_id[]='+post_id;
|
764 |
+
$.ajax({
|
765 |
+
type: 'POST',
|
766 |
+
url: ajaxurl,
|
767 |
+
data: data,
|
768 |
+
success: function(data) {
|
769 |
+
$('#list-'+post_id).html('<span class="green"><?php _e('Done'); ?></span>');
|
770 |
+
},
|
771 |
+
error: _this.action.catch_errors
|
772 |
+
});
|
773 |
+
})
|
774 |
+
};
|
775 |
+
|
776 |
+
this.create.init = function() {
|
777 |
+
_this.create.events();
|
778 |
+
};
|
779 |
+
this.create.init();
|
780 |
};
|
781 |
jQuery(function($) {
|
782 |
+
QQWorld_auto_save_images.scan_posts();
|
783 |
});
|
784 |
</script>
|
785 |
<p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button-primary" name="Submit" /></p>
|
793 |
register_setting('qqworld_auto_save_images_settings', 'qqworld_auto_save_imagess_set_featured_image');
|
794 |
}
|
795 |
|
796 |
+
/**
|
797 |
+
* gets the current post type in the WordPress Admin
|
798 |
+
*/
|
799 |
+
public function get_current_post_type() {
|
800 |
+
global $post, $typenow, $current_screen;
|
801 |
+
|
802 |
+
if (isset($_GET['post']) && $_GET['post']) {
|
803 |
+
$post_type = get_post_type($_GET['post']);
|
804 |
+
return $post_type;
|
805 |
+
}
|
806 |
+
|
807 |
+
//we have a post so we can just get the post type from that
|
808 |
+
if ( $post && $post->post_type )
|
809 |
+
return $post->post_type;
|
810 |
+
|
811 |
+
//check the global $typenow - set in admin.php
|
812 |
+
elseif( $typenow )
|
813 |
+
return $typenow;
|
814 |
+
|
815 |
+
//check the global $current_screen object - set in sceen.php
|
816 |
+
elseif( $current_screen && $current_screen->post_type )
|
817 |
+
return $current_screen->post_type;
|
818 |
+
|
819 |
+
//lastly check the post_type querystring
|
820 |
+
elseif( isset( $_REQUEST['post_type'] ) )
|
821 |
+
return sanitize_key( $_REQUEST['post_type'] );
|
822 |
+
|
823 |
+
//we do not know the post type!
|
824 |
+
return null;
|
825 |
+
}
|
826 |
+
|
827 |
function add_actions() {
|
828 |
+
$post_type = $this->get_current_post_type();
|
829 |
+
if ($post_type) {
|
830 |
+
add_action($this->using_action.'_'.$post_type, array($this, 'fetch_images') );
|
|
|
|
|
|
|
|
|
831 |
}
|
832 |
}
|
833 |
|
834 |
function remove_actions() {
|
835 |
+
$post_type = $this->get_current_post_type();
|
836 |
+
if ($post_type) {
|
837 |
+
remove_action($this->using_action.'_'.$post_type, array($this, 'fetch_images') );
|
|
|
|
|
|
|
|
|
838 |
}
|
839 |
}
|
840 |
|
841 |
+
function utf8_urldecode($str) {
|
842 |
+
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\\\1;",urldecode($str));
|
843 |
+
return html_entity_decode($str, null, 'UTF-8');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
844 |
}
|
845 |
|
846 |
function save_remote_images() {
|
854 |
if ( !current_user_can('edit_post', $post_id) )
|
855 |
return;
|
856 |
|
857 |
+
$content = $this->utf8_urldecode($this->utf8_urldecode($_POST['content']));
|
858 |
|
859 |
$preg=preg_match_all($this->preg,stripslashes($content),$matches);
|
860 |
if($preg){
|