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 customization of Paired AMP URLs #5558

Merged
merged 174 commits into from
Jan 23, 2021
Merged
Changes from 1 commit
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
edacdae
Introduce context param for amp_add_paired_endpoint()
westonruter Oct 31, 2020
b6a9209
Undo adding context param to amp_add_paired_endpoint()
westonruter Oct 31, 2020
3420914
Introduce PairedAmpRouting service
westonruter Nov 2, 2020
162b13a
Move amp_redirect_old_slug_to_new_url() to PairedAmpRouting
westonruter Nov 2, 2020
33116c6
Move amp_correct_query_when_is_front_page() to PairedAmpRouting service
westonruter Nov 2, 2020
0278c8c
Add initial implementations of the 4 paired AMP permalink structures
westonruter Nov 2, 2020
6ede6bd
Add filters for implementing custom paired AMP permalink structures
westonruter Nov 3, 2020
b544dde
Fix ability to preview post using a custom paired AMP URL
westonruter Nov 3, 2020
ffaeeaf
Allow paired browsing to work for custom paired URLs
westonruter Nov 4, 2020
e53528e
Use postMessage for navigation and scrolling
westonruter Nov 5, 2020
65eaa08
Remove unused vars
westonruter Nov 5, 2020
5d4f267
Remove obsolete ampPageHasErrors and improve isAmpDocument passing
westonruter Nov 5, 2020
4d8808b
Implement heartbeat check
westonruter Nov 5, 2020
c7805af
Restore exit link in modal
westonruter Nov 5, 2020
18b32f2
Fix initialization of iframes to populate document title
westonruter Nov 5, 2020
9eb39d0
Eliminate dependence on window.name
westonruter Nov 6, 2020
1711aca
Fix event delegation for navigate messages
westonruter Nov 6, 2020
9a81427
Introduce PairedBrowsing service
westonruter Nov 6, 2020
400d037
Move option values to Options interface
westonruter Nov 6, 2020
110dafe
Make amp_get_permalink() an alias for get_permalink() in Standard mode
westonruter Nov 6, 2020
a4f2ed4
Fix infinite recursion in get_options
westonruter Nov 6, 2020
002e3a7
Fix tests
westonruter Nov 6, 2020
f5ce3ea
Improve implementation of deprecated is_paired_available method
westonruter Nov 7, 2020
78b6e5c
Rename 'permalink structure' to 'paired URL structure'
westonruter Nov 7, 2020
3c4b334
Add Paired URL Structure settings drawer
westonruter Nov 7, 2020
f0738aa
Flush rewrite rules when changing the paired URL structure
westonruter Nov 7, 2020
be3674a
Improve formatting of paired URL examples
westonruter Nov 8, 2020
54ca5b7
Add missing 'custom' to has_paired_url_structure method
westonruter Nov 8, 2020
ac532ee
Prevent appending /amp/ endpoint to URLs which already have rewrite e…
westonruter Nov 8, 2020
b516de6
Improve styling of paired URL structure items
westonruter Nov 8, 2020
a43bc0f
Use notice for custom paired URL structure; add examples
westonruter Nov 9, 2020
90f2e63
Preserve AMP endpoint through redirect_canonical
westonruter Nov 10, 2020
8678e4c
Only add necessary filters when is not canonical
westonruter Nov 10, 2020
c3c086a
Fix malformed injection of amp endpoint in paginate_links()
westonruter Nov 10, 2020
214aa00
Fix generating AMP URLs for paged, comment pages, and post previews
westonruter Nov 10, 2020
478ee5d
Fix regex for added_rewrite_endpoints_pattern
westonruter Nov 10, 2020
0956f97
Make use of using_permalinks helper method
westonruter Nov 10, 2020
f26cbfe
Check amp_is_request() once when adding filters
westonruter Nov 11, 2020
a6e7094
Eliminate use of add_rewrite_endpoint() for adding AMP suffix
westonruter Nov 11, 2020
51552b9
Account for slashing in REQUEST_URI
westonruter Nov 12, 2020
7354ccf
Tighten styling of Paired URL Structure drawer
westonruter Nov 13, 2020
f86e40e
Introduce REST filters to move logic to service
westonruter Nov 14, 2020
924c5a8
Remove PAIRED_URL_STRUCTURE_CUSTOM from Option
westonruter Nov 15, 2020
5db417f
Note redundancy of sanitize_options with enum
westonruter Nov 15, 2020
df34b6a
Remove obsolete filtering of paginate_links
westonruter Nov 15, 2020
a366020
Indicate the name of the theme/plugin which introduces the custom pai…
westonruter Nov 15, 2020
7b7c6bd
Add notice on permalink settings screen for where to manage paried UR…
westonruter Nov 15, 2020
8b9627a
Limit kses to what is actually needed
westonruter Nov 15, 2020
bfce803
Add todos
westonruter Nov 16, 2020
7c7a7bf
Prevent selecting suffix endpoint when there are conflicts
westonruter Nov 17, 2020
208d413
Ensure that 'amp' query var is always registered
westonruter Nov 17, 2020
1d5a9f5
Avoid matching segments after /amp/ in URL paths
westonruter Nov 17, 2020
be3e97b
Use DI PairedAmpService in MobileRedirection
westonruter Nov 20, 2020
2f169cc
Fix tearDown by resetting $wp_the_query
westonruter Nov 20, 2020
73ae481
Remove tests for removal of endpoint segments after /amp/
westonruter Nov 20, 2020
03ee0a6
Fix OptionsRESTControllerTest by adding item
westonruter Nov 20, 2020
59f8f28
Fix MobileRedirection tests that should not have previously passed
westonruter Nov 20, 2020
0e20815
Add filtering for wp_unique_post_slug and wp_unique_term_slug
westonruter Nov 20, 2020
bd23b4a
Remove filter_unique_term_slug since only applies when duplicate
westonruter Nov 20, 2020
a9b7c0f
Flush rewrite rules when swiching template mode
westonruter Nov 23, 2020
89717ff
Restore environment variables after modifying for parse_request
westonruter Nov 24, 2020
7005d07
Extract has/remove logic into methods
westonruter Nov 24, 2020
2b73dd5
Move redirection logic to PairedAmpRouting service
westonruter Nov 24, 2020
25f0fbb
Remove redundant is_validate_request check in amp_is_request()
westonruter Nov 24, 2020
480ff4e
Factor out duplicate redirect logic
westonruter Nov 25, 2020
1e95220
Improve identification of comment form in Comment sanitizer
westonruter Nov 25, 2020
9bab094
Remove redundant paired endpoint being added to _wp_amp_action_xhr_co…
westonruter Nov 25, 2020
dcf37a0
Fix AMP-to-AMP linking for forms with implicit GET method
westonruter Nov 25, 2020
2474e8d
Move paired comment form handling from AMP_Theme_Support to MobileRed…
westonruter Nov 25, 2020
1ce9be5
Remove obsolete finish_init tests for logic moved to PairedAmpRouting
westonruter Nov 25, 2020
bedb5a3
Deprecate amp_add_frontend_actions(), move logic to PairedAmpRouting
westonruter Nov 25, 2020
46ec29d
Improve AMP/non-AMP URL determination in add_admin_bar_menu_items
westonruter Nov 26, 2020
86c6b7c
Improve conditional logic in amp_add_admin_bar_view_link()
westonruter Nov 26, 2020
076f3f5
Prevent legacy reader paired URL structure from being available when …
westonruter Nov 26, 2020
a2d65af
Only remove paired endpoint on non-canonical sites during normalization
westonruter Nov 27, 2020
fccad70
Only consider endpoint suffix if paired URL structure uses it
westonruter Nov 27, 2020
cb680d7
Eliminate attempting to determine the semantic canonical URL
westonruter Nov 27, 2020
e64e3b0
Rework redirect_extraneous_endpoint_suffix logic to account for any e…
westonruter Nov 27, 2020
1757f24
Only add rewrite endpoint if not Standard mode
westonruter Nov 27, 2020
530bff9
Ensure /amp/ endpoint suffix is present on $wp->request
westonruter Nov 27, 2020
17dfd9e
Avoid removing rewrite endpoint when custom paired structure is in place
westonruter Nov 27, 2020
95bd077
Disable use of suffix endpoints if not using permalinks
westonruter Nov 27, 2020
a33e301
Tighten up method names
westonruter Nov 28, 2020
a3da16a
Move filter_query_vars to add_paired_hooks
westonruter Nov 28, 2020
71b1e3d
Move Admin\PairedBrowsing to Paired\BrowsingApp
westonruter Nov 28, 2020
7f0d76a
Revert "Move Admin\PairedBrowsing to Paired\BrowsingApp"
westonruter Nov 29, 2020
f0fd06b
Utilize PairedAmpRouting service in PairedBrowsing
westonruter Nov 29, 2020
cc7ab65
Remove redundant paired from method names
westonruter Nov 29, 2020
dc61126
Let endpoint suffix/query_var helper methods be static
westonruter Nov 29, 2020
92711c7
Introduce classes for defining paired URL structures
westonruter Nov 30, 2020
6b74bb5
Ignore phpstan error regarding instantiation of abstract class
westonruter Nov 30, 2020
e481eb6
Check paired URL structure if AMP query var is not present
westonruter Nov 30, 2020
0842e13
Fix passing back custom structure in REST API
westonruter Nov 30, 2020
78a124c
Omit value from query var in LegacyReaderUrlStructure
westonruter Nov 30, 2020
2d4dea4
Identify paired request in environment at plugins_loaded
westonruter Nov 30, 2020
7ffcc64
Add default implementation of has_endpoint
westonruter Nov 30, 2020
de94608
Restore allowing query var alone to enable AMP; fix tests
westonruter Dec 1, 2020
9899444
Fix root logic for restore_path_endpoint_in_environment
westonruter Dec 1, 2020
459ef2c
Move static methods into PairedUrls service
westonruter Dec 1, 2020
6c82d2f
Make PairedUrls service singular
westonruter Dec 1, 2020
d1e8732
Instantiate PairedUrlStructure via injector
westonruter Dec 1, 2020
06eb23e
Rename 'suffix endpoint' to 'path suffix' label
westonruter Dec 1, 2020
93d538b
Rename 'endpoint suffix' with 'path suffix'
westonruter Dec 1, 2020
b13f892
Check for not empty instead of isset to fix compat with PHP8
westonruter Dec 1, 2020
916a53f
Guard against URL parse failure in add_path_suffix
westonruter Dec 1, 2020
f8f3022
Prevent registering AMP preview button plugin on standard mode
westonruter Dec 2, 2020
517c280
Fix phpunit tests after f8f30224
westonruter Dec 2, 2020
97730f6
Remove erroneous internal tag from PairedUrl service
westonruter Dec 6, 2020
88ae9c2
Fix class name in phpdoc for PairedUrl service
westonruter Dec 6, 2020
43b8fdb
Fix grammar typo
westonruter Dec 6, 2020
9f6db09
Harden with array casting after applying filters
westonruter Dec 6, 2020
3995ef6
Fix grammar typo
westonruter Dec 6, 2020
fd66fb5
Improve whitespace for closure
westonruter Dec 6, 2020
a9b68cd
Rename using_permalinks to rewrite_using_permalinks
westonruter Dec 6, 2020
85d4df6
Use alternative array check to prevent filtering out empty values
westonruter Dec 6, 2020
59708b3
Add REWRITE_USING_PERMALINKS to REST API schema
westonruter Dec 6, 2020
1835abc
Utilize wp_kses for hardening amp_validated_url_status_actions
westonruter Dec 6, 2020
ac24eca
Clarify behavior of ensure_app_location
westonruter Dec 6, 2020
e324017
Fix description of LegacyTransitionalUrlStructure
westonruter Dec 6, 2020
1d76c79
Restore paired-browsing app.css internal dependency
westonruter Dec 6, 2020
72b26f4
Merge branch 'develop' of github.com:ampproject/amp-wp into add/amp-u…
westonruter Dec 16, 2020
825f865
Merge branch 'develop' of github.com:ampproject/amp-wp into add/amp-u…
westonruter Dec 30, 2020
f2d960c
Add caching for url_to_postid() and address phpcs complains from Word…
westonruter Dec 30, 2020
1076da5
Fix eslint issues identified by #5732
westonruter Dec 30, 2020
6cae4ee
Ensure wp_old_slug_redirect() is called just-in-time before redirect_…
westonruter Dec 30, 2020
d997e67
Remove assertions due to amp_add_frontend_actions() no longer being c…
westonruter Dec 30, 2020
9b08c33
Add missing type definitions to JS
westonruter Dec 31, 2020
b7efbf5
Add tooltip to top-level AMP admin bar menu item
westonruter Dec 31, 2020
85a5d22
Revert changes to is_paired_available but leave soft-deprecation
westonruter Dec 31, 2020
a31e348
Add comment to explain need for filter_comment_post_redirect
westonruter Dec 31, 2020
6e287ce
Add PHPUnit tests for PairedBrowsing
westonruter Dec 31, 2020
a911d23
Merge branch 'develop' of github.com:ampproject/amp-wp into add/amp-u…
westonruter Dec 31, 2020
c1abc85
Set Transitional mode in test_add_admin_bar_menu_item
westonruter Dec 31, 2020
c26bad4
Move PairedBrowsingTest to Admin directory
westonruter Dec 31, 2020
d122081
Add incomplete tests for PairedRouting
westonruter Dec 31, 2020
577454b
Revert "Add incomplete tests for PairedRouting"
westonruter Dec 31, 2020
bc91570
Revert "Move PairedBrowsingTest to Admin directory"
westonruter Dec 31, 2020
d046b27
Revert "Revert "Move PairedBrowsingTest to Admin directory""
westonruter Dec 31, 2020
2e62da4
Update namespace for PairedBrowsingTest to hopefully fix strange test…
westonruter Dec 31, 2020
2e9ce8d
Revert "Revert "Add incomplete tests for PairedRouting""
westonruter Jan 8, 2021
1c6506f
Check query_var for post types and taxonomies in addition to rewrite …
westonruter Jan 8, 2021
4dfc724
Update cached url_to_postid() variant to not short-circuit if host no…
westonruter Jan 8, 2021
4ee9159
Add integrated test for initialize_paired_request
westonruter Jan 8, 2021
3091059
Improve method ordering
westonruter Jan 8, 2021
56c9c41
Test REQUEST_URI suspension duriong parse request
westonruter Jan 8, 2021
9e76c56
Add tests for filter_unique_post_slug, add_paired_request_hooks, get_…
westonruter Jan 12, 2021
263bef9
Add tests for filter_default_options and sanitize_options
westonruter Jan 12, 2021
7d6aeea
Add tests for has/add/remove_endpoint, has_custom_paired_url_structur…
westonruter Jan 12, 2021
0c1235a
Remove obsolete rewrite endpoint condition logic from redirect_extran…
westonruter Jan 12, 2021
2fdf9f8
Refactor redirect_paired_amp_unavailable to dedup with redirect_paire…
westonruter Jan 13, 2021
20595e6
Add tests for PairedUrl
westonruter Jan 13, 2021
957425a
Add tests for PairedUrlStructures
westonruter Jan 13, 2021
891847a
Merge branch 'develop' of github.com:ampproject/amp-wp into add/amp-u…
westonruter Jan 14, 2021
ec6dc1d
Eliminate reliance on WP_Rewrite in favor of looking at permalink_str…
westonruter Jan 18, 2021
2be5e09
Remove nullable from jsdoc args and fix param description
westonruter Jan 21, 2021
a59a21e
Add origin checks for message events
westonruter Jan 21, 2021
f9c48ec
Make use of codeCoverageIgnore comment
westonruter Jan 21, 2021
d457385
Fix class reference
westonruter Jan 21, 2021
f93f984
Fix since phpdoc param
westonruter Jan 21, 2021
6caacd6
Remove PairedUrlExamples copy pasta
westonruter Jan 21, 2021
5a33f05
Use self instead of static
westonruter Jan 21, 2021
e73eed1
Change a todo into a note
westonruter Jan 21, 2021
73b8600
Use hidden prop instead of hidden class
westonruter Jan 21, 2021
d29f652
Rename query_var to query_param as a paired URL structure
westonruter Jan 21, 2021
71a3a0b
Add assertion for completeness
westonruter Jan 21, 2021
6cee698
Fix test class namespaces
westonruter Jan 21, 2021
081d3ef
Add newly-needed use statements for DependencyInjectedTestCase
westonruter Jan 21, 2021
0017c8b
Use WP_UnitTestCase for Test_AMP_Options_Manager
westonruter Jan 21, 2021
ac968be
Update todo for how a condition can be updated
westonruter Jan 21, 2021
651b411
Go back to using query_var instead of query_param
westonruter Jan 21, 2021
ac0d0b9
Merge branch 'develop' of github.com:ampproject/amp-wp into add/amp-u…
westonruter Jan 21, 2021
b115101
Ensure `$current_screen` global variable does not interfere with tests
pierlon Jan 23, 2021
648d340
Ensure "add analytics" button is in view
pierlon Jan 23, 2021
180fdbc
Wait for succss notice to appear
pierlon Jan 23, 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
Prev Previous commit
Next Next commit
Move Admin\PairedBrowsing to Paired\BrowsingApp
westonruter committed Nov 28, 2020

Verified

This commit was signed with the committer’s verified signature. The key has expired.
westonruter Weston Ruter
commit 71b1e3dd1aeb7134dd6122d62357b1a63766ae92
2 changes: 1 addition & 1 deletion .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
'admin.onboarding_wizard' => \AmpProject\AmpWP\Admin\OnboardingWizardSubmenuPage::class,
'admin.options_menu' => \AmpProject\AmpWP\Admin\OptionsMenu::class,
'admin.polyfills' => \AmpProject\AmpWP\Admin\Polyfills::class,
'admin.paired_browsing' => \AmpProject\AmpWP\Admin\PairedBrowsing::class,
'amp_slug_customization_watcher' => \AmpProject\AmpWP\AmpSlugCustomizationWatcher::class,
'css_transient_cache.ajax_handler' => \AmpProject\AmpWP\Admin\ReenableCssTransientCachingAjaxAction::class,
'css_transient_cache.monitor' => \AmpProject\AmpWP\BackgroundTask\MonitorCssTransientCaching::class,
@@ -26,6 +25,7 @@
'injector' => \AmpProject\AmpWP\Infrastructure\Injector::class,
'mobile_redirection' => \AmpProject\AmpWP\MobileRedirection::class,
'obsolete_block_attribute_remover' => \AmpProject\AmpWP\ObsoleteBlockAttributeRemover::class,
'paired.browsing_app' => \AmpProject\AmpWP\Paired\BrowsingApp::class,
'plugin_activation_notice' => \AmpProject\AmpWP\Admin\PluginActivationNotice::class,
'plugin_registry' => \AmpProject\AmpWP\PluginRegistry::class,
'plugin_suppression' => \AmpProject\AmpWP\PluginSuppression::class,
4 changes: 2 additions & 2 deletions includes/templates/amp-paired-browsing.php
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@
*/

use AmpProject\AmpWP\QueryVar;
use AmpProject\AmpWP\Admin\PairedBrowsing;
use AmpProject\AmpWP\Paired\BrowsingApp;

$url = remove_query_arg( [ PairedBrowsing::APP_QUERY_VAR, QueryVar::NOAMP ], amp_get_current_url() );
$url = remove_query_arg( [ BrowsingApp::APP_QUERY_VAR, QueryVar::NOAMP ], amp_get_current_url() );
$non_amp_url = add_query_arg( QueryVar::NOAMP, QueryVar::NOAMP_MOBILE, $url );
$amp_url = amp_add_paired_endpoint( $url );
?>
2 changes: 1 addition & 1 deletion src/AmpWpPlugin.php
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ final class AmpWpPlugin extends ServiceBasedPlugin {
'admin.onboarding_wizard' => Admin\OnboardingWizardSubmenuPage::class,
'admin.options_menu' => Admin\OptionsMenu::class,
'admin.polyfills' => Admin\Polyfills::class,
'admin.paired_amp_routing' => Admin\PairedBrowsing::class,
'admin.paired_amp_routing' => Paired\BrowsingApp::class,
'amp_slug_customization_watcher' => AmpSlugCustomizationWatcher::class,
'css_transient_cache.ajax_handler' => Admin\ReenableCssTransientCachingAjaxAction::class,
'css_transient_cache.monitor' => BackgroundTask\MonitorCssTransientCaching::class,
14 changes: 7 additions & 7 deletions src/Admin/PairedBrowsing.php → src/Paired/BrowsingApp.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* Class PairedBrowsing.
* Class BrowsingApp.
*
* @package AmpProject\AmpWP
*/

namespace AmpProject\AmpWP\Admin;
namespace AmpProject\AmpWP\Paired;

use AMP_Options_Manager;
use AMP_Theme_Support;
@@ -27,7 +27,7 @@
* @since 1.5.0
* @internal
*/
final class PairedBrowsing implements Service, Registerable, Conditional {
final class BrowsingApp implements Service, Registerable, Conditional {

/**
* Query var for requests to open the app.
@@ -53,7 +53,7 @@ public static function is_needed() {
}

/**
* PairedBrowsing constructor.
* BrowsingApp constructor.
*
* @param UserAccess $dev_tools_user_access DevTools User Access.
*/
@@ -152,8 +152,8 @@ public function init_client() {

$is_amp_request = amp_is_request();
$current_url = amp_get_current_url();
$amp_url = $is_amp_request ? $current_url : amp_add_paired_endpoint( $current_url );
$non_amp_url = ! $is_amp_request ? $current_url : amp_remove_paired_endpoint( $current_url );
$amp_url = $is_amp_request ? $current_url : amp_add_paired_endpoint( $current_url ); // @todo Use the service.
$non_amp_url = ! $is_amp_request ? $current_url : amp_remove_paired_endpoint( $current_url ); // @todo Use the service.

wp_add_inline_script(
$handle,
@@ -217,7 +217,7 @@ public function get_paired_browsing_url( $url = null ) {
if ( ! $url ) {
$url = amp_get_current_url();
}
$url = amp_remove_paired_endpoint( $url );
$url = amp_remove_paired_endpoint( $url ); // @todo Use the service.
$url = remove_query_arg(
[ QueryVar::NOAMP, AMP_Validated_URL_Post_Type::VALIDATE_ACTION, AMP_Validation_Manager::VALIDATION_ERROR_TERM_STATUS_QUERY_VAR ],
$url