Skip to content
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

Settings page: Update "Track logged-in users" option texts for clarity #1071

Merged
merged 7 commits into from
Sep 13, 2022
2 changes: 1 addition & 1 deletion src/UI/class-metadata-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function render_metadata( string $meta_type ): void {
$this->parsely->api_key_is_missing() ||

// Chosen not to track logged-in users.
( ! $parsely_options['track_authenticated_users'] && $this->parsely->parsely_is_user_logged_in() ) ||
( ! $parsely_options['track_authenticated_users'] && $this->parsely->is_blog_member_logged_in() ) ||

// 404 pages are not tracked.
is_404() ||
Expand Down
5 changes: 4 additions & 1 deletion src/UI/class-settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ private function initialize_basic_section(): void {
);

// Track logged-in users.
$h = __( 'By default, the plugin will track the activity of users that are logged into this site. You can change this setting to only track the activity of anonymous visitors. Note: You will no longer see the Parse.ly tracking code on your site if you browse while logged in.', 'wp-parsely' );
$h = __( 'Choose whether logged-in visitors should be tracked. You will no longer see the Parse.ly tracking code on your site if you browse while logged-in.', 'wp-parsely' );
if ( is_multisite() ) {
$h .= __( ' Note: For WordPress multisite, a user must be logged-in to the current site to be considered logged-in.', 'wp-parsely' );
}
add_settings_field(
'track_authenticated_users',
__( 'Track Logged-in Users', 'wp-parsely' ),
Expand Down
7 changes: 4 additions & 3 deletions src/class-parsely.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,15 @@ public static function get_settings_url( int $_blog_id = null ): string {
}

/**
* Checks to see if Parse.ly user is logged in.
* Checks to see if the current user is a member of the current blog.
*
* @return bool
*/
public function parsely_is_user_logged_in(): bool {
// can't use $blog_id here because it futzes with the global $blog_id.
public function is_blog_member_logged_in(): bool {
// Can't use $blog_id here because it futzes with the global $blog_id.
$current_blog_id = get_current_blog_id();
$current_user_id = get_current_user_id();

return is_user_member_of_blog( $current_user_id, $current_blog_id );
}

Expand Down
2 changes: 1 addition & 1 deletion src/class-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function enqueue_js_tracker(): void {
if ( in_array( get_post_type(), $parsely_options['track_post_types'], true ) && ! Parsely::post_has_trackable_status( $post ) ) {
$display = false;
}
if ( ! $parsely_options['track_authenticated_users'] && $this->parsely->parsely_is_user_logged_in() ) {
if ( ! $parsely_options['track_authenticated_users'] && $this->parsely->is_blog_member_logged_in() ) {
$display = false;
}
if ( ! in_array( get_post_type(), $parsely_options['track_post_types'], true ) && ! in_array( get_post_type(), $parsely_options['track_page_types'], true ) ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/ScriptsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function test_enqueue_js_api_with_secret(): void {
* @uses \Parsely\Parsely::api_key_is_missing
* @uses \Parsely\Parsely::api_key_is_set
* @uses \Parsely\Parsely::get_options
* @uses \Parsely\Parsely::parsely_is_user_logged_in
* @uses \Parsely\Parsely::is_blog_member_logged_in
* @uses \Parsely\Parsely::get_api_key
* @uses \Parsely\Parsely::get_tracker_url
* @uses \Parsely\Parsely::post_has_trackable_status
Expand Down Expand Up @@ -366,7 +366,7 @@ public function test_do_not_track_logged_in_users(): void {
* @uses \Parsely\Parsely::api_key_is_missing
* @uses \Parsely\Parsely::api_key_is_set
* @uses \Parsely\Parsely::get_options
* @uses \Parsely\Parsely::parsely_is_user_logged_in
* @uses \Parsely\Parsely::is_blog_member_logged_in
* @uses \Parsely\Parsely::post_has_trackable_status
* @uses \Parsely\Parsely::update_metadata_endpoint
* @uses \Parsely\Parsely::get_api_key
Expand Down