PluginProbe ʕ •ᴥ•ʔ
Auto Post Cleaner / 3.9.7
Auto Post Cleaner v3.9.7
3.12.0 3.13.1 3.2.4 3.2.5 3.3.0 3.3.10 3.3.11 3.3.8 3.4.2 3.5.3 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.7.5 3.7.6 3.8.0 3.9.0 3.9.4 3.9.6 3.9.7 trunk 3.0.0 3.1.0 3.10.1 3.10.2 3.11.4
delete-old-posts-programmatically / freemius / start.php
delete-old-posts-programmatically / freemius Last commit date
assets 1 year ago includes 1 year ago languages 1 year ago templates 1 year ago LICENSE.txt 5 years ago README.md 1 year ago config.php 3 years ago index.php 5 years ago require.php 1 year ago start.php 1 year ago
start.php
625 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.0.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Freemius SDK Version.
15 *
16 * @var string
17 */
18 $this_sdk_version = '2.11.0';
19
20 #region SDK Selection Logic --------------------------------------------------------------------
21
22 /**
23 * Special logic added on 1.1.6 to make sure that every Freemius powered plugin
24 * will ALWAYS be loaded with the newest SDK from the active Freemius powered plugins.
25 *
26 * Since Freemius SDK is backward compatible, this will make sure that all Freemius powered
27 * plugins will run correctly.
28 *
29 * @since 1.1.6
30 */
31
32 global $fs_active_plugins;
33
34 if ( ! function_exists( 'fs_find_caller_plugin_file' ) ) {
35 // Require SDK essentials.
36 require_once dirname( __FILE__ ) . '/includes/fs-essential-functions.php';
37 }
38
39 /**
40 * We updated the logic to support SDK loading from a subfolder of a theme as well as from a parent theme
41 * If the SDK is found in the active theme, it sets the relative path accordingly.
42 * If not, it checks the parent theme and sets the relative path if found there.
43 * This allows the SDK to be loaded from composer dependencies or from a custom `vendor/freemius` folder.
44 *
45 * @author Daniele Alessandra (@DanieleAlessandra)
46 * @since 2.9.0.5
47 *
48 *
49 * This complex logic fixes symlink issues (e.g. with Vargant). The logic assumes
50 * that if it's a file from an SDK running in a theme, the location of the SDK
51 * is in the main theme's folder.
52 *
53 * @author Vova Feldman (@svovaf)
54 * @since 1.2.2.6
55 */
56 $file_path = fs_normalize_path( __FILE__ );
57 $fs_root_path = dirname( $file_path );
58
59 // @todo: Remove this code after a few months when WP 6.3 usage is low enough.
60 global $wp_version;
61
62 if (
63 ! function_exists( 'wp_get_current_user' ) &&
64 /**
65 * `get_stylesheet()` will rely on `wp_get_current_user()` when it is being filtered by `theme-previews.php`. That happens only when the site editor is loaded or when the site editor is sending REST requests.
66 * @see theme-previews.php:wp_get_theme_preview_path()
67 *
68 * @todo This behavior is already fixed in the core (WP 6.3.2+), and this code can be removed after a few months when WP 6.3 usage is low enough.
69 * @since WP 6.3.0
70 */
71 version_compare( $wp_version, '6.3', '>=' ) &&
72 version_compare( $wp_version, '6.3.1', '<=' ) &&
73 (
74 'site-editor.php' === basename( $_SERVER['SCRIPT_FILENAME'] ) ||
75 (
76 function_exists( 'wp_is_json_request' ) &&
77 wp_is_json_request() &&
78 ! empty( $_GET['wp_theme_preview'] )
79 )
80 )
81 ) {
82 // Requiring this file since the call to get_stylesheet() below can trigger a call to wp_get_current_user() when previewing a theme.
83 require_once ABSPATH . 'wp-includes/pluggable.php';
84 }
85
86 /**
87 * Get the themes directory where the active theme is located (not passing the stylesheet will make WordPress
88 * assume that the themes directory is inside `wp-content`.
89 *
90 * @author Leo Fajardo (@leorw)
91 * @since 2.2.3
92 */
93 $themes_directory = get_theme_root( get_stylesheet() );
94 $themes_directory_name = basename( $themes_directory );
95
96 // This change ensures that the condition works even if the SDK is located in a subdirectory (e.g., vendor)
97 $theme_candidate_sdk_basename = str_replace( $themes_directory . '/' . get_stylesheet() . '/', '', $fs_root_path );
98
99 // Check if the current file is part of the active theme.
100 $is_current_sdk_from_active_theme = $file_path == $themes_directory . '/' . get_stylesheet() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path );
101 $is_current_sdk_from_parent_theme = false;
102
103 // Check if the current file is part of the parent theme.
104 if ( ! $is_current_sdk_from_active_theme ) {
105 $theme_candidate_sdk_basename = str_replace( $themes_directory . '/' . get_template() . '/',
106 '',
107 $fs_root_path );
108 $is_current_sdk_from_parent_theme = $file_path == $themes_directory . '/' . get_template() . '/' . $theme_candidate_sdk_basename . '/' . basename( $file_path );
109 }
110
111 $theme_name = null;
112 if ( $is_current_sdk_from_active_theme ) {
113 $theme_name = get_stylesheet();
114 $this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
115 $is_theme = true;
116 } else if ( $is_current_sdk_from_parent_theme ) {
117 $theme_name = get_template();
118 $this_sdk_relative_path = '../' . $themes_directory_name . '/' . $theme_name . '/' . $theme_candidate_sdk_basename;
119 $is_theme = true;
120 } else {
121 $this_sdk_relative_path = plugin_basename( $fs_root_path );
122 $is_theme = false;
123
124 /**
125 * If this file was included from another plugin with lower SDK version, and if this plugin is symlinked, then we need to get the actual plugin path,
126 * as the value right now will be wrong, it will only remove the directory separator from the file_path.
127 *
128 * The check of `fs_find_direct_caller_plugin_file` determines that this file was indeed included by a different plugin than the main plugin.
129 */
130 if ( DIRECTORY_SEPARATOR . $this_sdk_relative_path === $fs_root_path && function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
131 $original_plugin_dir_name = dirname( fs_find_direct_caller_plugin_file( $file_path ) );
132
133 // Remove everything before the original plugin directory name.
134 $this_sdk_relative_path = substr( $this_sdk_relative_path, strpos( $this_sdk_relative_path, $original_plugin_dir_name ) );
135
136 unset( $original_plugin_dir_name );
137 }
138 }
139
140 if ( ! isset( $fs_active_plugins ) ) {
141 // Load all Freemius powered active plugins.
142 $fs_active_plugins = get_option( 'fs_active_plugins' );
143
144 if ( ! is_object( $fs_active_plugins ) ) {
145 $fs_active_plugins = new stdClass();
146 }
147
148 if ( ! isset( $fs_active_plugins->plugins ) ) {
149 $fs_active_plugins->plugins = array();
150 }
151 }
152
153 if ( empty( $fs_active_plugins->abspath ) ) {
154 /**
155 * Store the WP install absolute path reference to identify environment change
156 * while replicating the storage.
157 *
158 * @author Vova Feldman (@svovaf)
159 * @since 1.2.1.7
160 */
161 $fs_active_plugins->abspath = ABSPATH;
162 } else {
163 if ( ABSPATH !== $fs_active_plugins->abspath ) {
164 /**
165 * WordPress path has changed, cleanup the SDK references cache.
166 * This resolves issues triggered when spinning a staging environments
167 * while replicating the database.
168 *
169 * @author Vova Feldman (@svovaf)
170 * @since 1.2.1.7
171 */
172 $fs_active_plugins->abspath = ABSPATH;
173 $fs_active_plugins->plugins = array();
174 unset( $fs_active_plugins->newest );
175 } else {
176 /**
177 * Make sure SDK references are still valid. This resolves
178 * issues when users hard delete modules via FTP.
179 *
180 * @author Vova Feldman (@svovaf)
181 * @since 1.2.1.7
182 */
183 $has_changes = false;
184 foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) {
185 if ( ! file_exists( ( isset( $data->type ) && 'theme' === $data->type ? $themes_directory : WP_PLUGIN_DIR ) . '/' . $sdk_path ) ) {
186 unset( $fs_active_plugins->plugins[ $sdk_path ] );
187
188 if (
189 ! empty( $fs_active_plugins->newest ) &&
190 $sdk_path === $fs_active_plugins->newest->sdk_path
191 ) {
192 unset( $fs_active_plugins->newest );
193 }
194
195 $has_changes = true;
196 }
197 }
198
199 if ( $has_changes ) {
200 if ( empty( $fs_active_plugins->plugins ) ) {
201 unset( $fs_active_plugins->newest );
202 }
203
204 update_option( 'fs_active_plugins', $fs_active_plugins );
205 }
206 }
207 }
208
209 if ( ! function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
210 require_once dirname( __FILE__ ) . '/includes/supplements/fs-essential-functions-1.1.7.1.php';
211 }
212
213 if ( ! function_exists( 'fs_get_plugins' ) ) {
214 require_once dirname( __FILE__ ) . '/includes/supplements/fs-essential-functions-2.2.1.php';
215 }
216
217 // Update current SDK info based on the SDK path.
218 if ( ! isset( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) ||
219 $this_sdk_version != $fs_active_plugins->plugins[ $this_sdk_relative_path ]->version
220 ) {
221 if ( $is_theme ) {
222 // Saving relative path and not only directory name as it could be a subfolder
223 $plugin_path = $theme_name;
224 } else {
225 $plugin_path = plugin_basename( fs_find_direct_caller_plugin_file( $file_path ) );
226 }
227
228 $fs_active_plugins->plugins[ $this_sdk_relative_path ] = (object) array(
229 'version' => $this_sdk_version,
230 'type' => ( $is_theme ? 'theme' : 'plugin' ),
231 'timestamp' => time(),
232 'plugin_path' => $plugin_path,
233 );
234 }
235
236 $is_current_sdk_newest = isset( $fs_active_plugins->newest ) && ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path );
237
238 if ( ! isset( $fs_active_plugins->newest ) ) {
239 /**
240 * This will be executed only once, for the first time a Freemius powered plugin is activated.
241 */
242 fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
243
244 $is_current_sdk_newest = true;
245 } else if ( version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '<' ) ) {
246 /**
247 * Current SDK is newer than the newest stored SDK.
248 */
249 fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
250
251 if ( class_exists( 'Freemius' ) ) {
252 // Older SDK version was already loaded.
253
254 if ( ! $fs_active_plugins->newest->in_activation ) {
255 // Re-order plugins to load this plugin first.
256 fs_newest_sdk_plugin_first();
257 }
258
259 // Refresh page.
260 fs_redirect( $_SERVER['REQUEST_URI'] );
261 }
262 } else {
263 if ( ! function_exists( 'get_plugins' ) ) {
264 require_once ABSPATH . 'wp-admin/includes/plugin.php';
265 }
266
267 $fs_newest_sdk = $fs_active_plugins->newest;
268 $fs_newest_sdk = $fs_active_plugins->plugins[ $fs_newest_sdk->sdk_path ];
269
270 $is_newest_sdk_type_theme = ( isset( $fs_newest_sdk->type ) && 'theme' === $fs_newest_sdk->type );
271
272 /**
273 * @var bool $is_newest_sdk_module_active
274 * True if the plugin with the newest SDK is active.
275 * True if the newest SDK is part of the current theme or current theme's parent.
276 * False otherwise.
277 */
278 if ( ! $is_newest_sdk_type_theme ) {
279 $is_newest_sdk_module_active = is_plugin_active( $fs_newest_sdk->plugin_path );
280 } else {
281 $current_theme = wp_get_theme();
282 // Detect if current theme is the one registered as newer SDK
283 $is_newest_sdk_module_active = (
284 strpos(
285 $fs_newest_sdk->plugin_path,
286 '../' . $themes_directory_name . '/' . $current_theme->get_stylesheet() . '/'
287 ) === 0
288 );
289
290 $current_theme_parent = $current_theme->parent();
291
292 /**
293 * If the current theme is a child of the theme that has the newest SDK, this prevents a redirects loop
294 * from happening by keeping the SDK info stored in the `fs_active_plugins` option.
295 */
296 if ( ! $is_newest_sdk_module_active && $current_theme_parent instanceof WP_Theme ) {
297 // Detect if current theme parent is the one registered as newer SDK
298 $is_newest_sdk_module_active = (
299 strpos(
300 $fs_newest_sdk->plugin_path,
301 '../' . $themes_directory_name . '/' . $current_theme_parent->get_stylesheet() . '/'
302 ) === 0
303 );
304 }
305 }
306
307 if ( $is_current_sdk_newest &&
308 ! $is_newest_sdk_module_active &&
309 ! $fs_active_plugins->newest->in_activation
310 ) {
311 // If current SDK is the newest and the plugin is NOT active, it means
312 // that the current plugin in activation mode.
313 $fs_active_plugins->newest->in_activation = true;
314 update_option( 'fs_active_plugins', $fs_active_plugins );
315 }
316
317 if ( ! $is_theme ) {
318 $sdk_starter_path = fs_normalize_path( WP_PLUGIN_DIR . '/' . $this_sdk_relative_path . '/start.php' );
319 } else {
320 $sdk_starter_path = fs_normalize_path(
321 $themes_directory
322 . '/'
323 . str_replace( "../{$themes_directory_name}/", '', $this_sdk_relative_path )
324 . '/start.php' );
325 }
326
327 $is_newest_sdk_path_valid = ( $is_newest_sdk_module_active || $fs_active_plugins->newest->in_activation ) && file_exists( $sdk_starter_path );
328
329 if ( ! $is_newest_sdk_path_valid && ! $is_current_sdk_newest ) {
330 // Plugin with newest SDK is no longer active, or SDK was moved to a different location.
331 unset( $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ] );
332 }
333
334 if ( ! ( $is_newest_sdk_module_active || $fs_active_plugins->newest->in_activation ) ||
335 ! $is_newest_sdk_path_valid ||
336 // Is newest SDK downgraded.
337 ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
338 version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '>' ) )
339 ) {
340 /**
341 * Plugin with newest SDK is no longer active.
342 * OR
343 * The newest SDK was in the current plugin. BUT, seems like the version of
344 * the SDK was downgraded to a lower SDK.
345 */
346 // Find the active plugin with the newest SDK version and update the newest reference.
347 fs_fallback_to_newest_active_sdk();
348 } else {
349 if ( $is_newest_sdk_module_active &&
350 $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
351 ( $fs_active_plugins->newest->in_activation ||
352 ( class_exists( 'Freemius' ) && ( ! defined( 'WP_FS__SDK_VERSION' ) || version_compare( WP_FS__SDK_VERSION, $this_sdk_version, '<' ) ) )
353 )
354
355 ) {
356 if ( $fs_active_plugins->newest->in_activation && ! $is_newest_sdk_type_theme ) {
357 // Plugin no more in activation.
358 $fs_active_plugins->newest->in_activation = false;
359 update_option( 'fs_active_plugins', $fs_active_plugins );
360 }
361
362 // Reorder plugins to load plugin with newest SDK first.
363 if ( fs_newest_sdk_plugin_first() ) {
364 // Refresh page after re-order to make sure activated plugin loads newest SDK.
365 if ( class_exists( 'Freemius' ) ) {
366 fs_redirect( $_SERVER['REQUEST_URI'] );
367 }
368 }
369 }
370 }
371 }
372
373 if ( class_exists( 'Freemius' ) ) {
374 // SDK was already loaded.
375 return;
376 }
377
378 if ( isset( $fs_active_plugins->newest ) && version_compare( $this_sdk_version, $fs_active_plugins->newest->version, '<' ) ) {
379 $newest_sdk = $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ];
380
381 $plugins_or_theme_dir_path = ( ! isset( $newest_sdk->type ) || 'theme' !== $newest_sdk->type ) ?
382 WP_PLUGIN_DIR :
383 $themes_directory;
384
385 $newest_sdk_starter = fs_normalize_path(
386 $plugins_or_theme_dir_path
387 . '/'
388 . str_replace( "../{$themes_directory_name}/", '', $fs_active_plugins->newest->sdk_path )
389 . '/start.php' );
390
391 if ( file_exists( $newest_sdk_starter ) ) {
392 // Reorder plugins to load plugin with newest SDK first.
393 fs_newest_sdk_plugin_first();
394
395 // There's a newer SDK version, load it instead of the current one!
396 require_once $newest_sdk_starter;
397
398 return;
399 }
400 }
401
402 #endregion SDK Selection Logic --------------------------------------------------------------------
403
404 #region Hooks & Filters Collection --------------------------------------------------------------------
405
406 /**
407 * Freemius hooks (actions & filters) tags structure:
408 *
409 * fs_{filter/action_name}_{plugin_slug}
410 *
411 * --------------------------------------------------------
412 *
413 * Usage with WordPress' add_action() / add_filter():
414 *
415 * add_action('fs_{filter/action_name}_{plugin_slug}', $callable);
416 *
417 * --------------------------------------------------------
418 *
419 * Usage with Freemius' instance add_action() / add_filter():
420 *
421 * // No need to add 'fs_' prefix nor '_{plugin_slug}' suffix.
422 * my_freemius()->add_action('{action_name}', $callable);
423 *
424 * --------------------------------------------------------
425 *
426 * Freemius filters collection:
427 *
428 * fs_connect_url_{plugin_slug}
429 * fs_trial_promotion_message_{plugin_slug}
430 * fs_is_long_term_user_{plugin_slug}
431 * fs_uninstall_reasons_{plugin_slug}
432 * fs_is_plugin_update_{plugin_slug}
433 * fs_api_domains_{plugin_slug}
434 * fs_email_template_sections_{plugin_slug}
435 * fs_support_forum_submenu_{plugin_slug}
436 * fs_support_forum_url_{plugin_slug}
437 * fs_connect_message_{plugin_slug}
438 * fs_connect_message_on_update_{plugin_slug}
439 * fs_uninstall_confirmation_message_{plugin_slug}
440 * fs_pending_activation_message_{plugin_slug}
441 * fs_is_submenu_visible_{plugin_slug}
442 * fs_plugin_icon_{plugin_slug}
443 * fs_show_trial_{plugin_slug}
444 *
445 * --------------------------------------------------------
446 *
447 * Freemius actions collection:
448 *
449 * fs_after_license_loaded_{plugin_slug}
450 * fs_after_license_change_{plugin_slug}
451 * fs_after_plans_sync_{plugin_slug}
452 *
453 * fs_after_account_details_{plugin_slug}
454 * fs_after_account_user_sync_{plugin_slug}
455 * fs_after_account_plan_sync_{plugin_slug}
456 * fs_before_account_load_{plugin_slug}
457 * fs_after_account_connection_{plugin_slug}
458 * fs_account_property_edit_{plugin_slug}
459 * fs_account_email_verified_{plugin_slug}
460 * fs_account_page_load_before_departure_{plugin_slug}
461 * fs_before_account_delete_{plugin_slug}
462 * fs_after_account_delete_{plugin_slug}
463 *
464 * fs_sdk_version_update_{plugin_slug}
465 * fs_plugin_version_update_{plugin_slug}
466 *
467 * fs_initiated_{plugin_slug}
468 * fs_after_init_plugin_registered_{plugin_slug}
469 * fs_after_init_plugin_anonymous_{plugin_slug}
470 * fs_after_init_plugin_pending_activations_{plugin_slug}
471 * fs_after_init_addon_registered_{plugin_slug}
472 * fs_after_init_addon_anonymous_{plugin_slug}
473 * fs_after_init_addon_pending_activations_{plugin_slug}
474 *
475 * fs_after_premium_version_activation_{plugin_slug}
476 * fs_after_free_version_reactivation_{plugin_slug}
477 *
478 * fs_after_uninstall_{plugin_slug}
479 * fs_before_admin_menu_init_{plugin_slug}
480 */
481
482 #endregion Hooks & Filters Collection --------------------------------------------------------------------
483
484 if ( ! class_exists( 'Freemius' ) ) {
485
486 if ( ! defined( 'WP_FS__SDK_VERSION' ) ) {
487 define( 'WP_FS__SDK_VERSION', $this_sdk_version );
488 }
489
490 $plugins_or_theme_dir_path = fs_normalize_path( trailingslashit( $is_theme ?
491 $themes_directory :
492 WP_PLUGIN_DIR ) );
493
494 if ( 0 === strpos( $file_path, $plugins_or_theme_dir_path ) ) {
495 // No symlinks
496 } else {
497 /**
498 * This logic finds the SDK symlink and set WP_FS__DIR to use it.
499 *
500 * @author Vova Feldman (@svovaf)
501 * @since 1.2.2.5
502 */
503 $sdk_symlink = null;
504
505 // Try to load SDK's symlink from cache.
506 if ( isset( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) &&
507 is_object( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) &&
508 ! empty( $fs_active_plugins->plugins[ $this_sdk_relative_path ]->sdk_symlink )
509 ) {
510 $sdk_symlink = $fs_active_plugins->plugins[ $this_sdk_relative_path ]->sdk_symlink;
511 if ( 0 === strpos( $sdk_symlink, $plugins_or_theme_dir_path ) ) {
512 /**
513 * Make the symlink path relative.
514 *
515 * @author Leo Fajardo (@leorw)
516 */
517 $sdk_symlink = substr( $sdk_symlink, strlen( $plugins_or_theme_dir_path ) );
518
519 $fs_active_plugins->plugins[ $this_sdk_relative_path ]->sdk_symlink = $sdk_symlink;
520 update_option( 'fs_active_plugins', $fs_active_plugins );
521 }
522
523 $realpath = realpath( $plugins_or_theme_dir_path . $sdk_symlink );
524 if ( ! is_string( $realpath ) || ! file_exists( $realpath ) ) {
525 $sdk_symlink = null;
526 }
527 }
528
529 if ( empty( $sdk_symlink ) ) // Has symlinks, therefore, we need to configure WP_FS__DIR based on the symlink.
530 {
531 $partial_path_right = basename( $file_path );
532 $partial_path_left = dirname( $file_path );
533 $realpath = realpath( $plugins_or_theme_dir_path . $partial_path_right );
534
535 while ( '/' !== $partial_path_left &&
536 ( false === $realpath || $file_path !== fs_normalize_path( $realpath ) )
537 ) {
538 $partial_path_right = trailingslashit( basename( $partial_path_left ) ) . $partial_path_right;
539 $partial_path_left_prev = $partial_path_left;
540 $partial_path_left = dirname( $partial_path_left_prev );
541
542 /**
543 * Avoid infinite loop if for example `$partial_path_left_prev` is `C:/`, in this case,
544 * `dirname( 'C:/' )` will return `C:/`.
545 *
546 * @author Leo Fajardo (@leorw)
547 */
548 if ( $partial_path_left === $partial_path_left_prev ) {
549 $partial_path_left = '';
550 break;
551 }
552
553 $realpath = realpath( $plugins_or_theme_dir_path . $partial_path_right );
554 }
555
556 if ( ! empty( $partial_path_left ) && '/' !== $partial_path_left ) {
557 $sdk_symlink = fs_normalize_path( dirname( $partial_path_right ) );
558
559 // Cache value.
560 if ( isset( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) &&
561 is_object( $fs_active_plugins->plugins[ $this_sdk_relative_path ] )
562 ) {
563 $fs_active_plugins->plugins[ $this_sdk_relative_path ]->sdk_symlink = $sdk_symlink;
564 update_option( 'fs_active_plugins', $fs_active_plugins );
565 }
566 }
567 }
568
569 if ( ! empty( $sdk_symlink ) ) {
570 // Set SDK dir to the symlink path.
571 define( 'WP_FS__DIR', $plugins_or_theme_dir_path . $sdk_symlink );
572 }
573 }
574
575 // Load SDK files.
576 require_once dirname( __FILE__ ) . '/require.php';
577
578 /**
579 * Quick shortcut to get Freemius for specified plugin.
580 * Used by various templates.
581 *
582 * @param number $module_id
583 *
584 * @return Freemius
585 */
586 function freemius( $module_id ) {
587 return Freemius::instance( $module_id );
588 }
589
590 /**
591 * @param string $slug
592 * @param number $plugin_id
593 * @param string $public_key
594 * @param bool $is_live Is live or test plugin.
595 * @param bool $is_premium Hints freemius if running the premium plugin or not.
596 *
597 * @return Freemius
598 *
599 * @deprecated Please use fs_dynamic_init().
600 */
601 function fs_init( $slug, $plugin_id, $public_key, $is_live = true, $is_premium = true ) {
602 $fs = Freemius::instance( $plugin_id, $slug, true );
603 $fs->init( $plugin_id, $public_key, $is_live, $is_premium );
604
605 return $fs;
606 }
607
608 /**
609 * @param array <string,string|bool|array> $module Plugin or Theme details.
610 *
611 * @return Freemius
612 * @throws Freemius_Exception
613 */
614 function fs_dynamic_init( $module ) {
615 $fs = Freemius::instance( $module['id'], $module['slug'], true );
616 $fs->dynamic_init( $module );
617
618 return $fs;
619 }
620
621 function fs_dump_log() {
622 FS_Logger::dump();
623 }
624 }
625