PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 4.0.1
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v4.0.1
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 2 years ago Elementor 2 years ago Ends 2 years ago Includes 2 years ago Plugins 2 years ago Providers 2 years ago ThirdParty 2 years ago AutoLoader.php 2 years ago Compatibility.php 2 years ago Core.php 2 years ago CoreLegacy.php 4 years ago DisablerLegacy.php 2 years ago Loader.php 2 years ago RestAPI.php 2 years ago Shortcode.php 2 years ago index.html 7 years ago simple_html_dom.php 4 years ago
CoreLegacy.php
376 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 add_action('admin_notices',[$this,'embedpress_admin_notice']);
77 }
78
79 /**
80 * Method that retrieves the plugin name.
81 *
82 * @since 1.0.0
83 *
84 * @return string
85 */
86 public function getPluginName()
87 {
88 return $this->pluginName;
89 }
90
91 /**
92 * Method that retrieves the plugin version.
93 *
94 * @since 1.0.0
95 *
96 * @return string
97 */
98 public function getPluginVersion()
99 {
100 return $this->pluginVersion;
101 }
102
103 /**
104 * Method that retrieves the loader instance.
105 *
106 * @since 1.0.0
107 *
108 * @return Loader
109 */
110 public function getLoader()
111 {
112 return $this->loaderInstance;
113 }
114
115 /**
116 * Method responsible to connect all required hooks in order to make the plugin work.
117 *
118 * @since 1.0.0
119 *
120 * @return void
121 */
122 public function initialize()
123 {
124 global $wp_actions;
125
126 $this->start_plugin_tracking();
127
128 if (is_admin()) {
129 new EmbedpressSettings();
130 $plgSettings = self::getSettings();
131 $this->admin_notice();
132
133 add_filter('plugin_action_links_embedpress/embedpress.php',
134 ['\\EmbedPress\\CoreLegacy', 'handleActionLinks'], 10, 2);
135
136 add_action('admin_enqueue_scripts', ['\\EmbedPress\\Ends\\Back\\Handler', 'enqueueStyles']);
137 add_action('wp_ajax_embedpress_notice_dismiss', ['\\EmbedPress\\Ends\\Back\\Handler', 'embedpress_notice_dismiss']);
138 add_action('init', ['\\EmbedPress\\DisablerLegacy', 'run'], 1);
139 add_action('init', [$this, 'configureTinyMCE'], 1);
140
141 $plgHandlerAdminInstance = new EndHandlerAdmin($this->getPluginName(), $this->getPluginVersion());
142
143 if ( $plgSettings->enablePluginInAdmin ) {
144 $this->loaderInstance->add_action('admin_enqueue_scripts', $plgHandlerAdminInstance, 'enqueueScripts');
145 }
146
147 $onAjaxCallbackName = "doShortcodeReceivedViaAjax";
148 $this->loaderInstance->add_action('wp_ajax_embedpress_do_ajax_request', $plgHandlerAdminInstance,
149 $onAjaxCallbackName);
150 $this->loaderInstance->add_action('wp_ajax_nopriv_embedpress_do_ajax_request', $plgHandlerAdminInstance,
151 $onAjaxCallbackName);
152
153 $this->loaderInstance->add_action('wp_ajax_embedpress_get_embed_url_info', $plgHandlerAdminInstance,
154 "getUrlInfoViaAjax");
155
156 unset($onAjaxCallbackName, $plgHandlerAdminInstance);
157 } else {
158 add_action('init', ['\\EmbedPress\\DisablerLegacy', 'run'], 1);
159
160 $plgSettings = Core::getSettings();
161
162 if (!is_admin() && $plgSettings->enablePluginInFront ) {
163 $plgHandlerPublicInstance = new EndHandlerPublic($this->getPluginName(), $this->getPluginVersion());
164
165 $this->loaderInstance->add_action('wp_enqueue_scripts', $plgHandlerPublicInstance, 'enqueueScripts');
166 $this->loaderInstance->add_action('wp_enqueue_scripts', $plgHandlerPublicInstance, 'enqueueStyles');
167
168 unset($plgHandlerPublicInstance);
169 }
170
171 }
172
173 // Add support for embeds on AMP pages
174 add_filter('pp_embed_parsed_content', ['\\EmbedPress\\AMP\\EmbedHandler', 'processParsedContent'], 10, 3);
175
176 // Add support for our embeds on Beaver Builder. Without this it only run the native embeds.
177 add_filter('fl_builder_before_render_shortcodes',
178 ['\\EmbedPress\\ThirdParty\\BeaverBuilder', 'before_render_shortcodes']);
179
180 $this->loaderInstance->run();
181 }
182
183 /**
184 * Callback called right after the plugin has been activated.
185 *
186 * @since 1.0.0
187 * @static
188 *
189 * @return void
190 */
191 public static function onPluginActivationCallback()
192 {
193 add_filter('rewrite_rules_array', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedRewriteRules']);
194 flush_rewrite_rules();
195 }
196
197 /**
198 * Callback called right after the plugin has been deactivated.
199 *
200 * @since 1.0.0
201 * @static
202 *
203 * @return void
204 */
205 public static function onPluginDeactivationCallback()
206 {
207 remove_filter('rewrite_rules_array', ['\\EmbedPress\\DisablerLegacy', 'disableDefaultEmbedRewriteRules']);
208 flush_rewrite_rules();
209 }
210
211 /**
212 * Method that retrieves all additional service providers defined in the ~<plugin_root_path>/providers.php file.
213 *
214 * @since 1.0.0
215 * @static
216 *
217 * @return array
218 */
219 public static function getAdditionalServiceProviders()
220 {
221 $additionalProvidersFilePath = EMBEDPRESS_PATH_BASE . 'providers.php';
222 if (file_exists($additionalProvidersFilePath)) {
223 include $additionalProvidersFilePath;
224 if (isset($additionalServiceProviders)) {
225 return apply_filters( 'embedpress_additional_service_providers', $additionalServiceProviders);
226 }
227 }
228
229 return apply_filters( 'embedpress_additional_service_providers', []);
230 }
231
232 /**
233 * Method that checks if an embed of a given service provider can be responsive.
234 *
235 * @since 1.0.0
236 * @static
237 *
238 * @param string $serviceProviderAlias The service's slug.
239 *
240 * @return boolean
241 */
242 public static function canServiceProviderBeResponsive($serviceProviderAlias)
243 {
244 return in_array($serviceProviderAlias, [
245 "dailymotion",
246 "kickstarter",
247 "rutube",
248 "ted",
249 "vimeo",
250 "youtube",
251 "ustream",
252 "google-docs",
253 "animatron",
254 "amcharts",
255 "on-aol-com",
256 "animoto",
257 "videojug",
258 'issuu',
259 ]);
260 }
261
262 /**
263 * Method that retrieves the plugin settings defined by the user.
264 *
265 * @since 1.0.0
266 * @static
267 *
268 * @return object
269 */
270 public static function getSettings()
271 {
272 $settings = get_option(EMBEDPRESS_PLG_NAME);
273
274 if ( ! isset($settings['enablePluginInAdmin'])) {
275 $settings['enablePluginInAdmin'] = true;
276 }
277
278 if ( ! isset($settings['enablePluginInFront'])) {
279 $settings['enablePluginInFront'] = true;
280 }
281
282 return (object)$settings;
283 }
284
285
286 /**
287 * Retrieve all registered plugins.
288 *
289 * @since 1.4.0
290 * @static
291 *
292 * @return array
293 */
294 public static function getPlugins()
295 {
296 return self::$plugins;
297 }
298
299 /**
300 * Handle links displayed below the plugin name in the WordPress Installed Plugins page.
301 *
302 * @since 1.4.0
303 * @static
304 *
305 * @return array
306 */
307 public static function handleActionLinks($links, $file)
308 {
309 $settingsLink = '<a href="' . admin_url('admin.php?page=embedpress') . '" aria-label="' . __('Open settings page',
310 'embedpress') . '">' . __('Settings', 'embedpress') . '</a>';
311
312 array_unshift($links, $settingsLink);
313 if ( !is_embedpress_pro_active() ) {
314 $links[] = '<a href="https://wpdeveloper.com/in/upgrade-embedpress" target="_blank" class="embedpress-go-pro-action" style="color: green">'.__('Go Pro', 'embedpress').'</a>';
315 }
316 return $links;
317 }
318
319
320 /**
321 * Method that ensures the API's url are whitelisted to WordPress external requests.
322 *
323 * @since 1.4.0
324 * @static
325 *
326 * @param boolean $isAllowed
327 * @param string $host
328 * @param string $url
329 *
330 * @return boolean
331 */
332 public static function allowApiHost($isAllowed, $host, $url)
333 {
334 if ($host === EMBEDPRESS_LICENSES_API_HOST) {
335 $isAllowed = true;
336 }
337
338 return $isAllowed;
339 }
340
341 /**
342 * Add filters to configure the TinyMCE editor.
343 *
344 * @since 1.6.2
345 */
346 public function configureTinyMCE()
347 {
348 add_filter('teeny_mce_before_init', [$this, 'hookOnPaste']);
349 add_filter('tiny_mce_before_init', [$this, 'hookOnPaste']);
350 }
351
352 /**
353 * Hook the onPaste methof to the paste_preprocess config in the editor.
354 *
355 * @since 1.6.2
356 *
357 * @param array $mceInit
358 *
359 * @return array
360 */
361 public function hookOnPaste($mceInit)
362 {
363 $settings = self::getSettings();
364
365 if (isset($settings->enablePluginInAdmin) && $settings->enablePluginInAdmin) {
366 // We hook here because the onPaste is sometimes called after the content was already added to the editor.
367 // If you copy text from the editor and paste there, it will give no way to use a normal onPaste event hook
368 // to modify the input since it was already injected.
369 $mceInit['paste_preprocess'] = 'function (plugin, args) { if (typeof EmbedPress !== "undefined") {EmbedPress.onPaste(plugin, args); } }';
370 }
371
372
373 return $mceInit;
374 }
375 }
376