mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-16 21:23:39 +09:00
Merge branch 'feature/review_notice'
This commit is contained in:
@@ -197,4 +197,8 @@ a.um-delete{ color: #a00; }
|
||||
.wp-admin p.um-nav-roles label {
|
||||
margin-top: 2px !important;
|
||||
margin-bottom: 2px !important;
|
||||
}
|
||||
|
||||
.um_hidden_notice {
|
||||
display: none;
|
||||
}
|
||||
@@ -262,3 +262,5 @@ p.disabled-on-off .um-admin-yesno *{
|
||||
.um-admin-cur-condition-template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
|
||||
jQuery(document).on('click', '#um_add_review_love', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="love"]').show();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document).on('click', '#um_add_review_good', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="good"]').show();
|
||||
});
|
||||
|
||||
|
||||
jQuery(document).on('click', '#um_add_review_bad', function (e) {
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="bad"]').show();
|
||||
});
|
||||
|
||||
|
||||
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) {
|
||||
var notice_key = jQuery(this).parents('.um-admin-notice').data('key');
|
||||
|
||||
wp.ajax.send( 'um_dismiss_notice', {
|
||||
data: {
|
||||
key: notice_key,
|
||||
nonce: um_admin_scripts.nonce
|
||||
},
|
||||
success: function( data ) {
|
||||
return true;
|
||||
},
|
||||
error: function( data ) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -12,6 +12,31 @@ function um_init_tooltips() {
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
|
||||
/**
|
||||
clone a field dropdown
|
||||
**/
|
||||
jQuery(document).on( 'click', '#um_add_review_love', function(e){
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="love"]').show();
|
||||
});
|
||||
|
||||
/**
|
||||
clone a field dropdown
|
||||
**/
|
||||
jQuery(document).on( 'click', '#um_add_review_good', function(e){
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="good"]').show();
|
||||
});
|
||||
|
||||
/**
|
||||
clone a field dropdown
|
||||
**/
|
||||
jQuery(document).on( 'click', '#um_add_review_bad', function(e){
|
||||
jQuery(this).parents('#um_start_review_notice').hide();
|
||||
jQuery('.um_hidden_notice[data-key="bad"]').show();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
clone a field dropdown
|
||||
**/
|
||||
@@ -215,23 +240,4 @@ jQuery(document).ready(function() {
|
||||
jQuery(this).parents('.um-nav-edit').find('.um-nav-roles').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
jQuery(document).on( 'click', '.um-admin-notice.is-dismissible .notice-dismiss', function(e) {
|
||||
var notice_key = jQuery(this).parents('.um-admin-notice').data('key');
|
||||
|
||||
wp.ajax.send( 'um_dimiss_notice', {
|
||||
data: {
|
||||
key: notice_key,
|
||||
nonce: um_admin_scripts.nonce
|
||||
},
|
||||
success: function( data ) {
|
||||
return true;
|
||||
},
|
||||
error: function( data ) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -292,7 +292,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
/**
|
||||
* Load global css
|
||||
*/
|
||||
function load_global_css() {
|
||||
function load_global_scripts() {
|
||||
wp_register_script( 'um_admin_global', $this->js_url . 'um-admin-global.js', array('jquery'), ultimatemember_version, true );
|
||||
wp_enqueue_script( 'um_admin_global' );
|
||||
|
||||
wp_register_style( 'um_admin_global', $this->css_url . 'um-admin-global.css' );
|
||||
wp_enqueue_style( 'um_admin_global' );
|
||||
}
|
||||
@@ -390,7 +393,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
}*/
|
||||
|
||||
$this->load_functions();
|
||||
$this->load_global_css();
|
||||
$this->load_global_scripts();
|
||||
$this->load_form();
|
||||
$this->load_forms();
|
||||
$this->load_modal();
|
||||
@@ -423,7 +426,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) {
|
||||
|
||||
} else {
|
||||
|
||||
$this->load_global_css();
|
||||
$this->load_global_scripts();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
add_action( 'admin_init', array( &$this, 'create_list' ), 10 );
|
||||
add_action( 'admin_notices', array( &$this, 'render_notices' ), 1 );
|
||||
|
||||
//add_action( 'wp_ajax_um_dimiss_notice', array( &$this, 'dimiss_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,10 +41,12 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
$this->localize_note();
|
||||
$this->show_update_messages();
|
||||
$this->check_wrong_install_folder();
|
||||
$this->admin_notice_tracking();
|
||||
$this->admin_notice_opt_in();
|
||||
$this->need_upgrade();
|
||||
$this->check_wrong_licenses();
|
||||
|
||||
$this->reviews_notice();
|
||||
|
||||
|
||||
//$this->future_changed();
|
||||
|
||||
@@ -140,8 +143,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
$admin_notices = $this->get_admin_notices();
|
||||
|
||||
$hidden = get_user_meta( get_current_user_id(), 'um_hidden_admin_notices', true );
|
||||
$hidden = empty( $hidden ) ? array() : $hidden;
|
||||
$hidden = get_option( 'um_hidden_admin_notices', array() );
|
||||
|
||||
uasort( $admin_notices, array( &$this, 'notice_priority_sort' ) );
|
||||
|
||||
@@ -191,11 +193,11 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
|
||||
$class = ! empty( $notice_data['class'] ) ? $notice_data['class'] : 'updated';
|
||||
|
||||
$dimissible = ! empty( $admin_notices[ $key ]['dimissible'] );
|
||||
$dismissible = ! empty( $admin_notices[ $key ]['dismissible'] );
|
||||
|
||||
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'] : '' ?>
|
||||
</div>
|
||||
|
||||
@@ -499,42 +501,43 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
/**
|
||||
* Show admin notices
|
||||
*/
|
||||
public function admin_notice_tracking() {
|
||||
public function admin_notice_opt_in() {
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//backward compatibility
|
||||
$hide_notice = get_option( 'um_tracking_notice' );
|
||||
|
||||
if ( $hide_notice ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_into_tracking' ) );
|
||||
$optout_url = esc_url( add_query_arg( 'um_adm_action', 'opt_out_of_tracking' ) );
|
||||
$optin_url = esc_url( add_query_arg( 'um_adm_action', 'opt_in' ) );
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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 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>
|
||||
|
||||
<?php $message = ob_get_clean();
|
||||
|
||||
$this->add_notice( 'tracking_notice', array(
|
||||
$this->add_notice( 'opt_in_notice', array(
|
||||
'class' => 'updated',
|
||||
'message' => $message,
|
||||
'dismissible' => true
|
||||
), 2 );
|
||||
}
|
||||
|
||||
@@ -609,6 +612,71 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function reviews_notice() {
|
||||
|
||||
$first_activation_date = get_option( 'um_first_activation_date', false );
|
||||
|
||||
if ( empty( $first_activation_date ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $first_activation_date + MONTH_IN_SECONDS > time() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
ob_start(); ?>
|
||||
|
||||
<div id="um_start_review_notice">
|
||||
<p>
|
||||
<?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>
|
||||
<a href="javascript:void(0);" id="um_add_review_love"><?php _e( 'I love it!', 'ultimate-member' ) ?></a> |
|
||||
<a href="javascript:void(0);" id="um_add_review_good"><?php _e('It\'s good but could be better', '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>
|
||||
</div>
|
||||
<div class="um_hidden_notice" data-key="love">
|
||||
<p>
|
||||
<?php printf( __( 'Great! We\'re happy to hear that you love the plugin. It would be amazing if you could let others know why you like %s by leaving a review of the plugin. This will help %s to grow and become more popular and would be massively appreciated by us!' ), ultimatemember_plugin_name, ultimatemember_plugin_name ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<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>
|
||||
</div>
|
||||
<div class="um_hidden_notice" data-key="good">
|
||||
<p>
|
||||
<?php _e( 'We\'re glad to hear that you like the plugin but we would love to get your feedback so we can make the plugin better.' ); ?>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="um_hidden_notice" data-key="bad">
|
||||
<p>
|
||||
<?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>
|
||||
<a href="https://ultimatemember.com/feedback/" target="_blank" class="button button-primary um_review_link"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php $message = ob_get_clean();
|
||||
|
||||
$this->add_notice( 'reviews_notice', array(
|
||||
'class' => 'updated',
|
||||
'message' => $message,
|
||||
'dismissible' => true
|
||||
), 1 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check Future Changes notice
|
||||
*/
|
||||
@@ -625,21 +693,62 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
$this->add_notice( 'future_changes', array(
|
||||
'class' => 'updated',
|
||||
'message' => $message,
|
||||
//'dimissible' => true,
|
||||
), 2 );
|
||||
}
|
||||
|
||||
|
||||
function dimiss_notice() {
|
||||
function dismiss_notice() {
|
||||
if ( empty( $_POST['key'] ) ) {
|
||||
wp_send_json_error( __( 'Wrong Data', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$hidden_notices = get_user_meta( get_current_user_id(), 'um_hidden_admin_notices', true );
|
||||
$hidden_notices = empty( $hidden_notices ) ? array() : $hidden_notices;
|
||||
$hidden_notices = get_option( 'um_hidden_admin_notices', array() );
|
||||
$hidden_notices[] = $_POST['key'];
|
||||
|
||||
update_user_meta( get_current_user_id(), 'um_hidden_admin_notices', $hidden_notices );
|
||||
update_option( 'um_hidden_admin_notices', $hidden_notices );
|
||||
|
||||
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
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => 'um_allow_tracking',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Allow Tracking','ultimate-member' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'uninstall_on_delete',
|
||||
'type' => 'checkbox',
|
||||
|
||||
Reference in New Issue
Block a user