- added reviews notice;

This commit is contained in:
nikitozzzzzzz
2018-07-01 17:13:32 +03:00
parent 5570a9431e
commit a4d372f439
7 changed files with 149 additions and 24 deletions
@@ -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,40 @@
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-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;
}
});
});
});
+25 -19
View File
@@ -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;
}
});
});
});
+6 -3
View File
@@ -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();
}
+69 -2
View File
@@ -30,7 +30,7 @@ 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' ) );
}
@@ -44,6 +44,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$this->need_upgrade();
$this->check_wrong_licenses();
$this->reviews_notice();
//$this->future_changed();
@@ -609,6 +611,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. Could you tell us your experience of 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>&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;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
<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/?filter=5" target="_blank" class="button button-primary"><?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="#" class="button button-primary"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
</p>
</div>
<div class="um_hidden_notice" data-key="bad">
<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.' ); ?>
</p>
<p>
<a href="#" class="button button-primary"><?php _e( 'Provide Feedback', 'ultimate-member' ) ?></a>
</p>
</div>
<?php $message = ob_get_clean();
$this->add_notice( 'reviews_notice', array(
'class' => 'updated',
'message' => $message,
'dimissible' => true
), 1 );
}
/**
* Check Future Changes notice
*/
@@ -630,7 +697,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
}
function dimiss_notice() {
function dismiss_notice() {
if ( empty( $_POST['key'] ) ) {
wp_send_json_error( __( 'Wrong Data', 'ultimate-member' ) );
}
+3
View File
@@ -462,6 +462,8 @@ if ( ! class_exists( 'UM' ) ) {
if ( ! $version ) {
update_option( 'um_last_version_upgrade', ultimatemember_version );
add_option( 'um_first_activation_date', time() );
//show avatars on first install
if ( ! get_option( 'show_avatars' ) ) {
update_option( 'show_avatars', 1 );
@@ -496,6 +498,7 @@ if ( ! class_exists( 'UM' ) ) {
$this->admin_upgrade()->init_packages_ajax_handlers();
$this->admin_gdpr();
$this->columns();
$this->notices();
} elseif ( $this->is_request( 'admin' ) ) {
$this->admin();
$this->admin_menu();