From 73b2cc914577c94a1b85ef6c5ab2e4208dbe9ffd Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Sat, 11 Apr 2020 08:33:52 +0545 Subject: [PATCH 1/7] Add - Theme review notice --- css/admin/theme-review.css | 19 ++ functions.php | 1 + .../class-masonic-theme-review-notice.php | 188 ++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 css/admin/theme-review.css create mode 100644 inc/admin/class-masonic-theme-review-notice.php diff --git a/css/admin/theme-review.css b/css/admin/theme-review.css new file mode 100644 index 0000000..fd51a9f --- /dev/null +++ b/css/admin/theme-review.css @@ -0,0 +1,19 @@ +.theme-review-notice .links { + margin: 10px 0; + padding-bottom: 10px; +} + +.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 51a0c3e..3b43281 100644 --- a/functions.php +++ b/functions.php @@ -381,6 +381,7 @@ function masonic_meta_box_display_toggle() { if ( is_admin() ) { require get_template_directory() . '/inc/admin/class-masonic-admin.php'; require get_template_directory() . '/inc/admin/class-masonic-tdi-notice.php'; + require get_template_directory() . '/inc/admin/class-masonic-theme-review-notice.php'; /** * Load TGMPA Configs. diff --git a/inc/admin/class-masonic-theme-review-notice.php b/inc/admin/class-masonic-theme-review-notice.php new file mode 100644 index 0000000..c765af0 --- /dev/null +++ b/inc/admin/class-masonic-theme-review-notice.php @@ -0,0 +1,188 @@ +ID; + $current_user = wp_get_current_user(); + $ignored_notice = get_user_meta( $user_id, 'masonic_ignore_theme_review_notice', true ); + $ignored_notice_partially = get_user_meta( $user_id, 'nag_masonic_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( 'masonic_theme_installed_time' ) > strtotime( '-15 sec' ) ) || ( $ignored_notice_partially > strtotime( '-15 sec' ) ) || ( $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_masonic_ignore_theme_review_notice'] ) && '0' == $_GET['nag_masonic_ignore_theme_review_notice'] ) { + add_user_meta( $user_id, 'masonic_ignore_theme_review_notice', 'true', true ); + } + + } + + /** + * Function to remove the theme review notice partially as requested by the user. + */ + public function masonic_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_masonic_ignore_theme_review_notice_partially'] ) && '0' == $_GET['nag_masonic_ignore_theme_review_notice_partially'] ) { + update_user_meta( $user_id, 'nag_masonic_ignore_theme_review_notice_partially', time() ); + } + + } + + /** + * Remove the data set after the theme has been switched to other theme. + */ + public function masonic_theme_rating_notice_data_remove() { + + $get_all_users = get_users(); + $theme_installed_time = get_option( 'masonic_theme_installed_time' ); + + // Delete options data. + if ( $theme_installed_time ) { + delete_option( 'masonic_theme_installed_time' ); + } + + // Delete user meta data for theme review notice. + foreach ( $get_all_users as $user ) { + $ignored_notice = get_user_meta( $user->ID, 'masonic_ignore_theme_review_notice', true ); + $ignored_notice_partially = get_user_meta( $user->ID, 'nag_masonic_ignore_theme_review_notice_partially', true ); + + // Delete permanent notice remove data. + if ( $ignored_notice ) { + delete_user_meta( $user->ID, 'masonic_ignore_theme_review_notice' ); + } + + // Delete partial notice remove data. + if ( $ignored_notice_partially ) { + delete_user_meta( $user->ID, 'nag_masonic_ignore_theme_review_notice_partially' ); + } + + } + } + + /** + * Enqueue the required CSS file for theme review notice on admin page. + */ + public function masonic_theme_rating_notice_enqueue() { + + wp_enqueue_style( 'masonic-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' ); + + } + +} + +new Masonic_Theme_Review_Notice(); From 7b3b9d2f1eeb60d153b2e8b780db117ad5f06d80 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 07:05:44 +0545 Subject: [PATCH 2/7] Remove Global declaration uf $current_user --- inc/admin/class-masonic-theme-review-notice.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/inc/admin/class-masonic-theme-review-notice.php b/inc/admin/class-masonic-theme-review-notice.php index c765af0..0af40ce 100644 --- a/inc/admin/class-masonic-theme-review-notice.php +++ b/inc/admin/class-masonic-theme-review-notice.php @@ -54,8 +54,7 @@ public function masonic_theme_rating_notice() { */ public function masonic_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, 'masonic_ignore_theme_review_notice', true ); $ignored_notice_partially = get_user_meta( $user_id, 'nag_masonic_ignore_theme_review_notice_partially', true ); @@ -118,8 +117,7 @@ public function masonic_theme_review_notice() { */ public function masonic_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_masonic_ignore_theme_review_notice'] ) && '0' == $_GET['nag_masonic_ignore_theme_review_notice'] ) { @@ -133,8 +131,7 @@ public function masonic_ignore_theme_review_notice() { */ public function masonic_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_masonic_ignore_theme_review_notice_partially'] ) && '0' == $_GET['nag_masonic_ignore_theme_review_notice_partially'] ) { From 4a62974dd1cc1c0a393ed3205f6614e3820aee57 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 07:07:03 +0545 Subject: [PATCH 3/7] Fix - Shortening of Theme review CSS --- css/admin/theme-review.css | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/css/admin/theme-review.css b/css/admin/theme-review.css index fd51a9f..0d02fdc 100644 --- a/css/admin/theme-review.css +++ b/css/admin/theme-review.css @@ -1,19 +1,15 @@ -.theme-review-notice .links { - margin: 10px 0; - padding-bottom: 10px; +.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 a3b142ddc726994ba4c19497d4c4380f2a63a491 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 6 May 2020 07:10:09 +0545 Subject: [PATCH 4/7] Update - Changelog --- readme.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.txt b/readme.txt index 2567fb7..8bebdbf 100644 --- a/readme.txt +++ b/readme.txt @@ -43,6 +43,9 @@ and we will include it within the theme from next version update. /**********************************************************/ == Changelog == += Version TBD = +* Tweak - Add review notice message. + = Version 1.3.3 - 2020-02-20 = * Fix - Link for `skip-link` to content area. * Tweak - Update `screen-reader-text` CSS. From fa5dd7a9a3f90478c6eddb8814d86ed68aef5864 Mon Sep 17 00:00:00 2001 From: NituShrestha Date: Wed, 13 May 2020 12:48:36 +0545 Subject: [PATCH 5/7] Fix - Theme review CSS --- css/admin/message.css | 17 +++++++++++++++++ css/admin/theme-review.css | 15 --------------- inc/admin/class-masonic-theme-review-notice.php | 12 +----------- 3 files changed, 18 insertions(+), 26 deletions(-) delete mode 100644 css/admin/theme-review.css diff --git a/css/admin/message.css b/css/admin/message.css index 907102c..80dab84 100644 --- a/css/admin/message.css +++ b/css/admin/message.css @@ -23,3 +23,20 @@ -webkit-transition: all .1s ease-in-out; transition: all .1s ease-in-out; } + +/* Theme review notice CSS */ +.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.css b/css/admin/theme-review.css deleted file mode 100644 index 0d02fdc..0000000 --- a/css/admin/theme-review.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-masonic-theme-review-notice.php b/inc/admin/class-masonic-theme-review-notice.php index 0af40ce..95d4a31 100644 --- a/inc/admin/class-masonic-theme-review-notice.php +++ b/inc/admin/class-masonic-theme-review-notice.php @@ -28,8 +28,7 @@ public function __construct() { add_action( 'after_setup_theme', array( $this, 'masonic_theme_rating_notice' ) ); add_action( 'switch_theme', array( $this, 'masonic_theme_rating_notice_data_remove' ) ); - add_action( 'admin_enqueue_scripts', array( $this, 'masonic_theme_rating_notice_enqueue' ) ); - + } /** @@ -171,15 +170,6 @@ public function masonic_theme_rating_notice_data_remove() { } } - /** - * Enqueue the required CSS file for theme review notice on admin page. - */ - public function masonic_theme_rating_notice_enqueue() { - - wp_enqueue_style( 'masonic-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' ); - - } - } new Masonic_Theme_Review_Notice(); From 51a81fe7ec34074249659a39fb99075a1ee716df Mon Sep 17 00:00:00 2001 From: ThemeGrill Date: Fri, 15 May 2020 10:47:02 +0545 Subject: [PATCH 6/7] Linked admin review notice CSS rules --- css/admin/message.css | 17 ----------------- css/admin/theme-review-notice.css | 16 ++++++++++++++++ inc/admin/class-masonic-theme-review-notice.php | 16 ++++++++++++---- 3 files changed, 28 insertions(+), 21 deletions(-) create mode 100644 css/admin/theme-review-notice.css diff --git a/css/admin/message.css b/css/admin/message.css index 80dab84..907102c 100644 --- a/css/admin/message.css +++ b/css/admin/message.css @@ -23,20 +23,3 @@ -webkit-transition: all .1s ease-in-out; transition: all .1s ease-in-out; } - -/* Theme review notice CSS */ -.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 new file mode 100644 index 0000000..0b9637d --- /dev/null +++ b/css/admin/theme-review-notice.css @@ -0,0 +1,16 @@ +/* Theme review notice CSS */ +.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/inc/admin/class-masonic-theme-review-notice.php b/inc/admin/class-masonic-theme-review-notice.php index 95d4a31..96aaf7c 100644 --- a/inc/admin/class-masonic-theme-review-notice.php +++ b/inc/admin/class-masonic-theme-review-notice.php @@ -28,7 +28,7 @@ public function __construct() { add_action( 'after_setup_theme', array( $this, 'masonic_theme_rating_notice' ) ); add_action( 'switch_theme', array( $this, 'masonic_theme_rating_notice_data_remove' ) ); - + add_action( 'admin_enqueue_scripts', array( $this, 'masonic_theme_rating_notice_enqueue' ) ); } /** @@ -65,7 +65,7 @@ public function masonic_theme_review_notice() { * 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( 'masonic_theme_installed_time' ) > strtotime( '-15 sec' ) ) || ( $ignored_notice_partially > strtotime( '-15 sec' ) ) || ( $ignored_notice ) ) { + if ( ( get_option( 'masonic_theme_installed_time' ) > strtotime( '-15 day' ) ) || ( $ignored_notice_partially > strtotime( '-15 day' ) ) || ( $ignored_notice ) ) { return; } ?> @@ -76,7 +76,8 @@ public function masonic_theme_review_notice() { printf( /* Translators: %1$s current user display name. */ esc_html__( - 'Howdy, %1$s! It seems that you have been using this theme for more than 15 day. We hope you are happy with everything that the theme has to offer. If you can spare a minute, please help us by leaving a 5-star review on WordPress.org. By spreading the love, we can continue to develop new amazing features in the future, for free!', 'masonic' + 'Howdy, %1$s! It seems that you have been using this theme for more than 15 day. We hope you are happy with everything that the theme has to offer. If you can spare a minute, please help us by leaving a 5-star review on WordPress.org. By spreading the love, we can continue to develop new amazing features in the future, for free!', + 'masonic' ), '' . esc_html( $current_user->display_name ) . '' ); @@ -166,10 +167,17 @@ public function masonic_theme_rating_notice_data_remove() { if ( $ignored_notice_partially ) { delete_user_meta( $user->ID, 'nag_masonic_ignore_theme_review_notice_partially' ); } - } } + /** + * Enqueue the required CSS file for theme review notice on admin page. + */ + public function masonic_theme_rating_notice_enqueue() { + + wp_enqueue_style( 'masonic-theme-review-notice', get_template_directory_uri() . '/css/admin/theme-review-notice.css' ); + + } } new Masonic_Theme_Review_Notice(); From fdea6b84328695d11a68a3b57248f8569e954559 Mon Sep 17 00:00:00 2001 From: ThemeGrill Date: Fri, 15 May 2020 10:47:55 +0545 Subject: [PATCH 7/7] Update @since version number --- inc/admin/class-masonic-theme-review-notice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin/class-masonic-theme-review-notice.php b/inc/admin/class-masonic-theme-review-notice.php index 96aaf7c..35542e7 100644 --- a/inc/admin/class-masonic-theme-review-notice.php +++ b/inc/admin/class-masonic-theme-review-notice.php @@ -4,7 +4,7 @@ * * @author ThemeGrill * @package masonic - * @since 1.1.4 + * @since 1.3.4 */ // Exit if directly accessed.