From 23ba9c0ad7df680681f2e93e4bbf3b39ae1a8a03 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Fri, 15 Jul 2022 21:31:45 -0500 Subject: [PATCH 1/4] Switch to Composer autoloader --- composer.json | 3 --- wp-parsely.php | 52 +++----------------------------------------------- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/composer.json b/composer.json index a3f08ce4d..0fc3aba6b 100644 --- a/composer.json +++ b/composer.json @@ -38,9 +38,6 @@ "autoload": { "classmap": [ "src/" - ], - "files": [ - "wp-parsely.php" ] }, "autoload-dev": { diff --git a/wp-parsely.php b/wp-parsely.php index 2164c7d64..553b04fd9 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -55,25 +55,9 @@ const PARSELY_VERSION = '3.4.2'; const PARSELY_FILE = __FILE__; -require __DIR__ . '/src/class-parsely.php'; -require __DIR__ . '/src/class-scripts.php'; -require __DIR__ . '/src/class-dashboard-link.php'; -require __DIR__ . '/src/UI/class-admin-bar.php'; -require __DIR__ . '/src/UI/class-metadata-renderer.php'; -require __DIR__ . '/src/Endpoints/class-metadata-endpoint.php'; -require __DIR__ . '/src/Endpoints/class-graphql-metadata.php'; - -require __DIR__ . '/src/class-metadata.php'; -require __DIR__ . '/src/Metadata/class-metadata-builder.php'; -require __DIR__ . '/src/Metadata/class-author-archive-builder.php'; -require __DIR__ . '/src/Metadata/class-category-builder.php'; -require __DIR__ . '/src/Metadata/class-date-builder.php'; -require __DIR__ . '/src/Metadata/class-front-page-builder.php'; -require __DIR__ . '/src/Metadata/class-page-builder.php'; -require __DIR__ . '/src/Metadata/class-page-for-posts-builder.php'; -require __DIR__ . '/src/Metadata/class-paginated-front-page-builder.php'; -require __DIR__ . '/src/Metadata/class-post-builder.php'; -require __DIR__ . '/src/Metadata/class-tag-builder.php'; +if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + require __DIR__ . '/vendor/autoload.php'; +} add_action( 'plugins_loaded', __NAMESPACE__ . '\\parsely_initialize_plugin' ); /** @@ -98,11 +82,6 @@ function parsely_initialize_plugin(): void { $metadata_renderer->run(); } -require __DIR__ . '/src/UI/class-admin-warning.php'; -require __DIR__ . '/src/UI/class-plugins-actions.php'; -require __DIR__ . '/src/UI/class-row-actions.php'; -require __DIR__ . '/src/UI/class-site-health.php'; - add_action( 'admin_init', __NAMESPACE__ . '\\parsely_admin_init_register' ); /** * Registers the Parse.ly wp-admin warnings, plugin actions and row actions. @@ -121,9 +100,6 @@ function parsely_admin_init_register(): void { $site_health->run(); } -require __DIR__ . '/src/UI/class-settings-page.php'; -require __DIR__ . '/src/UI/class-network-admin-sites-list.php'; - add_action( 'init', __NAMESPACE__ . '\\parsely_wp_admin_early_register' ); /** * Registers the additions the Parse.ly wp-admin settings page and Multisite @@ -137,18 +113,6 @@ function parsely_wp_admin_early_register(): void { $network_admin_sites_list->run(); } -require __DIR__ . '/src/RemoteAPI/interface-cache.php'; -require __DIR__ . '/src/RemoteAPI/interface-proxy.php'; -require __DIR__ . '/src/RemoteAPI/class-base-proxy.php'; -require __DIR__ . '/src/RemoteAPI/class-cached-proxy.php'; -require __DIR__ . '/src/RemoteAPI/class-related-proxy.php'; -require __DIR__ . '/src/RemoteAPI/class-analytics-posts-proxy.php'; -require __DIR__ . '/src/RemoteAPI/class-wordpress-cache.php'; -require __DIR__ . '/src/Endpoints/class-base-api-proxy.php'; -require __DIR__ . '/src/Endpoints/class-related-api-proxy.php'; -require __DIR__ . '/src/Endpoints/class-analytics-posts-api-proxy.php'; -require __DIR__ . '/src/Endpoints/class-rest-metadata.php'; - add_action( 'rest_api_init', __NAMESPACE__ . '\\parsely_rest_api_init' ); /** * Registers REST Endpoints that act as a proxy to the Parse.ly API. @@ -171,8 +135,6 @@ function parsely_rest_api_init(): void { $analytics_posts_endpoint->run(); } -require __DIR__ . '/src/blocks/recommendations/class-recommendations-block.php'; - add_action( 'init', __NAMESPACE__ . '\\init_recommendations_block' ); /** * Registers the Recommendations Block. @@ -182,8 +144,6 @@ function init_recommendations_block(): void { $recommendations_block->run(); } -require __DIR__ . '/src/UI/class-recommended-widget.php'; - add_action( 'widgets_init', __NAMESPACE__ . '\\parsely_recommended_widget_register' ); /** * Registers the Parse.ly Recommended widget. @@ -192,12 +152,6 @@ function parsely_recommended_widget_register(): void { register_widget( Recommended_Widget::class ); } -require __DIR__ . '/src/Integrations/class-integration.php'; -require __DIR__ . '/src/Integrations/class-integrations.php'; -require __DIR__ . '/src/Integrations/class-amp.php'; -require __DIR__ . '/src/Integrations/class-facebook-instant-articles.php'; -require __DIR__ . '/src/Integrations/class-google-web-stories.php'; - add_action( 'init', __NAMESPACE__ . '\\parsely_integrations' ); /** * Instantiates Integrations collection and registers built-in integrations. From 507de725e4d07246641868f513cc32ce5b489e2e Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Mon, 5 Sep 2022 16:03:46 +0300 Subject: [PATCH 2/4] Composer Autoloader: Attempt to fix failing tests --- .github/workflows/e2e-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 157d47a93..a1f64aa12 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,6 +23,9 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Refresh Composer autoloader + run: composer dump-autoload + - name: Use desired version of NodeJS uses: actions/setup-node@v3.4.1 with: From b2db42d13bcc36d59a161b045c0870177bdb21b7 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Mon, 5 Sep 2022 16:10:44 +0300 Subject: [PATCH 3/4] e2e-tests.yml: Update Composer autoload description --- .github/workflows/e2e-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a1f64aa12..a1a432372 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Refresh Composer autoloader + - name: Refresh Composer autoload files run: composer dump-autoload - name: Use desired version of NodeJS From d82a086f4fbc7d6e1c0cf57adc200cbac316fe5d Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Mon, 5 Sep 2022 16:33:00 +0300 Subject: [PATCH 4/4] Optimize Composer autoload files for E2E tests and deployment workflows --- .github/workflows/deploy.yml | 1 + .github/workflows/e2e-tests.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e75ec6bbd..6d4c1a828 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,6 +10,7 @@ jobs: run: | npm ci npm run build + composer dump-autoload --classmap-authoritative - name: WordPress Plugin Deploy uses: 10up/action-wordpress-plugin-deploy@stable env: diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index a1a432372..b788cdade 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v3 - name: Refresh Composer autoload files - run: composer dump-autoload + run: composer dump-autoload --classmap-authoritative - name: Use desired version of NodeJS uses: actions/setup-node@v3.4.1