2004-03-25 02:05:52 -05:00
< ? php
2004-05-09 01:47:02 -04:00
if ( isset ( $_GET [ 'action' ])) {
2004-03-25 16:04:36 -05:00
$standalone = 1 ;
require_once ( 'admin-header.php' );
2004-05-17 16:16:54 -04:00
check_admin_referer ();
2004-03-25 16:04:36 -05:00
if ( 'activate' == $_GET [ 'action' ]) {
$current = " \n " . get_settings ( 'active_plugins' ) . " \n " ;
$current = preg_replace ( " |( \n )+ \ s*| " , " \n " , $current );
$current = trim ( $current ) . " \n " . trim ( $_GET [ 'plugin' ]);
$current = trim ( $current );
2004-04-25 04:11:05 -04:00
$current = preg_replace ( " | \n \ s*| " , " \n " , $current ); // I don't know where this is coming from
2004-03-25 16:04:36 -05:00
update_option ( 'active_plugins' , $current );
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?activate=true' );
2004-03-25 16:04:36 -05:00
}
if ( 'deactivate' == $_GET [ 'action' ]) {
$current = " \n " . get_settings ( 'active_plugins' ) . " \n " ;
$current = str_replace ( " \n " . $_GET [ 'plugin' ], '' , $current );
$current = preg_replace ( " |( \n )+ \ s*| " , " \n " , $current );
update_option ( 'active_plugins' , trim ( $current ));
2004-04-14 15:04:14 -04:00
header ( 'Location: plugins.php?deactivate=true' );
2004-03-25 16:04:36 -05:00
}
}
2004-04-25 19:10:07 -04:00
require_once ( '../wp-includes/wp-l10n.php' );
$title = __ ( 'Manage Plugins' );
2004-03-25 02:05:52 -05:00
require_once ( 'admin-header.php' );
2004-03-25 03:10:26 -05:00
if ( $user_level < 9 ) // Must be at least level 9
2004-04-25 19:10:07 -04:00
die ( __ ( " Sorry, you must be at least a level 8 user to modify plugins. " ));
2004-03-25 03:10:26 -05:00
// Clean up options
// if any files are in the option that don't exist, axe 'em
$check_plugins = explode ( " \n " , ( get_settings ( 'active_plugins' )));
foreach ( $check_plugins as $check_plugin ) {
if ( ! file_exists ( ABSPATH . 'wp-content/plugins/' . $check_plugin )) {
$current = get_settings ( 'active_plugins' ) . " \n " ;
$current = str_replace ( $check_plugin . " \n " , '' , $current );
$current = preg_replace ( " | \n +| " , " \n " , $current );
update_option ( 'active_plugins' , trim ( $current ));
}
}
2004-03-25 02:05:52 -05:00
?>
2004-04-14 15:04:14 -04:00
2004-05-07 19:56:33 -04:00
< ? php if ( isset ( $_GET [ 'activate' ])) : ?>
2004-04-25 19:10:07 -04:00
< div class = " updated " >< p >< ? php _e ( 'Plugin <strong>activated</strong>.' ) ?> </p>
2004-04-14 15:04:14 -04:00
</ div >
< ? php endif ; ?>
2004-05-07 19:56:33 -04:00
< ? php if ( isset ( $_GET [ 'deactivate' ])) : ?>
2004-04-25 19:10:07 -04:00
< div class = " updated " >< p >< ? php _e ( 'Plugin <strong>deactivated</strong>.' ) ?> </p>
2004-04-14 15:04:14 -04:00
</ div >
< ? 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>
2004-06-13 12:00:16 -04:00
< p >< ? php _e ( 'Plugins are files you usually download separately from WordPress that add functionality. To install a plugin you generally just need to put the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is installed, you may activate it or deactivate it here.' ); ?> </p>
2004-03-25 02:05:52 -05:00
< ? php
// Files in wp-content/plugins directory
$plugins_dir = @ dir ( ABSPATH . 'wp-content/plugins' );
if ( $plugins_dir ) {
while (( $file = $plugins_dir -> read ()) !== false ) {
2004-04-14 15:04:14 -04:00
if ( ! preg_match ( '|^\.+$|' , $file ) && preg_match ( '|\.php$|' , $file ) )
$plugin_files [] = $file ;
2004-03-25 02:05:52 -05:00
}
}
if ( '' != trim ( get_settings ( 'active_plugins' ))) {
2004-03-25 03:10:26 -05:00
$current_plugins = explode ( " \n " , ( get_settings ( 'active_plugins' )));
2004-03-25 02:05:52 -05:00
}
if ( ! $plugins_dir || ! $plugin_files ) {
2004-04-24 15:46:11 -04:00
_e ( " <p>Couldn't open plugins directory or there are no plugins available.</p> " ); // TODO: make more helpful
2004-03-25 02:05:52 -05:00
} else {
?>
< table width = " 100% " cellpadding = " 3 " cellspacing = " 3 " >
< tr >
2004-04-24 15:46:11 -04:00
< th >< ? php _e ( 'Plugin' ); ?> </th>
< th >< ? php _e ( 'Version' ); ?> </th>
< th >< ? php _e ( 'Author' ); ?> </th>
< th >< ? php _e ( 'Description' ); ?> </th>
< th >< ? php _e ( 'Action' ); ?> </th>
2004-03-25 02:05:52 -05:00
</ tr >
< ? php
sort ( $plugin_files ); // Alphabetize by filename. Better way?
2004-05-07 19:56:33 -04:00
$style = '' ;
2004-03-25 02:05:52 -05:00
foreach ( $plugin_files as $plugin_file ) {
$plugin_data = implode ( '' , file ( ABSPATH . '/wp-content/plugins/' . $plugin_file ));
preg_match ( " |Plugin Name:(.*)|i " , $plugin_data , $plugin_name );
preg_match ( " |Plugin URI:(.*)|i " , $plugin_data , $plugin_uri );
preg_match ( " |Description:(.*)|i " , $plugin_data , $description );
preg_match ( " |Author:(.*)|i " , $plugin_data , $author_name );
preg_match ( " |Author URI:(.*)|i " , $plugin_data , $author_uri );
2004-05-07 19:56:33 -04:00
if ( preg_match ( " |Version:(.*)|i " , $plugin_data , $version ) )
$version = $version [ 1 ];
else
$version = '' ;
$description = wptexturize ( $description [ 1 ]);
2004-03-25 02:05:52 -05:00
if ( '' == $plugin_uri ) {
$plugin = $plugin_name [ 1 ];
} else {
2004-05-07 19:56:33 -04:00
$plugin = __ ( " <a href=' { $plugin_uri [ 1 ] } ' title='Visit plugin homepage'> { $plugin_name [ 1 ] } </a> " );
2004-03-25 02:05:52 -05:00
}
if ( '' == $author_uri ) {
$author = $author_name [ 1 ];
} else {
2004-05-07 19:56:33 -04:00
$author = __ ( " <a href=' { $author_uri [ 1 ] } ' title='Visit author homepage'> { $author_name [ 1 ] } </a> " );
2004-03-25 02:05:52 -05:00
}
$style = ( 'class="alternate"' == $style ) ? '' : 'class="alternate"' ;
2004-03-25 03:10:26 -05:00
if ( ! empty ( $current_plugins ) && in_array ( $plugin_file , $current_plugins )) {
2004-04-24 15:46:11 -04:00
$action = __ ( " <a href='plugins.php?action=deactivate&plugin= $plugin_file ' title='Deactivate this plugin' class='delete'>Deactivate</a> " );
$plugin = __ ( " <strong> $plugin </strong> " );
2004-03-25 03:10:26 -05:00
} else {
2004-04-24 15:46:11 -04:00
$action = __ ( " <a href='plugins.php?action=activate&plugin= $plugin_file ' title='Activate this plugin' class='edit'>Activate</a> " );
2004-03-25 03:10:26 -05:00
}
2004-03-25 02:05:52 -05:00
echo "
< tr $style >
< td > $plugin </ td >
2004-05-07 19:56:33 -04:00
< td > $version </ td >
2004-03-25 02:05:52 -05:00
< td > $author </ td >
< td > $description </ td >
2004-03-25 03:10:26 -05:00
< td > $action </ td >
2004-03-25 02:05:52 -05:00
</ tr > " ;
}
?>
</ table >
< ? php
}
?>
</ div >
< ? php
include ( 'admin-footer.php' );
2004-05-07 19:56:33 -04:00
?>