PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | src/Notices/NoticeMain.php +35 -41 4.4.1 → 4.4.5 View file →
@@ -4,9 +4,8 @@
4 4
5 5 use YayMail\Utils\SingletonTrait;
6 6 use YayMail\Notices\Ajax;
7 7 use YayMail\SupportedPlugins;
8 -use YayMail\Utils\Logger;
9 8
10 9 /**
11 10 *
12 11 * @method static NoticeMain get_instance()
@@ -13,19 +12,11 @@
13 12 */
14 13 class NoticeMain {
15 14 use SingletonTrait;
16 15
17 - private $logger;
18 -
19 - private $supported_plugins;
20 -
21 16 protected function __construct() {
22 - $this->logger = new Logger();
23 -
24 17 Ajax::get_instance();
25 18
26 - $this->supported_plugins = SupportedPlugins::get_instance();
27 -
28 19 $this->init_hooks();
29 20 }
30 21
31 22 protected function init_hooks() {
@@ -32,31 +23,13 @@
32 23 if ( ! function_exists( 'YayMail\init' ) ) {
33 24 return;
34 25 }
35 26 // Show recommendation notice
36 - if ( time() >= (int) get_option( 'yaymail_next_recommendation_suggest_addons_notice_time' ) ) {
37 - add_action( 'admin_notices', [ $this, 'render_suggest_addons_notice' ] );
27 + if ( is_admin() && time() >= (int) get_option( 'yaymail_next_recommendation_notice_time' ) ) {
28 + add_action( 'admin_notices', [ $this, 'render_recommendation_notice' ] );
29 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_notice_script' ] );
38 30 }
39 31
40 - if ( time() >= (int) get_option( 'yaymail_next_recommendation_upgrade_notice_time' ) ) {
41 - add_action( 'admin_notices', [ $this, 'render_upgrade_notice' ] );
42 - }
43 -
44 - if ( is_admin() ) {
45 - if ( time() >= (int) get_option( 'yaymail_next_recommendation_notice_time' ) || time() >= (int) get_option( 'yaymail_next_recommendation_suggest_addons_notice_time' ) || time() >= (int) get_option( 'yaymail_next_recommendation_upgrade_notice_time' ) ) {
46 - wp_enqueue_script( 'yaymail-notice', YAYMAIL_PLUGIN_URL . 'assets/scripts/notice.js', [ 'jquery' ], yaymail_version(), false );
47 - }
48 -
49 - wp_localize_script(
50 - 'yaymail-notice',
51 - 'yaymail_notice',
52 - [
53 - 'admin_ajax' => admin_url( 'admin-ajax.php' ),
54 - 'nonce' => wp_create_nonce( 'yaymail_nonce' ),
55 - ]
56 - );
57 - }
58 -
59 32 add_action(
60 33 'after_plugin_row_' . YAYMAIL_PLUGIN_BASENAME,
61 34 [ $this, 'display_under_plugin_notices' ],
62 35 10,
@@ -78,14 +51,15 @@
78 51 }
79 52 $plugin_data = $plugins[ $key ];
80 53 $is_yaycommerce_author = isset( $plugin_data['Author'] ) && strpos( $plugin_data['Author'], 'YayCommerce' ) !== false;
81 54
55 + $is_yaymagic_email_builder = strpos( $key, 'yaymagic-email-builder' ) !== false;
82 56 return $is_yaycommerce_author && (
83 57 strpos( $key, 'yaymail-addon' ) !== false ||
84 58 strpos( $key, 'email-customizer' ) !== false ||
85 59 strpos( $key, 'yaymail-premium-addon' ) !== false ||
86 60 strpos( $key, 'yaymail-conditional-logic' ) !== false
87 - );
61 + ) && ! $is_yaymagic_email_builder;
88 62 },
89 63 ARRAY_FILTER_USE_KEY
90 64 );
91 65
@@ -120,15 +94,16 @@
120 94 * Enqueues a script to modify the plugin row styling in the admin footer.
121 95 */
122 96 public function enqueue_admin_script() {
123 97 ?>
124 - <script>
125 - document.addEventListener('DOMContentLoaded', function() {
126 - var pluginRow = document.querySelector('tr[data-plugin="<?php echo esc_js( YAYMAIL_PLUGIN_BASENAME ); ?>"]');
127 - if (pluginRow) pluginRow.classList.add('update');
128 - });
129 - </script>
130 - <?php
98 +<script>
99 +document.addEventListener('DOMContentLoaded', function() {
100 + var pluginRow = document.querySelector(
101 + 'tr[data-plugin="<?php echo esc_js( YAYMAIL_PLUGIN_BASENAME ); ?>"]');
102 + if (pluginRow) pluginRow.classList.add('update');
103 +});
104 +</script>
105 +<?php
131 106 }
132 107
133 108 /**
134 109 * Returns the notice to update to new core version.
@@ -139,12 +114,31 @@
139 114 esc_html__( 'Please update the YayMail Addons to version 4.0 or later to ensure compatibility and optimal performance.', 'yaymail' ),
140 115 );
141 116 }
142 117
143 - public function render_suggest_addons_notice() {
118 + /**
119 + * Script for the recommendation notice dismiss/no-thanks buttons.
120 + */
121 + public function enqueue_notice_script() {
122 + wp_enqueue_script( 'yaymail-notice', YAYMAIL_PLUGIN_URL . 'assets/scripts/notice.js', [ 'jquery' ], yaymail_version(), false );
123 +
124 + wp_localize_script(
125 + 'yaymail-notice',
126 + 'yaymail_notice',
127 + [
128 + 'admin_ajax' => admin_url( 'admin-ajax.php' ),
129 + 'nonce' => wp_create_nonce( 'yaymail_nonce' ),
130 + ]
131 + );
132 + }
133 +
134 + public function render_recommendation_notice() {
135 + if ( ! function_exists( 'YayMail\init' ) ) {
136 + return;
137 + }
144 138 /* List out the 3rd-party that need our addon*/
145 139 $addon_needed_plugins = [];
146 - foreach ( $this->supported_plugins->get_addon_supported_plugins() as $addon_namespace => $addon ) {
140 + foreach ( SupportedPlugins::get_instance()->get_addon_supported_plugins() as $addon_namespace => $addon ) {
147 141 if ( ! empty( $addon['is_3rd_party_installed'] ) && empty( $addon['installation_status']['is_active'] ) ) {
148 142 $addon_needed_plugins[ $addon_namespace ] = $addon;
149 143 }
150 144 }
@@ -161,5 +155,5 @@
161 155 if ( ! empty( $pro_needed_plugins ) ) {
162 156 include YAYMAIL_PLUGIN_PATH . 'templates/notices/upgrade.php';
163 157 }
164 158 }
165 -}
159 +}