-
Notifications
You must be signed in to change notification settings - Fork 330
Description
Feature Description
The current logic used to render the necessary script tag(s) for Sign in With Google does not conform to the standard used by other modules with a tag, and does not use the Module_With_Tag interface nor an implementation/extension of Module_Web_Tag. Instead, logic is self-contained within the main Sign_In_With_Google class by way of the render_signinwithgoogle() method.
The logic within the the render_signinwithgoogle() method, along with necessary tag guard logic (if any) should be migrated into a Web_Tag instance and incorporated into the main Sign_In_With_Google class via the same pattern used by other modules, i.e. use of a register_tag() method hooked to template_redirect action (and/or other actions applicable to SiWG given the locations the script needs to render), and creation of an applicable Web_Tag class which itself extends from Module_Web_Tag. This Web_Tag class should contain much (if not all) of the logic currently contained within the render_signinwithgoogle() method.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The
Sign_In_With_Googleclass implements theModule_With_Taginterface - All necessary Sign in With Google scripts/tags are rendered using an applicable tag class within the SiWG namespace, which itself is an extension of the
Module_Web_Tagclass, i.e.Google\Site_Kit\Modules\Sign_In_With_Google\Web_Tag - Tag registration is handled within the main
Sign_In_With_Googleusing methods required by theModule_With_Taginterface - All (or as much of) the script rendering and guarding logic is moved from the current
render_signinwithgoogle()method and into applicable methods within the SiWG specificWeb_Tagclass
Implementation Brief
- Add
includes/Modules/Sign_In_With_Google/Tag_Guard.php- Should extend
Module_Tag_Guard, and includeModule_Settingsin the constructor - You can check
includes/Modules/Reader_Revenue_Manager/Tag_Guard.phpfor an example - Add
can_activate- Move over the logic from this method
private function can_render_signinwithgoogle() {
- Move over the logic from this method
- Should extend
- Add
includes/Modules/Sign_In_With_Google/Web_Tag.php- It should extend
Module_Web_Tag - Add
registermethod:- Hook into
wp_footerandlogin_footer, and invoke callbackrender_signinwithgoogle_scripts - Add
render_signinwithgoogle_scriptsmethod and move over the logic fromGoogle\Site_Kit\Modules\Sign_In_With_Google::render_signinwithgoogle$this->can_render_signinwithgoogle()conditional won't be needed here anymore, as this is checked as part of the tag guard checks
- Hook into
- It should extend
- Update
Google\Site_Kit\Modules\Sign_In_With_Google- It should implement
Module_With_Tag - In
registermethod:- Hook into the
template_redirectaction and invokeregister_tagmethod
- Hook into the
- Add
register_tagmethod- You can check
Google\Site_Kit\Modules\Ads::register_tagas an example - Instantiate
Web_TagusingclientIDsetting for tag ID argument - Use only newly added
Tag_Guardfor guards$tag->use_guard, others are not needed as they are not affecting existing rendering. - Register tag invoking
$tag->register()
- You can check
- It should implement
Test Coverage
- Split tests from
tests/phpunit/integration/Modules/Sign_In_With_GoogleTest.phpand move the parts fortest_render_signinwithgoogleto the tests for web tag class
QA Brief
- Enable the SiwG module and test login and registration continue to load and function as expected on the wp-login page and via the login button block within a post or page. See the epic bug bash instructions for details.
Changelog entry
- Refactor Sign in with Google to use common web tag infrastructure.