Skip to content

Conversation

@mchirag2002
Copy link
Contributor

Description

  • This PR contains the changes that add a new custom filter that can be used to enqueue the one tap scripts on certain specific pages instead of it being available only on login pages or sitewide.

Fixes

Add Ability to Render One-Tap Login Code/JS on Specific Pages with Filters (#279)

Copy link
Contributor

@rtBot rtBot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code analysis identified issues

action-phpcs-code-review has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 4 errors

⚠️ 1 warning


Powered by rtCamp's GitHub Actions Library

Copy link
Member

@mi5t4n mi5t4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few comments. Please feel free to reach out if you have any questions.

* @return void
*/
public function maybe_add_one_tap_to_frontend(): void {
$show_on_this_page = apply_filters(
Copy link
Member

@mi5t4n mi5t4n Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter doesn’t appear to be working. Even when it returns false, the file build/js/onetap.js is still being loaded on every page.

Steps to reproduce

  1. Goto the Login With Google Settings under the WP Settings menu.
  2. Populate the required credentials like Client ID and Client Secret.
  3. Checked the Create New User and Enable One Tap Login
  4. Select the Enable One Tap Login Site-Wide option
  5. Add below snippet code in Hello Dolly plugin or the in the current theme's functions.php file.
add_filter( 'rtcamp.google_one_tap_show', function( $is_allowed ) {
	return ! is_home();
});
  1. Navigate to the homepage
  2. We can still see the onetap pop-up view

Code that is probably causing the above issue

wp_register_script(
'login-with-google-one-tap-js',
trailingslashit( plugin()->url ) . 'assets/build/js/' . $filename,
[
'wp-i18n',
],
filemtime( trailingslashit( plugin()->path ) . 'assets/build/js/onetap.js' ),
true
);
wp_add_inline_script(
'login-with-google-one-tap-js',
'var TempAccessOneTap=' . json_encode( $data ), //phpcs:disable WordPress.WP.AlternativeFunctions.json_encode_json_encode
'before'
);
wp_enqueue_script( 'login-with-google-one-tap-js' );

*
* @return void
*/
public function maybe_add_one_tap_to_frontend(): void {
Copy link
Member

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.t to newly added function.

'rtcamp.google_one_tap_show',
( 'sitewide' === $this->settings->one_tap_login_screen )
);

Copy link
Member

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants