Conversation
|
Will take over reviewing this PR. |
|
@mchirag2002 Could you add screenshot or a video recording on what has changes where the new settings are ? |
There was a problem hiding this comment.
Pull Request Overview
This PR adds multisite network support for the Google Login plugin, allowing network administrators to configure OAuth credentials and settings globally across all sites in a WordPress multisite installation.
Key Changes:
- Adds network-level settings management for multisite installations
- Implements
get_client_id()andget_client_secret()methods to retrieve credentials from network settings in multisite environments - Adds an "Apply Globally" option to enforce network settings across all subsites
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| src/Modules/Settings.php | Core changes implementing network settings registration, rendering, and saving functionality with UI toggle logic |
| src/Container.php | Updates GoogleClient instantiation to use the new getter methods instead of direct property access |
| readme.txt | Documents multisite configuration in the setup instructions |
| README.md | Adds multisite setup documentation explaining the network administrator workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'client_secret' => '', | ||
| ]; | ||
|
|
||
| $settings = $_POST['wp_google_login_network_settings'] ?? []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
There was a problem hiding this comment.
While the phpcs:ignore comment indicates intentional access to unsanitized input, the array keys should be validated using wp_unslash() before processing. Consider wrapping $_POST['wp_google_login_network_settings'] with wp_unslash() to handle escaped input properly: $settings = isset( $_POST['wp_google_login_network_settings'] ) ? wp_unslash( $_POST['wp_google_login_network_settings'] ) : [];
| $settings = $_POST['wp_google_login_network_settings'] ?? []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| $settings = isset( $_POST['wp_google_login_network_settings'] ) ? wp_unslash( $_POST['wp_google_login_network_settings'] ) : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
@mi5t4n Updated the PR description to add the requested video. |
| * Register the settings, section and fields. | ||
| * Retrieves the Google OAuth Client ID, always from the network settings in multisite. | ||
| * | ||
| * @return string |
There was a problem hiding this comment.
Do add @since n.e.x.t and replace n.e.x.t with plugin version during release.
|
@mchirag2002 Left some comments. |
|
@mchirag2002 I was able to reproduce the issue again. It looks like we need to clear all the old settings in the multisite setup and create a completely fresh configuration. Note Remove all the settings from all the site options by searching through Kazam_screencast_00000.mp4 |
mi5t4n
left a comment
There was a problem hiding this comment.
We have same two text in the network settings and the membership link is not working in the network settings and in the invidividual site settings. https://prnt.sc/ao-MKoXXn_2B
src/Modules/Settings.php
Outdated
| public function apply_globally_field( $args = [] ): void { | ||
| $network_options = get_site_option( 'wp_google_login_network_settings', [] ); | ||
| ?> | ||
| <input type="checkbox" name="wp_google_login_network_settings[apply_globally]" id="apply-globally" value="1" <?php checked( ! empty( $network_options['apply_globally'] ) ); ?> /> |
There was a problem hiding this comment.
| <input type="checkbox" name="wp_google_login_network_settings[apply_globally]" id="apply-globally" value="1" <?php checked( ! empty( $network_options['apply_globally'] ) ); ?> /> | |
| <input | |
| type="checkbox" | |
| name="wp_google_login_network_settings[apply_globally]" | |
| id="apply-globally" | |
| value="1" | |
| <?php checked( ! empty( $network_options['apply_globally'] ) ); ?> | |
| /> |
src/Modules/Settings.php
Outdated
| <label style='display:block;margin-top:6px;'><input | ||
| type='checkbox' | ||
| name='wp_google_login_network_settings[one_tap_login]' | ||
| id="one-tap-login" <?php checked( $checked ); ?> | ||
| value='1'> | ||
| <?php esc_html_e( 'One Tap Login', 'login-with-google' ); ?> | ||
| </label> |
There was a problem hiding this comment.
| <label style='display:block;margin-top:6px;'><input | |
| type='checkbox' | |
| name='wp_google_login_network_settings[one_tap_login]' | |
| id="one-tap-login" <?php checked( $checked ); ?> | |
| value='1'> | |
| <?php esc_html_e( 'One Tap Login', 'login-with-google' ); ?> | |
| </label> | |
| <label style='display:block;margin-top:6px;'> | |
| <input | |
| type='checkbox' | |
| name='wp_google_login_network_settings[one_tap_login]' | |
| id="one-tap-login" <?php checked( $checked ); ?> | |
| value='1' | |
| /> | |
| <?php esc_html_e( 'One Tap Login', 'login-with-google' ); ?> | |
| </label> |
src/Modules/Settings.php
Outdated
| if ( $readonly ) { | ||
| echo 'disabled'; | ||
| } |
There was a problem hiding this comment.
| if ( $readonly ) { | |
| echo 'disabled'; | |
| } | |
| echo ( $readonly ? 'disabled' : '' ) |
| * @return void | ||
| */ | ||
| public function user_registration(): void { | ||
| public function user_registration( $args = [] ): void { |
There was a problem hiding this comment.
We need to add the version where $args parameter was introduced.
src/Modules/Settings.php
Outdated
| <input type='checkbox' | ||
| name='wp_google_login_network_settings[registration_enabled]' | ||
| id="user-registration" <?php checked( $checked ); ?> | ||
| value='1'> |
There was a problem hiding this comment.
| <input type='checkbox' | |
| name='wp_google_login_network_settings[registration_enabled]' | |
| id="user-registration" <?php checked( $checked ); ?> | |
| value='1'> | |
| <input | |
| type='checkbox' | |
| name='wp_google_login_network_settings[registration_enabled]' | |
| id="user-registration" <?php checked( $checked ); ?> | |
| value='1' | |
| > |
| * | ||
| * @return void | ||
| */ | ||
| public function save_network_settings(): void { |
There was a problem hiding this comment.
Add @since n.e.x.t for newly added functions.
| <h1><?php esc_html_e( 'Login with Google Network Settings', 'login-with-google' ); ?></h1> | ||
| <form method="post" action="edit.php?action=wp_google_login_network_settings"> | ||
| <?php | ||
| wp_nonce_field( 'wp_google_login_network-options' ); |
There was a problem hiding this comment.
Let's not use wp_google_login prefix as it indicates it's WP core specific. We have to use our own specific rtcamp_login_with_google_network-options. Apply similar thing to newly added nonce, settings, ids or input names.
There was a problem hiding this comment.
@mi5t4n this convention of using wp_google_login is present across the codebase since the beginning, and although I completely agree with you to alter the prefix, I think for code consistency we can create a new task for code refactoring and tackle it over there.
Otherwise once this PR is merged, we will be having some filters/nonces with different prefix and others with different prefix.
src/Modules/Settings.php
Outdated
| add_submenu_page( | ||
| 'settings.php', | ||
| __( 'Login with Google Network Settings', 'login-with-google' ), | ||
| __( 'Login with Google', 'login-with-google' ), |
There was a problem hiding this comment.
| __( 'Login with Google', 'login-with-google' ), | |
| _x( 'Login with Google', 'Page title', 'login-with-google' ), |
Description
Network AdminsClient IDandClient Secretto the network level and removed them from subsitesOnetap,Onetap locations,Create New Users, andWhitelisted domainsneed to be configured from the individual sites.ToDo before making this release
@sinceversion comments in the codebase with the release version.Demo video for the changes implemented
https://drive.google.com/file/d/1UVpIxZGK58cSi3I7myc67eyPuBmZVzcO/view?usp=sharing
Fixes
Make the plugin multisite compatible (#119)