From 3469f6972b6a1ddbacbe9fc1750f85a4f8bc2736 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Fri, 10 Apr 2020 17:13:31 +0545 Subject: [PATCH 1/5] Add - Theme review notice --- css/admin/theme-review-notice.css | 18 ++ functions.php | 1 + .../class-envince-theme-review-notice.php | 188 ++++++++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 css/admin/theme-review-notice.css create mode 100644 inc/admin/class-envince-theme-review-notice.php diff --git a/css/admin/theme-review-notice.css b/css/admin/theme-review-notice.css new file mode 100644 index 0000000..cf4ffff --- /dev/null +++ b/css/admin/theme-review-notice.css @@ -0,0 +1,18 @@ +.theme-review-notice .links { + margin: 10px 0; +} + +.theme-review-notice .links a { + height: auto; + padding: 3px 15px; + margin-left: 10px; + text-transform: uppercase; +} + +.theme-review-notice .links a .dashicons { + line-height: 1.2; +} + +.theme-review-notice .links a.button-primary { + margin-left: 0; +} diff --git a/functions.php b/functions.php index dae6a35..845abb0 100644 --- a/functions.php +++ b/functions.php @@ -33,6 +33,7 @@ if ( is_admin() ) { require get_template_directory() . '/inc/admin/class-envince-admin.php'; require get_template_directory() . '/inc/admin/class-envince-tdi-notice.php'; + require get_template_directory() . '/inc/admin/class-envince-theme-review-notice.php'; } /* Do theme setup on the 'after_setup_theme' hook. */ diff --git a/inc/admin/class-envince-theme-review-notice.php b/inc/admin/class-envince-theme-review-notice.php new file mode 100644 index 0000000..7debf27 --- /dev/null +++ b/inc/admin/class-envince-theme-review-notice.php @@ -0,0 +1,188 @@ +ID; + $current_user = wp_get_current_user(); + $ignored_notice = get_user_meta( $user_id, 'envince_ignore_theme_review_notice', true ); + $ignored_notice_partially = get_user_meta( $user_id, 'nag_envince_ignore_theme_review_notice_partially', true ); + + /** + * Return from notice display if: + * + * 1. The theme installed is less than 15 days. + * 2. If the user has ignored the message partially for 15 days. + * 3. Dismiss always if clicked on 'I Already Did' button. + */ + if ( ( get_option( 'envince_theme_installed_time' ) > strtotime( '-15 day' ) ) || ( $ignored_notice_partially > strtotime( '-15 day' ) ) || ( $ignored_notice ) ) { + return; + } + ?> + +
+

+ ' . esc_html( $current_user->display_name ) . '' + ); + ?> +

+ + + + +
+ + ID; + + /* If user clicks to ignore the notice, add that to their user meta */ + if ( isset( $_GET['nag_envince_ignore_theme_review_notice'] ) && '0' == $_GET['nag_envince_ignore_theme_review_notice'] ) { + add_user_meta( $user_id, 'envince_ignore_theme_review_notice', 'true', true ); + } + + } + + /** + * Function to remove the theme review notice partially as requested by the user. + */ + public function envince_ignore_theme_review_notice_partially() { + + global $current_user; + $user_id = $current_user->ID; + + /* If user clicks to ignore the notice, add that to their user meta */ + if ( isset( $_GET['nag_envince_ignore_theme_review_notice_partially'] ) && '0' == $_GET['nag_envince_ignore_theme_review_notice_partially'] ) { + update_user_meta( $user_id, 'nag_envince_ignore_theme_review_notice_partially', time() ); + } + + } + + /** + * Remove the data set after the theme has been switched to other theme. + */ + public function envince_theme_rating_notice_data_remove() { + + $get_all_users = get_users(); + $theme_installed_time = get_option( 'envince_theme_installed_time' ); + + // Delete options data. + if ( $theme_installed_time ) { + delete_option( 'envince_theme_installed_time' ); + } + + // Delete user meta data for theme review notice. + foreach ( $get_all_users as $user ) { + $ignored_notice = get_user_meta( $user->ID, 'envince_ignore_theme_review_notice', true ); + $ignored_notice_partially = get_user_meta( $user->ID, 'nag_envince_ignore_theme_review_notice_partially', true ); + + // Delete permanent notice remove data. + if ( $ignored_notice ) { + delete_user_meta( $user->ID, 'envince_ignore_theme_review_notice' ); + } + + // Delete partial notice remove data. + if ( $ignored_notice_partially ) { + delete_user_meta( $user->ID, 'nag_envince_ignore_theme_review_notice_partially' ); + } + + } + } + + /** + * Enqueue the required CSS file for theme review notice on admin page. + */ + public function envince_theme_rating_notice_enqueue() { + + wp_enqueue_style( 'envince-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' ); + + } + +} + +new Envince_Theme_Review_Notice(); From c3097928982bdd4e8e8be7daae617df6c0e5eba6 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 06:00:31 +0545 Subject: [PATCH 2/5] Remove Global declaration uf $current_user --- inc/admin/class-envince-theme-review-notice.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/inc/admin/class-envince-theme-review-notice.php b/inc/admin/class-envince-theme-review-notice.php index 7debf27..12f3dfa 100644 --- a/inc/admin/class-envince-theme-review-notice.php +++ b/inc/admin/class-envince-theme-review-notice.php @@ -54,8 +54,7 @@ public function envince_theme_rating_notice() { */ public function envince_theme_review_notice() { - global $current_user; - $user_id = $current_user->ID; + $user_id = get_current_user_id(); $current_user = wp_get_current_user(); $ignored_notice = get_user_meta( $user_id, 'envince_ignore_theme_review_notice', true ); $ignored_notice_partially = get_user_meta( $user_id, 'nag_envince_ignore_theme_review_notice_partially', true ); @@ -118,8 +117,7 @@ public function envince_theme_review_notice() { */ public function envince_ignore_theme_review_notice() { - global $current_user; - $user_id = $current_user->ID; + $user_id = get_current_user_id(); /* If user clicks to ignore the notice, add that to their user meta */ if ( isset( $_GET['nag_envince_ignore_theme_review_notice'] ) && '0' == $_GET['nag_envince_ignore_theme_review_notice'] ) { @@ -133,9 +131,8 @@ public function envince_ignore_theme_review_notice() { */ public function envince_ignore_theme_review_notice_partially() { - global $current_user; - $user_id = $current_user->ID; - + $user_id = get_current_user_id(); + /* If user clicks to ignore the notice, add that to their user meta */ if ( isset( $_GET['nag_envince_ignore_theme_review_notice_partially'] ) && '0' == $_GET['nag_envince_ignore_theme_review_notice_partially'] ) { update_user_meta( $user_id, 'nag_envince_ignore_theme_review_notice_partially', time() ); From 95e21602597e1be0a481b513cc7c411e7ad5f542 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 06:04:52 +0545 Subject: [PATCH 3/5] Fix - Shortening of Theme review CSS --- css/admin/theme-review-notice.css | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/css/admin/theme-review-notice.css b/css/admin/theme-review-notice.css index cf4ffff..0d02fdc 100644 --- a/css/admin/theme-review-notice.css +++ b/css/admin/theme-review-notice.css @@ -1,18 +1,15 @@ -.theme-review-notice .links { - margin: 10px 0; +.notice.updated.theme-review-notice { + padding-right: 40px; } -.theme-review-notice .links a { - height: auto; - padding: 3px 15px; - margin-left: 10px; - text-transform: uppercase; +.theme-review-notice .links { + margin: 0.5em 0; } -.theme-review-notice .links a .dashicons { - line-height: 1.2; +.theme-review-notice .links a { + margin: 2px; } -.theme-review-notice .links a.button-primary { - margin-left: 0; -} +.theme-review-notice .links .dashicons { + line-height: 30px; +} \ No newline at end of file From 97380bc4622700387cb7bb9aed318153bbd74549 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 06:58:09 +0545 Subject: [PATCH 4/5] Update - Changelog --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index ec32a06..afd98eb 100644 --- a/readme.txt +++ b/readme.txt @@ -41,6 +41,9 @@ Envince WordPress Theme, Copyright (c) 2015, ThemeGrill Envince is distributed under the terms of the GNU GPL == Changelog == += Version TBD = +* Tweak - Add review notice message. + = Version 1.2.5 - 2020-02-20 = * Tweak - Update `screen-reader-text` CSS. From 14d082cff59ed06b3634a6e08b65716e3b8c8a9b Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 13 May 2020 13:17:18 +0545 Subject: [PATCH 5/5] Fix - Theme review CSS --- css/admin/message.css | 20 +++++++++++++++++++ css/admin/theme-review-notice.css | 15 -------------- .../class-envince-theme-review-notice.php | 10 ---------- 3 files changed, 20 insertions(+), 25 deletions(-) delete mode 100644 css/admin/theme-review-notice.css diff --git a/css/admin/message.css b/css/admin/message.css index 6bce232..e11ad75 100644 --- a/css/admin/message.css +++ b/css/admin/message.css @@ -3,10 +3,12 @@ position: relative; border-left-color: #2ea2cc !important; } + .envince-message a.button-primary, .envince-message a.button-secondary { text-decoration: none !important; } + .envince-message a.envince-message-close { position: absolute; top: 0; @@ -16,6 +18,7 @@ line-height: 1.23076923; text-decoration: none; } + .envince-message a.envince-message-close:before { position: absolute; top: 8px; @@ -23,3 +26,20 @@ -webkit-transition: all .1s ease-in-out; transition: all .1s ease-in-out; } + +/* Review Notice */ +.notice.updated.theme-review-notice { + padding-right: 40px; +} + +.theme-review-notice .links { + margin: 0.5em 0; +} + +.theme-review-notice .links a { + margin: 2px; +} + +.theme-review-notice .links .dashicons { + line-height: 30px; +} diff --git a/css/admin/theme-review-notice.css b/css/admin/theme-review-notice.css deleted file mode 100644 index 0d02fdc..0000000 --- a/css/admin/theme-review-notice.css +++ /dev/null @@ -1,15 +0,0 @@ -.notice.updated.theme-review-notice { - padding-right: 40px; -} - -.theme-review-notice .links { - margin: 0.5em 0; -} - -.theme-review-notice .links a { - margin: 2px; -} - -.theme-review-notice .links .dashicons { - line-height: 30px; -} \ No newline at end of file diff --git a/inc/admin/class-envince-theme-review-notice.php b/inc/admin/class-envince-theme-review-notice.php index 12f3dfa..b56ad37 100644 --- a/inc/admin/class-envince-theme-review-notice.php +++ b/inc/admin/class-envince-theme-review-notice.php @@ -28,7 +28,6 @@ public function __construct() { add_action( 'after_setup_theme', array( $this, 'envince_theme_rating_notice' ) ); add_action( 'switch_theme', array( $this, 'envince_theme_rating_notice_data_remove' ) ); - add_action( 'admin_enqueue_scripts', array( $this, 'envince_theme_rating_notice_enqueue' ) ); } @@ -171,15 +170,6 @@ public function envince_theme_rating_notice_data_remove() { } } - /** - * Enqueue the required CSS file for theme review notice on admin page. - */ - public function envince_theme_rating_notice_enqueue() { - - wp_enqueue_style( 'envince-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' ); - - } - } new Envince_Theme_Review_Notice();