| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * Plugin Name: Woody Code Snippets |
| 4 | 4 | * Plugin URI: https://woodysnippet.com/ |
| 5 | 5 | * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service's code. Ensures no content duplication. |
| 6 | 6 | * Author: Themeisle |
| 7 | - * Version: 2.7.0 | |
| 7 | + * Version: 2.7.7 | |
| 8 | 8 | * WordPress Available: yes |
| 9 | 9 | * Requires License: no |
| 10 | 10 | * Text Domain: insert-php |
| 11 | 11 | * Domain Path: /languages/ |
| @@ -40,9 +40,9 @@ | ||
| 40 | 40 | |
| 41 | 41 | // Set the constant that the plugin is activated. |
| 42 | 42 | define( 'WINP_PLUGIN_ACTIVE', true ); |
| 43 | 43 | |
| 44 | -define( 'WINP_PLUGIN_VERSION', '2.6.1' ); | |
| 44 | +define( 'WINP_PLUGIN_VERSION', '2.7.7' ); | |
| 45 | 45 | |
| 46 | 46 | // Root directory of the plugin. |
| 47 | 47 | define( 'WINP_PLUGIN_DIR', __DIR__ ); |
| 48 | 48 | |
| @@ -87,13 +87,96 @@ | ||
| 87 | 87 | load_plugin_textdomain( 'insert-php', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 88 | 88 | } |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | +// START: Related to premium version compatibility check for below 1.3. | |
| 92 | +add_action( | |
| 93 | + 'plugins_loaded', | |
| 94 | + function () { | |
| 95 | + $premium_plugin_file = 'woody-ad-snippets-premium/woody-ad-snippets-premium.php'; | |
| 96 | + $premium_plugin_path = WP_PLUGIN_DIR . '/' . $premium_plugin_file; | |
| 97 | + | |
| 98 | + if ( ! file_exists( $premium_plugin_path ) ) { | |
| 99 | + return; | |
| 100 | + } | |
| 101 | + | |
| 102 | + if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 103 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 104 | + } | |
| 105 | + | |
| 106 | + if ( ! is_plugin_active( $premium_plugin_file ) ) { | |
| 107 | + return; | |
| 108 | + } | |
| 109 | + | |
| 110 | + if ( ! function_exists( 'get_plugin_data' ) ) { | |
| 111 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 112 | + } | |
| 113 | + $premium_data = get_plugin_data( $premium_plugin_path ); | |
| 114 | + | |
| 115 | + if ( version_compare( $premium_data['Version'], '1.3.0', '<' ) ) { | |
| 116 | + deactivate_plugins( $premium_plugin_file ); | |
| 117 | + set_transient( 'winp_premium_version_incompatible', true, WEEK_IN_SECONDS ); | |
| 118 | + } | |
| 119 | + }, | |
| 120 | + 5 | |
| 121 | +); | |
| 122 | + | |
| 123 | +add_action( | |
| 124 | + 'admin_init', | |
| 125 | + function () { | |
| 126 | + if ( isset( $_GET['winp_dismiss_premium_notice'] ) && check_admin_referer( 'winp_dismiss_premium_notice' ) ) { | |
| 127 | + delete_transient( 'winp_premium_version_incompatible' ); | |
| 128 | + wp_safe_redirect( remove_query_arg( 'winp_dismiss_premium_notice' ) ); | |
| 129 | + exit; | |
| 130 | + } | |
| 131 | + } | |
| 132 | +); | |
| 133 | + | |
| 134 | +add_action( | |
| 135 | + 'admin_notices', | |
| 136 | + function () { | |
| 137 | + if ( get_transient( 'winp_premium_version_incompatible' ) ) { | |
| 138 | + $dismiss_url = wp_nonce_url( | |
| 139 | + add_query_arg( 'winp_dismiss_premium_notice', '1' ), | |
| 140 | + 'winp_dismiss_premium_notice' | |
| 141 | + ); | |
| 142 | + ?> | |
| 143 | + <div class="notice notice-error"> | |
| 144 | + <p> | |
| 145 | + <strong><?php esc_html_e( 'Woody Code Snippets Premium has been deactivated.', 'insert-php' ); ?></strong> | |
| 146 | + </p> | |
| 147 | + <p> | |
| 148 | + <?php | |
| 149 | + printf( | |
| 150 | + // translators: %s Premium version number. | |
| 151 | + esc_html__( 'The installed premium version is not compatible with the current version of Woody Code Snippets. Please update the premium plugin to version %s or higher.', 'insert-php' ), | |
| 152 | + '<strong>1.3.0</strong>' | |
| 153 | + ); | |
| 154 | + ?> | |
| 155 | + </p> | |
| 156 | + <p> | |
| 157 | + <a href="<?php echo esc_url( $dismiss_url ); ?>" class="button button-secondary"> | |
| 158 | + <?php esc_html_e( 'Dismiss this notice', 'insert-php' ); ?> | |
| 159 | + </a> | |
| 160 | + </p> | |
| 161 | + </div> | |
| 162 | + <?php | |
| 163 | + } | |
| 164 | + } | |
| 165 | +); | |
| 166 | +// END: Related to premium version compatibility check for below 1.3. | |
| 167 | + | |
| 91 | 168 | require_once WINP_PLUGIN_DIR . '/includes/class.insertion.locations.php'; |
| 92 | 169 | require_once WINP_PLUGIN_DIR . '/includes/class.http.php'; |
| 93 | 170 | require_once WINP_PLUGIN_DIR . '/includes/class.helpers.php'; |
| 171 | +require_once WINP_PLUGIN_DIR . '/includes/class.code-validator.php'; | |
| 172 | +require_once WINP_PLUGIN_DIR . '/includes/class.error-handler.php'; | |
| 94 | 173 | require_once WINP_PLUGIN_DIR . '/includes/class.plugin.php'; |
| 95 | 174 | |
| 175 | +if ( file_exists( WINP_PLUGIN_DIR . '/vendor/autoload.php' ) ) { | |
| 176 | + require_once WINP_PLUGIN_DIR . '/vendor/autoload.php'; | |
| 177 | +} | |
| 178 | + | |
| 96 | 179 | /** |
| 97 | 180 | * Adds a hint and button to the fatal error message. |
| 98 | 181 | * |
| 99 | 182 | * Since WordPress 5.2, we have access to a special mode for catching PHP errors. |
| @@ -217,9 +300,8 @@ | ||
| 217 | 300 | global $winp_snippets_locations; |
| 218 | 301 | $winp_snippets_locations = new WINP_Insertion_Locations(); |
| 219 | 302 | |
| 220 | 303 | try { |
| 221 | - require_once WINP_PLUGIN_DIR . '/vendor/autoload.php'; | |
| 222 | 304 | new WINP_Plugin(); |
| 223 | 305 | } catch ( Exception $exception ) { |
| 224 | 306 | // Plugin wasn't initialized due to an error |
| 225 | 307 | define( 'WINP_PLUGIN_THROW_ERROR', true ); |