From 4f49bc0461f3b6b73a033f7b53e1ed7b8afc1134 Mon Sep 17 00:00:00 2001 From: Ari Stathopoulos Date: Thu, 2 Mar 2023 15:07:06 +0200 Subject: [PATCH] remove more includes --- src/wp-admin/includes/class-ftp.php | 2 - .../class-wp-filesystem-ftpsockets.php | 5 --- src/wp-admin/includes/list-table.php | 40 +++++++++---------- src/wp-includes/class-feed.php | 4 -- src/wp-includes/feed.php | 4 -- .../tests/customize/nav-menu-item-setting.php | 1 - .../tests/customize/nav-menu-setting.php | 1 - tests/phpunit/tests/customize/nav-menus.php | 1 - tests/phpunit/tests/customize/panel.php | 2 - tests/phpunit/tests/customize/partial.php | 1 - tests/phpunit/tests/customize/section.php | 2 - .../customize/selective-refresh-ajax.php | 1 - .../tests/customize/selective-refresh.php | 3 -- tests/phpunit/tests/customize/setting.php | 1 - tests/phpunit/tests/customize/widgets.php | 1 - tests/phpunit/tests/editor/wpEditors.php | 4 -- tests/phpunit/tests/feed/wpSimplePieFile.php | 3 -- tests/phpunit/tests/general/template.php | 4 -- tests/phpunit/tests/image/editor.php | 2 - tests/phpunit/tests/image/editorGd.php | 3 -- tests/phpunit/tests/image/editorImagick.php | 2 - tests/phpunit/tests/image/functions.php | 4 -- tests/phpunit/tests/image/header.php | 1 - tests/phpunit/tests/image/resizeGd.php | 2 - tests/phpunit/tests/image/resizeImagick.php | 3 -- tests/phpunit/tests/image/siteIcon.php | 2 - .../tests/menu/walker-nav-menu-edit.php | 3 -- tests/phpunit/tests/menu/walker-nav-menu.php | 1 - tests/phpunit/tests/post/nav-menu.php | 1 - .../rest-api/rest-attachments-controller.php | 1 - tests/phpunit/tests/theme/customHeader.php | 1 - tests/phpunit/tests/widgets/wpWidgetMedia.php | 1 - tests/phpunit/tests/widgets/wpWidgetText.php | 1 - 33 files changed, 18 insertions(+), 90 deletions(-) diff --git a/src/wp-admin/includes/class-ftp.php b/src/wp-admin/includes/class-ftp.php index 07cb936de1214..b7b5f335b572c 100644 --- a/src/wp-admin/includes/class-ftp.php +++ b/src/wp-admin/includes/class-ftp.php @@ -904,8 +904,6 @@ function PopError(){ $mod_sockets = extension_loaded( 'sockets' ); } -require_once __DIR__ . "/class-ftp-" . ( $mod_sockets ? "sockets" : "pure" ) . ".php"; - if ( $mod_sockets ) { class ftp extends ftp_sockets {} } else { diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php index da771e4156824..8d36da2c1b2e2 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -32,11 +32,6 @@ public function __construct( $opt = '' ) { $this->method = 'ftpsockets'; $this->errors = new WP_Error(); - // Check if possible to use ftp functions. - if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) { - return; - } - $this->ftp = new ftp(); if ( empty( $opt['port'] ) ) { diff --git a/src/wp-admin/includes/list-table.php b/src/wp-admin/includes/list-table.php index 1e2c190c80fe9..70208efbe51a3 100644 --- a/src/wp-admin/includes/list-table.php +++ b/src/wp-admin/includes/list-table.php @@ -21,34 +21,30 @@ function _get_list_table( $class_name, $args = array() ) { $core_classes = array( // Site Admin. - 'WP_Posts_List_Table' => 'posts', - 'WP_Media_List_Table' => 'media', - 'WP_Terms_List_Table' => 'terms', - 'WP_Users_List_Table' => 'users', - 'WP_Comments_List_Table' => 'comments', - 'WP_Post_Comments_List_Table' => array( 'comments', 'post-comments' ), - 'WP_Links_List_Table' => 'links', - 'WP_Plugin_Install_List_Table' => 'plugin-install', - 'WP_Themes_List_Table' => 'themes', - 'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ), - 'WP_Plugins_List_Table' => 'plugins', - 'WP_Application_Passwords_List_Table' => 'application-passwords', + 'WP_Posts_List_Table', + 'WP_Media_List_Table', + 'WP_Terms_List_Table', + 'WP_Users_List_Table', + 'WP_Comments_List_Table', + 'WP_Post_Comments_List_Table', + 'WP_Links_List_Table', + 'WP_Plugin_Install_List_Table', + 'WP_Themes_List_Table', + 'WP_Theme_Install_List_Table', + 'WP_Plugins_List_Table', + 'WP_Application_Passwords_List_Table', // Network Admin. - 'WP_MS_Sites_List_Table' => 'ms-sites', - 'WP_MS_Users_List_Table' => 'ms-users', - 'WP_MS_Themes_List_Table' => 'ms-themes', + 'WP_MS_Sites_List_Table', + 'WP_MS_Users_List_Table', + 'WP_MS_Themes_List_Table', // Privacy requests tables. - 'WP_Privacy_Data_Export_Requests_List_Table' => 'privacy-data-export-requests', - 'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests', + 'WP_Privacy_Data_Export_Requests_List_Table', + 'WP_Privacy_Data_Removal_Requests_List_Table', ); - if ( isset( $core_classes[ $class_name ] ) ) { - foreach ( (array) $core_classes[ $class_name ] as $required ) { - require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php'; - } - + if ( in_array( $class_name, $core_classes ) ) { if ( isset( $args['screen'] ) ) { $args['screen'] = convert_to_screen( $args['screen'] ); } elseif ( isset( $GLOBALS['hook_suffix'] ) ) { diff --git a/src/wp-includes/class-feed.php b/src/wp-includes/class-feed.php index 5e5688f450619..c6a320640ed3d 100644 --- a/src/wp-includes/class-feed.php +++ b/src/wp-includes/class-feed.php @@ -8,7 +8,3 @@ */ _deprecated_file( basename( __FILE__ ), '4.7.0', 'fetch_feed()' ); - -if ( ! class_exists( 'SimplePie', false ) ) { - require_once ABSPATH . WPINC . '/class-simplepie.php'; -} diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 19a59d15525f3..84b0995acc17e 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -785,10 +785,6 @@ function feed_content_type( $type = '' ) { * @return SimplePie|WP_Error SimplePie object on success or WP_Error object on failure. */ function fetch_feed( $url ) { - if ( ! class_exists( 'SimplePie', false ) ) { - require_once ABSPATH . WPINC . '/class-simplepie.php'; - } - $feed = new SimplePie(); $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index 256e5f577c5d7..9a178b6aa7368 100644 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -20,7 +20,6 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { */ public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index 6d50c96ee0c62..bccadf8130626 100644 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -21,7 +21,6 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { */ public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 6cc8f3d08c5b6..ba16f1debd5e5 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -21,7 +21,6 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { */ public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); global $wp_customize; $this->wp_customize = new WP_Customize_Manager(); diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php index ab7859499e57c..89d377fdd52e1 100644 --- a/tests/phpunit/tests/customize/panel.php +++ b/tests/phpunit/tests/customize/panel.php @@ -14,7 +14,6 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->manager = $GLOBALS['wp_customize']; } @@ -214,7 +213,6 @@ public function test_print_templates_custom() { } } -require_once ABSPATH . WPINC . '/class-wp-customize-panel.php'; class Custom_Panel_Test extends WP_Customize_Panel { public $type = 'titleless'; diff --git a/tests/phpunit/tests/customize/partial.php b/tests/phpunit/tests/customize/partial.php index 5e173a8acf37c..5481645429619 100644 --- a/tests/phpunit/tests/customize/partial.php +++ b/tests/phpunit/tests/customize/partial.php @@ -31,7 +31,6 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { */ public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->wp_customize = $GLOBALS['wp_customize']; if ( isset( $this->wp_customize->selective_refresh ) ) { diff --git a/tests/phpunit/tests/customize/section.php b/tests/phpunit/tests/customize/section.php index da35a54eaa13e..f7a75f4505520 100644 --- a/tests/phpunit/tests/customize/section.php +++ b/tests/phpunit/tests/customize/section.php @@ -21,7 +21,6 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->manager = $GLOBALS['wp_customize']; } @@ -222,7 +221,6 @@ public function test_print_templates_custom() { } } -require_once ABSPATH . WPINC . '/class-wp-customize-section.php'; class Custom_Section_Test extends WP_Customize_Section { public $type = 'titleless'; diff --git a/tests/phpunit/tests/customize/selective-refresh-ajax.php b/tests/phpunit/tests/customize/selective-refresh-ajax.php index 040697d419e1b..d8a705aff0ba5 100644 --- a/tests/phpunit/tests/customize/selective-refresh-ajax.php +++ b/tests/phpunit/tests/customize/selective-refresh-ajax.php @@ -41,7 +41,6 @@ public function set_up() { add_filter( 'wp_doing_ajax', '__return_true' ); add_filter( 'wp_die_ajax_handler', array( $this, 'get_wp_die_handler' ), 1, 1 ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->wp_customize = $GLOBALS['wp_customize']; if ( isset( $this->wp_customize->selective_refresh ) ) { diff --git a/tests/phpunit/tests/customize/selective-refresh.php b/tests/phpunit/tests/customize/selective-refresh.php index b3cf7fd84aaf4..94cc493090771 100644 --- a/tests/phpunit/tests/customize/selective-refresh.php +++ b/tests/phpunit/tests/customize/selective-refresh.php @@ -31,7 +31,6 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { */ public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->wp_customize = $GLOBALS['wp_customize']; if ( isset( $this->wp_customize->selective_refresh ) ) { @@ -263,8 +262,6 @@ public function tear_down() { } } -require_once ABSPATH . WPINC . '/customize/class-wp-customize-partial.php'; - /** * Class Tested_Custom_Partial */ diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php index ef7ea0d93a081..570d108b940fd 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -19,7 +19,6 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->manager = $GLOBALS['wp_customize']; $this->undefined = new stdClass(); diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index 654008a7a9b1a..aad836b6dee38 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -22,7 +22,6 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; add_theme_support( 'customize-selective-refresh-widgets' ); add_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) ); diff --git a/tests/phpunit/tests/editor/wpEditors.php b/tests/phpunit/tests/editor/wpEditors.php index c4e9e50515fda..e4696812ffa66 100644 --- a/tests/phpunit/tests/editor/wpEditors.php +++ b/tests/phpunit/tests/editor/wpEditors.php @@ -1,9 +1,5 @@ user->create( array( 'role' => 'administrator' ) ) ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager(); $wp_customize->register_controls(); $wp_customize->start_previewing_theme(); @@ -200,7 +197,6 @@ public function test_customize_preview_wp_site_icon_dirty() { global $wp_customize; wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager(); $wp_customize->register_controls(); $wp_customize->start_previewing_theme(); diff --git a/tests/phpunit/tests/image/editor.php b/tests/phpunit/tests/image/editor.php index be4591451d8ec..f9c9a449b7dba 100644 --- a/tests/phpunit/tests/image/editor.php +++ b/tests/phpunit/tests/image/editor.php @@ -15,8 +15,6 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { * Setup test fixture */ public function set_up() { - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; - require_once DIR_TESTDATA . '/../includes/mock-image-editor.php'; // This needs to come after the mock image editor class is loaded. diff --git a/tests/phpunit/tests/image/editorGd.php b/tests/phpunit/tests/image/editorGd.php index 640561238a0a4..4ced397fe7d0c 100644 --- a/tests/phpunit/tests/image/editorGd.php +++ b/tests/phpunit/tests/image/editorGd.php @@ -14,9 +14,6 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { public $editor_engine = 'WP_Image_Editor_GD'; public function set_up() { - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; - require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; - // This needs to come after the mock image editor class is loaded. parent::set_up(); } diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index a8db8a3210123..899109f2ab2f2 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -14,8 +14,6 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { public $editor_engine = 'WP_Image_Editor_Imagick'; public function set_up() { - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; - require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; require_once DIR_TESTROOT . '/includes/class-wp-test-stream.php'; // This needs to come after the mock image editor class is loaded. diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 82988c5f6b64d..44066eb5a919b 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -13,10 +13,6 @@ class Tests_Image_Functions extends WP_UnitTestCase { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; - require_once ABSPATH . WPINC . '/class-wp-image-editor-gd.php'; - require_once ABSPATH . WPINC . '/class-wp-image-editor-imagick.php'; - require_once DIR_TESTDATA . '/../includes/mock-image-editor.php'; // Ensure no legacy / failed tests detritus. diff --git a/tests/phpunit/tests/image/header.php b/tests/phpunit/tests/image/header.php index 6b480a953c46e..627e73466bbbc 100644 --- a/tests/phpunit/tests/image/header.php +++ b/tests/phpunit/tests/image/header.php @@ -1,5 +1,4 @@ walker = new Walker_Nav_Menu_Edit(); $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth; diff --git a/tests/phpunit/tests/menu/walker-nav-menu.php b/tests/phpunit/tests/menu/walker-nav-menu.php index 0c38502f9e452..2b15f24207540 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu.php +++ b/tests/phpunit/tests/menu/walker-nav-menu.php @@ -26,7 +26,6 @@ public function set_up() { parent::set_up(); /** Walker_Nav_Menu class */ - require_once ABSPATH . 'wp-includes/class-walker-nav-menu.php'; $this->walker = new Walker_Nav_Menu(); $this->orig_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth; diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index dc7cc74e2d6af..89daa8bd6fa0f 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -862,7 +862,6 @@ public function test_wp_delete_customize_changeset_dependent_auto_drafts() { ) ) ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager(); do_action( 'customize_register', $wp_customize ); $wp_customize->save_changeset_post( diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 7794ee417e7ff..3fed82d9f59ec 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -2258,7 +2258,6 @@ public function test_edit_image_returns_error_if_mismatched_src() { * @since 5.5.0 */ protected function setup_mock_editor() { - require_once ABSPATH . WPINC . '/class-wp-image-editor.php'; require_once DIR_TESTDATA . '/../includes/mock-image-editor.php'; add_filter( diff --git a/tests/phpunit/tests/theme/customHeader.php b/tests/phpunit/tests/theme/customHeader.php index 21350deedaad1..723dcddb0dd8e 100644 --- a/tests/phpunit/tests/theme/customHeader.php +++ b/tests/phpunit/tests/theme/customHeader.php @@ -24,7 +24,6 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { public function set_up() { parent::set_up(); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $GLOBALS['wp_customize'] = new WP_Customize_Manager(); $this->customize_manager = $GLOBALS['wp_customize']; diff --git a/tests/phpunit/tests/widgets/wpWidgetMedia.php b/tests/phpunit/tests/widgets/wpWidgetMedia.php index d138c41583173..588afd32edc5e 100644 --- a/tests/phpunit/tests/widgets/wpWidgetMedia.php +++ b/tests/phpunit/tests/widgets/wpWidgetMedia.php @@ -122,7 +122,6 @@ public function test_constructor_in_customize_preview() { ) ) ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => wp_generate_uuid4(), diff --git a/tests/phpunit/tests/widgets/wpWidgetText.php b/tests/phpunit/tests/widgets/wpWidgetText.php index b35fa02e0eca3..4ed9bb437bc92 100644 --- a/tests/phpunit/tests/widgets/wpWidgetText.php +++ b/tests/phpunit/tests/widgets/wpWidgetText.php @@ -87,7 +87,6 @@ public function test__register_in_customize_preview() { ) ) ); - require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; $wp_customize = new WP_Customize_Manager( array( 'changeset_uuid' => wp_generate_uuid4(),