| @@ -1,37 +1,167 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin Name: Woody Code Snippets | |
| 3 | + * Plugin Name: Woody code snippets (PHP snippets | Insert PHP) | |
| 4 | 4 | * Plugin URI: https://woodysnippet.com/ |
| 5 | - * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service's code. Ensures no content duplication. | |
| 6 | - * Author: Themeisle | |
| 7 | - * Version: 2.7.6 | |
| 8 | - * WordPress Available: yes | |
| 9 | - * Requires License: no | |
| 5 | + * Description: Executes PHP code, uses conditional logic to insert ads, text, media content and external service’s code. Ensures no content duplication. | |
| 6 | + * Author: Creative Motion, Will Bontrager Software, LLC <will@willmaster.com> | |
| 7 | + * Version: 2.4.6 | |
| 10 | 8 | * Text Domain: insert-php |
| 11 | 9 | * Domain Path: /languages/ |
| 12 | - * Author URI: https://themeisle.com | |
| 10 | + * Author URI: https://cm-wp.com | |
| 11 | + */ | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * Developers who contributions in the development plugin: | |
| 13 | 15 | * |
| 14 | - * @package Woody_Code_Snippets | |
| 16 | + * Will Bontrager | |
| 17 | + * --------------------------------------------------------------------------------- | |
| 18 | + * 1.0.0v - 1.3.0v Developed the first plugin version, which was named Insert php. | |
| 19 | + * This was the founder of this plugin. | |
| 20 | + * | |
| 21 | + * If you are a long-term user, you may be confused about the new plugin update. | |
| 22 | + * You’ve been using an old plugin – Insert php 1.3.0, and now got an extended | |
| 23 | + * product – Woody Code Snippets. Insert php was the first plugin version to work | |
| 24 | + * with PHP code. It was created by Will Bontrager Software, LLC. In 2018, the | |
| 25 | + * Webcraftic studio started to actively develop the plugin. We’ve created a | |
| 26 | + * roadmap and released several powerful updates that help you to use PHP code | |
| 27 | + * more comfortable and secure. Now plugin supports not only PHP but other | |
| 28 | + * snippet types as well. We’ve decided to rename the plugin as Woody ad | |
| 29 | + * snippets. This name is more suitable for new and powerful plugin features. | |
| 30 | + * | |
| 31 | + * More information about the Insert PHP plugin can be found here: | |
| 32 | + * http://www.willmaster.com/software/WPplugins/go/iphphome_iphplugin | |
| 33 | + * --------------------------------------------------------------------------------- | |
| 34 | + * | |
| 35 | + * Alexander Kovalev | |
| 36 | + * --------------------------------------------------------------------------------- | |
| 37 | + * 1.3.0v - 2.0.6v. - Developed framework, plugin interface and plugin development. | |
| 38 | + * 2.0.6v. - 2.2.5v - Fix bugs, improvement some code parts for the plugin. | |
| 39 | + * | |
| 40 | + * Email: alex.kovalevv@gmail.com | |
| 41 | + * Personal card: https://alexkovalevv.github.io | |
| 42 | + * Personal repo: https://github.com/alexkovalevv | |
| 43 | + * --------------------------------------------------------------------------------- | |
| 44 | + * | |
| 45 | + * Alexander Vitkalov | |
| 46 | + * --------------------------------------------------------------------------------- | |
| 47 | + * 2.0.6v. - 2.2.5v - Development conditional logic for some snippets, added new snippets types, | |
| 48 | + * development snippets library, development import/export. | |
| 49 | + * | |
| 50 | + * Personal repo: https://github.com/nechin | |
| 51 | + * --------------------------------------------------------------------------------- | |
| 52 | + * | |
| 53 | + * Artem Prihodko | |
| 54 | + * --------------------------------------------------------------------------------- | |
| 55 | + * 2.3.2v - current | |
| 56 | + * | |
| 57 | + * Email: webtemyk@yandex.ru | |
| 58 | + * Personal repo: https://github.com/temyk | |
| 59 | + * --------------------------------------------------------------------------------- | |
| 15 | 60 | */ |
| 16 | 61 | |
| 17 | -// Exit if accessed directly. | |
| 62 | +// Exit if accessed directly | |
| 18 | 63 | if ( ! defined( 'ABSPATH' ) ) { |
| 19 | 64 | exit; |
| 20 | 65 | } |
| 66 | +// @formatter:off | |
| 21 | 67 | |
| 22 | -if ( version_compare( PHP_VERSION, '7.4', '<' ) ) { | |
| 23 | - add_action( | |
| 24 | - 'admin_notices', | |
| 25 | - function () { | |
| 26 | - ?> | |
| 27 | - <div class="notice notice-error"> | |
| 28 | - <p><?php esc_html_e( 'Woody Code Snippets requires PHP 7.4 or higher. Please upgrade your PHP version.', 'insert-php' ); ?></p> | |
| 29 | - </div> | |
| 30 | - <?php | |
| 31 | - } | |
| 32 | - ); | |
| 33 | 68 | |
| 69 | + | |
| 70 | +/** | |
| 71 | + * ----------------------------------------------------------------------------- | |
| 72 | + * CHECK REQUIREMENTS | |
| 73 | + * Check compatibility with php and wp version of the user's site. As well as checking | |
| 74 | + * compatibility with other plugins from Webcraftic. | |
| 75 | + * ----------------------------------------------------------------------------- | |
| 76 | + */ | |
| 77 | + | |
| 78 | +require_once dirname( __FILE__ ) . '/libs/factory/core/includes/class-factory-requirements.php'; | |
| 79 | + | |
| 80 | +$plugin_info = [ | |
| 81 | + 'prefix' => 'wbcr_inp_', | |
| 82 | + 'plugin_name' => 'wbcr_insert_php', | |
| 83 | + 'plugin_title' => __( 'Woody Code Snippets', 'insert-php' ), | |
| 84 | + 'plugin_text_domain' => 'insert-php', | |
| 85 | + | |
| 86 | + // PLUGIN SUPPORT | |
| 87 | + 'support_details' => [ | |
| 88 | + 'url' => 'https://r.freemius.com/3465/1916966/https://woodysnippet.com', | |
| 89 | + 'affiliate_url' => 'https://r.freemius.com/3465/1916966/', | |
| 90 | + 'pages_map' => [ | |
| 91 | + 'features' => 'premium-features', // {site}/premium-features | |
| 92 | + 'pricing' => 'pricing', // {site}/prices | |
| 93 | + 'support' => 'support', // {site}/support | |
| 94 | + 'docs' => 'getting-started-with-woody-ad-snippets', // {site}/docs | |
| 95 | + ], | |
| 96 | + ], | |
| 97 | + | |
| 98 | + // PLUGIN ADVERTS | |
| 99 | + 'render_adverts' => true, | |
| 100 | + 'adverts_settings' => [ | |
| 101 | + 'dashboard_widget' => true, // show dashboard widget (default: false) | |
| 102 | + 'right_sidebar' => true, // show adverts sidebar (default: false) | |
| 103 | + 'notice' => true, // show notice message (default: false) | |
| 104 | + ], | |
| 105 | + | |
| 106 | + // PLUGIN UPDATED SETTINGS | |
| 107 | + /* | |
| 108 | + 'has_updates' => false, | |
| 109 | + 'updates_settings' => array( | |
| 110 | + 'repository' => 'wordpress', | |
| 111 | + 'slug' => 'woody-ad-snippets', | |
| 112 | + 'maybe_rollback' => true, | |
| 113 | + 'rollback_settings' => array( | |
| 114 | + 'prev_stable_version' => '0.0.0', | |
| 115 | + ), | |
| 116 | + ),*/ | |
| 117 | + | |
| 118 | + // PLUGIN PREMIUM SETTINGS | |
| 119 | + 'has_premium' => true, | |
| 120 | + 'license_settings' => [ | |
| 121 | + 'provider' => 'freemius', | |
| 122 | + 'slug' => 'woody-ad-snippets-premium', | |
| 123 | + 'plugin_id' => '3465', | |
| 124 | + 'public_key' => 'pk_fc5703fe4f4fbc3e87f17fce5e0b8', | |
| 125 | + 'price' => 19, | |
| 126 | + 'has_updates' => true, | |
| 127 | + 'updates_settings' => [ | |
| 128 | + 'maybe_rollback' => true, | |
| 129 | + 'rollback_settings' => [ | |
| 130 | + 'prev_stable_version' => '0.0.0', | |
| 131 | + ], | |
| 132 | + ], | |
| 133 | + ], | |
| 134 | + | |
| 135 | + // FRAMEWORK MODULES | |
| 136 | + 'load_factory_modules' => [ | |
| 137 | + [ 'libs/factory/bootstrap', 'factory_bootstrap_458', 'admin' ], | |
| 138 | + [ 'libs/factory/forms', 'factory_forms_454', 'admin' ], | |
| 139 | + [ 'libs/factory/pages', 'factory_pages_456', 'admin' ], | |
| 140 | + [ 'libs/factory/types', 'factory_types_413' ], | |
| 141 | + [ 'libs/factory/taxonomies', 'factory_taxonomies_333' ], | |
| 142 | + [ 'libs/factory/metaboxes', 'factory_metaboxes_413', 'admin' ], | |
| 143 | + [ 'libs/factory/viewtables', 'factory_viewtables_413', 'admin' ], | |
| 144 | + [ 'libs/factory/shortcodes', 'factory_shortcodes_333', 'all' ], | |
| 145 | + [ 'libs/factory/freemius', 'factory_freemius_144', 'all' ], | |
| 146 | + [ 'libs/factory/adverts', 'factory_adverts_134', 'admin' ], | |
| 147 | + [ 'libs/factory/feedback', 'factory_feedback_117', 'admin' ], | |
| 148 | + ], | |
| 149 | +]; | |
| 150 | + | |
| 151 | +/** | |
| 152 | + * Checks compatibility with WordPress, php and other plugins. | |
| 153 | + */ | |
| 154 | +$wbcr_compatibility = new Wbcr_Factory457_Requirements( __FILE__, array_merge( $plugin_info, [ | |
| 155 | + 'plugin_already_activate' => defined( 'WINP_PLUGIN_ACTIVE' ), | |
| 156 | + 'required_php_version' => '7.0', | |
| 157 | + 'required_wp_version' => '4.8.0', | |
| 158 | +] ) ); | |
| 159 | + | |
| 160 | +/** | |
| 161 | + * If the plugin is compatible, it will continue its work, otherwise it will be stopped and the user will receive a warning. | |
| 162 | + */ | |
| 163 | +if ( ! $wbcr_compatibility->check() ) { | |
| 34 | 164 | return; |
| 35 | 165 | } |
| 36 | 166 | |
| 37 | 167 | global $wbcr_inp_safe_mode; |
| @@ -37,36 +167,29 @@ | ||
| 37 | 167 | global $wbcr_inp_safe_mode; |
| 38 | 168 | |
| 39 | 169 | $wbcr_inp_safe_mode = false; |
| 40 | 170 | |
| 41 | -// Set the constant that the plugin is activated. | |
| 171 | +// Set the constant that the plugin is activated | |
| 42 | 172 | define( 'WINP_PLUGIN_ACTIVE', true ); |
| 43 | 173 | |
| 44 | -define( 'WINP_PLUGIN_VERSION', '2.7.6' ); | |
| 174 | +define( 'WINP_PLUGIN_VERSION', $wbcr_compatibility->get_plugin_version() ); | |
| 45 | 175 | |
| 46 | -// Root directory of the plugin. | |
| 47 | -define( 'WINP_PLUGIN_DIR', __DIR__ ); | |
| 176 | +// Root directory of the plugin | |
| 177 | +define( 'WINP_PLUGIN_DIR', dirname( __FILE__ ) ); | |
| 48 | 178 | |
| 49 | -define( 'WINP_PLUGIN_FILE', __FILE__ ); | |
| 179 | +// Absolute url of the root directory of the plugin | |
| 180 | +define( 'WINP_PLUGIN_URL', plugins_url( null, __FILE__ ) ); | |
| 50 | 181 | |
| 51 | -// Absolute url of the root directory of the plugin. | |
| 52 | -define( 'WINP_PLUGIN_URL', plugins_url( '', __FILE__ ) ); | |
| 53 | - | |
| 54 | -// Relative url of the plugin. | |
| 182 | +// Relative url of the plugin | |
| 55 | 183 | define( 'WINP_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
| 56 | 184 | |
| 57 | -// Plugin slug. | |
| 58 | -define( 'WINP_PLUGIN_SLUG', basename( dirname( WINP_PLUGIN_FILE ) ) ); | |
| 59 | - | |
| 60 | -define( 'WINP_PLUGIN_NAMESPACE', str_replace( '-', '_', strtolower( trim( WINP_PLUGIN_SLUG ) ) ) ); | |
| 61 | - | |
| 62 | -// The type of posts used for snippets types. | |
| 185 | +// The type of posts used for snippets types | |
| 63 | 186 | define( 'WINP_SNIPPETS_POST_TYPE', 'wbcr-snippets' ); |
| 64 | 187 | |
| 65 | -// The taxonomy used for snippets types. | |
| 188 | +// The taxonomy used for snippets types | |
| 66 | 189 | define( 'WINP_SNIPPETS_TAXONOMY', 'wbcr-snippet-tags' ); |
| 67 | 190 | |
| 68 | -// The snippets types. | |
| 191 | +// The snippets types | |
| 69 | 192 | define( 'WINP_SNIPPET_TYPE_PHP', 'php' ); |
| 70 | 193 | define( 'WINP_SNIPPET_TYPE_TEXT', 'text' ); |
| 71 | 194 | define( 'WINP_SNIPPET_TYPE_UNIVERSAL', 'universal' ); |
| 72 | 195 | define( 'WINP_SNIPPET_TYPE_CSS', 'css' ); |
| @@ -73,246 +196,36 @@ | ||
| 73 | 196 | define( 'WINP_SNIPPET_TYPE_JS', 'js' ); |
| 74 | 197 | define( 'WINP_SNIPPET_TYPE_HTML', 'html' ); |
| 75 | 198 | define( 'WINP_SNIPPET_TYPE_AD', 'advert' ); |
| 76 | 199 | |
| 77 | -// We need to update these. | |
| 78 | -define( 'WINP_UPGRADE', 'https://woodysnippet.com/upgrade' ); | |
| 79 | -define( 'WINP_DOCS', 'https://docs.themeisle.com/category/2429-woody-installation-and-setup' ); | |
| 80 | -define( 'WINP_ORG_SUPPORT', 'https://wordpress.org/support/plugin/insert-php/' ); | |
| 81 | -define( 'WINP_SUPPORT', 'https://themeisle.com/contact/' ); | |
| 82 | - | |
| 83 | -// Load text domain for translations. | |
| 84 | -add_action( | |
| 85 | - 'plugins_loaded', | |
| 86 | - function () { | |
| 87 | - load_plugin_textdomain( 'insert-php', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); | |
| 88 | - } | |
| 89 | -); | |
| 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 | - | |
| 200 | +require_once WINP_PLUGIN_DIR . '/libs/factory/core/boot.php'; | |
| 201 | +require_once WINP_PLUGIN_DIR . '/includes/compat.php'; | |
| 168 | 202 | require_once WINP_PLUGIN_DIR . '/includes/class.insertion.locations.php'; |
| 169 | -require_once WINP_PLUGIN_DIR . '/includes/class.http.php'; | |
| 170 | 203 | require_once WINP_PLUGIN_DIR . '/includes/class.helpers.php'; |
| 171 | -require_once WINP_PLUGIN_DIR . '/includes/class.error-handler.php'; | |
| 172 | 204 | require_once WINP_PLUGIN_DIR . '/includes/class.plugin.php'; |
| 173 | 205 | |
| 174 | -if ( file_exists( WINP_PLUGIN_DIR . '/vendor/autoload.php' ) ) { | |
| 175 | - require_once WINP_PLUGIN_DIR . '/vendor/autoload.php'; | |
| 176 | -} | |
| 206 | +/* | |
| 207 | + * Woocommerce Insertion location | |
| 208 | + * @since 2.4 | |
| 209 | + * */ | |
| 177 | 210 | |
| 178 | -/** | |
| 179 | - * Adds a hint and button to the fatal error message. | |
| 180 | - * | |
| 181 | - * Since WordPress 5.2, we have access to a special mode for catching PHP errors. | |
| 182 | - * If a user makes a syntax error while editing a snippet, instead of a white screen | |
| 183 | - * (if PHP errors are disabled on the server), they will see a message from WordPress | |
| 184 | - * generated by the WP_Fatal_Error_Handler class. | |
| 185 | - * | |
| 186 | - * We decided to add a button to this message to switch to safe mode. | |
| 187 | - */ | |
| 188 | -add_filter( | |
| 189 | - 'wp_php_error_message', | |
| 190 | - function ( $message ) { | |
| 191 | - $safe_mode_url = admin_url( 'edit.php?post_type=' . WINP_SNIPPETS_POST_TYPE . '&wbcr-php-snippets-safe-mode' ); | |
| 192 | - $safe_mode_button = '<div style="margin:20px 0;padding:20px; background:#ffe8e8;">' . __( 'If you see this message after saving the snippet to the Woody Code Snippets plugin, please enable safe mode in the Woody plugin. Safe mode will allow you to continue working in the admin panel of your site and change the snippet in which you made a php error.', 'insert-php' ) . '</div>'; | |
| 193 | - $safe_mode_button .= '<a href="' . $safe_mode_url . '" class="button">' . __( 'Enable Safe Mode', 'insert-php' ) . '</a>'; | |
| 211 | +global $winp_snippets_locations; | |
| 212 | +$winp_snippets_locations = new WINP_Insertion_Locations(); | |
| 194 | 213 | |
| 195 | - return $message . $safe_mode_button; | |
| 196 | - } | |
| 197 | -); | |
| 214 | +try { | |
| 215 | + new WINP_Plugin( __FILE__, array_merge( $plugin_info, [ | |
| 216 | + 'plugin_version' => WINP_PLUGIN_VERSION, | |
| 217 | + 'plugin_text_domain' => $wbcr_compatibility->get_text_domain(), | |
| 218 | + ] ) ); | |
| 219 | +} catch ( Exception $exception ) { | |
| 220 | + // Plugin wasn't initialized due to an error | |
| 221 | + define( 'WINP_PLUGIN_THROW_ERROR', true ); | |
| 198 | 222 | |
| 199 | -/** | |
| 200 | - * Enables/Disable safe mode, in which the php code will not be executed. | |
| 201 | - */ | |
| 202 | -add_action( | |
| 203 | - 'plugins_loaded', | |
| 204 | - function () { | |
| 205 | - if ( isset( $_GET['wbcr-php-snippets-safe-mode'] ) ) { | |
| 206 | - WINP_Helper::enable_safe_mode(); | |
| 207 | - wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-safe-mode' ] ) ) ); | |
| 208 | - die(); | |
| 209 | - } | |
| 223 | + $wbcr_plugin_error_func = function () use ( $exception ) { | |
| 224 | + $error = sprintf( 'The %s plugin has stopped. <b>Error:</b> %s Code: %s', 'Woody Ad Snippets', $exception->getMessage(), $exception->getCode() ); | |
| 225 | + echo '<div class="notice notice-error"><p>' . $error . '</p></div>'; | |
| 226 | + }; | |
| 210 | 227 | |
| 211 | - if ( isset( $_GET['wbcr-php-snippets-disable-safe-mode'] ) ) { | |
| 212 | - WINP_Helper::disable_safe_mode(); | |
| 213 | - wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-disable-safe-mode' ] ) ) ); | |
| 214 | - die(); | |
| 215 | - } | |
| 216 | - }, | |
| 217 | - - 1 | |
| 218 | -); | |
| 219 | - | |
| 220 | -/** | |
| 221 | - * Register product to SDK | |
| 222 | - * | |
| 223 | - * @param array<string> $products Registered products. | |
| 224 | - * @return array<string> | |
| 225 | - */ | |
| 226 | -function winp_sdk_register_products( $products ) { | |
| 227 | - $products[] = WINP_PLUGIN_FILE; | |
| 228 | - | |
| 229 | - return $products; | |
| 228 | + add_action( 'admin_notices', $wbcr_plugin_error_func ); | |
| 229 | + add_action( 'network_admin_notices', $wbcr_plugin_error_func ); | |
| 230 | 230 | } |
| 231 | - | |
| 232 | -/** | |
| 233 | - * About page metadata | |
| 234 | - * | |
| 235 | - * @return array<string, mixed> | |
| 236 | - */ | |
| 237 | -function winp_sdk_about_page() { | |
| 238 | - return [ | |
| 239 | - 'location' => 'edit.php?post_type=wbcr-snippets', | |
| 240 | - 'logo' => WINP_PLUGIN_URL . '/admin/assets/img/icon-256x256.png', | |
| 241 | - 'review_link' => false, | |
| 242 | - 'has_upgrade_menu' => false, | |
| 243 | - ]; | |
| 244 | -} | |
| 245 | - | |
| 246 | -/** | |
| 247 | - * Register compatibility using SDK. | |
| 248 | - * | |
| 249 | - * @param array<string, array<string, string>> $compatibilities All compatibilities. | |
| 250 | - * | |
| 251 | - * @return array<string, array<string, string>> Registered compatibility. | |
| 252 | - */ | |
| 253 | -function winp_sdk_register_compatibility( $compatibilities ) { | |
| 254 | - $compatibilities['WoodyPro'] = [ | |
| 255 | - 'basefile' => defined( 'WASP_PLUGIN_FILE' ) ? WASP_PLUGIN_FILE : '', | |
| 256 | - 'required' => '1.3.0', | |
| 257 | - ]; | |
| 258 | - | |
| 259 | - return $compatibilities; | |
| 260 | -} | |
| 261 | - | |
| 262 | -add_filter( 'themeisle_sdk_products', 'winp_sdk_register_products' ); | |
| 263 | -add_filter( WINP_PLUGIN_NAMESPACE . '_about_us_metadata', 'winp_sdk_about_page' ); | |
| 264 | -add_filter( 'themeisle_sdk_compatibilities/' . basename( WINP_PLUGIN_DIR ), 'winp_sdk_register_compatibility' ); | |
| 265 | - | |
| 266 | -// Register activation/deactivation hooks. | |
| 267 | -register_activation_hook( | |
| 268 | - WINP_PLUGIN_FILE, | |
| 269 | - function () { | |
| 270 | - global $winp_snippets_locations; | |
| 271 | - if ( ! isset( $winp_snippets_locations ) ) { | |
| 272 | - $winp_snippets_locations = new WINP_Insertion_Locations(); | |
| 273 | - } | |
| 274 | - | |
| 275 | - // Instantiate plugin for activation. | |
| 276 | - $plugin = new WINP_Plugin(); | |
| 277 | - $plugin->activation_hook(); | |
| 278 | - } | |
| 279 | -); | |
| 280 | - | |
| 281 | -register_deactivation_hook( | |
| 282 | - WINP_PLUGIN_FILE, | |
| 283 | - function () { | |
| 284 | - global $winp_snippets_locations; | |
| 285 | - if ( ! isset( $winp_snippets_locations ) ) { | |
| 286 | - $winp_snippets_locations = new WINP_Insertion_Locations(); | |
| 287 | - } | |
| 288 | - | |
| 289 | - // Instantiate plugin for deactivation. | |
| 290 | - $plugin = new WINP_Plugin(); | |
| 291 | - $plugin->deactivation_hook(); | |
| 292 | - } | |
| 293 | -); | |
| 294 | - | |
| 295 | -// Initialize on 'init' hook with priority 0 to avoid early translation loading (WP 6.7+) | |
| 296 | -add_action( | |
| 297 | - 'init', | |
| 298 | - function () { | |
| 299 | - global $winp_snippets_locations; | |
| 300 | - $winp_snippets_locations = new WINP_Insertion_Locations(); | |
| 301 | - | |
| 302 | - try { | |
| 303 | - new WINP_Plugin(); | |
| 304 | - } catch ( Exception $exception ) { | |
| 305 | - // Plugin wasn't initialized due to an error | |
| 306 | - define( 'WINP_PLUGIN_THROW_ERROR', true ); | |
| 307 | - | |
| 308 | - $wbcr_plugin_error_func = function () use ( $exception ) { | |
| 309 | - $error = sprintf( 'The %s plugin has stopped. <b>Error:</b> %s Code: %s', 'Woody Ad Snippets', $exception->getMessage(), $exception->getCode() ); | |
| 310 | - echo '<div class="notice notice-error"><p>' . $error . '</p></div>'; | |
| 311 | - }; | |
| 312 | - | |
| 313 | - add_action( 'admin_notices', $wbcr_plugin_error_func ); | |
| 314 | - add_action( 'network_admin_notices', $wbcr_plugin_error_func ); | |
| 315 | - } | |
| 316 | - }, | |
| 317 | - 0 | |
| 318 | -); | |
| 231 | +// @formatter:on | |