Changeset 8585 for trunk/wp-admin/includes/plugin.php
- Timestamp:
- 08/07/2008 11:39:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r8514 r8585 158 158 } 159 159 160 function is_plugin_active($plugin){ 160 /** 161 * Check whether the plugin is active by checking the active_plugins list. 162 * 163 * @since 2.5.0 164 * 165 * @param string $plugin Base plugin path from plugins directory. 166 * @return bool True, if in the active plugins list. False, not in the list. 167 */ 168 function is_plugin_active($plugin) { 161 169 return in_array($plugin, get_option('active_plugins')); 162 170 } … … 278 286 279 287 foreach( $plugins as $plugin_file ) { 288 // Run Uninstall hook 289 if ( is_uninstallable_plugin( $plugin_file ) ) 290 uninstall_plugin($plugin_file); 291 280 292 $this_plugin_dir = trailingslashit( dirname($plugins_dir . $plugin_file) ); 281 293 // If plugin is in its own directory, recursively delete the directory. … … 327 339 328 340 return 0; 341 } 342 343 /** 344 * Whether the plugin can be uninstalled. 345 * 346 * @since {@internal Version Unknown}} 347 * 348 * @param string $plugin Plugin path to check. 349 * @return bool Whether plugin can be uninstalled. 350 */ 351 function is_uninstallable_plugin($plugin) { 352 $file = plugin_basename($plugin); 353 354 $uninstallable_plugins = (array) get_option('uninstall_plugins'); 355 if ( isset( $uninstallable_plugins[$file] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) 356 return true; 357 358 return false; 359 } 360 361 /** 362 * Uninstall a single plugin. 363 * 364 * Calls the uninstall hook, if it is available. 365 * 366 * @param string $plugin Relative plugin path from Plugin Directory. 367 */ 368 function uninstall_plugin($plugin) { 369 $file = plugin_basename($plugin); 370 371 $uninstallable_plugins = (array) get_option('uninstall_plugins'); 372 if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) { 373 if ( isset( $uninstallable_plugins[$file] ) ) { 374 unset($uninstallable_plugins[$file]); 375 update_option('uninstall_plugins', $uninstallable_plugins); 376 } 377 unset($uninstallable_plugins); 378 379 define('WP_UNINSTALL_PLUGIN', $file); 380 include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php'; 381 382 return true; 383 } 384 385 if ( isset( $uninstallable_plugins[$file] ) ) { 386 $callable = $uninstallable_plugins[$file]; 387 unset($uninstallable_plugins[$file]); 388 update_option('uninstall_plugins', $uninstallable_plugins); 389 unset($uninstallable_plugins); 390 391 include WP_PLUGIN_DIR . '/' . $file; 392 393 add_action( 'uninstall_' . $file, $callable ); 394 do_action( 'uninstall_' . $file ); 395 } 329 396 } 330 397
Note: See TracChangeset
for help on using the changeset viewer.