2004-03-25 08:05:52 +01:00
< ? php
2004-10-19 05:03:06 +02:00
require_once ( 'admin.php' );
2004-03-25 08:05:52 +01:00
2004-08-09 09:17:54 +02:00
if ( isset ( $_GET [ 'action' ]) ) {
2004-03-25 22:04:36 +01:00
if ( 'activate' == $_GET [ 'action' ]) {
2006-05-27 01:08:05 +02:00
check_admin_referer ( 'activate-plugin_' . $_GET [ 'plugin' ]);
2006-08-30 23:46:31 +02:00
$current = get_option ( 'active_plugins' );
2006-11-08 03:20:02 +01:00
$plugin = trim ( $_GET [ 'plugin' ]);
if ( validate_file ( $plugin ) )
wp_die ( __ ( 'Invalid plugin.' ));
if ( ! file_exists ( ABSPATH . PLUGINDIR . '/' . $plugin ) )
wp_die ( __ ( 'Plugin file does not exist.' ));
if ( ! in_array ( $plugin , $current )) {
2007-01-25 21:45:20 +01:00
wp_redirect ( 'plugins.php?error=true' ); // we'll override this later if the plugin can be included without fatal error
2007-04-11 05:23:23 +02:00
ob_start ();
2007-01-25 21:45:20 +01:00
@ include ( ABSPATH . PLUGINDIR . '/' . $plugin );
2006-11-08 03:20:02 +01:00
$current [] = $plugin ;
2005-07-04 23:53:26 +02:00
sort ( $current );
update_option ( 'active_plugins' , $current );
2006-11-08 03:20:02 +01:00
do_action ( 'activate_' . $plugin );
2007-04-11 05:23:23 +02:00
ob_end_clean ();
2004-09-26 20:12:12 +02:00
}
2007-01-25 21:45:20 +01:00
wp_redirect ( 'plugins.php?activate=true' ); // overrides the ?error=true one above
2005-07-04 23:53:26 +02:00
} else if ( 'deactivate' == $_GET [ 'action' ]) {
2006-05-27 01:08:05 +02:00
check_admin_referer ( 'deactivate-plugin_' . $_GET [ 'plugin' ]);
2006-08-30 23:46:31 +02:00
$current = get_option ( 'active_plugins' );
2004-08-09 09:17:54 +02:00
array_splice ( $current , array_search ( $_GET [ 'plugin' ], $current ), 1 ); // Array-fu!
update_option ( 'active_plugins' , $current );
2005-07-04 23:53:26 +02:00
do_action ( 'deactivate_' . trim ( $_GET [ 'plugin' ] ));
2006-06-27 07:38:56 +02:00
wp_redirect ( 'plugins.php?deactivate=true' );
2007-03-31 22:56:54 +02:00
} elseif ( $_GET [ 'action' ] == 'deactivate-all' ) {
check_admin_referer ( 'deactivate-all' );
$current = get_option ( 'active_plugins' );
foreach ( $current as $plugin ) {
array_splice ( $current , array_search ( $plugin , $current ), 1 );
do_action ( 'deactivate_' . $plugin );
}
update_option ( 'active_plugins' , array ());
wp_redirect ( 'plugins.php?deactivate-all=true' );
2004-03-25 22:04:36 +01:00
}
2005-12-28 01:16:40 +01:00
exit ;
2004-03-25 22:04:36 +01:00
}
2006-11-18 08:31:29 +01:00
$title = __ ( 'Manage Plugins' );
2004-03-25 08:05:52 +01:00
require_once ( 'admin-header.php' );
2004-03-25 09:10:26 +01:00
// Clean up options
2004-08-09 09:17:54 +02:00
// If any plugins don't exist, axe 'em
2004-03-25 09:10:26 +01:00
2006-08-30 23:46:31 +02:00
$check_plugins = get_option ( 'active_plugins' );
2005-04-04 04:48:18 +02:00
// Sanity check. If the active plugin list is not an array, make it an
// empty array.
if ( ! is_array ( $check_plugins ) ) {
$check_plugins = array ();
2006-02-12 08:53:23 +01:00
update_option ( 'active_plugins' , $check_plugins );
2005-04-04 04:48:18 +02:00
}
// If a plugin file does not exist, remove it from the list of active
// plugins.
2004-03-25 09:10:26 +01:00
foreach ( $check_plugins as $check_plugin ) {
2006-09-21 22:46:39 +02:00
if ( ! file_exists ( ABSPATH . PLUGINDIR . '/' . $check_plugin )) {
2006-08-30 23:46:31 +02:00
$current = get_option ( 'active_plugins' );
2005-10-06 01:19:48 +02:00
$key = array_search ( $check_plugin , $current );
if ( false !== $key && NULL !== $key ) {
unset ( $current [ $key ]);
update_option ( 'active_plugins' , $current );
}
2004-03-25 09:10:26 +01:00
}
}
2004-03-25 08:05:52 +01:00
?>
2004-04-14 21:04:14 +02:00
2007-01-25 21:45:20 +01:00
< ? php if ( isset ( $_GET [ 'error' ]) ) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' ) ?> </p></div>
< ? 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 22:56:54 +02:00
< ? php elseif ( isset ( $_GET [ 'deactivate-all' ])) : ?>
< div id = " message " class = " updated fade " >< p >< ? php _e ( 'All plugins <strong>deactivated</strong>.' ); ?> </p></div>
2004-04-14 21:04:14 +02:00
< ? php endif ; ?>
2004-03-25 08:05:52 +01:00
< div class = " wrap " >
2004-04-24 21:46:11 +02:00
< h2 >< ? php _e ( 'Plugin Management' ); ?> </h2>
2005-08-07 12:45:06 +02: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 08:05:52 +01:00
< ? php
2006-08-30 23:46:31 +02:00
if ( get_option ( 'active_plugins' ) )
$current_plugins = get_option ( 'active_plugins' );
2004-03-25 08:05:52 +01:00
2004-11-26 03:29:45 +01:00
$plugins = get_plugins ();
if ( empty ( $plugins )) {
2005-12-12 23:48:30 +01:00
echo '<p>' ;
2006-12-27 01:51:00 +01:00
_e ( " Couldn’t open plugins directory or there are no plugins available. " ); // TODO: make more helpful
2005-12-12 23:48:30 +01:00
echo '</p>' ;
2004-03-25 08:05:52 +01:00
} else {
?>
2006-10-06 03:14:47 +02:00
< table class = " widefat plugins " >
2006-05-10 22:35:10 +02:00
< thead >
2004-03-25 08:05:52 +01:00
< tr >
2006-09-27 02:51:17 +02:00
< th >< ? php _e ( 'Plugin' ); ?> </th>
< th style = " text-align: center " >< ? php _e ( 'Version' ); ?> </th>
< th >< ? php _e ( 'Description' ); ?> </th>
2006-10-04 08:48:52 +02:00
< th style = " text-align: center " < ? php if ( current_user_can ( 'edit_plugins' ) ) echo ' colspan="2"' ; ?> ><?php _e('Action'); ?></th>
2004-03-25 08:05:52 +01:00
</ tr >
2006-05-10 22:35:10 +02:00
</ thead >
2004-03-25 08:05:52 +01:00
< ? php
2004-05-08 01:56:33 +02:00
$style = '' ;
2006-01-24 08:48:21 +01:00
2004-11-26 03:29:45 +01:00
foreach ( $plugins as $plugin_file => $plugin_data ) {
2005-03-11 17:53:16 +01:00
$style = ( 'class="alternate"' == $style || 'class="alternate active"' == $style ) ? '' : 'alternate' ;
2004-03-25 09:10:26 +01:00
if ( ! empty ( $current_plugins ) && in_array ( $plugin_file , $current_plugins )) {
2006-10-04 08:48:52 +02:00
$toggle = " <a href=' " . wp_nonce_url ( " plugins.php?action=deactivate&plugin= $plugin_file " , 'deactivate-plugin_' . $plugin_file ) . " ' title=' " . __ ( 'Deactivate this plugin' ) . " ' class='delete'> " . __ ( 'Deactivate' ) . " </a> " ;
2005-01-14 21:20:29 +01:00
$plugin_data [ 'Title' ] = " <strong> { $plugin_data [ 'Title' ] } </strong> " ;
2005-03-11 17:53:16 +01:00
$style .= $style == 'alternate' ? ' active' : 'active' ;
2004-03-25 09:10:26 +01:00
} else {
2006-10-04 08:48:52 +02:00
$toggle = " <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 09:10:26 +01:00
}
2006-11-29 10:22:49 +01: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 );
2006-10-04 08:48:52 +02:00
if ( $style != '' )
$style = 'class="' . $style . '"' ;
2007-03-06 18:47:27 +01:00
if ( is_writable ( ABSPATH . PLUGINDIR . '/' . $plugin_file ) )
2006-10-04 08:48:52 +02:00
$edit = " <a href='plugin-editor.php?file= $plugin_file ' title=' " . __ ( 'Open this file in the Plugin Editor' ) . " ' class='edit'> " . __ ( 'Edit' ) . " </a> " ;
else
$edit = '' ;
2004-03-25 08:05:52 +01:00
echo "
< tr $style >
2005-08-07 12:45:06 +02:00
< td class = 'name' > { $plugin_data [ 'Title' ]} </ td >
< td class = 'vers' > { $plugin_data [ 'Version' ]} </ td >
2006-10-06 03:14:47 +02:00
< td class = 'desc' >< p > { $plugin_data [ 'Description' ]} < cite > " .sprintf(__('By %s'), $plugin_data['Author'] ). " .</ cite ></ p ></ td >
2006-10-04 08:48:52 +02:00
< td class = 'togl' > $toggle </ td > " ;
if ( current_user_can ( 'edit_plugins' ) )
echo "
< td > $edit </ td > " ;
echo "
2004-03-25 08:05:52 +01:00
</ tr > " ;
}
?>
2007-03-31 22:56:54 +02:00
< tr >
2007-04-07 18:03:38 +02:00
< td colspan = " 3 " >& nbsp ; </ td >
< td colspan = " 2 " style = " width:12em; " >< a href = " <?php echo wp_nonce_url('plugins.php?action=deactivate-all', 'deactivate-all'); ?> " class = " delete " >< ? php _e ( 'Deactivate All Plugins' ); ?> </a></td>
2007-03-31 22:56:54 +02:00
</ tr >
2004-03-25 08:05:52 +01:00
</ table >
< ? php
}
?>
2005-05-09 13:37:36 +02:00
2006-12-13 20:36:10 +01: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.' ), PLUGINDIR ); ?> </p>
2005-08-07 12:45:06 +02:00
2005-05-09 13:37:36 +02:00
< h2 >< ? php _e ( 'Get More Plugins' ); ?> </h2>
2006-10-06 03:14:47 +02: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>
2006-12-13 20:36:10 +01: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.' ), PLUGINDIR ); ?> </p>
2005-05-09 13:37:36 +02:00
2004-03-25 08:05:52 +01:00
</ div >
< ? php
include ( 'admin-footer.php' );
2004-11-29 18:28:53 +01:00
?>