Changeset 57545 for trunk/src/wp-settings.php
- Timestamp:
- 02/06/2024 11:44:09 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-settings.php
r57539 r57545 413 413 $GLOBALS['wp_plugin_paths'] = array(); 414 414 415 // Load and initialize WP_Plugin_Dependencies. 416 require_once ABSPATH . WPINC . '/class-wp-plugin-dependencies.php'; 417 if ( ! defined( 'WP_RUN_CORE_TESTS' ) ) { 418 WP_Plugin_Dependencies::initialize(); 419 } 420 415 421 // Load must-use plugins. 416 422 foreach ( wp_get_mu_plugins() as $mu_plugin ) { … … 487 493 488 494 // Load active plugins. 495 $all_plugin_data = get_option( 'plugin_data', array() ); 496 $failed_plugins = array(); 497 $update_plugin_data = false; 489 498 foreach ( wp_get_active_and_valid_plugins() as $plugin ) { 499 $plugin_file = str_replace( trailingslashit( WP_PLUGIN_DIR ), '', $plugin ); 500 if ( ! isset( $all_plugin_data[ $plugin_file ] ) ) { 501 require_once ABSPATH . 'wp-admin/includes/plugin.php'; 502 $all_plugin_data[ $plugin_file ] = get_plugin_data( WP_PLUGIN_DIR . "/$plugin_file" ); 503 504 $update_plugin_data = true; 505 } 506 507 $plugin_headers = $all_plugin_data[ $plugin_file ]; 508 $errors = array(); 509 $requirements = array( 510 'requires' => ! empty( $plugin_headers['RequiresWP'] ) ? $plugin_headers['RequiresWP'] : '', 511 'requires_php' => ! empty( $plugin_headers['RequiresPHP'] ) ? $plugin_headers['RequiresPHP'] : '', 512 'requires_plugins' => ! empty( $plugin_headers['RequiresPlugins'] ) ? $plugin_headers['RequiresPlugins'] : '', 513 ); 514 $compatible_wp = is_wp_version_compatible( $requirements['requires'] ); 515 $compatible_php = is_php_version_compatible( $requirements['requires_php'] ); 516 $dependencies_met = ! WP_Plugin_Dependencies::has_unmet_dependencies( $plugin_file ); 517 518 $php_update_message = '</p><p>' . sprintf( 519 /* translators: %s: URL to Update PHP page. */ 520 __( '<a href="%s">Learn more about updating PHP</a>.' ), 521 esc_url( wp_get_update_php_url() ) 522 ); 523 524 $annotation = wp_get_update_php_annotation(); 525 526 if ( $annotation ) { 527 $php_update_message .= '</p><p><em>' . $annotation . '</em>'; 528 } 529 530 if ( ! $dependencies_met ) { 531 $errors[] = sprintf( 532 /* translators: %s: The plugin's name. */ 533 _x( '%s has unmet dependencies.', 'plugin' ), 534 $plugin_headers['Name'] 535 ); 536 } 537 538 if ( ! $compatible_wp && ! $compatible_php ) { 539 $errors[] = sprintf( 540 /* translators: 1: Current WordPress version, 2: Current PHP version, 3: Plugin name, 4: Required WordPress version, 5: Required PHP version. */ 541 _x( '<strong>Error:</strong> Current versions of WordPress (%1$s) and PHP (%2$s) do not meet minimum requirements for %3$s. The plugin requires WordPress %4$s and PHP %5$s.', 'plugin' ), 542 get_bloginfo( 'version' ), 543 PHP_VERSION, 544 $plugin_headers['Name'], 545 $requirements['requires'], 546 $requirements['requires_php'] 547 ) . $php_update_message; 548 } elseif ( ! $compatible_php ) { 549 $errors[] = sprintf( 550 /* translators: 1: Current PHP version, 2: Plugin name, 3: Required PHP version. */ 551 _x( '<strong>Error:</strong> Current PHP version (%1$s) does not meet minimum requirements for %2$s. The plugin requires PHP %3$s.', 'plugin' ), 552 PHP_VERSION, 553 $plugin_headers['Name'], 554 $requirements['requires_php'] 555 ) . $php_update_message; 556 } elseif ( ! $compatible_wp ) { 557 $errors[] = sprintf( 558 /* translators: 1: Current WordPress version, 2: Plugin name, 3: Required WordPress version. */ 559 _x( '<strong>Error:</strong> Current WordPress version (%1$s) does not meet minimum requirements for %2$s. The plugin requires WordPress %3$s.', 'plugin' ), 560 get_bloginfo( 'version' ), 561 $plugin_headers['Name'], 562 $requirements['requires'] 563 ); 564 } 565 566 if ( ! empty( $errors ) ) { 567 $failed_plugins[ $plugin_file ] = ''; 568 foreach ( $errors as $error ) { 569 $failed_plugins[ $plugin_file ] .= wp_get_admin_notice( 570 $error, 571 array( 572 'type' => 'error', 573 'dismissible' => true, 574 ) 575 ); 576 } 577 continue; 578 } 579 490 580 wp_register_plugin_realpath( $plugin ); 491 581 … … 505 595 unset( $plugin, $_wp_plugin_file ); 506 596 597 if ( $update_plugin_data ) { 598 update_option( 'plugin_data', $all_plugin_data ); 599 } 600 601 if ( ! empty( $failed_plugins ) ) { 602 add_action( 603 'admin_notices', 604 function () use ( $failed_plugins ) { 605 global $pagenow; 606 607 if ( 'index.php' === $pagenow || 'plugins.php' === $pagenow ) { 608 echo implode( '', $failed_plugins ); 609 } 610 } 611 ); 612 } 613 unset( $failed_plugins ); 614 507 615 // Load pluggable functions. 508 616 require ABSPATH . WPINC . '/pluggable.php';
Note: See TracChangeset
for help on using the changeset viewer.