web/wp-admin/plugins.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    59 			exit;
    59 			exit;
    60 			break;
    60 			break;
    61 		case 'activate-selected':
    61 		case 'activate-selected':
    62 			if ( ! current_user_can('activate_plugins') )
    62 			if ( ! current_user_can('activate_plugins') )
    63 				wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
    63 				wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
    64 			
    64 
    65 			check_admin_referer('bulk-manage-plugins');
    65 			check_admin_referer('bulk-manage-plugins');
    66 
    66 
    67 			$plugins = (array) $_POST['checked'];
    67 			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
    68 			$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
    68 			$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
    69 			if ( empty($plugins) ) {
    69 			if ( empty($plugins) ) {
    70 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
    70 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
    71 				exit;
    71 				exit;
    72 			}
    72 			}
    91 
    91 
    92 			$valid = validate_plugin($plugin);
    92 			$valid = validate_plugin($plugin);
    93 			if ( is_wp_error($valid) )
    93 			if ( is_wp_error($valid) )
    94 				wp_die($valid);
    94 				wp_die($valid);
    95 
    95 
    96 			error_reporting( E_ALL ^ E_NOTICE );
    96 			if ( defined('E_RECOVERABLE_ERROR') )
       
    97 				error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
       
    98 			else
       
    99 				error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
       
   100 
    97 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
   101 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
    98 			include(WP_PLUGIN_DIR . '/' . $plugin);
   102 			include(WP_PLUGIN_DIR . '/' . $plugin);
    99 			do_action('activate_' . $plugin);
   103 			do_action('activate_' . $plugin);
   100 			exit;
   104 			exit;
   101 			break;
   105 			break;
   113 			if ( ! current_user_can('activate_plugins') )
   117 			if ( ! current_user_can('activate_plugins') )
   114 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
   118 				wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
   115 
   119 
   116 			check_admin_referer('bulk-manage-plugins');
   120 			check_admin_referer('bulk-manage-plugins');
   117 
   121 
   118 			$plugins = (array) $_POST['checked'];
   122 			$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
   119 			$plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
   123 			$plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
   120 			if ( empty($plugins) ) {
   124 			if ( empty($plugins) ) {
   121 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
   125 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
   122 				exit;
   126 				exit;
   123 			}
   127 			}
   136 			if ( ! current_user_can('delete_plugins') )
   140 			if ( ! current_user_can('delete_plugins') )
   137 				wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
   141 				wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
   138 
   142 
   139 			check_admin_referer('bulk-manage-plugins');
   143 			check_admin_referer('bulk-manage-plugins');
   140 
   144 
   141 			$plugins = (array) $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen.
   145 			//$_POST = from the plugin form; $_GET = from the FTP details screen.
       
   146 			$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
   142 			$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
   147 			$plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
   143 			if ( empty($plugins) ) {
   148 			if ( empty($plugins) ) {
   144 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
   149 				wp_redirect("plugins.php?plugin_status=$status&paged=$page");
   145 				exit;
   150 				exit;
   146 			}
   151 			}
   268 	<div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
   273 	<div id="message" class="updated fade"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
   269 <?php endif; ?>
   274 <?php endif; ?>
   270 
   275 
   271 <div class="wrap">
   276 <div class="wrap">
   272 <?php screen_icon(); ?>
   277 <?php screen_icon(); ?>
   273 <h2><?php echo esc_html( $title ); ?></h2>
   278 <h2><?php echo esc_html( $title ); ?> <a href="plugin-install.php" class="button add-new-h2"><?php echo esc_html_x('Add New', 'plugin'); ?></a></h2>
   274 
   279 
   275 <?php
   280 <?php
   276 
   281 
   277 $all_plugins = get_plugins();
   282 $all_plugins = get_plugins();
   278 $search_plugins = array();
   283 $search_plugins = array();
   347 $plugins = &$$plugin_array_name;
   352 $plugins = &$$plugin_array_name;
   348 
   353 
   349 //Paging.
   354 //Paging.
   350 $total_this_page = "total_{$status}_plugins";
   355 $total_this_page = "total_{$status}_plugins";
   351 $total_this_page = $$total_this_page;
   356 $total_this_page = $$total_this_page;
   352 $plugins_per_page = get_user_option('plugins_per_page');
   357 $plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
   353 if ( empty($plugins_per_page) )
   358 if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
   354 	$plugins_per_page = 999;
   359 	$plugins_per_page = 999;
   355 $plugins_per_page = apply_filters('plugins_per_page', $plugins_per_page);
   360 $plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
   356 
   361 
   357 $start = ($page - 1) * $plugins_per_page;
   362 $start = ($page - 1) * $plugins_per_page;
   358 
   363 
   359 $page_links = paginate_links( array(
   364 $page_links = paginate_links( array(
   360 	'base' => add_query_arg( 'paged', '%#%' ),
   365 	'base' => add_query_arg( 'paged', '%#%' ),