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