BSF_Analytics::option_notice()
Display admin notice for usage tracking.
Description
Source
File: inc/lib/bsf-analytics/class-bsf-analytics.php
public function option_notice() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
foreach ( $this->entities as $key => $data ) {
$time_to_display = isset( $data['time_to_display'] ) ? $data['time_to_display'] : '+24 hours';
$usage_doc_link = isset( $data['usage_doc_link'] ) ? $data['usage_doc_link'] : $this->usage_doc_link;
// Don't display the notice if tracking is disabled or White Label is enabled for any of our plugins.
if ( false !== get_site_option( $key . '_analytics_optin', false ) || $this->is_white_label_enabled( $key ) ) {
continue;
}
// Show tracker consent notice after 24 hours from installed time.
if ( strtotime( $time_to_display, $this->get_analytics_install_time( $key ) ) > time() ) {
continue;
}
/* translators: %s product name */
$notice_string = sprintf( __( 'Want to help make %1s even more awesome? Allow us to collect non-sensitive diagnostic data and usage information. ', 'astra' ), '<strong>' . esc_html( $data['product_name'] ) . '</strong>' );
if ( is_multisite() ) {
$notice_string .= __( 'This will be applicable for all sites from the network.', 'astra' );
}
$language_dir = is_rtl() ? 'rtl' : 'ltr';
Astra_Notices::add_notice(
array(
'id' => $key . '-optin-notice',
'type' => '',
'message' => sprintf(
'<div class="notice-content">
<div class="notice-heading">
%1$s
</div>
<div class="astra-notices-container">
<a href="%2$s" class="astra-notices button-primary">
%3$s
</a>
<a href="%4$s" data-repeat-notice-after="%5$s" class="astra-notices button-secondary">
%6$s
</a>
</div>
</div>',
/* translators: %s usage doc link */
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.', 'astra' ) ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'yes',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
__( 'Yes! Allow it', 'astra' ),
esc_url(
add_query_arg(
array(
$key . '_analytics_optin' => 'no',
$key . '_analytics_nonce' => wp_create_nonce( $key . '_analytics_optin' ),
'bsf_analytics_source' => $key,
)
)
),
MONTH_IN_SECONDS,
__( 'No Thanks', 'astra' )
),
'show_if' => true,
'repeat-notice-after' => false,
'priority' => 18,
'display-with-other-notices' => true,
)
);
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |