Skip to content

Commit

Permalink
remove more includes
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Mar 2, 2023
1 parent 3941748 commit 4f49bc0
Show file tree
Hide file tree
Showing 33 changed files with 18 additions and 90 deletions.
2 changes: 0 additions & 2 deletions src/wp-admin/includes/class-ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions src/wp-admin/includes/class-wp-filesystem-ftpsockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down
40 changes: 18 additions & 22 deletions src/wp-admin/includes/list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down
4 changes: 0 additions & 4 deletions src/wp-includes/class-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
4 changes: 0 additions & 4 deletions src/wp-includes/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/nav-menu-item-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/nav-menu-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/nav-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/customize/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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';

Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/partial.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/customize/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down Expand Up @@ -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';

Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/selective-refresh-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/tests/customize/selective-refresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -263,8 +262,6 @@ public function tear_down() {
}
}

require_once ABSPATH . WPINC . '/customize/class-wp-customize-partial.php';

/**
* Class Tested_Custom_Partial
*/
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/customize/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down
4 changes: 0 additions & 4 deletions tests/phpunit/tests/editor/wpEditors.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

if ( ! class_exists( '_WP_Editors', false ) ) {
require_once ABSPATH . WPINC . '/class-wp-editor.php';
}

/**
* @group editor
*
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/tests/feed/wpSimplePieFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
class Tests_Feed_wpSimplePieFile extends WP_UnitTestCase {
public static function set_up_before_class() {
parent::set_up_before_class();

require_once ABSPATH . 'wp-includes/class-simplepie.php';
require_once ABSPATH . 'wp-includes/class-wp-simplepie-file.php';
}

/**
Expand Down
4 changes: 0 additions & 4 deletions tests/phpunit/tests/general/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @group site_icon
*/

require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php';

class Tests_General_Template extends WP_UnitTestCase {
protected $wp_site_icon;
public $site_icon_id;
Expand Down Expand Up @@ -182,7 +180,6 @@ public function test_customize_preview_wp_site_icon_empty() {
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();
Expand All @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/image/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/tests/image/editorGd.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/image/editorImagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions tests/phpunit/tests/image/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/image/header.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
require_once ABSPATH . 'wp-admin/includes/class-custom-image-header.php';

/**
* @group image
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/image/resizeGd.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class Test_Image_Resize_GD extends WP_Tests_Image_Resize_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();
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/tests/image/resizeImagick.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class Test_Image_Resize_Imagick extends WP_Tests_Image_Resize_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';

// This needs to come after the mock image editor class is loaded.
parent::set_up();
}
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/image/siteIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @group site_icon
*/

require_once ABSPATH . 'wp-admin/includes/class-wp-site-icon.php';

class Tests_WP_Site_Icon extends WP_UnitTestCase {
protected $wp_site_icon;

Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/tests/menu/walker-nav-menu-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public function set_up() {

parent::set_up();

/** Walker_Nav_Menu_Edit class */
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php';

$this->walker = new Walker_Nav_Menu_Edit();

$this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth;
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/menu/walker-nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/post/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/theme/customHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/widgets/wpWidgetMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/widgets/wpWidgetText.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 4f49bc0

Please sign in to comment.