mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
use activate_plugin for error scraping, pass full WP_Error object to wp_die(), whitespace cleanups. Props DD32. fixes #7671
git-svn-id: http://svn.automattic.com/wordpress/trunk@9315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b5b92a3968
commit
58d9c20de5
@ -28,9 +28,9 @@ if( !empty($action) ) {
|
|||||||
check_admin_referer('activate-plugin_' . $plugin);
|
check_admin_referer('activate-plugin_' . $plugin);
|
||||||
$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
|
$result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin);
|
||||||
if ( is_wp_error( $result ) )
|
if ( is_wp_error( $result ) )
|
||||||
wp_die( $result->get_error_message() );
|
wp_die($result);
|
||||||
$recent = (array)get_option('recently_activated');
|
$recent = (array)get_option('recently_activated');
|
||||||
if( isset($recent[ $plugin ]) ){
|
if ( isset($recent[ $plugin ]) ) {
|
||||||
unset($recent[ $plugin ]);
|
unset($recent[ $plugin ]);
|
||||||
update_option('recently_activated', $recent);
|
update_option('recently_activated', $recent);
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ if( !empty($action) ) {
|
|||||||
|
|
||||||
$recent = (array)get_option('recently_activated');
|
$recent = (array)get_option('recently_activated');
|
||||||
foreach( (array)$_POST['checked'] as $plugin => $time) {
|
foreach( (array)$_POST['checked'] as $plugin => $time) {
|
||||||
if( isset($recent[ $plugin ]) )
|
if ( isset($recent[ $plugin ]) )
|
||||||
unset($recent[ $plugin ]);
|
unset($recent[ $plugin ]);
|
||||||
}
|
}
|
||||||
if( $recent != get_option('recently_activated') ) //If array changed, update it.
|
if( $recent != get_option('recently_activated') ) //If array changed, update it.
|
||||||
@ -59,7 +59,9 @@ if( !empty($action) ) {
|
|||||||
wp_die($valid);
|
wp_die($valid);
|
||||||
error_reporting( E_ALL ^ E_NOTICE );
|
error_reporting( E_ALL ^ E_NOTICE );
|
||||||
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
|
@ini_set('display_errors', true); //Ensure that Fatal errors are displayed.
|
||||||
include(WP_PLUGIN_DIR . '/' . $plugin);
|
$result = activate_plugin($plugin, false);
|
||||||
|
if ( is_wp_error( $result ) )
|
||||||
|
wp_die($result);
|
||||||
exit;
|
exit;
|
||||||
break;
|
break;
|
||||||
case 'deactivate':
|
case 'deactivate':
|
||||||
@ -73,14 +75,14 @@ if( !empty($action) ) {
|
|||||||
check_admin_referer('bulk-manage-plugins');
|
check_admin_referer('bulk-manage-plugins');
|
||||||
deactivate_plugins($_POST['checked']);
|
deactivate_plugins($_POST['checked']);
|
||||||
$deactivated = array();
|
$deactivated = array();
|
||||||
foreach( (array)$_POST['checked'] as $plugin )
|
foreach ( (array)$_POST['checked'] as $plugin )
|
||||||
$deactivated[ $plugin ] = time();
|
$deactivated[ $plugin ] = time();
|
||||||
update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
|
update_option('recently_activated', $deactivated + (array)get_option('recently_activated'));
|
||||||
wp_redirect('plugins.php?deactivate-multi=true');
|
wp_redirect('plugins.php?deactivate-multi=true');
|
||||||
exit;
|
exit;
|
||||||
break;
|
break;
|
||||||
case 'delete-selected':
|
case 'delete-selected':
|
||||||
if( ! current_user_can('delete_plugins') )
|
if ( ! current_user_can('delete_plugins') )
|
||||||
wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
|
wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
|
||||||
|
|
||||||
check_admin_referer('bulk-manage-plugins');
|
check_admin_referer('bulk-manage-plugins');
|
||||||
@ -91,7 +93,7 @@ if( !empty($action) ) {
|
|||||||
$title = __('Delete Plugin');
|
$title = __('Delete Plugin');
|
||||||
$parent_file = 'plugins.php';
|
$parent_file = 'plugins.php';
|
||||||
|
|
||||||
if( ! isset($_REQUEST['verify-delete']) ) {
|
if ( ! isset($_REQUEST['verify-delete']) ) {
|
||||||
wp_enqueue_script('jquery');
|
wp_enqueue_script('jquery');
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
?>
|
?>
|
||||||
@ -99,8 +101,8 @@ if( !empty($action) ) {
|
|||||||
<h2><?php _e('Delete Plugin(s)'); ?></h2>
|
<h2><?php _e('Delete Plugin(s)'); ?></h2>
|
||||||
<?php
|
<?php
|
||||||
$files_to_delete = $plugin_info = array();
|
$files_to_delete = $plugin_info = array();
|
||||||
foreach( (array) $plugins as $plugin ) {
|
foreach ( (array) $plugins as $plugin ) {
|
||||||
if( '.' == dirname($plugin) ) {
|
if ( '.' == dirname($plugin) ) {
|
||||||
$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
|
$files_to_delete[] = WP_PLUGIN_DIR . '/' . $plugin;
|
||||||
if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
|
if( $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin) )
|
||||||
$plugin_info[ $plugin ] = $data;
|
$plugin_info[ $plugin ] = $data;
|
||||||
@ -120,7 +122,7 @@ if( !empty($action) ) {
|
|||||||
<p>
|
<p>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
foreach( $plugin_info as $plugin )
|
foreach ( $plugin_info as $plugin )
|
||||||
echo '<li>', sprintf(__('%s by %s'), $plugin['Name'], $plugin['Author']), '</li>';
|
echo '<li>', sprintf(__('%s by %s'), $plugin['Name'], $plugin['Author']), '</li>';
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
@ -130,7 +132,7 @@ if( !empty($action) ) {
|
|||||||
<input type="hidden" name="verify-delete" value="1" />
|
<input type="hidden" name="verify-delete" value="1" />
|
||||||
<input type="hidden" name="delete-selected" value="1" />
|
<input type="hidden" name="delete-selected" value="1" />
|
||||||
<?php
|
<?php
|
||||||
foreach( (array)$plugins as $plugin )
|
foreach ( (array)$plugins as $plugin )
|
||||||
echo '<input type="hidden" name="checked[]" value="' . attribute_escape($plugin) . '" />';
|
echo '<input type="hidden" name="checked[]" value="' . attribute_escape($plugin) . '" />';
|
||||||
?>
|
?>
|
||||||
<?php wp_nonce_field('bulk-manage-plugins') ?>
|
<?php wp_nonce_field('bulk-manage-plugins') ?>
|
||||||
@ -144,7 +146,7 @@ if( !empty($action) ) {
|
|||||||
<div id="files-list" style="display:none;">
|
<div id="files-list" style="display:none;">
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
foreach( (array)$files_to_delete as $file )
|
foreach ( (array)$files_to_delete as $file )
|
||||||
echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
|
echo '<li>' . str_replace(WP_PLUGIN_DIR, '', $file) . '</li>';
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
@ -172,8 +174,8 @@ $title = __('Manage Plugins');
|
|||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
|
|
||||||
$invalid = validate_active_plugins();
|
$invalid = validate_active_plugins();
|
||||||
if( !empty($invalid) )
|
if ( !empty($invalid) )
|
||||||
foreach($invalid as $plugin_file => $error)
|
foreach ( $invalid as $plugin_file => $error )
|
||||||
echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), wp_specialchars($plugin_file), $error->get_error_message()) . '</p></div>';
|
echo '<div id="message" class="error"><p>' . sprintf(__('The plugin <code>%s</code> has been <strong>deactivated</strong> due to an error: %s'), wp_specialchars($plugin_file), $error->get_error_message()) . '</p></div>';
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -215,13 +217,13 @@ $recent_plugins = array();
|
|||||||
$recently_activated = (array) get_option('recently_activated');
|
$recently_activated = (array) get_option('recently_activated');
|
||||||
|
|
||||||
//Clean out any plugins which were deactivated over a week ago.
|
//Clean out any plugins which were deactivated over a week ago.
|
||||||
foreach( $recently_activated as $key => $time )
|
foreach ( $recently_activated as $key => $time )
|
||||||
if( $time + (7*24*60*60) < time() ) //1 week
|
if ( $time + (7*24*60*60) < time() ) //1 week
|
||||||
unset($recently_activated[ $key ]);
|
unset($recently_activated[ $key ]);
|
||||||
if( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
|
if ( $recently_activated != get_option('recently_activated') ) //If array changed, update it.
|
||||||
update_option('recently_activated', $recently_activated);
|
update_option('recently_activated', $recently_activated);
|
||||||
|
|
||||||
foreach( (array)$all_plugins as $plugin_file => $plugin_data) {
|
foreach ( (array)$all_plugins as $plugin_file => $plugin_data) {
|
||||||
|
|
||||||
//Translate, Apply Markup, Sanitize HTML
|
//Translate, Apply Markup, Sanitize HTML
|
||||||
$plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true);
|
$plugin_data = _get_plugin_data_markup_translate($plugin_data, true, true);
|
||||||
@ -272,15 +274,15 @@ function print_plugins_table($plugins, $context = '') {
|
|||||||
<tbody class="plugins">
|
<tbody class="plugins">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if( empty($plugins) ) {
|
if ( empty($plugins) ) {
|
||||||
echo '<tr>
|
echo '<tr>
|
||||||
<td colspan="6">' . __('No plugins to show') . '</td>
|
<td colspan="6">' . __('No plugins to show') . '</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
foreach( (array)$plugins as $plugin_file => $plugin_data) {
|
foreach ( (array)$plugins as $plugin_file => $plugin_data) {
|
||||||
$action_links = array();
|
$action_links = array();
|
||||||
|
|
||||||
if( 'active' == $context )
|
if ( 'active' == $context )
|
||||||
$action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '" class="delete">' . __('Deactivate') . '</a>';
|
$action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=deactivate&plugin=' . $plugin_file, 'deactivate-plugin_' . $plugin_file) . '" title="' . __('Deactivate this plugin') . '" class="delete">' . __('Deactivate') . '</a>';
|
||||||
else //Inactive or Recently deactivated
|
else //Inactive or Recently deactivated
|
||||||
$action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
|
$action_links[] = '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin') . '" class="edit">' . __('Activate') . '</a>';
|
||||||
|
Loading…
Reference in New Issue
Block a user