2004-03-25 02:05:52 -05:00
< ? php
2004-10-18 23:03:06 -04:00
require_once ( 'admin.php' );
2004-03-25 02:05:52 -05:00
2004-08-09 03:17:54 -04:00
if ( isset ( $_GET [ 'action' ]) ) {
2008-01-16 11:45:36 -05:00
if ( isset ( $_GET [ 'plugin' ]) )
$plugin = trim ( $_GET [ 'plugin' ]);
2008-01-09 04:37:27 -05:00
if ( 'activate' == $_GET [ 'action' ] ) {
2006-05-26 19:08:05 -04:00
check_admin_referer ( 'activate-plugin_' . $_GET [ 'plugin' ]);
2008-01-09 04:37:27 -05:00
$result = activate_plugin ( $_GET [ 'plugin' ], 'plugins.php?error=true&plugin=' . $plugin );
if ( is_wp_error ( $result ) )
2007-10-17 13:14:58 -04:00
wp_die ( $result -> get_error_message () );
2007-01-25 15:45:20 -05:00
wp_redirect ( 'plugins.php?activate=true' ); // overrides the ?error=true one above
2008-01-09 04:37:27 -05:00
} elseif ( 'error_scrape' == $_GET [ 'action' ] ) {
2007-06-25 14:57:54 -04:00
check_admin_referer ( 'plugin-activation-error_' . $plugin );
2008-01-09 04:37:27 -05:00
$valid = validate_plugin ( $plugin );
if ( is_wp_error ( $valid ) )
wp_die ( $valid );
2008-01-16 11:46:49 -05:00
error_reporting ( E_ALL ^ E_NOTICE );
@ ini_set ( 'display_errors' , true ); //Ensure that Fatal errors are displayed.
2008-05-27 13:55:24 -04:00
include ( WP_PLUGIN_DIR . '/' . $plugin );
2008-01-09 04:37:27 -05:00
} elseif ( 'deactivate' == $_GET [ 'action' ] ) {
2006-05-26 19:08:05 -04:00
check_admin_referer ( 'deactivate-plugin_' . $_GET [ 'plugin' ]);
2007-10-17 13:14:58 -04:00
deactivate_plugins ( $_GET [ 'plugin' ]);
2006-06-27 01:38:56 -04:00
wp_redirect ( 'plugins.php?deactivate=true' );
2008-01-09 04:37:27 -05:00
} elseif ( 'deactivate-all' == $_GET [ 'action' ] ) {
2007-03-31 16:56:54 -04:00
check_admin_referer ( 'deactivate-all' );
2007-10-17 13:14:58 -04:00
deactivate_all_plugins ();
2007-03-31 16:56:54 -04:00
wp_redirect ( 'plugins.php?deactivate-all=true' );
2008-01-09 04:37:27 -05:00
} elseif ( 'reactivate-all' == $_GET [ 'action' ]) {
check_admin_referer ( 'reactivate-all' );
reactivate_all_plugins ( 'plugins.php?errors=true' );
wp_redirect ( 'plugins.php?reactivate-all=true' ); // overrides the ?error=true one above
2004-03-25 16:04:36 -05:00
}
2008-01-09 04:37:27 -05:00
2005-12-27 19:16:40 -05:00
exit ;
2004-03-25 16:04:36 -05:00
}
2006-11-18 02:31:29 -05:00
$title = __ ( 'Manage Plugins' );
2004-03-25 02:05:52 -05:00
require_once ( 'admin-header.php' );
2008-01-09 04:37:27 -05:00
validate_active_plugins ();
2005-04-03 22:48:18 -04:00
2004-03-25 02:05:52 -05:00
?>
2004-04-14 15:04:14 -04:00
2007-01-25 15:45:20 -05:00
< ? php if ( isset ( $_GET [ 'error' ]) ) : ?>
2007-06-25 14:57:54 -04:00
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' ) ?> </p>
< ? php
$plugin = trim ( $_GET [ 'plugin' ]);
2008-01-16 11:46:49 -05:00
if ( wp_verify_nonce ( $_GET [ '_error_nonce' ], 'plugin-activation-error_' . $plugin ) ) { ?>
2007-06-25 14:57:54 -04:00
< iframe style = " border:0 " width = " 100% " height = " 70px " src = " <?php bloginfo('wpurl'); ?>/wp-admin/plugins.php?action=error_scrape&plugin=<?php echo attribute_escape( $plugin ); ?>&_wpnonce=<?php echo attribute_escape( $_GET['_error_nonce'] ); ?> " ></ iframe >
< ? php
}
?>
</ div >
2008-01-09 04:37:27 -05:00
< ? php elseif ( isset ( $_GET [ 'errors' ]) ) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Some plugins could not be reactivated because they triggered a <strong>fatal error</strong>.' ) ?> </p></div>
2007-01-25 15:45:20 -05:00
< ? php elseif ( isset ( $_GET [ 'activate' ]) ) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin <strong>activated</strong>.' ) ?> </p></div>
< ? php elseif ( isset ( $_GET [ 'deactivate' ]) ) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin <strong>deactivated</strong>.' ) ?> </p></div>
2007-03-31 16:56:54 -04:00
< ? php elseif ( isset ( $_GET [ 'deactivate-all' ])) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'All plugins <strong>deactivated</strong>.' ); ?> </p></div>
2008-01-09 04:37:27 -05:00
< ? php elseif ( isset ( $_GET [ 'reactivate-all' ])) : ?>
2008-03-21 15:40:06 -04:00
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugins <strong>reactivated</strong>.' ); ?> </p></div>
2004-04-14 15:04:14 -04:00
< ? php endif ; ?>
2004-03-25 02:05:52 -05:00
< div class = " wrap " >
2004-04-24 15:46:11 -04:00
< h2 >< ? php _e ( 'Plugin Management' ); ?> </h2>
2005-08-07 06:45:06 -04:00
< p >< ? php _e ( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ); ?> </p>
2004-03-25 02:05:52 -05:00
< ? php
2004-11-25 21:29:45 -05:00
$plugins = get_plugins ();
if ( empty ( $plugins )) {
2005-12-12 17:48:30 -05:00
echo '<p>' ;
2006-12-26 19:51:00 -05:00
_e ( " Couldn’t open plugins directory or there are no plugins available. " ); // TODO: make more helpful
2005-12-12 17:48:30 -05:00
echo '</p>' ;
2004-03-25 02:05:52 -05:00
} else {
?>
2008-02-27 14:18:21 -05:00
< div class = " tablenav " >
2008-03-14 19:58:31 -04:00
< div class = " alignleft " >
2008-02-27 14:18:21 -05:00
< ? php
$active = get_option ( 'active_plugins' );
$inactive = get_option ( 'deactivated_plugins' );
if ( ! empty ( $active ) ) {
?>
2008-04-28 11:17:55 -04:00
< a class = " button-secondary delete " href = " <?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?> " >< ? php _e ( 'Deactivate All Plugins' ); ?> </a>
2008-02-27 14:18:21 -05:00
< ? php
} elseif ( empty ( $active ) && ! empty ( $inactive ) ) {
?>
2008-04-28 11:17:55 -04:00
< a class = " button-secondary delete " href = " <?php echo wp_nonce_url('plugins.php?action=reactivate-all', 'reactivate-all'); ?> " >< ? php _e ( 'Reactivate Plugins' ); ?> </a>
2008-02-27 14:18:21 -05:00
< ? php
} // endif active/inactive plugin check
?>
</ div >
2008-03-14 19:58:31 -04:00
< br class = " clear " />
2008-02-27 14:18:21 -05:00
</ div >
2008-03-14 19:58:31 -04:00
< br class = " clear " />
2008-02-27 14:18:21 -05:00
< table class = " widefat " >
2006-05-10 16:35:10 -04:00
< thead >
2004-03-25 02:05:52 -05:00
< tr >
2006-09-26 20:51:17 -04:00
< th >< ? php _e ( 'Plugin' ); ?> </th>
2008-03-14 19:58:31 -04:00
< th class = " num " >< ? php _e ( 'Version' ); ?> </th>
2006-09-26 20:51:17 -04:00
< th >< ? php _e ( 'Description' ); ?> </th>
2008-03-26 18:27:27 -04:00
< th class = " status " >< ? php _e ( 'Status' ) ?> </th>
2008-03-25 23:33:14 -04:00
< th class = " action-links " >< ? php _e ( 'Action' ); ?> </th>
2004-03-25 02:05:52 -05:00
</ tr >
2006-05-10 16:35:10 -04:00
</ thead >
2008-02-27 14:18:21 -05:00
< tbody id = " plugins " >
2004-03-25 02:05:52 -05:00
< ? php
2004-11-25 21:29:45 -05:00
foreach ( $plugins as $plugin_file => $plugin_data ) {
2008-03-25 23:59:40 -04:00
$action_links = array ();
$style = '' ;
2004-03-25 03:10:26 -05:00
2008-03-26 00:23:02 -04:00
if ( is_plugin_active ( $plugin_file ) ) {
2008-03-25 23:59:40 -04:00
$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> " ;
$style = 'active' ;
2004-03-25 03:10:26 -05:00
} else {
2008-03-25 23:59:40 -04:00
$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> " ;
2004-03-25 03:10:26 -05:00
}
2008-05-27 13:55:24 -04:00
if ( current_user_can ( 'edit_plugins' ) && is_writable ( WP_PLUGIN_DIR . '/' . $plugin_file ) )
2008-03-25 23:59:40 -04:00
$action_links [] = " <a href='plugin-editor.php?file= $plugin_file ' title=' " . __ ( 'Open this file in the Plugin Editor' ) . " ' class='edit'> " . __ ( 'Edit' ) . " </a> " ;
2006-11-29 04:22:49 -05:00
$plugins_allowedtags = array ( 'a' => array ( 'href' => array (), 'title' => array ()), 'abbr' => array ( 'title' => array ()), 'acronym' => array ( 'title' => array ()), 'code' => array (), 'em' => array (), 'strong' => array ());
// Sanitize all displayed data
$plugin_data [ 'Title' ] = wp_kses ( $plugin_data [ 'Title' ], $plugins_allowedtags );
$plugin_data [ 'Version' ] = wp_kses ( $plugin_data [ 'Version' ], $plugins_allowedtags );
$plugin_data [ 'Description' ] = wp_kses ( $plugin_data [ 'Description' ], $plugins_allowedtags );
$plugin_data [ 'Author' ] = wp_kses ( $plugin_data [ 'Author' ], $plugins_allowedtags );
2008-03-25 23:59:40 -04:00
$author = ( empty ( $plugin_data [ 'Author' ]) ) ? '' : ' <cite>' . sprintf ( __ ( 'By %s' ), $plugin_data [ 'Author' ] ) . '.</cite>' ;
2006-11-29 04:22:49 -05:00
2006-10-04 02:48:52 -04:00
if ( $style != '' )
2008-03-25 23:59:40 -04:00
$style = ' class="' . $style . '"' ;
2006-10-04 02:48:52 -04:00
2008-03-25 23:59:40 -04:00
$action_links = apply_filters ( 'plugin_action_links' , $action_links , $plugin_file , $plugin_info );
2007-09-07 14:53:56 -04:00
2004-03-25 02:05:52 -05:00
echo "
2008-03-25 23:59:40 -04:00
< tr $style >
2005-08-07 06:45:06 -04:00
< td class = 'name' > { $plugin_data [ 'Title' ]} </ td >
< td class = 'vers' > { $plugin_data [ 'Version' ]} </ td >
2007-09-07 14:53:56 -04:00
< td class = 'desc' >< p > { $plugin_data [ 'Description' ]} $author </ p ></ td >
2008-03-26 00:23:02 -04:00
< td class = 'status' > " ;
if ( is_plugin_active ( $plugin_file ) )
2008-03-26 18:27:27 -04:00
echo __ ( '<span class="active">Active</span>' );
2008-03-26 00:23:02 -04:00
else
2008-03-26 18:27:27 -04:00
_e ( '<span class="inactive">Inactive</span>' );
2008-03-26 00:23:02 -04:00
echo " </td>
2008-03-25 23:33:14 -04:00
< td class = 'togl action-links' > $toggle " ;
2008-03-25 23:59:40 -04:00
if ( ! empty ( $action_links ) )
echo implode ( ' | ' , $action_links );
2008-03-25 23:33:14 -04:00
echo " </td>
2004-03-25 02:05:52 -05:00
</ tr > " ;
2007-08-22 06:48:48 -04:00
do_action ( 'after_plugin_row' , $plugin_file );
2004-03-25 02:05:52 -05:00
}
?>
2008-02-27 14:18:21 -05:00
</ tbody >
2004-03-25 02:05:52 -05:00
</ table >
2008-02-27 14:18:21 -05:00
2004-03-25 02:05:52 -05:00
< ? php
}
?>
2005-05-09 07:37:36 -04:00
2008-05-27 13:55:24 -04:00
< p >< ? php printf ( __ ( 'If something goes wrong with a plugin and you can’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.' ), WP_PLUGIN_DIR ); ?> </p>
2005-08-07 06:45:06 -04:00
2005-05-09 07:37:36 -04:00
< h2 >< ? php _e ( 'Get More Plugins' ); ?> </h2>
2006-10-05 21:14:47 -04:00
< p >< ? php _e ( 'You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.' ); ?> </p>
2008-05-27 13:55:24 -04:00
< p >< ? php printf ( __ ( 'To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.' ), WP_PLUGIN_DIR ); ?> </p>
2005-05-09 07:37:36 -04:00
2004-03-25 02:05:52 -05:00
</ div >
< ? php
include ( 'admin-footer.php' );
2004-11-29 12:28:53 -05:00
?>