EmbedPress – Embed Google Docs, YouTube, Maps, Vimeo, Wistia Videos & Upload PDF, PPT in Gutenberg & Elementor - Version 1.4.0

Version Description

Release Date: 2017-01-06

  • Added support to WordPress 4.7;
  • Added support to Embedpress own plugins;
  • Fixed bug that was preventing interaction with some embeds;
  • Code enhancements.
Download this release

Release Info

Developer pressshack
Plugin Icon wp plugin EmbedPress – Embed Google Docs, YouTube, Maps, Vimeo, Wistia Videos & Upload PDF, PPT in Gutenberg & Elementor
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.1 to 1.4.0

EmbedPress/AutoLoader.php CHANGED
File without changes
EmbedPress/{Plugin.php → Core.php} RENAMED
@@ -1,6 +1,7 @@
1
  <?php
2
  namespace EmbedPress;
3
 
 
4
  use \EmbedPress\Loader;
5
  use \EmbedPress\Ends\Back\Handler as EndHandlerAdmin;
6
  use \EmbedPress\Ends\Front\Handler as EndHandlerPublic;
@@ -16,7 +17,7 @@ use \EmbedPress\Ends\Front\Handler as EndHandlerPublic;
16
  * @license GPLv2 or later
17
  * @since 1.0.0
18
  */
19
- class Plugin
20
  {
21
  /**
22
  * The name of the plugin.
@@ -48,6 +49,17 @@ class Plugin
48
  */
49
  protected $loaderInstance;
50
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * Initialize the plugin and set its properties.
53
  *
@@ -118,6 +130,8 @@ class Plugin
118
  add_action('admin_init', array($settingsClassNamespace, 'registerActions'));
119
  unset($settingsClassNamespace);
120
 
 
 
121
  // Load CSS
122
  wp_register_style( 'embedpress-admin', plugins_url( 'embedpress/assets/css/admin.css' ) );
123
  wp_enqueue_style( 'embedpress-admin' );
@@ -210,6 +224,7 @@ class Plugin
210
  * @since 1.0.0
211
  * @static
212
  *
 
213
  * @return boolean
214
  */
215
  public static function canServiceProviderBeResponsive($serviceProviderAlias)
@@ -227,7 +242,7 @@ class Plugin
227
  */
228
  public static function getSettings()
229
  {
230
- $settings = get_option("embedpress_options");
231
 
232
  if (!isset($settings['displayPreviewBox'])) {
233
  $settings['displayPreviewBox'] = true;
@@ -239,4 +254,96 @@ class Plugin
239
 
240
  return (object)$settings;
241
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
1
  <?php
2
  namespace EmbedPress;
3
 
4
+ use \EmbedPress\AutoLoader;
5
  use \EmbedPress\Loader;
6
  use \EmbedPress\Ends\Back\Handler as EndHandlerAdmin;
7
  use \EmbedPress\Ends\Front\Handler as EndHandlerPublic;
17
  * @license GPLv2 or later
18
  * @since 1.0.0
19
  */
20
+ class Core
21
  {
22
  /**
23
  * The name 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 = array();
62
+
63
  /**
64
  * Initialize the plugin and set its properties.
65
  *
130
  add_action('admin_init', array($settingsClassNamespace, 'registerActions'));
131
  unset($settingsClassNamespace);
132
 
133
+ add_filter('plugin_action_links_embedpress/embedpress.php', array('\EmbedPress\Core', 'handleActionLinks'), 10, 2);
134
+
135
  // Load CSS
136
  wp_register_style( 'embedpress-admin', plugins_url( 'embedpress/assets/css/admin.css' ) );
137
  wp_enqueue_style( 'embedpress-admin' );
224
  * @since 1.0.0
225
  * @static
226
  *
227
+ * @param string $serviceProviderAlias The service's slug.
228
  * @return boolean
229
  */
230
  public static function canServiceProviderBeResponsive($serviceProviderAlias)
242
  */
243
  public static function getSettings()
244
  {
245
+ $settings = get_option(EMBEDPRESS_PLG_NAME);
246
 
247
  if (!isset($settings['displayPreviewBox'])) {
248
  $settings['displayPreviewBox'] = true;
254
 
255
  return (object)$settings;
256
  }
257
+
258
+ /**
259
+ * Method that register an EmbedPress plugin.
260
+ *
261
+ * @since 1.4.0
262
+ * @static
263
+ *
264
+ * @param array $pluginMeta Associative array containing plugin's name, slug and namespace
265
+ * @return void
266
+ */
267
+ public static function registerPlugin($pluginMeta)
268
+ {
269
+ $pluginMeta = json_decode(json_encode($pluginMeta));
270
+
271
+ if (empty($pluginMeta->name) || empty($pluginMeta->slug) || empty($pluginMeta->namespace)) {
272
+ return;
273
+ }
274
+
275
+ if (!isset(self::$plugins[$pluginMeta->slug])) {
276
+ AutoLoader::register($pluginMeta->namespace, WP_PLUGIN_DIR .'/'. EMBEDPRESS_PLG_NAME .'-'. $pluginMeta->slug .'/'. $pluginMeta->name);
277
+
278
+ $plugin = "{$pluginMeta->namespace}\Plugin";
279
+ if (!empty(@$plugin::SLUG)) {
280
+ self::$plugins[$pluginMeta->slug] = $pluginMeta->namespace;
281
+
282
+ $bsFilePath = $plugin::PATH . EMBEDPRESS_PLG_NAME .'-'. $plugin::SLUG .'.php';
283
+
284
+ register_activation_hook($bsFilePath, array($plugin::NAMESPACE_STRING, 'onActivationCallback'));
285
+ register_deactivation_hook($bsFilePath, array($plugin::NAMESPACE_STRING, 'onDeactivationCallback'));
286
+
287
+ add_action('admin_init', array($plugin, 'onLoadAdminCallback'));
288
+
289
+ add_action(EMBEDPRESS_PLG_NAME .':'. $plugin::SLUG .':settings:register', array($plugin, 'registerSettings'));
290
+ add_action(EMBEDPRESS_PLG_NAME .':settings:render:tab', array($plugin, 'renderTab'));
291
+
292
+ add_filter('plugin_action_links_embedpress-'. $plugin::SLUG .'/embedpress-'. $plugin::SLUG .'.php', array($plugin, 'handleActionLinks'), 10, 2);
293
+
294
+ $plugin::registerEvents();
295
+ }
296
+ }
297
+ }
298
+
299
+ /**
300
+ * Retrieve all registered plugins.
301
+ *
302
+ * @since 1.4.0
303
+ * @static
304
+ *
305
+ * @return array
306
+ */
307
+ public static function getPlugins()
308
+ {
309
+ return self::$plugins;
310
+ }
311
+
312
+ /**
313
+ * Handle links displayed below the plugin name in the WordPress Installed Plugins page.
314
+ *
315
+ * @since 1.4.0
316
+ * @static
317
+ *
318
+ * @return array
319
+ */
320
+ public static function handleActionLinks($links, $file)
321
+ {
322
+ $settingsLink = '<a href="'. admin_url('admin.php?page=embedpress') .'" aria-label="'. __('Open settings page', 'embedpress') .'">'. __('Settings', 'embedpress') .'</a>';
323
+
324
+ array_unshift($links, $settingsLink);
325
+
326
+ return $links;
327
+ }
328
+
329
+ /**
330
+ * Method that ensures the API's url are whitelisted to WordPress external requests.
331
+ *
332
+ * @since 1.4.0
333
+ * @static
334
+ *
335
+ * @param boolean $isAllowed
336
+ * @param string $host
337
+ * @param string $url
338
+ *
339
+ * @return boolean
340
+ */
341
+ public static function allowApiHost($isAllowed, $host, $url)
342
+ {
343
+ if ($host === EMBEDPRESS_LICENSES_API_HOST) {
344
+ $isAllowed = true;
345
+ }
346
+
347
+ return $isAllowed;
348
+ }
349
  }
EmbedPress/Disabler.php CHANGED
@@ -23,7 +23,7 @@ class Disabler
23
  *
24
  * @return void
25
  */
26
- public function run()
27
  {
28
  self::disableNativeEmbedHooks();
29
 
@@ -90,6 +90,8 @@ class Disabler
90
  remove_shortcode(EMBEDPRESS_SHORTCODE);
91
 
92
  wp_deregister_script('wp-embed');
 
 
93
  }
94
 
95
  /**
23
  *
24
  * @return void
25
  */
26
+ public static function run()
27
  {
28
  self::disableNativeEmbedHooks();
29
 
90
  remove_shortcode(EMBEDPRESS_SHORTCODE);
91
 
92
  wp_deregister_script('wp-embed');
93
+
94
+ add_filter('http_request_host_is_external', array('\EmbedPress\Core', 'allowApiHost'), 10, 3);
95
  }
96
 
97
  /**
EmbedPress/Ends/Back/Handler.php CHANGED
@@ -3,7 +3,7 @@ namespace EmbedPress\Ends\Back;
3
 
4
  use \EmbedPress\Ends\Handler as EndHandlerAbstract;
5
  use \EmbedPress\Shortcode;
6
- use \EmbedPress\Plugin;
7
  use \Embera\Embera;
8
 
9
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
@@ -30,7 +30,7 @@ class Handler extends EndHandlerAbstract
30
  */
31
  public function enqueueScripts()
32
  {
33
- $plgSettings = Plugin::getSettings();
34
 
35
  wp_enqueue_script("bootbox-bootstrap", EMBEDPRESS_URL_ASSETS .'js/vendor/bootstrap/bootstrap.min.js', array('jquery'), $this->pluginVersion, true);
36
  wp_enqueue_script("bootbox", EMBEDPRESS_URL_ASSETS .'js/vendor/bootbox.min.js', array('jquery', 'bootbox-bootstrap'), $this->pluginVersion, true);
@@ -45,6 +45,18 @@ class Handler extends EndHandlerAbstract
45
  'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
46
  'displayPreviewBox' => $plgSettings->displayPreviewBox
47
  ));
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  /**
@@ -69,9 +81,7 @@ class Handler extends EndHandlerAbstract
69
  public function doShortcodeReceivedViaAjax()
70
  {
71
  $response = array(
72
- 'data' => array(
73
- 'content' => Shortcode::parseContent(@$_POST['subject'], true)
74
- )
75
  );
76
 
77
  header('Content-Type:application/json;charset=UTF-8');
@@ -97,7 +107,7 @@ class Handler extends EndHandlerAbstract
97
  if (!!strlen($response['url'])) {
98
  $embera = new Embera();
99
 
100
- $additionalServiceProviders = Plugin::getAdditionalServiceProviders();
101
  if (!empty($additionalServiceProviders)) {
102
  foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
103
  Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $embera);
@@ -107,7 +117,7 @@ class Handler extends EndHandlerAbstract
107
  $urlInfo = $embera->getUrlInfo($response['url']);
108
  if (isset($urlInfo[$response['url']])) {
109
  $urlInfo = (object)$urlInfo[$response['url']];
110
- $response['canBeResponsive'] = Plugin::canServiceProviderBeResponsive($urlInfo->provider_alias);
111
  }
112
  }
113
 
3
 
4
  use \EmbedPress\Ends\Handler as EndHandlerAbstract;
5
  use \EmbedPress\Shortcode;
6
+ use \EmbedPress\Core;
7
  use \Embera\Embera;
8
 
9
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
30
  */
31
  public function enqueueScripts()
32
  {
33
+ $plgSettings = Core::getSettings();
34
 
35
  wp_enqueue_script("bootbox-bootstrap", EMBEDPRESS_URL_ASSETS .'js/vendor/bootstrap/bootstrap.min.js', array('jquery'), $this->pluginVersion, true);
36
  wp_enqueue_script("bootbox", EMBEDPRESS_URL_ASSETS .'js/vendor/bootbox.min.js', array('jquery', 'bootbox-bootstrap'), $this->pluginVersion, true);
45
  'EMBEDPRESS_URL_ASSETS' => EMBEDPRESS_URL_ASSETS,
46
  'displayPreviewBox' => $plgSettings->displayPreviewBox
47
  ));
48
+
49
+ $installedPlugins = Core::getPlugins();
50
+ if (count($installedPlugins) > 0) {
51
+ foreach ($installedPlugins as $plgSlug => $plgNamespace) {
52
+ $plgScriptPathRelative = "assets/js/embedpress.{$plgSlug}.js";
53
+ $plgName = "embedpress-{$plgSlug}";
54
+
55
+ if (file_exists(WP_PLUGIN_DIR . "/{$plgName}/{$plgScriptPathRelative}")) {
56
+ wp_enqueue_script($plgName, plugins_url($plgName) .'/'. $plgScriptPathRelative, array($this->pluginName), $this->pluginVersion, true);
57
+ }
58
+ }
59
+ }
60
  }
61
 
62
  /**
81
  public function doShortcodeReceivedViaAjax()
82
  {
83
  $response = array(
84
+ 'data' => Shortcode::parseContent(@$_POST['subject'], true)
 
 
85
  );
86
 
87
  header('Content-Type:application/json;charset=UTF-8');
107
  if (!!strlen($response['url'])) {
108
  $embera = new Embera();
109
 
110
+ $additionalServiceProviders = Core::getAdditionalServiceProviders();
111
  if (!empty($additionalServiceProviders)) {
112
  foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
113
  Shortcode::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $embera);
117
  $urlInfo = $embera->getUrlInfo($response['url']);
118
  if (isset($urlInfo[$response['url']])) {
119
  $urlInfo = (object)$urlInfo[$response['url']];
120
+ $response['canBeResponsive'] = Core::canServiceProviderBeResponsive($urlInfo->provider_alias);
121
  }
122
  }
123
 
EmbedPress/Ends/Back/Settings.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  namespace EmbedPress\Ends\Back;
3
 
4
- use \EmbedPress\Plugin;
5
 
6
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
7
 
@@ -59,7 +59,7 @@ class Settings
59
  *
60
  * @var string $sectionGroupIdentifier The name of the plugin.
61
  */
62
- private static $sectionGroupIdentifier = "embedpress_options";
63
 
64
  /**
65
  * Map to all settings.
@@ -72,15 +72,15 @@ class Settings
72
  */
73
  private static $fieldMap = array(
74
  'enablePluginInAdmin' => array(
75
- 'label' => "Enable EmbedPress in the admin area",
76
  'section' => "admin"
77
  ),
78
  'displayPreviewBox' => array(
79
- 'label' => "Display Preview Box inside editor",
80
  'section' => "admin"
81
  ),
82
  'forceFacebookLanguage' => array(
83
- 'label' => "Display Facebook embeds in a different language",
84
  'section' => "admin"
85
  )
86
  );
@@ -120,12 +120,26 @@ class Settings
120
  */
121
  public static function registerActions()
122
  {
123
- register_setting(self::$sectionGroupIdentifier, self::$sectionGroupIdentifier, array(self::$namespace, "validateForm"));
 
 
 
 
 
124
 
125
- add_settings_section(self::$sectionAdminIdentifier, 'Admin Section Settings', array(self::$namespace, 'renderHelpText'), self::$identifier);
 
 
 
 
 
 
126
 
127
- foreach (self::$fieldMap as $fieldName => $field) {
128
- add_settings_field($fieldName, $field['label'], array(self::$namespace, "renderField_{$fieldName}"), self::$identifier, self::${"section". ucfirst($field['section']) ."Identifier"});
 
 
 
129
  }
130
  }
131
 
@@ -137,12 +151,24 @@ class Settings
137
  */
138
  public static function renderForm()
139
  {
 
 
 
140
  ?>
141
  <div>
142
- <h2>EmbedPress Settings Page</h2>
 
 
 
 
 
 
 
 
 
143
  <form action="options.php" method="POST">
144
- <?php settings_fields(self::$sectionGroupIdentifier); ?>
145
- <?php do_settings_sections(self::$identifier); ?>
146
 
147
  <input name="Submit" type="submit" class="button button-primary" value="Save changes" />
148
  </form>
@@ -171,19 +197,6 @@ class Settings
171
  return $data;
172
  }
173
 
174
- /**
175
- * Method that prints help info for the form.
176
- *
177
- * @since 1.0.0
178
- * @static
179
- *
180
- * @return string
181
- */
182
- public static function renderHelpText()
183
- {
184
- return "";
185
- }
186
-
187
  /**
188
  * Method that renders the displayPreviewBox input.
189
  *
@@ -196,7 +209,7 @@ class Settings
196
 
197
  $options = get_option(self::$sectionGroupIdentifier);
198
 
199
- $activeOptions = Plugin::getSettings();
200
  if (isset($activeOptions->enablePluginInAdmin) && (bool)$activeOptions->enablePluginInAdmin === false) {
201
  $options[$fieldName] = false;
202
  } else {
@@ -207,6 +220,7 @@ class Settings
207
  echo '<label><input type="radio" id="'. $fieldName .'_0" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="0" '. (!$options[$fieldName] ? "checked" : "") .' /> No</label>';
208
  echo "&nbsp;&nbsp;";
209
  echo '<label><input type="radio" id="'. $fieldName .'_1" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="1" '. ($options[$fieldName] ? "checked" : "") .' /> Yes</label>';
 
210
  }
211
 
212
  /**
@@ -226,6 +240,7 @@ class Settings
226
  echo '<label><input type="radio" id="'. $fieldName .'_0" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="0" '. (!$options[$fieldName] ? "checked" : "") .' /> No</label>';
227
  echo "&nbsp;&nbsp;";
228
  echo '<label><input type="radio" id="'. $fieldName .'_1" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="1" '. ($options[$fieldName] ? "checked" : "") .' /> Yes</label>';
 
229
  }
230
 
231
  /**
@@ -252,6 +267,8 @@ class Settings
252
  }
253
  echo '</optgroup>';
254
  echo '</select>';
 
 
255
  }
256
 
257
  /**
1
  <?php
2
  namespace EmbedPress\Ends\Back;
3
 
4
+ use \EmbedPress\Core;
5
 
6
  (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
7
 
59
  *
60
  * @var string $sectionGroupIdentifier The name of the plugin.
61
  */
62
+ private static $sectionGroupIdentifier = "embedpress";
63
 
64
  /**
65
  * Map to all settings.
72
  */
73
  private static $fieldMap = array(
74
  'enablePluginInAdmin' => array(
75
+ 'label' => "Allow EmbedPress in Admin",
76
  'section' => "admin"
77
  ),
78
  'displayPreviewBox' => array(
79
+ 'label' => "Load embeds inside Editors",
80
  'section' => "admin"
81
  ),
82
  'forceFacebookLanguage' => array(
83
+ 'label' => "Facebook embeds language",
84
  'section' => "admin"
85
  )
86
  );
120
  */
121
  public static function registerActions()
122
  {
123
+ $activeTab = strtolower(@$_GET['tab']);
124
+ if ($activeTab !== "embedpress") {
125
+ $action = "embedpress:{$activeTab}:settings:register";
126
+ } else {
127
+ $activeTab = "";
128
+ }
129
 
130
+ if (!empty($activeTab) && has_action($action)) {
131
+ do_action($action, array(
132
+ 'id' => self::$sectionAdminIdentifier,
133
+ 'slug' => self::$identifier
134
+ ));
135
+ } else {
136
+ register_setting(self::$sectionGroupIdentifier, self::$sectionGroupIdentifier, array(self::$namespace, "validateForm"));
137
 
138
+ add_settings_section(self::$sectionAdminIdentifier, 'General Settings', null, self::$identifier);
139
+
140
+ foreach (self::$fieldMap as $fieldName => $field) {
141
+ add_settings_field($fieldName, $field['label'], array(self::$namespace, "renderField_{$fieldName}"), self::$identifier, self::${"section". ucfirst($field['section']) ."Identifier"});
142
+ }
143
  }
144
  }
145
 
151
  */
152
  public static function renderForm()
153
  {
154
+ $activeTab = strtolower(@$_GET['tab']);
155
+ $settingsFieldsIdentifier = !empty($activeTab) ? "embedpress:{$activeTab}" : self::$sectionGroupIdentifier;
156
+ $settingsSectionsIdentifier = !empty($activeTab) ? "embedpress:{$activeTab}" : self::$identifier;
157
  ?>
158
  <div>
159
+ <h1>EmbedPress</h1>
160
+
161
+ <?php settings_errors(); ?>
162
+
163
+ <h2 class="nav-tab-wrapper">
164
+ <a href="?page=embedpress" class="nav-tab<?php echo $activeTab === 'embedpress' || empty($activeTab) ? ' nav-tab-active' : ''; ?> ">General settings</a>
165
+
166
+ <?php do_action('embedpress:settings:render:tab', $activeTab); ?>
167
+ </h2>
168
+
169
  <form action="options.php" method="POST">
170
+ <?php settings_fields($settingsFieldsIdentifier); ?>
171
+ <?php do_settings_sections($settingsSectionsIdentifier); ?>
172
 
173
  <input name="Submit" type="submit" class="button button-primary" value="Save changes" />
174
  </form>
197
  return $data;
198
  }
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  /**
201
  * Method that renders the displayPreviewBox input.
202
  *
209
 
210
  $options = get_option(self::$sectionGroupIdentifier);
211
 
212
+ $activeOptions = Core::getSettings();
213
  if (isset($activeOptions->enablePluginInAdmin) && (bool)$activeOptions->enablePluginInAdmin === false) {
214
  $options[$fieldName] = false;
215
  } else {
220
  echo '<label><input type="radio" id="'. $fieldName .'_0" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="0" '. (!$options[$fieldName] ? "checked" : "") .' /> No</label>';
221
  echo "&nbsp;&nbsp;";
222
  echo '<label><input type="radio" id="'. $fieldName .'_1" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="1" '. ($options[$fieldName] ? "checked" : "") .' /> Yes</label>';
223
+ echo '<p class="description">Load embeds automatically detected inside your editor\'s content (i.e. TinyMCE).</p>';
224
  }
225
 
226
  /**
240
  echo '<label><input type="radio" id="'. $fieldName .'_0" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="0" '. (!$options[$fieldName] ? "checked" : "") .' /> No</label>';
241
  echo "&nbsp;&nbsp;";
242
  echo '<label><input type="radio" id="'. $fieldName .'_1" name="'. self::$sectionGroupIdentifier .'['. $fieldName .']" value="1" '. ($options[$fieldName] ? "checked" : "") .' /> Yes</label>';
243
+ echo '<p class="description">Allow EmbedPress to run here in the Admin area. Disabling this <strong>will not</strong> affect your frontend embeds.</p>';
244
  }
245
 
246
  /**
267
  }
268
  echo '</optgroup>';
269
  echo '</select>';
270
+
271
+ echo '<p class="description">Choose to force or not a different language into your Facebook embeds.</p>';
272
  }
273
 
274
  /**
EmbedPress/Ends/Front/Handler.php CHANGED
@@ -37,6 +37,6 @@ class Handler extends EndHandlerAbstract
37
  */
38
  public function enqueueStyles()
39
  {
40
- wp_enqueue_style(EMBEDPRESS_NAME, EMBEDPRESS_URL_ASSETS .'css/embedpress.css');
41
  }
42
  }
37
  */
38
  public function enqueueStyles()
39
  {
40
+ wp_enqueue_style(EMBEDPRESS_PLG_NAME, EMBEDPRESS_URL_ASSETS .'css/embedpress.css');
41
  }
42
  }
EmbedPress/Ends/Handler.php CHANGED
File without changes
EmbedPress/Loader.php CHANGED
File without changes
EmbedPress/Plugins/Html/Field.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace EmbedPress\Plugins\Html;
3
+
4
+ (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
5
+
6
+ /**
7
+ * Entity responsible to generating and rendering html fields to the settings page.
8
+ *
9
+ * @package EmbedPress
10
+ * @author PressShack <help@pressshack.com>
11
+ * @copyright Copyright (C) 2016 Open Source Training, LLC. All rights reserved.
12
+ * @license GPLv2 or later
13
+ * @since 1.4.0
14
+ */
15
+
16
+ class Field
17
+ {
18
+ /**
19
+ * Generates a text type input.
20
+ *
21
+ * @since 1.4.0
22
+ * @access protected
23
+ * @static
24
+ *
25
+ * @return string
26
+ */
27
+ protected static function text($value)
28
+ {
29
+ $html = '<input type="text" name="embedpress:{{slug}}[{{name}}]" class="{{classes}}" placeholder="{{placeholder}}" value="'. (string)$value .'">';
30
+
31
+ return $html;
32
+ }
33
+
34
+ /**
35
+ * Generates a textarea input.
36
+ *
37
+ * @since 1.4.0
38
+ * @access protected
39
+ * @static
40
+ *
41
+ * @return string
42
+ */
43
+ protected static function textarea($value)
44
+ {
45
+ $html = '<textarea name="embedpress:{{slug}}[{{name}}]" class="{{classes}}" placeholder="{{placeholder}}">'. (string)$value .'</textarea>';
46
+
47
+ return $html;
48
+ }
49
+
50
+ /**
51
+ * Generates a radio type input.
52
+ *
53
+ * @since 1.4.0
54
+ * @access protected
55
+ * @static
56
+ *
57
+ * @return string
58
+ */
59
+ protected static function radio($options, $value = null)
60
+ {
61
+ $html = array();
62
+
63
+ foreach ((array)$options as $optionValue => $optionLabel) {
64
+ $html[] = '<label>';
65
+ $html[] = '<input type="radio" name="embedpress:{{slug}}[{{name}}]" class="{{classes}}" value="'. $optionValue .'"'. ($value === $optionValue ? ' checked' : '') .'>';
66
+ $html[] = '&nbsp;'. $optionLabel;
67
+ $html[] = '</label>&nbsp;&nbsp;';
68
+ }
69
+
70
+ $html = implode('', $html);
71
+
72
+ return $html;
73
+ }
74
+
75
+ /**
76
+ * Generates a select input.
77
+ *
78
+ * @since 1.4.0
79
+ * @access protected
80
+ * @static
81
+ *
82
+ * @return string
83
+ */
84
+ protected static function select($options, $value = null)
85
+ {
86
+ $html = array('<select name="embedpress:{{slug}}[{{name}}]" class="{{classes}}">');
87
+
88
+ foreach ((array)$options as $optionValue => $optionLabel) {
89
+ $html[] = '<option value="'. $optionValue .'"'. ($value === (string)$optionValue ? ' selected' : '') .'>'. $optionLabel .'</option>';
90
+ }
91
+
92
+ $html[] = '</select>';
93
+
94
+ $html = implode('', $html);
95
+
96
+ return $html;
97
+ }
98
+
99
+ /**
100
+ * Render a field based on a field schema.
101
+ *
102
+ * @since 1.4.0
103
+ * @static
104
+ *
105
+ * @param array $params There's two available keys: 'field' which holds the field schema; and 'pluginSlug' which represents the slug of the plugin where the field belongs to.
106
+ * @return void
107
+ */
108
+ public static function render($params)
109
+ {
110
+ $field = json_decode(json_encode($params['field']));
111
+
112
+ $pluginSlug = "embedpress:{$params['pluginSlug']}";
113
+
114
+ $options = (array)get_option($pluginSlug);
115
+
116
+ $field->type = strtolower($field->type);
117
+
118
+ if ($field->slug === "license_key") {
119
+ $value = @$options['license']['key'];
120
+ } else {
121
+ $value = isset($options[$field->slug]) ? $options[$field->slug] : (isset($field->default) ? $field->default : '');
122
+ }
123
+
124
+ if (in_array($field->type, array('bool', 'boolean'))) {
125
+ $html = self::radio(array(
126
+ 0 => 'No',
127
+ 1 => 'Yes'
128
+ ), (int)$value);
129
+ } else if (isset($field->options)) {
130
+ $html = self::select((array)$field->options, (string)$value);
131
+ } else if (in_array($field->type, array('textarea'))) {
132
+ $html = self::textarea((string)$value);
133
+ } else {
134
+ $html = self::text((string)$value);
135
+ }
136
+
137
+ $html = str_replace('{{slug}}', $params['pluginSlug'], $html);
138
+ $html = str_replace('{{name}}', $field->slug, $html);
139
+ $html = str_replace('{{classes}}', implode(' ', (array)@$field->classes), $html);
140
+ $html = str_replace('{{placeholder}}', (string)@$field->placeholder, $html);
141
+
142
+ $html .= wp_nonce_field("{$pluginSlug}:nonce", "{$pluginSlug}:nonce");
143
+
144
+ if ($field->slug === "license_key") {
145
+ $licenseStatusClass = "ep-label-danger";
146
+ switch (trim(strtoupper(@$options['license']['status']))) {
147
+ case '':
148
+ $licenseStatusMessage = "Missing license";
149
+ break;
150
+ case 'EXPIRED':
151
+ $licenseStatusMessage = "Your license key is expired";
152
+ break;
153
+ case 'REVOKED':
154
+ $licenseStatusMessage = "Your license key has been disabled";
155
+ break;
156
+ case 'MISSING':
157
+ case 'INVALID':
158
+ $licenseStatusMessage = "Invalid license";
159
+ break;
160
+ case 'SITE_INACTIVE':
161
+ $licenseStatusMessage = "Your license is not active for this URL";
162
+ break;
163
+ case 'ITEM_NAME_MISMATCH':
164
+ $licenseStatusMessage = "This appears to be an invalid license key for this product";
165
+ break;
166
+ case 'NO_ACTIVATIONS_LEFT':
167
+ $licenseStatusMessage = "Your license key has reached its activation limit";
168
+ break;
169
+ case 'VALID':
170
+ $licenseStatusClass = "ep-label-success";
171
+ $licenseStatusMessage = "Activated";
172
+ break;
173
+ default:
174
+ $licenseStatusMessage = "Not validated yet";
175
+ break;
176
+ }
177
+
178
+ $html .= '<br/><br/><strong>Status: <span class="'. $licenseStatusClass .'">'. __($licenseStatusMessage) .'</span>.</strong><br/><br/>';
179
+ if (@$options['license']['status'] !== 'valid') {
180
+ $html .= '<button type="submit" class="button-secondary">' . __('Activate License') . '</button> ';
181
+ $html .= '<a href="'. EMBEDPRESS_LICENSES_MORE_INFO_URL .'" target="_blank" class="ep-small-link ep-small-spacing" rel="noopener noreferrer" style="display: inline-block; margin-left: 20px;" title="'. __('Click here to read more about licenses.') .'">' . __('More information') . '</a>';
182
+ $html .= '<br/><br/>';
183
+ }
184
+
185
+ $html .= '<hr>';
186
+ }
187
+
188
+ if (!empty($field->description)) {
189
+ $html .= '<br/>';
190
+ $html .= '<p class="description">'. $field->description .'</p>';
191
+ }
192
+
193
+ echo $html;
194
+ }
195
+ }
EmbedPress/Plugins/Html/index.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>403 Forbidden</title>
5
+ </head>
6
+ <body>
7
+ <p>Directory access is forbidden.</p>
8
+ </body>
9
+ </html>
EmbedPress/Plugins/Plugin.php ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace EmbedPress\Plugins;
3
+
4
+ use \EmbedPress\Updater;
5
+
6
+ (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
7
+
8
+ /**
9
+ * Entity that represents a model to EmbedPress plugins.
10
+ *
11
+ * @package EmbedPress
12
+ * @author PressShack <help@pressshack.com>
13
+ * @copyright Copyright (C) 2016 Open Source Training, LLC. All rights reserved.
14
+ * @license GPLv2 or later
15
+ * @since 1.4.0
16
+ * @abstract
17
+ */
18
+ abstract class Plugin
19
+ {
20
+ /**
21
+ * Method that register all EmbedPress events.
22
+ *
23
+ * @since 1.4.0
24
+ * @static
25
+ *
26
+ * @return void
27
+ */
28
+ public static function registerEvents()
29
+ {
30
+ // do nothing
31
+ }
32
+
33
+ /**
34
+ * Method that checks if EmbedPress is active or not.
35
+ *
36
+ * @since 1.4.0
37
+ * @access protected
38
+ * @static
39
+ *
40
+ * @return boolean
41
+ */
42
+ protected static function isEmbedPressActive()
43
+ {
44
+ $isEmbedPressActive = is_plugin_active(EMBEDPRESS_PLG_NAME .'/'. EMBEDPRESS_PLG_NAME .'.php');
45
+
46
+ return $isEmbedPressActive;
47
+ }
48
+
49
+ /**
50
+ * Retrieve an error message based on its code.
51
+ *
52
+ * @since 1.4.0
53
+ * @access protected
54
+ * @static
55
+ *
56
+ * @param string $err The error code.
57
+ * @return string
58
+ */
59
+ protected static function getErrorMessage($err = '')
60
+ {
61
+ if ($err === 'ERR_MISSING_DEPENDENCY') {
62
+ return __('Please, <strong>install</strong> and <strong>activate <a href="https://wordpress.org/plugins/'. EMBEDPRESS_PLG_NAME .'" target="_blank" rel="noopener noreferrer">'. EMBEDPRESS .'</a></strong> plugin in order to make <em>'. EMBEDPRESS .' - '. static::NAME .'</em> to work.');
63
+ }
64
+
65
+ return $err;
66
+ }
67
+
68
+ /**
69
+ * Callback triggered by WordPress' 'admin_init' default action.
70
+ *
71
+ * @since 1.4.0
72
+ * @static
73
+ *
74
+ * @return void
75
+ */
76
+ public static function onLoadAdminCallback()
77
+ {
78
+ $pluginSignature = EMBEDPRESS_PLG_NAME .'-'. static::SLUG .'/'. EMBEDPRESS_PLG_NAME .'-'. static::SLUG .'.php';
79
+ if (is_admin() && !self::isEmbedPressActive() && is_plugin_active($pluginSignature)) {
80
+ deactivate_plugins($pluginSignature);
81
+ } else {
82
+ static::registerSettings();
83
+
84
+ $options = static::getOptions();
85
+
86
+ new Updater(EMBEDPRESS_LICENSES_API_URL, static::PATH . EMBEDPRESS_PLG_NAME .'-'. static::SLUG .'.php', array(
87
+ 'version' => static::VERSION,
88
+ 'license' => (string)@$options['license']['key'],
89
+ 'item_name' => "EmbedPress - ". static::NAME,
90
+ 'author' => "PressShack"
91
+ ));
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Callback triggered by WordPress' 'register_activation_hook' function.
97
+ *
98
+ * @since 1.4.0
99
+ * @static
100
+ *
101
+ * @return void
102
+ */
103
+ public static function onActivationCallback()
104
+ {
105
+ if (is_admin() && !self::isEmbedPressActive()) {
106
+ echo '<p><a href="'. admin_url('plugins.php') .'">'. __('Go back') .'</a></p>';
107
+
108
+ wp_die(self::getErrorMessage('ERR_MISSING_DEPENDENCY'));
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Callback triggered by WordPress' 'register_deactivation_hook' function.
114
+ *
115
+ * @since 1.4.0
116
+ * @static
117
+ *
118
+ * @return void
119
+ */
120
+ public static function onDeactivationCallback()
121
+ {
122
+ delete_option(EMBEDPRESS_PLG_NAME .':'. static::SLUG);
123
+ }
124
+
125
+ /**
126
+ * Method that validates the EmbedPress plugin's settings form.
127
+ *
128
+ * @since 1.4.0
129
+ * @static
130
+ *
131
+ * @param array $postData The data coming from the form via POST.
132
+ * @return array
133
+ */
134
+ public static function validateForm($postData)
135
+ {
136
+ $pluginSlugNonce = EMBEDPRESS_PLG_NAME .':'. static::SLUG .':nonce';
137
+ if (!check_admin_referer($pluginSlugNonce, $pluginSlugNonce)) {
138
+ return;
139
+ }
140
+
141
+ $data = array();
142
+
143
+ $schema = static::getOptionsSchema();
144
+ foreach ($schema as $fieldSlug => $field) {
145
+ if (isset($postData[$fieldSlug])) {
146
+ $value = $postData[$fieldSlug];
147
+ } else {
148
+ $value = isset($field['default']) ? $field['default'] : null;
149
+ }
150
+
151
+ settype($value, isset($field['type']) && in_array(strtolower($field['type']), array('bool', 'boolean', 'int', 'integer', 'float', 'string')) ? $field['type'] : 'string');
152
+
153
+ $data[$fieldSlug] = $value;
154
+ }
155
+
156
+ static::onAfterFormValidation($data);
157
+
158
+ if (isset($data['license_key'])) {
159
+ unset($data['license_key']);
160
+ }
161
+
162
+ return $data;
163
+ }
164
+
165
+ /**
166
+ * Method called right after the settings form being validated but before saving the data into DB.
167
+ *
168
+ * @since 1.4.0
169
+ * @static
170
+ *
171
+ * @param array Data after validation.
172
+ * @return void
173
+ */
174
+ public static function onAfterFormValidation(&$data)
175
+ {
176
+ // do nothing
177
+ }
178
+
179
+ /**
180
+ * Method that appends a tab in EmbedPress' Settings page to the plugin.
181
+ *
182
+ * @since 1.4.0
183
+ * @static
184
+ *
185
+ * @return void
186
+ */
187
+ public static function renderTab($activeTab)
188
+ {
189
+ ?>
190
+
191
+ <a href="?page=<?php echo EMBEDPRESS_PLG_NAME; ?>&tab=<?php echo static::SLUG; ?>" class="nav-tab<?php echo $activeTab === static::SLUG ? ' nav-tab-active' : ''; ?> "><?php echo static::NAME; ?></a>
192
+
193
+ <?php
194
+ }
195
+
196
+ /**
197
+ * Method that return the absolute path to the plugin.
198
+ *
199
+ * @since 1.4.0
200
+ * @static
201
+ *
202
+ * @return void
203
+ */
204
+ public static function registerSettings()
205
+ {
206
+ $identifier = EMBEDPRESS_PLG_NAME .':'. static::SLUG;
207
+
208
+ register_setting($identifier, $identifier, array(static::NAMESPACE_STRING, 'validateForm'));
209
+ add_settings_section($identifier, EMBEDPRESS .' > '. static::NAME .' Settings', array(static::NAMESPACE_STRING, 'onAfterRegisterSettings'), $identifier);
210
+
211
+ self::registerSettingsFields();
212
+ }
213
+
214
+ /**
215
+ * Register all plugin fields to the settings page.
216
+ *
217
+ * @since 1.4.0
218
+ * @static
219
+ *
220
+ * @return void
221
+ */
222
+ public static function registerSettingsFields()
223
+ {
224
+ $identifier = EMBEDPRESS_PLG_NAME .':'. static::SLUG;
225
+
226
+ $schema = static::getOptionsSchema();
227
+ foreach ($schema as $fieldSlug => $field) {
228
+ $field['slug'] = $fieldSlug;
229
+
230
+ add_settings_field($fieldSlug, $field['label'], array(__NAMESPACE__ .'\Html\Field', 'render'), $identifier, $identifier, array(
231
+ 'pluginSlug' => static::SLUG,
232
+ 'field' => $field
233
+ ));
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Callback called after the plugin's settings page has been registered and rendered.
239
+ *
240
+ * @since 1.4.0
241
+ * @static
242
+ *
243
+ * @return void
244
+ */
245
+ public static function onAfterRegisterSettings()
246
+ {
247
+ // do nothing
248
+ }
249
+
250
+ /**
251
+ * Retrieve user defined options.
252
+ *
253
+ * @since 1.4.0
254
+ * @static
255
+ *
256
+ * @return array
257
+ */
258
+ public static function getOptions()
259
+ {
260
+ $options = (array)get_option(EMBEDPRESS_PLG_NAME .':'. static::SLUG);
261
+ if (empty($options) || (count($options) === 1 && empty($options[0]))) {
262
+ $options = array();
263
+ $schema = static::getOptionsSchema();
264
+ foreach ($schema as $fieldSlug => $field) {
265
+ $value = isset($field['default']) ? $field['default'] : "";
266
+
267
+ settype($value, isset($field['type']) && in_array(strtolower($field['type']), array('bool', 'boolean', 'int', 'integer', 'float', 'string')) ? $field['type'] : 'string');
268
+
269
+ if ($fieldSlug === "license_key") {
270
+ $options['license'] = array(
271
+ 'key' => $value,
272
+ 'status' => "missing"
273
+ );
274
+ } else {
275
+ $options[$fieldSlug] = $value;
276
+ }
277
+ }
278
+ }
279
+
280
+ return $options;
281
+ }
282
+
283
+ /**
284
+ * Handle links displayed below the plugin name in the WordPress Installed Plugins page.
285
+ *
286
+ * @since 1.4.0
287
+ * @static
288
+ *
289
+ * @return array
290
+ */
291
+ public static function handleActionLinks($links, $file)
292
+ {
293
+ $settingsLink = '<a href="'. admin_url('admin.php?page='. EMBEDPRESS_PLG_NAME .'&tab='. static::SLUG) .'" aria-label="'. __('Open settings page', 'embedpress-'. static::SLUG) .'">'. __('Settings', 'embedpress-'. static::SLUG) .'</a>';
294
+
295
+ array_unshift($links, $settingsLink);
296
+
297
+ return $links;
298
+ }
299
+
300
+ /**
301
+ * Method that validates a license key.
302
+ *
303
+ * @since 1.4.0
304
+ * @access protected
305
+ * @static
306
+ *
307
+ * @return mixed
308
+ */
309
+ protected static function validateLicenseKey($licenseKey)
310
+ {
311
+ $pluginSlug = EMBEDPRESS_PLG_NAME .':'. static::SLUG;
312
+
313
+ $response = wp_remote_post(EMBEDPRESS_LICENSES_API_URL, array(
314
+ 'timeout' => 30,
315
+ 'sslverify' => false,
316
+ 'body' => array(
317
+ 'edd_action' => "activate_license",
318
+ 'license' => $licenseKey,
319
+ 'item_name' => "EmbedPress - ". static::NAME,
320
+ 'url' => home_url()
321
+ )
322
+ ));
323
+
324
+ $errMessage = "";
325
+ if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) {
326
+ $errMessage = (is_wp_error($response) && !empty($response->get_error_message())) ? $response->get_error_message() : __('An error occurred, please try again.');
327
+ return "";
328
+ } else {
329
+ $licenseData = json_decode(wp_remote_retrieve_body($response));
330
+ if (empty($licenseData) || !is_object($licenseData)) {
331
+ $licenseNewStatus = "invalid";
332
+ } else {
333
+ if (@$licenseData->success === false) {
334
+ $licenseNewStatus = !empty(@$licenseData->error) ? $licenseData->error : "invalid";
335
+ } else {
336
+ $licenseNewStatus = "valid";
337
+ }
338
+ }
339
+
340
+ return $licenseNewStatus;
341
+ }
342
+ }
343
+ }
EmbedPress/Plugins/index.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>403 Forbidden</title>
5
+ </head>
6
+ <body>
7
+ <p>Directory access is forbidden.</p>
8
+ </body>
9
+ </html>
EmbedPress/Providers/GoogleDocs.php CHANGED
File without changes
EmbedPress/Providers/GoogleMaps.php CHANGED
File without changes
EmbedPress/Providers/index.html CHANGED
File without changes
EmbedPress/Shortcode.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  namespace EmbedPress;
3
 
4
- use \EmbedPress\Plugin;
5
  use \Embera\Embera;
6
  use \Embera\Formatter;
7
 
@@ -49,15 +49,15 @@ class Shortcode
49
  * @since 1.0.0
50
  * @static
51
  *
52
- * @param array $attributes @TODO
53
  * @param string $subject The given string
54
  * @return string
55
  */
56
  public static function do_shortcode($attributes = array(), $subject = null)
57
  {
58
- $decodedSubject = self::parseContent($subject, true, $attributes);
59
 
60
- return $decodedSubject;
61
  }
62
 
63
  /**
@@ -109,6 +109,11 @@ class Shortcode
109
  // Gather info about the shortcode's link
110
  $urlData = self::$oEmbedInstance->fetch($serviceProvider, $content, $attributes);
111
 
 
 
 
 
 
112
  // Transform all shortcode attributes into html form. I.e.: {foo: "joe"} -> foo="joe"
113
  $attributesHtml = array();
114
  foreach ($attributes as $attrName => $attrValue) {
@@ -175,7 +180,7 @@ class Shortcode
175
  // If the embed couldn't be generated, we'll try to use Embera's API
176
  $emberaInstance = new Embera($emberaInstanceSettings);
177
  // Add support to the user's custom service providers
178
- $additionalServiceProviders = Plugin::getAdditionalServiceProviders();
179
  if (!empty($additionalServiceProviders)) {
180
  foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
181
  self::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $emberaInstance);
@@ -207,7 +212,7 @@ class Shortcode
207
  if (strtoupper($urlData->provider_name) === "NATIONAL FILM BOARD OF CANADA") {
208
  $parsedContent = html_entity_decode($parsedContent);
209
  } else if (strtoupper($urlData->provider_name) === "FACEBOOK") {
210
- $plgSettings = Plugin::getSettings();
211
 
212
  // Check if the user wants to force a certain language into Facebook embeds.
213
  $locale = isset($plgSettings->fbLanguage) && !empty($plgSettings->fbLanguage) ? $plgSettings->fbLanguage : false;
@@ -219,7 +224,7 @@ class Shortcode
219
  unset($locale, $plgSettings);
220
  }
221
 
222
- unset($embedTemplate, $urlData, $serviceProvider);
223
 
224
  // This assure that the iframe has the same dimensions the user wants to
225
  if (isset($emberaInstanceSettings['params']['width']) || isset($emberaInstanceSettings['params']['height'])) {
@@ -252,7 +257,15 @@ class Shortcode
252
  }
253
 
254
  if (!empty($parsedContent)) {
255
- return $parsedContent;
 
 
 
 
 
 
 
 
256
  }
257
  }
258
 
1
  <?php
2
  namespace EmbedPress;
3
 
4
+ use \EmbedPress\Core;
5
  use \Embera\Embera;
6
  use \Embera\Formatter;
7
 
49
  * @since 1.0.0
50
  * @static
51
  *
52
+ * @param array $attributes Array of attributes
53
  * @param string $subject The given string
54
  * @return string
55
  */
56
  public static function do_shortcode($attributes = array(), $subject = null)
57
  {
58
+ $embed = self::parseContent($subject, true, $attributes);
59
 
60
+ return is_object($embed) ? $embed->embed : $embed;
61
  }
62
 
63
  /**
109
  // Gather info about the shortcode's link
110
  $urlData = self::$oEmbedInstance->fetch($serviceProvider, $content, $attributes);
111
 
112
+ $eventResults = apply_filters('embedpress:onBeforeEmbed', $urlData);
113
+ if (empty($eventResults)) {
114
+ return $subject;
115
+ }
116
+
117
  // Transform all shortcode attributes into html form. I.e.: {foo: "joe"} -> foo="joe"
118
  $attributesHtml = array();
119
  foreach ($attributes as $attrName => $attrValue) {
180
  // If the embed couldn't be generated, we'll try to use Embera's API
181
  $emberaInstance = new Embera($emberaInstanceSettings);
182
  // Add support to the user's custom service providers
183
+ $additionalServiceProviders = Core::getAdditionalServiceProviders();
184
  if (!empty($additionalServiceProviders)) {
185
  foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
186
  self::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $emberaInstance);
212
  if (strtoupper($urlData->provider_name) === "NATIONAL FILM BOARD OF CANADA") {
213
  $parsedContent = html_entity_decode($parsedContent);
214
  } else if (strtoupper($urlData->provider_name) === "FACEBOOK") {
215
+ $plgSettings = Core::getSettings();
216
 
217
  // Check if the user wants to force a certain language into Facebook embeds.
218
  $locale = isset($plgSettings->fbLanguage) && !empty($plgSettings->fbLanguage) ? $plgSettings->fbLanguage : false;
224
  unset($locale, $plgSettings);
225
  }
226
 
227
+ unset($embedTemplate, $serviceProvider);
228
 
229
  // This assure that the iframe has the same dimensions the user wants to
230
  if (isset($emberaInstanceSettings['params']['width']) || isset($emberaInstanceSettings['params']['height'])) {
257
  }
258
 
259
  if (!empty($parsedContent)) {
260
+ $embed = (object)array_merge((array)$urlData, array(
261
+ 'attributes' => (object)$attributes,
262
+ 'embed' => $parsedContent,
263
+ 'url' => $content
264
+ ));
265
+
266
+ $embed = apply_filters('embedpress:onAfterEmbed', $embed);
267
+
268
+ return $embed;
269
  }
270
  }
271
 
EmbedPress/Updater.php ADDED
@@ -0,0 +1,381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace EmbedPress;
3
+
4
+ (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
5
+
6
+ /**
7
+ * Class that handles Pro plugins updates.
8
+ * Based on Pippin Williamson's work.
9
+ */
10
+ class Updater
11
+ {
12
+ private $api_url = '';
13
+ private $api_data = array();
14
+ private $name = '';
15
+ private $slug = '';
16
+ private $version = '';
17
+ private $wp_override = false;
18
+
19
+ /**
20
+ * Class constructor.
21
+ *
22
+ * @uses plugin_basename()
23
+ * @uses hook()
24
+ *
25
+ * @param string $_api_url The URL pointing to the custom API endpoint.
26
+ * @param string $_plugin_file Path to the plugin file.
27
+ * @param array $_api_data Optional data to send with API calls.
28
+ */
29
+ public function __construct($_api_url, $_plugin_file, $_api_data = null)
30
+ {
31
+ global $edd_plugin_data;
32
+
33
+ $this->api_url = trailingslashit($_api_url);
34
+ $this->api_data = $_api_data;
35
+ $this->name = plugin_basename($_plugin_file);
36
+ $this->slug = basename($_plugin_file, '.php');
37
+ $this->version = $_api_data['version'];
38
+ $this->wp_override = isset($_api_data['wp_override']) ? (bool)$_api_data['wp_override'] : false;
39
+
40
+ $edd_plugin_data[$this->slug] = $this->api_data;
41
+
42
+ $this->prepareHooks();
43
+ }
44
+
45
+ /**
46
+ * Set up WordPress filters to hook into WP's update process.
47
+ *
48
+ * @uses add_filter()
49
+ * @uses add_action()
50
+ * @uses remove_action()
51
+ *
52
+ * @return void
53
+ */
54
+ public function prepareHooks()
55
+ {
56
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
57
+ add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
58
+ remove_action('after_plugin_row_'. $this->name, 'wp_plugin_update_row', 10, 2);
59
+ add_action('after_plugin_row_'. $this->name, array($this, 'show_update_notification'), 10, 2);
60
+ add_action('admin_init', array($this, 'show_changelog'));
61
+ }
62
+
63
+ /**
64
+ * Check for Updates at the defined API endpoint and modify the update array.
65
+ *
66
+ * This function dives into the update API just when WordPress creates its update array,
67
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
68
+ * It is reassembled from parts of the native WordPress plugin update code.
69
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
70
+ *
71
+ * @uses api_request()
72
+ *
73
+ * @param array $_transient_data Update array build by WordPress.
74
+ * @return array Modified update array with custom plugin data.
75
+ */
76
+ public function check_update($_transient_data)
77
+ {
78
+ global $pagenow;
79
+
80
+ if (!is_object($_transient_data)) {
81
+ $_transient_data = new stdClass;
82
+ }
83
+
84
+ if ('plugins.php' === $pagenow && is_multisite()) {
85
+ return $_transient_data;
86
+ }
87
+
88
+ if (!empty($_transient_data->response) && !empty($_transient_data->response[$this->name]) && false === $this->wp_override) {
89
+ return $_transient_data;
90
+ }
91
+
92
+ $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
93
+
94
+ if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
95
+ if (version_compare($this->version, $version_info->new_version, '<')) {
96
+ $_transient_data->response[$this->name] = $version_info;
97
+ }
98
+
99
+ $_transient_data->last_checked = time();
100
+ $_transient_data->checked[$this->name] = $this->version;
101
+ }
102
+
103
+ return $_transient_data;
104
+ }
105
+
106
+ /**
107
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
108
+ *
109
+ * @param string $file
110
+ * @param array $plugin
111
+ */
112
+ public function show_update_notification($file, $plugin)
113
+ {
114
+ if (is_network_admin()) {
115
+ return;
116
+ }
117
+
118
+ if (!current_user_can('update_plugins')) {
119
+ return;
120
+ }
121
+
122
+ if (!is_multisite()) {
123
+ return;
124
+ }
125
+
126
+ if ($this->name !== $file) {
127
+ return;
128
+ }
129
+
130
+ // Remove our filter on the site transient
131
+ remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
132
+
133
+ $update_cache = get_site_transient('update_plugins');
134
+
135
+ $update_cache = is_object($update_cache) ? $update_cache : new stdClass();
136
+
137
+ if (empty($update_cache->response) || empty($update_cache->response[$this->name])) {
138
+ $cache_key = md5('edd_plugin_'. sanitize_key($this->name) .'_version_info');
139
+ $version_info = get_transient($cache_key);
140
+
141
+ if (false === $version_info) {
142
+ $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
143
+
144
+ set_transient($cache_key, $version_info, 3600);
145
+ }
146
+
147
+ if (!is_object($version_info)) {
148
+ return;
149
+ }
150
+
151
+ if (version_compare($this->version, $version_info->new_version, '<')) {
152
+ $update_cache->response[$this->name] = $version_info;
153
+ }
154
+
155
+ $update_cache->last_checked = time();
156
+ $update_cache->checked[$this->name] = $this->version;
157
+
158
+ set_site_transient('update_plugins', $update_cache);
159
+ } else {
160
+ $version_info = $update_cache->response[$this->name];
161
+ }
162
+
163
+ // Restore our filter
164
+ add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
165
+
166
+ if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
167
+ // build a plugin list row, with update notification
168
+ $wp_list_table = _get_list_table('WP_Plugins_List_Table');
169
+
170
+ echo '<tr class="plugin-update-tr" id="'. $this->slug .'-update" data-slug="'. $this->slug .'" data-plugin="'. $this->slug .'/'. $file .'">';
171
+ echo '<td colspan="3" class="plugin-update colspanchange">';
172
+ echo '<div class="update-message notice inline notice-warning notice-alt">';
173
+
174
+ $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='. $this->name .'&slug='. $this->slug .'&TB_iframe=true&width=772&height=911');
175
+
176
+ if (empty($version_info->download_link)) {
177
+ printf(
178
+ __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
179
+ esc_html($version_info->name),
180
+ '<a target="_blank" class="thickbox" href="'. esc_url($changelog_link) .'" rel="noopener noreferrer">',
181
+ esc_html($version_info->new_version),
182
+ '</a>'
183
+ );
184
+ } else {
185
+ printf(
186
+ __('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads'),
187
+ esc_html($version_info->name),
188
+ '<a target="_blank" class="thickbox" href="'. esc_url($changelog_link) .'" rel="noopener noreferrer">',
189
+ esc_html($version_info->new_version),
190
+ '</a>',
191
+ '<a href="'. esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $this->name, 'upgrade-plugin_'. $this->name)) .'">',
192
+ '</a>'
193
+ );
194
+ }
195
+
196
+ do_action("in_plugin_update_message-{$file}", $plugin, $version_info);
197
+
198
+ echo '</div></td></tr>';
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Updates information on the "View version x.x details" page with custom data.
204
+ *
205
+ * @uses api_request()
206
+ *
207
+ * @param mixed $_data
208
+ * @param string $_action
209
+ * @param object $_args
210
+ * @return object $_data
211
+ */
212
+ public function plugins_api_filter($_data, $_action = '', $_args = null)
213
+ {
214
+ if ($_action != 'plugin_information') {
215
+ return $_data;
216
+ }
217
+
218
+ if (!isset($_args->slug) || ($_args->slug != $this->slug)) {
219
+ return $_data;
220
+ }
221
+
222
+ $to_send = array(
223
+ 'slug' => $this->slug,
224
+ 'is_ssl' => is_ssl(),
225
+ 'fields' => array(
226
+ 'banners' => false, // These will be supported soon hopefully
227
+ 'reviews' => false
228
+ )
229
+ );
230
+
231
+ $cache_key = 'edd_api_request_'. substr(md5(serialize($this->slug)), 0, 15);
232
+
233
+ //Get the transient where we store the api request for this plugin for 24 hours
234
+ $edd_api_request_transient = get_site_transient($cache_key);
235
+
236
+ //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
237
+ if (empty($edd_api_request_transient)) {
238
+ $api_response = $this->api_request('plugin_information', $to_send);
239
+
240
+ //Expires in 1 day
241
+ set_site_transient($cache_key, $api_response, DAY_IN_SECONDS);
242
+
243
+ if (false !== $api_response) {
244
+ $_data = $api_response;
245
+ }
246
+ }
247
+
248
+ return $_data;
249
+ }
250
+
251
+ /**
252
+ * Disable SSL verification in order to prevent download update failures
253
+ *
254
+ * @param array $args
255
+ * @param string $url
256
+ * @return object $array
257
+ */
258
+ public function http_request_args($args, $url)
259
+ {
260
+ // If it is an https request and we are performing a package download, disable ssl verification
261
+ if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
262
+ $args['sslverify'] = false;
263
+ }
264
+
265
+ return $args;
266
+ }
267
+
268
+ /**
269
+ * Calls the API and, if successfull, returns the object delivered by the API.
270
+ *
271
+ * @uses get_bloginfo()
272
+ * @uses wp_remote_post()
273
+ * @uses is_wp_error()
274
+ *
275
+ * @param string $_action The requested action.
276
+ * @param array $_data Parameters for the API action.
277
+ * @return false|object
278
+ */
279
+ private function api_request($_action, $_data)
280
+ {
281
+ global $wp_version;
282
+
283
+ $data = array_merge($this->api_data, $_data);
284
+
285
+ if ($data['slug'] != $this->slug) {
286
+ return;
287
+ }
288
+
289
+ if ($this->api_url == trailingslashit(home_url())) {
290
+ return false; // Don't allow a plugin to ping itself
291
+ }
292
+
293
+ $api_params = array(
294
+ 'edd_action' => 'get_version',
295
+ 'license' => !empty($data['license']) ? $data['license'] : '',
296
+ 'item_name' => isset($data['item_name']) ? $data['item_name'] : false,
297
+ 'item_id' => isset($data['item_id']) ? $data['item_id'] : false,
298
+ 'slug' => $data['slug'],
299
+ 'author' => $data['author'],
300
+ 'url' => home_url()
301
+ );
302
+
303
+ $request = wp_remote_post($this->api_url, array(
304
+ 'timeout' => 15,
305
+ 'sslverify' => false,
306
+ 'body' => $api_params
307
+ ));
308
+
309
+ if (!is_wp_error($request)) {
310
+ $request = json_decode(wp_remote_retrieve_body($request));
311
+ }
312
+
313
+ if ($request && isset($request->sections)) {
314
+ $request->sections = maybe_unserialize($request->sections);
315
+ } else {
316
+ $request = false;
317
+ }
318
+
319
+ return $request;
320
+ }
321
+
322
+ public function show_changelog()
323
+ {
324
+ global $edd_plugin_data;
325
+
326
+ if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
327
+ return;
328
+ }
329
+
330
+ if (empty($_REQUEST['plugin'])) {
331
+ return;
332
+ }
333
+
334
+ if (empty($_REQUEST['slug'])) {
335
+ return;
336
+ }
337
+
338
+ if (!current_user_can('update_plugins')) {
339
+ wp_die(__('You do not have permission to install plugin updates', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
340
+ }
341
+
342
+ $data = $edd_plugin_data[$_REQUEST['slug']];
343
+ $cache_key = md5('edd_plugin_'. sanitize_key($_REQUEST['plugin']) .'_version_info');
344
+ $version_info = get_transient($cache_key);
345
+
346
+ if (false === $version_info) {
347
+ $api_params = array(
348
+ 'edd_action' => 'get_version',
349
+ 'item_name' => isset($data['item_name']) ? $data['item_name'] : false,
350
+ 'item_id' => isset($data['item_id']) ? $data['item_id'] : false,
351
+ 'slug' => $_REQUEST['slug'],
352
+ 'author' => $data['author'],
353
+ 'url' => home_url()
354
+ );
355
+
356
+ $request = wp_remote_post($this->api_url, array(
357
+ 'timeout' => 15,
358
+ 'sslverify' => false,
359
+ 'body' => $api_params
360
+ ));
361
+
362
+ if (!is_wp_error($request)) {
363
+ $version_info = json_decode(wp_remote_retrieve_body($request));
364
+ }
365
+
366
+ if (!empty($version_info) && isset($version_info->sections)) {
367
+ $version_info->sections = maybe_unserialize($version_info->sections);
368
+ } else {
369
+ $version_info = false;
370
+ }
371
+
372
+ set_transient($cache_key, $version_info, 3600);
373
+ }
374
+
375
+ if (!empty($version_info) && isset($version_info->sections['changelog'])) {
376
+ echo '<div style="background:#fff;padding:10px;">'. $version_info->sections['changelog'] .'</div>';
377
+ }
378
+
379
+ exit;
380
+ }
381
+ }
PROVIDERS.md CHANGED
File without changes
assets/css/admin.css CHANGED
@@ -26,4 +26,23 @@
26
 
27
  #toplevel_page_embedpress .current .dashicons-admin-generic::before {
28
  background-position: 0 -60px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
26
 
27
  #toplevel_page_embedpress .current .dashicons-admin-generic::before {
28
  background-position: 0 -60px;
29
+ }
30
+
31
+ /* Custom classes */
32
+
33
+ .ep-label-danger {
34
+ color: #d54e21;
35
+ }
36
+
37
+ .ep-label-success {
38
+ color: #5ca410;
39
+ }
40
+
41
+ .ep-small-link {
42
+ line-height: 28px;
43
+ font-size: 0.8em;
44
+ }
45
+
46
+ .ep-small-spacing {
47
+ margin-left: 5px;
48
  }
assets/css/font.css CHANGED
File without changes
assets/css/vendor/bootstrap/bootstrap.css.map CHANGED
File without changes
assets/images/index.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>403 Forbidden</title>
5
+ </head>
6
+ <body>
7
+ <p>Directory access is forbidden.</p>
8
+ </body>
9
+ </html>
assets/images/menu-icon.png CHANGED
Binary file
assets/js/preview.js CHANGED
@@ -6,7 +6,7 @@
6
  * @since 1.0
7
  */
8
 
9
- (function(window, $, String, $data) {
10
  "use strict";
11
 
12
  $(window.document).ready(function() {
@@ -154,7 +154,7 @@
154
 
155
  var SHORTCODE_REGEXP = new RegExp('\\[\/?'+ $data.EMBEDPRESS_SHORTCODE +'\\]', "gi");
156
 
157
- var EmbedPressPreview = function() {
158
  var self = this;
159
 
160
  var PLG_SYSTEM_ASSETS_CSS_PATH = $data.EMBEDPRESS_URL_ASSETS +"css";
@@ -761,9 +761,16 @@
761
  url = self.decodeEmbedURLSpecialChars(url, true, customAttributes);
762
  var rawUrl = url.stripShortcode($data.EMBEDPRESS_SHORTCODE);
763
 
 
 
 
 
 
 
 
764
  // Get the parsed embed code from the EmbedPress plugin
765
  self.getParsedContent(url, function getParsedContentCallback(result) {
766
- result.data.content = result.data.content.stripShortcode($data.EMBEDPRESS_SHORTCODE);
767
 
768
  var $wrapper = $(self.getElementInContentById('embedpress_wrapper_' + uid));
769
  var wrapperParent = $($wrapper.parent());
@@ -781,7 +788,7 @@
781
  wrapperParent = null;
782
 
783
  // Check if the url could not be embedded for some reason.
784
- if (rawUrl === result.data.content) {
785
  // Echoes the raw url
786
  $wrapper.replaceWith($('<p>'+ rawUrl +'</p>'));
787
  return;
@@ -792,11 +799,11 @@
792
  // Parse as DOM element
793
  var $content;
794
  try {
795
- $content = $(result.data.content);
796
  } catch(err) {
797
  // Fallback to a div, if the result is not a html markup, e.g. a url
798
  $content = $('<div>');
799
- $content.html(result.data.content);
800
  }
801
 
802
  if (!$('iframe', $content).length) {
@@ -900,8 +907,19 @@
900
  self.appendElementsIntoWrapper($content, $wrapper);
901
  }
902
 
903
- $wrapper.append($('<span class="mce-shim"></span>'));
904
  $wrapper.append($('<span class="wpview-end"></span>'));
 
 
 
 
 
 
 
 
 
 
 
905
  });
906
  };
907
 
@@ -1823,10 +1841,10 @@
1823
  };
1824
  };
1825
 
1826
- if (!window.EmbedPressPreview) {
1827
- window.EmbedPressPreview = new EmbedPressPreview();
1828
  }
1829
 
1830
- window.EmbedPressPreview.init($data.previewSettings);
1831
  });
1832
- })(window, jQuery, String, $data);
6
  * @since 1.0
7
  */
8
 
9
+ (function($, String, $data, undefined) {
10
  "use strict";
11
 
12
  $(window.document).ready(function() {
154
 
155
  var SHORTCODE_REGEXP = new RegExp('\\[\/?'+ $data.EMBEDPRESS_SHORTCODE +'\\]', "gi");
156
 
157
+ var EmbedPress = function() {
158
  var self = this;
159
 
160
  var PLG_SYSTEM_ASSETS_CSS_PATH = $data.EMBEDPRESS_URL_ASSETS +"css";
761
  url = self.decodeEmbedURLSpecialChars(url, true, customAttributes);
762
  var rawUrl = url.stripShortcode($data.EMBEDPRESS_SHORTCODE);
763
 
764
+ $(self).triggerHandler('EmbedPress.beforeEmbed', {
765
+ 'url' : rawUrl,
766
+ 'meta': {
767
+ 'attributes': customAttributes || {}
768
+ }
769
+ });
770
+
771
  // Get the parsed embed code from the EmbedPress plugin
772
  self.getParsedContent(url, function getParsedContentCallback(result) {
773
+ var embeddedContent = (typeof result.data === "object" ? result.data.embed : result.data).stripShortcode($data.EMBEDPRESS_SHORTCODE);
774
 
775
  var $wrapper = $(self.getElementInContentById('embedpress_wrapper_' + uid));
776
  var wrapperParent = $($wrapper.parent());
788
  wrapperParent = null;
789
 
790
  // Check if the url could not be embedded for some reason.
791
+ if (rawUrl === embeddedContent) {
792
  // Echoes the raw url
793
  $wrapper.replaceWith($('<p>'+ rawUrl +'</p>'));
794
  return;
799
  // Parse as DOM element
800
  var $content;
801
  try {
802
+ $content = $(embeddedContent);
803
  } catch(err) {
804
  // Fallback to a div, if the result is not a html markup, e.g. a url
805
  $content = $('<div>');
806
+ $content.html(embeddedContent);
807
  }
808
 
809
  if (!$('iframe', $content).length) {
907
  self.appendElementsIntoWrapper($content, $wrapper);
908
  }
909
 
910
+ //$wrapper.append($('<span class="mce-shim"></span>'));
911
  $wrapper.append($('<span class="wpview-end"></span>'));
912
+
913
+ if (result && result.data && typeof result.data === "object") {
914
+ result.data.width = $($wrapper).width();
915
+ result.data.height = $($wrapper).height();
916
+ }
917
+
918
+ $(self).triggerHandler('EmbedPress.afterEmbed', {
919
+ 'meta' : result.data,
920
+ 'url' : rawUrl,
921
+ 'wrapper': $wrapper
922
+ });
923
  });
924
  };
925
 
1841
  };
1842
  };
1843
 
1844
+ if (!window.EmbedPress) {
1845
+ window.EmbedPress = new EmbedPress();
1846
  }
1847
 
1848
+ window.EmbedPress.init($data.previewSettings);
1849
  });
1850
+ })(jQuery, String, $data);
assets/js/vendor/bootbox.min.js CHANGED
File without changes
autoloader.php CHANGED
File without changes
changelog.txt CHANGED
@@ -1,4 +1,12 @@
1
  == Changelog ==
 
 
 
 
 
 
 
 
2
  = 1.3.1 =
3
  Release Date: 2016-11-14
4
 
1
  == Changelog ==
2
+ = 1.4.0 =
3
+ Release Date: 2017-01-06
4
+
5
+ * Added support to WordPress 4.7;
6
+ * Added support to Embedpress own plugins;
7
+ * Fixed bug that was preventing interaction with some embeds;
8
+ * Code enhancements.
9
+
10
  = 1.3.1 =
11
  Release Date: 2016-11-14
12
 
embedpress.php CHANGED
@@ -12,13 +12,13 @@
12
  * @embedpress
13
  * Plugin Name: EmbedPress
14
  * Plugin URI: http://pressshack.com/embedpress/
15
- * Version: 1.3.1
16
  * Description: WordPress supports around 35 embed sources, but EmbedPress adds over 40 more, including Facebook, Google Maps, Google Docs, UStream! Just use the URL!
17
  * Author: PressShack
18
- * Author URI: http://pressshack.com/
19
  */
20
 
21
- use \EmbedPress\Plugin;
22
 
23
  require_once plugin_dir_path(__FILE__) .'includes.php';
24
 
@@ -26,16 +26,16 @@ require_once plugin_dir_path(__FILE__) .'includes.php';
26
 
27
  function onPluginActivationCallback()
28
  {
29
- Plugin::onPluginActivationCallback();
30
  }
31
 
32
  function onPluginDeactivationCallback()
33
  {
34
- Plugin::onPluginDeactivationCallback();
35
  }
36
 
37
  register_activation_hook(__FILE__, 'onPluginActivationCallback');
38
  register_deactivation_hook(__FILE__, 'onPluginDeactivationCallback');
39
 
40
- $embedPressPlugin = new Plugin();
41
  $embedPressPlugin->initialize();
12
  * @embedpress
13
  * Plugin Name: EmbedPress
14
  * Plugin URI: http://pressshack.com/embedpress/
15
+ * Version: 1.4.0
16
  * Description: WordPress supports around 35 embed sources, but EmbedPress adds over 40 more, including Facebook, Google Maps, Google Docs, UStream! Just use the URL!
17
  * Author: PressShack
18
+ * Author URI: http://pressshack.com
19
  */
20
 
21
+ use \EmbedPress\Core;
22
 
23
  require_once plugin_dir_path(__FILE__) .'includes.php';
24
 
26
 
27
  function onPluginActivationCallback()
28
  {
29
+ Core::onPluginActivationCallback();
30
  }
31
 
32
  function onPluginDeactivationCallback()
33
  {
34
+ Core::onPluginDeactivationCallback();
35
  }
36
 
37
  register_activation_hook(__FILE__, 'onPluginActivationCallback');
38
  register_deactivation_hook(__FILE__, 'onPluginDeactivationCallback');
39
 
40
+ $embedPressPlugin = new Core();
41
  $embedPressPlugin->initialize();
includes.php CHANGED
@@ -11,12 +11,16 @@ defined('ABSPATH') or die("No direct script access allowed.");
11
  * @since 1.0.0
12
  */
13
 
 
 
 
 
14
  if (!defined('EMBEDPRESS_PLG_NAME')) {
15
- define('EMBEDPRESS_PLG_NAME', "embedpress");
16
  }
17
 
18
  if (!defined('EMBEDPRESS_PLG_VERSION')) {
19
- define('EMBEDPRESS_PLG_VERSION', "1.3.1");
20
  }
21
 
22
  if (!defined('EMBEDPRESS_PATH_BASE')) {
@@ -47,8 +51,19 @@ if (!defined('EMBEDPRESS_SHORTCODE')) {
47
  define('EMBEDPRESS_SHORTCODE', "embed");
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  // Run libraries's autoload script
51
  require_once EMBEDPRESS_PATH_LIBRARIES ."autoload.php";
52
  // Run the plugin autoload script
53
  require_once EMBEDPRESS_PATH_BASE ."autoloader.php";
54
- ?>
11
  * @since 1.0.0
12
  */
13
 
14
+ if (!defined('EMBEDPRESS')) {
15
+ define('EMBEDPRESS', "EmbedPress");
16
+ }
17
+
18
  if (!defined('EMBEDPRESS_PLG_NAME')) {
19
+ define('EMBEDPRESS_PLG_NAME', strtolower(EMBEDPRESS));
20
  }
21
 
22
  if (!defined('EMBEDPRESS_PLG_VERSION')) {
23
+ define('EMBEDPRESS_PLG_VERSION', "1.4.0");
24
  }
25
 
26
  if (!defined('EMBEDPRESS_PATH_BASE')) {
51
  define('EMBEDPRESS_SHORTCODE', "embed");
52
  }
53
 
54
+ if (!defined('EMBEDPRESS_LICENSES_API_HOST')) {
55
+ define('EMBEDPRESS_LICENSES_API_HOST', "pressshack.staging.wpengine.com");
56
+ }
57
+
58
+ if (!defined('EMBEDPRESS_LICENSES_API_URL')) {
59
+ define('EMBEDPRESS_LICENSES_API_URL', "http://pressshack.staging.wpengine.com");
60
+ }
61
+
62
+ if (!defined('EMBEDPRESS_LICENSES_MORE_INFO_URL')) {
63
+ define('EMBEDPRESS_LICENSES_MORE_INFO_URL', "https://pressshack.com/embedpress/docs/activate-license");
64
+ }
65
+
66
  // Run libraries's autoload script
67
  require_once EMBEDPRESS_PATH_LIBRARIES ."autoload.php";
68
  // Run the plugin autoload script
69
  require_once EMBEDPRESS_PATH_BASE ."autoloader.php";
 
providers.php CHANGED
File without changes
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: PressShack
3
  Tags: 23hq, amcharts, animoto, bambuser, cacoo, chartblocks, chirbit, circuitlab, cloudup, clyp, collegehumor, coub, crowd ranking, daily mile, dailymotion, devianart, dipity, dotsub, facebook, flickr, funnyordie, gettyimages, github gist, google docs, google drawings, google maps, google sheets, google slides, huffduffer, hulu, imgur, infogram, instagram, issuu, kickstarter, meetup, mixcloud, mobypicture, nfb, photobucket, polldaddy, porfolium, reddit, release wire, reverbnation, roomshare, rutube, sapo videos, scribd, shortnote, shoudio, sketchfab, slideshare, smugmug, soundcloud, speaker deck, spotify, ted, tumblr, twitter, ustream, viddler, videojug, videopress, vimeo, vine, wordpress tv, youtube
4
  Requires at least: 4.0
5
- Tested up to: 4.6.1
6
- Stable tag: 1.3.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -90,6 +90,14 @@ There're two ways to install EmbedPress plugin:
90
  `
91
 
92
  == Changelog ==
 
 
 
 
 
 
 
 
93
  = 1.3.1 =
94
  Release Date: 2016-11-14
95
 
2
  Contributors: PressShack
3
  Tags: 23hq, amcharts, animoto, bambuser, cacoo, chartblocks, chirbit, circuitlab, cloudup, clyp, collegehumor, coub, crowd ranking, daily mile, dailymotion, devianart, dipity, dotsub, facebook, flickr, funnyordie, gettyimages, github gist, google docs, google drawings, google maps, google sheets, google slides, huffduffer, hulu, imgur, infogram, instagram, issuu, kickstarter, meetup, mixcloud, mobypicture, nfb, photobucket, polldaddy, porfolium, reddit, release wire, reverbnation, roomshare, rutube, sapo videos, scribd, shortnote, shoudio, sketchfab, slideshare, smugmug, soundcloud, speaker deck, spotify, ted, tumblr, twitter, ustream, viddler, videojug, videopress, vimeo, vine, wordpress tv, youtube
4
  Requires at least: 4.0
5
+ Tested up to: 4.7
6
+ Stable tag: 1.4.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
90
  `
91
 
92
  == Changelog ==
93
+ = 1.4.0 =
94
+ Release Date: 2017-01-06
95
+
96
+ * Added support to WordPress 4.7;
97
+ * Added support to Embedpress own plugins;
98
+ * Fixed bug that was preventing interaction with some embeds;
99
+ * Code enhancements.
100
+
101
  = 1.3.1 =
102
  Release Date: 2016-11-14
103