@@ -8,28 +8,28 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | //if uninstall not called from WordPress exit |
11 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) |
|
11 | +if (!defined('WP_UNINSTALL_PLUGIN')) |
|
12 | 12 | exit(); |
13 | 13 | |
14 | 14 | $option_name = 'bm_max_execution_time'; |
15 | 15 | |
16 | -if ( ! is_multisite() ) { |
|
16 | +if (!is_multisite()) { |
|
17 | 17 | // For Single site |
18 | - delete_option( $option_name ); |
|
18 | + delete_option($option_name); |
|
19 | 19 | } else { |
20 | 20 | // For Multisite |
21 | 21 | global $wpdb; |
22 | 22 | |
23 | 23 | // For regular options. |
24 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
|
24 | + $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
|
25 | 25 | $original_blog_id = get_current_blog_id(); |
26 | 26 | |
27 | - foreach ( $blog_ids as $blog_id ) { |
|
28 | - switch_to_blog( $blog_id ); |
|
29 | - delete_option( $option_name ); |
|
27 | + foreach ($blog_ids as $blog_id) { |
|
28 | + switch_to_blog($blog_id); |
|
29 | + delete_option($option_name); |
|
30 | 30 | } |
31 | - switch_to_blog( $original_blog_id ); |
|
31 | + switch_to_blog($original_blog_id); |
|
32 | 32 | |
33 | 33 | // For site options. |
34 | - delete_site_option( $option_name ); |
|
34 | + delete_site_option($option_name); |
|
35 | 35 | } |
@@ -8,8 +8,9 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | //if uninstall not called from WordPress exit |
11 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) |
|
11 | +if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
12 | 12 | exit(); |
13 | +} |
|
13 | 14 | |
14 | 15 | $option_name = 'bm_max_execution_time'; |
15 | 16 |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 ); |
210 | 210 | } |
211 | 211 | |
212 | - /** |
|
213 | - * Add navigation menu. |
|
214 | - */ |
|
215 | - public function add_menu() { |
|
212 | + /** |
|
213 | + * Add navigation menu. |
|
214 | + */ |
|
215 | + public function add_menu() { |
|
216 | 216 | |
217 | 217 | $this->post_page = add_submenu_page( 'tools.php', __( 'Bulk Move' , 'bulk-move'), __( 'Bulk Move' , 'bulk-move'), 'edit_others_posts', self::POSTS_PAGE_SLUG, array( &$this, 'display_posts_page' ) ); |
218 | 218 | |
@@ -223,36 +223,36 @@ discard block |
||
223 | 223 | add_action( 'admin_print_scripts-' . $this->post_page, array( &$this, 'add_styles') ); |
224 | 224 | |
225 | 225 | // meta boxes |
226 | - add_action( "load-{$this->post_page}", array( &$this, 'add_move_posts_settings_panel' ) ); |
|
226 | + add_action( "load-{$this->post_page}", array( &$this, 'add_move_posts_settings_panel' ) ); |
|
227 | 227 | add_action( "add_meta_boxes_{$this->post_page}", array( &$this, 'add_move_posts_meta_boxes' ) ); |
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Add settings Panel for move posts page. |
|
232 | - * |
|
233 | - * @since 1.0 |
|
234 | - */ |
|
235 | - public function add_move_posts_settings_panel() { |
|
236 | - |
|
237 | - /** |
|
238 | - * Create the WP_Screen object using page handle. |
|
239 | - */ |
|
240 | - $this->move_posts_screen = WP_Screen::get( $this->post_page ); |
|
241 | - |
|
242 | - /** |
|
243 | - * Content specified inline. |
|
244 | - */ |
|
245 | - $this->move_posts_screen->add_help_tab( |
|
246 | - array( |
|
247 | - 'title' => __( 'About Plugin', 'bulk-move' ), |
|
248 | - 'id' => 'about_tab', |
|
249 | - 'content' => '<p>' . __( 'This plugin allows you to move posts in bulk from selected categories to another category', 'bulk-move' ) . '</p>', |
|
250 | - 'callback' => false, |
|
251 | - ) |
|
252 | - ); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Add settings Panel for move posts page. |
|
232 | + * |
|
233 | + * @since 1.0 |
|
234 | + */ |
|
235 | + public function add_move_posts_settings_panel() { |
|
236 | + |
|
237 | + /** |
|
238 | + * Create the WP_Screen object using page handle. |
|
239 | + */ |
|
240 | + $this->move_posts_screen = WP_Screen::get( $this->post_page ); |
|
241 | + |
|
242 | + /** |
|
243 | + * Content specified inline. |
|
244 | + */ |
|
245 | + $this->move_posts_screen->add_help_tab( |
|
246 | + array( |
|
247 | + 'title' => __( 'About Plugin', 'bulk-move' ), |
|
248 | + 'id' => 'about_tab', |
|
249 | + 'content' => '<p>' . __( 'This plugin allows you to move posts in bulk from selected categories to another category', 'bulk-move' ) . '</p>', |
|
250 | + 'callback' => false, |
|
251 | + ) |
|
252 | + ); |
|
253 | 253 | |
254 | 254 | // Add help sidebar |
255 | - $this->move_posts_screen->set_help_sidebar( |
|
255 | + $this->move_posts_screen->set_help_sidebar( |
|
256 | 256 | '<p><strong>' . __( 'More information', 'bulk-move' ) . '</strong></p>' . |
257 | 257 | '<p><a href = "http://sudarmuthu.com/wordpress/bulk-move">' . __( 'Plugin Homepage/support', 'bulk-move' ) . '</a></p>' . |
258 | 258 | '<p><a href = "http://sudarmuthu.com/blog">' . __( "Plugin author's blog", 'bulk-move' ) . '</a></p>' . |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | |
265 | 265 | /* Enqueue WordPress' script for handling the meta boxes */ |
266 | 266 | wp_enqueue_script( 'postbox' ); |
267 | - } |
|
267 | + } |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * Register meta boxes for move posts page. |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @return object The one true Bulk_Move Instance |
427 | 427 | */ |
428 | 428 | function BULK_MOVE() { |
429 | - return Bulk_Move::instance(); |
|
429 | + return Bulk_Move::instance(); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Get BULK_MOVE Running |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | |
40 | 40 | // Exit if accessed directly |
41 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
41 | +if (!defined('ABSPATH')) exit; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Main Plugin class for Bulk Move. |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return The one true BULK_MOVE |
105 | 105 | */ |
106 | 106 | public static function instance() { |
107 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Bulk_Move ) ) { |
|
107 | + if (!isset(self::$instance) && !(self::$instance instanceof Bulk_Move)) { |
|
108 | 108 | self::$instance = new Bulk_Move; |
109 | 109 | self::$instance->setup_paths(); |
110 | 110 | self::$instance->includes(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function __clone() { |
130 | 130 | // Cloning instances of the class is forbidden |
131 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-move' ), '1.2.0' ); |
|
131 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'bulk-move'), '1.2.0'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function __wakeup() { |
143 | 143 | // Unserializing instances of the class is forbidden |
144 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'bulk-move' ), '1.2.0' ); |
|
144 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'bulk-move'), '1.2.0'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | */ |
156 | 156 | private function setup_paths() { |
157 | 157 | // Plugin Folder Path |
158 | - self::$PLUGIN_DIR = plugin_dir_path( __FILE__ ); |
|
158 | + self::$PLUGIN_DIR = plugin_dir_path(__FILE__); |
|
159 | 159 | |
160 | 160 | // Plugin Folder URL |
161 | - self::$PLUGIN_URL = plugin_dir_url( __FILE__ ); |
|
161 | + self::$PLUGIN_URL = plugin_dir_url(__FILE__); |
|
162 | 162 | |
163 | 163 | // Plugin Root File |
164 | 164 | self::$PLUGIN_FILE = __FILE__; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @return void |
175 | 175 | */ |
176 | 176 | private function includes() { |
177 | - require_once self::$PLUGIN_DIR . '/include/class-bulk-move-posts.php'; |
|
178 | - require_once self::$PLUGIN_DIR . '/include/class-bulk-move-util.php'; |
|
177 | + require_once self::$PLUGIN_DIR.'/include/class-bulk-move-posts.php'; |
|
178 | + require_once self::$PLUGIN_DIR.'/include/class-bulk-move-util.php'; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function load_textdomain() { |
187 | 187 | // Load localization domain |
188 | - $this->translations = dirname( plugin_basename( self::$PLUGIN_FILE ) ) . '/languages/'; |
|
189 | - load_plugin_textdomain( 'bulk-move', false, $this->translations ); |
|
188 | + $this->translations = dirname(plugin_basename(self::$PLUGIN_FILE)).'/languages/'; |
|
189 | + load_plugin_textdomain('bulk-move', false, $this->translations); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | */ |
201 | 201 | private function setup_actions() { |
202 | 202 | // Register hooks |
203 | - add_action( 'admin_menu', array( &$this, 'add_menu' ) ); |
|
204 | - add_action( 'admin_init', array( &$this, 'request_handler' ) ); |
|
205 | - add_action( 'wp_ajax_load_custom_taxonomy_by_post_type', 'Bulk_Move_Posts::load_custom_taxonomy_by_post_type' ); |
|
206 | - add_action( 'wp_ajax_load_custom_terms_by_taxonomy', 'Bulk_Move_Posts::load_custom_terms_by_taxonomy' ); |
|
203 | + add_action('admin_menu', array(&$this, 'add_menu')); |
|
204 | + add_action('admin_init', array(&$this, 'request_handler')); |
|
205 | + add_action('wp_ajax_load_custom_taxonomy_by_post_type', 'Bulk_Move_Posts::load_custom_taxonomy_by_post_type'); |
|
206 | + add_action('wp_ajax_load_custom_terms_by_taxonomy', 'Bulk_Move_Posts::load_custom_terms_by_taxonomy'); |
|
207 | 207 | |
208 | 208 | // Add more links in the plugin listing page |
209 | - add_filter( 'plugin_action_links', array( &$this, 'filter_plugin_actions' ), 10, 2 ); |
|
209 | + add_filter('plugin_action_links', array(&$this, 'filter_plugin_actions'), 10, 2); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function add_menu() { |
216 | 216 | |
217 | - $this->post_page = add_submenu_page( 'tools.php', __( 'Bulk Move' , 'bulk-move'), __( 'Bulk Move' , 'bulk-move'), 'edit_others_posts', self::POSTS_PAGE_SLUG, array( &$this, 'display_posts_page' ) ); |
|
217 | + $this->post_page = add_submenu_page('tools.php', __('Bulk Move', 'bulk-move'), __('Bulk Move', 'bulk-move'), 'edit_others_posts', self::POSTS_PAGE_SLUG, array(&$this, 'display_posts_page')); |
|
218 | 218 | |
219 | 219 | // enqueue JavaScript |
220 | - add_action( 'admin_print_scripts-' . $this->post_page, array( &$this, 'add_script') ); |
|
220 | + add_action('admin_print_scripts-'.$this->post_page, array(&$this, 'add_script')); |
|
221 | 221 | |
222 | 222 | // enqueue CSS |
223 | - add_action( 'admin_print_scripts-' . $this->post_page, array( &$this, 'add_styles') ); |
|
223 | + add_action('admin_print_scripts-'.$this->post_page, array(&$this, 'add_styles')); |
|
224 | 224 | |
225 | 225 | // meta boxes |
226 | - add_action( "load-{$this->post_page}", array( &$this, 'add_move_posts_settings_panel' ) ); |
|
227 | - add_action( "add_meta_boxes_{$this->post_page}", array( &$this, 'add_move_posts_meta_boxes' ) ); |
|
226 | + add_action("load-{$this->post_page}", array(&$this, 'add_move_posts_settings_panel')); |
|
227 | + add_action("add_meta_boxes_{$this->post_page}", array(&$this, 'add_move_posts_meta_boxes')); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -237,33 +237,33 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * Create the WP_Screen object using page handle. |
239 | 239 | */ |
240 | - $this->move_posts_screen = WP_Screen::get( $this->post_page ); |
|
240 | + $this->move_posts_screen = WP_Screen::get($this->post_page); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * Content specified inline. |
244 | 244 | */ |
245 | 245 | $this->move_posts_screen->add_help_tab( |
246 | 246 | array( |
247 | - 'title' => __( 'About Plugin', 'bulk-move' ), |
|
247 | + 'title' => __('About Plugin', 'bulk-move'), |
|
248 | 248 | 'id' => 'about_tab', |
249 | - 'content' => '<p>' . __( 'This plugin allows you to move posts in bulk from selected categories to another category', 'bulk-move' ) . '</p>', |
|
249 | + 'content' => '<p>'.__('This plugin allows you to move posts in bulk from selected categories to another category', 'bulk-move').'</p>', |
|
250 | 250 | 'callback' => false, |
251 | 251 | ) |
252 | 252 | ); |
253 | 253 | |
254 | 254 | // Add help sidebar |
255 | 255 | $this->move_posts_screen->set_help_sidebar( |
256 | - '<p><strong>' . __( 'More information', 'bulk-move' ) . '</strong></p>' . |
|
257 | - '<p><a href = "http://sudarmuthu.com/wordpress/bulk-move">' . __( 'Plugin Homepage/support', 'bulk-move' ) . '</a></p>' . |
|
258 | - '<p><a href = "http://sudarmuthu.com/blog">' . __( "Plugin author's blog", 'bulk-move' ) . '</a></p>' . |
|
259 | - '<p><a href = "http://sudarmuthu.com/wordpress/">' . __( "Other Plugin's by Author", 'bulk-move' ) . '</a></p>' |
|
256 | + '<p><strong>'.__('More information', 'bulk-move').'</strong></p>'. |
|
257 | + '<p><a href = "http://sudarmuthu.com/wordpress/bulk-move">'.__('Plugin Homepage/support', 'bulk-move').'</a></p>'. |
|
258 | + '<p><a href = "http://sudarmuthu.com/blog">'.__("Plugin author's blog", 'bulk-move').'</a></p>'. |
|
259 | + '<p><a href = "http://sudarmuthu.com/wordpress/">'.__("Other Plugin's by Author", 'bulk-move').'</a></p>' |
|
260 | 260 | ); |
261 | 261 | |
262 | 262 | /* Trigger the add_meta_boxes hooks to allow meta boxes to be added */ |
263 | - do_action( 'add_meta_boxes_' . $this->post_page, null ); |
|
263 | + do_action('add_meta_boxes_'.$this->post_page, null); |
|
264 | 264 | |
265 | 265 | /* Enqueue WordPress' script for handling the meta boxes */ |
266 | - wp_enqueue_script( 'postbox' ); |
|
266 | + wp_enqueue_script('postbox'); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | * @since 1.0 |
273 | 273 | */ |
274 | 274 | public function add_move_posts_meta_boxes() { |
275 | - add_meta_box( self::BOX_CATEGORY, __( 'Bulk Move By Category', 'bulk-move' ), 'Bulk_Move_Posts::render_move_category_box', $this->post_page, 'advanced' ); |
|
276 | - add_meta_box( self::BOX_TAG, __( 'Bulk Move By Tag', 'bulk-move' ), 'Bulk_Move_Posts::render_move_tag_box', $this->post_page, 'advanced' ); |
|
277 | - add_meta_box( self::BOX_CATEGORY_BY_TAG, __( 'Bulk Move Category By Tag', 'bulk-move' ), 'Bulk_Move_Posts::render_move_category_by_tag_box', $this->post_page, 'advanced' ); |
|
278 | - add_meta_box( self::BOX_TERMS, __( 'Bulk Move By Custom Taxonomy', 'bulk-move' ), 'Bulk_Move_Posts::render_move_by_custom_taxonomy_box', $this->post_page, 'advanced' ); |
|
279 | - add_meta_box( self::BOX_DEBUG, __( 'Debug Information', 'bulk-move' ), 'Bulk_Move_Posts::render_debug_box', $this->post_page, 'advanced', 'low' ); |
|
275 | + add_meta_box(self::BOX_CATEGORY, __('Bulk Move By Category', 'bulk-move'), 'Bulk_Move_Posts::render_move_category_box', $this->post_page, 'advanced'); |
|
276 | + add_meta_box(self::BOX_TAG, __('Bulk Move By Tag', 'bulk-move'), 'Bulk_Move_Posts::render_move_tag_box', $this->post_page, 'advanced'); |
|
277 | + add_meta_box(self::BOX_CATEGORY_BY_TAG, __('Bulk Move Category By Tag', 'bulk-move'), 'Bulk_Move_Posts::render_move_category_by_tag_box', $this->post_page, 'advanced'); |
|
278 | + add_meta_box(self::BOX_TERMS, __('Bulk Move By Custom Taxonomy', 'bulk-move'), 'Bulk_Move_Posts::render_move_by_custom_taxonomy_box', $this->post_page, 'advanced'); |
|
279 | + add_meta_box(self::BOX_DEBUG, __('Debug Information', 'bulk-move'), 'Bulk_Move_Posts::render_debug_box', $this->post_page, 'advanced', 'low'); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,32 +285,32 @@ discard block |
||
285 | 285 | public function display_posts_page() { |
286 | 286 | ?> |
287 | 287 | <div class="wrap"> |
288 | - <h2><?php _e( 'Bulk Move Posts', 'bulk-move' );?></h2> |
|
288 | + <h2><?php _e('Bulk Move Posts', 'bulk-move'); ?></h2> |
|
289 | 289 | |
290 | 290 | <form method = "post"> |
291 | 291 | <?php |
292 | 292 | // nonce for bulk move |
293 | - wp_nonce_field( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ); |
|
293 | + wp_nonce_field('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce'); |
|
294 | 294 | |
295 | 295 | /* Used to save closed meta boxes and their order */ |
296 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
297 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
296 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
297 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
298 | 298 | ?> |
299 | 299 | <div id = "poststuff"> |
300 | 300 | <div id="post-body" class="metabox-holder columns-2"> |
301 | 301 | |
302 | 302 | <div id="post-body-content"> |
303 | 303 | <div class="updated" > |
304 | - <p><strong><?php _e( 'WARNING: Posts moved once cannot be retrieved back. Use with caution.', 'bulk-move' ); ?></strong></p> |
|
304 | + <p><strong><?php _e('WARNING: Posts moved once cannot be retrieved back. Use with caution.', 'bulk-move'); ?></strong></p> |
|
305 | 305 | </div> |
306 | 306 | </div><!-- #post-body-content --> |
307 | 307 | |
308 | 308 | <div id="postbox-container-1" class="postbox-container"> |
309 | - <iframe frameBorder="0" height = "1000" src = "http://sudarmuthu.com/projects/wordpress/bulk-move/sidebar.php?color=<?php echo get_user_option( 'admin_color' ); ?>&version=<?php echo self::VERSION; ?>"></iframe> |
|
309 | + <iframe frameBorder="0" height = "1000" src = "http://sudarmuthu.com/projects/wordpress/bulk-move/sidebar.php?color=<?php echo get_user_option('admin_color'); ?>&version=<?php echo self::VERSION; ?>"></iframe> |
|
310 | 310 | </div> |
311 | 311 | |
312 | 312 | <div id="postbox-container-2" class="postbox-container"> |
313 | - <?php do_meta_boxes( '', 'advanced', null ); ?> |
|
313 | + <?php do_meta_boxes('', 'advanced', null); ?> |
|
314 | 314 | </div> <!-- #postbox-container-2 --> |
315 | 315 | |
316 | 316 | </div> <!-- #post-body --> |
@@ -320,40 +320,40 @@ discard block |
||
320 | 320 | </div><!-- .wrap --> |
321 | 321 | <?php |
322 | 322 | // Display credits in Footer |
323 | - add_action( 'in_admin_footer', array( &$this, 'admin_footer' ) ); |
|
323 | + add_action('in_admin_footer', array(&$this, 'admin_footer')); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/. |
328 | 328 | */ |
329 | 329 | public function admin_footer() { |
330 | - $plugin_data = get_plugin_data( __FILE__ ); |
|
331 | - printf( '%1$s ' . __( 'plugin', 'bulk-move' ) . ' | ' . __( 'Version', 'bulk-move' ) . ' %2$s | ' . __( 'by', 'bulk-move' ) . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author'] ); |
|
330 | + $plugin_data = get_plugin_data(__FILE__); |
|
331 | + printf('%1$s '.__('plugin', 'bulk-move').' | '.__('Version', 'bulk-move').' %2$s | '.__('by', 'bulk-move').' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Enqueue JavaScript. |
336 | 336 | */ |
337 | 337 | public function add_script() { |
338 | - wp_enqueue_script( self::JS_HANDLE, plugins_url( '/js/bulk-move.js', __FILE__ ), array( 'jquery' ), self::VERSION, true ); |
|
338 | + wp_enqueue_script(self::JS_HANDLE, plugins_url('/js/bulk-move.js', __FILE__), array('jquery'), self::VERSION, true); |
|
339 | 339 | |
340 | 340 | // JavaScript messages |
341 | 341 | $msg = array( |
342 | - 'move_warning' => __( 'Are you sure you want to move all the selected posts', 'bulk-move' ), |
|
342 | + 'move_warning' => __('Are you sure you want to move all the selected posts', 'bulk-move'), |
|
343 | 343 | ); |
344 | 344 | |
345 | 345 | $error = array( |
346 | - 'select_one' => __( 'Please select least one option', 'bulk-move' ), |
|
346 | + 'select_one' => __('Please select least one option', 'bulk-move'), |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | $bulk_move_posts = array( |
350 | 350 | 'action_get_taxonomy' => 'load_custom_taxonomy_by_post_type', |
351 | 351 | 'action_get_terms' => 'load_custom_terms_by_taxonomy', |
352 | - 'security' => wp_create_nonce( self::BOX_CUSTOM_TERMS_NONCE ), |
|
352 | + 'security' => wp_create_nonce(self::BOX_CUSTOM_TERMS_NONCE), |
|
353 | 353 | ); |
354 | 354 | |
355 | - $translation_array = array( 'msg' => $msg, 'error' => $error, 'bulk_move_posts' => $bulk_move_posts ); |
|
356 | - wp_localize_script( self::JS_HANDLE, self::JS_VARIABLE, $translation_array ); |
|
355 | + $translation_array = array('msg' => $msg, 'error' => $error, 'bulk_move_posts' => $bulk_move_posts); |
|
356 | + wp_localize_script(self::JS_HANDLE, self::JS_VARIABLE, $translation_array); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @since 1.2.0 |
363 | 363 | */ |
364 | 364 | public function add_styles() { |
365 | - wp_enqueue_style( self::CSS_HANDLE, plugins_url( '/css/bulk-move.css', __FILE__ ), false, self::VERSION ); |
|
365 | + wp_enqueue_style(self::CSS_HANDLE, plugins_url('/css/bulk-move.css', __FILE__), false, self::VERSION); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -370,25 +370,25 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function request_handler() { |
372 | 372 | // controller |
373 | - if ( isset( $_POST['bm_action'] ) ) { |
|
374 | - do_action( 'bm_' . $_POST['bm_action'], $_POST ); |
|
373 | + if (isset($_POST['bm_action'])) { |
|
374 | + do_action('bm_'.$_POST['bm_action'], $_POST); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // hook the admin notices action |
378 | - add_action( 'admin_notices', array( &$this, 'moved_notice' ), 9 ); |
|
378 | + add_action('admin_notices', array(&$this, 'moved_notice'), 9); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
382 | 382 | * Show moved notice messages. |
383 | 383 | */ |
384 | 384 | public function moved_notice() { |
385 | - if ( isset( $this->msg ) && $this->msg != '' ) { |
|
386 | - echo "<div class = 'updated'><p>" . $this->msg . '</p></div>'; |
|
385 | + if (isset($this->msg) && $this->msg != '') { |
|
386 | + echo "<div class = 'updated'><p>".$this->msg.'</p></div>'; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // cleanup |
390 | 390 | $this->msg = ''; |
391 | - remove_action( 'admin_notices', array( &$this, 'moved_notice' ) ); |
|
391 | + remove_action('admin_notices', array(&$this, 'moved_notice')); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | * @param <type> $links |
400 | 400 | * @param <type> $file |
401 | 401 | */ |
402 | - public function filter_plugin_actions( $links, $file ) { |
|
402 | + public function filter_plugin_actions($links, $file) { |
|
403 | 403 | static $this_plugin; |
404 | - if( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ ); |
|
404 | + if (!$this_plugin) $this_plugin = plugin_basename(__FILE__); |
|
405 | 405 | |
406 | - if( $file == $this_plugin ) { |
|
407 | - $settings_link = '<a href="tools.php?page=' . self::POSTS_PAGE_SLUG . '">' . __( 'Manage', 'bulk-move' ) . '</a>'; |
|
408 | - array_unshift( $links, $settings_link ); // before other links |
|
406 | + if ($file == $this_plugin) { |
|
407 | + $settings_link = '<a href="tools.php?page='.self::POSTS_PAGE_SLUG.'">'.__('Manage', 'bulk-move').'</a>'; |
|
408 | + array_unshift($links, $settings_link); // before other links |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | return $links; |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | */ |
39 | 39 | |
40 | 40 | // Exit if accessed directly |
41 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
41 | +if ( ! defined( 'ABSPATH' ) ) { |
|
42 | + exit; |
|
43 | +} |
|
42 | 44 | |
43 | 45 | /** |
44 | 46 | * Main Plugin class for Bulk Move. |
@@ -401,7 +403,9 @@ discard block |
||
401 | 403 | */ |
402 | 404 | public function filter_plugin_actions( $links, $file ) { |
403 | 405 | static $this_plugin; |
404 | - if( ! $this_plugin ) $this_plugin = plugin_basename( __FILE__ ); |
|
406 | + if( ! $this_plugin ) { |
|
407 | + $this_plugin = plugin_basename( __FILE__ ); |
|
408 | + } |
|
405 | 409 | |
406 | 410 | if( $file == $this_plugin ) { |
407 | 411 | $settings_link = '<a href="tools.php?page=' . self::POSTS_PAGE_SLUG . '">' . __( 'Manage', 'bulk-move' ) . '</a>'; |
@@ -456,82 +456,82 @@ discard block |
||
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
459 | - /** |
|
460 | - * Loads the custom Taxonomy by Post Type. |
|
461 | - * |
|
462 | - * @since 1.3.0 |
|
463 | - */ |
|
464 | - public static function load_custom_taxonomy_by_post_type() { |
|
465 | - $bulk_move = BULK_MOVE(); |
|
466 | - check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
467 | - $post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : 'post'; |
|
468 | - |
|
469 | - $taxonomies = get_object_taxonomies( $post_type ); |
|
470 | - |
|
471 | - $args = array( |
|
472 | - 'taxonomy' => $taxonomies, |
|
473 | - 'hide_empty' => false, |
|
474 | - 'orderby' => 'name', |
|
475 | - ); |
|
476 | - |
|
477 | - ob_start(); |
|
459 | + /** |
|
460 | + * Loads the custom Taxonomy by Post Type. |
|
461 | + * |
|
462 | + * @since 1.3.0 |
|
463 | + */ |
|
464 | + public static function load_custom_taxonomy_by_post_type() { |
|
465 | + $bulk_move = BULK_MOVE(); |
|
466 | + check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
467 | + $post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : 'post'; |
|
468 | + |
|
469 | + $taxonomies = get_object_taxonomies( $post_type ); |
|
470 | + |
|
471 | + $args = array( |
|
472 | + 'taxonomy' => $taxonomies, |
|
473 | + 'hide_empty' => false, |
|
474 | + 'orderby' => 'name', |
|
475 | + ); |
|
476 | + |
|
477 | + ob_start(); |
|
478 | 478 | ?> |
479 | 479 | <option class="level-0" value="select"><?php _e( 'Select Taxonomy ', 'bulk-move' ); ?></option> |
480 | 480 | <?php |
481 | - foreach ( $taxonomies as $taxonomy ) : |
|
482 | - ?> |
|
481 | + foreach ( $taxonomies as $taxonomy ) : |
|
482 | + ?> |
|
483 | 483 | <option class="level-0" value="<?php echo $taxonomy; ?>"><?php echo $taxonomy; ?></option> |
484 | 484 | <?php |
485 | - endforeach; |
|
486 | - $data = ob_get_clean(); |
|
487 | - wp_send_json_success( $data ); |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Loads the custom Terms by Taxonomy. |
|
492 | - * |
|
493 | - * @since 1.3.0 |
|
494 | - */ |
|
495 | - public static function load_custom_terms_by_taxonomy() { |
|
496 | - $bulk_move = BULK_MOVE(); |
|
497 | - check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
498 | - $taxonomy = isset( $_POST['taxonomy'] ) ? sanitize_text_field( $_POST['taxonomy'] ) : 'category'; |
|
499 | - |
|
500 | - $args = array( |
|
501 | - 'taxonomy' => $taxonomy, |
|
502 | - 'hide_empty' => false, |
|
503 | - 'orderby' => 'name', |
|
504 | - ); |
|
505 | - $terms = get_terms( $args ); |
|
506 | - |
|
507 | - $select_term = '<option class="level-0" value="-1">' . __( 'Select Term ', '"bulk-move' ) . '</option>'; |
|
508 | - $map_term = '<option class="level-0" value="-1">' . __( 'Remove Term ', 'bullk-move' ) . '</option>'; |
|
509 | - ob_start(); |
|
510 | - foreach ( $terms as $term ) : |
|
511 | - ?> |
|
485 | + endforeach; |
|
486 | + $data = ob_get_clean(); |
|
487 | + wp_send_json_success( $data ); |
|
488 | + } |
|
489 | + |
|
490 | + /** |
|
491 | + * Loads the custom Terms by Taxonomy. |
|
492 | + * |
|
493 | + * @since 1.3.0 |
|
494 | + */ |
|
495 | + public static function load_custom_terms_by_taxonomy() { |
|
496 | + $bulk_move = BULK_MOVE(); |
|
497 | + check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
498 | + $taxonomy = isset( $_POST['taxonomy'] ) ? sanitize_text_field( $_POST['taxonomy'] ) : 'category'; |
|
499 | + |
|
500 | + $args = array( |
|
501 | + 'taxonomy' => $taxonomy, |
|
502 | + 'hide_empty' => false, |
|
503 | + 'orderby' => 'name', |
|
504 | + ); |
|
505 | + $terms = get_terms( $args ); |
|
506 | + |
|
507 | + $select_term = '<option class="level-0" value="-1">' . __( 'Select Term ', '"bulk-move' ) . '</option>'; |
|
508 | + $map_term = '<option class="level-0" value="-1">' . __( 'Remove Term ', 'bullk-move' ) . '</option>'; |
|
509 | + ob_start(); |
|
510 | + foreach ( $terms as $term ) : |
|
511 | + ?> |
|
512 | 512 | <option class="level-0" value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?> (<?php echo $term->count; ?>)</option> |
513 | 513 | <?php |
514 | - endforeach; |
|
515 | - $ob = ob_get_clean(); |
|
516 | - $select_term .= $ob; |
|
517 | - $map_term .= $ob; |
|
518 | - $data = array( 'select_term' => $select_term, 'map_term' => $map_term ); |
|
519 | - wp_send_json_success( $data ); |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Render move terms box. |
|
524 | - * |
|
525 | - * @since 1.3.0 |
|
526 | - */ |
|
527 | - public static function render_move_by_custom_taxonomy_box() { |
|
528 | - |
|
529 | - if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_CATEGORY ) ) { |
|
530 | - printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
531 | - |
|
532 | - return; |
|
533 | - } |
|
534 | - ?> |
|
514 | + endforeach; |
|
515 | + $ob = ob_get_clean(); |
|
516 | + $select_term .= $ob; |
|
517 | + $map_term .= $ob; |
|
518 | + $data = array( 'select_term' => $select_term, 'map_term' => $map_term ); |
|
519 | + wp_send_json_success( $data ); |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Render move terms box. |
|
524 | + * |
|
525 | + * @since 1.3.0 |
|
526 | + */ |
|
527 | + public static function render_move_by_custom_taxonomy_box() { |
|
528 | + |
|
529 | + if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_CATEGORY ) ) { |
|
530 | + printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
531 | + |
|
532 | + return; |
|
533 | + } |
|
534 | + ?> |
|
535 | 535 | <!-- Custom Taxonomy Start--> |
536 | 536 | <h4><?php _e( 'Select the post type to show its taxonomy. On the left side, select the term whose posts you want to move. On the right side select the term to which you want the posts to be moved.', 'bulk-move' ) ?></h4> |
537 | 537 | |
@@ -546,9 +546,9 @@ discard block |
||
546 | 546 | <tr> |
547 | 547 | <td scope="row" colspan="2"> |
548 | 548 | <?php |
549 | - $custom_post_types_args = array( '_builtin' => false ); |
|
550 | - $custom_post_types = get_post_types( $custom_post_types_args ); |
|
551 | - ?> |
|
549 | + $custom_post_types_args = array( '_builtin' => false ); |
|
550 | + $custom_post_types = get_post_types( $custom_post_types_args ); |
|
551 | + ?> |
|
552 | 552 | <?php if ( count( $custom_post_types ) === 0 ) : ?> |
553 | 553 | <p> |
554 | 554 | <span class="error-notice"><?php _e( 'You have no custom post type registered.', 'bulk-move' ); ?></span> |
@@ -612,63 +612,63 @@ discard block |
||
612 | 612 | </p> |
613 | 613 | <!-- Custom Taxonomy end--> |
614 | 614 | <?php |
615 | - } |
|
616 | - |
|
617 | - public static function move_custom_taxonomy() { |
|
618 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
619 | - |
|
620 | - do_action( 'bm_pre_request_handler' ); |
|
621 | - |
|
622 | - $wp_query = new WP_Query; |
|
623 | - $bm = BULK_MOVE(); |
|
624 | - |
|
625 | - // Move by terms. |
|
626 | - $old_cat = absint( $_POST['smbm_mbct_selected_term'] ); |
|
627 | - $taxonomy = $_POST['smbm_mbct_taxonomy']; |
|
628 | - $post_types = array( $_POST['smbm_mbct_post_type'] ); |
|
629 | - |
|
630 | - $new_cat = ( $_POST['smbm_mbct_mapped_term'] == -1 ) ? -1 : absint( $_POST['smbm_mbct_mapped_term'] ); |
|
631 | - |
|
632 | - $posts_count = 0 ; |
|
633 | - |
|
634 | - if ( $old_cat !== -1 ) { |
|
635 | - foreach ( $post_types as $post_type ) { |
|
636 | - $posts_args = array( |
|
637 | - 'tax_query' => array( |
|
638 | - array( |
|
639 | - 'taxonomy' => $taxonomy, |
|
640 | - 'field' => 'term_id', |
|
641 | - 'terms' => $old_cat, |
|
642 | - ), |
|
643 | - ), |
|
644 | - 'post_type' => $post_type, |
|
645 | - 'nopaging' => 'true', |
|
646 | - ); |
|
647 | - |
|
648 | - $posts = $wp_query->query( $posts_args ); |
|
649 | - $posts_count += count( $posts ); |
|
650 | - |
|
651 | - foreach ( $posts as $post ) { |
|
652 | - |
|
653 | - if ( $new_cat != -1 ) { |
|
654 | - if ( isset( $_POST['smbm_mbct_overwrite'] ) && 'overwrite' == $_POST['smbm_mbct_overwrite'] ) { |
|
655 | - // Remove old categories |
|
656 | - $is_append_terms = false; |
|
657 | - } else { |
|
658 | - // Add to existing categories |
|
659 | - $is_append_terms = true; |
|
660 | - } |
|
661 | - wp_set_object_terms( $post->ID, $new_cat, $taxonomy, $is_append_terms ); |
|
662 | - } else { |
|
663 | - wp_remove_object_terms( $post->ID, $old_cat, $taxonomy ); |
|
664 | - } |
|
665 | - } |
|
666 | - } |
|
667 | - } |
|
668 | - |
|
669 | - $bm->msg = sprintf( _n( 'Moved %d post from the selected category', 'Moved %d posts from the selected category' , $posts_count, 'bulk-move' ), $posts_count ); |
|
670 | - } |
|
671 | - } |
|
615 | + } |
|
616 | + |
|
617 | + public static function move_custom_taxonomy() { |
|
618 | + if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
619 | + |
|
620 | + do_action( 'bm_pre_request_handler' ); |
|
621 | + |
|
622 | + $wp_query = new WP_Query; |
|
623 | + $bm = BULK_MOVE(); |
|
624 | + |
|
625 | + // Move by terms. |
|
626 | + $old_cat = absint( $_POST['smbm_mbct_selected_term'] ); |
|
627 | + $taxonomy = $_POST['smbm_mbct_taxonomy']; |
|
628 | + $post_types = array( $_POST['smbm_mbct_post_type'] ); |
|
629 | + |
|
630 | + $new_cat = ( $_POST['smbm_mbct_mapped_term'] == -1 ) ? -1 : absint( $_POST['smbm_mbct_mapped_term'] ); |
|
631 | + |
|
632 | + $posts_count = 0 ; |
|
633 | + |
|
634 | + if ( $old_cat !== -1 ) { |
|
635 | + foreach ( $post_types as $post_type ) { |
|
636 | + $posts_args = array( |
|
637 | + 'tax_query' => array( |
|
638 | + array( |
|
639 | + 'taxonomy' => $taxonomy, |
|
640 | + 'field' => 'term_id', |
|
641 | + 'terms' => $old_cat, |
|
642 | + ), |
|
643 | + ), |
|
644 | + 'post_type' => $post_type, |
|
645 | + 'nopaging' => 'true', |
|
646 | + ); |
|
647 | + |
|
648 | + $posts = $wp_query->query( $posts_args ); |
|
649 | + $posts_count += count( $posts ); |
|
650 | + |
|
651 | + foreach ( $posts as $post ) { |
|
652 | + |
|
653 | + if ( $new_cat != -1 ) { |
|
654 | + if ( isset( $_POST['smbm_mbct_overwrite'] ) && 'overwrite' == $_POST['smbm_mbct_overwrite'] ) { |
|
655 | + // Remove old categories |
|
656 | + $is_append_terms = false; |
|
657 | + } else { |
|
658 | + // Add to existing categories |
|
659 | + $is_append_terms = true; |
|
660 | + } |
|
661 | + wp_set_object_terms( $post->ID, $new_cat, $taxonomy, $is_append_terms ); |
|
662 | + } else { |
|
663 | + wp_remove_object_terms( $post->ID, $old_cat, $taxonomy ); |
|
664 | + } |
|
665 | + } |
|
666 | + } |
|
667 | + } |
|
668 | + |
|
669 | + $bm->msg = sprintf( _n( 'Moved %d post from the selected category', 'Moved %d posts from the selected category' , $posts_count, 'bulk-move' ), $posts_count ); |
|
670 | + } |
|
671 | + } |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | // Hooks |
@@ -15,54 +15,54 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public static function render_move_category_box() { |
17 | 17 | |
18 | - if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_CATEGORY ) ) { |
|
19 | - printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
18 | + if (Bulk_Move_Util::is_posts_box_hidden(Bulk_Move::BOX_CATEGORY)) { |
|
19 | + printf(__('This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move'), 'tools.php?page='.Bulk_Move::POSTS_PAGE_SLUG); |
|
20 | 20 | |
21 | 21 | return; |
22 | 22 | } |
23 | 23 | ?> |
24 | 24 | <!-- Category Start--> |
25 | - <h4><?php _e( 'On the left side, select the category whose post you want to move. In the right side select the category to which you want the posts to be moved.', 'bulk-move' ) ?></h4> |
|
25 | + <h4><?php _e('On the left side, select the category whose post you want to move. In the right side select the category to which you want the posts to be moved.', 'bulk-move') ?></h4> |
|
26 | 26 | |
27 | 27 | <fieldset class="options"> |
28 | 28 | <table class="optiontable"> |
29 | 29 | <tr> |
30 | 30 | <td scope="row" > |
31 | 31 | <?php |
32 | - wp_dropdown_categories( array( |
|
32 | + wp_dropdown_categories(array( |
|
33 | 33 | 'name' => 'smbm_mc_selected_cat', |
34 | 34 | 'show_count' => true, |
35 | 35 | 'hierarchical' => true, |
36 | 36 | 'orderby' => 'NAME', |
37 | 37 | 'hide_empty' => false, |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | ?> |
40 | 40 | ==> |
41 | 41 | </td> |
42 | 42 | <td scope="row" > |
43 | 43 | <?php |
44 | - wp_dropdown_categories( array( |
|
44 | + wp_dropdown_categories(array( |
|
45 | 45 | 'name' => 'smbm_mc_mapped_cat', |
46 | 46 | 'show_count' => true, |
47 | 47 | 'hierarchical' => true, |
48 | 48 | 'orderby' => 'NAME', |
49 | 49 | 'hide_empty' => false, |
50 | - 'show_option_none' => __( 'Remove Category', 'bulk-move' ), |
|
51 | - ) ); |
|
50 | + 'show_option_none' => __('Remove Category', 'bulk-move'), |
|
51 | + )); |
|
52 | 52 | ?> |
53 | 53 | </td> |
54 | 54 | </tr> |
55 | 55 | |
56 | 56 | </table> |
57 | 57 | <p> |
58 | - <?php _e( 'If the post contains other categories, then', 'bulk-move' ); ?> |
|
59 | - <input type="radio" name="smbm_mc_overwrite" value="overwrite" checked><?php _e( 'Remove them', 'bulk-move' ); ?> |
|
60 | - <input type="radio" name="smbm_mc_overwrite" value="no-overwrite"><?php _e( "Don't remove them", 'bulk-move' ); ?> |
|
58 | + <?php _e('If the post contains other categories, then', 'bulk-move'); ?> |
|
59 | + <input type="radio" name="smbm_mc_overwrite" value="overwrite" checked><?php _e('Remove them', 'bulk-move'); ?> |
|
60 | + <input type="radio" name="smbm_mc_overwrite" value="no-overwrite"><?php _e("Don't remove them", 'bulk-move'); ?> |
|
61 | 61 | </p> |
62 | 62 | |
63 | 63 | </fieldset> |
64 | 64 | <p class="submit"> |
65 | - <button type="submit" name="bm_action" value="move_cats" class="button-primary"><?php _e( 'Bulk Move ', 'bulk-move' ) ?>»</button> |
|
65 | + <button type="submit" name="bm_action" value="move_cats" class="button-primary"><?php _e('Bulk Move ', 'bulk-move') ?>»</button> |
|
66 | 66 | </p> |
67 | 67 | <!-- Category end--> |
68 | 68 | <?php |
@@ -77,47 +77,47 @@ discard block |
||
77 | 77 | * @since 1.2.0 |
78 | 78 | */ |
79 | 79 | public static function move_cats() { |
80 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
80 | + if (check_admin_referer('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce')) { |
|
81 | 81 | |
82 | - do_action( 'bm_pre_request_handler' ); |
|
82 | + do_action('bm_pre_request_handler'); |
|
83 | 83 | |
84 | 84 | $wp_query = new WP_Query; |
85 | 85 | $bm = BULK_MOVE(); |
86 | 86 | |
87 | 87 | // move by cats |
88 | - $old_cat = absint( $_POST['smbm_mc_selected_cat'] ); |
|
89 | - $new_cat = ( $_POST['smbm_mc_mapped_cat'] == -1 ) ? -1 : absint( $_POST['smbm_mc_mapped_cat'] ); |
|
88 | + $old_cat = absint($_POST['smbm_mc_selected_cat']); |
|
89 | + $new_cat = ($_POST['smbm_mc_mapped_cat'] == -1) ? -1 : absint($_POST['smbm_mc_mapped_cat']); |
|
90 | 90 | |
91 | 91 | $posts = $wp_query->query(array( |
92 | - 'category__in' => array( $old_cat ), |
|
92 | + 'category__in' => array($old_cat), |
|
93 | 93 | 'post_type' => 'post', |
94 | 94 | 'nopaging' => 'true', |
95 | - ) ); |
|
95 | + )); |
|
96 | 96 | |
97 | - foreach ( $posts as $post ) { |
|
98 | - $current_cats = array_diff( wp_get_post_categories( $post->ID ), array( $old_cat ) ); |
|
97 | + foreach ($posts as $post) { |
|
98 | + $current_cats = array_diff(wp_get_post_categories($post->ID), array($old_cat)); |
|
99 | 99 | |
100 | - if ( $new_cat != -1 ) { |
|
101 | - if ( isset( $_POST['smbm_mc_overwrite'] ) && 'overwrite' == $_POST['smbm_mc_overwrite'] ) { |
|
100 | + if ($new_cat != -1) { |
|
101 | + if (isset($_POST['smbm_mc_overwrite']) && 'overwrite' == $_POST['smbm_mc_overwrite']) { |
|
102 | 102 | // Remove old categories |
103 | - $current_cats = array( $new_cat ); |
|
103 | + $current_cats = array($new_cat); |
|
104 | 104 | } else { |
105 | 105 | // Add to existing categories |
106 | 106 | $current_cats[] = $new_cat; |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - if ( count( $current_cats ) == 0 ) { |
|
111 | - $current_cats = array( get_option( 'default_category' ) ); |
|
110 | + if (count($current_cats) == 0) { |
|
111 | + $current_cats = array(get_option('default_category')); |
|
112 | 112 | } |
113 | - $current_cats = array_values( $current_cats ); |
|
113 | + $current_cats = array_values($current_cats); |
|
114 | 114 | wp_update_post(array( |
115 | 115 | 'ID' => $post->ID, |
116 | 116 | 'post_category' => $current_cats, |
117 | - ) ); |
|
117 | + )); |
|
118 | 118 | } |
119 | 119 | |
120 | - $bm->msg = sprintf( _n( 'Moved %d post from the selected category', 'Moved %d posts from the selected category' , count( $posts ), 'bulk-move' ), count( $posts ) ); |
|
120 | + $bm->msg = sprintf(_n('Moved %d post from the selected category', 'Moved %d posts from the selected category', count($posts), 'bulk-move'), count($posts)); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public static function render_move_tag_box() { |
132 | 132 | |
133 | - if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_TAG ) ) { |
|
134 | - printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
133 | + if (Bulk_Move_Util::is_posts_box_hidden(Bulk_Move::BOX_TAG)) { |
|
134 | + printf(__('This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move'), 'tools.php?page='.Bulk_Move::POSTS_PAGE_SLUG); |
|
135 | 135 | |
136 | 136 | return; |
137 | 137 | } |
138 | 138 | ?> |
139 | 139 | <!-- Tag Start--> |
140 | - <h4><?php _e( 'On the left side, select the tag whose post you want to move. In the right side select the tag to which you want the posts to be moved.', 'bulk-move' ) ?></h4> |
|
140 | + <h4><?php _e('On the left side, select the tag whose post you want to move. In the right side select the tag to which you want the posts to be moved.', 'bulk-move') ?></h4> |
|
141 | 141 | |
142 | 142 | <fieldset class="options"> |
143 | 143 | <table class="optiontable"> |
@@ -145,11 +145,11 @@ discard block |
||
145 | 145 | <td scope="row" > |
146 | 146 | <select name="smbm_mt_old_tag"> |
147 | 147 | <?php |
148 | - $tags = get_tags( array( 'hide_empty' => false ) ); |
|
149 | - foreach ( $tags as $tag ) { |
|
148 | + $tags = get_tags(array('hide_empty' => false)); |
|
149 | + foreach ($tags as $tag) { |
|
150 | 150 | ?> |
151 | 151 | <option value="<?php echo $tag->term_id; ?>"> |
152 | - <?php echo $tag->name; ?> (<?php echo $tag->count . ' '; _e( 'Posts', 'bulk-move' ); ?>) |
|
152 | + <?php echo $tag->name; ?> (<?php echo $tag->count.' '; _e('Posts', 'bulk-move'); ?>) |
|
153 | 153 | </option> |
154 | 154 | <?php |
155 | 155 | } |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | </td> |
160 | 160 | <td scope="row" > |
161 | 161 | <select name="smbm_mt_new_tag"> |
162 | - <option value="-1"><?php _e( 'Remove Tag', 'bulk-move' ); ?></option> |
|
162 | + <option value="-1"><?php _e('Remove Tag', 'bulk-move'); ?></option> |
|
163 | 163 | <?php |
164 | 164 | foreach ($tags as $tag) { |
165 | 165 | ?> |
166 | 166 | <option value="<?php echo $tag->term_id; ?>"> |
167 | - <?php echo $tag->name; ?> (<?php echo $tag->count . ' '; _e( 'Posts', 'bulk-move' ); ?>) |
|
167 | + <?php echo $tag->name; ?> (<?php echo $tag->count.' '; _e('Posts', 'bulk-move'); ?>) |
|
168 | 168 | </option> |
169 | 169 | <?php |
170 | 170 | } |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | |
176 | 176 | </table> |
177 | 177 | <p> |
178 | - <?php _e( 'If the post contains other tags, then', 'bulk-move' ); ?> |
|
179 | - <input type="radio" name="smbm_mt_overwrite" value="overwrite" checked><?php _e( 'Remove them', 'bulk-move' ); ?> |
|
180 | - <input type="radio" name="smbm_mt_overwrite" value="no-overwrite"><?php _e( "Don't remove them", 'bulk-move' ); ?> |
|
178 | + <?php _e('If the post contains other tags, then', 'bulk-move'); ?> |
|
179 | + <input type="radio" name="smbm_mt_overwrite" value="overwrite" checked><?php _e('Remove them', 'bulk-move'); ?> |
|
180 | + <input type="radio" name="smbm_mt_overwrite" value="no-overwrite"><?php _e("Don't remove them", 'bulk-move'); ?> |
|
181 | 181 | </p> |
182 | 182 | </fieldset> |
183 | 183 | <p class="submit"> |
184 | - <button type="submit" name="bm_action" value="move_tags" class="button-primary"><?php _e( 'Bulk Move ', 'bulk-move' ) ?>»</button> |
|
184 | + <button type="submit" name="bm_action" value="move_tags" class="button-primary"><?php _e('Bulk Move ', 'bulk-move') ?>»</button> |
|
185 | 185 | </p> |
186 | 186 | <!-- Tag end--> |
187 | 187 | <?php |
@@ -197,42 +197,42 @@ discard block |
||
197 | 197 | */ |
198 | 198 | public static function move_tags() { |
199 | 199 | |
200 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
200 | + if (check_admin_referer('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce')) { |
|
201 | 201 | |
202 | - do_action( 'bm_pre_request_handler' ); |
|
202 | + do_action('bm_pre_request_handler'); |
|
203 | 203 | |
204 | 204 | $wp_query = new WP_Query; |
205 | 205 | $bm = BULK_MOVE(); |
206 | 206 | |
207 | 207 | // move by tags |
208 | - $old_tag = absint( $_POST['smbm_mt_old_tag'] ); |
|
209 | - $new_tag = ( $_POST['smbm_mt_new_tag'] == -1 ) ? -1 : absint( $_POST['smbm_mt_new_tag'] ); |
|
208 | + $old_tag = absint($_POST['smbm_mt_old_tag']); |
|
209 | + $new_tag = ($_POST['smbm_mt_new_tag'] == -1) ? -1 : absint($_POST['smbm_mt_new_tag']); |
|
210 | 210 | |
211 | - $posts = $wp_query->query( array( |
|
211 | + $posts = $wp_query->query(array( |
|
212 | 212 | 'tag__in' => $old_tag, |
213 | 213 | 'post_type' => 'post', |
214 | 214 | 'nopaging' => 'true', |
215 | 215 | )); |
216 | 216 | |
217 | - foreach ( $posts as $post ) { |
|
218 | - $current_tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) ); |
|
219 | - $current_tags = array_diff( $current_tags, array( $old_tag ) ); |
|
217 | + foreach ($posts as $post) { |
|
218 | + $current_tags = wp_get_post_tags($post->ID, array('fields' => 'ids')); |
|
219 | + $current_tags = array_diff($current_tags, array($old_tag)); |
|
220 | 220 | |
221 | - if ( $new_tag != -1 ) { |
|
222 | - if ( isset( $_POST['smbm_mt_overwrite'] ) && 'overwrite' == $_POST['smbm_mt_overwrite'] ) { |
|
221 | + if ($new_tag != -1) { |
|
222 | + if (isset($_POST['smbm_mt_overwrite']) && 'overwrite' == $_POST['smbm_mt_overwrite']) { |
|
223 | 223 | // Remove old tags |
224 | - $current_tags = array( $new_tag ); |
|
224 | + $current_tags = array($new_tag); |
|
225 | 225 | } else { |
226 | 226 | // add to existing tags |
227 | 227 | $current_tags[] = $new_tag; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - $current_tags = array_values( $current_tags ); |
|
232 | - wp_set_post_tags( $post->ID, $current_tags ); |
|
231 | + $current_tags = array_values($current_tags); |
|
232 | + wp_set_post_tags($post->ID, $current_tags); |
|
233 | 233 | } |
234 | 234 | |
235 | - $bm->msg = sprintf( _n( 'Moved %d post from the selected tag', 'Moved %d posts from the selected tag' , count( $posts ), 'bulk-move' ), count( $posts ) ); |
|
235 | + $bm->msg = sprintf(_n('Moved %d post from the selected tag', 'Moved %d posts from the selected tag', count($posts), 'bulk-move'), count($posts)); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
@@ -245,14 +245,14 @@ discard block |
||
245 | 245 | */ |
246 | 246 | public static function render_move_category_by_tag_box() { |
247 | 247 | |
248 | - if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_CATEGORY_BY_TAG ) ) { |
|
249 | - printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
248 | + if (Bulk_Move_Util::is_posts_box_hidden(Bulk_Move::BOX_CATEGORY_BY_TAG)) { |
|
249 | + printf(__('This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move'), 'tools.php?page='.Bulk_Move::POSTS_PAGE_SLUG); |
|
250 | 250 | |
251 | 251 | return; |
252 | 252 | } |
253 | 253 | ?> |
254 | 254 | <!-- Tag Start--> |
255 | - <h4><?php _e( 'On the left side, select the tag whose post you want to move. In the right side select the category to which you want the posts to be moved.', 'bulk-move' ) ?></h4> |
|
255 | + <h4><?php _e('On the left side, select the tag whose post you want to move. In the right side select the category to which you want the posts to be moved.', 'bulk-move') ?></h4> |
|
256 | 256 | |
257 | 257 | <fieldset class="options"> |
258 | 258 | <table class="optiontable"> |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | <td scope="row" > |
261 | 261 | <select name="smbm_mct_old_tag"> |
262 | 262 | <?php |
263 | - $tags = get_tags( array( 'hide_empty' => false ) ); |
|
264 | - foreach ( $tags as $tag ) { |
|
263 | + $tags = get_tags(array('hide_empty' => false)); |
|
264 | + foreach ($tags as $tag) { |
|
265 | 265 | ?> |
266 | 266 | <option value="<?php echo $tag->term_id; ?>"> |
267 | - <?php echo $tag->name; ?> (<?php echo $tag->count . ' '; _e( 'Posts', 'bulk-move' ); ?>) |
|
267 | + <?php echo $tag->name; ?> (<?php echo $tag->count.' '; _e('Posts', 'bulk-move'); ?>) |
|
268 | 268 | </option> |
269 | 269 | <?php |
270 | 270 | } |
@@ -274,27 +274,27 @@ discard block |
||
274 | 274 | </td> |
275 | 275 | <td scope="row" > |
276 | 276 | <?php |
277 | - wp_dropdown_categories( array( |
|
277 | + wp_dropdown_categories(array( |
|
278 | 278 | 'name' => 'smbm_mct_mapped_cat', |
279 | 279 | 'show_count' => true, |
280 | 280 | 'hierarchical' => true, |
281 | 281 | 'orderby' => 'NAME', |
282 | 282 | 'hide_empty' => false, |
283 | - 'show_option_none' => __( 'Choose Category', 'bulk-move' ), |
|
284 | - ) ); |
|
283 | + 'show_option_none' => __('Choose Category', 'bulk-move'), |
|
284 | + )); |
|
285 | 285 | ?> |
286 | 286 | </td> |
287 | 287 | </tr> |
288 | 288 | |
289 | 289 | </table> |
290 | 290 | <p> |
291 | - <?php _e( 'If the post contains other categories, then', 'bulk-move' ); ?> |
|
292 | - <input type="radio" name="smbm_mct_overwrite" value="overwrite" checked><?php _e( 'Remove them', 'bulk-move' ); ?> |
|
293 | - <input type="radio" name="smbm_mct_overwrite" value="no-overwrite"><?php _e( "Don't remove them", 'bulk-move' ); ?> |
|
291 | + <?php _e('If the post contains other categories, then', 'bulk-move'); ?> |
|
292 | + <input type="radio" name="smbm_mct_overwrite" value="overwrite" checked><?php _e('Remove them', 'bulk-move'); ?> |
|
293 | + <input type="radio" name="smbm_mct_overwrite" value="no-overwrite"><?php _e("Don't remove them", 'bulk-move'); ?> |
|
294 | 294 | </p> |
295 | 295 | </fieldset> |
296 | 296 | <p class="submit"> |
297 | - <button type="submit" name="bm_action" value="move_category_by_tag" class="button-primary"><?php _e( 'Bulk Move ', 'bulk-move' ) ?>»</button> |
|
297 | + <button type="submit" name="bm_action" value="move_category_by_tag" class="button-primary"><?php _e('Bulk Move ', 'bulk-move') ?>»</button> |
|
298 | 298 | </p> |
299 | 299 | <!-- Tag end--> |
300 | 300 | <?php |
@@ -310,47 +310,47 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public static function move_category_by_tag() { |
312 | 312 | |
313 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
313 | + if (check_admin_referer('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce')) { |
|
314 | 314 | |
315 | - do_action( 'bm_pre_request_handler' ); |
|
315 | + do_action('bm_pre_request_handler'); |
|
316 | 316 | |
317 | 317 | $wp_query = new WP_Query; |
318 | 318 | $bm = BULK_MOVE(); |
319 | 319 | |
320 | 320 | // move by tags |
321 | - $old_tag = absint( $_POST['smbm_mct_old_tag'] ); |
|
322 | - $new_cat = ( $_POST['smbm_mct_mapped_cat'] == -1 ) ? -1 : absint( $_POST['smbm_mct_mapped_cat'] ); |
|
321 | + $old_tag = absint($_POST['smbm_mct_old_tag']); |
|
322 | + $new_cat = ($_POST['smbm_mct_mapped_cat'] == -1) ? -1 : absint($_POST['smbm_mct_mapped_cat']); |
|
323 | 323 | |
324 | - $posts = $wp_query->query( array( |
|
324 | + $posts = $wp_query->query(array( |
|
325 | 325 | 'tag__in' => $old_tag, |
326 | 326 | 'post_type' => 'post', |
327 | 327 | 'nopaging' => 'true', |
328 | 328 | )); |
329 | 329 | |
330 | - foreach ( $posts as $post ) { |
|
331 | - $current_cats = wp_get_post_categories( $post->ID ); |
|
330 | + foreach ($posts as $post) { |
|
331 | + $current_cats = wp_get_post_categories($post->ID); |
|
332 | 332 | |
333 | - if ( $new_cat != -1 ) { |
|
334 | - if ( isset( $_POST['smbm_mct_overwrite'] ) && 'overwrite' == $_POST['smbm_mct_overwrite'] ) { |
|
333 | + if ($new_cat != -1) { |
|
334 | + if (isset($_POST['smbm_mct_overwrite']) && 'overwrite' == $_POST['smbm_mct_overwrite']) { |
|
335 | 335 | // Remove old categories |
336 | - $current_cats = array( $new_cat ); |
|
336 | + $current_cats = array($new_cat); |
|
337 | 337 | } else { |
338 | 338 | // Add to existing categories |
339 | 339 | $current_cats[] = $new_cat; |
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - if ( count( $current_cats ) == 0) { |
|
344 | - $current_cats = array( get_option( 'default_category' ) ); |
|
343 | + if (count($current_cats) == 0) { |
|
344 | + $current_cats = array(get_option('default_category')); |
|
345 | 345 | } |
346 | - $current_cats = array_values( $current_cats ); |
|
347 | - wp_update_post( array( |
|
346 | + $current_cats = array_values($current_cats); |
|
347 | + wp_update_post(array( |
|
348 | 348 | 'ID' => $post->ID, |
349 | 349 | 'post_category' => $current_cats, |
350 | - ) ); |
|
350 | + )); |
|
351 | 351 | } |
352 | 352 | |
353 | - $bm->msg = sprintf( _n( 'Moved %d post from the selected tag to the new category.', 'Moved %d posts from the selected tag to the new category.' , count( $posts ), 'bulk-move' ), count( $posts ) ); |
|
353 | + $bm->msg = sprintf(_n('Moved %d post from the selected tag to the new category.', 'Moved %d posts from the selected tag to the new category.', count($posts), 'bulk-move'), count($posts)); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | /** |
@@ -364,45 +364,45 @@ discard block |
||
364 | 364 | public static function render_debug_box() { |
365 | 365 | |
366 | 366 | // Get max script execution time from option. |
367 | - $max_execution_time = get_option( Bulk_Move::SCRIPT_TIMEOUT_OPTION ); |
|
368 | - if ( ! $max_execution_time ) { |
|
367 | + $max_execution_time = get_option(Bulk_Move::SCRIPT_TIMEOUT_OPTION); |
|
368 | + if (!$max_execution_time) { |
|
369 | 369 | $max_execution_time = ''; |
370 | 370 | } |
371 | 371 | ?> |
372 | 372 | <!-- Debug box start--> |
373 | 373 | <p> |
374 | - <?php _e( 'If you are seeing a blank page after clicking the Bulk Move button, then ', 'bulk-move' ); ?> |
|
375 | - <a href = "http://sudarmuthu.com/wordpress/bulk-move#faq"><?php _e( 'check out this FAQ', 'bulk-move' );?></a>. |
|
376 | - <?php _e( 'You also need need the following debug information.', 'bulk-move' ); ?> |
|
374 | + <?php _e('If you are seeing a blank page after clicking the Bulk Move button, then ', 'bulk-move'); ?> |
|
375 | + <a href = "http://sudarmuthu.com/wordpress/bulk-move#faq"><?php _e('check out this FAQ', 'bulk-move'); ?></a>. |
|
376 | + <?php _e('You also need need the following debug information.', 'bulk-move'); ?> |
|
377 | 377 | </p> |
378 | 378 | <table cellspacing="10"> |
379 | 379 | <tr> |
380 | - <th align="right"><?php _e( 'PHP Version ', 'bulk-move' ); ?></th> |
|
380 | + <th align="right"><?php _e('PHP Version ', 'bulk-move'); ?></th> |
|
381 | 381 | <td><?php echo phpversion(); ?></td> |
382 | 382 | </tr> |
383 | 383 | <tr> |
384 | - <th align="right"><?php _e( 'WordPress Version ', 'bulk-move' ); ?></th> |
|
385 | - <td><?php echo get_bloginfo( 'version' ); ?></td> |
|
384 | + <th align="right"><?php _e('WordPress Version ', 'bulk-move'); ?></th> |
|
385 | + <td><?php echo get_bloginfo('version'); ?></td> |
|
386 | 386 | </tr> |
387 | 387 | <tr> |
388 | - <th align="right"><?php _e( 'Plugin Version ', 'bulk-move' ); ?></th> |
|
388 | + <th align="right"><?php _e('Plugin Version ', 'bulk-move'); ?></th> |
|
389 | 389 | <td><?php echo Bulk_Move::VERSION; ?></td> |
390 | 390 | </tr> |
391 | 391 | <tr> |
392 | - <th align="right"><?php _e( 'Available memory size ', 'bulk-move' );?></th> |
|
393 | - <td><?php echo ini_get( 'memory_limit' ); ?></td> |
|
392 | + <th align="right"><?php _e('Available memory size ', 'bulk-move'); ?></th> |
|
393 | + <td><?php echo ini_get('memory_limit'); ?></td> |
|
394 | 394 | </tr> |
395 | 395 | <tr> |
396 | - <th align="right"><?php _e( 'Script time out ', 'bulk-move' );?></th> |
|
397 | - <td><strong><?php echo ini_get( 'max_execution_time' );?></strong> (<?php _e( 'In php.ini', 'bulk-move' );?>). <?php _e( 'Custom value: ', 'bulk-move' );?><input type="text" id="smbm_max_execution_time" name="smbm_max_execution_time" value="<?php echo $max_execution_time; ?>" > <button type="submit" name="bm_action" value="save_timeout" class="button-primary"><?php _e( 'Save', 'bulk-move' ) ?> »</button></td> |
|
396 | + <th align="right"><?php _e('Script time out ', 'bulk-move'); ?></th> |
|
397 | + <td><strong><?php echo ini_get('max_execution_time'); ?></strong> (<?php _e('In php.ini', 'bulk-move'); ?>). <?php _e('Custom value: ', 'bulk-move'); ?><input type="text" id="smbm_max_execution_time" name="smbm_max_execution_time" value="<?php echo $max_execution_time; ?>" > <button type="submit" name="bm_action" value="save_timeout" class="button-primary"><?php _e('Save', 'bulk-move') ?> »</button></td> |
|
398 | 398 | </tr> |
399 | 399 | <tr> |
400 | - <th align="right"><?php _e( 'Script input time ', 'bulk-move' ); ?></th> |
|
401 | - <td><?php echo ini_get( 'max_input_time' ); ?></td> |
|
400 | + <th align="right"><?php _e('Script input time ', 'bulk-move'); ?></th> |
|
401 | + <td><?php echo ini_get('max_input_time'); ?></td> |
|
402 | 402 | </tr> |
403 | 403 | </table> |
404 | 404 | |
405 | - <p><em><?php _e( 'If you are looking to delete posts in bulk, try out my ', 'bulk-move' ); ?> <a href = "http://sudarmuthu.com/wordpress/bulk-delete"><?php _e( 'Bulk Delete Plugin', 'bulk-move' );?></a>.</em></p> |
|
405 | + <p><em><?php _e('If you are looking to delete posts in bulk, try out my ', 'bulk-move'); ?> <a href = "http://sudarmuthu.com/wordpress/bulk-delete"><?php _e('Bulk Delete Plugin', 'bulk-move'); ?></a>.</em></p> |
|
406 | 406 | <!-- Debug box end--> |
407 | 407 | <?php |
408 | 408 | } |
@@ -417,24 +417,24 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public static function save_timeout() { |
419 | 419 | |
420 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
420 | + if (check_admin_referer('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce')) { |
|
421 | 421 | $bm = BULK_MOVE(); |
422 | 422 | $new_max_execution_time = $_POST['smbm_max_execution_time']; |
423 | 423 | |
424 | - if (is_numeric( $new_max_execution_time ) ) { |
|
424 | + if (is_numeric($new_max_execution_time)) { |
|
425 | 425 | //Update option. |
426 | - $option_updated = update_option( Bulk_Move::SCRIPT_TIMEOUT_OPTION, $new_max_execution_time ); |
|
426 | + $option_updated = update_option(Bulk_Move::SCRIPT_TIMEOUT_OPTION, $new_max_execution_time); |
|
427 | 427 | |
428 | - if ( $option_updated === true ) { |
|
428 | + if ($option_updated === true) { |
|
429 | 429 | //Success. |
430 | - $bm->msg = sprintf( __( 'Max execution time was successfully saved as %s seconds.', 'bulk-move' ), $new_max_execution_time ); |
|
430 | + $bm->msg = sprintf(__('Max execution time was successfully saved as %s seconds.', 'bulk-move'), $new_max_execution_time); |
|
431 | 431 | } else { |
432 | 432 | //Error saving option. |
433 | - $bm->msg = __( 'An unknown error occurred while saving your options.', 'bulk-move' ); |
|
433 | + $bm->msg = __('An unknown error occurred while saving your options.', 'bulk-move'); |
|
434 | 434 | } |
435 | 435 | } else { |
436 | 436 | //Error, value was not numeric. |
437 | - $bm->msg = sprintf( __( 'Could not update the max execution time to %s, it was not numeric. Enter the max number of seconds this script should run.', 'bulk-move' ), $new_max_execution_time ); |
|
437 | + $bm->msg = sprintf(__('Could not update the max execution time to %s, it was not numeric. Enter the max number of seconds this script should run.', 'bulk-move'), $new_max_execution_time); |
|
438 | 438 | } |
439 | 439 | } |
440 | 440 | } |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | */ |
450 | 450 | public static function change_timeout() { |
451 | 451 | // get max script execution time from option. |
452 | - $max_execution_time = get_option( Bulk_Move::SCRIPT_TIMEOUT_OPTION ); |
|
453 | - if ( ! $max_execution_time ) { |
|
452 | + $max_execution_time = get_option(Bulk_Move::SCRIPT_TIMEOUT_OPTION); |
|
453 | + if (!$max_execution_time) { |
|
454 | 454 | //Increase script timeout in order to handle many posts. |
455 | - ini_set( 'max_execution_time', $max_execution_time ); |
|
455 | + ini_set('max_execution_time', $max_execution_time); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public static function load_custom_taxonomy_by_post_type() { |
465 | 465 | $bulk_move = BULK_MOVE(); |
466 | - check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
467 | - $post_type = isset( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : 'post'; |
|
466 | + check_ajax_referer($bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security'); |
|
467 | + $post_type = isset($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : 'post'; |
|
468 | 468 | |
469 | - $taxonomies = get_object_taxonomies( $post_type ); |
|
469 | + $taxonomies = get_object_taxonomies($post_type); |
|
470 | 470 | |
471 | 471 | $args = array( |
472 | 472 | 'taxonomy' => $taxonomies, |
@@ -476,15 +476,15 @@ discard block |
||
476 | 476 | |
477 | 477 | ob_start(); |
478 | 478 | ?> |
479 | - <option class="level-0" value="select"><?php _e( 'Select Taxonomy ', 'bulk-move' ); ?></option> |
|
479 | + <option class="level-0" value="select"><?php _e('Select Taxonomy ', 'bulk-move'); ?></option> |
|
480 | 480 | <?php |
481 | - foreach ( $taxonomies as $taxonomy ) : |
|
481 | + foreach ($taxonomies as $taxonomy) : |
|
482 | 482 | ?> |
483 | 483 | <option class="level-0" value="<?php echo $taxonomy; ?>"><?php echo $taxonomy; ?></option> |
484 | 484 | <?php |
485 | 485 | endforeach; |
486 | 486 | $data = ob_get_clean(); |
487 | - wp_send_json_success( $data ); |
|
487 | + wp_send_json_success($data); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
@@ -494,20 +494,20 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public static function load_custom_terms_by_taxonomy() { |
496 | 496 | $bulk_move = BULK_MOVE(); |
497 | - check_ajax_referer( $bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security' ); |
|
498 | - $taxonomy = isset( $_POST['taxonomy'] ) ? sanitize_text_field( $_POST['taxonomy'] ) : 'category'; |
|
497 | + check_ajax_referer($bulk_move::BOX_CUSTOM_TERMS_NONCE, 'security'); |
|
498 | + $taxonomy = isset($_POST['taxonomy']) ? sanitize_text_field($_POST['taxonomy']) : 'category'; |
|
499 | 499 | |
500 | 500 | $args = array( |
501 | 501 | 'taxonomy' => $taxonomy, |
502 | 502 | 'hide_empty' => false, |
503 | 503 | 'orderby' => 'name', |
504 | 504 | ); |
505 | - $terms = get_terms( $args ); |
|
505 | + $terms = get_terms($args); |
|
506 | 506 | |
507 | - $select_term = '<option class="level-0" value="-1">' . __( 'Select Term ', '"bulk-move' ) . '</option>'; |
|
508 | - $map_term = '<option class="level-0" value="-1">' . __( 'Remove Term ', 'bullk-move' ) . '</option>'; |
|
507 | + $select_term = '<option class="level-0" value="-1">'.__('Select Term ', '"bulk-move').'</option>'; |
|
508 | + $map_term = '<option class="level-0" value="-1">'.__('Remove Term ', 'bullk-move').'</option>'; |
|
509 | 509 | ob_start(); |
510 | - foreach ( $terms as $term ) : |
|
510 | + foreach ($terms as $term) : |
|
511 | 511 | ?> |
512 | 512 | <option class="level-0" value="<?php echo $term->term_id; ?>"><?php echo $term->name; ?> (<?php echo $term->count; ?>)</option> |
513 | 513 | <?php |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | $ob = ob_get_clean(); |
516 | 516 | $select_term .= $ob; |
517 | 517 | $map_term .= $ob; |
518 | - $data = array( 'select_term' => $select_term, 'map_term' => $map_term ); |
|
519 | - wp_send_json_success( $data ); |
|
518 | + $data = array('select_term' => $select_term, 'map_term' => $map_term); |
|
519 | + wp_send_json_success($data); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -526,38 +526,38 @@ discard block |
||
526 | 526 | */ |
527 | 527 | public static function render_move_by_custom_taxonomy_box() { |
528 | 528 | |
529 | - if ( Bulk_Move_Util::is_posts_box_hidden( Bulk_Move::BOX_CATEGORY ) ) { |
|
530 | - printf( __( 'This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move' ), 'tools.php?page=' . Bulk_Move::POSTS_PAGE_SLUG ); |
|
529 | + if (Bulk_Move_Util::is_posts_box_hidden(Bulk_Move::BOX_CATEGORY)) { |
|
530 | + printf(__('This section just got enabled. Kindly <a href = "%1$s">refresh</a> the page to fully enable it.', 'bulk-move'), 'tools.php?page='.Bulk_Move::POSTS_PAGE_SLUG); |
|
531 | 531 | |
532 | 532 | return; |
533 | 533 | } |
534 | 534 | ?> |
535 | 535 | <!-- Custom Taxonomy Start--> |
536 | - <h4><?php _e( 'Select the post type to show its taxonomy. On the left side, select the term whose posts you want to move. On the right side select the term to which you want the posts to be moved.', 'bulk-move' ) ?></h4> |
|
536 | + <h4><?php _e('Select the post type to show its taxonomy. On the left side, select the term whose posts you want to move. On the right side select the term to which you want the posts to be moved.', 'bulk-move') ?></h4> |
|
537 | 537 | |
538 | 538 | <fieldset class="options"> |
539 | 539 | <table class="optiontable"> |
540 | 540 | <tr> |
541 | 541 | <td scope="row" colspan="2"> |
542 | - <?php _e( 'Select the post type to show its custom taxonomy.', 'bulk-move' ) ?> |
|
542 | + <?php _e('Select the post type to show its custom taxonomy.', 'bulk-move') ?> |
|
543 | 543 | </td> |
544 | 544 | <td scope="row"> |
545 | 545 | </tr> |
546 | 546 | <tr> |
547 | 547 | <td scope="row" colspan="2"> |
548 | 548 | <?php |
549 | - $custom_post_types_args = array( '_builtin' => false ); |
|
550 | - $custom_post_types = get_post_types( $custom_post_types_args ); |
|
549 | + $custom_post_types_args = array('_builtin' => false); |
|
550 | + $custom_post_types = get_post_types($custom_post_types_args); |
|
551 | 551 | ?> |
552 | - <?php if ( count( $custom_post_types ) === 0 ) : ?> |
|
552 | + <?php if (count($custom_post_types) === 0) : ?> |
|
553 | 553 | <p> |
554 | - <span class="error-notice"><?php _e( 'You have no custom post type registered.', 'bulk-move' ); ?></span> |
|
554 | + <span class="error-notice"><?php _e('You have no custom post type registered.', 'bulk-move'); ?></span> |
|
555 | 555 | </p> |
556 | 556 | <?php endif; ?> |
557 | 557 | <p> |
558 | 558 | <select name="smbm_mbct_post_type" id="smbm_mbct_post_type"> |
559 | - <option value="select"><?php _e( 'Select Post type', 'bulk-move' ); ?></option> |
|
560 | - <?php foreach ( $custom_post_types as $post_type ) : ?> |
|
559 | + <option value="select"><?php _e('Select Post type', 'bulk-move'); ?></option> |
|
560 | + <?php foreach ($custom_post_types as $post_type) : ?> |
|
561 | 561 | <option value="<?php echo $post_type; ?>"><?php echo $post_type; ?></option> |
562 | 562 | <?php endforeach; ?> |
563 | 563 | </select> |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | </tr> |
567 | 567 | <tr class="taxonomy-select-row"> |
568 | 568 | <td scope="row" colspan="2"> |
569 | - <?php _e( 'Select taxonomy to show its terms.', 'bulk-move' ) ?> |
|
569 | + <?php _e('Select taxonomy to show its terms.', 'bulk-move') ?> |
|
570 | 570 | </td> |
571 | 571 | <td scope="row"> |
572 | 572 | </tr> |
@@ -574,65 +574,65 @@ discard block |
||
574 | 574 | <td scope="row" colspan="2"> |
575 | 575 | <p> |
576 | 576 | <select name="smbm_mbct_taxonomy" id="smbm_mbct_taxonomy"> |
577 | - <option value="select"><?php _e( 'Select Taxonomy', 'bulk-move' ); ?></option> |
|
577 | + <option value="select"><?php _e('Select Taxonomy', 'bulk-move'); ?></option> |
|
578 | 578 | </select> |
579 | 579 | </p> |
580 | 580 | </td> |
581 | 581 | </tr> |
582 | 582 | <tr class="term-select-row"> |
583 | 583 | <td scope="row" colspan="2"> |
584 | - <?php _e( 'Select terms to move its posts.', 'bulk-move' ) ?> |
|
584 | + <?php _e('Select terms to move its posts.', 'bulk-move') ?> |
|
585 | 585 | </td> |
586 | 586 | <td scope="row"> |
587 | 587 | </tr> |
588 | 588 | <tr class="term-select-row"> |
589 | 589 | <td scope="row" > |
590 | 590 | <select name="smbm_mbct_selected_term" id="smbm_mbct_selected_term" class="postform"> |
591 | - <option class="level-0" value="-1"><?php _e( ' Select Term ', 'bulk-move' ); ?></option> |
|
591 | + <option class="level-0" value="-1"><?php _e(' Select Term ', 'bulk-move'); ?></option> |
|
592 | 592 | </select> |
593 | 593 | ==> |
594 | 594 | </td> |
595 | 595 | <td scope="row" > |
596 | 596 | <select name="smbm_mbct_mapped_term" id="smbm_mbct_mapped_term" class="postform"> |
597 | - <option class="level-0" value="-1"><?php _e( 'Remove Term ', 'bulk-move' ); ?></option> |
|
597 | + <option class="level-0" value="-1"><?php _e('Remove Term ', 'bulk-move'); ?></option> |
|
598 | 598 | </select> |
599 | 599 | </td> |
600 | 600 | </tr> |
601 | 601 | |
602 | 602 | </table> |
603 | 603 | <p> |
604 | - <?php _e( 'If the post contains other terms, then', 'bulk-move' ); ?> |
|
605 | - <input type="radio" name="smbm_mbct_overwrite" value="overwrite" checked><?php _e( 'Remove them', 'bulk-move' ); ?> |
|
606 | - <input type="radio" name="smbm_mbct_overwrite" value="no-overwrite"><?php _e( "Don't remove them", 'bulk-move' ); ?> |
|
604 | + <?php _e('If the post contains other terms, then', 'bulk-move'); ?> |
|
605 | + <input type="radio" name="smbm_mbct_overwrite" value="overwrite" checked><?php _e('Remove them', 'bulk-move'); ?> |
|
606 | + <input type="radio" name="smbm_mbct_overwrite" value="no-overwrite"><?php _e("Don't remove them", 'bulk-move'); ?> |
|
607 | 607 | </p> |
608 | 608 | |
609 | 609 | </fieldset> |
610 | 610 | <p class="submit"> |
611 | - <button type="submit" name="bm_action" value="move_custom_taxonomy" class="button-primary"><?php _e( 'Bulk Move ', 'bulk-move' ) ?>»</button> |
|
611 | + <button type="submit" name="bm_action" value="move_custom_taxonomy" class="button-primary"><?php _e('Bulk Move ', 'bulk-move') ?>»</button> |
|
612 | 612 | </p> |
613 | 613 | <!-- Custom Taxonomy end--> |
614 | 614 | <?php |
615 | 615 | } |
616 | 616 | |
617 | 617 | public static function move_custom_taxonomy() { |
618 | - if ( check_admin_referer( 'sm-bulk-move-posts', 'sm-bulk-move-posts-nonce' ) ) { |
|
618 | + if (check_admin_referer('sm-bulk-move-posts', 'sm-bulk-move-posts-nonce')) { |
|
619 | 619 | |
620 | - do_action( 'bm_pre_request_handler' ); |
|
620 | + do_action('bm_pre_request_handler'); |
|
621 | 621 | |
622 | 622 | $wp_query = new WP_Query; |
623 | 623 | $bm = BULK_MOVE(); |
624 | 624 | |
625 | 625 | // Move by terms. |
626 | - $old_cat = absint( $_POST['smbm_mbct_selected_term'] ); |
|
626 | + $old_cat = absint($_POST['smbm_mbct_selected_term']); |
|
627 | 627 | $taxonomy = $_POST['smbm_mbct_taxonomy']; |
628 | - $post_types = array( $_POST['smbm_mbct_post_type'] ); |
|
628 | + $post_types = array($_POST['smbm_mbct_post_type']); |
|
629 | 629 | |
630 | - $new_cat = ( $_POST['smbm_mbct_mapped_term'] == -1 ) ? -1 : absint( $_POST['smbm_mbct_mapped_term'] ); |
|
630 | + $new_cat = ($_POST['smbm_mbct_mapped_term'] == -1) ? -1 : absint($_POST['smbm_mbct_mapped_term']); |
|
631 | 631 | |
632 | - $posts_count = 0 ; |
|
632 | + $posts_count = 0; |
|
633 | 633 | |
634 | - if ( $old_cat !== -1 ) { |
|
635 | - foreach ( $post_types as $post_type ) { |
|
634 | + if ($old_cat !== -1) { |
|
635 | + foreach ($post_types as $post_type) { |
|
636 | 636 | $posts_args = array( |
637 | 637 | 'tax_query' => array( |
638 | 638 | array( |
@@ -645,37 +645,37 @@ discard block |
||
645 | 645 | 'nopaging' => 'true', |
646 | 646 | ); |
647 | 647 | |
648 | - $posts = $wp_query->query( $posts_args ); |
|
649 | - $posts_count += count( $posts ); |
|
648 | + $posts = $wp_query->query($posts_args); |
|
649 | + $posts_count += count($posts); |
|
650 | 650 | |
651 | - foreach ( $posts as $post ) { |
|
651 | + foreach ($posts as $post) { |
|
652 | 652 | |
653 | - if ( $new_cat != -1 ) { |
|
654 | - if ( isset( $_POST['smbm_mbct_overwrite'] ) && 'overwrite' == $_POST['smbm_mbct_overwrite'] ) { |
|
653 | + if ($new_cat != -1) { |
|
654 | + if (isset($_POST['smbm_mbct_overwrite']) && 'overwrite' == $_POST['smbm_mbct_overwrite']) { |
|
655 | 655 | // Remove old categories |
656 | 656 | $is_append_terms = false; |
657 | 657 | } else { |
658 | 658 | // Add to existing categories |
659 | 659 | $is_append_terms = true; |
660 | 660 | } |
661 | - wp_set_object_terms( $post->ID, $new_cat, $taxonomy, $is_append_terms ); |
|
661 | + wp_set_object_terms($post->ID, $new_cat, $taxonomy, $is_append_terms); |
|
662 | 662 | } else { |
663 | - wp_remove_object_terms( $post->ID, $old_cat, $taxonomy ); |
|
663 | + wp_remove_object_terms($post->ID, $old_cat, $taxonomy); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | } |
667 | 667 | } |
668 | 668 | |
669 | - $bm->msg = sprintf( _n( 'Moved %d post from the selected category', 'Moved %d posts from the selected category' , $posts_count, 'bulk-move' ), $posts_count ); |
|
669 | + $bm->msg = sprintf(_n('Moved %d post from the selected category', 'Moved %d posts from the selected category', $posts_count, 'bulk-move'), $posts_count); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 | } |
673 | 673 | |
674 | 674 | // Hooks |
675 | -add_action( 'bm_pre_request_handler' , array( 'Bulk_Move_Posts', 'change_timeout' ) ); |
|
676 | -add_action( 'bm_move_cats' , array( 'Bulk_Move_Posts', 'move_cats' ) ); |
|
677 | -add_action( 'bm_move_tags' , array( 'Bulk_Move_Posts', 'move_tags' ) ); |
|
678 | -add_action( 'bm_move_category_by_tag' , array( 'Bulk_Move_Posts', 'move_category_by_tag' ) ); |
|
679 | -add_action( 'bm_save_timeout' , array( 'Bulk_Move_Posts', 'save_timeout' ) ); |
|
680 | -add_action( 'bm_move_custom_taxonomy' , array( 'Bulk_Move_Posts', 'move_custom_taxonomy' ) ); |
|
675 | +add_action('bm_pre_request_handler', array('Bulk_Move_Posts', 'change_timeout')); |
|
676 | +add_action('bm_move_cats', array('Bulk_Move_Posts', 'move_cats')); |
|
677 | +add_action('bm_move_tags', array('Bulk_Move_Posts', 'move_tags')); |
|
678 | +add_action('bm_move_category_by_tag', array('Bulk_Move_Posts', 'move_category_by_tag')); |
|
679 | +add_action('bm_save_timeout', array('Bulk_Move_Posts', 'save_timeout')); |
|
680 | +add_action('bm_move_custom_taxonomy', array('Bulk_Move_Posts', 'move_custom_taxonomy')); |
|
681 | 681 | ?> |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @since 1.1 |
22 | 22 | */ |
23 | - public static function is_posts_box_hidden( $box ) { |
|
23 | + public static function is_posts_box_hidden($box) { |
|
24 | 24 | $hidden_boxes = self::get_posts_hidden_boxes(); |
25 | 25 | |
26 | - return ( is_array( $hidden_boxes ) && in_array( $box, $hidden_boxes ) ); |
|
26 | + return (is_array($hidden_boxes) && in_array($box, $hidden_boxes)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public static function get_posts_hidden_boxes() { |
37 | 37 | $current_user = wp_get_current_user(); |
38 | 38 | |
39 | - return get_user_meta( $current_user->ID, self::VISIBLE_POST_BOXES, true ); |
|
39 | + return get_user_meta($current_user->ID, self::VISIBLE_POST_BOXES, true); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |