PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 1.7.0
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v1.7.0
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / freemius / start.php
embedpress / freemius Last commit date
assets 9 years ago includes 9 years ago languages 9 years ago templates 9 years ago LICENSE.txt 9 years ago README.md 9 years ago config.php 9 years ago index.php 9 years ago package.json 9 years ago require.php 9 years ago start.php 9 years ago
start.php
308 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
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 = '1.2.1.6.1';
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 $this_sdk_relative_path = plugin_basename( dirname( __FILE__ ) );
35
36 if ( ! isset( $fs_active_plugins ) ) {
37 // Require SDK essentials.
38 require_once dirname( __FILE__ ) . '/includes/fs-essential-functions.php';
39
40 // Load all Freemius powered active plugins.
41 $fs_active_plugins = get_option( 'fs_active_plugins', new stdClass() );
42
43 if ( ! isset( $fs_active_plugins->plugins ) ) {
44 $fs_active_plugins->plugins = array();
45 }
46 }
47
48 if ( ! function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
49 require_once dirname( __FILE__ ) . '/includes/supplements/fs-essential-functions-1.1.7.1.php';
50 }
51
52 // Update current SDK info based on the SDK path.
53 if ( ! isset( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) ||
54 $this_sdk_version != $fs_active_plugins->plugins[ $this_sdk_relative_path ]->version
55 ) {
56 $fs_active_plugins->plugins[ $this_sdk_relative_path ] = (object) array(
57 'version' => $this_sdk_version,
58 'timestamp' => time(),
59 'plugin_path' => plugin_basename( fs_find_direct_caller_plugin_file( __FILE__ ) ),
60 );
61 }
62
63 $is_current_sdk_newest = isset( $fs_active_plugins->newest ) && ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path );
64
65 if ( ! isset( $fs_active_plugins->newest ) ) {
66 /**
67 * This will be executed only once, for the first time a Freemius powered plugin is activated.
68 */
69 fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
70
71 $is_current_sdk_newest = true;
72 } else if ( version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '<' ) ) {
73 /**
74 * Current SDK is newer than the newest stored SDK.
75 */
76 fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
77
78 if ( class_exists( 'Freemius' ) ) {
79 // Older SDK version was already loaded.
80
81 if ( ! $fs_active_plugins->newest->in_activation ) {
82 // Re-order plugins to load this plugin first.
83 fs_newest_sdk_plugin_first();
84 }
85
86 // Refresh page.
87 fs_redirect( $_SERVER['REQUEST_URI'] );
88 }
89 } else {
90 if ( ! function_exists( 'get_plugins' ) ) {
91 require_once ABSPATH . 'wp-admin/includes/plugin.php';
92 }
93
94 $is_newest_sdk_plugin_activate = is_plugin_active( $fs_active_plugins->newest->plugin_path );
95
96 if ( $is_current_sdk_newest &&
97 ! $is_newest_sdk_plugin_activate &&
98 ! $fs_active_plugins->newest->in_activation
99 ) {
100 // If current SDK is the newest and the plugin is NOT active, it means
101 // that the current plugin in activation mode.
102 $fs_active_plugins->newest->in_activation = true;
103 update_option( 'fs_active_plugins', $fs_active_plugins );
104 }
105
106 $is_newest_sdk_path_valid = ( $is_newest_sdk_plugin_activate || $fs_active_plugins->newest->in_activation ) && file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this_sdk_relative_path . '/start.php' ) );
107
108 if ( ! $is_newest_sdk_path_valid && ! $is_current_sdk_newest ) {
109 // Plugin with newest SDK is no longer active, or SDK was moved to a different location.
110 unset( $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ] );
111 }
112
113 if ( ! ( $is_newest_sdk_plugin_activate || $fs_active_plugins->newest->in_activation ) ||
114 ! $is_newest_sdk_path_valid ||
115 // Is newest SDK downgraded.
116 ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
117 version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '>' ) )
118 ) {
119 /**
120 * Plugin with newest SDK is no longer active.
121 * OR
122 * The newest SDK was in the current plugin. BUT, seems like the version of
123 * the SDK was downgraded to a lower SDK.
124 */
125 // Find the active plugin with the newest SDK version and update the newest reference.
126 fs_fallback_to_newest_active_sdk();
127 } else {
128 if ( $is_newest_sdk_plugin_activate &&
129 $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
130 ( $fs_active_plugins->newest->in_activation ||
131 ( class_exists( 'Freemius' ) && ( ! defined( 'WP_FS__SDK_VERSION' ) || version_compare( WP_FS__SDK_VERSION, $this_sdk_version, '<' ) ) )
132 )
133
134 ) {
135 if ( $fs_active_plugins->newest->in_activation ) {
136 // Plugin no more in activation.
137 $fs_active_plugins->newest->in_activation = false;
138 update_option( 'fs_active_plugins', $fs_active_plugins );
139 }
140
141 // Reorder plugins to load plugin with newest SDK first.
142 if ( fs_newest_sdk_plugin_first() ) {
143 // Refresh page after re-order to make sure activated plugin loads newest SDK.
144 if ( class_exists( 'Freemius' ) ) {
145 fs_redirect( $_SERVER['REQUEST_URI'] );
146 }
147 }
148 }
149 }
150 }
151
152 if ( class_exists( 'Freemius' ) ) {
153 // SDK was already loaded.
154 return;
155 }
156
157 if ( version_compare( $this_sdk_version, $fs_active_plugins->newest->version, '<' ) ) {
158 $newest_sdk_starter = fs_normalize_path( WP_PLUGIN_DIR . '/' . $fs_active_plugins->newest->sdk_path . '/start.php' );
159
160 if ( file_exists( $newest_sdk_starter ) ) {
161 // Reorder plugins to load plugin with newest SDK first.
162 fs_newest_sdk_plugin_first();
163
164 // There's a newer SDK version, load it instead of the current one!
165 require_once $newest_sdk_starter;
166
167 return;
168 }
169 }
170
171 #endregion SDK Selection Logic --------------------------------------------------------------------
172
173 #region Hooks & Filters Collection --------------------------------------------------------------------
174
175 /**
176 * Freemius hooks (actions & filters) tags structure:
177 *
178 * fs_{filter/action_name}_{plugin_slug}
179 *
180 * --------------------------------------------------------
181 *
182 * Usage with WordPress' add_action() / add_filter():
183 *
184 * add_action('fs_{filter/action_name}_{plugin_slug}', $callable);
185 *
186 * --------------------------------------------------------
187 *
188 * Usage with Freemius' instance add_action() / add_filter():
189 *
190 * // No need to add 'fs_' prefix nor '_{plugin_slug}' suffix.
191 * my_freemius()->add_action('{action_name}', $callable);
192 *
193 * --------------------------------------------------------
194 *
195 * Freemius filters collection:
196 *
197 * fs_connect_url_{plugin_slug}
198 * fs_trial_promotion_message_{plugin_slug}
199 * fs_is_long_term_user_{plugin_slug}
200 * fs_uninstall_reasons_{plugin_slug}
201 * fs_is_plugin_update_{plugin_slug}
202 * fs_api_domains_{plugin_slug}
203 * fs_email_template_sections_{plugin_slug}
204 * fs_support_forum_submenu_{plugin_slug}
205 * fs_support_forum_url_{plugin_slug}
206 * fs_connect_message_{plugin_slug}
207 * fs_connect_message_on_update_{plugin_slug}
208 * fs_uninstall_confirmation_message_{plugin_slug}
209 * fs_pending_activation_message_{plugin_slug}
210 * fs_is_submenu_visible_{plugin_slug}
211 * fs_plugin_icon_{plugin_slug}
212 * fs_show_trial_{plugin_slug}
213 *
214 * --------------------------------------------------------
215 *
216 * Freemius actions collection:
217 *
218 * fs_after_license_loaded_{plugin_slug}
219 * fs_after_license_change_{plugin_slug}
220 * fs_after_plans_sync_{plugin_slug}
221 *
222 * fs_after_account_details_{plugin_slug}
223 * fs_after_account_user_sync_{plugin_slug}
224 * fs_after_account_plan_sync_{plugin_slug}
225 * fs_before_account_load_{plugin_slug}
226 * fs_after_account_connection_{plugin_slug}
227 * fs_account_property_edit_{plugin_slug}
228 * fs_account_email_verified_{plugin_slug}
229 * fs_account_page_load_before_departure_{plugin_slug}
230 * fs_before_account_delete_{plugin_slug}
231 * fs_after_account_delete_{plugin_slug}
232 *
233 * fs_sdk_version_update_{plugin_slug}
234 * fs_plugin_version_update_{plugin_slug}
235 *
236 * fs_initiated_{plugin_slug}
237 * fs_after_init_plugin_registered_{plugin_slug}
238 * fs_after_init_plugin_anonymous_{plugin_slug}
239 * fs_after_init_plugin_pending_activations_{plugin_slug}
240 * fs_after_init_addon_registered_{plugin_slug}
241 * fs_after_init_addon_anonymous_{plugin_slug}
242 * fs_after_init_addon_pending_activations_{plugin_slug}
243 *
244 * fs_after_premium_version_activation_{plugin_slug}
245 * fs_after_free_version_reactivation_{plugin_slug}
246 *
247 * fs_after_uninstall_{plugin_slug}
248 * fs_before_admin_menu_init_{plugin_slug}
249 */
250
251 #endregion Hooks & Filters Collection --------------------------------------------------------------------
252
253 if ( ! class_exists( 'Freemius' ) ) {
254
255 if ( ! defined( 'WP_FS__SDK_VERSION' ) ) {
256 define( 'WP_FS__SDK_VERSION', $this_sdk_version );
257 }
258
259 // Load SDK files.
260 require_once dirname( __FILE__ ) . '/require.php';
261
262 /**
263 * Quick shortcut to get Freemius for specified plugin.
264 * Used by various templates.
265 *
266 * @param string $slug
267 *
268 * @return Freemius
269 */
270 function freemius( $slug ) {
271 return Freemius::instance( $slug );
272 }
273
274 /**
275 * @param string $slug
276 * @param number $plugin_id
277 * @param string $public_key
278 * @param bool $is_live Is live or test plugin.
279 * @param bool $is_premium Hints freemius if running the premium plugin or not.
280 *
281 * @return Freemius
282 *
283 * @deprecated Please use fs_dynamic_init().
284 */
285 function fs_init( $slug, $plugin_id, $public_key, $is_live = true, $is_premium = true ) {
286 $fs = Freemius::instance( $slug, true );
287 $fs->init( $plugin_id, $public_key, $is_live, $is_premium );
288
289 return $fs;
290 }
291
292 /**
293 * @param array<string,string> $module Plugin or Theme details.
294 *
295 * @return Freemius
296 * @throws Freemius_Exception
297 */
298 function fs_dynamic_init( $module ) {
299 $fs = Freemius::instance( $module['slug'], true );
300 $fs->dynamic_init( $module );
301
302 return $fs;
303 }
304
305 function fs_dump_log() {
306 FS_Logger::dump();
307 }
308 }