[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Plugins administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once __DIR__ . '/admin.php'; 11 12 if ( ! current_user_can( 'activate_plugins' ) ) { 13 wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) ); 14 } 15 16 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); 17 $pagenum = $wp_list_table->get_pagenum(); 18 19 $action = $wp_list_table->current_action(); 20 21 $plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : ''; 22 $s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : ''; 23 24 // Clean up request URI from temporary args for screen options/paging uri's to work as expected. 25 $query_args_to_remove = array( 26 'error', 27 'deleted', 28 'activate', 29 'activate-multi', 30 'deactivate', 31 'deactivate-multi', 32 'enabled-auto-update', 33 'disabled-auto-update', 34 'enabled-auto-update-multi', 35 'disabled-auto-update-multi', 36 '_error_nonce', 37 ); 38 39 $_SERVER['REQUEST_URI'] = remove_query_arg( $query_args_to_remove, $_SERVER['REQUEST_URI'] ); 40 41 wp_enqueue_script( 'updates' ); 42 43 WP_Plugin_Dependencies::initialize(); 44 45 if ( $action ) { 46 47 switch ( $action ) { 48 case 'activate': 49 if ( ! current_user_can( 'activate_plugin', $plugin ) ) { 50 wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) ); 51 } 52 53 if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) { 54 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 55 exit; 56 } 57 58 check_admin_referer( 'activate-plugin_' . $plugin ); 59 60 $result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() ); 61 if ( is_wp_error( $result ) ) { 62 if ( 'unexpected_output' === $result->get_error_code() ) { 63 $redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" ); 64 wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); 65 exit; 66 } else { 67 wp_die( $result ); 68 } 69 } 70 71 if ( ! is_network_admin() ) { 72 $recent = (array) get_option( 'recently_activated' ); 73 unset( $recent[ $plugin ] ); 74 update_option( 'recently_activated', $recent ); 75 } else { 76 $recent = (array) get_site_option( 'recently_activated' ); 77 unset( $recent[ $plugin ] ); 78 update_site_option( 'recently_activated', $recent ); 79 } 80 81 if ( isset( $_GET['from'] ) && 'import' === $_GET['from'] ) { 82 // Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix. 83 wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); 84 } elseif ( isset( $_GET['from'] ) && 'press-this' === $_GET['from'] ) { 85 wp_redirect( self_admin_url( 'press-this.php' ) ); 86 } else { 87 // Overrides the ?error=true one above. 88 wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); 89 } 90 exit; 91 92 case 'activate-selected': 93 if ( ! current_user_can( 'activate_plugins' ) ) { 94 wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) ); 95 } 96 97 check_admin_referer( 'bulk-plugins' ); 98 99 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); 100 101 if ( is_network_admin() ) { 102 foreach ( $plugins as $i => $plugin ) { 103 // Only activate plugins which are not already network activated. 104 if ( is_plugin_active_for_network( $plugin ) ) { 105 unset( $plugins[ $i ] ); 106 } 107 } 108 } else { 109 foreach ( $plugins as $i => $plugin ) { 110 // Only activate plugins which are not already active and are not network-only when on Multisite. 111 if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) { 112 unset( $plugins[ $i ] ); 113 } 114 // Only activate plugins which the user can activate. 115 if ( ! current_user_can( 'activate_plugin', $plugin ) ) { 116 unset( $plugins[ $i ] ); 117 } 118 } 119 } 120 121 if ( empty( $plugins ) ) { 122 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 123 exit; 124 } 125 126 activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() ); 127 128 if ( ! is_network_admin() ) { 129 $recent = (array) get_option( 'recently_activated' ); 130 } else { 131 $recent = (array) get_site_option( 'recently_activated' ); 132 } 133 134 foreach ( $plugins as $plugin ) { 135 unset( $recent[ $plugin ] ); 136 } 137 138 if ( ! is_network_admin() ) { 139 update_option( 'recently_activated', $recent ); 140 } else { 141 update_site_option( 'recently_activated', $recent ); 142 } 143 144 wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) ); 145 exit; 146 147 case 'update-selected': 148 check_admin_referer( 'bulk-plugins' ); 149 150 if ( isset( $_GET['plugins'] ) ) { 151 $plugins = explode( ',', wp_unslash( $_GET['plugins'] ) ); 152 } elseif ( isset( $_POST['checked'] ) ) { 153 $plugins = (array) wp_unslash( $_POST['checked'] ); 154 } else { 155 $plugins = array(); 156 } 157 158 // Used in the HTML title tag. 159 $title = __( 'Update Plugins' ); 160 $parent_file = 'plugins.php'; 161 162 wp_enqueue_script( 'updates' ); 163 require_once ABSPATH . 'wp-admin/admin-header.php'; 164 165 echo '<div class="wrap">'; 166 echo '<h1>' . esc_html( $title ) . '</h1>'; 167 168 $url = self_admin_url( 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ) ); 169 $url = wp_nonce_url( $url, 'bulk-update-plugins' ); 170 171 echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; 172 echo '</div>'; 173 require_once ABSPATH . 'wp-admin/admin-footer.php'; 174 exit; 175 176 case 'error_scrape': 177 if ( ! current_user_can( 'activate_plugin', $plugin ) ) { 178 wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) ); 179 } 180 181 check_admin_referer( 'plugin-activation-error_' . $plugin ); 182 183 $valid = validate_plugin( $plugin ); 184 if ( is_wp_error( $valid ) ) { 185 wp_die( $valid ); 186 } 187 188 if ( ! WP_DEBUG ) { 189 error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); 190 } 191 192 ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed. 193 // Go back to "sandbox" scope so we get the same errors as before. 194 plugin_sandbox_scrape( $plugin ); 195 /** This action is documented in wp-admin/includes/plugin.php */ 196 do_action( "activate_{$plugin}" ); 197 exit; 198 199 case 'deactivate': 200 if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) { 201 wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) ); 202 } 203 204 check_admin_referer( 'deactivate-plugin_' . $plugin ); 205 206 if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) { 207 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 208 exit; 209 } 210 211 deactivate_plugins( $plugin, false, is_network_admin() ); 212 213 if ( ! is_network_admin() ) { 214 update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) ); 215 } else { 216 update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) ); 217 } 218 219 if ( headers_sent() ) { 220 echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />"; 221 } else { 222 wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) ); 223 } 224 exit; 225 226 case 'deactivate-selected': 227 if ( ! current_user_can( 'deactivate_plugins' ) ) { 228 wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) ); 229 } 230 231 check_admin_referer( 'bulk-plugins' ); 232 233 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); 234 // Do not deactivate plugins which are already deactivated. 235 if ( is_network_admin() ) { 236 $plugins = array_filter( $plugins, 'is_plugin_active_for_network' ); 237 } else { 238 $plugins = array_filter( $plugins, 'is_plugin_active' ); 239 $plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) ); 240 241 foreach ( $plugins as $i => $plugin ) { 242 // Only deactivate plugins which the user can deactivate. 243 if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) { 244 unset( $plugins[ $i ] ); 245 } 246 } 247 } 248 if ( empty( $plugins ) ) { 249 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 250 exit; 251 } 252 253 deactivate_plugins( $plugins, false, is_network_admin() ); 254 255 $deactivated = array(); 256 foreach ( $plugins as $plugin ) { 257 $deactivated[ $plugin ] = time(); 258 } 259 260 if ( ! is_network_admin() ) { 261 update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) ); 262 } else { 263 update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) ); 264 } 265 266 wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) ); 267 exit; 268 269 case 'delete-selected': 270 if ( ! current_user_can( 'delete_plugins' ) ) { 271 wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) ); 272 } 273 274 check_admin_referer( 'bulk-plugins' ); 275 276 // $_POST = from the plugin form; $_GET = from the FTP details screen. 277 $plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array(); 278 if ( empty( $plugins ) ) { 279 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 280 exit; 281 } 282 283 $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins. 284 if ( empty( $plugins ) ) { 285 wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); 286 exit; 287 } 288 289 // Bail on all if any paths are invalid. 290 // validate_file() returns truthy for invalid files. 291 $invalid_plugin_files = array_filter( $plugins, 'validate_file' ); 292 if ( $invalid_plugin_files ) { 293 wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); 294 exit; 295 } 296 297 require ABSPATH . 'wp-admin/update.php'; 298 299 $parent_file = 'plugins.php'; 300 301 if ( ! isset( $_REQUEST['verify-delete'] ) ) { 302 wp_enqueue_script( 'jquery' ); 303 require_once ABSPATH . 'wp-admin/admin-header.php'; 304 305 ?> 306 <div class="wrap"> 307 <?php 308 309 $plugin_info = array(); 310 $have_non_network_plugins = false; 311 312 foreach ( (array) $plugins as $plugin ) { 313 $plugin_slug = dirname( $plugin ); 314 315 if ( '.' === $plugin_slug ) { 316 $data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); 317 if ( $data ) { 318 $plugin_info[ $plugin ] = $data; 319 $plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 320 if ( ! $plugin_info[ $plugin ]['Network'] ) { 321 $have_non_network_plugins = true; 322 } 323 } 324 } else { 325 // Get plugins list from that folder. 326 $folder_plugins = get_plugins( '/' . $plugin_slug ); 327 if ( $folder_plugins ) { 328 foreach ( $folder_plugins as $plugin_file => $data ) { 329 $plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data ); 330 $plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); 331 if ( ! $plugin_info[ $plugin_file ]['Network'] ) { 332 $have_non_network_plugins = true; 333 } 334 } 335 } 336 } 337 } 338 339 $plugins_to_delete = count( $plugin_info ); 340 341 ?> 342 <?php if ( 1 === $plugins_to_delete ) : ?> 343 <h1><?php _e( 'Delete Plugin' ); ?></h1> 344 <?php 345 if ( $have_non_network_plugins && is_network_admin() ) : 346 $maybe_active_plugin = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'This plugin may be active on other sites in the network.' ); 347 wp_admin_notice( 348 $maybe_active_plugin, 349 array( 350 'additional_classes' => array( 'error' ), 351 ) 352 ); 353 endif; 354 ?> 355 <p><?php _e( 'You are about to remove the following plugin:' ); ?></p> 356 <?php else : ?> 357 <h1><?php _e( 'Delete Plugins' ); ?></h1> 358 <?php 359 if ( $have_non_network_plugins && is_network_admin() ) : 360 $maybe_active_plugins = '<strong>' . __( 'Caution:' ) . '</strong> ' . __( 'These plugins may be active on other sites in the network.' ); 361 wp_admin_notice( 362 $maybe_active_plugins, 363 array( 364 'additional_classes' => array( 'error' ), 365 ) 366 ); 367 endif; 368 ?> 369 <p><?php _e( 'You are about to remove the following plugins:' ); ?></p> 370 <?php endif; ?> 371 <ul class="ul-disc"> 372 <?php 373 374 $data_to_delete = false; 375 376 foreach ( $plugin_info as $plugin ) { 377 if ( $plugin['is_uninstallable'] ) { 378 /* translators: 1: Plugin name, 2: Plugin author. */ 379 echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>'; 380 $data_to_delete = true; 381 } else { 382 /* translators: 1: Plugin name, 2: Plugin author. */ 383 echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>'; 384 } 385 } 386 387 ?> 388 </ul> 389 <p> 390 <?php 391 392 if ( $data_to_delete ) { 393 _e( 'Are you sure you want to delete these files and data?' ); 394 } else { 395 _e( 'Are you sure you want to delete these files?' ); 396 } 397 398 ?> 399 </p> 400 <form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> 401 <input type="hidden" name="verify-delete" value="1" /> 402 <input type="hidden" name="action" value="delete-selected" /> 403 <?php 404 405 foreach ( (array) $plugins as $plugin ) { 406 echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; 407 } 408 409 ?> 410 <?php wp_nonce_field( 'bulk-plugins' ); ?> 411 <?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?> 412 </form> 413 <?php 414 415 $referer = wp_get_referer(); 416 417 ?> 418 <form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> 419 <?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?> 420 </form> 421 </div> 422 <?php 423 424 require_once ABSPATH . 'wp-admin/admin-footer.php'; 425 exit; 426 } else { 427 $plugins_to_delete = count( $plugins ); 428 } // End if verify-delete. 429 430 $delete_result = delete_plugins( $plugins ); 431 432 // Store the result in an option rather than a URL param due to object type & length. 433 // Cannot use transient/cache, as that could get flushed if any plugin flushes data on uninstall/delete. 434 update_option( 'plugins_delete_result_' . $user_ID, $delete_result, false ); 435 wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) ); 436 exit; 437 case 'clear-recent-list': 438 if ( ! is_network_admin() ) { 439 update_option( 'recently_activated', array() ); 440 } else { 441 update_site_option( 'recently_activated', array() ); 442 } 443 444 break; 445 case 'resume': 446 if ( is_multisite() ) { 447 return; 448 } 449 450 if ( ! current_user_can( 'resume_plugin', $plugin ) ) { 451 wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) ); 452 } 453 454 check_admin_referer( 'resume-plugin_' . $plugin ); 455 456 $result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) ); 457 458 if ( is_wp_error( $result ) ) { 459 wp_die( $result ); 460 } 461 462 wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) ); 463 exit; 464 case 'enable-auto-update': 465 case 'disable-auto-update': 466 case 'enable-auto-update-selected': 467 case 'disable-auto-update-selected': 468 if ( ! current_user_can( 'update_plugins' ) || ! wp_is_auto_update_enabled_for_type( 'plugin' ) ) { 469 wp_die( __( 'Sorry, you are not allowed to manage plugins automatic updates.' ) ); 470 } 471 472 if ( is_multisite() && ! is_network_admin() ) { 473 wp_die( __( 'Please connect to your network admin to manage plugins automatic updates.' ) ); 474 } 475 476 $redirect = self_admin_url( "plugins.php?plugin_status={$status}&paged={$page}&s={$s}" ); 477 478 if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) { 479 if ( empty( $plugin ) ) { 480 wp_redirect( $redirect ); 481 exit; 482 } 483 484 check_admin_referer( 'updates' ); 485 } else { 486 if ( empty( $_POST['checked'] ) ) { 487 wp_redirect( $redirect ); 488 exit; 489 } 490 491 check_admin_referer( 'bulk-plugins' ); 492 } 493 494 $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); 495 496 if ( 'enable-auto-update' === $action ) { 497 $auto_updates[] = $plugin; 498 $auto_updates = array_unique( $auto_updates ); 499 $redirect = add_query_arg( array( 'enabled-auto-update' => 'true' ), $redirect ); 500 } elseif ( 'disable-auto-update' === $action ) { 501 $auto_updates = array_diff( $auto_updates, array( $plugin ) ); 502 $redirect = add_query_arg( array( 'disabled-auto-update' => 'true' ), $redirect ); 503 } else { 504 $plugins = (array) wp_unslash( $_POST['checked'] ); 505 506 if ( 'enable-auto-update-selected' === $action ) { 507 $new_auto_updates = array_merge( $auto_updates, $plugins ); 508 $new_auto_updates = array_unique( $new_auto_updates ); 509 $query_args = array( 'enabled-auto-update-multi' => 'true' ); 510 } else { 511 $new_auto_updates = array_diff( $auto_updates, $plugins ); 512 $query_args = array( 'disabled-auto-update-multi' => 'true' ); 513 } 514 515 // Return early if all selected plugins already have auto-updates enabled or disabled. 516 // Must use non-strict comparison, so that array order is not treated as significant. 517 if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual 518 wp_redirect( $redirect ); 519 exit; 520 } 521 522 $auto_updates = $new_auto_updates; 523 $redirect = add_query_arg( $query_args, $redirect ); 524 } 525 526 /** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */ 527 $all_items = apply_filters( 'all_plugins', get_plugins() ); 528 529 // Remove plugins that don't exist or have been deleted since the option was last updated. 530 $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); 531 532 update_site_option( 'auto_update_plugins', $auto_updates ); 533 534 wp_redirect( $redirect ); 535 exit; 536 default: 537 if ( isset( $_POST['checked'] ) ) { 538 check_admin_referer( 'bulk-plugins' ); 539 540 $screen = get_current_screen()->id; 541 $sendback = wp_get_referer(); 542 $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); 543 544 /** This action is documented in wp-admin/edit.php */ 545 $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores 546 wp_safe_redirect( $sendback ); 547 exit; 548 } 549 break; 550 } 551 } 552 553 $wp_list_table->prepare_items(); 554 555 wp_enqueue_script( 'plugin-install' ); 556 add_thickbox(); 557 558 add_screen_option( 'per_page', array( 'default' => 999 ) ); 559 560 get_current_screen()->add_help_tab( 561 array( 562 'id' => 'overview', 563 'title' => __( 'Overview' ), 564 'content' => 565 '<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' . 566 '<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' . 567 '<p>' . sprintf( 568 /* translators: %s: WordPress Plugin Directory URL. */ 569 __( 'If you would like to see more plugins to choose from, click on the “Add New Plugin” button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!' ), 570 __( 'https://wordpress.org/plugins/' ) 571 ) . '</p>', 572 ) 573 ); 574 get_current_screen()->add_help_tab( 575 array( 576 'id' => 'compatibility-problems', 577 'title' => __( 'Troubleshooting' ), 578 'content' => 579 '<p>' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin’s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '</p>' . 580 '<p>' . sprintf( 581 /* translators: %s: WP_PLUGIN_DIR constant value. */ 582 __( 'If something goes wrong with a plugin and you cannot use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ), 583 '<code>' . WP_PLUGIN_DIR . '</code>' 584 ) . '</p>', 585 ) 586 ); 587 588 $help_sidebar_autoupdates = ''; 589 590 if ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) { 591 get_current_screen()->add_help_tab( 592 array( 593 'id' => 'plugins-themes-auto-updates', 594 'title' => __( 'Auto-updates' ), 595 'content' => 596 '<p>' . __( 'Auto-updates can be enabled or disabled for each individual plugin. Plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' . 597 '<p>' . __( 'Auto-updates are only available for plugins recognized by WordPress.org, or that include a compatible update system.' ) . '</p>' . 598 '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>', 599 ) 600 ); 601 602 $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>'; 603 } 604 605 get_current_screen()->set_help_sidebar( 606 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 607 '<p>' . __( '<a href="https://wordpress.org/documentation/article/manage-plugins/">Documentation on Managing Plugins</a>' ) . '</p>' . 608 $help_sidebar_autoupdates . 609 '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>' 610 ); 611 612 get_current_screen()->set_screen_reader_content( 613 array( 614 'heading_views' => __( 'Filter plugins list' ), 615 'heading_pagination' => __( 'Plugins list navigation' ), 616 'heading_list' => __( 'Plugins list' ), 617 ) 618 ); 619 620 // Used in the HTML title tag. 621 $title = __( 'Plugins' ); 622 $parent_file = 'plugins.php'; 623 624 require_once ABSPATH . 'wp-admin/admin-header.php'; 625 626 $invalid = validate_active_plugins(); 627 if ( ! empty( $invalid ) ) { 628 foreach ( $invalid as $plugin_file => $error ) { 629 $deactivated_message = sprintf( 630 /* translators: 1: Plugin file, 2: Error message. */ 631 __( 'The plugin %1$s has been deactivated due to an error: %2$s' ), 632 '<code>' . esc_html( $plugin_file ) . '</code>', 633 esc_html( $error->get_error_message() ) 634 ); 635 wp_admin_notice( 636 $deactivated_message, 637 array( 638 'id' => 'message', 639 'additional_classes' => array( 'error' ), 640 ) 641 ); 642 } 643 } 644 645 // Used by wp_admin_notice() updated notices. 646 $updated_notice_args = array( 647 'id' => 'message', 648 'additional_classes' => array( 'updated' ), 649 'dismissible' => true, 650 ); 651 if ( isset( $_GET['error'] ) ) { 652 653 if ( isset( $_GET['main'] ) ) { 654 $errmsg = __( 'You cannot delete a plugin while it is active on the main site.' ); 655 } elseif ( isset( $_GET['charsout'] ) ) { 656 $errmsg = sprintf( 657 /* translators: %d: Number of characters. */ 658 _n( 659 'The plugin generated %d character of <strong>unexpected output</strong> during activation.', 660 'The plugin generated %d characters of <strong>unexpected output</strong> during activation.', 661 $_GET['charsout'] 662 ), 663 $_GET['charsout'] 664 ); 665 $errmsg .= ' ' . __( 'If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' ); 666 } elseif ( 'resuming' === $_GET['error'] ) { 667 $errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' ); 668 } else { 669 $errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' ); 670 } 671 672 if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) 673 && isset( $_GET['_error_nonce'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) 674 ) { 675 $iframe_url = add_query_arg( 676 array( 677 'action' => 'error_scrape', 678 'plugin' => urlencode( $plugin ), 679 '_wpnonce' => urlencode( $_GET['_error_nonce'] ), 680 ), 681 admin_url( 'plugins.php' ) 682 ); 683 684 $errmsg .= '<iframe style="border:0" width="100%" height="70px" src="' . esc_url( $iframe_url ) . '"></iframe>'; 685 } 686 687 wp_admin_notice( 688 $errmsg, 689 array( 690 'id' => 'message', 691 'additional_classes' => array( 'error' ), 692 ) 693 ); 694 695 } elseif ( isset( $_GET['deleted'] ) ) { 696 $delete_result = get_option( 'plugins_delete_result_' . $user_ID ); 697 // Delete it once we're done. 698 delete_option( 'plugins_delete_result_' . $user_ID ); 699 700 if ( is_wp_error( $delete_result ) ) { 701 $plugin_not_deleted_message = sprintf( 702 /* translators: %s: Error message. */ 703 __( 'Plugin could not be deleted due to an error: %s' ), 704 esc_html( $delete_result->get_error_message() ) 705 ); 706 wp_admin_notice( 707 $plugin_not_deleted_message, 708 array( 709 'id' => 'message', 710 'additional_classes' => array( 'error' ), 711 'dismissible' => true, 712 ) 713 ); 714 } else { 715 if ( 1 === (int) $_GET['deleted'] ) { 716 $plugins_deleted_message = __( 'The selected plugin has been deleted.' ); 717 } else { 718 $plugins_deleted_message = __( 'The selected plugins have been deleted.' ); 719 } 720 wp_admin_notice( $plugins_deleted_message, $updated_notice_args ); 721 } 722 } elseif ( isset( $_GET['activate'] ) ) { 723 wp_admin_notice( __( 'Plugin activated.' ), $updated_notice_args ); 724 } elseif ( isset( $_GET['activate-multi'] ) ) { 725 wp_admin_notice( __( 'Selected plugins activated.' ), $updated_notice_args ); 726 } elseif ( isset( $_GET['deactivate'] ) ) { 727 wp_admin_notice( __( 'Plugin deactivated.' ), $updated_notice_args ); 728 } elseif ( isset( $_GET['deactivate-multi'] ) ) { 729 wp_admin_notice( __( 'Selected plugins deactivated.' ), $updated_notice_args ); 730 } elseif ( 'update-selected' === $action ) { 731 wp_admin_notice( __( 'All selected plugins are up to date.' ), $updated_notice_args ); 732 } elseif ( isset( $_GET['resume'] ) ) { 733 wp_admin_notice( __( 'Plugin resumed.' ), $updated_notice_args ); 734 } elseif ( isset( $_GET['enabled-auto-update'] ) ) { 735 wp_admin_notice( __( 'Plugin will be auto-updated.' ), $updated_notice_args ); 736 } elseif ( isset( $_GET['disabled-auto-update'] ) ) { 737 wp_admin_notice( __( 'Plugin will no longer be auto-updated.' ), $updated_notice_args ); 738 } elseif ( isset( $_GET['enabled-auto-update-multi'] ) ) { 739 wp_admin_notice( __( 'Selected plugins will be auto-updated.' ), $updated_notice_args ); 740 } elseif ( isset( $_GET['disabled-auto-update-multi'] ) ) { 741 wp_admin_notice( __( 'Selected plugins will no longer be auto-updated.' ), $updated_notice_args ); 742 } 743 ?> 744 745 <?php WP_Plugin_Dependencies::display_admin_notice_for_unmet_dependencies(); ?> 746 <?php WP_Plugin_Dependencies::display_admin_notice_for_circular_dependencies(); ?> 747 <div class="wrap"> 748 <h1 class="wp-heading-inline"> 749 <?php 750 echo esc_html( $title ); 751 ?> 752 </h1> 753 754 <?php 755 if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) { 756 ?> 757 <a href="<?php echo esc_url( self_admin_url( 'plugin-install.php' ) ); ?>" class="page-title-action"><?php echo esc_html__( 'Add New Plugin' ); ?></a> 758 <?php 759 } 760 761 if ( strlen( $s ) ) { 762 echo '<span class="subtitle">'; 763 printf( 764 /* translators: %s: Search query. */ 765 __( 'Search results for: %s' ), 766 '<strong>' . esc_html( urldecode( $s ) ) . '</strong>' 767 ); 768 echo '</span>'; 769 } 770 ?> 771 772 <hr class="wp-header-end"> 773 774 <?php 775 /** 776 * Fires before the plugins list table is rendered. 777 * 778 * This hook also fires before the plugins list table is rendered in the Network Admin. 779 * 780 * Please note: The 'active' portion of the hook name does not refer to whether the current 781 * view is for active plugins, but rather all plugins actively-installed. 782 * 783 * @since 3.0.0 784 * 785 * @param array[] $plugins_all An array of arrays containing information on all installed plugins. 786 */ 787 do_action( 'pre_current_active_plugins', $plugins['all'] ); 788 ?> 789 790 <?php $wp_list_table->views(); ?> 791 792 <form class="search-form search-plugins" method="get"> 793 <?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?> 794 </form> 795 796 <form method="post" id="bulk-action-form"> 797 798 <input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" /> 799 <input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" /> 800 801 <?php $wp_list_table->display(); ?> 802 </form> 803 804 <span class="spinner"></span> 805 </div> 806 807 <?php 808 wp_print_request_filesystem_credentials_modal(); 809 wp_print_admin_notice_templates(); 810 wp_print_update_row_templates(); 811 812 require_once ABSPATH . 'wp-admin/admin-footer.php';
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Fri Apr 26 08:20:02 2024 | Cross-referenced by PHPXref |