-
Notifications
You must be signed in to change notification settings - Fork 27
Adding custom filter for one-tap login #282
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -94,6 +94,10 @@ public function init(): void { | |||||||||||||||||||||||||||||||||||||
| add_action( 'wp_enqueue_scripts', [ $this, 'one_tap_scripts' ] ); | ||||||||||||||||||||||||||||||||||||||
| add_action( 'wp_footer', [ $this, 'one_tap_prompt' ], 10000 ); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Defer the custom one-tap page addition to 'wp' action to ensure all conditionals work. | ||||||||||||||||||||||||||||||||||||||
| add_action( 'wp', [ $this, 'maybe_add_one_tap_to_frontend' ] ); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| add_action( 'login_enqueue_scripts', [ $this, 'one_tap_scripts' ] ); | ||||||||||||||||||||||||||||||||||||||
| add_action( 'login_footer', [ $this, 'one_tap_prompt' ] ); | ||||||||||||||||||||||||||||||||||||||
| add_action( 'wp_ajax_nopriv_validate_id_token', [ $this, 'validate_token' ] ); | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -106,6 +110,25 @@ public function init(): void { | |||||||||||||||||||||||||||||||||||||
| // Add filters here. | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||
| * Maybe add one-tap to frontend based on settings. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * Use this filter as per requirement to show or hide one-tap on specific pages, the filter passes a boolean value. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
| * @return void | ||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||
| public function maybe_add_one_tap_to_frontend(): void { | ||||||||||||||||||||||||||||||||||||||
| $show_on_this_page = apply_filters( | ||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This filter doesn’t appear to be working. Even when it returns Steps to reproduce
add_filter( 'rtcamp.google_one_tap_show', function( $is_allowed ) {
return ! is_home();
});
Code that is probably causing the above issuelogin-with-google/src/Modules/OneTapLogin.php Lines 173 to 190 in 2a11dd6
|
||||||||||||||||||||||||||||||||||||||
| 'rtcamp.google_one_tap_show', | ||||||||||||||||||||||||||||||||||||||
mchirag2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
| ( 'sitewide' === $this->settings->one_tap_login_screen ) | ||||||||||||||||||||||||||||||||||||||
mchirag2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
mchirag2002 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another thing, we have to version and document the newly added filter as well. |
||||||||||||||||||||||||||||||||||||||
| if ( $show_on_this_page ) { | ||||||||||||||||||||||||||||||||||||||
| add_action( 'wp_enqueue_scripts', [ $this, 'one_tap_scripts' ] ); | ||||||||||||||||||||||||||||||||||||||
| add_action( 'wp_footer', [ $this, 'one_tap_prompt' ], 10000 ); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||
| * Show one tap prompt markup. | ||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
@since n.e.x.tto newly added function.