From e0d45ff192b9d0987a19ebf7fe715d5cded52eda Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Wed, 17 Oct 2018 16:04:46 +0530 Subject: [PATCH 1/8] added rating notice --- assets/images/astra-logo.svg | 16 ++ assets/images/astra.svg | 37 +++ custom-typekit-fonts.php | 56 +++++ inc/lib/notices/class-astra-notices.php | 308 ++++++++++++++++++++++++ inc/lib/notices/notices.js | 94 ++++++++ 5 files changed, 511 insertions(+) create mode 100644 assets/images/astra-logo.svg create mode 100644 assets/images/astra.svg create mode 100644 inc/lib/notices/class-astra-notices.php create mode 100644 inc/lib/notices/notices.js diff --git a/assets/images/astra-logo.svg b/assets/images/astra-logo.svg new file mode 100644 index 0000000..5befef9 --- /dev/null +++ b/assets/images/astra-logo.svg @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/assets/images/astra.svg b/assets/images/astra.svg new file mode 100644 index 0000000..bd4abba --- /dev/null +++ b/assets/images/astra.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/custom-typekit-fonts.php b/custom-typekit-fonts.php index 57e6aea..a2f41e5 100644 --- a/custom-typekit-fonts.php +++ b/custom-typekit-fonts.php @@ -30,3 +30,59 @@ * BSF Custom Fonts */ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts.php'; + +if ( ! function_exists( 'register_notices' ) ) : + + /** + * Ask Theme Rating + * + * @since 1.4.0 + */ + function register_notices() { + $image_path = CUSTOM_TYPEKIT_FONTS_URI . 'assets/images/astra-logo.svg'; + Astra_Notices::add_notice( + array( + 'id' => 'custom-typekit-fonts-rating', + 'type' => '', + /* translators: %1$s logo link, %2$s product rating link, %3$s dismissable notice transient time. */ + 'message' => sprintf( + '
+
+
+
+ %2$s +
+ %3$s
+ +
', + $image_path, + __( 'Hello! Seems like you have used Custom Typekit Fonts to build this website — Thanks a ton!', 'custom-typekit-fonts' ), + __( 'Could you please do us a BIG favor and give it a 5-star rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the Custom Typekit Fonts.', 'custom-typekit-fonts' ), + 'https://wordpress.org/support/theme/astra/reviews/?filter=5#new-post', + __( 'Ok, you deserve it', 'custom-typekit-fonts' ), + MONTH_IN_SECONDS, + __( 'Nope, maybe later', 'custom-typekit-fonts' ), + __( 'I already did', 'custom-typekit-fonts' ) + ), + 'repeat-notice-after' => MONTH_IN_SECONDS, + 'priority' => 25, + 'display-with-other-notices' => true, + ) + ); + } + + add_action( 'admin_notices', 'register_notices' ); + +endif; diff --git a/inc/lib/notices/class-astra-notices.php b/inc/lib/notices/class-astra-notices.php new file mode 100644 index 0000000..0d40532 --- /dev/null +++ b/inc/lib/notices/class-astra-notices.php @@ -0,0 +1,308 @@ + Create custom close notice link in the notice markup. E.g. + * `` + * It close the notice for 30 days. + * + * @package Astra Sites + * @since 1.4.0 + */ + +if ( ! class_exists( 'Astra_Notices' ) ) : + + /** + * Astra_Notices + * + * @since 1.4.0 + */ + class Astra_Notices { + + /** + * Notices + * + * @access private + * @var array Notices. + * @since 1.4.0 + */ + private static $version = '1.0.0'; + + /** + * Notices + * + * @access private + * @var array Notices. + * @since 1.4.0 + */ + private static $notices = array(); + + /** + * Instance + * + * @access private + * @var object Class object. + * @since 1.4.0 + */ + private static $instance; + + /** + * Initiator + * + * @since 1.4.0 + * @return object initialized object of class. + */ + public static function get_instance() { + if ( ! isset( self::$instance ) ) { + self::$instance = new self; + } + return self::$instance; + } + + /** + * Constructor + * + * @since 1.4.0 + */ + public function __construct() { + add_action( 'admin_notices', array( $this, 'show_notices' ), 30 ); + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + add_action( 'wp_ajax_astra-notice-dismiss', array( $this, 'dismiss_notice' ) ); + add_filter( 'wp_kses_allowed_html', array( $this, 'add_data_attributes' ), 10, 2 ); + } + + /** + * Filters and Returns a list of allowed tags and attributes for a given context. + * + * @param Array $allowedposttags Array of allowed tags. + * @param String $context Context type (explicit). + * @since 1.4.0 + * @return Array + */ + function add_data_attributes( $allowedposttags, $context ) { + $allowedposttags['a']['data-repeat-notice-after'] = true; + + return $allowedposttags; + } + + /** + * Add Notice. + * + * @since 1.4.0 + * @param array $args Notice arguments. + * @return void + */ + public static function add_notice( $args = array() ) { + self::$notices[] = $args; + } + + /** + * Dismiss Notice. + * + * @since 1.4.0 + * @return void + */ + function dismiss_notice() { + $notice_id = ( isset( $_POST['notice_id'] ) ) ? sanitize_key( $_POST['notice_id'] ) : ''; + $repeat_notice_after = ( isset( $_POST['repeat_notice_after'] ) ) ? absint( $_POST['repeat_notice_after'] ) : ''; + + // Valid inputs? + if ( ! empty( $notice_id ) ) { + + if ( ! empty( $repeat_notice_after ) ) { + set_transient( $notice_id, true, $repeat_notice_after ); + } else { + update_user_meta( get_current_user_id(), $notice_id, true ); + } + + wp_send_json_success(); + } + + wp_send_json_error(); + } + + /** + * Enqueue Scripts. + * + * @since 1.4.0 + * @return void + */ + function enqueue_scripts() { + wp_register_script( 'astra-notices', self::_get_uri() . 'notices.js', array( 'jquery' ), null, self::$version ); + } + + /** + * Rating priority sort + * + * @since 1.5.2 + * @param array $array1 array one. + * @param array $array2 array two. + * @return array + */ + function sort_notices( $array1, $array2 ) { + return strnatcmp( $array1['priority'], $array2['priority'] ); + } + + /** + * Notice Types + * + * @since 1.4.0 + * @return void + */ + function show_notices() { + + $defaults = array( + 'id' => '', // Optional, Notice ID. If empty it set `astra-notices-id-<$array-index>`. + 'type' => 'info', // Optional, Notice type. Default `info`. Expected [info, warning, notice, error]. + 'message' => '', // Optional, Message. + 'show_if' => true, // Optional, Show notice on custom condition. E.g. 'show_if' => if( is_admin() ) ? true, false, . + 'repeat-notice-after' => '', // Optional, Dismiss-able notice time. It'll auto show after given time. + 'class' => '', // Optional, Additional notice wrapper class. + 'priority' => 10, // Priority of the notice. + 'display-with-other-notices' => true, // Should the notice be displayed if other notices are being displayed from Astra_Notices. + ); + + // Count for the notices that are rendered. + $notices_displayed = 0; + + // sort the array with priority. + usort( self::$notices, array( $this, 'sort_notices' ) ); + + foreach ( self::$notices as $key => $notice ) { + + $notice = wp_parse_args( $notice, $defaults ); + + $notice['id'] = self::get_notice_id( $notice, $key ); + + $notice['classes'] = self::get_wrap_classes( $notice ); + + // Notices visible after transient expire. + if ( isset( $notice['show_if'] ) && true === $notice['show_if'] ) { + if ( self::is_expired( $notice ) ) { + + // don't display the notice if it is not supposed to be displayed with other notices. + if ( 0 !== $notices_displayed && false === $notice['display-with-other-notices'] ) { + return; + } + + self::markup( $notice ); + $notices_displayed++; + } + } else { + // No transient notices. + self::markup( $notice ); + } + } + + } + + /** + * Markup Notice. + * + * @since 1.4.0 + * @param array $notice Notice markup. + * @return void + */ + public static function markup( $notice = array() ) { + + wp_enqueue_script( 'astra-notices' ); + + ?> +
+
+ +
+
+ Date: Wed, 17 Oct 2018 16:47:26 +0530 Subject: [PATCH 2/8] updated notice rating code --- assets/images/astra-logo.svg | 16 --------- assets/images/astra.svg | 37 -------------------- assets/images/custom-typekit-fonts-icon.png | Bin 0 -> 6370 bytes custom-typekit-fonts.php | 4 +-- 4 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 assets/images/astra-logo.svg delete mode 100644 assets/images/astra.svg create mode 100644 assets/images/custom-typekit-fonts-icon.png diff --git a/assets/images/astra-logo.svg b/assets/images/astra-logo.svg deleted file mode 100644 index 5befef9..0000000 --- a/assets/images/astra-logo.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/assets/images/astra.svg b/assets/images/astra.svg deleted file mode 100644 index bd4abba..0000000 --- a/assets/images/astra.svg +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/assets/images/custom-typekit-fonts-icon.png b/assets/images/custom-typekit-fonts-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..53392386ead42916b0b7e10322f098f310360974 GIT binary patch literal 6370 zcmYM1bx_q`wD!N}&>hm-S*I?BmuX*sxgxxI66bEi|0lcRI@bhCGS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j!#WIei@rnK`s56obdk@VE514Cyh;-#DX1lC! z7D0Mz#Jey$LC{Ah6pK&XBcH(*M&><_znXUA{d&k8<1#m zn6rV5Ev{Q{8kT>rGN*kBzwayZL2Ef?tRDYlRS6+Z^1;)P z^i(qNSmekG8l{4=7l^tLlmHC&B7LAE+8Lj`9~J>zz&U3v^SA4>DNO?MEnt`49P?djqL061h97ng z`#$|psxqgQ&lzFvvxpGCDz1N3UA==*ME}X~%3T6vUuGj36o1&*k+4sSHas%-YihgN zYOfO|K8r2MQGcFoq=bc0yJB=pWUc{M@NV`!fSvIFaa03p;z_FTXY|yH5&slahUXEBRDkh#Xlw_Y*wnR~~&CN&XNrV4h^cMpa z=(!ebUm@c>ut?dn$#Y@_t-|o#zi_z}^M5Fi+uM2}ZLOn*a<;9Omu8E6=CVHApR+<= z7G9S!d^$#lkWTq%E|j+VM^jRP0nALYQ}n%2pmSY5pp~55f6cvSZS|c}T1ZVT*T$dh zyL?#~maHKV(c}LD19{}3W1Z+B&IBZc%rM;Pk74fgC52wq>~9)+y{GB(v?5=Yym`iK zfZrtu66P&~SRKe@obmz38l_1=*64D*uX;8CPFy$~{r^ZwLbl|#{KqhavOx(fzU7`F dOn;&UmYm9pe2!|)o`*<4ML|QpR@O57{{c>5^JV}5 literal 0 HcmV?d00001 diff --git a/custom-typekit-fonts.php b/custom-typekit-fonts.php index a2f41e5..6140d78 100644 --- a/custom-typekit-fonts.php +++ b/custom-typekit-fonts.php @@ -39,7 +39,7 @@ * @since 1.4.0 */ function register_notices() { - $image_path = CUSTOM_TYPEKIT_FONTS_URI . 'assets/images/astra-logo.svg'; + $image_path = CUSTOM_TYPEKIT_FONTS_URI . 'assets/images/custom-typekit-fonts-icon.png'; Astra_Notices::add_notice( array( 'id' => 'custom-typekit-fonts-rating', @@ -78,7 +78,7 @@ function register_notices() { ), 'repeat-notice-after' => MONTH_IN_SECONDS, 'priority' => 25, - 'display-with-other-notices' => true, + 'display-with-other-notices' => false, ) ); } From dbb3d06ebb8d6a73cca60ab4b4d303fbd4c6041c Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Wed, 17 Oct 2018 17:51:56 +0530 Subject: [PATCH 3/8] included notice file --- custom-typekit-fonts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-typekit-fonts.php b/custom-typekit-fonts.php index 6140d78..fc6e9ab 100644 --- a/custom-typekit-fonts.php +++ b/custom-typekit-fonts.php @@ -30,6 +30,7 @@ * BSF Custom Fonts */ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts.php'; +require_once CUSTOM_TYPEKIT_FONTS_URI . 'inc/lib/notices/class-astra-notices.php'; if ( ! function_exists( 'register_notices' ) ) : @@ -44,7 +45,6 @@ function register_notices() { array( 'id' => 'custom-typekit-fonts-rating', 'type' => '', - /* translators: %1$s logo link, %2$s product rating link, %3$s dismissable notice transient time. */ 'message' => sprintf( '
From a9162e67f58b1c91f88b2315f188d8ed28781b33 Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Wed, 17 Oct 2018 17:54:28 +0530 Subject: [PATCH 4/8] update review URL --- custom-typekit-fonts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-typekit-fonts.php b/custom-typekit-fonts.php index fc6e9ab..71ce026 100644 --- a/custom-typekit-fonts.php +++ b/custom-typekit-fonts.php @@ -70,7 +70,7 @@ function register_notices() { $image_path, __( 'Hello! Seems like you have used Custom Typekit Fonts to build this website — Thanks a ton!', 'custom-typekit-fonts' ), __( 'Could you please do us a BIG favor and give it a 5-star rating on WordPress? This would boost our motivation and help other users make a comfortable decision while choosing the Custom Typekit Fonts.', 'custom-typekit-fonts' ), - 'https://wordpress.org/support/theme/astra/reviews/?filter=5#new-post', + 'https://wordpress.org/support/plugin/custom-typekit-fonts/reviews/?filter=5#new-post', __( 'Ok, you deserve it', 'custom-typekit-fonts' ), MONTH_IN_SECONDS, __( 'Nope, maybe later', 'custom-typekit-fonts' ), From 1ffe2a9f0947df71612f5177af31e2c90e88901f Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Wed, 17 Oct 2018 17:59:24 +0530 Subject: [PATCH 5/8] updated CSS --- assets/css/custom-typekit-fonts.css | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/assets/css/custom-typekit-fonts.css b/assets/css/custom-typekit-fonts.css index f6507c2..3451be7 100644 --- a/assets/css/custom-typekit-fonts.css +++ b/assets/css/custom-typekit-fonts.css @@ -67,3 +67,43 @@ .ctf-kit-not-active { color: #ae5842; } + +.astra-review-notice-container { + display: flex; + align-items: center; + padding-top: 10px; +} + +.astra-review-notice-container .dashicons { + font-size: 1.4em; + padding-left: 10px; +} + +.astra-review-notice-container a { + padding-left: 5px; + text-decoration: none; +} + +.astra-review-notice-container .dashicons:first-child { + padding-left: 0; +} + +.notice-image img { + max-width: 90px; +} + +.notice-content .notice-heading { + padding-bottom: 5px; +} + +.notice-content { + margin-left: 15px; +} + +.notice-container { + padding-top: 10px; + padding-bottom: 10px; + display: flex; + justify-content: left; + align-items: center; +} \ No newline at end of file From e4fd633986e39d5eb4054239ca09f5d376f4095f Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Wed, 17 Oct 2018 18:07:49 +0530 Subject: [PATCH 6/8] updated included code for motice --- custom-typekit-fonts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom-typekit-fonts.php b/custom-typekit-fonts.php index 71ce026..45ed961 100644 --- a/custom-typekit-fonts.php +++ b/custom-typekit-fonts.php @@ -30,7 +30,7 @@ * BSF Custom Fonts */ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts.php'; -require_once CUSTOM_TYPEKIT_FONTS_URI . 'inc/lib/notices/class-astra-notices.php'; +require_once CUSTOM_TYPEKIT_FONTS_DIR . 'inc/lib/notices/class-astra-notices.php'; if ( ! function_exists( 'register_notices' ) ) : From b084d56243b384cde46336f16058b864ccf9aa45 Mon Sep 17 00:00:00 2001 From: uttam sharma Date: Fri, 19 Oct 2018 17:59:06 +0530 Subject: [PATCH 7/8] update notice file --- inc/lib/notices/class-astra-notices.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/inc/lib/notices/class-astra-notices.php b/inc/lib/notices/class-astra-notices.php index 0d40532..973b1b0 100644 --- a/inc/lib/notices/class-astra-notices.php +++ b/inc/lib/notices/class-astra-notices.php @@ -145,7 +145,14 @@ function enqueue_scripts() { * @return array */ function sort_notices( $array1, $array2 ) { - return strnatcmp( $array1['priority'], $array2['priority'] ); + if ( ! isset( $array1['priority'] ) ) { + $array1['priority'] = 10; + } + if ( ! isset( $array2['priority'] ) ) { + $array2['priority'] = 10; + } + + return $array1['priority'] - $array2['priority']; } /** @@ -187,16 +194,17 @@ function show_notices() { // don't display the notice if it is not supposed to be displayed with other notices. if ( 0 !== $notices_displayed && false === $notice['display-with-other-notices'] ) { - return; + continue; } self::markup( $notice ); - $notices_displayed++; } } else { // No transient notices. self::markup( $notice ); } + + ++$notices_displayed; } } @@ -236,7 +244,7 @@ private static function get_wrap_classes( $notice ) { $classes[] = 'notice-' . $notice['type']; } - return implode( ' ', $classes ); + return esc_attr( implode( ' ', $classes ) ); } /** @@ -305,4 +313,4 @@ public static function _get_uri() { */ Astra_Notices::get_instance(); -endif; +endif; \ No newline at end of file From c6565887f366f2ee00c6e3e63c5d9e6d0ecf6fa7 Mon Sep 17 00:00:00 2001 From: Uttam Sharma Date: Tue, 5 Nov 2019 14:36:23 +0530 Subject: [PATCH 8/8] updated astra motice --- inc/lib/notices/class-astra-notices.php | 14 +++++++++++++- inc/lib/notices/notices.js | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/inc/lib/notices/class-astra-notices.php b/inc/lib/notices/class-astra-notices.php index 973b1b0..607b5f6 100644 --- a/inc/lib/notices/class-astra-notices.php +++ b/inc/lib/notices/class-astra-notices.php @@ -110,6 +110,11 @@ public static function add_notice( $args = array() ) { function dismiss_notice() { $notice_id = ( isset( $_POST['notice_id'] ) ) ? sanitize_key( $_POST['notice_id'] ) : ''; $repeat_notice_after = ( isset( $_POST['repeat_notice_after'] ) ) ? absint( $_POST['repeat_notice_after'] ) : ''; + $nonce = ( isset( $_POST['nonce'] ) ) ? sanitize_key( $_POST['nonce'] ) : ''; + + if ( false === wp_verify_nonce( $nonce, 'astra-notices' ) ) { + wp_send_json_error( _e( 'WordPress Nonce not validated.', 'astra-sites' ) ); + } // Valid inputs? if ( ! empty( $notice_id ) ) { @@ -134,6 +139,13 @@ function dismiss_notice() { */ function enqueue_scripts() { wp_register_script( 'astra-notices', self::_get_uri() . 'notices.js', array( 'jquery' ), null, self::$version ); + wp_localize_script( + 'astra-notices', + 'astraNotices', + array( + '_notice_nonce' => wp_create_nonce( 'astra-notices' ), + ) + ); } /** @@ -313,4 +325,4 @@ public static function _get_uri() { */ Astra_Notices::get_instance(); -endif; \ No newline at end of file +endif; diff --git a/inc/lib/notices/notices.js b/inc/lib/notices/notices.js index 2c7497b..b7062a1 100644 --- a/inc/lib/notices/notices.js +++ b/inc/lib/notices/notices.js @@ -82,6 +82,7 @@ action : 'astra-notice-dismiss', notice_id : notice_id, repeat_notice_after : parseInt( repeat_notice_after ), + nonce : astraNotices._notice_nonce }, });