Version Description
Download this release
Release Info
| Developer | Asif2BD |
| Plugin | |
| Version | 2.4.1 |
| Comparing to | |
| See all releases | |
Code changes from version 2.4.0 to 2.4.1
- EmbedPress/Core.php +4 -0
- EmbedPress/Ends/Back/Settings.php +104 -94
- EmbedPress/Shortcode.php +207 -213
- Gutenberg/src/init.php +1 -1
- assets/js/settings.js +15 -0
- embedpress.php +1 -1
- includes.php +2 -2
- readme.txt +4 -3
EmbedPress/Core.php
CHANGED
|
@@ -453,6 +453,10 @@ class Core {
|
|
| 453 |
$settings['enablePluginInFront'] = true;
|
| 454 |
}
|
| 455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
if (!isset($settings['enableEmbedResizeHeight'])) {
|
| 457 |
$settings['enableEmbedResizeHeight'] = 552;
|
| 458 |
}
|
| 453 |
$settings['enablePluginInFront'] = true;
|
| 454 |
}
|
| 455 |
|
| 456 |
+
if (!isset($settings['enableGlobalEmbedResize'])) {
|
| 457 |
+
$settings['enableGlobalEmbedResize'] = false;
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
if (!isset($settings['enableEmbedResizeHeight'])) {
|
| 461 |
$settings['enableEmbedResizeHeight'] = 552;
|
| 462 |
}
|
EmbedPress/Ends/Back/Settings.php
CHANGED
|
@@ -4,7 +4,7 @@ namespace EmbedPress\Ends\Back;
|
|
| 4 |
|
| 5 |
use EmbedPress\Compatibility;
|
| 6 |
|
| 7 |
-
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Entity that handles the plugin's settings page.
|
|
@@ -16,8 +16,7 @@ use EmbedPress\Compatibility;
|
|
| 16 |
* @license GPLv2 or later
|
| 17 |
* @since 1.0.0
|
| 18 |
*/
|
| 19 |
-
class Settings
|
| 20 |
-
{
|
| 21 |
/**
|
| 22 |
* This class namespace.
|
| 23 |
*
|
|
@@ -67,8 +66,7 @@ class Settings
|
|
| 67 |
*
|
| 68 |
* @since 1.0.0
|
| 69 |
*/
|
| 70 |
-
public function __construct()
|
| 71 |
-
{
|
| 72 |
}
|
| 73 |
|
| 74 |
/**
|
|
@@ -76,8 +74,7 @@ class Settings
|
|
| 76 |
*
|
| 77 |
* @since 1.0.0
|
| 78 |
*/
|
| 79 |
-
public function __clone()
|
| 80 |
-
{
|
| 81 |
}
|
| 82 |
|
| 83 |
/**
|
|
@@ -86,10 +83,9 @@ class Settings
|
|
| 86 |
* @since 1.0.0
|
| 87 |
* @static
|
| 88 |
*/
|
| 89 |
-
public static function registerMenuItem()
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
[self::$namespace, 'renderForm'], null, 64);
|
| 93 |
}
|
| 94 |
|
| 95 |
/**
|
|
@@ -98,38 +94,41 @@ class Settings
|
|
| 98 |
* @since 1.0.0
|
| 99 |
* @static
|
| 100 |
*/
|
| 101 |
-
public static function registerActions()
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
if ($activeTab !== "embedpress") {
|
| 105 |
$action = "embedpress:{$activeTab}:settings:register";
|
| 106 |
} else {
|
| 107 |
$activeTab = "";
|
| 108 |
}
|
| 109 |
|
| 110 |
-
if ( !
|
| 111 |
-
do_action($action, [
|
| 112 |
'id' => self::$sectionAdminIdentifier,
|
| 113 |
'slug' => self::$identifier,
|
| 114 |
-
]);
|
| 115 |
} else {
|
| 116 |
-
register_setting(self::$sectionGroupIdentifier, self::$sectionGroupIdentifier,
|
| 117 |
-
[self::$namespace, "validateForm"]);
|
| 118 |
|
| 119 |
-
add_settings_section(self::$sectionAdminIdentifier, '', null, self::$identifier);
|
| 120 |
|
| 121 |
$fieldMap = [];
|
| 122 |
-
if ( !
|
| 123 |
$fieldMap = [
|
| 124 |
-
'enablePluginInAdmin'
|
| 125 |
'label' => "Load previews in the admin editor",
|
| 126 |
'section' => "admin",
|
| 127 |
],
|
| 128 |
-
'enablePluginInFront'
|
| 129 |
'label' => "Load previews in the frontend editor",
|
| 130 |
'section' => "admin",
|
| 131 |
],
|
| 132 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
'label' => "Embed Iframe Width",
|
| 134 |
'section' => "admin",
|
| 135 |
],
|
|
@@ -145,9 +144,9 @@ class Settings
|
|
| 145 |
'section' => "admin",
|
| 146 |
];
|
| 147 |
|
| 148 |
-
foreach ($fieldMap as $fieldName => $field) {
|
| 149 |
-
add_settings_field($fieldName, $field['label'], [self::$namespace, "renderField_{$fieldName}"],
|
| 150 |
-
self::$identifier, self::${"section" . ucfirst($field['section']) . "Identifier"});
|
| 151 |
}
|
| 152 |
}
|
| 153 |
}
|
|
@@ -155,25 +154,23 @@ class Settings
|
|
| 155 |
/**
|
| 156 |
* Returns true if the plugin is active
|
| 157 |
*
|
| 158 |
-
* @param
|
| 159 |
*
|
| 160 |
* @return boolean
|
| 161 |
*/
|
| 162 |
-
protected static function is_plugin_active($plugin)
|
| 163 |
-
|
| 164 |
-
return is_plugin_active("{$plugin}/{$plugin}.php");
|
| 165 |
}
|
| 166 |
|
| 167 |
/**
|
| 168 |
* Returns true if the plugin is installed
|
| 169 |
*
|
| 170 |
-
* @param
|
| 171 |
*
|
| 172 |
* @return boolean
|
| 173 |
*/
|
| 174 |
-
protected static function is_plugin_installed($plugin)
|
| 175 |
-
|
| 176 |
-
return file_exists(plugin_dir_path(EMBEDPRESS_ROOT) . "{$plugin}/{$plugin}.php");
|
| 177 |
}
|
| 178 |
|
| 179 |
/**
|
|
@@ -182,17 +179,16 @@ class Settings
|
|
| 182 |
* @since 1.0.0
|
| 183 |
* @static
|
| 184 |
*/
|
| 185 |
-
public static function renderForm()
|
| 186 |
-
{
|
| 187 |
// Add the color picker css file
|
| 188 |
-
wp_enqueue_style('wp-color-picker');
|
| 189 |
// Include our custom jQuery file with WordPress Color Picker dependency
|
| 190 |
-
wp_enqueue_script('ep-settings', EMBEDPRESS_URL_ASSETS . 'js/settings.js', ['wp-color-picker'],
|
| 191 |
-
EMBEDPRESS_VERSION, true);
|
| 192 |
|
| 193 |
-
$activeTab = isset($_GET['tab']) ? strtolower($_GET['tab']) : "";
|
| 194 |
-
$settingsFieldsIdentifier = !
|
| 195 |
-
$settingsSectionsIdentifier = !
|
| 196 |
?>
|
| 197 |
<div id="embedpress-settings-wrapper">
|
| 198 |
<header>
|
|
@@ -208,25 +204,26 @@ class Settings
|
|
| 208 |
<div>
|
| 209 |
<h2 class="nav-tab-wrapper">
|
| 210 |
<a href="?page=embedpress"
|
| 211 |
-
class="nav-tab<?php echo $activeTab === 'embedpress' || empty($activeTab) ? ' nav-tab-active' : ''; ?> ">
|
| 212 |
General settings
|
| 213 |
</a>
|
| 214 |
-
<?php do_action('embedpress:settings:render:tab', $activeTab); ?>
|
| 215 |
-
<?php do_action('embedpress_license_tab'
|
| 216 |
|
| 217 |
</h2>
|
| 218 |
|
| 219 |
-
<?php if ($activeTab !== 'addons') : ?>
|
| 220 |
<form action="options.php" method="POST" style="padding-bottom: 20px;">
|
| 221 |
-
<?php settings_fields($settingsFieldsIdentifier); ?>
|
| 222 |
-
<?php do_settings_sections($settingsSectionsIdentifier); ?>
|
| 223 |
-
<?php if ($activeTab !== 'embedpress_license') : ?>
|
| 224 |
-
<button type="submit" class="button button-primary embedpress-setting-save">Save changes
|
|
|
|
| 225 |
<?php endif; ?>
|
| 226 |
</form>
|
| 227 |
<?php endif; ?>
|
| 228 |
-
<?php if ($activeTab == 'embedpress_license') : ?>
|
| 229 |
-
|
| 230 |
<?php endif; ?>
|
| 231 |
</div>
|
| 232 |
|
|
@@ -288,21 +285,21 @@ class Settings
|
|
| 288 |
/**
|
| 289 |
* Method that validates the form data.
|
| 290 |
*
|
|
|
|
|
|
|
|
|
|
| 291 |
* @since 1.0.0
|
| 292 |
* @static
|
| 293 |
*
|
| 294 |
-
* @param mixed $freshData Data received from the form.
|
| 295 |
-
*
|
| 296 |
-
* @return array
|
| 297 |
*/
|
| 298 |
-
public static function validateForm($freshData)
|
| 299 |
-
{
|
| 300 |
$data = [
|
| 301 |
-
'enablePluginInAdmin'
|
| 302 |
-
'enablePluginInFront'
|
| 303 |
-
'
|
| 304 |
-
'
|
| 305 |
-
'
|
|
|
|
| 306 |
];
|
| 307 |
|
| 308 |
return $data;
|
|
@@ -314,15 +311,14 @@ class Settings
|
|
| 314 |
* @since 1.0.0
|
| 315 |
* @static
|
| 316 |
*/
|
| 317 |
-
public static function renderField_enablePluginInAdmin()
|
| 318 |
-
{
|
| 319 |
$fieldName = "enablePluginInAdmin";
|
| 320 |
|
| 321 |
-
$options = get_option(self::$sectionGroupIdentifier);
|
| 322 |
|
| 323 |
-
$options[$fieldName] = !
|
| 324 |
|
| 325 |
-
echo '<label><input type="radio" id="' . $fieldName . '_0" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="0" ' . (
|
| 326 |
echo " ";
|
| 327 |
echo '<label><input type="radio" id="' . $fieldName . '_1" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="1" ' . ($options[$fieldName] ? "checked" : "") . ' /> Yes</label>';
|
| 328 |
echo '<p class="description">Do you want EmbedPress to run here in the admin area? Disabling this <strong>will not</strong> affect your frontend embeds.</p>';
|
|
@@ -334,37 +330,54 @@ class Settings
|
|
| 334 |
* @since 1.6.0
|
| 335 |
* @static
|
| 336 |
*/
|
| 337 |
-
public static function renderField_enablePluginInFront()
|
| 338 |
-
{
|
| 339 |
$fieldName = "enablePluginInFront";
|
| 340 |
|
| 341 |
-
$options = get_option(self::$sectionGroupIdentifier);
|
| 342 |
|
| 343 |
-
$options[$fieldName] = !
|
| 344 |
|
| 345 |
-
echo '<label><input type="radio" id="' . $fieldName . '_0" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="0" ' . (
|
| 346 |
echo " ";
|
| 347 |
echo '<label><input type="radio" id="' . $fieldName . '_1" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="1" ' . ($options[$fieldName] ? "checked" : "") . ' /> Yes</label>';
|
| 348 |
echo '<p class="description">Do you want EmbedPress to run within editors in frontend (if there\'s any)? Disabling this <strong>will not</strong> affect embeds seem by your regular users in frontend.</p>';
|
| 349 |
}
|
| 350 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
/**
|
| 352 |
* Method that renders the enableEmbedResizeHeight input.
|
| 353 |
*
|
| 354 |
* @since 2.4.0
|
| 355 |
* @static
|
| 356 |
*/
|
| 357 |
-
public static function renderField_enableEmbedResizeHeight()
|
| 358 |
-
{
|
| 359 |
$fieldName = "enableEmbedResizeHeight";
|
| 360 |
|
| 361 |
-
$options = get_option(self::$sectionGroupIdentifier);
|
| 362 |
|
| 363 |
-
$value = !
|
| 364 |
|
| 365 |
-
echo '<input type="number" value="'.absint($value).'" class="regular-text" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 366 |
|
| 367 |
-
echo '<p class="description">Global Embed Iframe Height</p>';
|
| 368 |
}
|
| 369 |
|
| 370 |
/**
|
|
@@ -373,14 +386,13 @@ class Settings
|
|
| 373 |
* @since 2.4.0
|
| 374 |
* @static
|
| 375 |
*/
|
| 376 |
-
public static function renderField_enableEmbedResizeWidth()
|
| 377 |
-
{
|
| 378 |
$fieldName = "enableEmbedResizeWidth";
|
| 379 |
-
$options
|
| 380 |
-
$value
|
| 381 |
|
| 382 |
-
echo '<input type="number" value="'.absint($value).'" class="regular-text" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 383 |
-
echo '<p class="description">Global Embed Iframe Width </p>';
|
| 384 |
}
|
| 385 |
|
| 386 |
/**
|
|
@@ -389,20 +401,19 @@ class Settings
|
|
| 389 |
* @since 1.3.0
|
| 390 |
* @static
|
| 391 |
*/
|
| 392 |
-
public static function renderField_forceFacebookLanguage()
|
| 393 |
-
{
|
| 394 |
$fieldName = "fbLanguage";
|
| 395 |
|
| 396 |
-
$options = get_option(self::$sectionGroupIdentifier);
|
| 397 |
|
| 398 |
-
$options[$fieldName] = !
|
| 399 |
|
| 400 |
$facebookLocales = self::getFacebookAvailableLocales();
|
| 401 |
|
| 402 |
echo '<select name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 403 |
echo '<option value="0">Automatic (by Facebook)</option>';
|
| 404 |
echo '<optgroup label="Available">';
|
| 405 |
-
foreach ($facebookLocales as $locale => $localeName) {
|
| 406 |
echo '<option value="' . $locale . '"' . ($options[$fieldName] === $locale ? ' selected' : '') . '>' . $localeName . '</option>';
|
| 407 |
}
|
| 408 |
echo '</optgroup>';
|
|
@@ -414,13 +425,12 @@ class Settings
|
|
| 414 |
/**
|
| 415 |
* Returns a list of locales that can be used on Facebook embeds.
|
| 416 |
*
|
|
|
|
| 417 |
* @since 1.3.0
|
| 418 |
* @static
|
| 419 |
*
|
| 420 |
-
* @return array
|
| 421 |
*/
|
| 422 |
-
public static function getFacebookAvailableLocales()
|
| 423 |
-
{
|
| 424 |
$locales = [
|
| 425 |
'af_ZA' => "Afrikaans",
|
| 426 |
'ak_GH' => "Akan",
|
| 4 |
|
| 5 |
use EmbedPress\Compatibility;
|
| 6 |
|
| 7 |
+
(defined( 'ABSPATH' ) && defined( 'EMBEDPRESS_IS_LOADED' )) or die( "No direct script access allowed." );
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Entity that handles the plugin's settings page.
|
| 16 |
* @license GPLv2 or later
|
| 17 |
* @since 1.0.0
|
| 18 |
*/
|
| 19 |
+
class Settings {
|
|
|
|
| 20 |
/**
|
| 21 |
* This class namespace.
|
| 22 |
*
|
| 66 |
*
|
| 67 |
* @since 1.0.0
|
| 68 |
*/
|
| 69 |
+
public function __construct() {
|
|
|
|
| 70 |
}
|
| 71 |
|
| 72 |
/**
|
| 74 |
*
|
| 75 |
* @since 1.0.0
|
| 76 |
*/
|
| 77 |
+
public function __clone() {
|
|
|
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 83 |
* @since 1.0.0
|
| 84 |
* @static
|
| 85 |
*/
|
| 86 |
+
public static function registerMenuItem() {
|
| 87 |
+
add_menu_page( 'EmbedPress Settings', 'EmbedPress', 'manage_options', 'embedpress',
|
| 88 |
+
[ self::$namespace, 'renderForm' ], null, 64 );
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
/**
|
| 94 |
* @since 1.0.0
|
| 95 |
* @static
|
| 96 |
*/
|
| 97 |
+
public static function registerActions() {
|
| 98 |
+
$activeTab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : "";
|
| 99 |
+
if ( $activeTab !== "embedpress" ) {
|
|
|
|
| 100 |
$action = "embedpress:{$activeTab}:settings:register";
|
| 101 |
} else {
|
| 102 |
$activeTab = "";
|
| 103 |
}
|
| 104 |
|
| 105 |
+
if ( !empty( $activeTab ) && has_action( $action ) ) {
|
| 106 |
+
do_action( $action, [
|
| 107 |
'id' => self::$sectionAdminIdentifier,
|
| 108 |
'slug' => self::$identifier,
|
| 109 |
+
] );
|
| 110 |
} else {
|
| 111 |
+
register_setting( self::$sectionGroupIdentifier, self::$sectionGroupIdentifier,
|
| 112 |
+
[ self::$namespace, "validateForm" ] );
|
| 113 |
|
| 114 |
+
add_settings_section( self::$sectionAdminIdentifier, '', null, self::$identifier );
|
| 115 |
|
| 116 |
$fieldMap = [];
|
| 117 |
+
if ( !Compatibility::isWordPress5() || Compatibility::isClassicalEditorActive() ) {
|
| 118 |
$fieldMap = [
|
| 119 |
+
'enablePluginInAdmin' => [
|
| 120 |
'label' => "Load previews in the admin editor",
|
| 121 |
'section' => "admin",
|
| 122 |
],
|
| 123 |
+
'enablePluginInFront' => [
|
| 124 |
'label' => "Load previews in the frontend editor",
|
| 125 |
'section' => "admin",
|
| 126 |
],
|
| 127 |
+
'enableGlobalEmbedResize' => [
|
| 128 |
+
'label' => "Enable Global Embed Dimension",
|
| 129 |
+
'section' => "admin",
|
| 130 |
+
],
|
| 131 |
+
'enableEmbedResizeWidth' => [
|
| 132 |
'label' => "Embed Iframe Width",
|
| 133 |
'section' => "admin",
|
| 134 |
],
|
| 144 |
'section' => "admin",
|
| 145 |
];
|
| 146 |
|
| 147 |
+
foreach ( $fieldMap as $fieldName => $field ) {
|
| 148 |
+
add_settings_field( $fieldName, $field['label'], [ self::$namespace, "renderField_{$fieldName}" ],
|
| 149 |
+
self::$identifier, self::${"section" . ucfirst( $field['section'] ) . "Identifier"} );
|
| 150 |
}
|
| 151 |
}
|
| 152 |
}
|
| 154 |
/**
|
| 155 |
* Returns true if the plugin is active
|
| 156 |
*
|
| 157 |
+
* @param string $plugin
|
| 158 |
*
|
| 159 |
* @return boolean
|
| 160 |
*/
|
| 161 |
+
protected static function is_plugin_active( $plugin ) {
|
| 162 |
+
return is_plugin_active( "{$plugin}/{$plugin}.php" );
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
/**
|
| 166 |
* Returns true if the plugin is installed
|
| 167 |
*
|
| 168 |
+
* @param string $plugin
|
| 169 |
*
|
| 170 |
* @return boolean
|
| 171 |
*/
|
| 172 |
+
protected static function is_plugin_installed( $plugin ) {
|
| 173 |
+
return file_exists( plugin_dir_path( EMBEDPRESS_ROOT ) . "{$plugin}/{$plugin}.php" );
|
|
|
|
| 174 |
}
|
| 175 |
|
| 176 |
/**
|
| 179 |
* @since 1.0.0
|
| 180 |
* @static
|
| 181 |
*/
|
| 182 |
+
public static function renderForm() {
|
|
|
|
| 183 |
// Add the color picker css file
|
| 184 |
+
wp_enqueue_style( 'wp-color-picker' );
|
| 185 |
// Include our custom jQuery file with WordPress Color Picker dependency
|
| 186 |
+
wp_enqueue_script( 'ep-settings', EMBEDPRESS_URL_ASSETS . 'js/settings.js', [ 'wp-color-picker' ],
|
| 187 |
+
EMBEDPRESS_VERSION, true );
|
| 188 |
|
| 189 |
+
$activeTab = isset( $_GET['tab'] ) ? strtolower( $_GET['tab'] ) : "";
|
| 190 |
+
$settingsFieldsIdentifier = !empty( $activeTab ) ? "embedpress:{$activeTab}" : self::$sectionGroupIdentifier;
|
| 191 |
+
$settingsSectionsIdentifier = !empty( $activeTab ) ? "embedpress:{$activeTab}" : self::$identifier;
|
| 192 |
?>
|
| 193 |
<div id="embedpress-settings-wrapper">
|
| 194 |
<header>
|
| 204 |
<div>
|
| 205 |
<h2 class="nav-tab-wrapper">
|
| 206 |
<a href="?page=embedpress"
|
| 207 |
+
class="nav-tab<?php echo $activeTab === 'embedpress' || empty( $activeTab ) ? ' nav-tab-active' : ''; ?> ">
|
| 208 |
General settings
|
| 209 |
</a>
|
| 210 |
+
<?php do_action( 'embedpress:settings:render:tab', $activeTab ); ?>
|
| 211 |
+
<?php do_action( 'embedpress_license_tab', $activeTab ); ?>
|
| 212 |
|
| 213 |
</h2>
|
| 214 |
|
| 215 |
+
<?php if ( $activeTab !== 'addons' ) : ?>
|
| 216 |
<form action="options.php" method="POST" style="padding-bottom: 20px;">
|
| 217 |
+
<?php settings_fields( $settingsFieldsIdentifier ); ?>
|
| 218 |
+
<?php do_settings_sections( $settingsSectionsIdentifier ); ?>
|
| 219 |
+
<?php if ( $activeTab !== 'embedpress_license' ) : ?>
|
| 220 |
+
<button type="submit" class="button button-primary embedpress-setting-save">Save changes
|
| 221 |
+
</button>
|
| 222 |
<?php endif; ?>
|
| 223 |
</form>
|
| 224 |
<?php endif; ?>
|
| 225 |
+
<?php if ( $activeTab == 'embedpress_license' ) : ?>
|
| 226 |
+
<?php echo do_action( 'embedpress_license' ); ?>
|
| 227 |
<?php endif; ?>
|
| 228 |
</div>
|
| 229 |
|
| 285 |
/**
|
| 286 |
* Method that validates the form data.
|
| 287 |
*
|
| 288 |
+
* @param mixed $freshData Data received from the form.
|
| 289 |
+
*
|
| 290 |
+
* @return array
|
| 291 |
* @since 1.0.0
|
| 292 |
* @static
|
| 293 |
*
|
|
|
|
|
|
|
|
|
|
| 294 |
*/
|
| 295 |
+
public static function validateForm( $freshData ) {
|
|
|
|
| 296 |
$data = [
|
| 297 |
+
'enablePluginInAdmin' => isset( $freshData['enablePluginInAdmin'] ) ? (bool)$freshData['enablePluginInAdmin'] : true,
|
| 298 |
+
'enablePluginInFront' => isset( $freshData['enablePluginInFront'] ) ? (bool)$freshData['enablePluginInFront'] : true,
|
| 299 |
+
'enableGlobalEmbedResize' => isset( $freshData['enableGlobalEmbedResize'] ) ? (bool)$freshData['enableGlobalEmbedResize'] : false,
|
| 300 |
+
'enableEmbedResizeHeight' => isset( $freshData['enableEmbedResizeHeight'] ) ? $freshData['enableEmbedResizeHeight'] : 552,
|
| 301 |
+
'enableEmbedResizeWidth' => isset( $freshData['enableEmbedResizeWidth'] ) ? $freshData['enableEmbedResizeWidth'] : 652,
|
| 302 |
+
'fbLanguage' => $freshData['fbLanguage'],
|
| 303 |
];
|
| 304 |
|
| 305 |
return $data;
|
| 311 |
* @since 1.0.0
|
| 312 |
* @static
|
| 313 |
*/
|
| 314 |
+
public static function renderField_enablePluginInAdmin() {
|
|
|
|
| 315 |
$fieldName = "enablePluginInAdmin";
|
| 316 |
|
| 317 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 318 |
|
| 319 |
+
$options[$fieldName] = !isset( $options[$fieldName] ) ? true : (bool)$options[$fieldName];
|
| 320 |
|
| 321 |
+
echo '<label><input type="radio" id="' . $fieldName . '_0" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="0" ' . (!$options[$fieldName] ? "checked" : "") . ' /> No</label>';
|
| 322 |
echo " ";
|
| 323 |
echo '<label><input type="radio" id="' . $fieldName . '_1" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="1" ' . ($options[$fieldName] ? "checked" : "") . ' /> Yes</label>';
|
| 324 |
echo '<p class="description">Do you want EmbedPress to run here in the admin area? Disabling this <strong>will not</strong> affect your frontend embeds.</p>';
|
| 330 |
* @since 1.6.0
|
| 331 |
* @static
|
| 332 |
*/
|
| 333 |
+
public static function renderField_enablePluginInFront() {
|
|
|
|
| 334 |
$fieldName = "enablePluginInFront";
|
| 335 |
|
| 336 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 337 |
|
| 338 |
+
$options[$fieldName] = !isset( $options[$fieldName] ) ? true : (bool)$options[$fieldName];
|
| 339 |
|
| 340 |
+
echo '<label><input type="radio" id="' . $fieldName . '_0" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="0" ' . (!$options[$fieldName] ? "checked" : "") . ' /> No</label>';
|
| 341 |
echo " ";
|
| 342 |
echo '<label><input type="radio" id="' . $fieldName . '_1" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="1" ' . ($options[$fieldName] ? "checked" : "") . ' /> Yes</label>';
|
| 343 |
echo '<p class="description">Do you want EmbedPress to run within editors in frontend (if there\'s any)? Disabling this <strong>will not</strong> affect embeds seem by your regular users in frontend.</p>';
|
| 344 |
}
|
| 345 |
|
| 346 |
+
/**
|
| 347 |
+
* Method that renders the enablePluginInAdmin input.
|
| 348 |
+
*
|
| 349 |
+
* @since 2.4.1
|
| 350 |
+
* @static
|
| 351 |
+
*/
|
| 352 |
+
public static function renderField_enableGlobalEmbedResize() {
|
| 353 |
+
$fieldName = "enableGlobalEmbedResize";
|
| 354 |
+
|
| 355 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 356 |
+
|
| 357 |
+
$options[$fieldName] = !isset( $options[$fieldName] ) ? false : (bool)$options[$fieldName];
|
| 358 |
+
|
| 359 |
+
echo '<label><input class="enableglobalembedresize" type="radio" id="' . $fieldName . '_0" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="0" ' . (!$options[$fieldName] ? "checked" : "") . ' /> No</label>';
|
| 360 |
+
echo " ";
|
| 361 |
+
echo '<label><input class="enableglobalembedresize" type="radio" id="' . $fieldName . '_1" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']" value="1" ' . ($options[$fieldName] ? "checked" : "") . ' /> Yes</label>';
|
| 362 |
+
echo '<p class="description">Do you want use global embed dimension, Disabling this <strong>will not</strong> affect embeds.</p>';
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
/**
|
| 366 |
* Method that renders the enableEmbedResizeHeight input.
|
| 367 |
*
|
| 368 |
* @since 2.4.0
|
| 369 |
* @static
|
| 370 |
*/
|
| 371 |
+
public static function renderField_enableEmbedResizeHeight() {
|
|
|
|
| 372 |
$fieldName = "enableEmbedResizeHeight";
|
| 373 |
|
| 374 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 375 |
|
| 376 |
+
$value = !isset( $options[$fieldName] ) ? '552' : $options[$fieldName];
|
| 377 |
|
| 378 |
+
echo '<span class="embedpress-allow-globla-dimension"><input type="number" value="' . absint( $value ) . '" class="regular-text" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 379 |
|
| 380 |
+
echo '<p class="description">Global Embed Iframe Height</p></span>';
|
| 381 |
}
|
| 382 |
|
| 383 |
/**
|
| 386 |
* @since 2.4.0
|
| 387 |
* @static
|
| 388 |
*/
|
| 389 |
+
public static function renderField_enableEmbedResizeWidth() {
|
|
|
|
| 390 |
$fieldName = "enableEmbedResizeWidth";
|
| 391 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 392 |
+
$value = !isset( $options[$fieldName] ) ? '652' : $options[$fieldName];
|
| 393 |
|
| 394 |
+
echo '<span class="embedpress-allow-globla-dimension"><input type="number" value="' . absint( $value ) . '" class="regular-text" name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 395 |
+
echo '<p class="description">Global Embed Iframe Width </p></span>';
|
| 396 |
}
|
| 397 |
|
| 398 |
/**
|
| 401 |
* @since 1.3.0
|
| 402 |
* @static
|
| 403 |
*/
|
| 404 |
+
public static function renderField_forceFacebookLanguage() {
|
|
|
|
| 405 |
$fieldName = "fbLanguage";
|
| 406 |
|
| 407 |
+
$options = get_option( self::$sectionGroupIdentifier );
|
| 408 |
|
| 409 |
+
$options[$fieldName] = !isset( $options[$fieldName] ) ? "" : $options[$fieldName];
|
| 410 |
|
| 411 |
$facebookLocales = self::getFacebookAvailableLocales();
|
| 412 |
|
| 413 |
echo '<select name="' . self::$sectionGroupIdentifier . '[' . $fieldName . ']">';
|
| 414 |
echo '<option value="0">Automatic (by Facebook)</option>';
|
| 415 |
echo '<optgroup label="Available">';
|
| 416 |
+
foreach ( $facebookLocales as $locale => $localeName ) {
|
| 417 |
echo '<option value="' . $locale . '"' . ($options[$fieldName] === $locale ? ' selected' : '') . '>' . $localeName . '</option>';
|
| 418 |
}
|
| 419 |
echo '</optgroup>';
|
| 425 |
/**
|
| 426 |
* Returns a list of locales that can be used on Facebook embeds.
|
| 427 |
*
|
| 428 |
+
* @return array
|
| 429 |
* @since 1.3.0
|
| 430 |
* @static
|
| 431 |
*
|
|
|
|
| 432 |
*/
|
| 433 |
+
public static function getFacebookAvailableLocales() {
|
|
|
|
| 434 |
$locales = [
|
| 435 |
'af_ZA' => "Afrikaans",
|
| 436 |
'ak_GH' => "Akan",
|
EmbedPress/Shortcode.php
CHANGED
|
@@ -5,7 +5,7 @@ namespace EmbedPress;
|
|
| 5 |
use Embera\Embera;
|
| 6 |
use Embera\Formatter;
|
| 7 |
|
| 8 |
-
(defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed.");
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Entity responsible to handle the plugin's shortcode events and behaviors.
|
|
@@ -16,8 +16,7 @@ use Embera\Formatter;
|
|
| 16 |
* @license GPLv2 or later
|
| 17 |
* @since 1.0.0
|
| 18 |
*/
|
| 19 |
-
class Shortcode
|
| 20 |
-
{
|
| 21 |
/**
|
| 22 |
* The WP_oEmbed class instance.
|
| 23 |
*
|
|
@@ -32,68 +31,69 @@ class Shortcode
|
|
| 32 |
/**
|
| 33 |
* Register the plugin's shortcode into WordPress.
|
| 34 |
*
|
|
|
|
| 35 |
* @since 1.0.0
|
| 36 |
* @static
|
| 37 |
*
|
| 38 |
-
* @return void
|
| 39 |
*/
|
| 40 |
-
public static function register()
|
| 41 |
-
{
|
| 42 |
// Register the new shortcode for embeds.
|
| 43 |
-
add_shortcode(EMBEDPRESS_SHORTCODE, ['\\EmbedPress\\Shortcode', 'do_shortcode']);
|
| 44 |
-
add_shortcode('embed_oembed_html', ['\\EmbedPress\\Shortcode', 'do_shortcode']);
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Method that converts the plugin shortcoded-string into its complex content.
|
| 49 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
* @since 1.0.0
|
| 51 |
* @static
|
| 52 |
*
|
| 53 |
-
* @param array $attributes Array of attributes
|
| 54 |
-
* @param string $subject The given string
|
| 55 |
-
*
|
| 56 |
-
* @return string
|
| 57 |
*/
|
| 58 |
|
| 59 |
-
public static function do_shortcode($attributes = [], $subject = null)
|
| 60 |
-
{
|
| 61 |
$plgSettings = Core::getSettings();
|
| 62 |
-
$
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
return is_object($embed) ? $embed->embed : $embed;
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 72 |
* Replace a given content with its embeded HTML code.
|
| 73 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
* @since 1.0.0
|
| 75 |
* @static
|
| 76 |
*
|
| 77 |
-
* @param string The raw content that will be replaced.
|
| 78 |
-
* @param boolean Optional. If true, new lines at the end of the embeded code are stripped.
|
| 79 |
-
*
|
| 80 |
-
* @return string
|
| 81 |
*/
|
| 82 |
-
public static function parseContent($subject, $stripNewLine = false, $customAttributes = [])
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
$customAttributes = self::parseContentAttributesFromString($subject);
|
| 87 |
}
|
| 88 |
|
| 89 |
-
$content = preg_replace('/(\[' . EMBEDPRESS_SHORTCODE . '(?:\]|.+?\])|\[\/' . EMBEDPRESS_SHORTCODE . '\])/i',
|
| 90 |
-
"", $subject);
|
| 91 |
|
| 92 |
// Converts any special HTML entities back to characters.
|
| 93 |
-
$content = htmlspecialchars_decode($content);
|
| 94 |
|
| 95 |
// Check if the WP_oEmbed class is loaded
|
| 96 |
-
if ( !
|
| 97 |
require_once ABSPATH . 'wp-includes/class-wp-oembed.php';
|
| 98 |
|
| 99 |
self::$oEmbedInstance = _wp_oembed_get_object();
|
|
@@ -103,205 +103,205 @@ class Shortcode
|
|
| 103 |
'params' => [],
|
| 104 |
];
|
| 105 |
|
| 106 |
-
$content_uid = md5($content);
|
| 107 |
|
| 108 |
-
$attributes = self::parseContentAttributes($customAttributes, $content_uid);
|
| 109 |
-
if (isset($attributes['width']) || isset($attributes['height'])) {
|
| 110 |
-
if (isset($attributes['width'])) {
|
| 111 |
$emberaInstanceSettings['params']['width'] = $attributes['width'];
|
| 112 |
-
unset($attributes['width']);
|
| 113 |
}
|
| 114 |
|
| 115 |
-
if (isset($attributes['height'])) {
|
| 116 |
$emberaInstanceSettings['params']['height'] = $attributes['height'];
|
| 117 |
-
unset($attributes['height']);
|
| 118 |
}
|
| 119 |
}
|
| 120 |
|
| 121 |
// Identify what service provider the shortcode's link belongs to
|
| 122 |
-
$serviceProvider = self::$oEmbedInstance->get_provider($content);
|
| 123 |
|
| 124 |
|
| 125 |
// Check if OEmbed was unable to detect the url service provider.
|
| 126 |
-
if (empty($serviceProvider)) {
|
| 127 |
// Attempt to do the same using Embera.
|
| 128 |
-
$emberaInstance = new Embera($emberaInstanceSettings);
|
| 129 |
// Add support to the user's custom service providers
|
| 130 |
$additionalServiceProviders = Core::getAdditionalServiceProviders();
|
| 131 |
-
if ( !
|
| 132 |
-
foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
|
| 133 |
-
self::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $emberaInstance);
|
| 134 |
}
|
| 135 |
|
| 136 |
-
unset($serviceProviderUrls, $serviceProviderClassName);
|
| 137 |
}
|
| 138 |
|
| 139 |
// Attempt to fetch more info about the url-embed.
|
| 140 |
-
$urlData = $emberaInstance->getUrlInfo($content);
|
| 141 |
} else {
|
| 142 |
// Attempt to fetch more info about the url-embed.
|
| 143 |
-
$urlData = self::$oEmbedInstance->fetch($serviceProvider, $content, $attributes);
|
| 144 |
}
|
| 145 |
|
| 146 |
// Sanitize the data
|
| 147 |
-
$urlData = self::sanitizeUrlData($urlData);
|
| 148 |
|
| 149 |
// Stores the original content
|
| 150 |
-
if (is_object($urlData)) {
|
| 151 |
$urlData->originalContent = $content;
|
| 152 |
}
|
| 153 |
|
| 154 |
-
$eventResults = apply_filters('embedpress:onBeforeEmbed', $urlData);
|
| 155 |
-
if (empty($eventResults)) {
|
| 156 |
// EmbedPress seems unable to embed the url.
|
| 157 |
return $subject;
|
| 158 |
}
|
| 159 |
|
| 160 |
// Transform all shortcode attributes into html form. I.e.: {foo: "joe"} -> foo="joe"
|
| 161 |
$attributesHtml = [];
|
| 162 |
-
foreach ($attributes as $attrName => $attrValue) {
|
| 163 |
$attributesHtml[] = $attrName . '="' . $attrValue . '"';
|
| 164 |
}
|
| 165 |
|
| 166 |
// Define the EmbedPress html template where the generated embed will be injected in
|
| 167 |
-
$embedTemplate = '<div ' . implode(' ', $attributesHtml) . '>{html}</div>';
|
| 168 |
|
| 169 |
// Check if $content is a google shortened url and tries to extract from it which Google service it refers to.
|
| 170 |
-
if (preg_match('/http[s]?:\/\/goo\.gl\/(?:([a-z]+)\/)?[a-z0-9]+\/?$/i', $content, $matches)) {
|
| 171 |
// Fetch all headers from the short-url so we can know how to handle its original content depending on the service.
|
| 172 |
-
$headers = get_headers($content);
|
| 173 |
|
| 174 |
$supportedServicesHeadersPatterns = [
|
| 175 |
'maps' => '/^Location:\s+(http[s]?:\/\/.+)$/i',
|
| 176 |
];
|
| 177 |
|
| 178 |
-
$service = isset($matches[1]) ? strtolower($matches[1]) : null;
|
| 179 |
// No specific service was found in the url.
|
| 180 |
-
if (empty($service)) {
|
| 181 |
// Let's try to guess which service the original url belongs to.
|
| 182 |
-
foreach ($headers as $header) {
|
| 183 |
// Check if the short-url reffers to a Google Maps url.
|
| 184 |
-
if (preg_match($supportedServicesHeadersPatterns['maps'], $header, $matches)) {
|
| 185 |
// Replace the shortened url with its original url.
|
| 186 |
$content = $matches[1];
|
| 187 |
break;
|
| 188 |
}
|
| 189 |
}
|
| 190 |
-
unset($header);
|
| 191 |
} else {
|
| 192 |
// Check if the Google service is supported atm.
|
| 193 |
-
if (isset($supportedServicesHeadersPatterns[$service])) {
|
| 194 |
// Tries to extract the url based on its headers.
|
| 195 |
-
$originalUrl = self::extractContentFromHeaderAsArray($supportedServicesHeadersPatterns[$service],
|
| 196 |
-
$headers);
|
| 197 |
// Replace the shortened url with its original url if the specific header was found.
|
| 198 |
-
if ( !
|
| 199 |
$content = $originalUrl;
|
| 200 |
}
|
| 201 |
-
unset($originalUrl);
|
| 202 |
}
|
| 203 |
}
|
| 204 |
-
unset($service, $supportedServicesHeadersPatterns, $headers, $matches);
|
| 205 |
}
|
| 206 |
|
| 207 |
// Facebook is a special case. WordPress will try to embed them using OEmbed, but they always end up embedding the profile page, regardless
|
| 208 |
// if the url was pointing to a photo, a post, etc. So, since Embera can embed only facebook-media/posts, we'll use it only for that.
|
| 209 |
-
if (isset($urlData->provider_name) && in_array($urlData->provider_name, ['Facebook'])) {
|
| 210 |
// Check if this is a Facebook profile url.
|
| 211 |
-
if (preg_match('/facebook\.com\/(?:[^\/]+?)\/?$/', $content, $match)) {
|
| 212 |
// Try to embed the url using WP's OSEmbed.
|
| 213 |
-
$parsedContent = self::$oEmbedInstance->get_html($content, $attributes);
|
| 214 |
} else {
|
| 215 |
// Try to embed the url using EmbedPress' Embera.
|
| 216 |
$parsedContent = false;
|
| 217 |
}
|
| 218 |
} else {
|
| 219 |
// Try to embed the url using WP's OSEmbed.
|
| 220 |
-
$parsedContent = self::$oEmbedInstance->get_html($content, $attributes);
|
| 221 |
}
|
| 222 |
|
| 223 |
-
if (
|
| 224 |
-
if ( !
|
| 225 |
// If the embed couldn't be generated, we'll try to use Embera's API
|
| 226 |
-
$emberaInstance = new Embera($emberaInstanceSettings);
|
| 227 |
// Add support to the user's custom service providers
|
| 228 |
$additionalServiceProviders = Core::getAdditionalServiceProviders();
|
| 229 |
-
if ( !
|
| 230 |
-
foreach ($additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls) {
|
| 231 |
-
self::addServiceProvider($serviceProviderClassName, $serviceProviderUrls, $emberaInstance);
|
| 232 |
}
|
| 233 |
|
| 234 |
-
unset($serviceProviderUrls, $serviceProviderClassName);
|
| 235 |
}
|
| 236 |
}
|
| 237 |
|
| 238 |
// Register the html template
|
| 239 |
-
$emberaFormaterInstance = new Formatter($emberaInstance, true);
|
| 240 |
-
$emberaFormaterInstance->setTemplate($embedTemplate);
|
| 241 |
|
| 242 |
// Try to generate the embed using Embera API
|
| 243 |
-
$parsedContent = $emberaFormaterInstance->transform($content);
|
| 244 |
|
| 245 |
-
unset($emberaFormaterInstance, $additionalServiceProviders, $emberaInstance);
|
| 246 |
} else {
|
| 247 |
// Inject the generated code inside the html template
|
| 248 |
-
$parsedContent = str_replace('{html}', $parsedContent, $embedTemplate);
|
| 249 |
|
| 250 |
// Replace all single quotes to double quotes. I.e: foo='joe' -> foo="joe"
|
| 251 |
-
$parsedContent = str_replace("'", '"', $parsedContent);
|
| 252 |
|
| 253 |
// Replace the flag `{provider_alias}` which is used by Embera with the "ose-<serviceProviderAlias>". I.e: YouTube -> "ose-youtube"
|
| 254 |
-
$parsedContent = preg_replace('/((?:ose-)?\{provider_alias\})/i',
|
| 255 |
-
"ose-" . strtolower($urlData->provider_name), $parsedContent);
|
| 256 |
}
|
| 257 |
|
| 258 |
-
if (isset($urlData->provider_name) || (is_array($urlData) && isset($urlData[$content]['provider_name']))) {
|
| 259 |
// NFB seems to always return their embed code with all HTML entities into their applicable characters string.
|
| 260 |
-
if ((isset($urlData->provider_name) && strtoupper($urlData->provider_name) === "NATIONAL FILM BOARD OF CANADA") || (is_array($urlData) && isset($urlData[$content]['provider_name']) && strtoupper($urlData[$content]['provider_name']) === "NATIONAL FILM BOARD OF CANADA")) {
|
| 261 |
-
$parsedContent = html_entity_decode($parsedContent);
|
| 262 |
-
} elseif ((isset($urlData->provider_name) && strtoupper($urlData->provider_name) === "FACEBOOK") || (is_array($urlData) && isset($urlData[$content]['provider_name']) && strtoupper($urlData[$content]['provider_name']) === "FACEBOOK")) {
|
| 263 |
$plgSettings = Core::getSettings();
|
| 264 |
|
| 265 |
// Check if the user wants to force a certain language into Facebook embeds.
|
| 266 |
-
$locale = isset($plgSettings->fbLanguage) && !
|
| 267 |
-
if (
|
| 268 |
// Replace the automatically detected language by Facebook's API with the language chosen by the user.
|
| 269 |
-
$parsedContent = preg_replace('/\/[a-z]{2}\_[a-z]{2}\/sdk\.js/i', "/{$locale}/sdk.js",
|
| 270 |
-
$parsedContent);
|
| 271 |
}
|
| 272 |
|
| 273 |
// Make sure `adapt_container_width` parameter is set to false. Setting to true, as it is by default, might cause Facebook to render embeds inside editors (in admin) with only 180px wide.
|
| 274 |
-
if (is_admin()) {
|
| 275 |
-
$parsedContent = preg_replace('~data\-adapt\-container\-width=\"(?:true|1)\"~i',
|
| 276 |
-
'data-adapt-container-width="0"', $parsedContent);
|
| 277 |
}
|
| 278 |
|
| 279 |
-
unset($locale, $plgSettings);
|
| 280 |
}
|
| 281 |
}
|
| 282 |
|
| 283 |
-
unset($embedTemplate, $serviceProvider);
|
| 284 |
|
| 285 |
// This assure that the iframe has the same dimensions the user wants to
|
| 286 |
-
if (isset($emberaInstanceSettings['params']['width']) || isset($emberaInstanceSettings['params']['height'])) {
|
| 287 |
-
if (isset($emberaInstanceSettings['params']['width']) && isset($emberaInstanceSettings['params']['height'])) {
|
| 288 |
$customWidth = (int)$emberaInstanceSettings['params']['width'];
|
| 289 |
$customHeight = (int)$emberaInstanceSettings['params']['height'];
|
| 290 |
} else {
|
| 291 |
-
if (preg_match('~width="(\d+)"|width\s+:\s+(\d+)~i', $parsedContent, $matches)) {
|
| 292 |
$iframeWidth = (int)$matches[1];
|
| 293 |
}
|
| 294 |
|
| 295 |
-
if (preg_match('~height="(\d+)"|height\s+:\s+(\d+)~i', $parsedContent, $matches)) {
|
| 296 |
$iframeHeight = (int)$matches[1];
|
| 297 |
}
|
| 298 |
|
| 299 |
-
if (isset($iframeWidth) && isset($iframeHeight) && $iframeWidth > 0 && $iframeHeight > 0) {
|
| 300 |
-
$iframeRatio = ceil($iframeWidth / $iframeHeight);
|
| 301 |
|
| 302 |
-
if (isset($emberaInstanceSettings['params']['width'])) {
|
| 303 |
$customWidth = (int)$emberaInstanceSettings['params']['width'];
|
| 304 |
-
$customHeight = ceil($customWidth / $iframeRatio);
|
| 305 |
} else {
|
| 306 |
$customHeight = (int)$emberaInstanceSettings['params']['height'];
|
| 307 |
$customWidth = $iframeRatio * $customHeight;
|
|
@@ -309,41 +309,41 @@ class Shortcode
|
|
| 309 |
}
|
| 310 |
}
|
| 311 |
|
| 312 |
-
if (isset($customWidth) && isset($customHeight)) {
|
| 313 |
-
if (preg_match('~width="(\d+)"~i', $parsedContent)) {
|
| 314 |
-
$parsedContent = preg_replace('~width="(\d+)"~i', 'width="' . $customWidth . '"',
|
| 315 |
-
$parsedContent);
|
| 316 |
}
|
| 317 |
|
| 318 |
-
if (preg_match('~height="(\d+)"~i', $parsedContent)) {
|
| 319 |
-
$parsedContent = preg_replace('~height="(\d+)"~i', 'height="' . $customHeight . '"',
|
| 320 |
-
$parsedContent);
|
| 321 |
}
|
| 322 |
|
| 323 |
-
if (preg_match('~width\s+:\s+(\d+)~i', $parsedContent)) {
|
| 324 |
-
$parsedContent = preg_replace('~width\s+:\s+(\d+)~i', 'width: ' . $customWidth, $parsedContent);
|
| 325 |
}
|
| 326 |
|
| 327 |
-
if (preg_match('~height\s+:\s+(\d+)~i', $parsedContent)) {
|
| 328 |
-
$parsedContent = preg_replace('~height\s+:\s+(\d+)~i', 'height: ' . $customHeight,
|
| 329 |
-
$parsedContent);
|
| 330 |
}
|
| 331 |
}
|
| 332 |
}
|
| 333 |
|
| 334 |
-
if ($stripNewLine) {
|
| 335 |
-
$parsedContent = preg_replace('/\n/', '', $parsedContent);
|
| 336 |
}
|
| 337 |
|
| 338 |
-
$parsedContent = apply_filters('pp_embed_parsed_content', $parsedContent, $urlData, $attributes);
|
| 339 |
|
| 340 |
-
if ( !
|
| 341 |
-
$embed = (object)array_merge((array)$urlData, [
|
| 342 |
'attributes' => (object)$attributes,
|
| 343 |
'embed' => $parsedContent,
|
| 344 |
'url' => $content,
|
| 345 |
-
]);
|
| 346 |
-
$embed = apply_filters('embedpress:onAfterEmbed', $embed);
|
| 347 |
return $embed;
|
| 348 |
}
|
| 349 |
}
|
|
@@ -354,26 +354,25 @@ class Shortcode
|
|
| 354 |
/**
|
| 355 |
* Method that adds support to a given new service provider (SP).
|
| 356 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
* @since 1.0.0
|
| 358 |
* @static
|
| 359 |
*
|
| 360 |
-
* @param string $className The new SP class name.
|
| 361 |
-
* @param string $reference The new SP reference name.
|
| 362 |
-
* @param \Embera\Embera $emberaInstance The embera's instance where the SP will be registered in.
|
| 363 |
-
*
|
| 364 |
-
* @return boolean
|
| 365 |
*/
|
| 366 |
-
public static function addServiceProvider($className, $reference, &$emberaInstance)
|
| 367 |
-
|
| 368 |
-
if (empty($className) || empty($reference)) {
|
| 369 |
return false;
|
| 370 |
}
|
| 371 |
|
| 372 |
-
if (is_string($reference)) {
|
| 373 |
-
$emberaInstance->addProvider($reference, EMBEDPRESS_NAMESPACE . "\\Providers\\{$className}");
|
| 374 |
-
} elseif (is_array($reference)) {
|
| 375 |
-
foreach ($reference as $serviceProviderUrl) {
|
| 376 |
-
self::addServiceProvider($className, $serviceProviderUrl, $emberaInstance);
|
| 377 |
}
|
| 378 |
} else {
|
| 379 |
return false;
|
|
@@ -383,22 +382,21 @@ class Shortcode
|
|
| 383 |
/**
|
| 384 |
* Method that retrieves all custom parameters from a shortcoded string.
|
| 385 |
*
|
|
|
|
|
|
|
|
|
|
| 386 |
* @since 1.0.0
|
| 387 |
* @static
|
| 388 |
*
|
| 389 |
-
* @param string $subject The given shortcoded string.
|
| 390 |
-
*
|
| 391 |
-
* @return array
|
| 392 |
*/
|
| 393 |
-
public static function parseContentAttributesFromString($subject)
|
| 394 |
-
{
|
| 395 |
$customAttributes = [];
|
| 396 |
-
if (preg_match('/\[embed\s*(.*?)\]/i', stripslashes($subject), $m)) {
|
| 397 |
-
if (preg_match_all('/(\!?\w+-?\w*)(?:="(.+?)")?/i', stripslashes($m[1]), $matches)) {
|
| 398 |
$attributes = $matches[1];
|
| 399 |
$attrValues = $matches[2];
|
| 400 |
|
| 401 |
-
foreach ($attributes as $attrIndex => $attrName) {
|
| 402 |
$customAttributes[$attrName] = $attrValues[$attrIndex];
|
| 403 |
}
|
| 404 |
}
|
|
@@ -410,62 +408,61 @@ class Shortcode
|
|
| 410 |
/**
|
| 411 |
* Method that parses and adds the "data-" prefix to the given custom shortcode attributes.
|
| 412 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
* @since 1.0.0
|
| 414 |
* @access private
|
| 415 |
* @static
|
| 416 |
*
|
| 417 |
-
* @param array $customAttributes The array containing the embed attributes.
|
| 418 |
-
* @param string $content_uid An optional string specifying a unique ID for the embed
|
| 419 |
-
*
|
| 420 |
-
* @return array
|
| 421 |
*/
|
| 422 |
-
private static function parseContentAttributes(array $customAttributes, $content_uid = null)
|
| 423 |
-
{
|
| 424 |
$attributes = [
|
| 425 |
-
'class' => ["embedpress-wrapper"],
|
| 426 |
];
|
| 427 |
|
| 428 |
$embedShouldBeResponsive = true;
|
| 429 |
$embedShouldHaveCustomDimensions = false;
|
| 430 |
-
if ( !
|
| 431 |
-
if (isset($customAttributes['class'])) {
|
| 432 |
-
if ( !
|
| 433 |
-
$customAttributes['class'] = explode(' ', $customAttributes['class']);
|
| 434 |
|
| 435 |
-
$attributes['class'] = array_merge($attributes['class'], $customAttributes['class']);
|
| 436 |
}
|
| 437 |
|
| 438 |
-
unset($customAttributes['class']);
|
| 439 |
}
|
| 440 |
|
| 441 |
-
if (isset($customAttributes['width'])) {
|
| 442 |
-
if ( !
|
| 443 |
$attributes['width'] = (int)$customAttributes['width'];
|
| 444 |
$embedShouldHaveCustomDimensions = true;
|
| 445 |
}
|
| 446 |
}
|
| 447 |
|
| 448 |
-
if (isset($customAttributes['height'])) {
|
| 449 |
-
if ( !
|
| 450 |
$attributes['height'] = (int)$customAttributes['height'];
|
| 451 |
$embedShouldHaveCustomDimensions = true;
|
| 452 |
}
|
| 453 |
}
|
| 454 |
|
| 455 |
-
if ( !
|
| 456 |
$attrNameDefaultPrefix = "data-";
|
| 457 |
-
foreach ($customAttributes as $attrName => $attrValue) {
|
| 458 |
-
if (is_numeric($attrName)) {
|
| 459 |
$attrName = $attrValue;
|
| 460 |
$attrValue = "";
|
| 461 |
}
|
| 462 |
|
| 463 |
-
$attrName = str_replace($attrNameDefaultPrefix, "", $attrName);
|
| 464 |
|
| 465 |
-
if ( !
|
| 466 |
-
if ($attrName[0] === "!") {
|
| 467 |
$attrValue = "false";
|
| 468 |
-
$attrName = substr($attrName, 1);
|
| 469 |
} else {
|
| 470 |
$attrValue = "true";
|
| 471 |
}
|
|
@@ -476,35 +473,35 @@ class Shortcode
|
|
| 476 |
}
|
| 477 |
|
| 478 |
// Check if there's any "responsive" parameter
|
| 479 |
-
$responsiveAttributes = ["responsive", "data-responsive"];
|
| 480 |
-
foreach ($responsiveAttributes as $responsiveAttr) {
|
| 481 |
-
if (isset($attributes[$responsiveAttr])) {
|
| 482 |
-
if ( !
|
| 483 |
$embedShouldBeResponsive = true;
|
| 484 |
} else {
|
| 485 |
-
$embedShouldBeResponsive = !
|
| 486 |
}
|
| 487 |
|
| 488 |
break;
|
| 489 |
}
|
| 490 |
}
|
| 491 |
-
unset($responsiveAttr, $responsiveAttributes);
|
| 492 |
}
|
| 493 |
|
| 494 |
$attributes['class'][] = 'ose-{provider_alias}';
|
| 495 |
|
| 496 |
-
if ( !
|
| 497 |
$attributes['class'][] = 'ose-uid-' . $content_uid;
|
| 498 |
}
|
| 499 |
|
| 500 |
-
if ($embedShouldBeResponsive &&
|
| 501 |
$attributes['class'][] = 'responsive';
|
| 502 |
} else {
|
| 503 |
$attributes['data-responsive'] = "false";
|
| 504 |
}
|
| 505 |
|
| 506 |
-
$attributes['class'] = implode(' ', array_unique(array_filter($attributes['class'])));
|
| 507 |
-
if(isset($attributes['width'])){
|
| 508 |
$attributes['style'] = "width:{$attributes['width'] }px;height:{$attributes['height'] }px;";
|
| 509 |
}
|
| 510 |
|
|
@@ -514,17 +511,16 @@ class Shortcode
|
|
| 514 |
/**
|
| 515 |
* Method that checks if a given value is/can be identified as (bool)false.
|
| 516 |
*
|
|
|
|
|
|
|
|
|
|
| 517 |
* @since 1.0.0
|
| 518 |
* @static
|
| 519 |
*
|
| 520 |
-
* @param mixed $subject The value to be checked.
|
| 521 |
-
*
|
| 522 |
-
* @return boolean
|
| 523 |
*/
|
| 524 |
-
public static function valueIsFalse($subject)
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
switch ($subject) {
|
| 528 |
case "0":
|
| 529 |
case "false":
|
| 530 |
case "off":
|
|
@@ -542,21 +538,20 @@ class Shortcode
|
|
| 542 |
* Return the value from a header which is in an array resulted from a get_headers() call.
|
| 543 |
* If the header cannot be found, this method will return null instead.
|
| 544 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
* @since 1.1.0
|
| 546 |
* @access private
|
| 547 |
* @static
|
| 548 |
*
|
| 549 |
-
* @param string $headerPattern Regex pattern the header and its value must match.
|
| 550 |
-
* @param array $headersList A list of headers resulted from a get_headers() call.
|
| 551 |
-
*
|
| 552 |
-
* @return mixed
|
| 553 |
*/
|
| 554 |
-
private static function extractContentFromHeaderAsArray($headerPattern, $headersList)
|
| 555 |
-
{
|
| 556 |
$headerValue = null;
|
| 557 |
|
| 558 |
-
foreach ($headersList as $header) {
|
| 559 |
-
if (preg_match($headerPattern, $header, $matches)) {
|
| 560 |
$headerValue = $matches[1];
|
| 561 |
break;
|
| 562 |
}
|
|
@@ -570,33 +565,32 @@ class Shortcode
|
|
| 570 |
* attributes from "dash" separated to "underline" separated to be able to access
|
| 571 |
* those attributes from the object, without having to convert it to an array.
|
| 572 |
*
|
|
|
|
|
|
|
|
|
|
| 573 |
* @since 1.6.1
|
| 574 |
* @access private
|
| 575 |
* @static
|
| 576 |
*
|
| 577 |
-
* @param object $data
|
| 578 |
-
*
|
| 579 |
-
* @return object
|
| 580 |
*/
|
| 581 |
-
private static function sanitizeUrlData($data)
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
$attributes = get_object_vars($data);
|
| 585 |
|
| 586 |
-
foreach ($attributes as $key => $value) {
|
| 587 |
-
if (substr_count($key, '-')) {
|
| 588 |
-
unset($data->$key);
|
| 589 |
|
| 590 |
-
$key = str_replace('-', '_', $key);
|
| 591 |
$data->$key = $value;
|
| 592 |
}
|
| 593 |
}
|
| 594 |
-
} elseif (is_array($data)) {
|
| 595 |
-
foreach ($data as $key => $value) {
|
| 596 |
-
if (substr_count($key, '-')) {
|
| 597 |
-
unset($data[$key]);
|
| 598 |
|
| 599 |
-
$key = str_replace('-', '_', $key);
|
| 600 |
$data[$key] = $value;
|
| 601 |
}
|
| 602 |
}
|
| 5 |
use Embera\Embera;
|
| 6 |
use Embera\Formatter;
|
| 7 |
|
| 8 |
+
(defined( 'ABSPATH' ) && defined( 'EMBEDPRESS_IS_LOADED' )) or die( "No direct script access allowed." );
|
| 9 |
|
| 10 |
/**
|
| 11 |
* Entity responsible to handle the plugin's shortcode events and behaviors.
|
| 16 |
* @license GPLv2 or later
|
| 17 |
* @since 1.0.0
|
| 18 |
*/
|
| 19 |
+
class Shortcode {
|
|
|
|
| 20 |
/**
|
| 21 |
* The WP_oEmbed class instance.
|
| 22 |
*
|
| 31 |
/**
|
| 32 |
* Register the plugin's shortcode into WordPress.
|
| 33 |
*
|
| 34 |
+
* @return void
|
| 35 |
* @since 1.0.0
|
| 36 |
* @static
|
| 37 |
*
|
|
|
|
| 38 |
*/
|
| 39 |
+
public static function register() {
|
|
|
|
| 40 |
// Register the new shortcode for embeds.
|
| 41 |
+
add_shortcode( EMBEDPRESS_SHORTCODE, [ '\\EmbedPress\\Shortcode', 'do_shortcode' ] );
|
| 42 |
+
add_shortcode( 'embed_oembed_html', [ '\\EmbedPress\\Shortcode', 'do_shortcode' ] );
|
| 43 |
}
|
| 44 |
|
| 45 |
/**
|
| 46 |
* Method that converts the plugin shortcoded-string into its complex content.
|
| 47 |
*
|
| 48 |
+
* @param array $attributes Array of attributes
|
| 49 |
+
* @param string $subject The given string
|
| 50 |
+
*
|
| 51 |
+
* @return string
|
| 52 |
* @since 1.0.0
|
| 53 |
* @static
|
| 54 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
*/
|
| 56 |
|
| 57 |
+
public static function do_shortcode( $attributes = [], $subject = null ) {
|
|
|
|
| 58 |
$plgSettings = Core::getSettings();
|
| 59 |
+
$default = [];
|
| 60 |
+
if ( $plgSettings->enableGlobalEmbedResize ) {
|
| 61 |
+
$default = [
|
| 62 |
+
'width' => $plgSettings->enableEmbedResizeWidth,
|
| 63 |
+
'height' => $plgSettings->enableEmbedResizeHeight
|
| 64 |
+
];
|
| 65 |
+
}
|
| 66 |
+
$attributes = wp_parse_args( $attributes, $default );
|
| 67 |
+
$embed = self::parseContent( $subject, true, $attributes );
|
| 68 |
|
| 69 |
+
return is_object( $embed ) ? $embed->embed : $embed;
|
| 70 |
}
|
| 71 |
|
| 72 |
/**
|
| 73 |
* Replace a given content with its embeded HTML code.
|
| 74 |
*
|
| 75 |
+
* @param string The raw content that will be replaced.
|
| 76 |
+
* @param boolean Optional. If true, new lines at the end of the embeded code are stripped.
|
| 77 |
+
*
|
| 78 |
+
* @return string
|
| 79 |
* @since 1.0.0
|
| 80 |
* @static
|
| 81 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
*/
|
| 83 |
+
public static function parseContent( $subject, $stripNewLine = false, $customAttributes = [] ) {
|
| 84 |
+
if ( !empty( $subject ) ) {
|
| 85 |
+
if ( empty( $customAttributes ) ) {
|
| 86 |
+
$customAttributes = self::parseContentAttributesFromString( $subject );
|
|
|
|
| 87 |
}
|
| 88 |
|
| 89 |
+
$content = preg_replace( '/(\[' . EMBEDPRESS_SHORTCODE . '(?:\]|.+?\])|\[\/' . EMBEDPRESS_SHORTCODE . '\])/i',
|
| 90 |
+
"", $subject );
|
| 91 |
|
| 92 |
// Converts any special HTML entities back to characters.
|
| 93 |
+
$content = htmlspecialchars_decode( $content );
|
| 94 |
|
| 95 |
// Check if the WP_oEmbed class is loaded
|
| 96 |
+
if ( !self::$oEmbedInstance ) {
|
| 97 |
require_once ABSPATH . 'wp-includes/class-wp-oembed.php';
|
| 98 |
|
| 99 |
self::$oEmbedInstance = _wp_oembed_get_object();
|
| 103 |
'params' => [],
|
| 104 |
];
|
| 105 |
|
| 106 |
+
$content_uid = md5( $content );
|
| 107 |
|
| 108 |
+
$attributes = self::parseContentAttributes( $customAttributes, $content_uid );
|
| 109 |
+
if ( isset( $attributes['width'] ) || isset( $attributes['height'] ) ) {
|
| 110 |
+
if ( isset( $attributes['width'] ) ) {
|
| 111 |
$emberaInstanceSettings['params']['width'] = $attributes['width'];
|
| 112 |
+
unset( $attributes['width'] );
|
| 113 |
}
|
| 114 |
|
| 115 |
+
if ( isset( $attributes['height'] ) ) {
|
| 116 |
$emberaInstanceSettings['params']['height'] = $attributes['height'];
|
| 117 |
+
unset( $attributes['height'] );
|
| 118 |
}
|
| 119 |
}
|
| 120 |
|
| 121 |
// Identify what service provider the shortcode's link belongs to
|
| 122 |
+
$serviceProvider = self::$oEmbedInstance->get_provider( $content );
|
| 123 |
|
| 124 |
|
| 125 |
// Check if OEmbed was unable to detect the url service provider.
|
| 126 |
+
if ( empty( $serviceProvider ) ) {
|
| 127 |
// Attempt to do the same using Embera.
|
| 128 |
+
$emberaInstance = new Embera( $emberaInstanceSettings );
|
| 129 |
// Add support to the user's custom service providers
|
| 130 |
$additionalServiceProviders = Core::getAdditionalServiceProviders();
|
| 131 |
+
if ( !empty( $additionalServiceProviders ) ) {
|
| 132 |
+
foreach ( $additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls ) {
|
| 133 |
+
self::addServiceProvider( $serviceProviderClassName, $serviceProviderUrls, $emberaInstance );
|
| 134 |
}
|
| 135 |
|
| 136 |
+
unset( $serviceProviderUrls, $serviceProviderClassName );
|
| 137 |
}
|
| 138 |
|
| 139 |
// Attempt to fetch more info about the url-embed.
|
| 140 |
+
$urlData = $emberaInstance->getUrlInfo( $content );
|
| 141 |
} else {
|
| 142 |
// Attempt to fetch more info about the url-embed.
|
| 143 |
+
$urlData = self::$oEmbedInstance->fetch( $serviceProvider, $content, $attributes );
|
| 144 |
}
|
| 145 |
|
| 146 |
// Sanitize the data
|
| 147 |
+
$urlData = self::sanitizeUrlData( $urlData );
|
| 148 |
|
| 149 |
// Stores the original content
|
| 150 |
+
if ( is_object( $urlData ) ) {
|
| 151 |
$urlData->originalContent = $content;
|
| 152 |
}
|
| 153 |
|
| 154 |
+
$eventResults = apply_filters( 'embedpress:onBeforeEmbed', $urlData );
|
| 155 |
+
if ( empty( $eventResults ) ) {
|
| 156 |
// EmbedPress seems unable to embed the url.
|
| 157 |
return $subject;
|
| 158 |
}
|
| 159 |
|
| 160 |
// Transform all shortcode attributes into html form. I.e.: {foo: "joe"} -> foo="joe"
|
| 161 |
$attributesHtml = [];
|
| 162 |
+
foreach ( $attributes as $attrName => $attrValue ) {
|
| 163 |
$attributesHtml[] = $attrName . '="' . $attrValue . '"';
|
| 164 |
}
|
| 165 |
|
| 166 |
// Define the EmbedPress html template where the generated embed will be injected in
|
| 167 |
+
$embedTemplate = '<div ' . implode( ' ', $attributesHtml ) . '>{html}</div>';
|
| 168 |
|
| 169 |
// Check if $content is a google shortened url and tries to extract from it which Google service it refers to.
|
| 170 |
+
if ( preg_match( '/http[s]?:\/\/goo\.gl\/(?:([a-z]+)\/)?[a-z0-9]+\/?$/i', $content, $matches ) ) {
|
| 171 |
// Fetch all headers from the short-url so we can know how to handle its original content depending on the service.
|
| 172 |
+
$headers = get_headers( $content );
|
| 173 |
|
| 174 |
$supportedServicesHeadersPatterns = [
|
| 175 |
'maps' => '/^Location:\s+(http[s]?:\/\/.+)$/i',
|
| 176 |
];
|
| 177 |
|
| 178 |
+
$service = isset( $matches[1] ) ? strtolower( $matches[1] ) : null;
|
| 179 |
// No specific service was found in the url.
|
| 180 |
+
if ( empty( $service ) ) {
|
| 181 |
// Let's try to guess which service the original url belongs to.
|
| 182 |
+
foreach ( $headers as $header ) {
|
| 183 |
// Check if the short-url reffers to a Google Maps url.
|
| 184 |
+
if ( preg_match( $supportedServicesHeadersPatterns['maps'], $header, $matches ) ) {
|
| 185 |
// Replace the shortened url with its original url.
|
| 186 |
$content = $matches[1];
|
| 187 |
break;
|
| 188 |
}
|
| 189 |
}
|
| 190 |
+
unset( $header );
|
| 191 |
} else {
|
| 192 |
// Check if the Google service is supported atm.
|
| 193 |
+
if ( isset( $supportedServicesHeadersPatterns[$service] ) ) {
|
| 194 |
// Tries to extract the url based on its headers.
|
| 195 |
+
$originalUrl = self::extractContentFromHeaderAsArray( $supportedServicesHeadersPatterns[$service],
|
| 196 |
+
$headers );
|
| 197 |
// Replace the shortened url with its original url if the specific header was found.
|
| 198 |
+
if ( !empty( $originalUrl ) ) {
|
| 199 |
$content = $originalUrl;
|
| 200 |
}
|
| 201 |
+
unset( $originalUrl );
|
| 202 |
}
|
| 203 |
}
|
| 204 |
+
unset( $service, $supportedServicesHeadersPatterns, $headers, $matches );
|
| 205 |
}
|
| 206 |
|
| 207 |
// Facebook is a special case. WordPress will try to embed them using OEmbed, but they always end up embedding the profile page, regardless
|
| 208 |
// if the url was pointing to a photo, a post, etc. So, since Embera can embed only facebook-media/posts, we'll use it only for that.
|
| 209 |
+
if ( isset( $urlData->provider_name ) && in_array( $urlData->provider_name, [ 'Facebook' ] ) ) {
|
| 210 |
// Check if this is a Facebook profile url.
|
| 211 |
+
if ( preg_match( '/facebook\.com\/(?:[^\/]+?)\/?$/', $content, $match ) ) {
|
| 212 |
// Try to embed the url using WP's OSEmbed.
|
| 213 |
+
$parsedContent = self::$oEmbedInstance->get_html( $content, $attributes );
|
| 214 |
} else {
|
| 215 |
// Try to embed the url using EmbedPress' Embera.
|
| 216 |
$parsedContent = false;
|
| 217 |
}
|
| 218 |
} else {
|
| 219 |
// Try to embed the url using WP's OSEmbed.
|
| 220 |
+
$parsedContent = self::$oEmbedInstance->get_html( $content, $attributes );
|
| 221 |
}
|
| 222 |
|
| 223 |
+
if ( !$parsedContent ) {
|
| 224 |
+
if ( !isset( $emberaInstance ) ) {
|
| 225 |
// If the embed couldn't be generated, we'll try to use Embera's API
|
| 226 |
+
$emberaInstance = new Embera( $emberaInstanceSettings );
|
| 227 |
// Add support to the user's custom service providers
|
| 228 |
$additionalServiceProviders = Core::getAdditionalServiceProviders();
|
| 229 |
+
if ( !empty( $additionalServiceProviders ) ) {
|
| 230 |
+
foreach ( $additionalServiceProviders as $serviceProviderClassName => $serviceProviderUrls ) {
|
| 231 |
+
self::addServiceProvider( $serviceProviderClassName, $serviceProviderUrls, $emberaInstance );
|
| 232 |
}
|
| 233 |
|
| 234 |
+
unset( $serviceProviderUrls, $serviceProviderClassName );
|
| 235 |
}
|
| 236 |
}
|
| 237 |
|
| 238 |
// Register the html template
|
| 239 |
+
$emberaFormaterInstance = new Formatter( $emberaInstance, true );
|
| 240 |
+
$emberaFormaterInstance->setTemplate( $embedTemplate );
|
| 241 |
|
| 242 |
// Try to generate the embed using Embera API
|
| 243 |
+
$parsedContent = $emberaFormaterInstance->transform( $content );
|
| 244 |
|
| 245 |
+
unset( $emberaFormaterInstance, $additionalServiceProviders, $emberaInstance );
|
| 246 |
} else {
|
| 247 |
// Inject the generated code inside the html template
|
| 248 |
+
$parsedContent = str_replace( '{html}', $parsedContent, $embedTemplate );
|
| 249 |
|
| 250 |
// Replace all single quotes to double quotes. I.e: foo='joe' -> foo="joe"
|
| 251 |
+
$parsedContent = str_replace( "'", '"', $parsedContent );
|
| 252 |
|
| 253 |
// Replace the flag `{provider_alias}` which is used by Embera with the "ose-<serviceProviderAlias>". I.e: YouTube -> "ose-youtube"
|
| 254 |
+
$parsedContent = preg_replace( '/((?:ose-)?\{provider_alias\})/i',
|
| 255 |
+
"ose-" . strtolower( $urlData->provider_name ), $parsedContent );
|
| 256 |
}
|
| 257 |
|
| 258 |
+
if ( isset( $urlData->provider_name ) || (is_array( $urlData ) && isset( $urlData[$content]['provider_name'] )) ) {
|
| 259 |
// NFB seems to always return their embed code with all HTML entities into their applicable characters string.
|
| 260 |
+
if ( (isset( $urlData->provider_name ) && strtoupper( $urlData->provider_name ) === "NATIONAL FILM BOARD OF CANADA") || (is_array( $urlData ) && isset( $urlData[$content]['provider_name'] ) && strtoupper( $urlData[$content]['provider_name'] ) === "NATIONAL FILM BOARD OF CANADA") ) {
|
| 261 |
+
$parsedContent = html_entity_decode( $parsedContent );
|
| 262 |
+
} elseif ( (isset( $urlData->provider_name ) && strtoupper( $urlData->provider_name ) === "FACEBOOK") || (is_array( $urlData ) && isset( $urlData[$content]['provider_name'] ) && strtoupper( $urlData[$content]['provider_name'] ) === "FACEBOOK") ) {
|
| 263 |
$plgSettings = Core::getSettings();
|
| 264 |
|
| 265 |
// Check if the user wants to force a certain language into Facebook embeds.
|
| 266 |
+
$locale = isset( $plgSettings->fbLanguage ) && !empty( $plgSettings->fbLanguage ) ? $plgSettings->fbLanguage : false;
|
| 267 |
+
if ( !!$locale ) {
|
| 268 |
// Replace the automatically detected language by Facebook's API with the language chosen by the user.
|
| 269 |
+
$parsedContent = preg_replace( '/\/[a-z]{2}\_[a-z]{2}\/sdk\.js/i', "/{$locale}/sdk.js",
|
| 270 |
+
$parsedContent );
|
| 271 |
}
|
| 272 |
|
| 273 |
// Make sure `adapt_container_width` parameter is set to false. Setting to true, as it is by default, might cause Facebook to render embeds inside editors (in admin) with only 180px wide.
|
| 274 |
+
if ( is_admin() ) {
|
| 275 |
+
$parsedContent = preg_replace( '~data\-adapt\-container\-width=\"(?:true|1)\"~i',
|
| 276 |
+
'data-adapt-container-width="0"', $parsedContent );
|
| 277 |
}
|
| 278 |
|
| 279 |
+
unset( $locale, $plgSettings );
|
| 280 |
}
|
| 281 |
}
|
| 282 |
|
| 283 |
+
unset( $embedTemplate, $serviceProvider );
|
| 284 |
|
| 285 |
// This assure that the iframe has the same dimensions the user wants to
|
| 286 |
+
if ( isset( $emberaInstanceSettings['params']['width'] ) || isset( $emberaInstanceSettings['params']['height'] ) ) {
|
| 287 |
+
if ( isset( $emberaInstanceSettings['params']['width'] ) && isset( $emberaInstanceSettings['params']['height'] ) ) {
|
| 288 |
$customWidth = (int)$emberaInstanceSettings['params']['width'];
|
| 289 |
$customHeight = (int)$emberaInstanceSettings['params']['height'];
|
| 290 |
} else {
|
| 291 |
+
if ( preg_match( '~width="(\d+)"|width\s+:\s+(\d+)~i', $parsedContent, $matches ) ) {
|
| 292 |
$iframeWidth = (int)$matches[1];
|
| 293 |
}
|
| 294 |
|
| 295 |
+
if ( preg_match( '~height="(\d+)"|height\s+:\s+(\d+)~i', $parsedContent, $matches ) ) {
|
| 296 |
$iframeHeight = (int)$matches[1];
|
| 297 |
}
|
| 298 |
|
| 299 |
+
if ( isset( $iframeWidth ) && isset( $iframeHeight ) && $iframeWidth > 0 && $iframeHeight > 0 ) {
|
| 300 |
+
$iframeRatio = ceil( $iframeWidth / $iframeHeight );
|
| 301 |
|
| 302 |
+
if ( isset( $emberaInstanceSettings['params']['width'] ) ) {
|
| 303 |
$customWidth = (int)$emberaInstanceSettings['params']['width'];
|
| 304 |
+
$customHeight = ceil( $customWidth / $iframeRatio );
|
| 305 |
} else {
|
| 306 |
$customHeight = (int)$emberaInstanceSettings['params']['height'];
|
| 307 |
$customWidth = $iframeRatio * $customHeight;
|
| 309 |
}
|
| 310 |
}
|
| 311 |
|
| 312 |
+
if ( isset( $customWidth ) && isset( $customHeight ) ) {
|
| 313 |
+
if ( preg_match( '~width="(\d+)"~i', $parsedContent ) ) {
|
| 314 |
+
$parsedContent = preg_replace( '~width="(\d+)"~i', 'width="' . $customWidth . '"',
|
| 315 |
+
$parsedContent );
|
| 316 |
}
|
| 317 |
|
| 318 |
+
if ( preg_match( '~height="(\d+)"~i', $parsedContent ) ) {
|
| 319 |
+
$parsedContent = preg_replace( '~height="(\d+)"~i', 'height="' . $customHeight . '"',
|
| 320 |
+
$parsedContent );
|
| 321 |
}
|
| 322 |
|
| 323 |
+
if ( preg_match( '~width\s+:\s+(\d+)~i', $parsedContent ) ) {
|
| 324 |
+
$parsedContent = preg_replace( '~width\s+:\s+(\d+)~i', 'width: ' . $customWidth, $parsedContent );
|
| 325 |
}
|
| 326 |
|
| 327 |
+
if ( preg_match( '~height\s+:\s+(\d+)~i', $parsedContent ) ) {
|
| 328 |
+
$parsedContent = preg_replace( '~height\s+:\s+(\d+)~i', 'height: ' . $customHeight,
|
| 329 |
+
$parsedContent );
|
| 330 |
}
|
| 331 |
}
|
| 332 |
}
|
| 333 |
|
| 334 |
+
if ( $stripNewLine ) {
|
| 335 |
+
$parsedContent = preg_replace( '/\n/', '', $parsedContent );
|
| 336 |
}
|
| 337 |
|
| 338 |
+
$parsedContent = apply_filters( 'pp_embed_parsed_content', $parsedContent, $urlData, $attributes );
|
| 339 |
|
| 340 |
+
if ( !empty( $parsedContent ) ) {
|
| 341 |
+
$embed = (object)array_merge( (array)$urlData, [
|
| 342 |
'attributes' => (object)$attributes,
|
| 343 |
'embed' => $parsedContent,
|
| 344 |
'url' => $content,
|
| 345 |
+
] );
|
| 346 |
+
$embed = apply_filters( 'embedpress:onAfterEmbed', $embed );
|
| 347 |
return $embed;
|
| 348 |
}
|
| 349 |
}
|
| 354 |
/**
|
| 355 |
* Method that adds support to a given new service provider (SP).
|
| 356 |
*
|
| 357 |
+
* @param string $className The new SP class name.
|
| 358 |
+
* @param string $reference The new SP reference name.
|
| 359 |
+
* @param \Embera\Embera $emberaInstance The embera's instance where the SP will be registered in.
|
| 360 |
+
*
|
| 361 |
+
* @return boolean
|
| 362 |
* @since 1.0.0
|
| 363 |
* @static
|
| 364 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
*/
|
| 366 |
+
public static function addServiceProvider( $className, $reference, &$emberaInstance ) {
|
| 367 |
+
if ( empty( $className ) || empty( $reference ) ) {
|
|
|
|
| 368 |
return false;
|
| 369 |
}
|
| 370 |
|
| 371 |
+
if ( is_string( $reference ) ) {
|
| 372 |
+
$emberaInstance->addProvider( $reference, EMBEDPRESS_NAMESPACE . "\\Providers\\{$className}" );
|
| 373 |
+
} elseif ( is_array( $reference ) ) {
|
| 374 |
+
foreach ( $reference as $serviceProviderUrl ) {
|
| 375 |
+
self::addServiceProvider( $className, $serviceProviderUrl, $emberaInstance );
|
| 376 |
}
|
| 377 |
} else {
|
| 378 |
return false;
|
| 382 |
/**
|
| 383 |
* Method that retrieves all custom parameters from a shortcoded string.
|
| 384 |
*
|
| 385 |
+
* @param string $subject The given shortcoded string.
|
| 386 |
+
*
|
| 387 |
+
* @return array
|
| 388 |
* @since 1.0.0
|
| 389 |
* @static
|
| 390 |
*
|
|
|
|
|
|
|
|
|
|
| 391 |
*/
|
| 392 |
+
public static function parseContentAttributesFromString( $subject ) {
|
|
|
|
| 393 |
$customAttributes = [];
|
| 394 |
+
if ( preg_match( '/\[embed\s*(.*?)\]/i', stripslashes( $subject ), $m ) ) {
|
| 395 |
+
if ( preg_match_all( '/(\!?\w+-?\w*)(?:="(.+?)")?/i', stripslashes( $m[1] ), $matches ) ) {
|
| 396 |
$attributes = $matches[1];
|
| 397 |
$attrValues = $matches[2];
|
| 398 |
|
| 399 |
+
foreach ( $attributes as $attrIndex => $attrName ) {
|
| 400 |
$customAttributes[$attrName] = $attrValues[$attrIndex];
|
| 401 |
}
|
| 402 |
}
|
| 408 |
/**
|
| 409 |
* Method that parses and adds the "data-" prefix to the given custom shortcode attributes.
|
| 410 |
*
|
| 411 |
+
* @param array $customAttributes The array containing the embed attributes.
|
| 412 |
+
* @param string $content_uid An optional string specifying a unique ID for the embed
|
| 413 |
+
*
|
| 414 |
+
* @return array
|
| 415 |
* @since 1.0.0
|
| 416 |
* @access private
|
| 417 |
* @static
|
| 418 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
*/
|
| 420 |
+
private static function parseContentAttributes( array $customAttributes, $content_uid = null ) {
|
|
|
|
| 421 |
$attributes = [
|
| 422 |
+
'class' => [ "embedpress-wrapper" ],
|
| 423 |
];
|
| 424 |
|
| 425 |
$embedShouldBeResponsive = true;
|
| 426 |
$embedShouldHaveCustomDimensions = false;
|
| 427 |
+
if ( !empty( $customAttributes ) ) {
|
| 428 |
+
if ( isset( $customAttributes['class'] ) ) {
|
| 429 |
+
if ( !empty( $customAttributes['class'] ) ) {
|
| 430 |
+
$customAttributes['class'] = explode( ' ', $customAttributes['class'] );
|
| 431 |
|
| 432 |
+
$attributes['class'] = array_merge( $attributes['class'], $customAttributes['class'] );
|
| 433 |
}
|
| 434 |
|
| 435 |
+
unset( $customAttributes['class'] );
|
| 436 |
}
|
| 437 |
|
| 438 |
+
if ( isset( $customAttributes['width'] ) ) {
|
| 439 |
+
if ( !empty( $customAttributes['width'] ) ) {
|
| 440 |
$attributes['width'] = (int)$customAttributes['width'];
|
| 441 |
$embedShouldHaveCustomDimensions = true;
|
| 442 |
}
|
| 443 |
}
|
| 444 |
|
| 445 |
+
if ( isset( $customAttributes['height'] ) ) {
|
| 446 |
+
if ( !empty( $customAttributes['height'] ) ) {
|
| 447 |
$attributes['height'] = (int)$customAttributes['height'];
|
| 448 |
$embedShouldHaveCustomDimensions = true;
|
| 449 |
}
|
| 450 |
}
|
| 451 |
|
| 452 |
+
if ( !empty( $customAttributes ) ) {
|
| 453 |
$attrNameDefaultPrefix = "data-";
|
| 454 |
+
foreach ( $customAttributes as $attrName => $attrValue ) {
|
| 455 |
+
if ( is_numeric( $attrName ) ) {
|
| 456 |
$attrName = $attrValue;
|
| 457 |
$attrValue = "";
|
| 458 |
}
|
| 459 |
|
| 460 |
+
$attrName = str_replace( $attrNameDefaultPrefix, "", $attrName );
|
| 461 |
|
| 462 |
+
if ( !strlen( $attrValue ) ) {
|
| 463 |
+
if ( $attrName[0] === "!" ) {
|
| 464 |
$attrValue = "false";
|
| 465 |
+
$attrName = substr( $attrName, 1 );
|
| 466 |
} else {
|
| 467 |
$attrValue = "true";
|
| 468 |
}
|
| 473 |
}
|
| 474 |
|
| 475 |
// Check if there's any "responsive" parameter
|
| 476 |
+
$responsiveAttributes = [ "responsive", "data-responsive" ];
|
| 477 |
+
foreach ( $responsiveAttributes as $responsiveAttr ) {
|
| 478 |
+
if ( isset( $attributes[$responsiveAttr] ) ) {
|
| 479 |
+
if ( !strlen( $attributes[$responsiveAttr] ) ) { // If the parameter is passed but have no value, it will be true by default
|
| 480 |
$embedShouldBeResponsive = true;
|
| 481 |
} else {
|
| 482 |
+
$embedShouldBeResponsive = !self::valueIsFalse( $attributes[$responsiveAttr] );
|
| 483 |
}
|
| 484 |
|
| 485 |
break;
|
| 486 |
}
|
| 487 |
}
|
| 488 |
+
unset( $responsiveAttr, $responsiveAttributes );
|
| 489 |
}
|
| 490 |
|
| 491 |
$attributes['class'][] = 'ose-{provider_alias}';
|
| 492 |
|
| 493 |
+
if ( !empty( $content_uid ) ) {
|
| 494 |
$attributes['class'][] = 'ose-uid-' . $content_uid;
|
| 495 |
}
|
| 496 |
|
| 497 |
+
if ( $embedShouldBeResponsive && !$embedShouldHaveCustomDimensions ) {
|
| 498 |
$attributes['class'][] = 'responsive';
|
| 499 |
} else {
|
| 500 |
$attributes['data-responsive'] = "false";
|
| 501 |
}
|
| 502 |
|
| 503 |
+
$attributes['class'] = implode( ' ', array_unique( array_filter( $attributes['class'] ) ) );
|
| 504 |
+
if ( isset( $attributes['width'] ) ) {
|
| 505 |
$attributes['style'] = "width:{$attributes['width'] }px;height:{$attributes['height'] }px;";
|
| 506 |
}
|
| 507 |
|
| 511 |
/**
|
| 512 |
* Method that checks if a given value is/can be identified as (bool)false.
|
| 513 |
*
|
| 514 |
+
* @param mixed $subject The value to be checked.
|
| 515 |
+
*
|
| 516 |
+
* @return boolean
|
| 517 |
* @since 1.0.0
|
| 518 |
* @static
|
| 519 |
*
|
|
|
|
|
|
|
|
|
|
| 520 |
*/
|
| 521 |
+
public static function valueIsFalse( $subject ) {
|
| 522 |
+
$subject = strtolower( trim( (string)$subject ) );
|
| 523 |
+
switch ( $subject ) {
|
|
|
|
| 524 |
case "0":
|
| 525 |
case "false":
|
| 526 |
case "off":
|
| 538 |
* Return the value from a header which is in an array resulted from a get_headers() call.
|
| 539 |
* If the header cannot be found, this method will return null instead.
|
| 540 |
*
|
| 541 |
+
* @param string $headerPattern Regex pattern the header and its value must match.
|
| 542 |
+
* @param array $headersList A list of headers resulted from a get_headers() call.
|
| 543 |
+
*
|
| 544 |
+
* @return mixed
|
| 545 |
* @since 1.1.0
|
| 546 |
* @access private
|
| 547 |
* @static
|
| 548 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 549 |
*/
|
| 550 |
+
private static function extractContentFromHeaderAsArray( $headerPattern, $headersList ) {
|
|
|
|
| 551 |
$headerValue = null;
|
| 552 |
|
| 553 |
+
foreach ( $headersList as $header ) {
|
| 554 |
+
if ( preg_match( $headerPattern, $header, $matches ) ) {
|
| 555 |
$headerValue = $matches[1];
|
| 556 |
break;
|
| 557 |
}
|
| 565 |
* attributes from "dash" separated to "underline" separated to be able to access
|
| 566 |
* those attributes from the object, without having to convert it to an array.
|
| 567 |
*
|
| 568 |
+
* @param object $data
|
| 569 |
+
*
|
| 570 |
+
* @return object
|
| 571 |
* @since 1.6.1
|
| 572 |
* @access private
|
| 573 |
* @static
|
| 574 |
*
|
|
|
|
|
|
|
|
|
|
| 575 |
*/
|
| 576 |
+
private static function sanitizeUrlData( $data ) {
|
| 577 |
+
if ( is_object( $data ) ) {
|
| 578 |
+
$attributes = get_object_vars( $data );
|
|
|
|
| 579 |
|
| 580 |
+
foreach ( $attributes as $key => $value ) {
|
| 581 |
+
if ( substr_count( $key, '-' ) ) {
|
| 582 |
+
unset( $data->$key );
|
| 583 |
|
| 584 |
+
$key = str_replace( '-', '_', $key );
|
| 585 |
$data->$key = $value;
|
| 586 |
}
|
| 587 |
}
|
| 588 |
+
} elseif ( is_array( $data ) ) {
|
| 589 |
+
foreach ( $data as $key => $value ) {
|
| 590 |
+
if ( substr_count( $key, '-' ) ) {
|
| 591 |
+
unset( $data[$key] );
|
| 592 |
|
| 593 |
+
$key = str_replace( '-', '_', $key );
|
| 594 |
$data[$key] = $value;
|
| 595 |
}
|
| 596 |
}
|
Gutenberg/src/init.php
CHANGED
|
@@ -93,4 +93,4 @@ add_filter( 'block_categories', 'embedpress_block_category', 10, 2);
|
|
| 93 |
|
| 94 |
foreach ( glob( plugin_dir_path(__FILE__) . '*/index.php' ) as $block_logic ) {
|
| 95 |
require $block_logic;
|
| 96 |
-
}
|
| 93 |
|
| 94 |
foreach ( glob( plugin_dir_path(__FILE__) . '*/index.php' ) as $block_logic ) {
|
| 95 |
require $block_logic;
|
| 96 |
+
}
|
assets/js/settings.js
CHANGED
|
@@ -11,4 +11,19 @@
|
|
| 11 |
$(function () {
|
| 12 |
$('.color-field').wpColorPicker();
|
| 13 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
})(jQuery);
|
| 11 |
$(function () {
|
| 12 |
$('.color-field').wpColorPicker();
|
| 13 |
});
|
| 14 |
+
|
| 15 |
+
//control global embed iframe size
|
| 16 |
+
$('.enableglobalembedresize').on('change', embedpressEnableglobalembedresize);
|
| 17 |
+
embedpressEnableglobalembedresize();
|
| 18 |
+
|
| 19 |
+
function embedpressEnableglobalembedresize(e) {
|
| 20 |
+
var check = $('.enableglobalembedresize:checked').val();
|
| 21 |
+
var selector = $('.embedpress-allow-globla-dimension').closest( "tr" );
|
| 22 |
+
if(check!=='1'){
|
| 23 |
+
selector.hide();
|
| 24 |
+
}else{
|
| 25 |
+
selector.show();
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
})(jQuery);
|
embedpress.php
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
* Facebook, Google Maps, Google Docs, UStream! Just use the URL!
|
| 7 |
* Author: WPDeveloper
|
| 8 |
* Author URI: https://wpdeveloper.net
|
| 9 |
-
* Version: 2.4.
|
| 10 |
* Text Domain: embedpress
|
| 11 |
* Domain Path: /languages
|
| 12 |
*
|
| 6 |
* Facebook, Google Maps, Google Docs, UStream! Just use the URL!
|
| 7 |
* Author: WPDeveloper
|
| 8 |
* Author URI: https://wpdeveloper.net
|
| 9 |
+
* Version: 2.4.1
|
| 10 |
* Text Domain: embedpress
|
| 11 |
* Domain Path: /languages
|
| 12 |
*
|
includes.php
CHANGED
|
@@ -22,7 +22,7 @@ if ( ! defined('EMBEDPRESS_PLG_NAME')) {
|
|
| 22 |
}
|
| 23 |
|
| 24 |
if ( ! defined('EMBEDPRESS_VERSION')) {
|
| 25 |
-
define('EMBEDPRESS_VERSION', "2.4.
|
| 26 |
/**
|
| 27 |
* @deprecated 2.2.0
|
| 28 |
*/
|
|
@@ -30,7 +30,7 @@ if ( ! defined('EMBEDPRESS_VERSION')) {
|
|
| 30 |
}
|
| 31 |
|
| 32 |
if ( ! defined('EMBEDPRESS_PRO_VERSION')) {
|
| 33 |
-
define('EMBEDPRESS_PRO_VERSION', "2.
|
| 34 |
}
|
| 35 |
|
| 36 |
if ( ! defined('EMBEDPRESS_ROOT')) {
|
| 22 |
}
|
| 23 |
|
| 24 |
if ( ! defined('EMBEDPRESS_VERSION')) {
|
| 25 |
+
define('EMBEDPRESS_VERSION', "2.4.1");
|
| 26 |
/**
|
| 27 |
* @deprecated 2.2.0
|
| 28 |
*/
|
| 30 |
}
|
| 31 |
|
| 32 |
if ( ! defined('EMBEDPRESS_PRO_VERSION')) {
|
| 33 |
+
define('EMBEDPRESS_PRO_VERSION', "2.3.1");
|
| 34 |
}
|
| 35 |
|
| 36 |
if ( ! defined('EMBEDPRESS_ROOT')) {
|
readme.txt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
=== EmbedPress – Embed Google Docs, Vimeo and Wistia videos, Giphy and Imgur photos, and more ===
|
| 3 |
Contributors: EmbedPress, asif2bd, re_enter_rupok, wpdevteam, manzurahammed, andergmartins, stevejburge, pressshack, deenison
|
| 4 |
Author: WPDeveloper
|
|
@@ -7,7 +6,7 @@ Tags: embed, code, video embed, Youtube embed, map embed, content embed, iframes
|
|
| 7 |
Requires at least: 4.6
|
| 8 |
Tested up to: 5.3
|
| 9 |
Requires PHP: 5.6
|
| 10 |
-
Stable tag: 2.4.
|
| 11 |
License: GPLv2 or later
|
| 12 |
License URI: https://opensource.org/licenses/GPL-3.0
|
| 13 |
|
|
@@ -265,6 +264,8 @@ Not at all. You can set up everything your team needs without any coding knowled
|
|
| 265 |
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
| 266 |
and this project adheres to [Semantic Versioning](http://semver.org/).
|
| 267 |
|
|
|
|
|
|
|
| 268 |
|
| 269 |
= [2.4.0] - 2020-03-02 =
|
| 270 |
* Gutenberg Compatibility improvement
|
|
@@ -575,4 +576,4 @@ Added Wistia and Twitch blocks for Gutenberg
|
|
| 575 |
|
| 576 |
== Upgrade Notice ==
|
| 577 |
|
| 578 |
-
*
|
|
|
|
| 1 |
=== EmbedPress – Embed Google Docs, Vimeo and Wistia videos, Giphy and Imgur photos, and more ===
|
| 2 |
Contributors: EmbedPress, asif2bd, re_enter_rupok, wpdevteam, manzurahammed, andergmartins, stevejburge, pressshack, deenison
|
| 3 |
Author: WPDeveloper
|
| 6 |
Requires at least: 4.6
|
| 7 |
Tested up to: 5.3
|
| 8 |
Requires PHP: 5.6
|
| 9 |
+
Stable tag: 2.4.1
|
| 10 |
License: GPLv2 or later
|
| 11 |
License URI: https://opensource.org/licenses/GPL-3.0
|
| 12 |
|
| 264 |
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
| 265 |
and this project adheres to [Semantic Versioning](http://semver.org/).
|
| 266 |
|
| 267 |
+
= [2.4.1] - 2020-03-04 =
|
| 268 |
+
* Fixed global iFrame resize capacity
|
| 269 |
|
| 270 |
= [2.4.0] - 2020-03-02 =
|
| 271 |
* Gutenberg Compatibility improvement
|
| 576 |
|
| 577 |
== Upgrade Notice ==
|
| 578 |
|
| 579 |
+
* [Minor after 2.4.0] Fixed global iFrame resize capacity
|
