wp/wp-admin/plugins.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 if ( ! current_user_can('activate_plugins') )
    12 if ( ! current_user_can( 'activate_plugins' ) ) {
    13 	wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
    13 	wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
    14 
    14 }
    15 $wp_list_table = _get_list_table('WP_Plugins_List_Table');
    15 
    16 $pagenum = $wp_list_table->get_pagenum();
    16 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
       
    17 $pagenum       = $wp_list_table->get_pagenum();
    17 
    18 
    18 $action = $wp_list_table->current_action();
    19 $action = $wp_list_table->current_action();
    19 
    20 
    20 $plugin = isset($_REQUEST['plugin']) ? wp_unslash( $_REQUEST['plugin'] ) : '';
    21 $plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
    21 $s = isset($_REQUEST['s']) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
    22 $s      = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
    22 
    23 
    23 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    24 // Clean up request URI from temporary args for screen options/paging uri's to work as expected.
    24 $_SERVER['REQUEST_URI'] = remove_query_arg(array('error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce'), $_SERVER['REQUEST_URI']);
    25 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'error', 'deleted', 'activate', 'activate-multi', 'deactivate', 'deactivate-multi', '_error_nonce' ), $_SERVER['REQUEST_URI'] );
    25 
    26 
    26 wp_enqueue_script( 'updates' );
    27 wp_enqueue_script( 'updates' );
    27 
    28 
    28 if ( $action ) {
    29 if ( $action ) {
    29 
    30 
    32 			if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
    33 			if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
    33 				wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
    34 				wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
    34 			}
    35 			}
    35 
    36 
    36 			if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
    37 			if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
    37 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
    38 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
    38 				exit;
    39 				exit;
    39 			}
    40 			}
    40 
    41 
    41 			check_admin_referer('activate-plugin_' . $plugin);
    42 			check_admin_referer( 'activate-plugin_' . $plugin );
    42 
    43 
    43 			$result = activate_plugin($plugin, self_admin_url('plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
    44 			$result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
    44 			if ( is_wp_error( $result ) ) {
    45 			if ( is_wp_error( $result ) ) {
    45 				if ( 'unexpected_output' == $result->get_error_code() ) {
    46 				if ( 'unexpected_output' == $result->get_error_code() ) {
    46 					$redirect = self_admin_url('plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s");
    47 					$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
    47 					wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
    48 					wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
    48 					exit;
    49 					exit;
    49 				} else {
    50 				} else {
    50 					wp_die($result);
    51 					wp_die( $result );
    51 				}
    52 				}
    52 			}
    53 			}
    53 
    54 
    54 			if ( ! is_network_admin() ) {
    55 			if ( ! is_network_admin() ) {
    55 				$recent = (array) get_option( 'recently_activated' );
    56 				$recent = (array) get_option( 'recently_activated' );
    59 				$recent = (array) get_site_option( 'recently_activated' );
    60 				$recent = (array) get_site_option( 'recently_activated' );
    60 				unset( $recent[ $plugin ] );
    61 				unset( $recent[ $plugin ] );
    61 				update_site_option( 'recently_activated', $recent );
    62 				update_site_option( 'recently_activated', $recent );
    62 			}
    63 			}
    63 
    64 
    64 			if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
    65 			if ( isset( $_GET['from'] ) && 'import' == $_GET['from'] ) {
    65 				wp_redirect( self_admin_url("import.php?import=" . str_replace('-importer', '', dirname($plugin))) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
    66 				wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix
    66 			} else if ( isset($_GET['from']) && 'press-this' == $_GET['from'] ) {
    67 			} elseif ( isset( $_GET['from'] ) && 'press-this' == $_GET['from'] ) {
    67 				wp_redirect( self_admin_url( "press-this.php") );
    68 				wp_redirect( self_admin_url( 'press-this.php' ) );
    68 			} else if ( isset( $_GET['from'] ) && 'try-gutenberg' == $_GET['from'] ) {
    69 			} else {
    69 				if ( 'gutenberg/gutenberg.php' === $plugin ) {
    70 				wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); // overrides the ?error=true one above
    70 					wp_redirect( self_admin_url( "admin.php?page=gutenberg" ) );
       
    71 				} else {
       
    72 					wp_redirect( self_admin_url() );
       
    73 				}
       
    74 			} else {
       
    75 				wp_redirect( self_admin_url("plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s") ); // overrides the ?error=true one above
       
    76 			}
    71 			}
    77 			exit;
    72 			exit;
    78 
    73 
    79 		case 'activate-selected':
    74 		case 'activate-selected':
    80 			if ( ! current_user_can('activate_plugins') )
    75 			if ( ! current_user_can( 'activate_plugins' ) ) {
    81 				wp_die(__('Sorry, you are not allowed to activate plugins for this site.'));
    76 				wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) );
    82 
    77 			}
    83 			check_admin_referer('bulk-plugins');
    78 
       
    79 			check_admin_referer( 'bulk-plugins' );
    84 
    80 
    85 			$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
    81 			$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
    86 
    82 
    87 			if ( is_network_admin() ) {
    83 			if ( is_network_admin() ) {
    88 				foreach ( $plugins as $i => $plugin ) {
    84 				foreach ( $plugins as $i => $plugin ) {
   102 						unset( $plugins[ $i ] );
    98 						unset( $plugins[ $i ] );
   103 					}
    99 					}
   104 				}
   100 				}
   105 			}
   101 			}
   106 
   102 
   107 			if ( empty($plugins) ) {
   103 			if ( empty( $plugins ) ) {
   108 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
   104 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
   109 				exit;
   105 				exit;
   110 			}
   106 			}
   111 
   107 
   112 			activate_plugins($plugins, self_admin_url('plugins.php?error=true'), is_network_admin() );
   108 			activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() );
   113 
   109 
   114 			if ( ! is_network_admin() ) {
   110 			if ( ! is_network_admin() ) {
   115 				$recent = (array) get_option('recently_activated' );
   111 				$recent = (array) get_option( 'recently_activated' );
   116 			} else {
   112 			} else {
   117 				$recent = (array) get_site_option('recently_activated' );
   113 				$recent = (array) get_site_option( 'recently_activated' );
   118 			}
   114 			}
   119 
   115 
   120 			foreach ( $plugins as $plugin ) {
   116 			foreach ( $plugins as $plugin ) {
   121 				unset( $recent[ $plugin ] );
   117 				unset( $recent[ $plugin ] );
   122 			}
   118 			}
   125 				update_option( 'recently_activated', $recent );
   121 				update_option( 'recently_activated', $recent );
   126 			} else {
   122 			} else {
   127 				update_site_option( 'recently_activated', $recent );
   123 				update_site_option( 'recently_activated', $recent );
   128 			}
   124 			}
   129 
   125 
   130 			wp_redirect( self_admin_url("plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   126 			wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
   131 			exit;
   127 			exit;
   132 
   128 
   133 		case 'update-selected' :
   129 		case 'update-selected':
   134 
       
   135 			check_admin_referer( 'bulk-plugins' );
   130 			check_admin_referer( 'bulk-plugins' );
   136 
   131 
   137 			if ( isset( $_GET['plugins'] ) )
   132 			if ( isset( $_GET['plugins'] ) ) {
   138 				$plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
   133 				$plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
   139 			elseif ( isset( $_POST['checked'] ) )
   134 			} elseif ( isset( $_POST['checked'] ) ) {
   140 				$plugins = (array) wp_unslash( $_POST['checked'] );
   135 				$plugins = (array) wp_unslash( $_POST['checked'] );
   141 			else
   136 			} else {
   142 				$plugins = array();
   137 				$plugins = array();
   143 
   138 			}
   144 			$title = __( 'Update Plugins' );
   139 
       
   140 			$title       = __( 'Update Plugins' );
   145 			$parent_file = 'plugins.php';
   141 			$parent_file = 'plugins.php';
   146 
   142 
   147 			wp_enqueue_script( 'updates' );
   143 			wp_enqueue_script( 'updates' );
   148 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   144 			require_once( ABSPATH . 'wp-admin/admin-header.php' );
   149 
   145 
   150 			echo '<div class="wrap">';
   146 			echo '<div class="wrap">';
   151 			echo '<h1>' . esc_html( $title ) . '</h1>';
   147 			echo '<h1>' . esc_html( $title ) . '</h1>';
   152 
   148 
   153 			$url = self_admin_url('update.php?action=update-selected&amp;plugins=' . urlencode( join(',', $plugins) ));
   149 			$url = self_admin_url( 'update.php?action=update-selected&amp;plugins=' . urlencode( join( ',', $plugins ) ) );
   154 			$url = wp_nonce_url($url, 'bulk-update-plugins');
   150 			$url = wp_nonce_url( $url, 'bulk-update-plugins' );
   155 
   151 
   156 			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
   152 			echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
   157 			echo '</div>';
   153 			echo '</div>';
   158 			require_once(ABSPATH . 'wp-admin/admin-footer.php');
   154 			require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   159 			exit;
   155 			exit;
   160 
   156 
   161 		case 'error_scrape':
   157 		case 'error_scrape':
   162 			if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
   158 			if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
   163 				wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
   159 				wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
   164 			}
   160 			}
   165 
   161 
   166 			check_admin_referer('plugin-activation-error_' . $plugin);
   162 			check_admin_referer( 'plugin-activation-error_' . $plugin );
   167 
   163 
   168 			$valid = validate_plugin($plugin);
   164 			$valid = validate_plugin( $plugin );
   169 			if ( is_wp_error($valid) )
   165 			if ( is_wp_error( $valid ) ) {
   170 				wp_die($valid);
   166 				wp_die( $valid );
       
   167 			}
   171 
   168 
   172 			if ( ! WP_DEBUG ) {
   169 			if ( ! WP_DEBUG ) {
   173 				error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
   170 				error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );
   174 			}
   171 			}
   175 
   172 
   176 			@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
   173 			@ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed.
   177 			// Go back to "sandbox" scope so we get the same errors as before
   174 			// Go back to "sandbox" scope so we get the same errors as before
   178 			plugin_sandbox_scrape( $plugin );
   175 			plugin_sandbox_scrape( $plugin );
   179 			/** This action is documented in wp-admin/includes/plugin.php */
   176 			/** This action is documented in wp-admin/includes/plugin.php */
   180 			do_action( "activate_{$plugin}" );
   177 			do_action( "activate_{$plugin}" );
   181 			exit;
   178 			exit;
   183 		case 'deactivate':
   180 		case 'deactivate':
   184 			if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
   181 			if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
   185 				wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
   182 				wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
   186 			}
   183 			}
   187 
   184 
   188 			check_admin_referer('deactivate-plugin_' . $plugin);
   185 			check_admin_referer( 'deactivate-plugin_' . $plugin );
   189 
   186 
   190 			if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
   187 			if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
   191 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
   188 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
   192 				exit;
   189 				exit;
   193 			}
   190 			}
   194 
   191 
   195 			deactivate_plugins( $plugin, false, is_network_admin() );
   192 			deactivate_plugins( $plugin, false, is_network_admin() );
   196 
   193 
   198 				update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
   195 				update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
   199 			} else {
   196 			} else {
   200 				update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
   197 				update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
   201 			}
   198 			}
   202 
   199 
   203 			if ( headers_sent() )
   200 			if ( headers_sent() ) {
   204 				echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
   201 				echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
   205 			else
   202 			} else {
   206 				wp_redirect( self_admin_url("plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s") );
   203 				wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
       
   204 			}
   207 			exit;
   205 			exit;
   208 
   206 
   209 		case 'deactivate-selected':
   207 		case 'deactivate-selected':
   210 			if ( ! current_user_can( 'deactivate_plugins' ) ) {
   208 			if ( ! current_user_can( 'deactivate_plugins' ) ) {
   211 				wp_die(__('Sorry, you are not allowed to deactivate plugins for this site.'));
   209 				wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) );
   212 			}
   210 			}
   213 
   211 
   214 			check_admin_referer('bulk-plugins');
   212 			check_admin_referer( 'bulk-plugins' );
   215 
   213 
   216 			$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
   214 			$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
   217 			// Do not deactivate plugins which are already deactivated.
   215 			// Do not deactivate plugins which are already deactivated.
   218 			if ( is_network_admin() ) {
   216 			if ( is_network_admin() ) {
   219 				$plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
   217 				$plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
   225 					// Only deactivate plugins which the user can deactivate.
   223 					// Only deactivate plugins which the user can deactivate.
   226 					if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
   224 					if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
   227 						unset( $plugins[ $i ] );
   225 						unset( $plugins[ $i ] );
   228 					}
   226 					}
   229 				}
   227 				}
   230 
   228 			}
   231 			}
   229 			if ( empty( $plugins ) ) {
   232 			if ( empty($plugins) ) {
   230 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
   233 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
       
   234 				exit;
   231 				exit;
   235 			}
   232 			}
   236 
   233 
   237 			deactivate_plugins( $plugins, false, is_network_admin() );
   234 			deactivate_plugins( $plugins, false, is_network_admin() );
   238 
   235 
   245 				update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
   242 				update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
   246 			} else {
   243 			} else {
   247 				update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
   244 				update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
   248 			}
   245 			}
   249 
   246 
   250 			wp_redirect( self_admin_url("plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s") );
   247 			wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
   251 			exit;
   248 			exit;
   252 
   249 
   253 		case 'delete-selected':
   250 		case 'delete-selected':
   254 			if ( ! current_user_can('delete_plugins') ) {
   251 			if ( ! current_user_can( 'delete_plugins' ) ) {
   255 				wp_die(__('Sorry, you are not allowed to delete plugins for this site.'));
   252 				wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
   256 			}
   253 			}
   257 
   254 
   258 			check_admin_referer('bulk-plugins');
   255 			check_admin_referer( 'bulk-plugins' );
   259 
   256 
   260 			//$_POST = from the plugin form; $_GET = from the FTP details screen.
   257 			//$_POST = from the plugin form; $_GET = from the FTP details screen.
   261 			$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
   258 			$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
   262 			if ( empty( $plugins ) ) {
   259 			if ( empty( $plugins ) ) {
   263 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
   260 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
   264 				exit;
   261 				exit;
   265 			}
   262 			}
   266 
   263 
   267 			$plugins = array_filter($plugins, 'is_plugin_inactive'); // Do not allow to delete Activated plugins.
   264 			$plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete Activated plugins.
   268 			if ( empty( $plugins ) ) {
   265 			if ( empty( $plugins ) ) {
   269 				wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
   266 				wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
   270 				exit;
   267 				exit;
   271 			}
   268 			}
   272 
   269 
   273 			// Bail on all if any paths are invalid.
   270 			// Bail on all if any paths are invalid.
   274 			// validate_file() returns truthy for invalid files
   271 			// validate_file() returns truthy for invalid files
   275 			$invalid_plugin_files = array_filter( $plugins, 'validate_file' );
   272 			$invalid_plugin_files = array_filter( $plugins, 'validate_file' );
   276 			if ( $invalid_plugin_files ) {
   273 			if ( $invalid_plugin_files ) {
   277 				wp_redirect( self_admin_url("plugins.php?plugin_status=$status&paged=$page&s=$s") );
   274 				wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
   278 				exit;
   275 				exit;
   279 			}
   276 			}
   280 
   277 
   281 			include(ABSPATH . 'wp-admin/update.php');
   278 			include( ABSPATH . 'wp-admin/update.php' );
   282 
   279 
   283 			$parent_file = 'plugins.php';
   280 			$parent_file = 'plugins.php';
   284 
   281 
   285 			if ( ! isset($_REQUEST['verify-delete']) ) {
   282 			if ( ! isset( $_REQUEST['verify-delete'] ) ) {
   286 				wp_enqueue_script('jquery');
   283 				wp_enqueue_script( 'jquery' );
   287 				require_once(ABSPATH . 'wp-admin/admin-header.php');
   284 				require_once( ABSPATH . 'wp-admin/admin-header.php' );
   288 				?>
   285 				?>
   289 			<div class="wrap">
   286 			<div class="wrap">
   290 				<?php
   287 				<?php
   291 					$plugin_info = array();
   288 					$plugin_info              = array();
   292 					$have_non_network_plugins = false;
   289 					$have_non_network_plugins = false;
   293 					foreach ( (array) $plugins as $plugin ) {
   290 				foreach ( (array) $plugins as $plugin ) {
   294 						$plugin_slug = dirname( $plugin );
   291 					$plugin_slug = dirname( $plugin );
   295 
   292 
   296 						if ( '.' == $plugin_slug ) {
   293 					if ( '.' == $plugin_slug ) {
   297 							if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
   294 						if ( $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ) ) {
   298 								$plugin_info[ $plugin ] = $data;
   295 							$plugin_info[ $plugin ]                     = $data;
   299 								$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   296 							$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
   300 								if ( ! $plugin_info[ $plugin ]['Network'] ) {
   297 							if ( ! $plugin_info[ $plugin ]['Network'] ) {
       
   298 								$have_non_network_plugins = true;
       
   299 							}
       
   300 						}
       
   301 					} else {
       
   302 						// Get plugins list from that folder.
       
   303 						if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
       
   304 							foreach ( $folder_plugins as $plugin_file => $data ) {
       
   305 								$plugin_info[ $plugin_file ]                     = _get_plugin_data_markup_translate( $plugin_file, $data );
       
   306 								$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
       
   307 								if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
   301 									$have_non_network_plugins = true;
   308 									$have_non_network_plugins = true;
   302 								}
       
   303 							}
       
   304 						} else {
       
   305 							// Get plugins list from that folder.
       
   306 							if ( $folder_plugins = get_plugins( '/' . $plugin_slug ) ) {
       
   307 								foreach ( $folder_plugins as $plugin_file => $data ) {
       
   308 									$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
       
   309 									$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
       
   310 									if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
       
   311 										$have_non_network_plugins = true;
       
   312 									}
       
   313 								}
   309 								}
   314 							}
   310 							}
   315 						}
   311 						}
   316 					}
   312 					}
       
   313 				}
   317 					$plugins_to_delete = count( $plugin_info );
   314 					$plugins_to_delete = count( $plugin_info );
   318 				?>
   315 				?>
   319 				<?php if ( 1 == $plugins_to_delete ) : ?>
   316 				<?php if ( 1 == $plugins_to_delete ) : ?>
   320 					<h1><?php _e( 'Delete Plugin' ); ?></h1>
   317 					<h1><?php _e( 'Delete Plugin' ); ?></h1>
   321 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
   318 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
   322 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
   319 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
   323 					<?php endif; ?>
   320 					<?php endif; ?>
   324 					<p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
   321 					<p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
   325 				<?php else: ?>
   322 				<?php else : ?>
   326 					<h1><?php _e( 'Delete Plugins' ); ?></h1>
   323 					<h1><?php _e( 'Delete Plugins' ); ?></h1>
   327 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
   324 					<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
   328 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
   325 						<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
   329 					<?php endif; ?>
   326 					<?php endif; ?>
   330 					<p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
   327 					<p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
   337 								/* translators: 1: plugin name, 2: plugin author */
   334 								/* translators: 1: plugin name, 2: plugin author */
   338 								echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>';
   335 								echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>';
   339 								$data_to_delete = true;
   336 								$data_to_delete = true;
   340 							} else {
   337 							} else {
   341 								/* translators: 1: plugin name, 2: plugin author */
   338 								/* translators: 1: plugin name, 2: plugin author */
   342 								echo '<li>', sprintf( _x('%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
   339 								echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
   343 							}
   340 							}
   344 						}
   341 						}
   345 						?>
   342 						?>
   346 					</ul>
   343 					</ul>
   347 				<p><?php
   344 				<p>
   348 				if ( $data_to_delete )
   345 				<?php
   349 					_e('Are you sure you wish to delete these files and data?');
   346 				if ( $data_to_delete ) {
   350 				else
   347 					_e( 'Are you sure you wish to delete these files and data?' );
   351 					_e('Are you sure you wish to delete these files?');
   348 				} else {
   352 				?></p>
   349 					_e( 'Are you sure you wish to delete these files?' );
   353 				<form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
   350 				}
       
   351 				?>
       
   352 				</p>
       
   353 				<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
   354 					<input type="hidden" name="verify-delete" value="1" />
   354 					<input type="hidden" name="verify-delete" value="1" />
   355 					<input type="hidden" name="action" value="delete-selected" />
   355 					<input type="hidden" name="action" value="delete-selected" />
   356 					<?php
   356 					<?php
   357 						foreach ( (array) $plugins as $plugin ) {
   357 					foreach ( (array) $plugins as $plugin ) {
   358 							echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
   358 						echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
   359 						}
   359 					}
   360 					?>
   360 					?>
   361 					<?php wp_nonce_field('bulk-plugins') ?>
   361 					<?php wp_nonce_field( 'bulk-plugins' ); ?>
   362 					<?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?>
   362 					<?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?>
   363 				</form>
   363 				</form>
   364 				<?php
   364 				<?php
   365 				$referer = wp_get_referer();
   365 				$referer = wp_get_referer();
   366 				?>
   366 				?>
   367 				<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
   367 				<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
   368 					<?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?>
   368 					<?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?>
   369 				</form>
   369 				</form>
   370 			</div>
   370 			</div>
   371 				<?php
   371 				<?php
   372 				require_once(ABSPATH . 'wp-admin/admin-footer.php');
   372 				require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   373 				exit;
   373 				exit;
   374 			} else {
   374 			} else {
   375 				$plugins_to_delete = count( $plugins );
   375 				$plugins_to_delete = count( $plugins );
   376 			} // endif verify-delete
   376 			} // endif verify-delete
   377 
   377 
   378 			$delete_result = delete_plugins( $plugins );
   378 			$delete_result = delete_plugins( $plugins );
   379 
   379 
   380 			set_transient('plugins_delete_result_' . $user_ID, $delete_result); //Store the result in a cache rather than a URL param due to object type & length
   380 			set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); //Store the result in a cache rather than a URL param due to object type & length
   381 			wp_redirect( self_admin_url("plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s") );
   381 			wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
   382 			exit;
   382 			exit;
   383 
   383 
   384 		case 'clear-recent-list':
   384 		case 'clear-recent-list':
   385 			if ( ! is_network_admin() ) {
   385 			if ( ! is_network_admin() ) {
   386 				update_option( 'recently_activated', array() );
   386 				update_option( 'recently_activated', array() );
   387 			} else {
   387 			} else {
   388 				update_site_option( 'recently_activated', array() );
   388 				update_site_option( 'recently_activated', array() );
   389 			}
   389 			}
   390 			break;
   390 			break;
   391 
   391 
       
   392 		case 'resume':
       
   393 			if ( is_multisite() ) {
       
   394 				return;
       
   395 			}
       
   396 
       
   397 			if ( ! current_user_can( 'resume_plugin', $plugin ) ) {
       
   398 				wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) );
       
   399 			}
       
   400 
       
   401 			check_admin_referer( 'resume-plugin_' . $plugin );
       
   402 
       
   403 			$result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) );
       
   404 
       
   405 			if ( is_wp_error( $result ) ) {
       
   406 				wp_die( $result );
       
   407 			}
       
   408 
       
   409 			wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) );
       
   410 			exit;
       
   411 
   392 		default:
   412 		default:
   393 			if ( isset( $_POST['checked'] ) ) {
   413 			if ( isset( $_POST['checked'] ) ) {
   394 				check_admin_referer('bulk-plugins');
   414 				check_admin_referer( 'bulk-plugins' );
   395 				$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
   415 				$plugins  = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
   396 				$sendback = wp_get_referer();
   416 				$sendback = wp_get_referer();
   397 
   417 
   398 				/** This action is documented in wp-admin/edit-comments.php */
   418 				/** This action is documented in wp-admin/edit-comments.php */
   399 				$sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins );
   419 				$sendback = apply_filters( 'handle_bulk_actions-' . get_current_screen()->id, $sendback, $action, $plugins );
   400 				wp_safe_redirect( $sendback );
   420 				wp_safe_redirect( $sendback );
   401 				exit;
   421 				exit;
   402 			}
   422 			}
   403 			break;
   423 			break;
   404 	}
   424 	}
   405 
       
   406 }
   425 }
   407 
   426 
   408 $wp_list_table->prepare_items();
   427 $wp_list_table->prepare_items();
   409 
   428 
   410 wp_enqueue_script('plugin-install');
   429 wp_enqueue_script( 'plugin-install' );
   411 add_thickbox();
   430 add_thickbox();
   412 
   431 
   413 add_screen_option( 'per_page', array( 'default' => 999 ) );
   432 add_screen_option( 'per_page', array( 'default' => 999 ) );
   414 
   433 
   415 get_current_screen()->add_help_tab( array(
   434 get_current_screen()->add_help_tab(
   416 'id'		=> 'overview',
   435 	array(
   417 'title'		=> __('Overview'),
   436 		'id'      => 'overview',
   418 'content'	=>
   437 		'title'   => __( 'Overview' ),
   419 	'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
   438 		'content' =>
   420 	'<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
   439 				 '<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' .
   421 	'<p>' . sprintf(
   440 				 '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' .
   422 		/* translators: %s: WordPress Plugin Directory URL */
   441 				'<p>' . sprintf(
   423 		__( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
   442 					/* translators: %s: WordPress Plugin Directory URL */
   424 		__( 'https://wordpress.org/plugins/' )
   443 					 __( 'If you would like to see more plugins to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
   425 	) . '</p>'
   444 					__( 'https://wordpress.org/plugins/' )
   426 ) );
   445 				) . '</p>',
   427 get_current_screen()->add_help_tab( array(
   446 	)
   428 'id'		=> 'compatibility-problems',
   447 );
   429 'title'		=> __('Troubleshooting'),
   448 get_current_screen()->add_help_tab(
   430 'content'	=>
   449 	array(
   431 	'<p>' . __('Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.') . '</p>' .
   450 		'id'      => 'compatibility-problems',
   432 	'<p>' . sprintf(
   451 		'title'   => __( 'Troubleshooting' ),
   433 		/* translators: WP_PLUGIN_DIR constant value */
   452 		'content' =>
   434 		__( 'If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
   453 				 '<p>' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin&#8217;s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '</p>' .
   435 		'<code>' . WP_PLUGIN_DIR . '</code>'
   454 				'<p>' . sprintf(
   436 	) . '</p>'
   455 					/* translators: WP_PLUGIN_DIR constant value */
   437 ) );
   456 					 __( 'If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ),
       
   457 					'<code>' . WP_PLUGIN_DIR . '</code>'
       
   458 				) . '</p>',
       
   459 	)
       
   460 );
   438 
   461 
   439 get_current_screen()->set_help_sidebar(
   462 get_current_screen()->set_help_sidebar(
   440 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   463 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   441 	'<p>' . __('<a href="https://codex.wordpress.org/Managing_Plugins#Plugin_Management">Documentation on Managing Plugins</a>') . '</p>' .
   464 	'<p>' . __( '<a href="https://codex.wordpress.org/Managing_Plugins#Plugin_Management">Documentation on Managing Plugins</a>' ) . '</p>' .
   442 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
   465 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   443 );
   466 );
   444 
   467 
   445 get_current_screen()->set_screen_reader_content( array(
   468 get_current_screen()->set_screen_reader_content(
   446 	'heading_views'      => __( 'Filter plugins list' ),
   469 	array(
   447 	'heading_pagination' => __( 'Plugins list navigation' ),
   470 		'heading_views'      => __( 'Filter plugins list' ),
   448 	'heading_list'       => __( 'Plugins list' ),
   471 		'heading_pagination' => __( 'Plugins list navigation' ),
   449 ) );
   472 		'heading_list'       => __( 'Plugins list' ),
   450 
   473 	)
   451 $title = __('Plugins');
   474 );
       
   475 
       
   476 $title       = __( 'Plugins' );
   452 $parent_file = 'plugins.php';
   477 $parent_file = 'plugins.php';
   453 
   478 
   454 require_once(ABSPATH . 'wp-admin/admin-header.php');
   479 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   455 
   480 
   456 $invalid = validate_active_plugins();
   481 $invalid = validate_active_plugins();
   457 if ( ! empty( $invalid ) ) {
   482 if ( ! empty( $invalid ) ) {
   458 	foreach ( $invalid as $plugin_file => $error ) {
   483 	foreach ( $invalid as $plugin_file => $error ) {
   459 		echo '<div id="message" class="error"><p>';
   484 		echo '<div id="message" class="error"><p>';
   460 		printf(
   485 		printf(
   461 			/* translators: 1: plugin file 2: error message */
   486 			/* translators: 1: plugin file, 2: error message */
   462 			__( 'The plugin %1$s has been <strong>deactivated</strong> due to an error: %2$s' ),
   487 			__( 'The plugin %1$s has been <strong>deactivated</strong> due to an error: %2$s' ),
   463 			'<code>' . esc_html( $plugin_file ) . '</code>',
   488 			'<code>' . esc_html( $plugin_file ) . '</code>',
   464 			$error->get_error_message() );
   489 			$error->get_error_message()
       
   490 		);
   465 		echo '</p></div>';
   491 		echo '</p></div>';
   466 	}
   492 	}
   467 }
   493 }
   468 ?>
   494 ?>
   469 
   495 
   470 <?php if ( isset($_GET['error']) ) :
   496 <?php
   471 
   497 if ( isset( $_GET['error'] ) ) :
   472 	if ( isset( $_GET['main'] ) )
   498 
       
   499 	if ( isset( $_GET['main'] ) ) {
   473 		$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
   500 		$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' );
   474 	elseif ( isset($_GET['charsout']) )
   501 	} elseif ( isset( $_GET['charsout'] ) ) {
   475 		$errmsg = sprintf(__('The plugin generated %d characters of <strong>unexpected output</strong> during activation. If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.'), $_GET['charsout']);
   502 		$errmsg  = sprintf(
   476 	else
   503 			_n(
   477 		$errmsg = __('Plugin could not be activated because it triggered a <strong>fatal error</strong>.');
   504 				'The plugin generated %d character of <strong>unexpected output</strong> during activation.',
       
   505 				'The plugin generated %d characters of <strong>unexpected output</strong> during activation.',
       
   506 				$_GET['charsout']
       
   507 			),
       
   508 			$_GET['charsout']
       
   509 		);
       
   510 		$errmsg .= ' ' . __( 'If you notice &#8220;headers already sent&#8221; messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' );
       
   511 	} elseif ( 'resuming' === $_GET['error'] ) {
       
   512 		$errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' );
       
   513 	} else {
       
   514 		$errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' );
       
   515 	}
   478 	?>
   516 	?>
   479 	<div id="message" class="error"><p><?php echo $errmsg; ?></p>
   517 	<div id="message" class="error"><p><?php echo $errmsg; ?></p>
   480 	<?php
   518 	<?php
   481 		if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
   519 	if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) ) {
   482 			$iframe_url = add_query_arg( array(
   520 		$iframe_url = add_query_arg(
       
   521 			array(
   483 				'action'   => 'error_scrape',
   522 				'action'   => 'error_scrape',
   484 				'plugin'   => urlencode( $plugin ),
   523 				'plugin'   => urlencode( $plugin ),
   485 				'_wpnonce' => urlencode( $_GET['_error_nonce'] ),
   524 				'_wpnonce' => urlencode( $_GET['_error_nonce'] ),
   486 			), admin_url( 'plugins.php' ) );
   525 			),
       
   526 			admin_url( 'plugins.php' )
       
   527 		);
   487 		?>
   528 		?>
   488 		<iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
   529 	<iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe>
   489 	<?php
   530 		<?php
   490 		}
   531 	}
   491 	?>
   532 	?>
   492 	</div>
   533 	</div>
   493 <?php elseif ( isset($_GET['deleted']) ) :
   534 	<?php
       
   535 elseif ( isset( $_GET['deleted'] ) ) :
   494 		$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
   536 		$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
   495 		// Delete it once we're done.
   537 		// Delete it once we're done.
   496 		delete_transient( 'plugins_delete_result_' . $user_ID );
   538 		delete_transient( 'plugins_delete_result_' . $user_ID );
   497 
   539 
   498 		if ( is_wp_error($delete_result) ) : ?>
   540 	if ( is_wp_error( $delete_result ) ) :
   499 		<div id="message" class="error notice is-dismissible"><p><?php printf( __('Plugin could not be deleted due to an error: %s'), $delete_result->get_error_message() ); ?></p></div>
   541 		?>
       
   542 		<div id="message" class="error notice is-dismissible"><p><?php printf( __( 'Plugin could not be deleted due to an error: %s' ), $delete_result->get_error_message() ); ?></p></div>
   500 		<?php else : ?>
   543 		<?php else : ?>
   501 		<div id="message" class="updated notice is-dismissible">
   544 		<div id="message" class="updated notice is-dismissible">
   502 			<p>
   545 			<p>
   503 				<?php
   546 				<?php
   504 				if ( 1 == (int) $_GET['deleted'] ) {
   547 				if ( 1 == (int) $_GET['deleted'] ) {
   508 				}
   551 				}
   509 				?>
   552 				?>
   510 			</p>
   553 			</p>
   511 		</div>
   554 		</div>
   512 		<?php endif; ?>
   555 		<?php endif; ?>
   513 <?php elseif ( isset($_GET['activate']) ) : ?>
   556 <?php elseif ( isset( $_GET['activate'] ) ) : ?>
   514 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>activated</strong>.') ?></p></div>
   557 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>activated</strong>.' ); ?></p></div>
   515 <?php elseif (isset($_GET['activate-multi'])) : ?>
   558 <?php elseif ( isset( $_GET['activate-multi'] ) ) : ?>
   516 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>activated</strong>.'); ?></p></div>
   559 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins <strong>activated</strong>.' ); ?></p></div>
   517 <?php elseif ( isset($_GET['deactivate']) ) : ?>
   560 <?php elseif ( isset( $_GET['deactivate'] ) ) : ?>
   518 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Plugin <strong>deactivated</strong>.') ?></p></div>
   561 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>deactivated</strong>.' ); ?></p></div>
   519 <?php elseif (isset($_GET['deactivate-multi'])) : ?>
   562 <?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?>
   520 	<div id="message" class="updated notice is-dismissible"><p><?php _e('Selected plugins <strong>deactivated</strong>.'); ?></p></div>
   563 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins <strong>deactivated</strong>.' ); ?></p></div>
   521 <?php elseif ( 'update-selected' == $action ) : ?>
   564 <?php elseif ( 'update-selected' == $action ) : ?>
   522 	<div id="message" class="updated notice is-dismissible"><p><?php _e('All selected plugins are up to date.'); ?></p></div>
   565 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div>
       
   566 <?php elseif ( isset( $_GET['resume'] ) ) : ?>
       
   567 	<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>resumed</strong>.' ); ?></p></div>
   523 <?php endif; ?>
   568 <?php endif; ?>
   524 
   569 
   525 <div class="wrap">
   570 <div class="wrap">
   526 <h1 class="wp-heading-inline"><?php
   571 <h1 class="wp-heading-inline">
       
   572 <?php
   527 echo esc_html( $title );
   573 echo esc_html( $title );
   528 ?></h1>
   574 ?>
       
   575 </h1>
   529 
   576 
   530 <?php
   577 <?php
   531 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can('install_plugins') ) { ?>
   578 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) {
       
   579 	?>
   532 	<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a>
   580 	<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a>
   533 <?php
   581 	<?php
   534 }
   582 }
   535 
   583 
   536 if ( strlen( $s ) ) {
   584 if ( strlen( $s ) ) {
   537 	/* translators: %s: search keywords */
   585 	/* translators: %s: search keywords */
   538 	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( urldecode( $s ) ) );
   586 	printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( urldecode( $s ) ) );
   550  * Please note: The 'active' portion of the hook name does not refer to whether the current
   598  * Please note: The 'active' portion of the hook name does not refer to whether the current
   551  * view is for active plugins, but rather all plugins actively-installed.
   599  * view is for active plugins, but rather all plugins actively-installed.
   552  *
   600  *
   553  * @since 3.0.0
   601  * @since 3.0.0
   554  *
   602  *
   555  * @param array $plugins_all An array containing all installed plugins.
   603  * @param array[] $plugins_all An array of arrays containing information on all installed plugins.
   556  */
   604  */
   557 do_action( 'pre_current_active_plugins', $plugins['all'] );
   605 do_action( 'pre_current_active_plugins', $plugins['all'] );
   558 ?>
   606 ?>
   559 
   607 
   560 <?php $wp_list_table->views(); ?>
   608 <?php $wp_list_table->views(); ?>
   563 <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
   611 <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?>
   564 </form>
   612 </form>
   565 
   613 
   566 <form method="post" id="bulk-action-form">
   614 <form method="post" id="bulk-action-form">
   567 
   615 
   568 <input type="hidden" name="plugin_status" value="<?php echo esc_attr($status) ?>" />
   616 <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" />
   569 <input type="hidden" name="paged" value="<?php echo esc_attr($page) ?>" />
   617 <input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" />
   570 
   618 
   571 <?php $wp_list_table->display(); ?>
   619 <?php $wp_list_table->display(); ?>
   572 </form>
   620 </form>
   573 
   621 
   574 	<span class="spinner"></span>
   622 	<span class="spinner"></span>
   577 <?php
   625 <?php
   578 wp_print_request_filesystem_credentials_modal();
   626 wp_print_request_filesystem_credentials_modal();
   579 wp_print_admin_notice_templates();
   627 wp_print_admin_notice_templates();
   580 wp_print_update_row_templates();
   628 wp_print_update_row_templates();
   581 
   629 
   582 include(ABSPATH . 'wp-admin/admin-footer.php');
   630 include( ABSPATH . 'wp-admin/admin-footer.php' );