- removed tracking;

- changed notices texts;
- fixed MailChimp opt-in from notice;
This commit is contained in:
nikitozzzzzzz
2018-07-02 16:46:22 +03:00
parent a4d372f439
commit ac88f69cd6
6 changed files with 94 additions and 226 deletions
@@ -19,6 +19,36 @@ jQuery(document).ready(function() {
}); });
jQuery(document).on('click', '.um_review_link', function (e) {
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
});
jQuery(document).on('click', '.um_opt_in_link', function (e) {
jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' ).trigger('click');
});
jQuery(document).on('click', '#um_opt_in_start', function (e) {
var dismiss = jQuery(this).parents('.um-admin-notice').find( '.notice-dismiss' );
jQuery(this).prop('disabled', true).attr('disabled', 'disabled');
wp.ajax.send( 'um_opt_in_notice', {
data: {
nonce: um_admin_scripts.nonce
},
success: function( data ) {
dismiss.trigger('click');
jQuery(this).prop('disabled', false);
},
error: function( data ) {
jQuery(this).prop('disabled', false);
return false;
}
});
});
jQuery(document).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) { jQuery(document).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) {
var notice_key = jQuery(this).parents('.um-admin-notice').data('key'); var notice_key = jQuery(this).parents('.um-admin-notice').data('key');
+64 -20
View File
@@ -31,6 +31,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 ); add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
add_action( 'wp_ajax_um_dismiss_notice', array( &$this, 'dismiss_notice' ) ); add_action( 'wp_ajax_um_dismiss_notice', array( &$this, 'dismiss_notice' ) );
add_action( 'wp_ajax_um_opt_in_notice', array( &$this, 'opt_in_notice' ) );
} }
@@ -40,7 +41,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->localize_note(); $this->localize_note();
$this->show_update_messages(); $this->show_update_messages();
$this->check_wrong_install_folder(); $this->check_wrong_install_folder();
$this->admin_notice_tracking(); $this->admin_notice_opt_in();
$this->need_upgrade(); $this->need_upgrade();
$this->check_wrong_licenses(); $this->check_wrong_licenses();
@@ -193,11 +194,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated'; $class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated';
$dimissible = ! empty( $admin_notices[ $key ]['dimissible'] ); $dismissible = ! empty( $admin_notices[ $key ]['dismissible'] );
ob_start(); ?> ob_start(); ?>
<div class="<?php echo esc_attr( $class ) ?> um-admin-notice notice <?php echo $dimissible ? 'is-dismissible' : '' ?>" data-key="<?php echo $key ?>"> <div class="<?php echo esc_attr( $class ) ?> um-admin-notice notice <?php echo $dismissible ? 'is-dismissible' : '' ?>" data-key="<?php echo $key ?>">
<?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?> <?php echo ! empty( $notice_data['message'] ) ? $notice_data['message'] : '' ?>
</div> </div>
@@ -501,42 +502,43 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
/** /**
* Show admin notices * Show admin notices
*/ */
public function admin_notice_tracking() { public function admin_notice_opt_in() {
if ( ! current_user_can( 'manage_options' ) ) { if ( ! current_user_can( 'manage_options' ) ) {
return; return;
} }
//backward compatibility
$hide_notice = get_option( 'um_tracking_notice' ); $hide_notice = get_option( 'um_tracking_notice' );
if ( $hide_notice ) { if ( $hide_notice ) {
return; return;
} }
$optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_into_tracking' ) ); $optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_in' ) );
$optout_url = esc_url( add_query_arg( 'um_adm_action', 'opt_out_of_tracking' ) );
ob_start(); ?> ob_start(); ?>
<p> <p>
<?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions for %s via our website. If you subscribe to our mailing list we will immediately email you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a> (you\'ll need to confirm your subscription via email).', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?> <?php printf( __( 'Thanks for installing <strong>%s</strong>! We hope you like the plugin. To fund full-time development and support of the plugin we also sell extensions for %s via our website. If you subscribe to our mailing list we will email you a 20%% discount code for our <a href="%s" target="_blank">extensions bundle</a> (you\'ll need to confirm your opt-in via email before the discount code can be sent).', 'ultimate-member' ), ultimatemember_plugin_name, ultimatemember_plugin_name, 'https://ultimatemember.com/core-extensions-bundle/' ); ?>
</p> </p>
<p> <p>
<a href="<?php echo esc_url( $optin_url ) ?>" class="button button-primary"><?php _e( 'Subscribe to mailing list', 'ultimate-member' ) ?></a> <a href="javascript:void(0);" id="um_opt_in_start" class="button button-primary"><?php _e( 'Subscribe to mailing list', 'ultimate-member' ) ?></a>
&nbsp; &nbsp;
<a href="<?php echo esc_url( $optout_url ) ?>" class="button-secondary"><?php _e( 'No thanks', 'ultimate-member' ) ?></a> <a href="javascript:void(0);" class="button-secondary um_opt_in_link"><?php _e( 'No thanks', 'ultimate-member' ) ?></a>
</p> </p>
<p class="description" style="font-size: 11px;"> <p class="description" style="font-size: 11px;">
<?php printf( __( 'By clicking the subscribe button you are agreeing to join our mailing list (managed via MailChimp). See our <a href="%s" target="_blank">privacy policy</a>', 'ultimate-member' ), 'https://ultimatemember.com/support/policy/' ); ?> <?php printf( __( 'By clicking the subscribe button you are agree to join our mailing list. See our <a href="%s" target="_blank">privacy policy</a>', 'ultimate-member' ), 'https://ultimatemember.com/privacy-policy/' ); ?>
</p> </p>
<?php $message = ob_get_clean(); <?php $message = ob_get_clean();
$this->add_notice( 'tracking_notice', array( $this->add_notice( 'opt_in_notice', array(
'class' => 'updated', 'class' => 'updated',
'message' => $message, 'message' => $message,
'dismissible' => true
), 2 ); ), 2 );
} }
@@ -630,11 +632,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
<div id="um_start_review_notice"> <div id="um_start_review_notice">
<p> <p>
<?php printf( __( 'Hey there! It\'s been one month since you installed %s. Could you tell us your experience of the plugin so far?', 'ultimate-member' ), ultimatemember_plugin_name ) ?> <?php printf( __( 'Hey there! It\'s been one month since you installed %s. How have you found the plugin so far?', 'ultimate-member' ), ultimatemember_plugin_name ) ?>
</p> </p>
<p> <p>
<a href="javascript:void(0);" id="um_add_review_love"><?php _e( 'I love it!', 'ultimate-member' ) ?></a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:void(0);" id="um_add_review_love"><?php _e( 'I love it!', 'ultimate-member' ) ?></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" id="um_add_review_good"><?php _e('It\'s good but could be better', 'ultimate-member' ) ?></a>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:void(0);" id="um_add_review_good"><?php _e('It\'s good but could be better', 'ultimate-member' ) ?></a>&nbsp;|&nbsp;
<a href="javascript:void(0);" id="um_add_review_bad"><?php _e('I don\'t like the plugin', 'ultimate-member' ) ?></a> <a href="javascript:void(0);" id="um_add_review_bad"><?php _e('I don\'t like the plugin', 'ultimate-member' ) ?></a>
</p> </p>
</div> </div>
@@ -644,7 +646,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
</p> </p>
<p> <p>
<a href="https://wordpress.org/support/plugin/ultimate-member/reviews/?filter=5" target="_blank" class="button button-primary"><?php _e( 'Leave Review', 'ultimate-member' ) ?></a> <a href="https://wordpress.org/support/plugin/ultimate-member/reviews/?rate=5#new-post" target="_blank" class="button button-primary um_review_link"><?php _e( 'Leave Review', 'ultimate-member' ) ?></a>
</p> </p>
</div> </div>
<div class="um_hidden_notice" data-key="good"> <div class="um_hidden_notice" data-key="good">
@@ -653,16 +655,16 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
</p> </p>
<p> <p>
<a href="#" class="button button-primary"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a> <a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
</p> </p>
</div> </div>
<div class="um_hidden_notice" data-key="bad"> <div class="um_hidden_notice" data-key="bad">
<p> <p>
<?php _e( 'We\'re sorry to hear that. If you\'re having the issue with the plugin you can create a topic on our support forum and we will try and help you out with the issue. Alternatively if you have an idea on how we can make the plugin better or want to tell us what you don\'t like about the plugin you can tell us know by giving us feedback.' ); ?> <?php printf( __( 'We\'re sorry to hear that. If you\'re having the issue with the plugin you can create a topic on our <a href="%s" target="_blank">support forum</a> and we will try and help you out with the issue. Alternatively if you have an idea on how we can make the plugin better or want to tell us what you don\'t like about the plugin you can tell us know by giving us feedback.' ), 'https://wordpress.org/support/plugin/ultimate-member' ); ?>
</p> </p>
<p> <p>
<a href="#" class="button button-primary"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a> <a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
</p> </p>
</div> </div>
@@ -671,7 +673,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->add_notice( 'reviews_notice', array( $this->add_notice( 'reviews_notice', array(
'class' => 'updated', 'class' => 'updated',
'message' => $message, 'message' => $message,
'dimissible' => true 'dismissible' => true
), 1 ); ), 1 );
} }
@@ -692,7 +694,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->add_notice( 'future_changes', array( $this->add_notice( 'future_changes', array(
'class' => 'updated', 'class' => 'updated',
'message' => $message, 'message' => $message,
//'dimissible' => true,
), 2 ); ), 2 );
} }
@@ -711,5 +712,48 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
wp_send_json_success(); wp_send_json_success();
} }
function opt_in_notice() {
// Send a maximum of once per period
$last_send = get_option( 'um_opt_in_last_send', false );
if ( $last_send && $last_send > strtotime( '-1 day' ) ) {
return;
}
$data = array();
UM()->setup()->install_basics();
$data['email'] = get_option( 'admin_email' );
$data['send_discount'] = ! get_option( '__ultimatemember_coupon_sent' ) ? 1 : 0;
$data['unique_sitekey'] = get_option( '__ultimatemember_sitekey' );
$request = wp_remote_post( 'https://ultimatemember.com/?um_action=checkin', array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'body' => $data,
'user-agent' => 'UM/' . ultimatemember_version . '; ' . get_bloginfo( 'url' ),
) );
if ( ! is_wp_error( $request ) ) {
$request = json_decode( wp_remote_retrieve_body( $request ), true );
}
$request = ( $request ) ? maybe_unserialize( $request ) : false;
if ( ! empty( $request['id'] ) && ! empty( $request['list_id'] ) ) {
update_option( 'um_opt_in_last_send', time() );
if ( $request['discount_ready'] ) {
update_option( '__ultimatemember_coupon_sent', 1 );
}
}
wp_send_json_success();
}
} }
} }
@@ -1033,11 +1033,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'textarea_rows' => 6 'textarea_rows' => 6
) )
), ),
array(
'id' => 'um_allow_tracking',
'type' => 'checkbox',
'label' => __( 'Allow Tracking','ultimate-member' ),
),
array( array(
'id' => 'uninstall_on_delete', 'id' => 'uninstall_on_delete',
'type' => 'checkbox', 'type' => 'checkbox',
-1
View File
@@ -519,7 +519,6 @@ if ( ! class_exists( 'um\Config' ) ) {
'form_asterisk' => 0, 'form_asterisk' => 0,
'profile_title' => '{display_name} | {site_name}', 'profile_title' => '{display_name} | {site_name}',
'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile', 'profile_desc' => '{display_name} is on {site_name}. Join {site_name} to view {display_name}\'s profile',
'allow_tracking' => 0,
'admin_email' => get_bloginfo('admin_email'), 'admin_email' => get_bloginfo('admin_email'),
'mail_from' => get_bloginfo('name'), 'mail_from' => get_bloginfo('name'),
'mail_from_addr' => get_bloginfo('admin_email'), 'mail_from_addr' => get_bloginfo('admin_email'),
-15
View File
@@ -537,7 +537,6 @@ if ( ! class_exists( 'UM' ) ) {
$this->permalinks(); $this->permalinks();
$this->modal(); $this->modal();
$this->cron(); $this->cron();
$this->tracking();
$this->mobile(); $this->mobile();
$this->external_integrations(); $this->external_integrations();
$this->gdpr(); $this->gdpr();
@@ -1253,20 +1252,6 @@ if ( ! class_exists( 'UM' ) ) {
} }
/**
* @since 2.0
*
* @return um\core\Tracking
*/
function tracking() {
if ( empty( $this->classes['tracking'] ) ) {
$this->classes['tracking'] = new um\core\Tracking();
}
return $this->classes['tracking'];
}
/** /**
* @since 2.0 * @since 2.0
* *
-185
View File
@@ -1,185 +0,0 @@
<?php
namespace um\core;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'um\core\Tracking' ) ) {
/**
* Class Tracking
* @package um\core
*/
class Tracking {
/**
* @var
*/
private $data;
/**
* Tracking constructor.
*/
public function __construct() {
$this->schedule_send();
add_action( 'um_admin_do_action__opt_into_tracking', array( $this, 'um_admin_do_action__opt_into_tracking' ) );
add_action( 'um_admin_do_action__opt_out_of_tracking', array( $this, 'um_admin_do_action__opt_out_of_tracking' ) );
}
/**
* Opt-in tracking
*
* @param $action
*/
function um_admin_do_action__opt_into_tracking( $action ) {
UM()->options()->update( 'um_allow_tracking', 1 );
update_option( 'um_tracking_notice', 1 );
$this->send_checkin(true);
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
}
/**
* Opt-out of tracking
*
* @param $action
*/
function um_admin_do_action__opt_out_of_tracking( $action ) {
UM()->options()->update( 'um_allow_tracking', 0 );
update_option('um_tracking_notice', 1 );
exit( wp_redirect( remove_query_arg('um_adm_action') ) );
}
/**
* Setup info array
*
*/
private function setup_data() {
$data = array();
// Retrieve current theme info
if ( get_bloginfo( 'version' ) < '3.4' ) {
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
$theme = $theme_data['Name'];
$theme_ver = $theme_data['Version'];
} else {
$theme_data = wp_get_theme();
$theme = $theme_data->Name;
$theme_ver = $theme_data->Version;
}
$data['url'] = home_url();
$data['theme'] = $theme;
$data['theme_version'] = $theme_ver;
$data['wp_version'] = get_bloginfo( 'version' );
$data['version'] = ultimatemember_version;
// Retrieve current plugin information
if( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = array_keys( get_plugins() );
$active_plugins = get_option( 'active_plugins', array() );
foreach ( $plugins as $key => $plugin ) {
if ( in_array( $plugin, $active_plugins ) ) {
// Remove active plugins from list so we can show active and inactive separately
unset( $plugins[ $key ] );
}
}
$data['active_plugins'] = $active_plugins;
$data['inactive_plugins'] = $plugins;
$data['language'] = get_bloginfo('language');
$data['multisite'] = ( is_multisite() ) ? 1 : 0;
UM()->setup()->install_basics();
$data['email'] = get_option( 'admin_email' );
$data['unique_sitekey'] = get_option( '__ultimatemember_sitekey' );
$this->data = $data;
}
/**
* Check if tracking is allowed
*
* @return int
*/
private function tracking_allowed() {
if ( ! UM()->options()->get( 'allow_tracking' ) )
return 0;
return 1;
}
/**
* Get last send time
*
* @return mixed|void
*/
private function get_last_send() {
return get_option( 'um_tracking_last_send' );
}
/**
* Send a report
*
* @param bool $override
*/
public function send_checkin( $override = false ) {
if( ! $this->tracking_allowed() && ! $override )
return;
// Send a maximum of once per period
$last_send = $this->get_last_send();
if( $last_send && $last_send > strtotime( '-1 day' ) )
return;
$this->setup_data();
if ( !get_option('__ultimatemember_coupon_sent') ) {
$this->data['send_discount'] = 1;
} else {
$this->data['send_discount'] = 0;
}
$request = wp_remote_post( 'https://ultimatemember.com/?um_action=checkin', array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'body' => $this->data,
'user-agent' => 'UM/' . ultimatemember_version . '; ' . get_bloginfo( 'url' ),
) );
update_option( 'um_tracking_last_send', time() );
update_option( '__ultimatemember_coupon_sent', 1 );
}
/**
* Run a scheduled report
*/
private function schedule_send() {
add_action( 'um_daily_scheduled_events', array( $this, 'send_checkin' ) );
}
}
}