admin-bar
1 year ago
client-migration
6 months ago
compatibility
1 year ago
customizer
1 year ago
freemius
8 months ago
menu-icons
1 year ago
metabox
1 year ago
onboarding
2 weeks ago
panel
9 months ago
post-settings
2 months ago
preloader
1 year ago
shortcodes
1 year ago
themepanel
1 year ago
widgets
8 months ago
wizard
3 years ago
adobe-font.php
1 year ago
custom-code.php
8 months ago
dashboard.php
1 year ago
image-resizer.php
1 year ago
jshrink.php
3 years ago
mautic.php
2 months ago
ocean-extra-strings.php
3 years ago
plugins-tab.php
1 year ago
update-message.php
1 year ago
utils.php
1 year ago
walker.php
4 years ago
update-message.php
205 lines
| 1 | <?php |
| 2 | /** |
| 3 | * OceanWP plugin update message |
| 4 | * |
| 5 | * @package OceanWP WordPress theme |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | if ( ! class_exists( 'OE_Plugin_Update_Message' ) ) : |
| 13 | |
| 14 | class OE_Plugin_Update_Message { |
| 15 | |
| 16 | /** |
| 17 | * Setup class. |
| 18 | * |
| 19 | * @since 2.3.0 |
| 20 | */ |
| 21 | public function __construct() { |
| 22 | |
| 23 | add_action( 'in_plugin_update_message-ocean-extra/ocean-extra.php', array( $this, 'plugin_update_message' ), 10, 2 ); |
| 24 | add_action( 'admin_enqueue_scripts', array( $this, 'plugin_update_asset' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Message content |
| 29 | */ |
| 30 | public function plugin_update_content() { |
| 31 | ?> |
| 32 | <hr class="owp-update-warning__separator"> |
| 33 | <div class="owp-update-warning"> |
| 34 | <div class="warning-info-icon"> |
| 35 | <span class="dashicons dashicons-info"></span> |
| 36 | </div> |
| 37 | <div> |
| 38 | <div class="warning__title"> |
| 39 | <?php echo esc_html__( 'Backup recommended before plugin update.', 'ocean-extra' ); ?> |
| 40 | </div> |
| 41 | <div class="warning__message"> |
| 42 | <?php |
| 43 | printf( |
| 44 | /* translators: %1$s Link open tag, %2$s: Link close tag. */ |
| 45 | esc_html__( 'The latest update introduces significant improvements and changes to various plugin features. For a smooth update process, it\'s crucial to %1$s backup your website beforehand %2$s and test the update in a staging or test environment if available.', 'ocean-extra' ), |
| 46 | '<a href="https://docs.oceanwp.org/article/875-how-to-safely-update-wordpress-website" target="_blank">', |
| 47 | '</a>' |
| 48 | ); |
| 49 | ?> |
| 50 | </div> |
| 51 | </div> |
| 52 | </div> |
| 53 | |
| 54 | <hr class="owp-update-warning__separator"> |
| 55 | <div class="owp-update-warning"> |
| 56 | <div class="warning-info-icon green"> |
| 57 | <span class="dashicons dashicons-yes-alt"></span> |
| 58 | </div> |
| 59 | <div> |
| 60 | <div class="warning__title"> |
| 61 | <?php echo esc_html__( 'What\'s new?', 'ocean-extra' ); ?> |
| 62 | </div> |
| 63 | <div class="warning__message"> |
| 64 | <?php |
| 65 | printf( |
| 66 | /* translators: %1$s Link open tag, %2$s: Link close tag. */ |
| 67 | esc_html__( 'Revamped Customizer for enhanced experience! This update delivers a completely redesigned Customizer with a focus on improved user interface (UI), user experience (UX), and performance. Enjoy a faster and more intuitive way to personalize your website with a wider range of options at your fingertips. Learn %1$s how to properly update your websites and transition to OceanWP 4 %4$s, view %2$s OceanWP 4 New Customizer details %4$s or check out the %3$s OceanWP 4 Customizer documentation %4$s.', 'ocean-extra' ), |
| 68 | '<a href="https://oceanwp.org/blog/oceanwp-4-release-announcement/" target="_blank">', |
| 69 | '<a href="https://oceanwp.org/blog/customize-wordpress-new-core-update/" target="_blank">', |
| 70 | '<a href="https://docs.oceanwp.org/category/894-oceanwp-customizer" target="_blank">', |
| 71 | '</a>' |
| 72 | ); |
| 73 | ?> |
| 74 | </div> |
| 75 | <div class="owp-required-products"> |
| 76 | <table class="owp-required-version-table"> |
| 77 | <tbody> |
| 78 | <tr> |
| 79 | <th><?php echo esc_html__( 'Items', 'ocean-extra' ); ?></th> |
| 80 | <th><?php echo esc_html__( 'Required Version', 'ocean-extra' ); ?></th> |
| 81 | </tr> |
| 82 | <tr> |
| 83 | <td><?php echo esc_html__( 'OceanWP', 'ocean-extra' ); ?></td> |
| 84 | <td><?php echo esc_html__( '4.0.0', 'ocean-extra' ); ?></td> |
| 85 | </tr> |
| 86 | </tbody> |
| 87 | </table> |
| 88 | </div> |
| 89 | </div> |
| 90 | </div> |
| 91 | <?php |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Tested up to. |
| 96 | */ |
| 97 | public function plugin_tested_up_to_content() { |
| 98 | |
| 99 | $current_theme_version = oe_get_theme_version(); |
| 100 | $requires_at_least = $this->oe_get_plugin_header_data( 'ocean-extra/ocean-extra.php', 'RequiresOWP' ); |
| 101 | |
| 102 | ?> |
| 103 | |
| 104 | <hr class="owp-update-warning__separator"> |
| 105 | <div class="owp-update-warning"> |
| 106 | <div class="warning-info-icon"> |
| 107 | <span class="dashicons dashicons-info"></span> |
| 108 | </div> |
| 109 | <div> |
| 110 | <div class="warning__title"> |
| 111 | <?php echo esc_html__( 'Compatibility Alert.', 'ocean-extra' ); ?> |
| 112 | </div> |
| 113 | <div class="warning__message"> |
| 114 | <?php |
| 115 | printf( |
| 116 | esc_html__( |
| 117 | 'This plugin update requires compatibility with specific OceanWP theme versions. Please ensure your theme meets the following requirements before proceeding:', |
| 118 | 'ocean-extra' |
| 119 | ), |
| 120 | |
| 121 | ); |
| 122 | ?> |
| 123 | </div> |
| 124 | <div class="owp-required-products"> |
| 125 | <table class="owp-required-version-table"> |
| 126 | <tbody> |
| 127 | <tr> |
| 128 | <th><?php echo esc_html__( 'Items', 'ocean-extra' ); ?></th> |
| 129 | <th><?php echo esc_html__( 'Requires at Least', 'ocean-extra' ); ?></th> |
| 130 | </tr> |
| 131 | <tr> |
| 132 | <td><?php echo esc_html__( 'OceanWP', 'ocean-extra' ); ?></td> |
| 133 | <td><?php echo esc_attr( $requires_at_least ); ?></td> |
| 134 | </tr> |
| 135 | |
| 136 | </tbody> |
| 137 | </table> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | |
| 142 | <?php |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Enqueue scripts |
| 147 | * |
| 148 | * @since 2.2.9 |
| 149 | */ |
| 150 | public function plugin_update_message( $plugin_data, $new_data ) { |
| 151 | |
| 152 | $current_theme_version = oe_get_theme_version(); |
| 153 | |
| 154 | if ( ! empty( $current_theme_version ) && version_compare( $current_theme_version, '3.6.1', '<=' ) ) { |
| 155 | if ( isset( $plugin_data['update'] ) && $plugin_data['update'] ) { |
| 156 | $this->plugin_update_content(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | $requires_at_least = $this->oe_get_plugin_header_data( 'ocean-extra/ocean-extra.php', 'RequiresOWP' ); |
| 161 | if ( ! empty( $current_theme_version ) && version_compare( $current_theme_version, $requires_at_least, '<=' ) ) { |
| 162 | if ( isset( $plugin_data['update'] ) && $plugin_data['update'] ) { |
| 163 | $this->plugin_tested_up_to_content(); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| 169 | public function oe_get_plugin_header_data( $plugin_slug, $key_name ) { |
| 170 | |
| 171 | $plugin_file = WP_PLUGIN_DIR . '/' . $plugin_slug; |
| 172 | |
| 173 | $headers = array( |
| 174 | 'RequiresOWP' => 'OceanWP requires at least', |
| 175 | ); |
| 176 | |
| 177 | $plugin_data = get_file_data( $plugin_file, $headers ); |
| 178 | |
| 179 | $get_data = isset( $plugin_data[$key_name] ) ? $plugin_data[$key_name] : false; |
| 180 | |
| 181 | return $get_data; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Script |
| 186 | */ |
| 187 | public function plugin_update_asset() { |
| 188 | $screen = get_current_screen(); |
| 189 | |
| 190 | if ( 'plugins' === $screen->id || 'plugins-network' === $screen->id ) { |
| 191 | wp_enqueue_style( |
| 192 | 'oe-plugin-update', |
| 193 | plugins_url( '/assets/css/pluginUpdateMessage.min.css', __DIR__ ), |
| 194 | array(), |
| 195 | false |
| 196 | ); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | } |
| 201 | |
| 202 | endif; |
| 203 | |
| 204 | new OE_Plugin_Update_Message(); |
| 205 |