Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back-compat to old WP versions for new v2.2 features #6773

Merged
merged 37 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2a69d65
Check dependency_support in is_needed for AmpPlugins, AmpThemes, and …
westonruter Dec 8, 2021
949eeb3
Add status=active parameter to /wp/v2/themes REST API call for WP<5.7…
westonruter Dec 8, 2021
7fa097e
Do not search for blocks when on WordPress 4.9 and older
delawski Dec 8, 2021
f57f25c
Fail silently if plugins/themes endpoints are not available
delawski Dec 8, 2021
3f3cb57
Ensure Onboarding Wizard works on WordPress 4.9
delawski Dec 8, 2021
148d397
Fetch used plugin and theme fields only
delawski Dec 8, 2021
6b553c4
Update message copy
delawski Dec 8, 2021
c8a2d41
Add minimum WordPress version check for Support page
dhaval-parekh Dec 8, 2021
da361ae
Update unit test cases
dhaval-parekh Dec 8, 2021
bec8cbe
Fix phpcs issues
dhaval-parekh Dec 8, 2021
15a2a0f
Improve theme/plugin unavailability messaging
westonruter Dec 8, 2021
cff0d8f
Ensure ID attribute is added to scripts in WP<5.5
westonruter Dec 8, 2021
7345070
Harden injection of ID attribute into script loader tag
westonruter Dec 8, 2021
9360c3b
Fix regex pattern inversion
westonruter Dec 8, 2021
b58284d
Prevent access to validation UI when dependency_support is absent
westonruter Dec 8, 2021
2913e59
Fix URLValidationRESTControllerTest after new DependencySupport depen…
westonruter Dec 9, 2021
d830cb6
Remove obsolete SavePostValidationEvent
westonruter Dec 7, 2021
75d902c
Block access to AMP Customizer if site lacks dependency_support
westonruter Dec 9, 2021
ae04461
Fix typo
delawski Dec 9, 2021
c5ef2ec
Fix tests for restricting DevTools to whether DependencySupport present
westonruter Dec 9, 2021
0f2430b
Further fix PHPUnit tests after c5ef2ec0f
westonruter Dec 9, 2021
cc835a3
Merge branch 'develop' of github.com:ampproject/amp-wp into add/wp-ba…
westonruter Dec 10, 2021
c1e18f8
Temporarily register dependency_support as first service
westonruter Dec 10, 2021
721916a
Revert "Ensure Onboarding Wizard works on WordPress 4.9"
westonruter Dec 10, 2021
30b78fc
Add dependency_support as a requirement for AmpPlugins & AmpThemes
schlessera Dec 12, 2021
3214f92
Add missing HasRequirements interface to PluginActivationSiteScan
westonruter Dec 13, 2021
942f91e
Add codeCoverageIgnore comments
westonruter Dec 13, 2021
00ec54f
Further harden regex in amp_ensure_id_attribute_on_script_loader_tag()
westonruter Dec 13, 2021
24943e9
Restore wp_version in test tearDown method
westonruter Dec 13, 2021
e5c562b
Run amp_ensure_id_attribute_on_script_loader_tag at earliest priority
westonruter Dec 13, 2021
0dcdc77
Fix tests in WP 4.9..5.1
westonruter Dec 13, 2021
6d26e84
Fix test_prepare_response_standard in WP<5.5
westonruter Dec 13, 2021
f1c6208
Add tests for AMP_Customizer_Design_Settings
westonruter Dec 13, 2021
ccb9090
Add tests for amp_bootstrap_plugin()
westonruter Dec 13, 2021
6dbd043
Fix test_init_customizer to account for Gutenberg being active
westonruter Dec 13, 2021
779104f
Use remove_all_filters instead of remove_all_actions for purity sake
westonruter Dec 13, 2021
ff7e7b7
Hide DevTools toggles when dependency_support is absent
westonruter Dec 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/src/components/themes-context-provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function ThemesContextProvider( {

try {
const fetchedThemes = await apiFetch( {
path: '/wp/v2/themes',
path: '/wp/v2/themes?status=active',
} );

if ( hasUnmounted.current === true ) {
Expand Down
11 changes: 10 additions & 1 deletion includes/validation/class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,16 @@ public static function add_validation_error_sourcing() {

add_filter( 'do_shortcode_tag', [ __CLASS__, 'decorate_shortcode_source' ], PHP_INT_MAX, 2 );
add_filter( 'embed_oembed_html', [ __CLASS__, 'decorate_embed_source' ], PHP_INT_MAX, 3 );
add_filter( 'the_content', [ __CLASS__, 'add_block_source_comments' ], 8 ); // The do_blocks() function runs at priority 9.

// The `WP_Block_Type_Registry` class was added in WordPress 5.0.0. Because of that it sometimes caused issues
// on the AMP Validated URL screen when on WordPress 4.9.
if ( class_exists( 'WP_Block_Type_Registry' ) ) {
westonruter marked this conversation as resolved.
Show resolved Hide resolved
add_filter( 'the_content', [
__CLASS__,
'add_block_source_comments'
], 8 ); // The do_blocks() function runs at priority 9.
}

add_filter( 'the_editor', [ __CLASS__, 'filter_the_editor_to_detect_sources' ] );
}

Expand Down
5 changes: 5 additions & 0 deletions src/Admin/AmpPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use AmpProject\AmpWP\Infrastructure\Delayed;
use AmpProject\AmpWP\Infrastructure\Registerable;
use AmpProject\AmpWP\Infrastructure\Service;
use AmpProject\AmpWP\Services;
use WP_Screen;
use function get_current_screen;
use stdClass;
Expand Down Expand Up @@ -61,6 +62,10 @@ public static function get_registration_action() {
*/
public static function is_needed() {

if ( ! Services::get( 'dependency_support' )->has_support() ) {
return false;
}
westonruter marked this conversation as resolved.
Show resolved Hide resolved

/** This filter is documented in src/Admin/AmpThemes.php */
return is_admin() && apply_filters( 'amp_compatible_ecosystem_shown', true, 'plugins' );
}
Expand Down
5 changes: 5 additions & 0 deletions src/Admin/AmpThemes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use AmpProject\AmpWP\Infrastructure\Delayed;
use AmpProject\AmpWP\Infrastructure\Registerable;
use AmpProject\AmpWP\Infrastructure\Service;
use AmpProject\AmpWP\Services;
use WP_Screen;
use stdClass;

Expand Down Expand Up @@ -60,6 +61,10 @@ public static function get_registration_action() {
*/
public static function is_needed() {

if ( ! Services::get( 'dependency_support' )->has_support() ) {
return false;
}
westonruter marked this conversation as resolved.
Show resolved Hide resolved

/**
* Filters whether to show AMP compatible ecosystem in the admin.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Admin/OnboardingWizardSubmenuPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ protected function add_preload_rest_paths() {
),
'/wp/v2/plugins',
'/wp/v2/settings',
'/wp/v2/themes',
'/wp/v2/themes?status=active',
'/wp/v2/users/me',
];

Expand Down
2 changes: 1 addition & 1 deletion src/Admin/OptionsMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected function add_preload_rest_paths() {
),
'/wp/v2/plugins',
'/wp/v2/settings',
'/wp/v2/themes',
'/wp/v2/themes?status=active',
'/wp/v2/users/me',
];

Expand Down
4 changes: 3 additions & 1 deletion src/Admin/PluginActivationSiteScan.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

use AMP_Options_Manager;
use AMP_Validation_Manager;
use AmpProject\AmpWP\DevTools\UserAccess;
use AmpProject\AmpWP\Infrastructure\Conditional;
use AmpProject\AmpWP\Infrastructure\Delayed;
use AmpProject\AmpWP\Infrastructure\Registerable;
use AmpProject\AmpWP\Infrastructure\Service;
use AmpProject\AmpWP\Services;

/**
* Class PluginActivationSiteScan
Expand Down Expand Up @@ -67,6 +67,8 @@ public static function is_needed() {
return (
is_admin()
&&
Services::get( 'dependency_support' )->has_support()
&&
! is_network_admin()
&&
'plugins.php' === $pagenow
Expand Down
1 change: 1 addition & 0 deletions src/Admin/SupportScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public static function is_needed() {
return (
is_admin()
&&
// Note: The view_site_health_checks capability was introduced in WordPress 5.2, so this will return false in older versions.
dhaval-parekh marked this conversation as resolved.
Show resolved Hide resolved
self::has_cap()
);
}
Expand Down