-
Notifications
You must be signed in to change notification settings - Fork 278
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
Conditionally Enqueue Admin Scripts and Styles for Enhanced Authorize Application Screen Visibility #8504
Comments
I've added the AC and IB and have moved directly to IBR. |
Hi @hussain-t, please can you take a look at this #8503 (comment), and make appropriate changes to this issue too? |
Thanks, @techanvil. "Authorize Application" sounds good to me. I've updated the AC and IB accordingly. |
IB LGTM, nice one @hussain-t! ✅ |
@techanvil, I have updated the AC and IB to align with the latest confirmation regarding the
Based on this, our checks are now focused on the specific static path rather than the domain. |
@hussain-t cool, thanks for the heads up. On a minor related note, the IB specifies checking using a regex pattern - we might find a substring match is sufficient, but we can figure that out at implementation time too. |
…ance/#8504-conditionally-enqueue-admin-scripts.
QA Update ✅Tested on develop branch on WP 6.5.2 and PHP 8.0 and results are as expected:
This is working well @hussain-t . I am moving this ticket to Approval column. |
Feature Description
Implement custom logic to conditionally load admin scripts and styles to enhance the WordPress Authorize Application screen based on the domain name within the
success_url
parameter, ensuring that enhancements are only applied for users with Site Kit for Google services.For more information, refer to the Custom Style Application and Identification Strategy sections in the design doc.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Authorize_Application
must be successfully implemented within theGoogle\Site_Kit\Core\Admin
namespace. This class will encapsulate all conditional logic for loading scripts and styles on the Authorize Applications screen.Authorize_Application
class must control the conditional enqueuing of scripts and styles based on two key criteria: the domain name in thesuccess_url
parameter and confirmation that the current page is theauthorize-application
page.Authorize_Application
class must confirm that the current page is theauthorize-application
page before enqueueing any scripts or styles. This ensures that enhancements are targeted and do not affect other areas of the admin dashboard.success_url
parameter contains the specific path/settings/authorization/wordpress
, indicating that the user interaction is related to the intended integration.authorize-application
and thesuccess_url
domain is correctly identified as a*.google.com
domain.Implementation Brief
In the
includes/Core/Admin
directory:Authorize_Application
class within theGoogle\Site_Kit\Core\Admin
namespace.Constructor Method
__construct
method within theAuthorize_Application
class that receives Context$context
and Assets$assets
as parameters.Methods
register()
:enqueue_assets
method to the WordPressadmin_enqueue_scripts
action, ensuring the Authorize Application styles are conditionally loaded.is_authorize_application_screen
:authorize-application
page. Utilizeget_current_screen()->id
to determine the screen identity.is_google_service
:success_url
parameter to ensure it matches the specified path/settings/authorization/wordpress
.parse_url()
and check it against a regex pattern.enqueue_assets()
:Assets::enqueue_asset
method to enqueue the stylesheet.googlesitekit-authorize-application
stylesheet if bothis_authorize_application_screen
andis_google_service
return true.Add the Stylesheet to the Assets Class
In
includes/Core/Assets/Assets.php
:Assets::get_assets
method to include thegooglesitekit-authorize-application
stylesheet using theStylesheet
constructor.Register the Authorize_Application Class
In
includes/Plugin.php
:Authorize_Application
class within thePlugin::register
method.Assets
class.Test Coverage
Authorize_Application
class.QA Brief
Testing with Site Kit Activated and Google Domain:
example.com
with your actual site domain:Yes, I approve of this connection
button displays with the color#0B57D0
.Testing with Non-Google Domain:
success_url
Domain: Change thesuccess_url
to a non-Google domain and access the same URL:Yes, I approve of this connection
button reverts to the default WordPress button color.Testing with Site Kit Deactivated:
success_url
pointing to a Google domain:Yes, I approve of this connection
button displays the default WordPress styles, showing that Site Kit enhancements are not applied without the plugin activated.Changelog entry
The text was updated successfully, but these errors were encountered: