QQWorld Auto Save Images - Version 1.2

Version Description

Download this release

Release Info

Developer qqworld
Plugin Icon 128x128 QQWorld Auto Save Images
Version 1.2
Comparing to
See all releases

Code changes from version 1.1 to 1.2

lang/qqworld_auto_save_images-zh_CN.mo ADDED
Binary file
lang/qqworld_auto_save_images-zh_CN.po ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ 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-01-05 21:11+0800\n"
7
+ "Last-Translator: Michael Q Wang <admin@qqworld.org>\n"
8
+ "Language-Team: QQWorld <admin@qqworld.org>\n"
9
+ "Language: zh_CN\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=1; plural=0;\n"
14
+ "X-Generator: Poedit 1.6.1\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+
17
+ msgid "The action of using"
18
+ msgstr "使用的动作"
19
+
20
+ msgid "Save post (Publish, save draft or pedding review)."
21
+ msgstr "保存文章时(发布文章,保存草稿和提交审核)。"
22
+
23
+ msgid "Publish post only."
24
+ msgstr "仅发布文章时。"
qqworld-auto-save-images.php CHANGED
@@ -1,17 +1,84 @@
1
  <?php
2
  /*
3
  Plugin Name: QQWorld Auto Save Images
4
- Plugin URI: http://project.qqworld.org
5
  Description: Automatically keep the all remote picture to the local, and automatically set featured image. 自动保存远程图片到本地,自动设置特色图片,并且支持机器人采集软件从外部提交。
6
- Version: 1.1
7
- Author: QQWorld
8
- Author URI: http://project.qqworld.org
9
  */
10
 
11
  class QQWorld_auto_save_images {
 
12
  function __construct() {
13
- add_action('publish_post', array($this, 'fetch_images') );
 
 
 
 
 
14
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  function fetch_images($post_ID) {
16
  //Check to make sure function is not executed more than once on save
17
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
@@ -20,7 +87,7 @@ class QQWorld_auto_save_images {
20
  if ( !current_user_can('edit_post', $post_ID) )
21
  return;
22
 
23
- remove_action('publish_post', array($this, 'fetch_images') );
24
 
25
  $post=get_post($post_ID);
26
  $content=$post->post_content;
@@ -40,8 +107,9 @@ class QQWorld_auto_save_images {
40
  }
41
  //Replace the image in the post
42
  wp_update_post(array('ID' => $post_ID, 'post_content' => $content));
43
- add_action('publish_post', array($this, 'fetch_images') );
44
  }
 
45
  //save exterior images
46
  function save_images($image_url,$post_id,$i){
47
  $file=file_get_contents($image_url);
1
  <?php
2
  /*
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.2
7
+ Author: Michael Wang
8
+ Author URI: http://www.qqworld.org
9
  */
10
 
11
  class QQWorld_auto_save_images {
12
+ var $using_action;
13
  function __construct() {
14
+ $this->using_action = get_option('using_action', 'publish');
15
+ $this->add_actions();
16
+ add_action( 'plugins_loaded', array($this, 'load_language') );
17
+ add_action( 'admin_menu', array($this, 'admin_menu') );
18
+ add_action( 'admin_init', array($this, 'register_settings') );
19
+ add_filter( 'plugin_row_meta', array($this, 'registerPluginLinks'),10,2 );
20
  }
21
+
22
+ public function load_language() {
23
+ load_plugin_textdomain( 'qqworld_auto_save_images', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
24
+ }
25
+
26
+ function registerPluginLinks($links, $file) {
27
+ $base = plugin_basename(__FILE__);
28
+ if ($file == $base) {
29
+ $links[] = '<a href="' . menu_page_url( 'qqworld-auto-save-images', 0 ) . '">' . __('Settings') . '</a>';
30
+ }
31
+ return $links;
32
+ }
33
+
34
+ function admin_menu() {
35
+ add_submenu_page('options-general.php', 'QQWorld Auto Save Images', 'QQWorld Auto Save Images', 'manage_options', 'qqworld-auto-save-images', array($this, 'fn'));
36
+ }
37
+
38
+ function fn() {
39
+ ?>
40
+ <div class="wrap">
41
+ <h2><?php _e('QQWorld Auto Save Images'); ?></h2>
42
+ <?php if ($_GET['updated']=='true') { ?><div class="updated settings-error" id="setting-error-settings_updated"><p><strong><?php _e('Settings saved.'); ?></strong></p></div><?php }; ?>
43
+ <form action="options.php" method="post">
44
+ <?php settings_fields('qqworld_auto_save_images_settings'); ?>
45
+ <table class="form-table">
46
+ <tbody>
47
+ <tr valign="top">
48
+ <th scope="row"><label for="blogname"><?php _e('The action of using', 'qqworld_auto_save_images'); ?></label></th>
49
+ <td><fieldset>
50
+ <legend class="screen-reader-text"><span><?php _e('The action of using', 'qqworld_auto_save_images'); ?></span></legend>
51
+ <label for="save">
52
+ <input name="using_action" type="radio" id="save" value="save" <?php checked('save', $this->using_action); ?> />
53
+ <?php _e('Save post (Publish, save draft or pedding review).', 'qqworld_auto_save_images'); ?>
54
+ </label><br />
55
+ <label for="publish">
56
+ <input name="using_action" type="radio" id="publish" value="publish" <?php checked('publish', $this->using_action); ?> />
57
+ <?php _e('Publish post only.', 'qqworld_auto_save_images'); ?>
58
+ </label>
59
+ </fieldset></td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+ <p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button-primary" name="Submit" /></p>
64
+ </form>
65
+ <?php
66
+ }
67
+
68
+ function register_settings() {
69
+ register_setting('qqworld_auto_save_images_settings', 'using_action');
70
+ }
71
+
72
+ function add_actions() {
73
+ if ($this->using_action == 'publish') add_action('publish_post', array($this, 'fetch_images') );
74
+ elseif ($this->using_action == 'save') add_action('save_post', array($this, 'fetch_images') );
75
+ }
76
+
77
+ function remove_actions() {
78
+ if ($this->using_action == 'publish') remove_action('publish_post', array($this, 'fetch_images') );
79
+ elseif ($this->using_action == 'save') remove_action('save_post', array($this, 'fetch_images') );
80
+ }
81
+
82
  function fetch_images($post_ID) {
83
  //Check to make sure function is not executed more than once on save
84
  if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
87
  if ( !current_user_can('edit_post', $post_ID) )
88
  return;
89
 
90
+ $this->remove_actions();
91
 
92
  $post=get_post($post_ID);
93
  $content=$post->post_content;
107
  }
108
  //Replace the image in the post
109
  wp_update_post(array('ID' => $post_ID, 'post_content' => $content));
110
+ $this->add_actions();
111
  }
112
+
113
  //save exterior images
114
  function save_images($image_url,$post_id,$i){
115
  $file=file_get_contents($image_url);