| @@ -1,9 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * PHP snippets plugin base |
| 4 | 4 | * |
| 5 | - * @package Woody_Code_Snippets | |
| 5 | + * @author Webcraftic <WordPress.webraftic@gmail.com> | |
| 6 | + * @copyright (c) 19.02.2018, Webcraftic | |
| 7 | + * @version 1.0 | |
| 6 | 8 | */ |
| 7 | 9 | |
| 8 | 10 | // Exit if accessed directly |
| 9 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -11,77 +13,42 @@ | ||
| 11 | 13 | } |
| 12 | 14 | |
| 13 | 15 | if ( ! class_exists( 'WINP_Plugin' ) ) { |
| 14 | 16 | |
| 15 | - class WINP_Plugin { | |
| 17 | + class WINP_Plugin extends Wbcr_Factory463_Plugin { | |
| 16 | 18 | |
| 17 | 19 | /** |
| 18 | - * Custom license provider (overrides parent's premium property) | |
| 19 | - * | |
| 20 | - * @var WINP_License | |
| 20 | + * @var Wbcr_Factory463_Plugin | |
| 21 | 21 | */ |
| 22 | - public $premium; | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * @var WINP_Plugin | |
| 26 | - */ | |
| 27 | 22 | private static $app; |
| 28 | 23 | |
| 29 | 24 | /** |
| 30 | - * Snippets custom post type instance. | |
| 25 | + * @param string $plugin_path | |
| 26 | + * @param array $data | |
| 31 | 27 | * |
| 32 | - * @var WINP_SnippetsType | |
| 28 | + * @throws Exception | |
| 33 | 29 | */ |
| 34 | - private $snippets_type; | |
| 30 | + public function __construct( $plugin_path, $data ) { | |
| 31 | + parent::__construct( $plugin_path, $data ); | |
| 35 | 32 | |
| 36 | - /** | |
| 37 | - * @throws Exception | |
| 38 | - */ | |
| 39 | - public function __construct() { | |
| 40 | 33 | self::$app = $this; |
| 41 | 34 | |
| 42 | - // Initialize custom license provider. | |
| 43 | - require_once WINP_PLUGIN_DIR . '/includes/class.license.php'; | |
| 44 | - $this->premium = new WINP_License(); | |
| 45 | - | |
| 46 | - require_once WINP_PLUGIN_DIR . '/includes/class.rest.php'; | |
| 47 | - new WINP_Rest(); | |
| 48 | - | |
| 49 | - require_once WINP_PLUGIN_DIR . '/admin/pages/class.settings.php'; | |
| 50 | - require_once WINP_PLUGIN_DIR . '/admin/pages/class.new-item.php'; | |
| 51 | - require_once WINP_PLUGIN_DIR . '/admin/pages/class.snippet-library.php'; | |
| 52 | - | |
| 53 | - WINP_Settings::get_instance(); | |
| 54 | - WINP_NewItem::get_instance(); | |
| 55 | - WINP_SnippetLibrary::get_instance(); | |
| 56 | - | |
| 57 | 35 | $this->load_global(); |
| 58 | 36 | |
| 59 | - if ( is_admin() || WINP_Helper::doing_rest_api() ) { | |
| 37 | + if ( is_admin() ) { | |
| 38 | + $this->initActivation(); | |
| 60 | 39 | |
| 61 | 40 | if ( WINP_Helper::doing_ajax() ) { |
| 62 | 41 | require WINP_PLUGIN_DIR . '/admin/ajax/ajax.php'; |
| 42 | + require WINP_PLUGIN_DIR . '/admin/ajax/check-license.php'; | |
| 63 | 43 | require WINP_PLUGIN_DIR . '/admin/ajax/snippet-library.php'; |
| 64 | 44 | } |
| 65 | 45 | |
| 66 | 46 | $this->load_backend(); |
| 67 | 47 | } |
| 68 | - add_action( | |
| 69 | - 'init', | |
| 70 | - function () { | |
| 71 | - if ( WINP_Plugin::app()->premium->is_active() ) { | |
| 72 | - update_option( WINP_PLUGIN_NAMESPACE . '_logger_flag', 'yes' ); | |
| 73 | - } | |
| 74 | - } | |
| 75 | - ); | |
| 76 | - | |
| 77 | - add_filter( WINP_PLUGIN_NAMESPACE . '_logger_data', [ $this, 'get_logger_data' ] ); | |
| 78 | - add_filter( 'themeisle_sdk_blackfriday_data', [ $this, 'add_black_friday_data' ] ); | |
| 79 | 48 | } |
| 80 | 49 | |
| 81 | 50 | /** |
| 82 | - * Get plugin instance | |
| 83 | - * | |
| 84 | 51 | * @return WINP_Plugin |
| 85 | 52 | */ |
| 86 | 53 | public static function app() { |
| 87 | 54 | return self::$app; |
| @@ -87,40 +54,11 @@ | ||
| 87 | 54 | return self::$app; |
| 88 | 55 | } |
| 89 | 56 | |
| 90 | 57 | /** |
| 91 | - * Survey data. | |
| 92 | - * | |
| 93 | - * @return array<string, mixed> | |
| 94 | - */ | |
| 95 | - public function get_survey_data() { | |
| 96 | - $install_time = get_option( WINP_PLUGIN_NAMESPACE . '_install', time() ); | |
| 97 | - $days_since_install = round( ( time() - $install_time ) / DAY_IN_SECONDS ); | |
| 98 | - $total_snippets = wp_count_posts( WINP_SNIPPETS_POST_TYPE ); | |
| 99 | - $total_snippets = isset( $total_snippets->publish ) ? $total_snippets->publish : 0; | |
| 100 | - | |
| 101 | - $data = [ | |
| 102 | - 'environmentId' => 'cmiooosih4vm0ad01eihjub64', | |
| 103 | - 'attributes' => [ | |
| 104 | - 'free_version' => WINP_PLUGIN_VERSION, | |
| 105 | - 'pro_version' => defined( 'WASP_PLUGIN_VERSION' ) ? WASP_PLUGIN_VERSION : '', | |
| 106 | - 'install_days_number' => $days_since_install, | |
| 107 | - 'license_status' => self::app()->premium->is_active(), | |
| 108 | - 'total_snippets' => $total_snippets, | |
| 109 | - ], | |
| 110 | - ]; | |
| 111 | - | |
| 112 | - if ( self::app()->premium->is_active() ) { | |
| 113 | - $data['attributes']['license_key'] = apply_filters( 'themeisle_sdk_secret_masking', self::app()->premium->get_key() ); | |
| 114 | - } | |
| 115 | - | |
| 116 | - return $data; | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | 58 | * @return bool |
| 121 | 59 | */ |
| 122 | - public function current_user_car() { | |
| 60 | + public function currentUserCan() { | |
| 123 | 61 | return current_user_can( 'manage_options' ); |
| 124 | 62 | } |
| 125 | 63 | |
| 126 | 64 | /** |
| @@ -127,12 +65,12 @@ | ||
| 127 | 65 | * Get Execute_Snippet object |
| 128 | 66 | * |
| 129 | 67 | * @return WINP_Execute_Snippet |
| 130 | 68 | */ |
| 131 | - public function get_execute_object() { | |
| 69 | + public function getExecuteObject() { | |
| 132 | 70 | require_once WINP_PLUGIN_DIR . '/includes/class.execute.snippet.php'; |
| 133 | 71 | |
| 134 | - return WINP_Execute_Snippet::app(); | |
| 72 | + return new WINP_Execute_Snippet(); | |
| 135 | 73 | } |
| 136 | 74 | |
| 137 | 75 | /** |
| 138 | 76 | * Get WINP_Api object |
| @@ -139,9 +77,8 @@ | ||
| 139 | 77 | * |
| 140 | 78 | * @return WINP_Api |
| 141 | 79 | */ |
| 142 | 80 | public function get_api_object() { |
| 143 | - require_once WINP_PLUGIN_DIR . '/admin/includes/class.request.php'; | |
| 144 | 81 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.api.php'; |
| 145 | 82 | |
| 146 | 83 | return new WINP_Api(); |
| 147 | 84 | } |
| @@ -157,58 +94,75 @@ | ||
| 157 | 94 | return new WINP_Common_Snippet(); |
| 158 | 95 | } |
| 159 | 96 | |
| 160 | 97 | /** |
| 161 | - * Plugin activation hook. | |
| 162 | - * Creates demo snippets on first activation and sets up capabilities. | |
| 163 | - * | |
| 164 | - * @return void | |
| 98 | + * @throws \Exception | |
| 99 | + * @since 2.2.0 | |
| 100 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 165 | 101 | */ |
| 166 | - public function activation_hook() { | |
| 167 | - // Add custom capabilities to administrator role. | |
| 168 | - $this->snippets_type->add_capabilities(); | |
| 102 | + /* | |
| 103 | + public function plugins_loaded() { | |
| 104 | + $this->register_pages(); | |
| 105 | + }*/ | |
| 169 | 106 | |
| 170 | - // Create demo snippets with examples of use. | |
| 171 | - if ( ! get_option( 'wbcr_inp_demo_snippets_created' ) ) { | |
| 172 | - WINP_Helper::create_demo_snippets(); | |
| 173 | - } | |
| 107 | + protected function initActivation() { | |
| 108 | + include_once WINP_PLUGIN_DIR . '/admin/activation.php'; | |
| 109 | + $this->registerActivation( 'WINP_Activation' ); | |
| 110 | + } | |
| 174 | 111 | |
| 175 | - WINP_Helper::flush_page_cache(); | |
| 112 | + /** | |
| 113 | + * @throws \Exception | |
| 114 | + * @since 2.2.0 | |
| 115 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 116 | + */ | |
| 117 | + public function register_pages() { | |
| 118 | + require_once WINP_PLUGIN_DIR . '/admin/pages/page.php'; | |
| 119 | + | |
| 120 | + $this->registerPage( 'WINP_NewItemPage', WINP_PLUGIN_DIR . '/admin/pages/new-item.php' ); | |
| 121 | + $this->registerPage( 'WINP_SettingsPage', WINP_PLUGIN_DIR . '/admin/pages/settings.php' ); | |
| 122 | + $this->registerPage( 'WINP_SnippetLibraryPage', WINP_PLUGIN_DIR . '/admin/pages/snippet-library.php' ); | |
| 123 | + $this->registerPage( 'WINP_License_Page', WINP_PLUGIN_DIR . '/admin/pages/license.php' ); | |
| 124 | + $this->registerPage( 'WINP_AboutPage', WINP_PLUGIN_DIR . '/admin/pages/about.php' ); | |
| 176 | 125 | } |
| 177 | 126 | |
| 178 | 127 | /** |
| 179 | - * Plugin deactivation hook. | |
| 180 | - * Removes custom capabilities. | |
| 181 | - * | |
| 182 | - * @return void | |
| 128 | + * @throws \Exception | |
| 129 | + * @since 2.2.0 | |
| 130 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 183 | 131 | */ |
| 184 | - public function deactivation_hook() { | |
| 185 | - // Remove custom capabilities from administrator role. | |
| 186 | - $this->snippets_type->remove_capabilities(); | |
| 132 | + public function register_depence_pages() { | |
| 133 | + require_once WINP_PLUGIN_DIR . '/admin/pages/page.php'; | |
| 134 | + | |
| 135 | + if ( ! ( defined( 'WASP_PLUGIN_ACTIVE' ) && WASP_PLUGIN_ACTIVE ) ) { | |
| 136 | + $this->registerPage( 'WINP_ImportPage', WINP_PLUGIN_DIR . '/admin/pages/import.php' ); | |
| 137 | + } | |
| 187 | 138 | } |
| 188 | 139 | |
| 189 | 140 | /** |
| 190 | - * Register custom post types and taxonomies. | |
| 191 | - * | |
| 192 | - * @throws \Exception Exception. | |
| 141 | + * @throws \Exception | |
| 193 | 142 | * @since 2.2.0 |
| 143 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 194 | 144 | */ |
| 195 | 145 | private function register_types() { |
| 196 | 146 | require_once WINP_PLUGIN_DIR . '/admin/types/snippets-post-types.php'; |
| 197 | - $this->snippets_type = new WINP_SnippetsType(); | |
| 147 | + Wbcr_FactoryTypes413::register( 'WINP_SnippetsType', $this ); | |
| 198 | 148 | |
| 199 | 149 | require_once WINP_PLUGIN_DIR . '/admin/types/snippets-taxonomy.php'; |
| 200 | - new WINP_SnippetsTaxonomy(); | |
| 150 | + Wbcr_FactoryTaxonomies333::register( 'WINP_SnippetsTaxonomy', $this ); | |
| 201 | 151 | } |
| 202 | 152 | |
| 203 | 153 | /** |
| 204 | - * Register shortcodes. | |
| 205 | - * | |
| 154 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 206 | 155 | * @since 2.2.0 |
| 207 | 156 | */ |
| 208 | 157 | private function register_shortcodes() { |
| 209 | - $action = WINP_HTTP::get( 'action', '' ); | |
| 158 | + $action = self::app()->request->get( 'action', '' ); | |
| 210 | 159 | if ( ! ( 'edit' == $action && is_admin() ) ) { |
| 160 | + if ( self::app()->getOption( 'support_old_shortcodes' ) ) { | |
| 161 | + // todo: Deprecated | |
| 162 | + require_once WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-insert-php.php'; | |
| 163 | + } | |
| 164 | + | |
| 211 | 165 | require_once WINP_PLUGIN_DIR . '/includes/shortcodes/shortcodes.php'; |
| 212 | 166 | require_once WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-php.php'; |
| 213 | 167 | require_once WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-text.php'; |
| 214 | 168 | require_once WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-universal.php'; |
| @@ -229,19 +183,35 @@ | ||
| 229 | 183 | |
| 230 | 184 | /** |
| 231 | 185 | * Initialization and require files for backend and frontend. |
| 232 | 186 | * |
| 187 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 233 | 188 | * @since 2.2.0 |
| 234 | 189 | */ |
| 235 | 190 | private function load_global() { |
| 236 | 191 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.gutenberg.snippet.php'; |
| 237 | - require_once WINP_PLUGIN_DIR . '/includes/class.admin-bar.php'; | |
| 238 | 192 | |
| 239 | 193 | new WINP_Gutenberg_Snippet(); |
| 240 | - WINP_Admin_Bar::instance(); | |
| 241 | 194 | |
| 242 | - $this->get_execute_object()->register_hooks(); | |
| 195 | + $this->getExecuteObject()->registerHooks(); | |
| 243 | 196 | $this->register_shortcodes(); |
| 197 | + | |
| 198 | + /** | |
| 199 | + * Enables/Disable safe mode, in which the php code will not be executed. | |
| 200 | + */ | |
| 201 | + add_action( 'plugins_loaded', function () { | |
| 202 | + if ( isset( $_GET['wbcr-php-snippets-safe-mode'] ) ) { | |
| 203 | + WINP_Helper::enable_safe_mode(); | |
| 204 | + wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-safe-mode' ] ) ) ); | |
| 205 | + die(); | |
| 206 | + } | |
| 207 | + | |
| 208 | + if ( isset( $_GET['wbcr-php-snippets-disable-safe-mode'] ) ) { | |
| 209 | + WINP_Helper::disable_safe_mode(); | |
| 210 | + wp_safe_redirect( esc_url( remove_query_arg( [ 'wbcr-php-snippets-disable-safe-mode' ] ) ) ); | |
| 211 | + die(); | |
| 212 | + } | |
| 213 | + }, - 1 ); | |
| 244 | 214 | } |
| 245 | 215 | |
| 246 | 216 | /** |
| 247 | 217 | * Initialization and require files for backend. |
| @@ -247,40 +217,46 @@ | ||
| 247 | 217 | * Initialization and require files for backend. |
| 248 | 218 | * |
| 249 | 219 | * @throws \Exception |
| 250 | 220 | * @since 2.2.0 |
| 221 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 251 | 222 | */ |
| 252 | 223 | private function load_backend() { |
| 253 | 224 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.snippets.viewtable.php'; |
| 254 | 225 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.filter.snippet.php'; |
| 255 | 226 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.actions.snippet.php'; |
| 227 | + require_once WINP_PLUGIN_DIR . '/admin/includes/class.import.snippet.php'; | |
| 256 | 228 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.notices.php'; |
| 257 | - require_once WINP_PLUGIN_DIR . '/admin/includes/class.admin.notices.php'; | |
| 258 | 229 | require_once WINP_PLUGIN_DIR . '/admin/includes/class.request.php'; |
| 230 | + require_once WINP_PLUGIN_DIR . '/admin/metaboxes/metabox.php'; | |
| 259 | 231 | require_once WINP_PLUGIN_DIR . '/admin/boot.php'; |
| 260 | 232 | |
| 261 | - $this->get_common_object()->register_hooks(); | |
| 233 | + $this->get_common_object()->registerHooks(); | |
| 234 | + | |
| 262 | 235 | $this->register_types(); |
| 263 | 236 | |
| 264 | 237 | new WINP_Filter_List(); |
| 265 | - new WINP_Actions_Snippet(); | |
| 266 | - WINP_Notices::instance(); | |
| 267 | - new WINP_Admin_Notices(); | |
| 238 | + new WINP_Export_Snippet(); | |
| 239 | + new WINP_Import_Snippet(); | |
| 240 | + new WINP_WarningNotices(); | |
| 268 | 241 | |
| 269 | - if ( ! defined( 'E2E_TESTING' ) ) { | |
| 270 | - add_filter( | |
| 271 | - 'themeisle-sdk/survey/' . WINP_PLUGIN_SLUG, | |
| 272 | - function ( $data, $page_slug ) { | |
| 273 | - if ( empty( $page_slug ) ) { | |
| 274 | - return $data; | |
| 275 | - } | |
| 242 | + # Required for i18n to be loaded properly | |
| 243 | + add_action( 'plugins_loaded', [ $this, 'register_pages' ] ); | |
| 276 | 244 | |
| 277 | - return $this->get_survey_data(); | |
| 278 | - }, | |
| 279 | - 10, | |
| 280 | - 2 | |
| 281 | - ); | |
| 282 | - } | |
| 245 | + # Required for compatibility with the premium plugin. | |
| 246 | + # We set the priority to 30 to wait for the premium plugin to load. | |
| 247 | + add_action( 'plugins_loaded', [ $this, 'register_depence_pages' ], 30 ); | |
| 248 | + | |
| 249 | + add_action( 'wbcr_factory_forms_460_register_controls', function () { | |
| 250 | + $colorControls = [ | |
| 251 | + [ | |
| 252 | + 'type' => 'winp-dropdown', | |
| 253 | + 'class' => 'WINP_FactoryForms_Dropdown', | |
| 254 | + 'include' => WINP_PLUGIN_DIR . '/includes/controls/class.dropdown.php', | |
| 255 | + ], | |
| 256 | + ]; | |
| 257 | + $this->forms->registerControls( $colorControls ); | |
| 258 | + } ); | |
| 283 | 259 | } |
| 284 | 260 | |
| 285 | 261 | /** |
| 286 | 262 | * Метод проверяет активацию премиум плагина и наличие действующего лицензионного ключа |
| @@ -287,122 +263,14 @@ | ||
| 287 | 263 | * |
| 288 | 264 | * @return bool |
| 289 | 265 | */ |
| 290 | 266 | public function is_premium() { |
| 291 | - return $this->premium->is_active(); | |
| 292 | - } | |
| 293 | - | |
| 294 | - /** | |
| 295 | - * Logger data. | |
| 296 | - * | |
| 297 | - * @return array<string, mixed> | |
| 298 | - */ | |
| 299 | - public function get_logger_data() { | |
| 300 | - $settings = WINP_Settings::get_instance()->get_settings(); | |
| 301 | - | |
| 302 | - // Each settings has a lot of keys, we only want name and value items. So map them. | |
| 303 | - $settings = array_map( | |
| 304 | - function ( $setting ) { | |
| 305 | - return [ | |
| 306 | - 'name' => isset( $setting['name'] ) ? $setting['name'] : '', | |
| 307 | - 'value' => isset( $setting['value'] ) ? $setting['value'] : '', | |
| 308 | - ]; | |
| 309 | - }, | |
| 310 | - $settings | |
| 311 | - ); | |
| 312 | - | |
| 313 | - $total_snippets = wp_count_posts( WINP_SNIPPETS_POST_TYPE ); | |
| 314 | - $total_snippets = isset( $total_snippets->publish ) ? $total_snippets->publish : 0; | |
| 315 | - | |
| 316 | - // Count snippets by type. | |
| 317 | - $snippet_types = [ 'php', 'css', 'js', 'text', 'html', 'advert', 'universal' ]; | |
| 318 | - $types_count = []; | |
| 319 | - | |
| 320 | - foreach ( $snippet_types as $type ) { | |
| 321 | - $count = get_posts( | |
| 322 | - [ | |
| 323 | - 'post_type' => WINP_SNIPPETS_POST_TYPE, | |
| 324 | - 'post_status' => 'publish', | |
| 325 | - 'meta_key' => 'wbcr_inp_snippet_type', | |
| 326 | - 'meta_value' => $type, | |
| 327 | - 'posts_per_page' => -1, | |
| 328 | - 'fields' => 'ids', | |
| 329 | - ] | |
| 330 | - ); | |
| 331 | - | |
| 332 | - if ( ! empty( $count ) ) { | |
| 333 | - $types_count[ $type ] = count( $count ); | |
| 334 | - } | |
| 267 | + if ( $this->premium->is_active() && $this->premium->is_activate() //&& $this->premium->is_install_package() | |
| 268 | + ) { | |
| 269 | + return true; | |
| 270 | + } else { | |
| 271 | + return false; | |
| 335 | 272 | } |
| 336 | - | |
| 337 | - return [ | |
| 338 | - 'settings' => $settings, | |
| 339 | - 'stats' => [ | |
| 340 | - 'total_snippets' => $total_snippets, | |
| 341 | - 'types' => $types_count, | |
| 342 | - ], | |
| 343 | - ]; | |
| 344 | 273 | } |
| 345 | 274 | |
| 346 | - /** | |
| 347 | - * Set the black friday data. | |
| 348 | - * | |
| 349 | - * @param array<string, mixed> $configs The configuration array for the loaded products. | |
| 350 | - * | |
| 351 | - * @return array<string, mixed> The configurations. | |
| 352 | - */ | |
| 353 | - public function add_black_friday_data( $configs ) { | |
| 354 | - $config = $configs['default']; | |
| 355 | - | |
| 356 | - $message = __( 'Conditional logic, revision history, import/export. Manage your custom code properly. Exclusively for existing Woody users.', 'insert-php' ); | |
| 357 | - $cta_label = __( 'Get Woody Pro', 'insert-php' ); | |
| 358 | - | |
| 359 | - $plan = apply_filters( 'product_woody_license_plan', 0 ); | |
| 360 | - $status = apply_filters( 'product_woody_license_status', 'invalid' ); | |
| 361 | - $license = apply_filters( 'product_woody_license_key', false ); | |
| 362 | - $pro_product_slug = defined( 'WASP_PLUGIN_FILE' ) ? basename( dirname( WASP_PLUGIN_FILE ) ) : ''; | |
| 363 | - | |
| 364 | - $is_pro = 'valid' === $status; | |
| 365 | - $is_expired = 'expired' === $status || 'active-expired' === $status; | |
| 366 | - | |
| 367 | - if ( $is_pro ) { | |
| 368 | - // translators: %s is the discount percentage. | |
| 369 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - up to %s off', 'insert-php' ), '30%' ); | |
| 370 | - // translators: %1$s - discount, %2$s - discount. | |
| 371 | - $message = sprintf( __( 'Upgrade your Woody Pro plan: %1$s off this week. Already on the plan you need? Renew early and save up to %2$s.', 'insert-php' ), '30%', '20%' ); | |
| 372 | - $cta_label = __( 'See your options', 'insert-php' ); | |
| 373 | - } elseif ( $is_expired ) { | |
| 374 | - // translators: %s is the discount percentage. | |
| 375 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '50%' ); | |
| 376 | - $message = __( 'Your Woody Pro features are still here, just locked. Renew at a reduced rate this week.', 'insert-php' ); | |
| 377 | - $cta_label = __( 'Reactivate now', 'insert-php' ); | |
| 378 | - } else { | |
| 379 | - // translators: %s - discount. | |
| 380 | - $config['title'] = sprintf( __( 'Woody Pro: %s off this week', 'insert-php' ), '60%' ); | |
| 381 | - // translators: %s is the discount percentage. | |
| 382 | - $config['plugin_meta_message'] = sprintf( __( 'Black Friday Sale - %s off', 'insert-php' ), '60%' ); | |
| 383 | - } | |
| 384 | - | |
| 385 | - $url_params = [ | |
| 386 | - 'utm_term' => $is_pro ? 'plan-' . $plan : 'free', | |
| 387 | - 'lkey' => ! empty( $license ) ? $license : false, | |
| 388 | - 'expired' => $is_expired ? '1' : false, | |
| 389 | - ]; | |
| 390 | - | |
| 391 | - if ( ( $is_pro || $is_expired ) && ! empty( $pro_product_slug ) ) { | |
| 392 | - $config['plugin_meta_targets'] = [ $pro_product_slug ]; | |
| 393 | - } | |
| 394 | - | |
| 395 | - $config['cta_label'] = $cta_label; | |
| 396 | - $config['message'] = $message; | |
| 397 | - | |
| 398 | - $config['sale_url'] = add_query_arg( | |
| 399 | - $url_params, | |
| 400 | - tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/woody-bf', 'bfcm', 'woody' ) ) | |
| 401 | - ); | |
| 402 | - | |
| 403 | - $configs[ WINP_PLUGIN_SLUG ] = $config; | |
| 404 | - | |
| 405 | - return $configs; | |
| 406 | - } | |
| 407 | 275 | } |
| 408 | 276 | } |