From a4d372f4397abf7bc04824803b49e2fb74433f7e Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Sun, 1 Jul 2018 17:13:32 +0300 Subject: [PATCH] - added reviews notice; --- includes/admin/assets/css/um-admin-global.css | 4 ++ includes/admin/assets/css/um-admin-misc.css | 2 + includes/admin/assets/js/um-admin-global.js | 40 +++++++++++ includes/admin/assets/js/um-admin-scripts.js | 44 +++++++----- includes/admin/core/class-admin-enqueue.php | 9 ++- includes/admin/core/class-admin-notices.php | 71 ++++++++++++++++++- includes/class-init.php | 3 + 7 files changed, 149 insertions(+), 24 deletions(-) create mode 100644 includes/admin/assets/js/um-admin-global.js diff --git a/includes/admin/assets/css/um-admin-global.css b/includes/admin/assets/css/um-admin-global.css index d11c3289..61855a69 100644 --- a/includes/admin/assets/css/um-admin-global.css +++ b/includes/admin/assets/css/um-admin-global.css @@ -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; } \ No newline at end of file diff --git a/includes/admin/assets/css/um-admin-misc.css b/includes/admin/assets/css/um-admin-misc.css index eeb376ee..7cb87ec8 100644 --- a/includes/admin/assets/css/um-admin-misc.css +++ b/includes/admin/assets/css/um-admin-misc.css @@ -262,3 +262,5 @@ p.disabled-on-off .um-admin-yesno *{ .um-admin-cur-condition-template { display: none; } + + diff --git a/includes/admin/assets/js/um-admin-global.js b/includes/admin/assets/js/um-admin-global.js new file mode 100644 index 00000000..32edd9ca --- /dev/null +++ b/includes/admin/assets/js/um-admin-global.js @@ -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; + } + }); + }); + + +}); \ No newline at end of file diff --git a/includes/admin/assets/js/um-admin-scripts.js b/includes/admin/assets/js/um-admin-scripts.js index fc20bbe2..25dd12e7 100644 --- a/includes/admin/assets/js/um-admin-scripts.js +++ b/includes/admin/assets/js/um-admin-scripts.js @@ -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; - } - }); - }); - }); \ No newline at end of file diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index 279b0dfd..8e6643a7 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -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(); } diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 4bed1295..3db7dbe5 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -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(); ?> + +
+

+ +

+

+     |     +     |     + +

+
+
+

+ +

+ +

+ +

+
+
+

+ +

+ +

+ +

+
+
+

+ +

+ +

+ +

+
+ + 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' ) ); } diff --git a/includes/class-init.php b/includes/class-init.php index 5aaa9227..0c264649 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -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();