diff --git a/admin/plugins.php b/admin/plugins.php index 71ad39ad..0b4ab4b0 100644 --- a/admin/plugins.php +++ b/admin/plugins.php @@ -38,21 +38,16 @@ if( isset( $_GET['action'] ) ) { $result = 'No plugin specified, or not a valid plugin'; } - $result = yourls_notice_box( $result ); - yourls_add_action('admin_notices', create_function( '', "echo '$result';" ) ); + yourls_add_notice( $result ); } // Handle message upon succesfull (de)activation if( isset( $_GET['success'] ) ) { if( $_GET['success'] == 'activated' OR $_GET['success'] == 'deactivated' ) { - $result = yourls_notice_box( 'Plugin '.$_GET['success'] ); - yourls_add_action('admin_notices', create_function( '', "echo '$result';" ) ); + yourls_add_notice( 'Plugin '.$_GET['success'] ); } } - -// TODO: UPDATE PLUGIN LIST IF ONE IS MISSING ? - yourls_html_head( 'plugins' ); yourls_html_logo(); yourls_html_menu(); @@ -134,7 +129,7 @@ yourls_html_menu(); yourls_defaultorder = 0; -

If something goes wrong after you activate a plugin, simply delete its directory, or rename the plugin file to something different than plugin.php. +

If something goes wrong after you activate a plugin and you cannot use YOURLS or access this page, simply rename or delete its directory, or rename the plugin file to something different than plugin.php.

\ No newline at end of file diff --git a/includes/functions-plugins.php b/includes/functions-plugins.php index b98ac133..9fc2b70d 100644 --- a/includes/functions-plugins.php +++ b/includes/functions-plugins.php @@ -322,12 +322,21 @@ function yourls_load_plugins() { if( !$active_plugins OR ( defined( 'YOURLS_INSTALLING' ) AND YOURLS_INSTALLING ) OR yourls_upgrade_is_needed() ) return; - foreach( (array)$active_plugins as $plugin ) { + foreach( (array)$active_plugins as $key=>$plugin ) { if( yourls_validate_plugin_file( YOURLS_PLUGINDIR.'/'.$plugin ) ) { include_once( YOURLS_PLUGINDIR.'/'.$plugin ); $ydb->plugins[] = $plugin; + unset( $active_plugins[$key] ); } } + + // $active_plugins should be empty now, if not, a plugin could not be find: remove it + if( count( $active_plugins ) ) { + $missing = ''.join( ', ', $active_plugins ).''; + yourls_update_option( 'active_plugins', $ydb->plugins ); + $message = 'Could not find and deactivated '. yourls_plural( 'plugin', count( $active_plugins ) ) .' '. $missing; + yourls_add_notice( $message ); + } } /** @@ -421,4 +430,4 @@ function yourls_plugin_basename( $file ) { $plugindir = yourls_sanitize_filename( YOURLS_PLUGINDIR ); $file = str_replace( $plugindir, '', $file ); return trim( $file, '/' ); -} \ No newline at end of file +}