Skip to content

Commit 6c5c670

Browse files
authored
Merge pull request #201 from brainstormforce/latest-optin-changes
PS-1385: Make Analytics optin changes in AIOSRS
2 parents fb15f71 + f1ddc7d commit 6c5c670

17 files changed

+842
-474
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Tags:** schema markup, rich snippets, wordpress seo, structured data, google search
55
**Requires at least:** 3.7
66
**Tested up to:** 6.8
7-
**Stable tag:** 1.7.2
7+
**Stable tag:** 1.7.3
88
**Requires PHP:** 7.4
99
**License:** GPLv2 or later
1010
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
@@ -83,6 +83,9 @@ No, the plugin provides an easy-to-use interface where you can add schema markup
8383

8484
## Changelog ##
8585

86+
### 1.7.3 ###
87+
- Improvement: Refactored and optimized the codebase to improve code quality.
88+
8689
### 1.7.2 ###
8790
- Fixed: Resolved the issue for function _load_textdomain_just_in_time was called incorrectly in WP 6.8.
8891

admin/bsf-analytics/changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
v1.1.14 - 6-May-2025
2+
- New: Introduced a key 'hide_optin_checkbox' to hide checkbox from Settings > General.
3+
- Improvement: Single optin notice for all bsf products.
4+
- Improvement: Introduced delay of 7 days for next optin message if user has reqested request from product.
5+
v1.1.13 - 17-April-2025
6+
- Improvement: Ensured unique id for label's `for` attribute in deactivation survey fields by prefixing them with product slugs.
7+
- Improvement: Prevented deactivation survey from triggering when switching from a child theme to its parent.
8+
9+
v1.1.12 - 24-March-2025
10+
- Improvement: Added `suremails` and `latepoint` slugs to UTM analytics.

admin/bsf-analytics/class-bsf-analytics.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ public function option_notice() {
209209
return;
210210
}
211211

212+
if( $this->is_tracking_enabled() ) {
213+
return; // Don't need to display notice if any of our plugin already have the permission.
214+
}
215+
216+
// If the user has opted out of tracking, don't show the notice till 7 days.
217+
if ( get_site_option( 'bsf_analytics_last_displayed_time' ) > time() - ( 7 * DAY_IN_SECONDS ) ) {
218+
return; // Don't display the notice if it was displayed recently.
219+
}
220+
212221
foreach ( $this->entities as $key => $data ) {
213222

214223
$time_to_display = isset( $data['time_to_display'] ) ? $data['time_to_display'] : '+24 hours';
@@ -225,8 +234,13 @@ public function option_notice() {
225234
}
226235

227236
/* translators: %s product name */
228-
$notice_string = sprintf( __( 'Want to help make %1s even more awesome? Allow us to collect non-sensitive diagnostic data and usage information. ' ), '<strong>' . esc_html( $data['product_name'] ) . '</strong>' );
229-
237+
$notice_string = sprintf(
238+
__(
239+
'Help us improve %1$s and our other products!<br><br>With your permission, we\'d like to collect <strong>non-sensitive information</strong> from your website — like your PHP version and which features you use — so we can fix bugs faster, make smarter decisions, and build features that actually matter to you. <em>No personal info. Ever.</em>'
240+
),
241+
'<strong>' . esc_html( $data['product_name'] ) . '</strong>'
242+
);
243+
230244
if ( is_multisite() ) {
231245
$notice_string .= __( 'This will be applicable for all sites from the network.' );
232246
}
@@ -252,7 +266,7 @@ public function option_notice() {
252266
</div>
253267
</div>',
254268
/* translators: %s usage doc link */
255-
sprintf( $notice_string . '<span dir="%1s"><a href="%2s" target="_blank" rel="noreferrer noopener">%3s</a><span>', $language_dir, esc_url( $usage_doc_link ), __( ' Know More.' ) ),
269+
sprintf( $notice_string . '<span dir="%1s"><a href="%2s" target="_blank" rel="noreferrer noopener">%3s</a><span><br><br>', $language_dir, esc_url( $usage_doc_link ), __( ' Know More.' ) ),
256270
esc_url(
257271
add_query_arg(
258272
array(
@@ -281,6 +295,8 @@ public function option_notice() {
281295
'display-with-other-notices' => true,
282296
)
283297
);
298+
299+
return;
284300
}
285301
}
286302

@@ -344,6 +360,7 @@ private function optin( $source ) {
344360
*/
345361
private function optout( $source ) {
346362
update_site_option( $source . '_analytics_optin', 'no' );
363+
update_site_option( 'bsf_analytics_last_displayed_time', time() );
347364
}
348365

349366
/**
@@ -357,6 +374,7 @@ private function includes() {
357374

358375
// Loads all the modules.
359376
require_once __DIR__ . '/modules/deactivation-survey/classes/class-deactivation-survey-feedback.php';
377+
require_once __DIR__ . '/modules/utm-analytics.php';
360378
}
361379

362380
/**
@@ -372,6 +390,17 @@ public function register_usage_tracking_setting() {
372390
return;
373391
}
374392

393+
/**
394+
* Introducing a new key 'hide_optin_checkbox, which allows individual plugin to hide optin checkbox
395+
* If they are providing providing in-plugin option to manage this option.
396+
* from General > Settings page.
397+
*
398+
* @since 1.1.14
399+
*/
400+
if( ! empty( $data['hide_optin_checkbox'] ) && true === $data['hide_optin_checkbox'] ) {
401+
continue;
402+
}
403+
375404
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
376405
$author = isset( $data['author'] ) ? $data['author'] : 'Brainstorm Force';
377406

@@ -488,7 +517,7 @@ public function add_analytics_option_callback( $option, $value ) {
488517
}
489518

490519
/**
491-
* Send analaytics track event if tracking is enabled.
520+
* Send analytics track event if tracking is enabled.
492521
*
493522
* @since 1.0.0
494523
*/
@@ -540,7 +569,7 @@ public function load_deactivation_survey_form() {
540569

541570
if ( class_exists( 'Deactivation_Survey_Feedback' ) ) {
542571
foreach ( $this->entities as $key => $data ) {
543-
// If the deactibation_survery info in available then only add the form.
572+
// If the deactivation_survey info in available then only add the form.
544573
if ( ! empty( $data['deactivation_survey'] ) && is_array( $data['deactivation_survey'] ) ) {
545574
foreach ( $data['deactivation_survey'] as $key => $survey_args ) {
546575
Deactivation_Survey_Feedback::show_feedback_form(

admin/bsf-analytics/modules/deactivation-survey/assets/js/feedback.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,14 @@
159159
} else if ( e.target.classList.contains( 'activate' ) ) {
160160
this.deactivateUrl = e.target.href;
161161

162-
// Don't show for Child Themes.
162+
// Don't show for Child Themes if parent theme is active & Parent Theme if child theme is active.
163163
if (
164164
-1 !==
165165
this.deactivateUrl.indexOf(
166166
`stylesheet=${ udsVars?._current_theme }-child`
167-
)
167+
) ||
168+
-1 !==
169+
this.deactivateUrl.indexOf(`stylesheet=${udsVars?._current_theme}&`)
168170
) {
169171
return;
170172
}

admin/bsf-analytics/modules/deactivation-survey/assets/js/feedback.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

admin/bsf-analytics/modules/deactivation-survey/classes/class-deactivation-survey-feedback.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ public static function show_feedback_form( array $args = array() ) {
100100
return;
101101
}
102102

103+
// Product slug used for input fields and labels in each plugin's deactivation survey.
104+
$product_slug = isset( $args['plugin_slug'] ) ? sanitize_text_field( $args['plugin_slug'] ) : 'bsf';
105+
103106
?>
104107
<div id="<?php echo esc_attr( $id ); ?>" class="uds-feedback-form--wrapper" style="display: none">
105108
<div class="uds-feedback-form--container">
@@ -121,11 +124,13 @@ public static function show_feedback_form( array $args = array() ) {
121124
<?php } ?>
122125

123126
<form class="uds-feedback-form" id="uds-feedback-form" method="post">
124-
<?php foreach ( $args['popup_reasons'] as $key => $value ) { ?>
127+
<?php foreach ( $args['popup_reasons'] as $key => $value ) {
128+
$input_id = $product_slug . '_uds_reason_input_' . $key;
129+
?>
125130
<fieldset>
126131
<div class="reason">
127-
<input type="radio" class="uds-reason-input" name="uds_reason_input" id="uds_reason_input_<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" data-show_cta="<?php echo esc_attr( $value['show_cta'] ); ?>" data-accept_feedback="<?php echo esc_attr( $value['accept_feedback'] ); ?>">
128-
<label class="uds-reason-label" for="uds_reason_input_<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $value['label'] ); ?></label>
132+
<input type="radio" class="uds-reason-input" name="uds_reason_input" id="<?php echo esc_attr( $input_id ); ?>" value="<?php echo esc_attr( $key ); ?>" data-placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>" data-show_cta="<?php echo esc_attr( $value['show_cta'] ); ?>" data-accept_feedback="<?php echo esc_attr( $value['accept_feedback'] ); ?>">
133+
<label class="uds-reason-label" for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $value['label'] ); ?></label>
129134
</div>
130135
</fieldset>
131136
<?php } ?>
@@ -151,8 +156,8 @@ public static function show_feedback_form( array $args = array() ) {
151156
</fieldset>
152157

153158
<div class="uds-feedback-form-sumbit--actions">
154-
<button class="button button-primary uds-feedback-submit" data-action="submit"><?php esc_html_e( 'Submit & Deactivate' ); ?></button>
155-
<button class="button button-secondary uds-feedback-skip" data-action="skip"><?php esc_html_e( 'Skip & Deactivate' ); ?></button>
159+
<button class="button button-primary uds-feedback-submit" data-action="submit"><?php esc_html_e( 'Submit & Deactivate' ); ?></button>
160+
<button class="button button-secondary uds-feedback-skip" data-action="skip"><?php esc_html_e( 'Skip & Deactivate' ); ?></button>
156161
<input type="hidden" name="referer" value="<?php echo esc_url( get_site_url() ); ?>">
157162
<input type="hidden" name="version" value="<?php echo esc_attr( $args['plugin_version'] ); ?>">
158163
<input type="hidden" name="source" value="<?php echo esc_attr( $args['plugin_slug'] ); ?>">

0 commit comments

Comments
 (0)