← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Compatibilities.php
+35
-34
4.0.7
→
3.9.2
View file →
| @@ -11,9 +11,8 @@ | ||
| 11 | 11 | |
| 12 | 12 | namespace ThemeisleSDK\Modules; |
| 13 | 13 | |
| 14 | 14 | use ThemeisleSDK\Common\Abstract_Module; |
| 15 | -use ThemeisleSDK\Loader; | |
| 16 | 15 | use ThemeisleSDK\Product; |
| 17 | 16 | |
| 18 | 17 | // Exit if accessed directly. |
| 19 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -53,10 +52,11 @@ | ||
| 53 | 52 | * Registers the hooks. |
| 54 | 53 | * |
| 55 | 54 | * @param Product $product Product to load. |
| 56 | 55 | * |
| 56 | + * @throws \Exception If the configuration is invalid. | |
| 57 | + * | |
| 57 | 58 | * @return Compatibilities Module instance. |
| 58 | - * @throws \Exception If the configuration is invalid. | |
| 59 | 59 | */ |
| 60 | 60 | public function load( $product ) { |
| 61 | 61 | |
| 62 | 62 | |
| @@ -120,46 +120,47 @@ | ||
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | if ( $requirement->is_theme() && $screen->id === 'themes' ) { |
| 123 | 123 | ?> |
| 124 | - <script type="text/javascript"> | |
| 125 | - jQuery(document).ready(function ($) { | |
| 126 | - setInterval(checkTheme, 500); | |
| 127 | - | |
| 128 | - function checkTheme() { | |
| 129 | - var theme = jQuery('.theme.active[data-slug="<?php echo esc_attr( $requirement->get_slug() ); ?>"]'); | |
| 130 | - var notice_id = 'testedup<?php echo esc_attr( $requirement->get_slug() . $product->get_slug() ); ?>'; | |
| 131 | - if (theme.length > 0 && jQuery('#' + notice_id).length === 0) { | |
| 132 | - theme.find('.theme-id-container').prepend('<div style="bottom:100%;top:auto;" id="' + notice_id + '" class="notice notice-warning"><?php echo sprintf( esc_html( Loader::$labels['compatibilities']['notice_theme'] ), '<strong>', '</strong>', esc_attr( $product->get_friendly_name() ) ); ?></div>'); | |
| 133 | - } | |
| 134 | - if (theme.length > 0 && jQuery('#' + notice_id + 'overlay').length === 0) { | |
| 135 | - jQuery('.theme-overlay.active .theme-author').after('<div style="bottom:100%;top:auto;" id="' + notice_id + 'overlay" class="notice notice-warning"><p><?php echo sprintf( esc_html( Loader::$labels['compatibilities']['notice_theme'] ), '<strong>', '</strong>', esc_attr( $product->get_friendly_name() ) ); ?></p></div>'); | |
| 136 | - } | |
| 124 | + <script type="text/javascript"> | |
| 125 | + jQuery(document).ready(function ($) { | |
| 126 | + setInterval(checkTheme, 500); | |
| 127 | + function checkTheme() { | |
| 128 | + var theme = jQuery( '.theme.active[data-slug="<?php echo esc_attr( $requirement->get_slug() ); ?>"]' ); | |
| 129 | + var notice_id = 'testedup<?php echo esc_attr( $requirement->get_slug() . $product->get_slug() ); ?>'; | |
| 130 | + var product_name = '<?php echo esc_attr( $product->get_friendly_name() ); ?>'; | |
| 131 | + if (theme.length > 0 && jQuery('#' + notice_id).length === 0) { | |
| 132 | + theme.find('.theme-id-container').prepend('<div style="bottom:100%;top:auto;" id="'+notice_id+'" class="notice notice-warning"><strong>Warning:</strong> This theme has not been tested with your current version of <strong>' + product_name +'</strong>. Please update '+product_name+' plugin.</div>'); | |
| 137 | 133 | } |
| 138 | - }) | |
| 134 | + if (theme.length > 0 && jQuery('#' + notice_id + 'overlay').length === 0) { | |
| 135 | + jQuery('.theme-overlay.active .theme-author').after('<div style="bottom:100%;top:auto;" id="'+notice_id+'overlay" class="notice notice-warning"><p><strong>Warning:</strong> This theme has not been tested with your current version of <strong>' + product_name +'</strong>. Please update '+product_name+' plugin.</p></div>'); | |
| 136 | + } | |
| 137 | + } | |
| 138 | + }) | |
| 139 | 139 | |
| 140 | - </script> | |
| 140 | + </script> | |
| 141 | 141 | <?php |
| 142 | 142 | } |
| 143 | 143 | if ( $requirement->is_plugin() && $screen->id === 'plugins' ) { |
| 144 | 144 | ?> |
| 145 | - <script type="text/javascript"> | |
| 146 | - jQuery(document).ready(function ($) { | |
| 147 | - setInterval(checkPlugin, 500); | |
| 148 | - | |
| 149 | - function checkPlugin() { | |
| 150 | - var plugin = jQuery('.plugins .active[data-slug="<?php echo esc_attr( $requirement->get_slug() ); ?>"]'); | |
| 151 | - var notice_id = 'testedup<?php echo esc_attr( $requirement->get_slug() . $product->get_slug() ); ?>'; | |
| 152 | - if (plugin.length > 0 && jQuery('#' + notice_id).length === 0) { | |
| 153 | - plugin.find('.column-description').append('<div style="bottom:100%;top:auto;" id="' + notice_id + '" class="notice notice-warning notice-alt notice-inline"><?php echo sprintf( esc_html( Loader::$labels['compatibilities']['notice_plugin'] ), '<strong>', '</strong>', esc_attr( $product->get_friendly_name() ), esc_attr( $product->is_plugin() ? Loader::$labels['compatibilities']['plugin'] : Loader::$labels['compatibilities']['theme'] ) ); ?></div>'); | |
| 154 | - } | |
| 145 | + <script type="text/javascript"> | |
| 146 | + jQuery(document).ready(function ($) { | |
| 147 | + setInterval(checkPlugin, 500); | |
| 148 | + function checkPlugin() { | |
| 149 | + var plugin = jQuery( '.plugins .active[data-slug="<?php echo esc_attr( $requirement->get_slug() ); ?>"]' ); | |
| 150 | + var notice_id = 'testedup<?php echo esc_attr( $requirement->get_slug() . $product->get_slug() ); ?>'; | |
| 151 | + var product_name = '<?php echo esc_attr( $product->get_friendly_name() ); ?>'; | |
| 152 | + var product_type = '<?php echo ( $product->is_plugin() ? 'plugin' : 'theme' ); ?>'; | |
| 153 | + if (plugin.length > 0 && jQuery('#' + notice_id).length === 0) { | |
| 154 | + plugin.find('.column-description').append('<div style="bottom:100%;top:auto;" id="'+notice_id+'" class="notice notice-warning notice-alt notice-inline"><strong>Warning:</strong> This plugin has not been tested with your current version of <strong>' + product_name +'</strong>. Please update '+product_name+' '+product_type+'.</div>'); | |
| 155 | 155 | } |
| 156 | - }) | |
| 156 | + } | |
| 157 | + }) | |
| 157 | 158 | |
| 158 | - </script> | |
| 159 | + </script> | |
| 159 | 160 | <?php |
| 160 | 161 | } |
| 161 | - } | |
| 162 | + } | |
| 162 | 163 | ); |
| 163 | 164 | |
| 164 | 165 | } |
| 165 | 166 | |
| @@ -195,15 +196,15 @@ | ||
| 195 | 196 | $should_block = true; |
| 196 | 197 | } |
| 197 | 198 | if ( $should_block ) { |
| 198 | 199 | echo( sprintf( |
| 199 | - esc_html( Loader::$labels['compatibilities']['notice2'] ), | |
| 200 | + '%s update requires a newer version of %s. Please %supdate%s %s %s.', | |
| 200 | 201 | esc_attr( $product->get_friendly_name() ), |
| 201 | 202 | esc_attr( $requirement->get_friendly_name() ), |
| 202 | 203 | '<a href="' . esc_url( admin_url( $requirement->is_theme() ? 'themes.php' : 'plugins.php' ) ) . '">', |
| 203 | 204 | '</a>', |
| 204 | 205 | esc_attr( $requirement->get_friendly_name() ), |
| 205 | - esc_attr( $requirement->is_theme() ? Loader::$labels['compatibilities']['theme'] : Loader::$labels['compatibilities']['plugin'] ) | |
| 206 | + esc_attr( $requirement->is_theme() ? 'theme' : 'plugin' ) | |
| 206 | 207 | ) ); |
| 207 | 208 | $upgrader->maintenance_mode( false ); |
| 208 | 209 | die(); |
| 209 | 210 | } |
| @@ -218,15 +219,15 @@ | ||
| 218 | 219 | 'admin_notices', |
| 219 | 220 | function () use ( $product, $requirement ) { |
| 220 | 221 | echo '<div class="notice notice-error "><p>'; |
| 221 | 222 | echo( sprintf( |
| 222 | - esc_html( Loader::$labels['compatibilities']['notice'] ), | |
| 223 | + '%s requires a newer version of %s. Please %supdate%s %s %s to the latest version.', | |
| 223 | 224 | '<strong>' . esc_attr( $product->get_friendly_name() ) . '</strong>', |
| 224 | 225 | '<strong>' . esc_attr( $requirement->get_friendly_name() ) . '</strong>', |
| 225 | 226 | '<a href="' . esc_url( admin_url( $requirement->is_theme() ? 'themes.php' : 'plugins.php' ) ) . '">', |
| 226 | 227 | '</a>', |
| 227 | 228 | '<strong>' . esc_attr( $requirement->get_friendly_name() ) . '</strong>', |
| 228 | - esc_attr( $requirement->is_theme() ? Loader::$labels['compatibilities']['theme'] : Loader::$labels['compatibilities']['plugin'] ) | |
| 229 | + esc_attr( $requirement->is_theme() ? 'theme' : 'plugin' ) | |
| 229 | 230 | ) ); |
| 230 | 231 | echo '</p></div>'; |
| 231 | 232 | } |
| 232 | 233 | ); |