PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.6.2
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.6.2
4.6.2 4.6.1 4.6.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 / EmbedPress / CoreLegacy.php
embedpress / EmbedPress Last commit date
AMP 3 years ago Analytics 2 months ago Elementor 3 weeks ago Ends 1 week ago Gutenberg 3 weeks ago Includes 3 days ago Plugins 1 year ago Providers 1 month ago ThirdParty 3 weeks ago AutoLoader.php 3 years ago Compatibility.php 3 years ago Core.php 3 days ago CoreLegacy.php 1 week ago DisablerLegacy.php 3 years ago Loader.php 3 years ago MilestoneNotification.php 3 weeks ago RestAPI.php 1 month ago Shortcode.php 3 weeks ago index.html 7 years ago simple_html_dom.php 5 years ago
CoreLegacy.php
422 lines
1 <?php
2
3 namespace EmbedPress;
4
5 use EmbedPress\Ends\Back\Handler as EndHandlerAdmin;
6 use EmbedPress\Ends\Back\Settings\EmbedpressSettings;
7 use EmbedPress\Ends\Front\Handler as EndHandlerPublic;
8 use EmbedPress\Includes\Traits\Shared;
9
10 (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
11
12 /**
13 * Entity that glues together all pieces that the plugin is made of, for WordPress before 5.0.
14 *
15 * @package EmbedPress
16 * @author EmbedPress <help@embedpress.com>
17 * @copyright Copyright (C) 2021 WPDeveloper. All rights reserved.
18 * @license GPLv3 or later
19 * @since 1.0.0
20 */
21 class CoreLegacy
22 {
23 use Shared;
24 /**
25 * The name of the plugin.
26 *
27 * @since 1.0.0
28 * @access protected
29 *
30 * @var string $pluginName The name of the plugin.
31 */
32 protected $pluginName;
33
34 /**
35 * The version of the plugin.
36 *
37 * @since 1.0.0
38 * @access protected
39 *
40 * @var string $pluginVersion The version of the plugin.
41 */
42 protected $pluginVersion;
43
44 /**
45 * An instance of the plugin loader.
46 * @since 1.0.0
47 * @access protected
48 * @var Loader $pluginVersion The version of the plugin.
49 */
50 protected $loaderInstance;
51
52 /**
53 * An associative array storing all registered/active EmbedPress plugins and their namespaces.
54 *
55 * @since 1.4.0
56 * @access private
57 * @static
58 *
59 * @var array
60 */
61 private static $plugins = [];
62
63 /**
64 * Initialize the plugin and set its properties.
65 *
66 * @since 1.0.0
67 *
68 * @return void
69 */
70 public function __construct()
71 {
72 $this->pluginName = EMBEDPRESS_PLG_NAME;
73 $this->pluginVersion = EMBEDPRESS_VERSION;
74
75 $this->loaderInstance = new Loader();
76
77 add_action( 'in_admin_header', [ $this, 'remove_admin_notice' ], 99 );
78 add_action('ep_admin_notices', [$this, 'embedpress_admin_notice']);
79 add_action('ep_admin_notices', [$this, 'admin_notice']);
80
81 }
82
83 /**
84 * Method that retrieves the plugin name.
85 *
86 * @since 1.0.0
87 *
88 * @return string
89 */
90 public function getPluginName()
91 {
92 return $this->pluginName;
93 }
94
95 /**
96 * Method that retrieves the plugin version.
97 *
98 * @since 1.0.0
99 *
100 * @return string
101 */
102 public function getPluginVersion()
103 {
104 return $this->pluginVersion;
105 }
106
107 /**
108 * Method that retrieves the loader instance.
109 *
110 * @since 1.0.0
111 *
112 * @return Loader
113 */
114 public function getLoader()
115 {
116 return $this->loaderInstance;
117 }
118
119 /**
120 * Method responsible to connect all required hooks in order to make the plugin work.
121 *
122 * @since 1.0.0
123 *
124 * @return void
125 */
126 public function initialize()
127 {
128 global $wp_actions;
129
130 $this->start_plugin_tracking();
131
132 // Google Reviews is editor-agnostic — its admin page, REST controller and
133 // review fetchers must load regardless of which editor is active. These
134 // registrations mirror EmbedPress\Core::initialize(); without them the
135 // Classic Editor code path (this class) leaves the Google Reviews admin
136 // page (admin.php?page=embedpress-google-reviews) and its REST endpoints
137 // unregistered. See FB #83635.
138 add_action('rest_api_init', ['\\EmbedPress\\Includes\\Classes\\GoogleReviewsRestController', 'register']);
139 add_action('enqueue_block_editor_assets', ['\\EmbedPress\\Includes\\Classes\\GoogleReviewsRenderer', 'enqueue_editor_assets']);
140 add_action('elementor/preview/enqueue_styles', ['\\EmbedPress\\Includes\\Classes\\GoogleReviewsRenderer', 'enqueue_editor_assets']);
141 \EmbedPress\Includes\Classes\GoogleReviewsAdminPage::register();
142 new \EmbedPress\Includes\Classes\GoogleReviewsApify();
143 new \EmbedPress\Includes\Classes\GoogleReviewsManaged();
144
145 if (is_admin()) {
146 new EmbedpressSettings();
147 $plgSettings = self::getSettings();
148
149 add_action( 'init', [ $this, 'admin_notice' ] );
150
151 add_filter('plugin_action_links_embedpress/embedpress.php',
152 ['\\EmbedPress\\CoreLegacy', 'handleActionLinks'], 10, 2);
153
154 add_action('admin_enqueue_scripts', ['\\EmbedPress\\Ends\\Back\\Handler', 'enqueueStyles']);
155 add_action('wp_ajax_embedpress_notice_dismiss', ['\\EmbedPress\\Ends\\Back\\Handler', 'embedpress_notice_dismiss']);
156 add_action('init', ['\\EmbedPress\\DisablerLegacy', 'run'], 1);
157 add_action('init', [$this, 'configureTinyMCE'], 1);
158
159 $plgHandlerAdminInstance = new EndHandlerAdmin($this->getPluginName(), $this->getPluginVersion());
160
161 if ( $plgSettings->enablePluginInAdmin ) {
162 $this->loaderInstance->add_action('admin_enqueue_scripts', $plgHandlerAdminInstance, 'enqueueScripts');
163 }
164
165 $onAjaxCallbackName = "doShortcodeReceivedViaAjax";
166 // Only logged-in users may resolve an arbitrary URL server-side via this
167 // handler. The nopriv registration is intentionally dropped: it exposed
168 // oEmbed discovery to unauthenticated callers (SSRF). The callback also
169 // enforces a capability + nonce check.
170 $this->loaderInstance->add_action('wp_ajax_embedpress_do_ajax_request', $plgHandlerAdminInstance,
171 $onAjaxCallbackName);
172
173 $this->loaderInstance->add_action('wp_ajax_embedpress_get_embed_url_info', $plgHandlerAdminInstance,
174 "getUrlInfoViaAjax");
175
176 unset($onAjaxCallbackName, $plgHandlerAdminInstance);
177 } else {
178 add_action('init', ['\\EmbedPress\\DisablerLegacy', 'run'], 1);
179
180 $plgSettings = Core::getSettings();
181
182 if (!is_admin() && $plgSettings->enablePluginInFront ) {
183 // Assets are now handled by AssetManager
184 // This section is kept for backward compatibility
185 }
186
187 }
188
189 // Add support for embeds on AMP pages
190 add_filter('pp_embed_parsed_content', ['\\EmbedPress\\AMP\\EmbedHandler', 'processParsedContent'], 10, 3);
191
192 // Add support for our embeds on Beaver Builder. Without this it only run the native embeds.
193 add_filter('fl_builder_before_render_shortcodes',
194 ['\\EmbedPress\\ThirdParty\\BeaverBuilder', 'before_render_shortcodes']);
195
196 $this->loaderInstance->run();
197 }
198
199 /**
200 * Callback called right after the plugin has been activated.
201 *
202 * @since 1.0.0
203 * @static
204 *
205 * @return void
206 */
207 public static function onPluginActivationCallback()
208 {
209 add_filter('rewrite_rules_array', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedRewriteRules']);
210 flush_rewrite_rules();
211
212 // Trigger the setup wizard redirect only on a true fresh install. See
213 // Core::onPluginActivationCallback() for how the marker is populated.
214 $install_type = get_option( 'embedpress_install_type', false );
215 if ( $install_type !== 'existing' ) {
216 $settings = get_option( EMBEDPRESS_PLG_NAME, [] );
217 $settings['need_first_time_redirect'] = true;
218 update_option( EMBEDPRESS_PLG_NAME, $settings );
219
220 // Clear any previous redirect done flag
221 delete_option( 'embedpress_activation_redirect_done' );
222 }
223 }
224
225 /**
226 * Callback called right after the plugin has been deactivated.
227 *
228 * @since 1.0.0
229 * @static
230 *
231 * @return void
232 */
233 public static function onPluginDeactivationCallback()
234 {
235 remove_filter('rewrite_rules_array', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedRewriteRules']);
236 flush_rewrite_rules();
237 }
238
239 /**
240 * Method that retrieves all additional service providers defined in the ~<plugin_root_path>/providers.php file.
241 *
242 * @since 1.0.0
243 * @static
244 *
245 * @return array
246 */
247 public static function getAdditionalServiceProviders()
248 {
249 $additionalProvidersFilePath = EMBEDPRESS_PATH_BASE . 'providers.php';
250 if (file_exists($additionalProvidersFilePath)) {
251 include $additionalProvidersFilePath;
252 if (isset($additionalServiceProviders)) {
253 return apply_filters( 'embedpress_additional_service_providers', $additionalServiceProviders);
254 }
255 }
256
257 return apply_filters( 'embedpress_additional_service_providers', []);
258 }
259
260 /**
261 * Method that checks if an embed of a given service provider can be responsive.
262 *
263 * @since 1.0.0
264 * @static
265 *
266 * @param string $serviceProviderAlias The service's slug.
267 *
268 * @return boolean
269 */
270 public static function canServiceProviderBeResponsive($serviceProviderAlias)
271 {
272 return in_array($serviceProviderAlias, [
273 "dailymotion",
274 "kickstarter",
275 "rutube",
276 "ted",
277 "vimeo",
278 "youtube",
279 "ustream",
280 "google-docs",
281 "animatron",
282 "amcharts",
283 "on-aol-com",
284 "animoto",
285 "videojug",
286 'issuu',
287 ]);
288 }
289
290 /**
291 * Method that retrieves the plugin settings defined by the user.
292 *
293 * @since 1.0.0
294 * @static
295 *
296 * @return object
297 */
298 public static function getSettings()
299 {
300 $settings = get_option(EMBEDPRESS_PLG_NAME);
301
302 if ( ! isset($settings['enablePluginInAdmin'])) {
303 $settings['enablePluginInAdmin'] = true;
304 }
305
306 if ( ! isset($settings['enablePluginInFront'])) {
307 $settings['enablePluginInFront'] = true;
308 }
309
310 return (object)$settings;
311 }
312
313
314 /**
315 * Retrieve all registered plugins.
316 *
317 * @since 1.4.0
318 * @static
319 *
320 * @return array
321 */
322 public static function getPlugins()
323 {
324 return self::$plugins;
325 }
326
327 /**
328 * Handle links displayed below the plugin name in the WordPress Installed Plugins page.
329 *
330 * @since 1.4.0
331 * @static
332 *
333 * @return array
334 */
335 public static function handleActionLinks($links, $file)
336 {
337 $settingsLink = '<a href="' . admin_url('admin.php?page=embedpress') . '" aria-label="' . __('Open settings page',
338 'embedpress') . '">' . __('Settings', 'embedpress') . '</a>';
339
340 array_unshift($links, $settingsLink);
341 if ( !apply_filters('embedpress/is_allow_rander', false) ) {
342 $links[] = '<a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank" class="embedpress-go-pro-action" style="color: green">'.__('Go Pro', 'embedpress').'</a>';
343 }
344 return $links;
345 }
346
347
348 /**
349 * Method that ensures the API's url are whitelisted to WordPress external requests.
350 *
351 * @since 1.4.0
352 * @static
353 *
354 * @param boolean $isAllowed
355 * @param string $host
356 * @param string $url
357 *
358 * @return boolean
359 */
360 public static function allowApiHost($isAllowed, $host, $url)
361 {
362 if ($host === EMBEDPRESS_LICENSES_API_HOST) {
363 $isAllowed = true;
364 }
365
366 return $isAllowed;
367 }
368
369 /**
370 * Add filters to configure the TinyMCE editor.
371 *
372 * @since 1.6.2
373 */
374 public function configureTinyMCE()
375 {
376 add_filter('teeny_mce_before_init', [$this, 'hookOnPaste']);
377 add_filter('tiny_mce_before_init', [$this, 'hookOnPaste']);
378 }
379
380 /**
381 * Hook the onPaste methof to the paste_preprocess config in the editor.
382 *
383 * @since 1.6.2
384 *
385 * @param array $mceInit
386 *
387 * @return array
388 */
389 public function hookOnPaste($mceInit)
390 {
391 $settings = self::getSettings();
392
393 if (isset($settings->enablePluginInAdmin) && $settings->enablePluginInAdmin) {
394 // error_log(print_r());
395 // We hook here because the onPaste is sometimes called after the content was already added to the editor.
396 // If you copy text from the editor and paste there, it will give no way to use a normal onPaste event hook
397 // to modify the input since it was already injected.
398 $mceInit['paste_preprocess'] = 'function (plugin, args) {
399 try {
400 if (typeof console !== "undefined" && console.log) {
401 console.log("TinyMCE paste_preprocess called, EmbedPress available:", typeof EmbedPress !== "undefined");
402 }
403 if (typeof EmbedPress !== "undefined" && typeof EmbedPress.onPaste === "function") {
404 EmbedPress.onPaste(plugin, args);
405 } else {
406 if (typeof console !== "undefined" && console.log) {
407 console.log("EmbedPress object or onPaste method not available");
408 }
409 }
410 } catch (error) {
411 if (typeof console !== "undefined" && console.error) {
412 console.error("EmbedPress paste_preprocess error:", error);
413 }
414 }
415 }';
416 }
417
418
419 return $mceInit;
420 }
421 }
422