]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/plugins.php
Wordpress 2.9
[autoinstalls/wordpress.git] / wp-admin / plugins.php
index 5a22807e8f829c9cda2336170d827dc26cc16393..48530eddcebb082d76703a557c073b52a89449a9 100644 (file)
@@ -9,6 +9,9 @@
 /** WordPress Administration Bootstrap */
 require_once('admin.php');
 
+if ( ! current_user_can('activate_plugins') )
+       wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));
+
 if ( isset($_POST['clear-recent-list']) )
        $action = 'clear-recent-list';
 elseif ( !empty($_REQUEST['action']) )
@@ -37,6 +40,9 @@ $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate',
 if ( !empty($action) ) {
        switch ( $action ) {
                case 'activate':
+                       if ( ! current_user_can('activate_plugins') )
+                               wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+
                        check_admin_referer('activate-plugin_' . $plugin);
 
                        $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
@@ -53,9 +59,12 @@ if ( !empty($action) ) {
                        exit;
                        break;
                case 'activate-selected':
+                       if ( ! current_user_can('activate_plugins') )
+                               wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+
                        check_admin_referer('bulk-manage-plugins');
 
-                       $plugins = (array) $_POST['checked'];
+                       $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
                        $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Only activate plugins which are not already active.
                        if ( empty($plugins) ) {
                                wp_redirect("plugins.php?plugin_status=$status&paged=$page");
@@ -75,19 +84,29 @@ if ( !empty($action) ) {
                        exit;
                        break;
                case 'error_scrape':
+                       if ( ! current_user_can('activate_plugins') )
+                               wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+
                        check_admin_referer('plugin-activation-error_' . $plugin);
 
                        $valid = validate_plugin($plugin);
                        if ( is_wp_error($valid) )
                                wp_die($valid);
 
-                       error_reporting( E_ALL ^ E_NOTICE );
+                       if ( defined('E_RECOVERABLE_ERROR') )
+                               error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR);
+                       else
+                               error_reporting(E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING);
+
                        @ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
                        include(WP_PLUGIN_DIR . '/' . $plugin);
                        do_action('activate_' . $plugin);
                        exit;
                        break;
                case 'deactivate':
+                       if ( ! current_user_can('activate_plugins') )
+                               wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
+
                        check_admin_referer('deactivate-plugin_' . $plugin);
                        deactivate_plugins($plugin);
                        update_option('recently_activated', array($plugin => time()) + (array)get_option('recently_activated'));
@@ -95,9 +114,12 @@ if ( !empty($action) ) {
                        exit;
                        break;
                case 'deactivate-selected':
+                       if ( ! current_user_can('activate_plugins') )
+                               wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
+
                        check_admin_referer('bulk-manage-plugins');
 
-                       $plugins = (array) $_POST['checked'];
+                       $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
                        $plugins = array_filter($plugins, 'is_plugin_active'); //Do not deactivate plugins which are already deactivated.
                        if ( empty($plugins) ) {
                                wp_redirect("plugins.php?plugin_status=$status&paged=$page");
@@ -120,7 +142,8 @@ if ( !empty($action) ) {
 
                        check_admin_referer('bulk-manage-plugins');
 
-                       $plugins = (array) $_REQUEST['checked']; //$_POST = from the plugin form; $_GET = from the FTP details screen.
+                       //$_POST = from the plugin form; $_GET = from the FTP details screen.
+                       $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
                        $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
                        if ( empty($plugins) ) {
                                wp_redirect("plugins.php?plugin_status=$status&paged=$page");
@@ -252,7 +275,7 @@ if ( !empty($invalid) )
 
 <div class="wrap">
 <?php screen_icon(); ?>
-<h2><?php echo esc_html( $title ); ?></h2>
+<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>
 
 <?php
 
@@ -331,10 +354,10 @@ $plugins = &$$plugin_array_name;
 //Paging.
 $total_this_page = "total_{$status}_plugins";
 $total_this_page = $$total_this_page;
-$plugins_per_page = get_user_option('plugins_per_page');
-if ( empty($plugins_per_page) )
+$plugins_per_page = (int) get_user_option( 'plugins_per_page', 0, false );
+if ( empty( $plugins_per_page ) || $plugins_per_page < 1 )
        $plugins_per_page = 999;
-$plugins_per_page = apply_filters('plugins_per_page', $plugins_per_page);
+$plugins_per_page = apply_filters( 'plugins_per_page', $plugins_per_page );
 
 $start = ($page - 1) * $plugins_per_page;