rebase from live enviornment
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// Note, this will be updated automatically during grunt release task
|
||||
$ET_BUILDER_VERSION = '3.17.3';
|
||||
1525
wp/plugins/divi-builder/includes/builder/ab-testing.php
Normal file
338
wp/plugins/divi-builder/includes/builder/api/DiviExtension.php
Normal file
@@ -0,0 +1,338 @@
|
||||
<?php
|
||||
/**
|
||||
* Divi extension base class.
|
||||
*
|
||||
* @package Builder
|
||||
* @subpackage API
|
||||
* @since 4.6.2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Core class used to implement the Divi Extension.
|
||||
*/
|
||||
class DiviExtension {
|
||||
|
||||
/**
|
||||
* Utility class instance.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var ET_Core_Data_Utils
|
||||
*/
|
||||
protected static $_;
|
||||
|
||||
/**
|
||||
* Dependencies for the extension's JavaScript bundles.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var array {
|
||||
* JavaScript Bundle Dependencies
|
||||
*
|
||||
* @type string[] $builder Dependencies for the builder bundle
|
||||
* @type string[] $frontend Dependencies for the frontend bundle
|
||||
* }
|
||||
*/
|
||||
protected $_bundle_dependencies = array();
|
||||
|
||||
/**
|
||||
* Builder bundle data
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_builder_js_data = array();
|
||||
|
||||
/**
|
||||
* Frontend bundle data
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_frontend_js_data = array();
|
||||
|
||||
/**
|
||||
* Whether or not the extension's debug mode is enabled. This should always be enabled
|
||||
* during development and never be enabled in production.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_debug;
|
||||
|
||||
/**
|
||||
* The gettext domain for the extension's translations.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $gettext_domain;
|
||||
|
||||
/**
|
||||
* The extension's WP Plugin name.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* Absolute path to the extension's directory.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $plugin_dir;
|
||||
|
||||
/**
|
||||
* The extension's directory URL.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $plugin_dir_url;
|
||||
|
||||
/**
|
||||
* The extension's version.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/**
|
||||
* DiviExtension constructor.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param string $name This Divi Extension's WP Plugin name/slug.
|
||||
* @param array $args Argument flexibility for child classes.
|
||||
*/
|
||||
public function __construct( $name = '', $args = array() ) {
|
||||
if ( ! self::$_ ) {
|
||||
self::$_ = ET_Core_Data_Utils::instance();
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
if ( $this->name ) {
|
||||
$this->_initialize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues minified, production javascript bundles.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function _enqueue_bundles() {
|
||||
// Frontend Bundle.
|
||||
$bundle_url = "{$this->plugin_dir_url}scripts/frontend-bundle.min.js";
|
||||
|
||||
wp_enqueue_script( "{$this->name}-frontend-bundle", $bundle_url, $this->_bundle_dependencies['frontend'], $this->version, true );
|
||||
|
||||
if ( et_core_is_fb_enabled() ) {
|
||||
// Builder Bundle.
|
||||
$bundle_url = "{$this->plugin_dir_url}scripts/builder-bundle.min.js";
|
||||
|
||||
wp_enqueue_script( "{$this->name}-builder-bundle", $bundle_url, $this->_bundle_dependencies['builder'], $this->version, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues non-minified, hot reloaded javascript bundles.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function _enqueue_debug_bundles() {
|
||||
// Frontend Bundle.
|
||||
$site_url = wp_parse_url( get_site_url() );
|
||||
$hot_bundle_url = "{$site_url['scheme']}://{$site_url['host']}:3000/static/js/frontend-bundle.js";
|
||||
|
||||
wp_enqueue_script( "{$this->name}-frontend-bundle", $hot_bundle_url, $this->_bundle_dependencies['frontend'], $this->version, true );
|
||||
|
||||
if ( et_core_is_fb_enabled() ) {
|
||||
// Builder Bundle.
|
||||
$hot_bundle_url = "{$site_url['scheme']}://{$site_url['host']}:3000/static/js/builder-bundle.js";
|
||||
|
||||
wp_enqueue_script( "{$this->name}-builder-bundle", $hot_bundle_url, $this->_bundle_dependencies['builder'], $this->version, true );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues minified (production) or non-minified (hot reloaded) backend styles.
|
||||
*
|
||||
* @since 4.4.9
|
||||
*/
|
||||
protected function _enqueue_backend_styles() {
|
||||
if ( $this->_debug ) {
|
||||
$site_url = wp_parse_url( get_site_url() );
|
||||
$backend_styles_url = "{$site_url['scheme']}://{$site_url['host']}:3000/styles/backend-style.css";
|
||||
} else {
|
||||
$extension_dir_path = plugin_dir_path( $this->plugin_dir );
|
||||
$backend_styles_path = "{$extension_dir_path}styles/backend-style.min.css";
|
||||
$backend_styles_url = "{$this->plugin_dir_url}styles/backend-style.min.css";
|
||||
|
||||
// Ensure backend style CSS file exists on production.
|
||||
if ( ! file_exists( $backend_styles_path ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Backend Styles - VB.
|
||||
wp_enqueue_style( "{$this->name}-backend-styles", $backend_styles_url, array(), $this->version );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets initial value of {@see self::$_bundle_dependencies}.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function _set_bundle_dependencies() {
|
||||
/**
|
||||
* Builder script handle name
|
||||
*
|
||||
* @since 3.??
|
||||
*
|
||||
* @param string
|
||||
*/
|
||||
$builder_modules_script_handle = apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' );
|
||||
|
||||
$this->_bundle_dependencies = array(
|
||||
'builder' => array( 'react-dom', "{$this->name}-frontend-bundle" ),
|
||||
'frontend' => array( 'jquery', $builder_modules_script_handle ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@see self::$_debug} based on the extension's global DEBUG constant.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function _set_debug_mode() {
|
||||
$name_parts = explode( '_', get_class( $this ) );
|
||||
$prefix = strtoupper( $name_parts[0] );
|
||||
$debug = $prefix . '_DEBUG';
|
||||
|
||||
$this->_debug = defined( $debug ) && constant( $debug );
|
||||
|
||||
if ( $this->_debug && ! DiviExtensions::register_debug_mode( $this ) ) {
|
||||
$this->_debug = false;
|
||||
|
||||
et_error( "You're Doing It Wrong! Only one Divi Extension can be in debug mode at a time." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads custom modules when the builder is ready.
|
||||
* {@see 'et_builder_modules_loaded'}
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function hook_et_builder_modules_loaded() {
|
||||
if ( file_exists( "{$this->plugin_dir}loader.php" ) ) {
|
||||
require_once "{$this->plugin_dir}loader.php";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs initialization tasks.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
protected function _initialize() {
|
||||
DiviExtensions::add( $this );
|
||||
|
||||
$this->_set_debug_mode();
|
||||
$this->_set_bundle_dependencies();
|
||||
|
||||
// Setup translations.
|
||||
load_plugin_textdomain( $this->gettext_domain, false, basename( $this->plugin_dir ) . '/languages' );
|
||||
|
||||
// Register callbacks.
|
||||
register_activation_hook( "{$this->plugin_dir}/{$this->name}.php", array( $this, 'wp_hook_activate' ) );
|
||||
register_deactivation_hook( "{$this->plugin_dir}/{$this->name}.php", array( $this, 'wp_hook_deactivate' ) );
|
||||
|
||||
add_action( 'et_builder_modules_loaded', array( $this, 'hook_et_builder_modules_loaded' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'wp_hook_enqueue_scripts' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_hook_enqueue_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs tasks when the plugin is activated.
|
||||
* {@see 'activate_$PLUGINNAME'}
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function wp_hook_activate() {
|
||||
// Force the legacy backend builder to reload its template cache.
|
||||
// This ensures that custom modules are available for use right away.
|
||||
et_pb_force_regenerate_templates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs tasks when the plugin is deactivated.
|
||||
* {@see 'deactivate_$PLUGINNAME'}
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public function wp_hook_deactivate() {}
|
||||
|
||||
/**
|
||||
* Enqueues the extension's scripts and styles.
|
||||
* {@see 'wp_enqueue_scripts'}
|
||||
*
|
||||
* @since 3.1
|
||||
* @since 4.4.9 Added backend styles for handling custom builder styles.
|
||||
*/
|
||||
public function wp_hook_enqueue_scripts() {
|
||||
if ( $this->_debug ) {
|
||||
$this->_enqueue_debug_bundles();
|
||||
} else {
|
||||
$styles = et_is_builder_plugin_active() ? 'style-dbp' : 'style';
|
||||
$styles_url = "{$this->plugin_dir_url}styles/{$styles}.min.css";
|
||||
|
||||
wp_enqueue_style( "{$this->name}-styles", $styles_url, array(), $this->version );
|
||||
|
||||
$this->_enqueue_bundles();
|
||||
}
|
||||
|
||||
if ( et_core_is_fb_enabled() && ! et_builder_bfb_enabled() ) {
|
||||
$this->_enqueue_backend_styles();
|
||||
}
|
||||
|
||||
// Normalize the extension name to get actual script name. For example from 'divi-custom-modules' to `DiviCustomModules`.
|
||||
$extension_name = str_replace( ' ', '', ucwords( str_replace( '-', ' ', $this->name ) ) );
|
||||
|
||||
// Enqueue frontend bundle's data.
|
||||
if ( ! empty( $this->_frontend_js_data ) ) {
|
||||
wp_localize_script( "{$this->name}-frontend-bundle", "{$extension_name}FrontendData", $this->_frontend_js_data );
|
||||
}
|
||||
|
||||
// Enqueue builder bundle's data.
|
||||
if ( et_core_is_fb_enabled() && ! empty( $this->_builder_js_data ) ) {
|
||||
wp_localize_script( "{$this->name}-builder-bundle", "{$extension_name}BuilderData", $this->_builder_js_data );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueues the extension's scripts and styles for admin area.
|
||||
*
|
||||
* @since 4.4.9
|
||||
*/
|
||||
public function admin_hook_enqueue_scripts() {
|
||||
if ( et_builder_bfb_enabled() || et_builder_is_tb_admin_screen() ) {
|
||||
$this->_enqueue_backend_styles();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
new DiviExtension();
|
||||
123
wp/plugins/divi-builder/includes/builder/api/DiviExtensions.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* Extension API: DiviExtensions class.
|
||||
*
|
||||
* @package Builder
|
||||
* @subpackage API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Composite class to manage all Divi Extensions.
|
||||
*/
|
||||
class DiviExtensions {
|
||||
|
||||
/**
|
||||
* Utility class instance.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var ET_Core_Data_Utils
|
||||
*/
|
||||
protected static $_;
|
||||
|
||||
/**
|
||||
* The first extension to enable debug mode for itself. Only one Divi Extension can be in
|
||||
* debug mode at a time.
|
||||
*
|
||||
* @var DiviExtension
|
||||
*/
|
||||
protected static $_debugging_extension;
|
||||
|
||||
/**
|
||||
* List of all instances of the Divi Extension.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @var DiviExtension[] {
|
||||
* All current Divi Extension instances
|
||||
*
|
||||
* @type DiviExtension $name Instance
|
||||
* }
|
||||
*/
|
||||
private static $_extensions;
|
||||
|
||||
/**
|
||||
* Register a Divi Extension instance.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param DiviExtension $instance Instance.
|
||||
*/
|
||||
public static function add( $instance ) {
|
||||
if ( ! isset( self::$_extensions[ $instance->name ] ) ) {
|
||||
self::$_extensions[ $instance->name ] = $instance;
|
||||
} else {
|
||||
et_error( "A Divi Extension named {$instance->name} already exists!" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one or all Divi Extension instances.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param string $name The extension name. Default: 'all'.
|
||||
*
|
||||
* @return DiviExtension|DiviExtension[]|null
|
||||
*/
|
||||
public static function get( $name = 'all' ) {
|
||||
if ( 'all' === $name ) {
|
||||
return self::$_extensions;
|
||||
}
|
||||
|
||||
return self::$_->array_get( self::$_extensions, $name, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the base `DiviExtension` class.
|
||||
*/
|
||||
public static function initialize() {
|
||||
self::$_ = ET_Core_Data_Utils::instance();
|
||||
|
||||
require_once ET_BUILDER_DIR . 'api/DiviExtension.php';
|
||||
|
||||
/**
|
||||
* Fires when the {@see DiviExtension} base class is available.
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
do_action( 'divi_extensions_init' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not a Divi Extension is in debug mode.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_debugging_extension() {
|
||||
return ! is_null( self::$_debugging_extension );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register's an extension instance for debug mode if one hasn't already been registered.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @param DiviExtension $instance Instance.
|
||||
*
|
||||
* @return bool Whether or not request was successful
|
||||
*/
|
||||
public static function register_debug_mode( $instance ) {
|
||||
if ( ! self::$_debugging_extension ) {
|
||||
self::$_debugging_extension = $instance;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DiviExtensions::initialize();
|
||||
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* Rest API: Layout Block
|
||||
*
|
||||
* @package Divi
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for custom REST API endpoint for Divi Layout block.
|
||||
*/
|
||||
class ET_Api_Rest_Block_Layout {
|
||||
|
||||
/**
|
||||
* Instance of `ET_Api_Rest_Block_Layout`.
|
||||
*
|
||||
* @var ET_Api_Rest_Block_Layout
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* ET_Api_Rest_Block_Layout constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class instance
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return object class instance
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register callback for Layout block REST API
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function register() {
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register REST API routes for Layout block
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route(
|
||||
'divi/v1',
|
||||
'get_layout_content',
|
||||
array(
|
||||
'methods' => 'POST',
|
||||
'callback' => array( $this, 'get_layout_content_callback' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
// using intval directly doesn't work, hence the custom callback.
|
||||
'sanitize_callback' => array( $this, 'sanitize_int' ),
|
||||
'validation_callback' => 'is_numeric',
|
||||
),
|
||||
'nonce' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
),
|
||||
'permission_callback' => array( $this, 'rest_api_layout_block_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'divi/v1',
|
||||
'block/layout/builder_edit_data',
|
||||
array(
|
||||
'methods' => 'POST',
|
||||
'callback' => array( $this, 'process_builder_edit_data' ),
|
||||
'args' => array(
|
||||
'action' => array(
|
||||
'sanitize_callback' => array( $this, 'sanitize_action' ), // update|delete|get.
|
||||
'validation_callback' => array( $this, 'validate_action' ),
|
||||
),
|
||||
'postId' => array(
|
||||
'sanitize_callback' => array( $this, 'sanitize_int' ),
|
||||
'validation_callback' => 'is_numeric',
|
||||
),
|
||||
'blockId' => array(
|
||||
'sanitize_callback' => 'sanitize_title',
|
||||
),
|
||||
'layoutContent' => array(
|
||||
'sanitize_callback' => 'wp_kses_post',
|
||||
),
|
||||
'nonce' => array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
),
|
||||
),
|
||||
'permission_callback' => array( $this, 'rest_api_layout_block_permission' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get layout content based on given post ID
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param WP_REST_Request $request Full details about the request.
|
||||
*
|
||||
* @return string|WP_Error
|
||||
*/
|
||||
public function get_layout_content_callback( WP_REST_Request $request ) {
|
||||
$post_id = $request->get_param( 'id' );
|
||||
$nonce = $request->get_param( 'nonce' );
|
||||
|
||||
// Action nonce check. REST API actually has checked for nonce at cookie sent on every
|
||||
// request and performed capability-based check. This check perform action-based nonce
|
||||
// check to strengthen the security
|
||||
// @see https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/.
|
||||
if ( ! wp_verify_nonce( $nonce, 'et_rest_get_layout_content' ) ) {
|
||||
return new WP_Error(
|
||||
'invalid_nonce',
|
||||
esc_html__( 'Invalid nonce', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// request has to have id param.
|
||||
if ( ! $post_id ) {
|
||||
return new WP_Error(
|
||||
'no_layout_id',
|
||||
esc_html__( 'No layout id found', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! isset( $post->post_content ) || ! $post->post_content ) {
|
||||
return new WP_Error(
|
||||
'no_layout_found',
|
||||
esc_html__( 'No valid layout content found.', 'et_builder' ),
|
||||
array(
|
||||
'status' => 404,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $post->post_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process /block/layout/builder_edit_data route request
|
||||
*
|
||||
* @param WP_Rest_Request $request Request to prepare items for.
|
||||
*
|
||||
* @return string|WP_Error
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function process_builder_edit_data( WP_Rest_Request $request ) {
|
||||
$post_id = $request->get_param( 'postId' );
|
||||
$block_id = $request->get_param( 'blockId' );
|
||||
$nonce = $request->get_param( 'nonce' );
|
||||
|
||||
// No post ID.
|
||||
if ( empty( $post_id ) ) {
|
||||
return new WP_Error(
|
||||
'no_post_id',
|
||||
esc_html__( 'No post id', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// No block ID.
|
||||
if ( empty( $block_id ) ) {
|
||||
return new WP_Error(
|
||||
'no_block_id',
|
||||
esc_html__( 'No block id', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Action nonce check. REST API actually has checked for nonce at cookie sent on every
|
||||
// request and performed capability-based check. This check perform action-based nonce
|
||||
// check to strengthen the security
|
||||
// @see https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/.
|
||||
if ( ! wp_verify_nonce( $nonce, 'et_rest_process_builder_edit_data' ) ) {
|
||||
return new WP_Error(
|
||||
'invalid_nonce',
|
||||
esc_html__( 'Invalid nonce', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$post_meta_key = "_et_block_layout_preview_{$block_id}";
|
||||
|
||||
switch ( $request->get_param( 'action' ) ) {
|
||||
case 'get':
|
||||
$result = get_post_meta( $post_id, $post_meta_key, true );
|
||||
break;
|
||||
case 'update':
|
||||
$layout_content = $request->get_param( 'layoutContent' );
|
||||
|
||||
// No layout content.
|
||||
if ( empty( $layout_content ) ) {
|
||||
return new WP_Error(
|
||||
'no_layout_content',
|
||||
esc_html__( 'No layout content', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$saved_layout_content = get_post_meta( $post_id, $post_meta_key, true );
|
||||
|
||||
if ( ! empty( $saved_layout_content ) && $saved_layout_content === $layout_content ) {
|
||||
// If for some reason layout exist and identical to the one being sent, return
|
||||
// true because update_post_meta() returns false if it updates the meta key and
|
||||
// the value doesn't change.
|
||||
$result = true;
|
||||
} else {
|
||||
// Otherwise, attempt to save post meta and returns how it goes.
|
||||
$result = update_post_meta(
|
||||
$post_id,
|
||||
$post_meta_key,
|
||||
$layout_content
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
case 'delete':
|
||||
$result = delete_post_meta( $post_id, $post_meta_key );
|
||||
break;
|
||||
default:
|
||||
return new WP_Error(
|
||||
'no_valid_action',
|
||||
esc_html__( 'No valid action found', 'et_builder' ),
|
||||
array(
|
||||
'status' => 400,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'result' => $result,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize int value
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param int|mixed $value Value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function sanitize_int( $value ) {
|
||||
return intval( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize request "action" argument
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $value Action value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function sanitize_action( $value ) {
|
||||
return $this->validate_action( $value ) ? $value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate request "action" argument
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $value Action value.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate_action( $value ) {
|
||||
$valid_builder_edit_data_actions = array(
|
||||
'get',
|
||||
'update',
|
||||
'delete',
|
||||
);
|
||||
|
||||
return in_array( $value, $valid_builder_edit_data_actions, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission callback for get layout permalink REST API endpoint
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function rest_api_layout_block_permission() {
|
||||
return current_user_can( 'edit_posts' ) && et_pb_is_allowed( 'use_visual_builder' );
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize ET_Api_Rest_Block_Layout.
|
||||
ET_Api_Rest_Block_Layout::instance();
|
||||
364
wp/plugins/divi-builder/includes/builder/autoload.php
Normal file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/**
|
||||
* Register autoloader.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
* @since 4.6.2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Autoloader for module helpers and structure elements.
|
||||
*
|
||||
* @param string $class The class name.
|
||||
*/
|
||||
function _et_pb_autoload( $class ) {
|
||||
switch ( $class ) {
|
||||
case 'ET_Builder_Section':
|
||||
case 'ET_Builder_Row':
|
||||
case 'ET_Builder_Row_Inner':
|
||||
case 'ET_Builder_Column':
|
||||
require_once 'main-structure-elements.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Multi_Value':
|
||||
require_once 'module/helpers/MultiValue.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Overflow':
|
||||
require_once 'module/helpers/Overflow.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Alignment':
|
||||
require_once 'module/helpers/Alignment.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Sizing':
|
||||
require_once 'module/helpers/Sizing.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Height':
|
||||
require_once 'module/helpers/Height.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Hover_Options':
|
||||
require_once 'module/helpers/HoverOptions.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Sticky_Options':
|
||||
require_once 'module/helpers/StickyOptions.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Max_Height':
|
||||
require_once 'module/helpers/MaxHeight.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Max_Width':
|
||||
require_once 'module/helpers/MaxWidth.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Min_Height':
|
||||
require_once 'module/helpers/MinHeight.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_ResponsiveOptions':
|
||||
require_once 'module/helpers/ResponsiveOptions.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Slider':
|
||||
require_once 'module/helpers/Slider.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Transition_Options':
|
||||
require_once 'module/helpers/TransitionOptions.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Width':
|
||||
require_once 'module/helpers/Width.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion':
|
||||
require_once 'module/helpers/motion/Motion.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Sanitizer':
|
||||
require_once 'module/helpers/motion/Sanitizer.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Opacity':
|
||||
require_once 'module/helpers/motion/Opacity.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Translate':
|
||||
require_once 'module/helpers/motion/Translate.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Scale':
|
||||
require_once 'module/helpers/motion/Scale.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Rotate':
|
||||
require_once 'module/helpers/motion/Rotate.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Motion_Blur':
|
||||
require_once 'module/helpers/motion/Blur.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Field_Base':
|
||||
require_once 'module/field/Base.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Fields_Factory':
|
||||
require_once 'module/field/Factory.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Overlay':
|
||||
require_once 'module/helpers/Overlay.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_MultiViewOptions':
|
||||
require_once 'module/helpers/MultiViewOptions.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_OptionTemplate':
|
||||
require_once 'module/helpers/OptionTemplate.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Style_Processor':
|
||||
require_once 'module/helpers/StyleProcessor.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Font':
|
||||
require_once 'module/helpers/Font.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Background':
|
||||
require_once 'module/helpers/Background.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_BackgroundLayout':
|
||||
require_once 'module/helpers/BackgroundLayout.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Woocommerce_Modules':
|
||||
if ( et_is_woocommerce_plugin_active() ) {
|
||||
require_once 'module/helpers/WooCommerceModules.php';
|
||||
}
|
||||
break;
|
||||
case 'ET_Builder_I18n':
|
||||
require_once 'feature/I18n.php';
|
||||
break;
|
||||
case 'ET_Builder_Module_Helper_Media':
|
||||
require_once 'module/helpers/class-et-builder-module-helper-media.php';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register( '_et_pb_autoload' );
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Multi_Value`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Multi_Value
|
||||
*/
|
||||
function et_pb_multi_value() {
|
||||
return ET_Builder_Module_Helper_Multi_Value::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Overflow`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Overflow
|
||||
*/
|
||||
function et_pb_overflow() {
|
||||
return ET_Builder_Module_Helper_Overflow::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Alignment`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Alignment
|
||||
*/
|
||||
function et_pb_alignment_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Alignment( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Height`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Height
|
||||
*/
|
||||
function et_pb_height_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Height( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Hover_Options`.
|
||||
*
|
||||
* @return ET_Builder_Module_Hover_Options
|
||||
*/
|
||||
function et_pb_hover_options() {
|
||||
return ET_Builder_Module_Hover_Options::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sticky option instance.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return ET_Builder_Module_Sticky_Options
|
||||
*/
|
||||
function et_pb_sticky_options() {
|
||||
return ET_Builder_Module_Sticky_Options::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Max_Height`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Max_Height
|
||||
*/
|
||||
function et_pb_max_height_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Max_Height( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Max_Width`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Max_Width
|
||||
*/
|
||||
function et_pb_max_width_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Max_Width( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Min_Height`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Min_Height
|
||||
*/
|
||||
function et_pb_min_height_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Min_Height( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_ResponsiveOptions`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_ResponsiveOptions
|
||||
*/
|
||||
function et_pb_responsive_options() {
|
||||
return ET_Builder_Module_Helper_ResponsiveOptions::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Slider`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Slider
|
||||
*/
|
||||
function et_pb_slider_options() {
|
||||
return new ET_Builder_Module_Helper_Slider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Transition_Options`.
|
||||
*
|
||||
* @return ET_Builder_Module_Transition_Options
|
||||
*/
|
||||
function et_pb_transition_options() {
|
||||
return ET_Builder_Module_Transition_Options::get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Width`.
|
||||
*
|
||||
* @param string $prefix The prefix string that may be added to field name.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Width
|
||||
*/
|
||||
function et_pb_width_options( $prefix = '' ) {
|
||||
return new ET_Builder_Module_Helper_Width( $prefix );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Font`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Font
|
||||
*/
|
||||
function et_pb_font_options() {
|
||||
return ET_Builder_Module_Helper_Font::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_BackgroundLayout`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_BackgroundLayout
|
||||
*/
|
||||
function et_pb_background_layout_options() {
|
||||
return ET_Builder_Module_Helper_BackgroundLayout::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get helper instance
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param string $helper_name Helper name.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
function et_builder_get_helper( $helper_name ) {
|
||||
switch ( $helper_name ) {
|
||||
case 'sticky':
|
||||
$helper = et_pb_sticky_options();
|
||||
break;
|
||||
|
||||
case 'hover':
|
||||
$helper = et_pb_hover_options();
|
||||
break;
|
||||
|
||||
case 'responsive':
|
||||
$helper = et_pb_responsive_options();
|
||||
break;
|
||||
|
||||
default:
|
||||
$helper = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ET_Builder_Module_Helper_MultiViewOptions wrapper
|
||||
*
|
||||
* @since 3.27.1
|
||||
*
|
||||
* @param ET_Builder_Element|bool $module Module object.
|
||||
* @param array $custom_props Defined custom props data.
|
||||
* @param array $conditional_values Defined options conditional values.
|
||||
* @param array $default_values Defined options default values.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_MultiViewOptions
|
||||
*/
|
||||
function et_pb_multi_view_options( $module = false, $custom_props = array(), $conditional_values = array(), $default_values = array() ) {
|
||||
return new ET_Builder_Module_Helper_MultiViewOptions( $module, $custom_props, $conditional_values, $default_values );
|
||||
}
|
||||
|
||||
if ( et_is_woocommerce_plugin_active() ) {
|
||||
add_filter(
|
||||
'et_builder_get_woo_default_columns',
|
||||
array(
|
||||
'ET_Builder_Module_Helper_Woocommerce_Modules',
|
||||
'get_columns_posts_default_value',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_OptionTemplate`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_OptionTemplate
|
||||
*/
|
||||
function et_pb_option_template() {
|
||||
return ET_Builder_Module_Helper_OptionTemplate::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instance of `ET_Builder_Module_Helper_Background`.
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Background
|
||||
*
|
||||
* @since 4.3.3
|
||||
*/
|
||||
function et_pb_background_options() {
|
||||
return ET_Builder_Module_Helper_Background::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ET_Builder_Module_Helper_Media wrapper
|
||||
*
|
||||
* @since 4.6.4
|
||||
*
|
||||
* @return ET_Builder_Module_Helper_Media
|
||||
*/
|
||||
function et_pb_media_options() {
|
||||
return ET_Builder_Module_Helper_Media::instance();
|
||||
}
|
||||
22928
wp/plugins/divi-builder/includes/builder/class-et-builder-element.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for plugin compatibility file
|
||||
*
|
||||
* @since 0.7 (builder version)
|
||||
*/
|
||||
class ET_Builder_Plugin_Compat_Base {
|
||||
public $plugin_id;
|
||||
|
||||
/**
|
||||
* Get plugin dir path based on plugin_id
|
||||
*
|
||||
* @return sting
|
||||
*/
|
||||
function get_plugin_dir_path() {
|
||||
return WP_PLUGIN_DIR . '/' . $this->plugin_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin data based on initialized plugin_id
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_plugin_data() {
|
||||
return get_plugin_data( $this->get_plugin_dir_path(), false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin version based on initialized plugin_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_plugin_version() {
|
||||
$plugin_data = $this->get_plugin_data();
|
||||
|
||||
if ( ! isset( $plugin_data['Version'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_data['Version'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Load plugin compatibility file if supported plugins are activated.
|
||||
*
|
||||
* @since 0.7 (builder version)
|
||||
*
|
||||
* @package Divi
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ET_Builder_Plugin_Compat_Loader.
|
||||
*/
|
||||
class ET_Builder_Plugin_Compat_Loader {
|
||||
/**
|
||||
* Unique instance of class.
|
||||
*
|
||||
* @var ET_Builder_Plugin_Compat_Loader
|
||||
*/
|
||||
public static $instance;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
private function __construct() {
|
||||
$this->init_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the class.
|
||||
*/
|
||||
public static function init() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook methods to WordPress action and filter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function init_hooks() {
|
||||
// Load plugin.php for frontend usage.
|
||||
if ( ! function_exists( 'is_plugin_active' ) || ! function_exists( 'get_plugins' ) ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
// Loop plugin list and load active plugin compatibility file.
|
||||
foreach ( array_keys( get_plugins() ) as $plugin ) {
|
||||
// Load plugin compat file if plugin is active.
|
||||
if ( is_plugin_active( $plugin ) ) {
|
||||
$plugin_compat_name = dirname( $plugin );
|
||||
$plugin_compat_url = apply_filters(
|
||||
"et_builder_plugin_compat_path_{$plugin_compat_name}",
|
||||
ET_BUILDER_DIR . "plugin-compat/{$plugin_compat_name}.php",
|
||||
$plugin_compat_name
|
||||
);
|
||||
|
||||
// Load plugin compat file (if compat file found).
|
||||
if ( file_exists( $plugin_compat_url ) ) {
|
||||
require_once $plugin_compat_url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ET_Builder_Plugin_Compat_Loader::init();
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Represent a simple value or a dynamic one.
|
||||
* Used for module attributes and content.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
* @since 3.17.2
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class ET_Builder_Value.
|
||||
*/
|
||||
class ET_Builder_Value {
|
||||
/**
|
||||
* Flag whether the value is static or dynamic.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $dynamic = false;
|
||||
|
||||
/**
|
||||
* Value content. Represents the dynamic content type when dynamic.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
/**
|
||||
* Array of dynamic content settings.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
protected $settings = array();
|
||||
|
||||
/**
|
||||
* ET_Builder_Value constructor.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @param boolean $dynamic Whether content is dynamic.
|
||||
* @param string $content Value content.
|
||||
* @param array $settings Dynamic content settings.
|
||||
*/
|
||||
public function __construct( $dynamic, $content, $settings = array() ) {
|
||||
$this->dynamic = $dynamic;
|
||||
$this->content = $content;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the value is dynamic or not.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_dynamic() {
|
||||
return $this->dynamic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value content.
|
||||
*
|
||||
* @since 4.4.4
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resolved content.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @param integer $post_id Post id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function resolve( $post_id ) {
|
||||
if ( ! $this->dynamic ) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
return et_builder_resolve_dynamic_content( $this->content, $this->settings, $post_id, 'display' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the static content or a serialized representation of the dynamic one.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serialize() {
|
||||
if ( ! $this->dynamic ) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
return et_builder_serialize_dynamic_content( $this->dynamic, $this->content, $this->settings );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,756 @@
|
||||
<?php
|
||||
/**
|
||||
* Global modules settings.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
*/
|
||||
|
||||
/**
|
||||
* Global settings class.
|
||||
*
|
||||
* @todo Rename this class to `ET_Builder_Module_Settings` so that its name clearly indicates its purpose.
|
||||
*/
|
||||
class ET_Global_Settings {
|
||||
/**
|
||||
* List of default settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $_settings = array();
|
||||
|
||||
/**
|
||||
* Whether reinit default setting values.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private static $_reinit_values = false;
|
||||
|
||||
/**
|
||||
* Initialize the global settings.
|
||||
*/
|
||||
public static function init() {
|
||||
// The class can only be initialized once.
|
||||
if ( ! empty( self::$_settings ) && ! self::$_reinit_values ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset _reinit_values property. It should only used once for every reinit() method call.
|
||||
if ( self::$_reinit_values ) {
|
||||
self::$_reinit_values = false;
|
||||
}
|
||||
|
||||
self::set_values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow global settings value to be reinitialized. Initially added a to make global
|
||||
* settings modifieable during unit/integration testing which uses PHPUnit & wp-browser
|
||||
*/
|
||||
public static function reinit() {
|
||||
self::$_reinit_values = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default global setting value
|
||||
*/
|
||||
private static function set_values() {
|
||||
$hover = et_pb_hover_options();
|
||||
|
||||
$font_defaults_h1 = array(
|
||||
'size' => '30px',
|
||||
'letter_spacing' => '0px',
|
||||
'line_height' => '1em',
|
||||
);
|
||||
|
||||
$font_defaults_h2 = array(
|
||||
'size' => '26px',
|
||||
'letter_spacing' => '0px',
|
||||
'line_height' => '1em',
|
||||
);
|
||||
|
||||
$font_defaults = array(
|
||||
'size' => '14',
|
||||
'color' => '#666666',
|
||||
'letter_spacing' => '0px',
|
||||
'line_height' => '1.7em',
|
||||
);
|
||||
|
||||
$background_gradient_defaults = array(
|
||||
'start' => '#2b87da',
|
||||
'end' => '#29c4a9',
|
||||
'type' => 'linear',
|
||||
'direction' => '180deg',
|
||||
'direction_radial' => 'center',
|
||||
'start_position' => '0%',
|
||||
'end_position' => '100%',
|
||||
'overlays_image' => 'off',
|
||||
);
|
||||
|
||||
$background_image_defaults = array(
|
||||
'size' => 'cover',
|
||||
'position' => 'center',
|
||||
'repeat' => 'no-repeat',
|
||||
'blend' => 'normal',
|
||||
);
|
||||
|
||||
$background_blend_mode_defaults = array(
|
||||
'background_blend_mode' => $background_image_defaults['blend'],
|
||||
);
|
||||
|
||||
$filter_defaults = array(
|
||||
'filter_hue_rotate' => '0deg',
|
||||
'filter_saturate' => '100%',
|
||||
'filter_brightness' => '100%',
|
||||
'filter_contrast' => '100%',
|
||||
'filter_invert' => '0%',
|
||||
'filter_sepia' => '0%',
|
||||
'filter_opacity' => '100%',
|
||||
'filter_blur' => '0px',
|
||||
);
|
||||
|
||||
$defaults = array(
|
||||
// Global: Buttons.
|
||||
'all_buttons_font_size' => '20',
|
||||
'all_buttons_border_width' => '2',
|
||||
'all_buttons_border_radius' => '3',
|
||||
'all_buttons_spacing' => '0',
|
||||
'all_buttons_font_style' => '',
|
||||
$hover->get_hover_field( 'all_buttons_border_radius' ) => '3',
|
||||
$hover->get_hover_field( 'all_buttons_spacing' ) => '0',
|
||||
// Global: Background Gradients.
|
||||
'all_background_gradient_start' => $background_gradient_defaults['start'],
|
||||
'all_background_gradient_end' => $background_gradient_defaults['end'],
|
||||
'all_background_gradient_type' => $background_gradient_defaults['type'],
|
||||
'all_background_gradient_direction' => $background_gradient_defaults['direction'],
|
||||
'all_background_gradient_direction_radial' => $background_gradient_defaults['direction_radial'],
|
||||
'all_background_gradient_start_position' => $background_gradient_defaults['start_position'],
|
||||
'all_background_gradient_end_position' => $background_gradient_defaults['end_position'],
|
||||
'all_background_gradient_overlays_image' => $background_gradient_defaults['overlays_image'],
|
||||
// Global: Filters.
|
||||
'all_filter_hue_rotate' => $filter_defaults['filter_hue_rotate'],
|
||||
'all_filter_saturate' => $filter_defaults['filter_saturate'],
|
||||
'all_filter_brightness' => $filter_defaults['filter_brightness'],
|
||||
'all_filter_contrast' => $filter_defaults['filter_contrast'],
|
||||
'all_filter_invert' => $filter_defaults['filter_invert'],
|
||||
'all_filter_sepia' => $filter_defaults['filter_sepia'],
|
||||
'all_filter_opacity' => $filter_defaults['filter_opacity'],
|
||||
'all_filter_blur' => $filter_defaults['filter_blur'],
|
||||
// Global: Mix Blend Mode.
|
||||
'all_mix_blend_mode' => 'normal',
|
||||
// Module: Accordion.
|
||||
'et_pb_accordion-toggle_font_size' => '16',
|
||||
'et_pb_accordion-toggle_font_style' => '',
|
||||
'et_pb_accordion-inactive_toggle_font_style' => '',
|
||||
'et_pb_accordion-toggle_icon_size' => '16',
|
||||
'et_pb_accordion-custom_padding' => '20',
|
||||
'et_pb_accordion-toggle_line_height' => '1em',
|
||||
'et_pb_accordion-toggle_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_accordion-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_accordion-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_accordion-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Audio.
|
||||
'et_pb_audio-title_font_size' => '26',
|
||||
'et_pb_audio-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_audio-title_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_audio-title_font_style' => '',
|
||||
'et_pb_audio-caption_font_size' => $font_defaults['size'],
|
||||
'et_pb_audio-caption_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_audio-caption_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_audio-caption_font_style' => '',
|
||||
'et_pb_audio-title_text_color' => '#666666',
|
||||
'et_pb_audio-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_audio-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_audio-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_audio-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Blog.
|
||||
'et_pb_blog-header_font_size' => '18',
|
||||
'et_pb_blog-header_font_style' => '',
|
||||
'et_pb_blog-meta_font_size' => '14',
|
||||
'et_pb_blog-meta_font_style' => '',
|
||||
'et_pb_blog-meta_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_blog-meta_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blog-header_color' => '#333333',
|
||||
'et_pb_blog-header_line_height' => '1em',
|
||||
'et_pb_blog-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blog-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_blog-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_blog-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blog-pagination_font_size' => $font_defaults['size'],
|
||||
'et_pb_blog-pagination_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_blog-pagination_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blog_masonry-header_font_size' => '26',
|
||||
'et_pb_blog_masonry-header_font_style' => '',
|
||||
'et_pb_blog_masonry-meta_font_size' => '14',
|
||||
'et_pb_blog_masonry-meta_font_style' => '',
|
||||
'et_pb_blog-read_more_font_size' => '14px',
|
||||
'et_pb_blog-read_more_line_height' => $font_defaults['line_height'],
|
||||
// Module: Blurb.
|
||||
'et_pb_blurb-header_font_size' => '18',
|
||||
'et_pb_blurb-header_color' => '#333333',
|
||||
'et_pb_blurb-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blurb-header_line_height' => '1em',
|
||||
'et_pb_blurb-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_blurb-body_color' => '#666666',
|
||||
'et_pb_blurb-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_blurb-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_blurb-text_orientation' => 'left',
|
||||
'et_pb_blurb-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_blurb-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_blurb-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_blurb-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Circle Counter.
|
||||
'et_pb_circle_counter-title_font_size' => '16',
|
||||
'et_pb_circle_counter-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_circle_counter-title_line_height' => '1em',
|
||||
'et_pb_circle_counter-title_font_style' => '',
|
||||
'et_pb_circle_counter-number_font_size' => '46',
|
||||
'et_pb_circle_counter-number_font_style' => '',
|
||||
'et_pb_circle_counter-title_color' => '#333333',
|
||||
'et_pb_circle_counter-number_line_height' => '225px',
|
||||
'et_pb_circle_counter-number_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_circle_counter-circle_color_alpha' => '0.1',
|
||||
// Module: Comments.
|
||||
'et_pb_comments-header_font_size' => $font_defaults_h1['size'],
|
||||
'et_pb_comments-header_line_height' => $font_defaults_h1['line_height'],
|
||||
// Module: Contact Form.
|
||||
'et_pb_contact_form-title_font_size' => '26',
|
||||
'et_pb_contact_form-title_font_style' => '',
|
||||
'et_pb_contact_form-form_field_font_size' => '14',
|
||||
'et_pb_contact_form-form_field_font_style' => '',
|
||||
'et_pb_contact_form-captcha_font_size' => '14',
|
||||
'et_pb_contact_form-captcha_font_style' => '',
|
||||
'et_pb_contact_form-padding' => '16',
|
||||
'et_pb_contact_form-title_color' => '#333333',
|
||||
'et_pb_contact_form-title_line_height' => '1em',
|
||||
'et_pb_contact_form-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_contact_form-form_field_color' => '#999999',
|
||||
'et_pb_contact_form-form_field_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_contact_form-form_field_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Countdown Timer.
|
||||
'et_pb_countdown_timer-header_font_size' => '22',
|
||||
'et_pb_countdown_timer-header_font_style' => '',
|
||||
'et_pb_countdown_timer-header_color' => '#333333',
|
||||
'et_pb_countdown_timer-header_line_height' => '1em',
|
||||
'et_pb_countdown_timer-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_countdown_timer-numbers_font_size' => '54px',
|
||||
'et_pb_countdown_timer-numbers_line_height' => '54px',
|
||||
'et_pb_countdown_timer-numbers_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_countdown_timer-separator_font_size' => '54px',
|
||||
'et_pb_countdown_timer-separator_line_height' => '54px',
|
||||
'et_pb_countdown_timer-separator_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_countdown_timer-label_line_height' => '25px',
|
||||
'et_pb_countdown_timer-label_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_countdown_timer-label_font_size' => $font_defaults['size'],
|
||||
'et_pb_countdown_timer-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_countdown_timer-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_countdown_timer-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_countdown_timer-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Bar Counters Item.
|
||||
'et_pb_counter-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_counter-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_counter-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_counter-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Bar Counters.
|
||||
'et_pb_counters-title_font_size' => '12',
|
||||
'et_pb_counters-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_counters-title_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_counters-title_font_style' => '',
|
||||
'et_pb_counters-percent_font_size' => '12',
|
||||
'et_pb_counters-percent_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_counters-percent_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_counters-percent_font_style' => '',
|
||||
'et_pb_counters-border_radius' => '0',
|
||||
'et_pb_counters-padding' => '0',
|
||||
'et_pb_counters-title_color' => '#999999',
|
||||
'et_pb_counters-percent_color' => '#ffffff',
|
||||
'et_pb_counters-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_counters-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_counters-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_counters-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: CTA.
|
||||
'et_pb_cta-header_font_size' => '26',
|
||||
'et_pb_cta-header_font_style' => '',
|
||||
'et_pb_cta-custom_padding' => '40',
|
||||
'et_pb_cta-header_text_color' => '#333333',
|
||||
'et_pb_cta-header_line_height' => '1em',
|
||||
'et_pb_cta-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_cta-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_cta-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_cta-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_cta-text_orientation' => 'center',
|
||||
'et_pb_cta-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_cta-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_cta-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_cta-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Divider.
|
||||
'et_pb_divider-divider_style' => 'solid',
|
||||
'et_pb_divider-divider_weight' => '1',
|
||||
'et_pb_divider-height' => '1',
|
||||
'et_pb_divider-divider_position' => 'top',
|
||||
// Module: Filterable Portfolio.
|
||||
'et_pb_filterable_portfolio-hover_overlay_color' => 'rgba(255,255,255,0.9)',
|
||||
'et_pb_filterable_portfolio-title_font_size' => '18',
|
||||
'et_pb_filterable_portfolio-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_filterable_portfolio-title_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_filterable_portfolio-title_font_style' => '',
|
||||
'et_pb_filterable_portfolio-title_color' => '#333333',
|
||||
'et_pb_filterable_portfolio-caption_font_size' => '14',
|
||||
'et_pb_filterable_portfolio-caption_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_filterable_portfolio-caption_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_filterable_portfolio-caption_font_style' => '',
|
||||
'et_pb_filterable_portfolio-filter_font_size' => '14',
|
||||
'et_pb_filterable_portfolio-filter_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_filterable_portfolio-filter_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_filterable_portfolio-filter_font_style' => '',
|
||||
'et_pb_filterable_portfolio-pagination_font_size' => '14',
|
||||
'et_pb_filterable_portfolio-pagination_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_filterable_portfolio-pagination_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_filterable_portfolio-pagination_font_style' => '',
|
||||
'et_pb_filterable_portfolio-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_filterable_portfolio-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_filterable_portfolio-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_filterable_portfolio-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_filterable_portfolio-zoom_icon_color' => '',
|
||||
// Module: Fullwidth Header.
|
||||
'et_pb_fullwidth_header-scroll_down_icon_size' => '50px',
|
||||
'et_pb_fullwidth_header-subhead_font_size' => '18px',
|
||||
'et_pb_fullwidth_header-button_one_font_size' => '20px',
|
||||
'et_pb_fullwidth_header-button_one_border_radius' => '3px',
|
||||
'et_pb_fullwidth_header-button_two_font_size' => '20px',
|
||||
'et_pb_fullwidth_header-button_two_border_radius' => '3px',
|
||||
'et_pb_fullwidth_header-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_fullwidth_header-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_fullwidth_header-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_fullwidth_header-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Fullwidth Menu.
|
||||
'et_pb_fullwidth_menu-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_fullwidth_menu-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_fullwidth_menu-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_fullwidth_menu-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Fullwidth Portfolio.
|
||||
'et_pb_fullwidth_portfolio-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_fullwidth_portfolio-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_fullwidth_portfolio-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_fullwidth_portfolio-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_fullwidth_portfolio-zoom_icon_color' => '',
|
||||
// Module: Fullwidth Post Title.
|
||||
'et_pb_fullwidth_post_title-title_font_size' => '26px',
|
||||
'et_pb_fullwidth_post_title-title_line_height' => '1em',
|
||||
'et_pb_fullwidth_post_title-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_fullwidth_post_title-meta_font_size' => $font_defaults['size'],
|
||||
'et_pb_fullwidth_post_title-meta_line_height' => '1em',
|
||||
'et_pb_fullwidth_post_title-meta_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Fullwidth Slider.
|
||||
'et_pb_fullwidth_slider-header_font_size' => '46',
|
||||
'et_pb_fullwidth_slider-header_font_style' => '',
|
||||
'et_pb_fullwidth_slider-body_font_size' => '16',
|
||||
'et_pb_fullwidth_slider-body_font_style' => '',
|
||||
'et_pb_fullwidth_slider-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_fullwidth_slider-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_fullwidth_slider-padding' => '16',
|
||||
'et_pb_fullwidth_slider-header_color' => '#ffffff',
|
||||
'et_pb_fullwidth_slider-header_line_height' => '1em',
|
||||
'et_pb_fullwidth_slider-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_fullwidth_slider-body_color' => '#ffffff',
|
||||
'et_pb_fullwidth_slider-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_fullwidth_slider-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_fullwidth_slider-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_fullwidth_slider-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Gallery.
|
||||
'et_pb_gallery-hover_overlay_color' => 'rgba(255,255,255,0.9)',
|
||||
'et_pb_gallery-title_font_size' => '16',
|
||||
'et_pb_gallery-title_color' => '#333333',
|
||||
'et_pb_gallery-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_gallery-title_line_height' => '1em',
|
||||
'et_pb_gallery-title_font_style' => '',
|
||||
'et_pb_gallery-caption_font_size' => '14',
|
||||
'et_pb_gallery-caption_font_style' => '',
|
||||
'et_pb_gallery-caption_color' => '#f3f3f3',
|
||||
'et_pb_gallery-caption_line_height' => '18px',
|
||||
'et_pb_gallery-caption_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_gallery-pagination_font_size' => '16px',
|
||||
'et_pb_gallery-pagination_line_height' => '1em',
|
||||
'et_pb_gallery-zoom_icon_color' => '',
|
||||
// Module: Image.
|
||||
'et_pb_image-animation' => 'left',
|
||||
// Module: Login.
|
||||
'et_pb_login-header_font_size' => '26',
|
||||
'et_pb_login-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_login-header_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_login-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_login-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_login-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_login-header_font_style' => '',
|
||||
'et_pb_login-custom_padding' => '40',
|
||||
'et_pb_login-focus_border_color' => '#ffffff',
|
||||
'et_pb_login-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_login-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_login-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_login-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Menu.
|
||||
'et_pb_menu-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_menu-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_menu-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_menu-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Number Counter.
|
||||
'et_pb_number_counter-title_font_size' => '16',
|
||||
'et_pb_number_counter-title_line_height' => '1em',
|
||||
'et_pb_number_counter-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_number_counter-title_font_style' => '',
|
||||
'et_pb_number_counter-number_font_size' => '72',
|
||||
'et_pb_number_counter-number_line_height' => '72px',
|
||||
'et_pb_number_counter-number_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_number_counter-number_font_style' => '',
|
||||
'et_pb_number_counter-title_color' => '#333333',
|
||||
'et_pb_number_counter-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_number_counter-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_number_counter-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_number_counter-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Portfolio.
|
||||
'et_pb_portfolio-hover_overlay_color' => 'rgba(255,255,255,0.9)',
|
||||
'et_pb_portfolio-title_font_size' => '18',
|
||||
'et_pb_portfolio-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_portfolio-title_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_portfolio-title_font_style' => '',
|
||||
'et_pb_portfolio-title_color' => '#333333',
|
||||
'et_pb_portfolio-caption_font_size' => '14',
|
||||
'et_pb_portfolio-caption_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_portfolio-caption_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_portfolio-caption_font_style' => '',
|
||||
'et_pb_portfolio-pagination_font_size' => '14',
|
||||
'et_pb_portfolio-pagination_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_portfolio-pagination_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_portfolio-pagination_font_style' => '',
|
||||
'et_pb_portfolio-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_portfolio-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_portfolio-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_portfolio-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_portfolio-zoom_icon_color' => '',
|
||||
// Module: Post Title.
|
||||
'et_pb_post_title-title_font_size' => '26px',
|
||||
'et_pb_post_title-title_line_height' => '1em',
|
||||
'et_pb_post_title-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_post_title-meta_font_size' => $font_defaults['size'],
|
||||
'et_pb_post_title-meta_line_height' => '1em',
|
||||
'et_pb_post_title-meta_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_post_title-parallax' => 'off',
|
||||
'et_pb_post_title-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_post_title-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_post_title-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_post_title-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Post Slider.
|
||||
'et_pb_post_slider-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_post_slider-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_post_slider-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_post_slider-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Pricing Tables Item (Pricing Table).
|
||||
'et_pb_pricing_table-header_font_size' => '22px',
|
||||
'et_pb_pricing_table-header_color' => '#ffffff',
|
||||
'et_pb_pricing_table-header_line_height' => '1em',
|
||||
'et_pb_pricing_table-subheader_font_size' => '16px',
|
||||
'et_pb_pricing_table-subheader_color' => '#ffffff',
|
||||
'et_pb_pricing_table-price_font_size' => '80px',
|
||||
'et_pb_pricing_table-price_color' => '#2EA3F2',
|
||||
'et_pb_pricing_table-price_line_height' => '82px',
|
||||
'et_pb_pricing_table-body_line_height' => '24px',
|
||||
'et_pb_pricing_table-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_pricing_table-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_pricing_table-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_pricing_table-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_pricing_table-excluded_letter_spacing' => '0px',
|
||||
'et_pb_pricing_table-excluded_line_height' => '1.7em',
|
||||
// Module: Pricing Tables.
|
||||
'et_pb_pricing_tables-header_font_size' => '22',
|
||||
'et_pb_pricing_tables-header_font_style' => '',
|
||||
'et_pb_pricing_tables-subheader_font_size' => '16',
|
||||
'et_pb_pricing_tables-subheader_font_style' => '',
|
||||
'et_pb_pricing_tables-price_font_size' => '80',
|
||||
'et_pb_pricing_tables-price_font_style' => '',
|
||||
'et_pb_pricing_tables-header_color' => '#ffffff',
|
||||
'et_pb_pricing_tables-header_line_height' => '1em',
|
||||
'et_pb_pricing_tables-subheader_color' => '#ffffff',
|
||||
'et_pb_pricing_tables-currency_frequency_font_size' => '16px',
|
||||
'et_pb_pricing_tables-currency_frequency_letter_spacing' => '0px',
|
||||
'et_pb_pricing_tables-currency_frequency_line_height' => '1.7em',
|
||||
'et_pb_pricing_tables-price_letter_spacing' => '0px',
|
||||
'et_pb_pricing_tables-price_color' => '#2EA3F2',
|
||||
'et_pb_pricing_tables-price_line_height' => '82px',
|
||||
'et_pb_pricing_tables-body_line_height' => '24px',
|
||||
'et_pb_pricing_tables-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_pricing_tables-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_pricing_tables-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_pricing_tables-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_pricing_tables-excluded_letter_spacing' => '0px',
|
||||
'et_pb_pricing_tables-excluded_line_height' => '1.7em',
|
||||
// Module: Shop.
|
||||
'et_pb_shop-title_font_size' => '16',
|
||||
'et_pb_shop-title_font_style' => '',
|
||||
'et_pb_shop-sale_badge_font_size' => '16',
|
||||
'et_pb_shop-sale_badge_font_style' => '',
|
||||
'et_pb_shop-price_font_size' => '14',
|
||||
'et_pb_shop-price_font_style' => '',
|
||||
'et_pb_shop-sale_price_font_size' => '14',
|
||||
'et_pb_shop-sale_price_font_style' => '',
|
||||
'et_pb_shop-title_color' => '#333333',
|
||||
'et_pb_shop-title_line_height' => '1em',
|
||||
'et_pb_shop-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_shop-price_line_height' => '26px',
|
||||
'et_pb_shop-price_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Sidebar.
|
||||
'et_pb_sidebar-header_font_size' => '18',
|
||||
'et_pb_sidebar-header_font_style' => '',
|
||||
'et_pb_sidebar-header_color' => '#333333',
|
||||
'et_pb_sidebar-header_line_height' => '1em',
|
||||
'et_pb_sidebar-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_sidebar-remove_border' => 'off',
|
||||
'et_pb_sidebar-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_sidebar-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_sidebar-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Signup.
|
||||
'et_pb_signup-header_font_size' => '26',
|
||||
'et_pb_signup-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_signup-header_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_signup-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_signup-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_signup-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_signup-result_message_font_size' => $font_defaults_h2['size'],
|
||||
'et_pb_signup-result_message_line_height' => $font_defaults_h2['line_height'],
|
||||
'et_pb_signup-header_font_style' => '',
|
||||
'et_pb_signup-padding' => '20',
|
||||
'et_pb_signup-focus_border_color' => '#ffffff',
|
||||
'et_pb_signup-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_signup-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_signup-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_signup-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_signup-form_field_font_size' => '14',
|
||||
'et_pb_signup-form_field_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_signup_form-form_field_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
// Module: Slider Item (Slide).
|
||||
'et_pb_slide-header_font_size' => '26px',
|
||||
'et_pb_slide-header_color' => '#ffffff',
|
||||
'et_pb_slide-header_line_height' => '1em',
|
||||
'et_pb_slide-body_font_size' => '16px',
|
||||
'et_pb_slide-body_color' => '#ffffff',
|
||||
'et_pb_slide-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_slide-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_slide-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_slide-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Slider.
|
||||
'et_pb_slider-header_font_size' => '46',
|
||||
'et_pb_slider-header_line_height' => '1em',
|
||||
'et_pb_slider-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_slider-header_font_style' => '',
|
||||
'et_pb_slider-body_font_size' => '16',
|
||||
'et_pb_slider-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_slider-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_slider-body_font_style' => '',
|
||||
'et_pb_slider-padding' => '16',
|
||||
'et_pb_slider-header_color' => '#ffffff',
|
||||
'et_pb_slider-body_color' => '#ffffff',
|
||||
'et_pb_slider-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_slider-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_slider-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_slider-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Social Media Follow.
|
||||
'et_pb_social_media_follow-icon_size' => '14',
|
||||
'et_pb_social_media_follow-button_font_style' => '',
|
||||
// Module: Tabs.
|
||||
'et_pb_tabs-tab_font_size' => $font_defaults['size'],
|
||||
'et_pb_tabs-tab_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_tabs-tab_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_tabs-title_font_size' => $font_defaults['size'],
|
||||
'et_pb_tabs-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_tabs-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_tabs-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_tabs-title_font_style' => '',
|
||||
'et_pb_tabs-padding' => '30',
|
||||
'et_pb_tabs-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_tabs-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_tabs-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_tabs-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Tabs Item (Tab).
|
||||
'et_pb_tab-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_tab-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_tab-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_tab-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Team Member (Person).
|
||||
'et_pb_team_member-header_font_size' => '18',
|
||||
'et_pb_team_member-header_font_style' => '',
|
||||
'et_pb_team_member-subheader_font_size' => '14',
|
||||
'et_pb_team_member-subheader_font_style' => '',
|
||||
'et_pb_team_member-social_network_icon_size' => '16',
|
||||
'et_pb_team_member-header_color' => '#333333',
|
||||
'et_pb_team_member-header_line_height' => '1em',
|
||||
'et_pb_team_member-header_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_team_member-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_team_member-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_team_member-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_team_member-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_team_member-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_team_member-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_team_member-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Testimonial.
|
||||
'et_pb_testimonial-portrait_border_radius' => '90',
|
||||
'et_pb_testimonial-portrait_width' => '90',
|
||||
'et_pb_testimonial-portrait_height' => '90',
|
||||
'et_pb_testimonial-author_name_font_style' => 'bold',
|
||||
'et_pb_testimonial-author_details_font_style' => 'bold',
|
||||
'et_pb_testimonial-border_color' => '#ffffff',
|
||||
'et_pb_testimonial-border_width' => '1px',
|
||||
'et_pb_testimonial-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_testimonial-body_line_height' => '1.5em',
|
||||
'et_pb_testimonial-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_testimonial-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_testimonial-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_testimonial-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_testimonial-background_blend' => $background_image_defaults['blend'],
|
||||
'et_pb_testimonial-quote_icon_background_color' => '#f5f5f5',
|
||||
// Module: Text.
|
||||
'et_pb_text-header_font_size' => $font_defaults_h1['size'],
|
||||
'et_pb_text-header_letter_spacing' => $font_defaults_h1['letter_spacing'],
|
||||
'et_pb_text-header_line_height' => $font_defaults_h1['line_height'],
|
||||
'et_pb_text-text_font_size' => $font_defaults['size'],
|
||||
'et_pb_text-text_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_text-text_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_text-border_color' => '#ffffff',
|
||||
'et_pb_text-border_width' => '1px',
|
||||
'et_pb_text-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_text-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_text-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_text-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Toggle.
|
||||
'et_pb_toggle-title_font_size' => '16',
|
||||
'et_pb_toggle-title_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_toggle-title_font_style' => '',
|
||||
'et_pb_toggle-inactive_title_font_style' => '',
|
||||
'et_pb_toggle-toggle_icon_size' => '16',
|
||||
'et_pb_toggle-title_color' => '#333333',
|
||||
'et_pb_toggle-title_line_height' => '1em',
|
||||
'et_pb_toggle-custom_padding' => '20',
|
||||
'et_pb_toggle-body_font_size' => $font_defaults['size'],
|
||||
'et_pb_toggle-body_line_height' => $font_defaults['line_height'],
|
||||
'et_pb_toggle-body_letter_spacing' => $font_defaults['letter_spacing'],
|
||||
'et_pb_toggle-background_size' => $background_image_defaults['size'],
|
||||
'et_pb_toggle-background_position' => $background_image_defaults['position'],
|
||||
'et_pb_toggle-background_repeat' => $background_image_defaults['repeat'],
|
||||
'et_pb_toggle-background_blend' => $background_image_defaults['blend'],
|
||||
// Module: Woo Title.
|
||||
'et_pb_wc_title-header_font_size' => $font_defaults_h1['size'],
|
||||
'et_pb_wc_title-header_line_height' => '1em',
|
||||
'et_pb_wc_stock-in_stock_text_color' => '#77a464',
|
||||
// Global: Field Input.
|
||||
'all_field_font_size' => '16',
|
||||
'all_field_border_width' => '0',
|
||||
'all_field_border_radius' => '3',
|
||||
'all_field_spacing' => '0',
|
||||
'all_field_font_style' => '',
|
||||
$hover->get_hover_field( 'all_field_border_radius' ) => '3',
|
||||
$hover->get_hover_field( 'all_field_spacing' ) => '0',
|
||||
);
|
||||
|
||||
if ( et_builder_has_limitation( 'forced_icon_color_default' ) ) {
|
||||
$defaults['et_pb_gallery-zoom_icon_color'] = et_get_option( 'accent_color', '#2ea3f2' );
|
||||
$defaults['et_pb_portfolio-zoom_icon_color'] = et_get_option( 'accent_color', '#2ea3f2' );
|
||||
$defaults['et_pb_fullwidth-portfolio-zoom_icon_color'] = et_get_option( 'accent_color', '#2ea3f2' );
|
||||
$defaults['et_pb_filterable_portfolio-zoom_icon_color'] = et_get_option( 'accent_color', '#2ea3f2' );
|
||||
}
|
||||
|
||||
$module_presets_manager = ET_Builder_Global_Presets_Settings::instance();
|
||||
if ( ! et_is_builder_plugin_active() && ! ET_Builder_Global_Presets_Settings::is_customizer_migrated() ) {
|
||||
$module_presets_manager->migrate_customizer_settings( $defaults );
|
||||
}
|
||||
|
||||
$custom_defaults_unmigrated = et_get_option( ET_Builder_Global_Presets_Settings::CUSTOM_DEFAULTS_UNMIGRATED_OPTION, false );
|
||||
|
||||
// reformat defaults array and add actual values to it.
|
||||
foreach ( $defaults as $setting_name => $default_value ) {
|
||||
$defaults[ $setting_name ] = array(
|
||||
'default' => $default_value,
|
||||
);
|
||||
|
||||
if ( ! et_is_builder_plugin_active() ) {
|
||||
$actual_value = (string) et_get_option( $setting_name, '', '', true );
|
||||
$add_as_actual = false;
|
||||
|
||||
// Pass Theme Customizer non module specific settings.
|
||||
$setting_array = explode( '-', $setting_name );
|
||||
$module_name = $setting_array[0];
|
||||
|
||||
if ( empty( $setting_array[1] ) || ! empty( $custom_defaults_unmigrated->$module_name ) && in_array( $setting_array[1], ET_Builder_Global_Presets_Settings::$phase_two_settings, true ) ) {
|
||||
$add_as_actual = true;
|
||||
}
|
||||
|
||||
if ( $add_as_actual && '' !== $actual_value ) {
|
||||
$defaults[ $setting_name ]['actual'] = $actual_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$_settings = apply_filters( 'et_set_default_values', $defaults );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default global setting value
|
||||
*
|
||||
* @param string $name Setting name.
|
||||
* @param string $get_value Defines the value it should get: actual or default.
|
||||
*
|
||||
* @return mixed Global setting value or FALSE
|
||||
*/
|
||||
public static function get_value( $name, $get_value = 'actual' ) {
|
||||
$settings = self::$_settings;
|
||||
|
||||
if ( ! isset( $settings[ $name ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( isset( $settings[ $name ][ $get_value ] ) ) {
|
||||
$result = $settings[ $name ][ $get_value ];
|
||||
} elseif ( 'actual' === $get_value && isset( $settings[ $name ]['default'] ) ) {
|
||||
$result = $settings[ $name ]['default'];
|
||||
} else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate 'on'/'off' into true/false
|
||||
* Pagebuilder use pseudo checkbox with 'on'/'off' value while customizer use true/false
|
||||
* which cause ET_Global_Settings' default value incompatibilities.
|
||||
*
|
||||
* @param string $name Setting name.
|
||||
* @param string $get_value Defines the value it should get: actual or default.
|
||||
* @param string $source pagebuilder or customizer.
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function get_checkbox_value( $name, $get_value = 'actual', $source = 'pagebuilder' ) {
|
||||
// Get value.
|
||||
$value = self::get_value( $name, $get_value );
|
||||
|
||||
// customizer to pagebuilder || pagebuilder to customizer.
|
||||
if ( 'customizer' === $source ) {
|
||||
if ( false === $value ) {
|
||||
return 'off';
|
||||
} else {
|
||||
return 'on';
|
||||
}
|
||||
} else {
|
||||
if ( 'off' === $value || false === $value ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the global settings.
|
||||
*/
|
||||
function et_builder_init_global_settings() {
|
||||
ET_Global_Settings::init();
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
if ( post_password_required() ) : ?>
|
||||
|
||||
<p class="nocomments container"><?php esc_html_e( 'This post is password protected. Enter the password to view comments.', 'et_builder' ); ?></p>
|
||||
<?php
|
||||
return;
|
||||
endif;
|
||||
|
||||
global $et_comments_header_level, $et_comments_form_title_level;
|
||||
|
||||
$et_comments_header_level_processed = isset( $et_comments_header_level ) && '' !== $et_comments_header_level ? et_pb_process_header_level( $et_comments_header_level, 'h1' ) : 'h1';
|
||||
?>
|
||||
<!-- You can start editing here. -->
|
||||
|
||||
<?php
|
||||
if ( empty( $comments_by_type ) ) {
|
||||
$comments_by_type = separate_comments( $comments );
|
||||
}
|
||||
?>
|
||||
|
||||
<section id="comment-wrap">
|
||||
<<?php echo et_core_intentionally_unescaped( $et_comments_header_level_processed, 'fixed_string' ); ?> id="comments" class="page_title"><?php comments_number( esc_html__( '0 Comments', 'et_builder' ), esc_html__( '1 Comment', 'et_builder' ), '% ' . esc_html__( 'Comments', 'et_builder' ) ); ?></<?php echo et_core_intentionally_unescaped( $et_comments_header_level_processed, 'fixed_string' ); ?>>
|
||||
<?php if ( have_comments() ) : ?>
|
||||
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
|
||||
<div class="comment_navigation_top clearfix">
|
||||
<div class="nav-previous"><?php previous_comments_link( et_get_safe_localization( __( '<span class="meta-nav">←</span> Older Comments', 'et_builder' ) ) ); ?></div>
|
||||
<div class="nav-next"><?php next_comments_link( et_get_safe_localization( __( 'Newer Comments <span class="meta-nav">→</span>', 'et_builder' ) ) ); ?></div>
|
||||
</div> <!-- .navigation -->
|
||||
<?php endif; // check for comment navigation ?>
|
||||
|
||||
<?php if ( ! empty( $comments_by_type['comment'] ) ) : ?>
|
||||
<ol class="commentlist clearfix">
|
||||
<?php
|
||||
wp_list_comments(
|
||||
array(
|
||||
'type' => 'comment',
|
||||
'callback' => 'et_custom_comments_display',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
|
||||
<div class="comment_navigation_bottom clearfix">
|
||||
<div class="nav-previous"><?php previous_comments_link( et_get_safe_localization( __( '<span class="meta-nav">←</span> Older Comments', 'et_builder' ) ) ); ?></div>
|
||||
<div class="nav-next"><?php next_comments_link( et_get_safe_localization( __( 'Newer Comments <span class="meta-nav">→</span>', 'et_builder' ) ) ); ?></div>
|
||||
</div> <!-- .navigation -->
|
||||
<?php endif; // check for comment navigation ?>
|
||||
|
||||
<?php if ( ! empty( $comments_by_type['pings'] ) ) : ?>
|
||||
<div id="trackbacks">
|
||||
<h3 id="trackbacks-title"><?php esc_html_e( 'Trackbacks/Pingbacks', 'et_builder' ); ?></h3>
|
||||
<ol class="pinglist">
|
||||
<?php wp_list_comments( 'type=pings&callback=et_list_pings' ); ?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php else : // this is displayed if there are no comments so far ?>
|
||||
<div id="comment-section" class="nocomments">
|
||||
<?php if ( 'open' === $post->comment_status ) : ?>
|
||||
<!-- If comments are open, but there are no comments. -->
|
||||
|
||||
<?php else : // comments are closed ?>
|
||||
<!-- If comments are closed. -->
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'open' === $post->comment_status ) : ?>
|
||||
<?php
|
||||
// Comment submit content title level.
|
||||
$et_comments_form_title_level_processed = isset( $et_comments_form_title_level ) && '' !== $et_comments_form_title_level ? et_pb_process_header_level( $et_comments_form_title_level, 'h3' ) : 'h3';
|
||||
$et_comments_form_title_level_escaped = et_core_intentionally_unescaped( $et_comments_form_title_level_processed, 'fixed_string' );
|
||||
|
||||
comment_form(
|
||||
array(
|
||||
'label_submit' => esc_attr__( 'Submit Comment', 'et_builder' ),
|
||||
'title_reply' => '<span>' . esc_attr__( 'Submit a Comment', 'et_builder' ) . '</span>',
|
||||
'title_reply_to' => esc_attr__( 'Leave a Reply to %s', 'et_builder' ),
|
||||
'title_reply_before' => '<' . $et_comments_form_title_level_escaped . ' id="reply-title" class="comment-reply-title">',
|
||||
'title_reply_after' => '</' . $et_comments_form_title_level_escaped . '>',
|
||||
'class_submit' => 'submit et_pb_button',
|
||||
'comment_notes_after' => '',
|
||||
'id_submit' => 'et_pb_submit',
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php else : ?>
|
||||
|
||||
<?php endif; // if you delete this the sky will fall on your head ?>
|
||||
</section>
|
||||
15
wp/plugins/divi-builder/includes/builder/compat/early.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// Compatibility code that needs to be run early and for each request.
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
if ( function_exists( 'ud_get_stateless_media' ) ) {
|
||||
// WP Stateless Plugin.
|
||||
function et_compat_stateless_skip_cache_busting( $result, $filename ) {
|
||||
return $filename;
|
||||
}
|
||||
|
||||
add_filter( 'stateless_skip_cache_busting', 'et_compat_stateless_skip_cache_busting', 10, 2 );
|
||||
}
|
||||
128
wp/plugins/divi-builder/includes/builder/compat/woocommerce.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
$GLOBALS['et_builder_used_in_wc_shop'] = false;
|
||||
|
||||
/**
|
||||
* Determines if current page is WooCommerce's shop page + uses builder.
|
||||
* NOTE: This has to be used after pre_get_post (et_builder_wc_pre_get_posts).
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function et_builder_used_in_wc_shop() {
|
||||
global $et_builder_used_in_wc_shop;
|
||||
|
||||
return apply_filters(
|
||||
'et_builder_used_in_wc_shop',
|
||||
$et_builder_used_in_wc_shop
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use page.php as template for a page which uses builder & being set as shop page
|
||||
*
|
||||
* @param string path to template
|
||||
* @return string modified path to template
|
||||
*/
|
||||
function et_builder_wc_template_include( $template ) {
|
||||
// Detemine whether current page uses builder and set as
|
||||
if ( et_builder_used_in_wc_shop() && '' !== locate_template( 'page.php' ) ) {
|
||||
$template = locate_template( 'page.php' );
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
add_filter( 'template_include', 'et_builder_wc_template_include', 20 );
|
||||
|
||||
/**
|
||||
* Overwrite WooCommerce's custom query in shop page if the page uses builder.
|
||||
* After proper shop page setup (page selection + permalink flushed), the original
|
||||
* page permalink will be recognized as is_post_type_archive by WordPress' rewrite
|
||||
* URL when it is being parsed. This causes is_page() detection fails and no way
|
||||
* to get actual page ID on pre_get_posts hook, unless by doing reverse detection:
|
||||
*
|
||||
* 1. Check if current page is product archive page. Most page will fail on this.
|
||||
* 2. Afterward, if wc_get_page_id( 'shop' ) returns a page ID, it means that
|
||||
* current page is shop page (product post type archive) which is configured
|
||||
* in custom page. Next, check whether Divi Builder is used on this page or not.
|
||||
*
|
||||
* @param object query object
|
||||
* @param void
|
||||
*/
|
||||
function et_builder_wc_pre_get_posts( $query ) {
|
||||
global $et_builder_used_in_wc_shop;
|
||||
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $query->is_main_query() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $query->is_search() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wc_get_page_id' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if current page is product archive page. Most page will fail on this.
|
||||
// initially used is_shop(), but is_shop()'s is_page() check throws error at
|
||||
// this early hook on homepage if shop page !== page_on_front
|
||||
if ( ! is_post_type_archive( 'product' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Note that the following check is only performed on product archive page.
|
||||
$shop_page_id = wc_get_page_id( 'shop' );
|
||||
$shop_page_object = get_post( $shop_page_id );
|
||||
$is_shop_page_exist = isset( $shop_page_object->post_type ) && 'page' === $shop_page_object->post_type;
|
||||
|
||||
if ( ! $is_shop_page_exist ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! et_pb_is_pagebuilder_used( $shop_page_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set et_builder_used_in_wc_shop() global to true
|
||||
$et_builder_used_in_wc_shop = true;
|
||||
|
||||
// Overwrite page query. This overwrite enables is_page() and other standard
|
||||
// page-related function to work normally after pre_get_posts hook
|
||||
$query->set( 'page_id', $shop_page_id );
|
||||
$query->set( 'post_type', 'page' );
|
||||
$query->set( 'posts_per_page', 1 );
|
||||
$query->set( 'wc_query', null );
|
||||
$query->set( 'meta_query', array() );
|
||||
|
||||
$query->is_singular = true;
|
||||
$query->is_page = true;
|
||||
$query->is_post_type_archive = false;
|
||||
$query->is_archive = false;
|
||||
|
||||
// Avoid unwanted <p> at the beginning of the rendered builder
|
||||
remove_filter( 'the_content', 'wpautop' );
|
||||
}
|
||||
add_action( 'pre_get_posts', 'et_builder_wc_pre_get_posts' );
|
||||
|
||||
/**
|
||||
* Remove woocommerce body classes if current shop page uses builder.
|
||||
* woocommerce-page body class causes builder's shop column styling to be irrelevant.
|
||||
*
|
||||
* @param array body classes
|
||||
* @return array modified body classes
|
||||
*/
|
||||
function et_builder_wc_body_class( $classes ) {
|
||||
if ( et_builder_used_in_wc_shop() ) {
|
||||
$classes = array_diff( $classes, array( 'woocommerce', 'woocommerce-page' ) );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
add_filter( 'body_class', 'et_builder_wc_body_class' );
|
||||
69
wp/plugins/divi-builder/includes/builder/conditions.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Utility functions for checking conditions.
|
||||
*
|
||||
* To be included in this file a function must:
|
||||
*
|
||||
* * Return a bool value
|
||||
* * Have a name that asks a yes or no question (where the first word after
|
||||
* the et_ prefix is a word like: is, can, has, should, was, had, must, or will)
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
* @since 4.0.7
|
||||
*/
|
||||
|
||||
// phpcs:disable Squiz.PHP.CommentedOutCode -- We may add `et_builder_()` in future.
|
||||
|
||||
/*
|
||||
Function Template
|
||||
|
||||
if ( ! function_exists( '' ) ):
|
||||
function et_builder_() {
|
||||
|
||||
}
|
||||
endif;
|
||||
|
||||
*/
|
||||
// phpcs:enable
|
||||
|
||||
// Note: Functions in this file are sorted alphabetically.
|
||||
|
||||
if ( ! function_exists( 'et_builder_is_loading_data' ) ) :
|
||||
/**
|
||||
* Determine whether builder is loading full data or not.
|
||||
*
|
||||
* @param string $type Is it a bb or vb.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function et_builder_is_loading_data( $type = 'vb' ) {
|
||||
// phpcs:disable WordPress.Security.NonceVerification -- This function does not change any stats, hence CSRF ok.
|
||||
if ( 'bb' === $type ) {
|
||||
return 'et_pb_get_backbone_templates' === et_()->array_get( $_POST, 'action' );
|
||||
}
|
||||
|
||||
$data_actions = array(
|
||||
'et_fb_retrieve_builder_data',
|
||||
'et_fb_update_builder_assets',
|
||||
);
|
||||
|
||||
return isset( $_POST['action'] ) && in_array( $_POST['action'], $data_actions, true );
|
||||
// phpcs:enable
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'et_builder_should_load_all_data' ) ) :
|
||||
/**
|
||||
* Determine whether to load full builder data.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function et_builder_should_load_all_data() {
|
||||
$needs_cached_definitions = et_core_is_fb_enabled() && ! et_fb_dynamic_asset_exists( 'definitions' );
|
||||
|
||||
return $needs_cached_definitions || ( ET_Builder_ELement::is_saving_cache() || et_builder_is_loading_data() );
|
||||
}
|
||||
endif;
|
||||
|
||||
// Note: Functions in this file are sorted alphabetically.
|
||||
7127
wp/plugins/divi-builder/includes/builder/core.php
Normal file
69
wp/plugins/divi-builder/includes/builder/deprecations.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Deprecated symbols mapped to replacements when applicable, organized by type.
|
||||
*
|
||||
* @since 3.1
|
||||
*
|
||||
* @return array[] {
|
||||
* Deprecations
|
||||
*
|
||||
* @type string[] $functions {
|
||||
* Deprecated Functions
|
||||
*
|
||||
* @type mixed $deprecated_symbol Replacement symbol or default value
|
||||
* ...
|
||||
* }
|
||||
* @type array[] $classes {
|
||||
* Deprecations By Class
|
||||
*
|
||||
* @type array[] $class_name {
|
||||
* Deprecated Symbols
|
||||
*
|
||||
* @type string[] $symbol_type {
|
||||
*
|
||||
* @type mixed $deprecated_symbol Replacement symbol or default value
|
||||
* ...
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
return array(
|
||||
'functions' => array(),
|
||||
'classes' => array(
|
||||
'\ET_Builder_Module_Blurb' => array(
|
||||
'method_args' => array(
|
||||
'_add_option_toggles' => array( 'general', array() ),
|
||||
'_shortcode_callback' => array( array(), null, 'et_pb_blurb' ),
|
||||
'_shortcode_passthru_callback' => array( array(), null, 'et_pb_blurb' ),
|
||||
'additional_shortcode_callback' => array( array(), null, 'et_pb_blurb' ),
|
||||
'shortcode_callback' => array( array(), null, 'et_pb_blurb' ),
|
||||
),
|
||||
'methods' => array(
|
||||
'_add_option_toggles' => '_add_settings_modal_toggles',
|
||||
'_get_current_shortcode_address' => 'generate_element_address',
|
||||
'_shortcode_callback' => '_render',
|
||||
'_shortcode_passthru_callback' => 'render_as_builder_data',
|
||||
'additional_shortcode_callback' => 'additional_render',
|
||||
'get_shortcode_fields' => 'get_default_props',
|
||||
'pre_shortcode_content' => 'before_render',
|
||||
'shortcode_atts' => '',
|
||||
'shortcode_atts_to_data_atts' => 'props_to_html_data_attrs',
|
||||
'shortcode_callback' => 'render',
|
||||
'shortcode_output' => 'output',
|
||||
),
|
||||
'properties' => array(
|
||||
'advanced_options' => 'advanced_fields',
|
||||
'custom_css_options' => 'custom_css_fields',
|
||||
'options_toggles' => 'settings_modal_toggles',
|
||||
'shortcode_atts' => 'props',
|
||||
'shortcode_content' => 'content',
|
||||
'allowlisted_fields' => array(),
|
||||
'no_shortcode_callback' => 'no_render',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
284
wp/plugins/divi-builder/includes/builder/feature/AjaxCache.php
Normal file
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* Ajax Cache.
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to cache commonly used AJAX requests.
|
||||
*/
|
||||
class ET_Builder_Ajax_Cache {
|
||||
|
||||
/**
|
||||
* Instance of this class.
|
||||
*
|
||||
* @var ET_Builder_Ajax_Cache
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* Transient name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_transient = 'et_builder_ajax_cache';
|
||||
|
||||
/**
|
||||
* Flag to determine whether to save cache or not on `shutdown` hook.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_dirty = false;
|
||||
|
||||
/**
|
||||
* List of all ajax cache.
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $_cache;
|
||||
|
||||
/**
|
||||
* ET_Builder_Ajax_Cache constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'et_builder_ajax_cache_clear', array( $this, 'clear' ), 10, 1 );
|
||||
add_action( 'shutdown', array( $this, 'save' ) );
|
||||
add_filter( 'et_builder_dynamic_asset_deps', array( $this, 'add_cache_dep' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether cache file exists or not.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function file_exists() {
|
||||
$file = $this->get_file_name();
|
||||
return $file && et_()->WPFS()->is_readable( $file );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether cache is empty or not.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_empty() {
|
||||
$this->load();
|
||||
return empty( $this->_cache );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue ajax cache as definitions dependency.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @param array $deps Dependencies array.
|
||||
* @param string $key Script handle.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_cache_dep( $deps, $key ) {
|
||||
// Skip all static assets but definitions.
|
||||
if ( 'et-dynamic-asset-definitions' !== $key ) {
|
||||
return $deps;
|
||||
}
|
||||
|
||||
if ( ! $this->file_exists() && ! $this->write_file() ) {
|
||||
// Bail out if cache is empty and cannot write the file.
|
||||
return $deps;
|
||||
}
|
||||
|
||||
// Enqueue ajax cache as definitions dependency.
|
||||
$handle = 'et-ajax-cache';
|
||||
$deps[] = $handle;
|
||||
wp_register_script( $handle, $this->get_url(), array(), ET_BUILDER_VERSION, false );
|
||||
|
||||
return $deps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load cache.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load() {
|
||||
if ( is_array( $this->_cache ) ) {
|
||||
// Cache was already loaded.
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_cache = get_transient( $this->_transient );
|
||||
|
||||
if ( ! is_array( $this->_cache ) ) {
|
||||
$this->_cache = array();
|
||||
$this->delete_file();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save cache.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save() {
|
||||
// Ensure cache is loaded.
|
||||
$this->load();
|
||||
|
||||
if ( $this->_dirty ) {
|
||||
set_transient( $this->_transient, $this->_cache );
|
||||
$this->delete_file();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write cache file.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function write_file() {
|
||||
if ( $this->is_empty() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = $this->get_file_name();
|
||||
$cache = '';
|
||||
foreach ( $this->_cache as $key => $value ) {
|
||||
$cache = sprintf( '"%s":%s,', $key, $value );
|
||||
}
|
||||
$cache = sprintf( '{"ajaxCache":{%s}}', rtrim( $cache, ',' ) );
|
||||
$cache = sprintf( 'window.ETBuilderBackend=jQuery.extend(true,%s,window.ETBuilderBackend)', $cache );
|
||||
|
||||
et_()->WPFS()->put_contents( $file, $cache );
|
||||
return $this->file_exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete cache file.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete_file() {
|
||||
if ( $this->file_exists() ) {
|
||||
et_()->WPFS()->delete( $this->get_file_name() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache key.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @param string $key Cache key.
|
||||
* @param string $content Cache value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set( $key, $content ) {
|
||||
$this->load();
|
||||
$this->_cache[ $key ] = wp_json_encode( $content );
|
||||
$this->_dirty = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset cache key.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @param string $key Cache key.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unset_( $key ) {
|
||||
$this->load();
|
||||
if ( isset( $this->_cache[ $key ] ) ) {
|
||||
unset( $this->_cache[ $key ] );
|
||||
$this->_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear cache.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear() {
|
||||
delete_transient( $this->_transient );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache file name.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public function get_file_name() {
|
||||
// Per language Cache due to some data being localized.
|
||||
$lang = is_admin() || et_fb_is_enabled() ? get_user_locale() : get_locale();
|
||||
$lang = trim( sanitize_file_name( $lang ), '.' );
|
||||
$prefix = 'ajax';
|
||||
$cache = et_()->path( et_core_cache_dir()->path, $lang );
|
||||
$files = glob( "{$cache}/{$prefix}-*.js" );
|
||||
$exists = is_array( $files ) && $files;
|
||||
|
||||
if ( $exists ) {
|
||||
return $files[0];
|
||||
}
|
||||
|
||||
wp_mkdir_p( $cache );
|
||||
|
||||
// Create uniq filename.
|
||||
$uniq = str_replace( '.', '', (string) microtime( true ) );
|
||||
$file = "{$cache}/{$prefix}-{$uniq}.js";
|
||||
|
||||
return et_()->WPFS()->is_writable( dirname( $file ) ) ? $file : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache url.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_url() {
|
||||
$file = $this->get_file_name();
|
||||
$lang = basename( dirname( $file ) );
|
||||
$name = basename( $file );
|
||||
return et_()->path( et_core_cache_dir()->url, $lang, $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class instance.
|
||||
*
|
||||
* @since 4.0.10
|
||||
*
|
||||
* @return ET_Builder_Ajax_Cache
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ET_Builder_Ajax_Cache::instance();
|
||||
@@ -0,0 +1,757 @@
|
||||
<?php
|
||||
/**
|
||||
* Compatibility for Gutenberg.
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Editing GB blocks inside Divi.
|
||||
*
|
||||
* @since 3.18 Added support for WP 5.0
|
||||
* @since 3.10.2
|
||||
*/
|
||||
class ET_Builder_Block_Editor_Integration {
|
||||
|
||||
/**
|
||||
* Regex to match gallery in block editor.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_gb_gallery_regexp = '/<ul class="wp-block-gallery[^"]*?">.*?<\/ul>/mis';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* ET_Builder_Block_Editor_Integration constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->init_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the post can be edited in the block editor.
|
||||
*
|
||||
* @param mixed $post Post ID or WP_Post object.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _can_edit_post( $post ) {
|
||||
if ( function_exists( 'gutenberg_can_edit_post' ) ) {
|
||||
return gutenberg_can_edit_post( $post );
|
||||
}
|
||||
|
||||
// In case WordPress is lower than version 5.0.
|
||||
if ( ! function_exists( 'use_block_editor_for_post' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return use_block_editor_for_post( $post );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether a post type is compatible with the block editor.
|
||||
*
|
||||
* @param string $type The post type.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _can_edit_post_type( $type ) {
|
||||
if ( function_exists( 'gutenberg_can_edit_post_type' ) ) {
|
||||
return gutenberg_can_edit_post_type( $type );
|
||||
}
|
||||
|
||||
// In case WordPress is lower than version 5.0.
|
||||
if ( ! function_exists( 'use_block_editor_for_post_type' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return use_block_editor_for_post_type( $type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current editor is set to load Gutenberg.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function _is_block_editor_page() {
|
||||
if ( function_exists( 'is_gutenberg_page' ) ) {
|
||||
return is_gutenberg_page();
|
||||
}
|
||||
|
||||
// In case WordPress is lower than version 5.0.
|
||||
if ( ! function_exists( 'use_block_editor_for_post' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return use_block_editor_for_post( get_the_ID() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter on map_meta_cap.
|
||||
*
|
||||
* @param array $caps Capabilities.
|
||||
* @param string $cap Capability to check.
|
||||
* @param string $user_id User ID.
|
||||
* @param array $args Additional args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||
// This only needs to run once,.
|
||||
remove_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10 );
|
||||
if (
|
||||
// GB checks for 'edit_post' so do nothing in all other cases.
|
||||
'edit_post' !== $cap ||
|
||||
// Ignore the case where Divi wasn't used to edit the post.
|
||||
! et_pb_is_pagebuilder_used( $args[0] )
|
||||
) {
|
||||
return $caps;
|
||||
}
|
||||
// We need to add `do_not_allow` for superadmins.
|
||||
$caps = array( 'do_not_allow' );
|
||||
|
||||
return $caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user capabilities that is relevant to block editor integration
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_current_user_capabilities() {
|
||||
/**
|
||||
* Make relevant capabilities filterable should the need to check for more caps arises
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array user capabilities
|
||||
*/
|
||||
$relevant_capabilities = array(
|
||||
'divi_library',
|
||||
'use_visual_builder',
|
||||
);
|
||||
$relevant_capabilities = apply_filters( 'et_block_editor_relevant_capabilities', $relevant_capabilities );
|
||||
|
||||
$capabilities = array();
|
||||
|
||||
foreach ( $relevant_capabilities as $cap_name ) {
|
||||
$capabilities[ $cap_name ] = et_pb_is_allowed( $cap_name );
|
||||
}
|
||||
|
||||
return $capabilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter used to disable GB for certain post types.
|
||||
*
|
||||
* @param bool $can_edit Whether post type can be editable with gutenberg or not.
|
||||
* @param string $post_type Post type name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function gutenberg_can_edit_post_type( $can_edit, $post_type ) {
|
||||
// The tricky part here is that GB doesn't pass the post ID to this filter but only its type
|
||||
// but we need the ID to determine whether the post has been edited with Divi.
|
||||
// Since GB uses `current_user_can( 'edit_post', $post->ID )` right after call this filter,
|
||||
// We hook into `map_meta_cap` (which gets passed the ID) and do our checks there.
|
||||
add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 );
|
||||
|
||||
return $can_edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue our GB compatibility bundle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_block_editor_assets() {
|
||||
// Load script dependencies that is used by builder on top window. These dependencies
|
||||
// happen to be the exact same scripts required by BFB top window's scripts.
|
||||
et_bfb_enqueue_scripts_dependencies();
|
||||
|
||||
// Enqueue open sans.
|
||||
et_builder_enqueue_open_sans();
|
||||
|
||||
// Enqueue integration & blocks scripts.
|
||||
$deps = array(
|
||||
'jquery',
|
||||
'et_bfb_admin_date_addon_js',
|
||||
'wp-hooks',
|
||||
);
|
||||
et_fb_enqueue_bundle( 'et-builder-gutenberg', 'gutenberg.js', $deps );
|
||||
|
||||
// Enqueue top window style.
|
||||
wp_register_style(
|
||||
'et-fb-top-window',
|
||||
ET_BUILDER_URI . '/frontend-builder/assets/css/fb-top-window.css',
|
||||
array(),
|
||||
ET_BUILDER_VERSION
|
||||
);
|
||||
|
||||
// Enqueue integration & blocks styles.
|
||||
$deps = array(
|
||||
'et-fb-top-window',
|
||||
);
|
||||
et_fb_enqueue_bundle( 'et-builder-gutenberg', 'gutenberg.css', $deps );
|
||||
|
||||
// this enqueue bundle.css.
|
||||
et_builder_enqueue_assets_main();
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$post_type = get_post_type();
|
||||
$enabled_for_post_type = et_builder_enabled_for_post_type( $post_type );
|
||||
$updates_options = get_site_option( 'et_automatic_updates_options', array() );
|
||||
$et_account = array(
|
||||
'et_username' => et_()->array_get( $updates_options, 'username', '' ),
|
||||
'et_api_key' => et_()->array_get( $updates_options, 'api_key', '' ),
|
||||
'status' => get_site_option( 'et_account_status', 'not_active' ),
|
||||
);
|
||||
|
||||
// Set helpers needed by our own Gutenberg bundle.
|
||||
$gutenberg = array(
|
||||
'helpers' => array(
|
||||
'postID' => $post_id,
|
||||
'postType' => $post_type,
|
||||
'is3rdPartyPostType' => et_builder_is_post_type_custom( $post_type ) ? 'yes' : 'no',
|
||||
'vbUrl' => et_fb_get_vb_url(),
|
||||
'builderUsed' => et_pb_is_pagebuilder_used( $post_id ),
|
||||
'scriptDebug' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
|
||||
'canToggle' => et_pb_is_allowed( 'divi_builder_control' ) && $enabled_for_post_type,
|
||||
'isEnabled' => $enabled_for_post_type,
|
||||
'i18n' => array(
|
||||
'placeholder' => array(
|
||||
'block' => array(
|
||||
'title' => esc_html__( 'Divi Builder', 'et_builder' ),
|
||||
'description' => esc_html__( 'The Divi Builder is activated on this page. To edit your page using the builder, click the Edit With The Divi Builder button.', 'et_builder' ),
|
||||
),
|
||||
'render' => array(
|
||||
'title' => array(
|
||||
'new' => esc_html__( 'Build Your Layout Using Divi', 'et_builder' ),
|
||||
'old' => esc_html__( 'This Layout Is Built With Divi', 'et_builder' ),
|
||||
),
|
||||
'divi' => array(
|
||||
'new' => esc_html__( 'Use Divi Builder', 'et_builder' ),
|
||||
'old' => esc_html__( 'Edit With The Divi Builder', 'et_builder' ),
|
||||
),
|
||||
'default' => esc_html__( 'Use Default Editor', 'et_builder' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Loaded into ETBlockUserStore.
|
||||
'capabilities' => $this->get_current_user_capabilities(),
|
||||
|
||||
// Loaded into ETBlockLibraryStore.
|
||||
'etAccount' => $et_account,
|
||||
|
||||
// Loaded into ETBlockSettingsStore.
|
||||
'conditions' => array(
|
||||
'isRtl' => is_rtl(),
|
||||
),
|
||||
'constants' => array(
|
||||
'emptyLayout' => '[et_pb_section admin_label="section"][et_pb_row admin_label="row"][/et_pb_row][/et_pb_section]',
|
||||
),
|
||||
'nonces' => array(
|
||||
'et_builder_library_get_layouts_data' => wp_create_nonce( 'et_builder_library_get_layouts_data' ),
|
||||
'et_builder_library_update_account' => wp_create_nonce( 'et_builder_library_update_account' ),
|
||||
'et_block_layout_preview' => wp_create_nonce( 'et_block_layout_preview' ),
|
||||
'et_rest_get_layout_content' => wp_create_nonce( 'et_rest_get_layout_content' ),
|
||||
'et_rest_process_builder_edit_data' => wp_create_nonce( 'et_rest_process_builder_edit_data' ),
|
||||
),
|
||||
'urls' => array(
|
||||
'adminAjax' => admin_url( 'admin-ajax.php' ),
|
||||
'diviLibrary' => ET_BUILDER_DIVI_LIBRARY_URL,
|
||||
'home' => home_url( '/' ),
|
||||
),
|
||||
/**
|
||||
* Make DOM selectors list filterable so third party can modified it if needed
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array list of selectors
|
||||
*/
|
||||
'selectors' => apply_filters(
|
||||
'et_gb_selectors',
|
||||
array(
|
||||
'pageLayoutSelect' => '#et_pb_page_layout',
|
||||
)
|
||||
),
|
||||
/**
|
||||
* Make Content Widhts settings filterable so third party can modified it if needed
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array content width configurations
|
||||
*/
|
||||
'contentWidths' => apply_filters(
|
||||
'et_gb_content_widths',
|
||||
array(
|
||||
// Intentionally set null for default and undefined if no saved content width found
|
||||
// unless `et_gb_content_widths` is being filtered to handle Divi Builder Plugin
|
||||
// situation which might not have deifined content width.
|
||||
'default' => null,
|
||||
'current' => get_post_meta( $post_id, '_et_gb_content_width', true ),
|
||||
'min' => 320, // Min content width (small smartphone width).
|
||||
'max' => 2880, // Max content width (15" laptop * 2).
|
||||
)
|
||||
),
|
||||
);
|
||||
wp_localize_script( 'et-builder-gutenberg', 'et_builder_gutenberg', $gutenberg );
|
||||
|
||||
// Set translated strings for the scripts.
|
||||
wp_set_script_translations( 'et-builder-gutenberg', 'et_builder', ET_BUILDER_DIR . 'languages' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new Divi page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_new_button() {
|
||||
global $typenow;
|
||||
if ( ! $this->_can_edit_post_type( $typenow ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$edit = 'post-new.php';
|
||||
$edit .= 'post' !== $typenow ? "?post_type=$typenow" : '';
|
||||
|
||||
// Create a nonce to auto activate VB on a new Auto Draft.
|
||||
$url = add_query_arg( 'et_fb_new_vb_nonce', wp_create_nonce( 'et_fb_new_vb_nonce' ), admin_url( $edit ) );
|
||||
$button = sprintf( '<a href="%s">%s</a>', esc_url( $url ), 'Divi' );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var menu = document.querySelector('#split-page-title-action .dropdown');
|
||||
|
||||
if (menu) {
|
||||
menu.insertAdjacentHTML('afterbegin', '<?php echo et_core_esc_previously( $button ); ?>');
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* This filter allows VB to be directly activated for Auto Drafts.
|
||||
*
|
||||
* @param object $post Auto Draft post.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function auto_draft( $post ) {
|
||||
// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
|
||||
if ( ! isset( $_GET['et_fb_new_vb_nonce'] ) || ! wp_verify_nonce( $_GET['et_fb_new_vb_nonce'], 'et_fb_new_vb_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the draft.
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $post->ID,
|
||||
'post_status' => 'draft',
|
||||
)
|
||||
);
|
||||
|
||||
// Add VB activation nonce.
|
||||
$url = add_query_arg(
|
||||
'et_fb_activation_nonce',
|
||||
wp_create_nonce( 'et_fb_activation_nonce_' . $post->ID ),
|
||||
et_fb_prepare_ssl_link( get_permalink( $post ) )
|
||||
);
|
||||
|
||||
// Set post meta to `off` or else `et_builder_set_content_activation` won't work...
|
||||
update_post_meta( $post->ID, '_et_pb_use_builder', 'off' );
|
||||
|
||||
wp_safe_redirect( $url );
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'Edit With Divi Editor' links
|
||||
*
|
||||
* @param array $actions Currently defined actions for the row.
|
||||
* @param object $post Current post object.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_edit_link( $actions, $post ) {
|
||||
// Maybe change this with et_fb_current_user_can_save or equivalent.
|
||||
|
||||
if ( ! $this->_can_edit_post( $post ) || ! et_builder_enabled_for_post_type( $post->post_type ) ) {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
if ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
|
||||
// Post is assigned as the blog page so it does not have editable content.
|
||||
return $actions;
|
||||
}
|
||||
|
||||
$post_id = $post->ID;
|
||||
$is_divi_library = 'et_pb_layout' === get_post_type( $post_id );
|
||||
$edit_url = $is_divi_library ? get_edit_post_link( $post_id, 'raw' ) : get_permalink( $post_id );
|
||||
|
||||
if ( et_pb_is_pagebuilder_used( $post_id ) ) {
|
||||
$edit_url = et_fb_get_vb_url( $edit_url );
|
||||
} else {
|
||||
if ( ! et_pb_is_allowed( 'divi_builder_control' ) ) {
|
||||
// Do not add Divi activation link when user lacks `Toggle Divi Builder` capability.
|
||||
return $actions;
|
||||
}
|
||||
$edit_url = add_query_arg(
|
||||
array(
|
||||
'et_fb_activation_nonce' => wp_create_nonce( 'et_fb_activation_nonce_' . $post_id ),
|
||||
),
|
||||
$edit_url
|
||||
);
|
||||
}
|
||||
|
||||
$edit_action = array(
|
||||
'divi' => sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
esc_url( $edit_url ),
|
||||
esc_attr(
|
||||
sprintf(
|
||||
__( 'Edit “%s” in Divi', 'et_builder' ),
|
||||
_draft_or_post_title( $post->ID )
|
||||
)
|
||||
),
|
||||
esc_html__( 'Edit With Divi', 'et_builder' )
|
||||
),
|
||||
);
|
||||
|
||||
$actions = array_merge( $actions, $edit_action );
|
||||
|
||||
// I'm leaving this here in case we wanna change item position.
|
||||
// $edit_offset = array_search( 'edit', array_keys( $actions ), true );
|
||||
// $actions = array_merge(
|
||||
// array_slice( $actions, 0, $edit_offset + 1 ),
|
||||
// $edit_action,
|
||||
// array_slice( $actions, $edit_offset + 1 )
|
||||
// );.
|
||||
|
||||
return $actions;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add filters needed to show our extra row action.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_edit_link_filters() {
|
||||
// For hierarchical post types.
|
||||
add_filter( 'page_row_actions', array( $this, 'add_edit_link' ), 10, 2 );
|
||||
// For non-hierarchical post types.
|
||||
add_filter( 'post_row_actions', array( $this, 'add_edit_link' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'Divi' to post states when builder is enabled for it.
|
||||
*
|
||||
* @param array $post_states Existing post states.
|
||||
* @param object $post Current post object.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function display_post_states( $post_states, $post ) {
|
||||
// Make sure that $post_states is an array. Third party plugin might modify $post_states and makes it null
|
||||
// which create various issue (i.e. Piklist + Having a page configured as a static page).
|
||||
if ( ! is_array( $post_states ) ) {
|
||||
$post_states = array();
|
||||
}
|
||||
|
||||
if ( et_pb_is_pagebuilder_used( $post->ID ) ) {
|
||||
// Remove Gutenberg if existing.
|
||||
$key = array_search( 'Gutenberg', $post_states, true );
|
||||
if ( false !== $key ) {
|
||||
unset( $post_states[ $key ] );
|
||||
}
|
||||
// GB devs didn't allow this to be translated so why should we ?
|
||||
$post_states[] = 'Divi';
|
||||
}
|
||||
|
||||
return $post_states;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that Divi enabled CPTs support 'custom-fields'.
|
||||
*
|
||||
* @since 3.19.12
|
||||
*/
|
||||
public function ensure_post_type_supports() {
|
||||
$post_types = et_builder_get_builder_post_types();
|
||||
|
||||
foreach ( $post_types as $post_type ) {
|
||||
if ( ! post_type_supports( $post_type, 'custom-fields' ) ) {
|
||||
add_post_type_support( $post_type, 'custom-fields' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter update_post_metadata return value from during a REST API update
|
||||
* when meta value isn't changed.
|
||||
*
|
||||
* @param mixed $result Previous result.
|
||||
* @param int $object_id Post ID.
|
||||
* @param string $meta_key Meta key.
|
||||
* @param mixed $meta_value Meta value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_post_metadata( $result, $object_id, $meta_key, $meta_value ) {
|
||||
if ( ! in_array( $meta_key, array( '_et_pb_use_builder', '_et_pb_old_content' ), true ) ) {
|
||||
// Only act if it's one of our metas.
|
||||
return $result;
|
||||
}
|
||||
if ( get_metadata( 'post', $object_id, $meta_key, true ) === $meta_value ) {
|
||||
// Return true instead of false so silly WP REST API call won't die on us....
|
||||
return true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove empty Divi GB placeholder when processing shortcode.
|
||||
*
|
||||
* @param string $post_content Raw post content (shortcode).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function et_fb_load_raw_post_content( $post_content ) {
|
||||
// Replace empty placeholder with no content so page creation will
|
||||
// still work in this case.
|
||||
return '<!-- wp:divi/placeholder /-->' === $post_content ? '' : $post_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a single GB gallery to shortcode.
|
||||
*
|
||||
* @param string $gallery Post content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function gb_gallery_to_shortcode( $gallery ) {
|
||||
|
||||
$gallery = is_array( $gallery ) ? $gallery[0] : $gallery;
|
||||
$ids = preg_match_all( '/data-id="(\d+)"/i', $gallery, $matches ) ? $matches[1] : array();
|
||||
$columns = preg_match( '/<ul class="wp-block-gallery columns-(\d)[^"]*?">/i', $gallery, $matches ) ? $matches[1] : 3;
|
||||
$shortcode = sprintf(
|
||||
'[gallery columns="%s" ids="%s"]',
|
||||
intval( $columns ),
|
||||
implode( ',', array_map( 'intval', $ids ) )
|
||||
);
|
||||
|
||||
return $shortcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert all GB galleries to shortcodes.
|
||||
*
|
||||
* @param string $content Post content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function gb_galleries_to_shortcodes( $content ) {
|
||||
return preg_replace_callback(
|
||||
$this->_gb_gallery_regexp,
|
||||
array( $this, 'gb_gallery_to_shortcode' ),
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a specified post's content for GB gallery and, if present, return the first
|
||||
*
|
||||
* @param string $gallery Gallery data and srcs parsed from the expanded shortcode.
|
||||
* @param int|WP_Post $post Post ID or object.
|
||||
*
|
||||
* @return string|array Gallery data and srcs parsed from the expanded shortcode.
|
||||
*/
|
||||
public function get_post_gallery( $gallery, $post ) {
|
||||
if ( $gallery ) {
|
||||
return $gallery;
|
||||
}
|
||||
|
||||
$content = get_post_field( 'post_content', $post );
|
||||
if ( empty( $content ) ) {
|
||||
return $gallery;
|
||||
}
|
||||
|
||||
if ( preg_match( $this->_gb_gallery_regexp, $content, $matches ) ) {
|
||||
// Found a GB gallery.
|
||||
if ( apply_filters( 'et_gb_gallery_to_shortcode', true ) ) {
|
||||
// Return as shortcode.
|
||||
return do_shortcode( $this->gb_gallery_to_shortcode( $matches[0] ) );
|
||||
}
|
||||
// Return it as is.
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
return $gallery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete first GB gallery in content
|
||||
*
|
||||
* @param string $content Content.
|
||||
* @param bool $deleted Whether a gallery has been already deleted or not.
|
||||
* @return string
|
||||
*/
|
||||
public function et_delete_post_gallery( $content, $deleted ) {
|
||||
if ( $deleted ) {
|
||||
// If a gallery was already removed, do nothing.
|
||||
return $content;
|
||||
}
|
||||
return preg_replace( $this->_gb_gallery_regexp, '', $content, 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove custom style from our metabox when GB is showing it.
|
||||
*
|
||||
* @param string $post_type Post type.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_boxes( $post_type ) {
|
||||
$is_block_editor_page = $this->_is_block_editor_page();
|
||||
$is_metabox_exist = function_exists( 'et_single_settings_meta_box' );
|
||||
$is_builder_enabled = et_builder_enabled_for_post_type( $post_type );
|
||||
$is_metabox_allowed = et_pb_is_allowed( 'page_options' );
|
||||
|
||||
if ( $is_block_editor_page && $is_metabox_exist && $is_builder_enabled && $is_metabox_allowed ) {
|
||||
// Change our metabox id so that no custom style is applied.
|
||||
remove_meta_box( 'et_settings_meta_box', $post_type, 'side' );
|
||||
add_meta_box(
|
||||
'et_settings_meta_box_gutenberg',
|
||||
esc_html__( 'Divi Page Settings', 'Divi' ),
|
||||
'et_single_settings_meta_box',
|
||||
$post_type,
|
||||
'side',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook into REST API page call.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rest_insert_page() {
|
||||
add_filter( 'update_post_metadata', array( $this, 'update_post_metadata' ), 10, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom auth function for meta updates via REST API.
|
||||
*
|
||||
* @param boolean $allowed True if allowed to view the meta field by default, false if else.
|
||||
* @param string $meta_key The meta key.
|
||||
* @param int $id Post ID.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function meta_auth( $allowed, $meta_key, $id ) {
|
||||
return current_user_can( 'edit_post', $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook methods to WordPress
|
||||
* Latest plugin version: 1.5
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init_hooks() {
|
||||
if ( is_admin() ) {
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ), 4 );
|
||||
add_action( 'admin_print_scripts-edit.php', array( $this, 'add_new_button' ), 10 );
|
||||
add_action( 'admin_init', array( $this, 'add_edit_link_filters' ) );
|
||||
|
||||
// Only need to add this filter is the nonce is present in the url request
|
||||
// nonce value will be checked in the filter itself.
|
||||
// phpcs:ignore WordPress.Security.NonceVerification -- This is just check, therefore nonce verification not required.
|
||||
if ( isset( $_GET['et_fb_new_vb_nonce'] ) ) {
|
||||
add_action( 'new_to_auto-draft', array( $this, 'auto_draft' ), 1 );
|
||||
}
|
||||
add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 );
|
||||
} else {
|
||||
// If "Enable Divi Gallery" option is enabled.
|
||||
if ( apply_filters( 'et_gb_gallery_to_shortcode', false ) === true ) {
|
||||
// Converts GB galleries to shortcodes.
|
||||
add_filter( 'the_content', array( $this, 'gb_galleries_to_shortcodes' ), 1 );
|
||||
}
|
||||
if ( apply_filters( 'et_gb_gallery_include_in_get_post_gallery', false ) === true ) {
|
||||
// Makes sure `get_post_gallery` returns a GB gallery if no shortcode is found.
|
||||
add_filter( 'get_post_gallery', array( $this, 'get_post_gallery' ), 10, 2 );
|
||||
}
|
||||
// This filter gets called when Divi removes first gallery shortcode from
|
||||
// a gallery post (as in post format). We hook into that to ensure that the first GB gallery
|
||||
// is deleted if nothing else was.
|
||||
add_filter( 'et_delete_post_gallery', array( $this, 'et_delete_post_gallery' ), 10, 2 );
|
||||
// Provide other code a simple way to access the conversion function via this custom filter.
|
||||
add_filter( 'et_gb_galleries_to_shortcodes', array( $this, 'gb_galleries_to_shortcodes' ) );
|
||||
}
|
||||
|
||||
add_filter( 'et_fb_load_raw_post_content', array( $this, 'et_fb_load_raw_post_content' ) );
|
||||
add_filter( 'init', array( $this, 'ensure_post_type_supports' ), 999999 );
|
||||
|
||||
// This is one of the most idiot things I had to do ever and its due to
|
||||
// a 10 month old-yet not fixed WP bug: https://core.trac.wordpress.org/ticket/42069
|
||||
// TLDR: when updating a post with meta via WP REST API, `update_metadata` should only
|
||||
// be called for metas whose value changed.
|
||||
// However, the equality check is fooled by values including characters that are
|
||||
// slashed or converted to entities, like " or <.
|
||||
// `update_metadata` is then called and returns `false` (because value didn't change) which results
|
||||
// in REST API page update to abort with a 500 error code....
|
||||
// To fix the issue, we hook into REST API page update and force `update_metadata` to return `true`
|
||||
// when value didn't change (only applied to our own meta keys).
|
||||
add_action( 'rest_insert_page', array( $this, 'rest_insert_page' ) );
|
||||
|
||||
// Need to deal with our metabox styling when inside GB.
|
||||
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 1 );
|
||||
|
||||
// To register the post metas is needed because we want to change their value within our custom GB blocks
|
||||
// Editing a post meta via REST API is allowed by default unless its key is protected (starts with `_`)
|
||||
// which is the case here so we also need to create a custom auth function.
|
||||
$auth = array( $this, 'meta_auth' );
|
||||
$args = array(
|
||||
'auth_callback' => $auth,
|
||||
'show_in_rest' => true,
|
||||
'single' => true,
|
||||
'type' => 'string',
|
||||
);
|
||||
register_meta( 'post', '_et_pb_use_builder', $args );
|
||||
$args = array(
|
||||
'auth_callback' => $auth,
|
||||
'show_in_rest' => true,
|
||||
'single' => true,
|
||||
'type' => 'string',
|
||||
);
|
||||
register_meta( 'post', '_et_pb_old_content', $args );
|
||||
$args = array(
|
||||
'auth_callback' => $auth,
|
||||
'show_in_rest' => true,
|
||||
'single' => true,
|
||||
'type' => 'string',
|
||||
);
|
||||
register_meta( 'post', '_et_gb_content_width', $args );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( et_core_is_gutenberg_active() ) {
|
||||
new ET_Builder_Block_Editor_Integration();
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Block Templates Compatibility.
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Block Templates Compatibility Class.
|
||||
*
|
||||
* @since 4.9.8
|
||||
*/
|
||||
class ET_Builder_Block_Templates {
|
||||
/**
|
||||
* Instance of `ET_Builder_Block_Templates`.
|
||||
*
|
||||
* @var ET_Builder_Block_Templates
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* ET_Builder_Block_Templates constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->set_query_templates_filters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class instance.
|
||||
*
|
||||
* @since 4.9.8
|
||||
*
|
||||
* @return ET_Builder_Block_Templates
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set query templates filters to override block templates.
|
||||
*
|
||||
* @since 4.9.8
|
||||
*/
|
||||
public function set_query_templates_filters() {
|
||||
// Bail early if current active builder is not DBP.
|
||||
if ( ! et_is_builder_plugin_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail early if `locate_block_template` function doesn't exists (WP 5.8).
|
||||
if ( ! function_exists( 'locate_block_template' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add those filters only when current active theme supports `block-templates` or
|
||||
// has block templates index HTML.
|
||||
if ( ! current_theme_supports( 'block-templates' ) && ! is_readable( get_stylesheet_directory() . '/block-templates/index.html' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of possible hook names:
|
||||
* - `404_template`
|
||||
* - `archive_template`
|
||||
* - `attachment_template` (Not Included)
|
||||
* - `author_template`
|
||||
* - `category_template`
|
||||
* - `date_template`
|
||||
* - `embed_template` (Not Included)
|
||||
* - `frontpage_template`
|
||||
* - `home_template`
|
||||
* - `index_template`
|
||||
* - `page_template`
|
||||
* - `paged_template`
|
||||
* - `privacypolicy_template`
|
||||
* - `search_template`
|
||||
* - `single_template`
|
||||
* - `singular_template`
|
||||
* - `tag_template`
|
||||
* - `taxonomy_template`
|
||||
*
|
||||
* However we don't include `attachment`, `paged`, and `embed` because they are not
|
||||
* modified or attached to TB tempates.
|
||||
*/
|
||||
$template_types = array(
|
||||
'404_template',
|
||||
'archive_template',
|
||||
'author_template',
|
||||
'category_template',
|
||||
'date_template',
|
||||
'frontpage_template',
|
||||
'home_template',
|
||||
'index_template',
|
||||
'page_template',
|
||||
'privacypolicy_template',
|
||||
'search_template',
|
||||
'single_template',
|
||||
'singular_template',
|
||||
'tag_template',
|
||||
'taxonomy_template',
|
||||
);
|
||||
|
||||
foreach ( $template_types as $template ) {
|
||||
add_filter( $template, array( $this, 'get_custom_query_template' ), 30, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pre-defined query template to override block template (modified default template
|
||||
* or custom template).
|
||||
*
|
||||
* @since 4.9.8
|
||||
*
|
||||
* @param string $template Path to the template. See locate_template().
|
||||
* @param string $type Sanitized filename without extension.
|
||||
* @param array $templates A list of template candidates, in descending order of priority.
|
||||
*
|
||||
* @return string Modified path to the template.
|
||||
*/
|
||||
public function get_custom_query_template( $template, $type, $templates ) {
|
||||
// Bail early if there is no TB templates for current page request.
|
||||
if ( empty( et_theme_builder_get_template_layouts() ) ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
// 1. Restore - Get pre-defined query template.
|
||||
$original_template = $template;
|
||||
$template = locate_template( $templates );
|
||||
|
||||
// If the `locate_template` return empty path because there is no template or theme
|
||||
// theme compat found, use builder block template canvas.
|
||||
if ( empty( $template ) && 'template-canvas.php' === basename( $original_template ) ) {
|
||||
$template = ET_BUILDER_DIR . 'templates/block-template-canvas.php';
|
||||
}
|
||||
|
||||
// 2. Remove hooks added for template canvas (block template).
|
||||
// Remove viewport meta tag.
|
||||
if ( function_exists( '_block_template_viewport_meta_tag' ) ) {
|
||||
remove_action( 'wp_head', '_block_template_viewport_meta_tag', 0 );
|
||||
}
|
||||
|
||||
// Render conditional title tag for `title-tag` support.
|
||||
add_action( 'wp_head', '_wp_render_title_tag', 1 );
|
||||
|
||||
// Remove unconditional title tag.
|
||||
if ( function_exists( '_block_template_render_title_tag' ) ) {
|
||||
remove_action( 'wp_head', '_block_template_render_title_tag', 1 );
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
ET_Builder_Block_Templates::instance();
|
||||
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Classic Editor Enabler.
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Classic_Editor' ) ) :
|
||||
/**
|
||||
* Load classic editor and disable Gutenberg/Block Editor
|
||||
*
|
||||
* Adapted from Classic Editor plugin by WordPress Contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
|
||||
* General Public License version 2, as published by the Free Software Foundation. You may NOT assume
|
||||
* that you can use any other version of the GPL.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
|
||||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* Classic Editor
|
||||
*
|
||||
* Copyright 2018 by WordPress Contributors
|
||||
*
|
||||
* Classic Editor is released under the GPL-2.0+
|
||||
*/
|
||||
class ET_Builder_Classic_Editor {
|
||||
/**
|
||||
* Instance of `ET_Builder_Classic_Editor`.
|
||||
*
|
||||
* @var ET_Builder_Classic_Editor
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* ET_Builder_Classic_Editor constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'register_actions' ), 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class instance.
|
||||
*
|
||||
* @since 3.18
|
||||
*
|
||||
* @return ET_Builder_Classic_Editor
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add & remove necessary actions and filters needed to load Classic Editor back
|
||||
* These filters are based on Classic Editor plugin to ensure required filters & actions needed
|
||||
* to load Classic Editor on Gutenberg / Block Editor (WordPress 5.0). All conditiononal Block Editor
|
||||
* loader based on query string has been removed.
|
||||
*
|
||||
* @since 3.18
|
||||
*/
|
||||
public function register_actions() {
|
||||
$gutenberg = has_filter( 'replace_editor', 'gutenberg_init' );
|
||||
$block_editor = version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' );
|
||||
|
||||
if ( ! $gutenberg && ! $block_editor ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load classic editor.
|
||||
// phpcs:ignore WordPress.Security.NonceVerification -- This function does not change any state, and is therefore not susceptible to CSRF.
|
||||
$enable_classic_editor = apply_filters( 'et_builder_enable_classic_editor', isset( $_GET['et_classic_editor'] ) );
|
||||
|
||||
if ( $block_editor && $enable_classic_editor ) {
|
||||
add_filter( 'use_block_editor_for_post_type', '__return_false', 100 );
|
||||
}
|
||||
|
||||
if ( $gutenberg && $enable_classic_editor ) {
|
||||
// gutenberg.php.
|
||||
remove_action( 'admin_menu', 'gutenberg_menu' );
|
||||
remove_action( 'admin_notices', 'gutenberg_build_files_notice' );
|
||||
remove_action( 'admin_notices', 'gutenberg_wordpress_version_notice' );
|
||||
remove_action( 'admin_init', 'gutenberg_redirect_demo' );
|
||||
|
||||
remove_filter( 'replace_editor', 'gutenberg_init' );
|
||||
|
||||
// lib/client-assets.php.
|
||||
remove_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
|
||||
remove_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 );
|
||||
remove_action( 'wp_enqueue_scripts', 'gutenberg_common_scripts_and_styles' );
|
||||
remove_action( 'admin_enqueue_scripts', 'gutenberg_common_scripts_and_styles' );
|
||||
|
||||
// lib/compat.php.
|
||||
remove_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' );
|
||||
|
||||
// lib/rest-api.php.
|
||||
remove_action( 'rest_api_init', 'gutenberg_register_rest_routes' );
|
||||
remove_action( 'rest_api_init', 'gutenberg_add_taxonomy_visibility_field' );
|
||||
|
||||
remove_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result' );
|
||||
remove_filter( 'registered_post_type', 'gutenberg_register_post_prepare_functions' );
|
||||
remove_filter( 'register_post_type_args', 'gutenberg_filter_post_type_labels' );
|
||||
|
||||
// lib/meta-box-partial-page.php.
|
||||
remove_action( 'do_meta_boxes', 'gutenberg_meta_box_save', 1000 );
|
||||
remove_action( 'submitpost_box', 'gutenberg_intercept_meta_box_render' );
|
||||
remove_action( 'submitpage_box', 'gutenberg_intercept_meta_box_render' );
|
||||
remove_action( 'edit_page_form', 'gutenberg_intercept_meta_box_render' );
|
||||
remove_action( 'edit_form_advanced', 'gutenberg_intercept_meta_box_render' );
|
||||
|
||||
remove_filter( 'redirect_post_location', 'gutenberg_meta_box_save_redirect' );
|
||||
remove_filter( 'filter_gutenberg_meta_boxes', 'gutenberg_filter_meta_boxes' );
|
||||
}
|
||||
|
||||
if ( $gutenberg && $enable_classic_editor ) {
|
||||
// gutenberg.php.
|
||||
remove_action( 'admin_init', 'gutenberg_add_edit_link_filters' );
|
||||
remove_action( 'admin_print_scripts-edit.php', 'gutenberg_replace_default_add_new_button' );
|
||||
|
||||
remove_filter( 'body_class', 'gutenberg_add_responsive_body_class' );
|
||||
remove_filter( 'admin_url', 'gutenberg_modify_add_new_button_url' );
|
||||
|
||||
// lib/compat.php.
|
||||
remove_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' );
|
||||
|
||||
// lib/register.php.
|
||||
remove_action( 'edit_form_top', 'gutenberg_remember_classic_editor_when_saving_posts' );
|
||||
|
||||
remove_filter( 'redirect_post_location', 'gutenberg_redirect_to_classic_editor_when_saving_posts' );
|
||||
remove_filter( 'get_edit_post_link', 'gutenberg_revisions_link_to_editor' );
|
||||
remove_filter( 'wp_prepare_revision_for_js', 'gutenberg_revisions_restore' );
|
||||
remove_filter( 'display_post_states', 'gutenberg_add_gutenberg_post_state' );
|
||||
|
||||
// lib/plugin-compat.php.
|
||||
remove_filter( 'rest_pre_insert_post', 'gutenberg_remove_wpcom_markdown_support' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
ET_Builder_Classic_Editor::instance();
|
||||
419
wp/plugins/divi-builder/includes/builder/feature/ErrorReport.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
/**
|
||||
* Handle error report
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
// get_plugins() is only available on dashboard; Manually require it needed.
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to send an error report.
|
||||
*/
|
||||
class ET_Builder_Error_Report {
|
||||
/**
|
||||
* Instance of `ET_Core_Data_Utils`.
|
||||
*
|
||||
* @var ET_Core_Data_Utils
|
||||
*/
|
||||
protected static $_;
|
||||
|
||||
/**
|
||||
* Instance of `ET_Builder_Error_Report`.
|
||||
*
|
||||
* @var ET_Builder_Error_Report
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* ET_Builder_Error_Report constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_et_fb_error_report', array( 'ET_Builder_Error_Report', 'endpoint' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get json_decode data and stripslashes if needed.
|
||||
*
|
||||
* @since 3.24
|
||||
*
|
||||
* @param string $data Data to be decoded.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function json_decode_maybe_stripslashes( $data ) {
|
||||
$decoded = json_decode( $data, true );
|
||||
if ( null === $decoded ) {
|
||||
$decoded = json_decode( stripslashes( $data ), true );
|
||||
}
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class instance.
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @return ET_Builder_Error_Report
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
self::$_ = ET_Core_Data_Utils::instance();
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information sent for error reporting
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_debug_info() {
|
||||
$info = array(
|
||||
'user' => array(
|
||||
'role',
|
||||
),
|
||||
'errors' => array(
|
||||
'error_message',
|
||||
'error_message_stack',
|
||||
'error_stack',
|
||||
'component_info',
|
||||
'notes',
|
||||
),
|
||||
'page' => array(
|
||||
'post_type',
|
||||
'builder_settings',
|
||||
'builder_history',
|
||||
'preferences',
|
||||
),
|
||||
'installation' => array(
|
||||
'product_name',
|
||||
'product_version',
|
||||
'builder_version',
|
||||
'wp_version',
|
||||
'installed_plugins',
|
||||
'active_plugins',
|
||||
'must_use_plugins',
|
||||
),
|
||||
);
|
||||
|
||||
// If the site uses divi builder plugin, provide the theme information.
|
||||
if ( et_is_builder_plugin_active() ) {
|
||||
array_unshift(
|
||||
$info['installation'],
|
||||
'theme_name'
|
||||
);
|
||||
}
|
||||
|
||||
// If the site uses child theme, provide the child theme information.
|
||||
if ( is_child_theme() ) {
|
||||
array_unshift(
|
||||
$info['installation'],
|
||||
'is_child_theme',
|
||||
'child_theme_name',
|
||||
'child_theme_version'
|
||||
);
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current product name
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function _get_product() {
|
||||
if ( et_is_builder_plugin_active() ) {
|
||||
return 'divi-builder';
|
||||
}
|
||||
|
||||
if ( function_exists( 'et_divi_fonts_url' ) ) {
|
||||
return 'Divi';
|
||||
}
|
||||
|
||||
if ( function_exists( 'et_extra_fonts_url' ) ) {
|
||||
return 'Extra';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get debug item value
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @param string $info_name debug info item name.
|
||||
* @param object $post alias for $_POST.
|
||||
*
|
||||
* @return string|array|object
|
||||
*/
|
||||
protected function _get_debug_value( $info_name, $post ) {
|
||||
switch ( $info_name ) {
|
||||
case 'role':
|
||||
$current_user = wp_get_current_user();
|
||||
$value = esc_html( implode( ', ', $current_user->roles ) );
|
||||
break;
|
||||
|
||||
case 'error_message':
|
||||
case 'error_message_stack':
|
||||
case 'error_stack':
|
||||
case 'notes':
|
||||
case 'post_type':
|
||||
// this will be saved into a text report, no need to convert entities.
|
||||
$value = self::$_->array_get( $post, $info_name, '' );
|
||||
break;
|
||||
|
||||
case 'latest_content':
|
||||
case 'loaded_content':
|
||||
$value = et_fb_process_to_shortcode( self::$_->array_get( $post, $info_name, array() ) );
|
||||
break;
|
||||
|
||||
case 'builder_settings':
|
||||
case 'builder_history':
|
||||
case 'component_info':
|
||||
$value = wp_json_encode( self::$_->array_get( $post, $info_name, array() ) );
|
||||
break;
|
||||
|
||||
case 'preferences':
|
||||
$value = array();
|
||||
foreach ( et_fb_app_preferences() as $name => $preference ) {
|
||||
$value[ $name ] = $preference['value'];
|
||||
}
|
||||
$value = wp_json_encode( $value );
|
||||
break;
|
||||
|
||||
case 'product_name':
|
||||
$value = $this->_get_product();
|
||||
break;
|
||||
|
||||
case 'product_version':
|
||||
$value = et_is_builder_plugin_active() ?
|
||||
self::$_->array_get( get_plugin_data( WP_PLUGIN_DIR . '/divi-builder/divi-builder.php' ), 'Version', '' ) :
|
||||
et_get_theme_version();
|
||||
|
||||
$value = esc_html( $value );
|
||||
break;
|
||||
|
||||
case 'builder_version':
|
||||
$value = ET_BUILDER_PRODUCT_VERSION;
|
||||
break;
|
||||
|
||||
case 'wp_version':
|
||||
$value = esc_html( get_bloginfo( 'version' ) );
|
||||
break;
|
||||
|
||||
case 'installed_plugins':
|
||||
$all_plugins = get_plugins();
|
||||
$value = wp_json_encode( array_keys( $all_plugins ), true );
|
||||
break;
|
||||
|
||||
case 'active_plugins':
|
||||
$all_plugins = get_plugins();
|
||||
$active_plugins_saved = get_option( 'active_plugins' );
|
||||
$active_plugins_keys = is_array( $active_plugins_saved ) ? $active_plugins_saved : array();
|
||||
$active_plugins = array_intersect_key( $all_plugins, array_flip( $active_plugins_keys ) );
|
||||
$value = wp_json_encode( $active_plugins, true );
|
||||
break;
|
||||
|
||||
case 'must_use_plugins':
|
||||
$value = wp_json_encode( get_mu_plugins(), true );
|
||||
break;
|
||||
|
||||
case 'theme_name':
|
||||
case 'child_theme_name':
|
||||
$value = esc_html( wp_get_theme()->get( 'Name' ) );
|
||||
break;
|
||||
|
||||
case 'theme_version':
|
||||
case 'child_theme_version':
|
||||
$value = esc_html( wp_get_theme()->get( 'Version' ) );
|
||||
break;
|
||||
|
||||
case 'is_child_theme':
|
||||
$value = is_child_theme() ? 'yes' : 'no';
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error report content
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @param string $data Report data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _get_report_content( $data ) {
|
||||
$report_content = '';
|
||||
|
||||
$debug_info = self::get_debug_info();
|
||||
|
||||
$report_content = array();
|
||||
|
||||
foreach ( $debug_info as $items_title => $debug_items ) {
|
||||
$item_key = 'group_title-' . $items_title;
|
||||
$items_title = ucwords( $items_title );
|
||||
|
||||
$report_content[ $item_key ] = $items_title;
|
||||
|
||||
foreach ( $debug_items as $debug_item ) {
|
||||
$item_value = et_core_esc_previously( $this->_get_debug_value( $debug_item, $data, 'array' ) );
|
||||
|
||||
$report_content[ $debug_item ] = $item_value;
|
||||
}
|
||||
}
|
||||
|
||||
return $report_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attachment data as string to be passed into endpoint
|
||||
*
|
||||
* @since 3.21.4
|
||||
*
|
||||
* @param string $data Report data.
|
||||
* @param string $field Debug info item name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _get_exported_layout_content( $data, $field ) {
|
||||
// phpcs:disable WordPress.Security.NonceVerification -- Nonce has been verified in the {@see self::endpoint()}.
|
||||
// Set faux $_POST value that is required by portability.
|
||||
$_POST['post'] = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
|
||||
$_POST['content'] = self::$_instance->_get_debug_value( $field, $data );
|
||||
|
||||
// Remove page value if it is equal to `false`, avoiding paginated images not accidentally triggered.
|
||||
if ( isset( $_POST['page'] ) && false === $_POST['page'] ) {
|
||||
unset( $_POST['page'] );
|
||||
}
|
||||
|
||||
$portability = et_core_portability_load( 'et_builder' );
|
||||
// Export the content.
|
||||
$result = $portability->export( true );
|
||||
// Delete temp files or else the same content will be used for all exports.
|
||||
$portability->delete_temp_files( 'et_core_export' );
|
||||
return $result;
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint for sending error report request
|
||||
*
|
||||
* @since 3.21.4
|
||||
*/
|
||||
public static function endpoint() {
|
||||
// Check for valid permission. Only administrator role can send error report.
|
||||
if ( ! et_core_security_check_passed( 'manage_options', 'et_fb_send_error_report' ) ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => esc_html__( 'You do not have valid permission to send error report', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
// Check valid post id.
|
||||
$post_id = self::$_->array_get( $_POST, 'post_id', false );
|
||||
|
||||
if ( ! $post_id ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => esc_html__( 'No valid post id found', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
// Check report data.
|
||||
$data = self::$_->array_get( $_POST, 'data', false );
|
||||
|
||||
if ( ! $data ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => esc_html__( 'No valid report data found', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
// Check for Elegant Themes username & API Key.
|
||||
$updates_options = get_site_option( 'et_automatic_updates_options', array() );
|
||||
$et_username = self::$_->array_get( $updates_options, 'username', '' );
|
||||
$et_api_key = self::$_->array_get( $updates_options, 'api_key', '' );
|
||||
|
||||
if ( '' === $et_username || '' === $et_api_key ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => esc_html__( 'No Elegant Themes username or API key found', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
// Check for account status.
|
||||
$et_account_status = get_site_option( 'et_account_status', 'not_active' );
|
||||
|
||||
if ( 'active' !== $et_account_status ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => esc_html__( 'Your Elegant Themes account is inactive', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
wp_die();
|
||||
}
|
||||
|
||||
$data = self::json_decode_maybe_stripslashes( $data );
|
||||
$et_endpoint = apply_filters( 'et_builder_report_endpoint', 'https://www.elegantthemes.com/api/reportV2.php' );
|
||||
|
||||
// Crafting reports and send to end endpoint.
|
||||
$request_settings = array(
|
||||
'timeout' => 30,
|
||||
'body' => array(
|
||||
'username' => $et_username,
|
||||
'api_key' => $et_api_key,
|
||||
'error_report' => self::$_instance->_get_report_content( $data ),
|
||||
'site_url' => site_url(),
|
||||
'attachments' => array(
|
||||
'latest' => self::$_instance->_get_exported_layout_content( $data, 'latest_content' ),
|
||||
'loaded' => self::$_instance->_get_exported_layout_content( $data, 'loaded_content' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$request = wp_remote_post( $et_endpoint, $request_settings );
|
||||
$request_response_code = wp_remote_retrieve_response_code( $request );
|
||||
$request_body = wp_remote_retrieve_body( $request );
|
||||
|
||||
if ( 200 === $request_response_code ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( json_decode( $request_body ) );
|
||||
}
|
||||
wp_die();
|
||||
}
|
||||
}
|
||||
|
||||
ET_Builder_Error_Report::instance();
|
||||
125
wp/plugins/divi-builder/includes/builder/feature/I18n.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Cached common translation.
|
||||
*
|
||||
* @package Builder
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Commonly used translations.
|
||||
*/
|
||||
class ET_Builder_I18n {
|
||||
|
||||
/**
|
||||
* Retrieve a commonly used translation.
|
||||
*
|
||||
* @since 4.4.9
|
||||
*
|
||||
* @param string $key Translation key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get( $key ) {
|
||||
// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.SpaceBeforeColonCASE
|
||||
// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE
|
||||
switch ( $key ) {
|
||||
// To avoid breaking tests:
|
||||
// 1. Do not remove `i18-list-begin` / `i18-list-end` tags.
|
||||
// 2. One traslation per line.
|
||||
// 3. `et_builder` Text Domain only.
|
||||
// 4. No comments / empty lines.
|
||||
// 5. Keep the list ordered, if can't do with your IDE, switch to Emacs.
|
||||
// i18-list-begin.
|
||||
case 'Admin Label' : return esc_html__( 'Admin Label', 'et_builder' );
|
||||
case 'Advanced' : return esc_html__( 'Advanced', 'et_builder' );
|
||||
case 'After' : return esc_html__( 'After', 'et_builder' );
|
||||
case 'Background' : return esc_html__( 'Background', 'et_builder' );
|
||||
case 'Before' : return esc_html__( 'Before', 'et_builder' );
|
||||
case 'Blur' : return esc_html__( 'Blur', 'et_builder' );
|
||||
case 'Body' : return esc_html__( 'Body', 'et_builder' );
|
||||
case 'Bottom Center' : return esc_html__( 'Bottom Center', 'et_builder' );
|
||||
case 'Bottom Left' : return esc_html__( 'Bottom Left', 'et_builder' );
|
||||
case 'Bottom Right' : return esc_html__( 'Bottom Right', 'et_builder' );
|
||||
case 'Bottom' : return esc_html__( 'Bottom', 'et_builder' );
|
||||
case 'Button' : return esc_html__( 'Button', 'et_builder' );
|
||||
case 'Cancel' : return esc_html__( 'Cancel', 'et_builder' );
|
||||
case 'Center Center' : return esc_html__( 'Center Center', 'et_builder' );
|
||||
case 'Center Left' : return esc_html__( 'Center Left', 'et_builder' );
|
||||
case 'Center Right' : return esc_html__( 'Center Right', 'et_builder' );
|
||||
case 'Center' : return esc_html__( 'Center', 'et_builder' );
|
||||
case 'Circle' : return esc_html__( 'Circle', 'et_builder' );
|
||||
case 'Color Burn' : return esc_html__( 'Color Burn', 'et_builder' );
|
||||
case 'Color Dodge' : return esc_html__( 'Color Dodge', 'et_builder' );
|
||||
case 'Color' : return esc_html__( 'Color', 'et_builder' );
|
||||
case 'Content' : return esc_html__( 'Content', 'et_builder' );
|
||||
case 'Custom CSS' : return esc_html__( 'Custom CSS', 'et_builder' );
|
||||
case 'Dark' : return esc_html__( 'Dark', 'et_builder' );
|
||||
case 'Darken' : return esc_html__( 'Darken', 'et_builder' );
|
||||
case 'Default' : return esc_html__( 'Default', 'et_builder' );
|
||||
case 'Design' : return esc_html__( 'Design', 'et_builder' );
|
||||
case 'Desktop' : return esc_html__( 'Desktop', 'et_builder' );
|
||||
case 'Difference' : return esc_html__( 'Difference', 'et_builder' );
|
||||
case 'Disc' : return esc_html__( 'Disc', 'et_builder' );
|
||||
case 'Down' : return esc_html__( 'Down', 'et_builder' );
|
||||
case 'Ease' : return esc_html__( 'Ease', 'et_builder' );
|
||||
case 'Ease-In' : return esc_html__( 'Ease-In', 'et_builder' );
|
||||
case 'Ease-In-Out' : return esc_html__( 'Ease-In-Out', 'et_builder' );
|
||||
case 'Ease-Out' : return esc_html__( 'Ease-Out', 'et_builder' );
|
||||
case 'Elements' : return esc_html__( 'Elements', 'et_builder' );
|
||||
case 'Exclusion' : return esc_html__( 'Exclusion', 'et_builder' );
|
||||
case 'Expand' : return esc_html__( 'Expand', 'et_builder' );
|
||||
case 'Fade' : return esc_html__( 'Fade', 'et_builder' );
|
||||
case 'Flip' : return esc_html__( 'Flip', 'et_builder' );
|
||||
case 'Hard Light' : return esc_html__( 'Hard Light', 'et_builder' );
|
||||
case 'Hue' : return esc_html__( 'Hue', 'et_builder' );
|
||||
case 'Image' : return esc_html__( 'Image', 'et_builder' );
|
||||
case 'Inside' : return esc_html__( 'Inside', 'et_builder' );
|
||||
case 'Layout' : return esc_html__( 'Layout', 'et_builder' );
|
||||
case 'Left' : return esc_html__( 'Left', 'et_builder' );
|
||||
case 'Light' : return esc_html__( 'Light', 'et_builder' );
|
||||
case 'Lighten' : return esc_html__( 'Lighten', 'et_builder' );
|
||||
case 'Linear' : return esc_html__( 'Linear', 'et_builder' );
|
||||
case 'Link' : return esc_html__( 'Link', 'et_builder' );
|
||||
case 'Luminosity' : return esc_html__( 'Luminosity', 'et_builder' );
|
||||
case 'Main Element' : return esc_html__( 'Main Element', 'et_builder' );
|
||||
case 'Multiply' : return esc_html__( 'Multiply', 'et_builder' );
|
||||
case 'No' : return esc_html__( 'No', 'et_builder' );
|
||||
case 'None' : return esc_html__( 'None', 'et_builder' );
|
||||
case 'Normal' : return esc_html__( 'Normal', 'et_builder' );
|
||||
case 'Off' : return esc_html__( 'Off', 'et_builder' );
|
||||
case 'On' : return esc_html__( 'On', 'et_builder' );
|
||||
case 'Outside' : return esc_html__( 'Outside', 'et_builder' );
|
||||
case 'Overlay' : return esc_html__( 'Overlay', 'et_builder' );
|
||||
case 'Phone' : return esc_html__( 'Phone', 'et_builder' );
|
||||
case 'Position' : return esc_html__( 'Position', 'et_builder' );
|
||||
case 'Radial' : return esc_html__( 'Radial', 'et_builder' );
|
||||
case 'Right' : return esc_html__( 'Right', 'et_builder' );
|
||||
case 'Saturation' : return esc_html__( 'Saturation', 'et_builder' );
|
||||
case 'Screen' : return esc_html__( 'Screen', 'et_builder' );
|
||||
case 'Sizing' : return esc_html__( 'Sizing', 'et_builder' );
|
||||
case 'Slide' : return esc_html__( 'Slide', 'et_builder' );
|
||||
case 'Soft Light' : return esc_html__( 'Soft Light', 'et_builder' );
|
||||
case 'Space' : return esc_html__( 'Space', 'et_builder' );
|
||||
case 'Square' : return esc_html__( 'Square', 'et_builder' );
|
||||
case 'Tablet' : return esc_html__( 'Tablet', 'et_builder' );
|
||||
case 'Text' : return esc_html__( 'Text', 'et_builder' );
|
||||
case 'Title' : return esc_html__( 'Title', 'et_builder' );
|
||||
case 'Top Center' : return esc_html__( 'Top Center', 'et_builder' );
|
||||
case 'Top Left' : return esc_html__( 'Top Left', 'et_builder' );
|
||||
case 'Top Right' : return esc_html__( 'Top Right', 'et_builder' );
|
||||
case 'Top' : return esc_html__( 'Top', 'et_builder' );
|
||||
case 'Up' : return esc_html__( 'Up', 'et_builder' );
|
||||
case 'Upload an image' : return esc_attr__( 'Upload an image', 'et_builder' );
|
||||
case 'Visibility' : return esc_attr__( 'Visibility', 'et_builder' );
|
||||
case 'Yes' : return esc_html__( 'Yes', 'et_builder' );
|
||||
// i18-list-end.
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
1164
wp/plugins/divi-builder/includes/builder/feature/Library.php
Normal file
1863
wp/plugins/divi-builder/includes/builder/feature/dynamic-content.php
Normal file
@@ -0,0 +1,294 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Global_Presets_History {
|
||||
const CUSTOM_DEFAULTS_HISTORY_OPTION = 'builder_custom_defaults_history';
|
||||
const GLOBAL_PRESETS_HISTORY_OPTION = 'builder_global_presets_history';
|
||||
const GLOBAL_PRESETS_HISTORY_LENGTH = 100;
|
||||
|
||||
private static $instance;
|
||||
|
||||
private function __construct() {
|
||||
$this->_register_ajax_callbacks();
|
||||
$this->_register_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns instance of the singleton class
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return ET_Builder_Global_Presets_History
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
private function _register_ajax_callbacks() {
|
||||
add_action(
|
||||
'wp_ajax_et_builder_save_global_presets_history',
|
||||
array(
|
||||
$this,
|
||||
'ajax_save_global_presets_history',
|
||||
)
|
||||
);
|
||||
add_action(
|
||||
'wp_ajax_et_builder_retrieve_global_presets_history',
|
||||
array(
|
||||
$this,
|
||||
'ajax_retrieve_global_presets_history',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function _register_hooks() {
|
||||
add_action( 'et_builder_modules_loaded', array( $this, 'migrate_custom_defaults_history' ), 99 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles AJAX requests to save history of Global Presets settings changes
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ajax_save_global_presets_history() {
|
||||
// Allow saving Global Presets for admins and support elevated users only
|
||||
if ( ! et_core_security_check_passed( 'switch_themes', 'et_builder_save_global_presets_history' ) ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'code' => 'et_forbidden',
|
||||
'message' => esc_html__( 'You do not have sufficient permissions to edit Divi Presets.', 'et_builder' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$history = json_decode( stripslashes( $_POST['history'] ) );
|
||||
|
||||
if ( self::sanitize_and_validate( $history ) ) {
|
||||
$current_settings = $history->history[ $history->index ];
|
||||
et_update_option( ET_Builder_Global_Presets_Settings::GLOBAL_PRESETS_OPTION, $current_settings->settings );
|
||||
et_update_option( self::GLOBAL_PRESETS_HISTORY_OPTION, $history );
|
||||
ET_Core_PageResource::remove_static_resources( 'all', 'all' );
|
||||
|
||||
if ( et_get_option( ET_Builder_Global_Presets_Settings::CUSTOM_DEFAULTS_UNMIGRATED_OPTION, false ) ) {
|
||||
et_delete_option( ET_Builder_Global_Presets_Settings::CUSTOM_DEFAULTS_UNMIGRATED_OPTION );
|
||||
et_fb_delete_builder_assets();
|
||||
}
|
||||
|
||||
ET_Builder_Ajax_Cache::instance()->unset_( 'ET_Builder_Global_Presets_History' );
|
||||
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
et_core_die( esc_html__( 'Global History data is corrupt.', 'et_builder' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles AJAX requests to retrieve history of Global Presets settings changes
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function ajax_retrieve_global_presets_history() {
|
||||
if ( ! et_core_security_check_passed( 'edit_posts', 'et_builder_retrieve_global_presets_history' ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
$history = $this->_get_global_presets_history();
|
||||
|
||||
ET_Builder_Ajax_Cache::instance()->set( 'ET_Builder_Global_Presets_History', $history );
|
||||
|
||||
wp_send_json_success( $history );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new Global Presets settings history record
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param {Object} $defaults
|
||||
*/
|
||||
public function add_global_history_record( $defaults ) {
|
||||
if ( empty( $defaults ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$new_record = (object) array(
|
||||
'settings' => $defaults,
|
||||
'time' => time() * 1000,
|
||||
'label' => esc_html__( 'Imported From Layout', 'et_builder' ),
|
||||
);
|
||||
|
||||
$history = $this->_get_global_presets_history();
|
||||
$history_index = (int) $history->index;
|
||||
|
||||
$history->history = array_slice( $history->history, 0, $history_index + 1 );
|
||||
array_push( $history->history, $new_record );
|
||||
$history->index++;
|
||||
|
||||
if ( count( $history->history ) > self::GLOBAL_PRESETS_HISTORY_LENGTH ) {
|
||||
$history->history = array_slice( $history->history, -self::GLOBAL_PRESETS_HISTORY_LENGTH );
|
||||
$history->index = min( $history->index, self::GLOBAL_PRESETS_HISTORY_LENGTH - 1 );
|
||||
}
|
||||
|
||||
et_update_option( self::GLOBAL_PRESETS_HISTORY_OPTION, $history );
|
||||
ET_Core_PageResource::remove_static_resources( 'all', 'all' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs validation and sanitizing history object.
|
||||
* Returns false if data is invalid or corrupt.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function sanitize_and_validate( &$data ) {
|
||||
if ( ! is_object( $data ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$properties = array(
|
||||
'history',
|
||||
'index',
|
||||
);
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
if ( ! property_exists( $data, $property ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_array( $data->history ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $data->history as &$record ) {
|
||||
if ( ! is_object( $record ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$properties = array(
|
||||
'settings',
|
||||
'time',
|
||||
'label',
|
||||
);
|
||||
|
||||
if ( count( (array) $record ) !== count( $properties ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $properties as $property ) {
|
||||
if ( ! property_exists( $record, $property ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $record->settings as &$module ) {
|
||||
if ( ! is_object( $module ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! is_numeric( $record->time ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$record->label = sanitize_text_field( $record->label );
|
||||
}
|
||||
|
||||
$data->index = sanitize_text_field( $data->index );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles theme version rollback.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $product_name - The short name of the product rolling back.
|
||||
* @param string $rollback_from_version
|
||||
* @param string $rollback_to_version
|
||||
*/
|
||||
public function after_version_rollback( $product_name, $rollback_from_version, $rollback_to_version ) {
|
||||
if ( ! isset( ET_Builder_Global_Presets_Settings::$allowed_products[ $product_name ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 0 > version_compare( $rollback_to_version, ET_Builder_Global_Presets_Settings::$allowed_products[ $product_name ] ) ) {
|
||||
et_delete_option( self::GLOBAL_PRESETS_HISTORY_OPTION );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Global Presets history object from DB
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function _get_global_presets_history() {
|
||||
$history = et_get_option( self::GLOBAL_PRESETS_HISTORY_OPTION, false );
|
||||
if ( ! $history ) {
|
||||
$history = (object) array(
|
||||
'history' => array(),
|
||||
'index' => - 1,
|
||||
);
|
||||
}
|
||||
|
||||
return $history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates Custom Defaults history format to Global Presets history format
|
||||
*
|
||||
* @since 4.5.0
|
||||
*/
|
||||
public static function migrate_custom_defaults_history() {
|
||||
if ( et_is_builder_plugin_active() || ET_Builder_Global_Presets_Settings::are_custom_defaults_migrated() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$history = et_get_option( self::CUSTOM_DEFAULTS_HISTORY_OPTION, false );
|
||||
|
||||
if ( ! $history ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$all_modules = ET_Builder_Element::get_modules();
|
||||
$migrated_history = (object) array();
|
||||
$migrated_history->history = array();
|
||||
|
||||
foreach ( $history->history as $record ) {
|
||||
$migrated_record = (object) array();
|
||||
$migrated_record->settings = (object) array();
|
||||
|
||||
foreach ( $record->settings as $module => $settings ) {
|
||||
$migrated_record->settings->$module = ET_Builder_Global_Presets_Settings::generate_module_initial_presets_structure( $module, $all_modules );
|
||||
|
||||
foreach ( $settings as $setting => $value ) {
|
||||
$migrated_record->settings->$module->presets->_initial->settings->$setting = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$migrated_record->time = $record->time;
|
||||
$migrated_record->label = $record->label;
|
||||
|
||||
$migrated_history->history[] = $migrated_record;
|
||||
}
|
||||
|
||||
$migrated_history->index = $history->index;
|
||||
|
||||
et_update_option( self::GLOBAL_PRESETS_HISTORY_OPTION, $migrated_history );
|
||||
}
|
||||
}
|
||||
|
||||
ET_Builder_Global_Presets_History::instance();
|
||||
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Global_Presets_Settings {
|
||||
const CUSTOM_DEFAULTS_OPTION = 'builder_custom_defaults';
|
||||
const CUSTOM_DEFAULTS_UNMIGRATED_OPTION = 'builder_custom_defaults_unmigrated';
|
||||
const CUSTOMIZER_SETTINGS_MIGRATED_FLAG = 'customizer_settings_migrated_flag';
|
||||
|
||||
const GLOBAL_PRESETS_OPTION = 'builder_global_presets';
|
||||
const CUSTOM_DEFAULTS_MIGRATED_FLAG = 'custom_defaults_migrated_flag';
|
||||
const MODULE_PRESET_ATTRIBUTE = '_module_preset';
|
||||
const MODULE_INITIAL_PRESET_ID = '_initial';
|
||||
|
||||
/**
|
||||
* @var array - The list of the product short names we allowing to do a Module Customizer settings migration rollback
|
||||
*/
|
||||
public static $allowed_products = array(
|
||||
'divi' => '4.5',
|
||||
'extra' => '4.5',
|
||||
);
|
||||
|
||||
// Migration phase two settings
|
||||
public static $phase_two_settings = array(
|
||||
'body_font_size',
|
||||
'captcha_font_size',
|
||||
'caption_font_size',
|
||||
'filter_font_size',
|
||||
'form_field_font_size',
|
||||
'header_font_size',
|
||||
'meta_font_size',
|
||||
'number_font_size',
|
||||
'percent_font_size',
|
||||
'price_font_size',
|
||||
'sale_badge_font_size',
|
||||
'sale_price_font_size',
|
||||
'subheader_font_size',
|
||||
'title_font_size',
|
||||
'toggle_font_size',
|
||||
'icon_size',
|
||||
'padding',
|
||||
'custom_padding',
|
||||
);
|
||||
|
||||
protected static $_module_additional_slugs = array(
|
||||
'et_pb_section' => array(
|
||||
'et_pb_section_fullwidth',
|
||||
'et_pb_section_specialty',
|
||||
),
|
||||
'et_pb_slide' => array(
|
||||
'et_pb_slide_fullwidth',
|
||||
),
|
||||
'et_pb_column' => array(
|
||||
'et_pb_column_specialty',
|
||||
),
|
||||
);
|
||||
|
||||
protected static $_module_types_conversion_map = array(
|
||||
'et_pb_section' => '_convert_section_type',
|
||||
'et_pb_column' => '_convert_column_type',
|
||||
'et_pb_column_inner' => '_convert_column_type',
|
||||
'et_pb_slide' => '_convert_slide_type',
|
||||
);
|
||||
|
||||
protected static $_module_import_types_conversion_map = array(
|
||||
'et_pb_section_specialty' => 'et_pb_section',
|
||||
'et_pb_section_fullwidth' => 'et_pb_section',
|
||||
'et_pb_column_inner' => 'et_bp_column',
|
||||
'et_pb_slide_fullwidth' => 'et_pb_slide',
|
||||
'et_pb_column_specialty' => 'et_pb_column',
|
||||
);
|
||||
|
||||
protected static $_instance;
|
||||
protected $_settings;
|
||||
|
||||
protected function __construct() {
|
||||
$global_presets = et_get_option( self::GLOBAL_PRESETS_OPTION, (object) array(), '', true );
|
||||
|
||||
$this->_settings = $this->_normalize_global_presets( $global_presets );
|
||||
|
||||
$this->_register_hooks();
|
||||
}
|
||||
|
||||
protected function _register_hooks() {
|
||||
add_action( 'et_after_version_rollback', array( $this, 'after_version_rollback' ), 10, 3 );
|
||||
add_action( 'et_builder_modules_loaded', array( $this, 'migrate_custom_defaults' ), 100 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns instance of the singleton class
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return ET_Builder_Global_Presets_Settings
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$_instance ) ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of additional module slugs used to separate Global Presets settings.
|
||||
* For example defaults for sections must be separated depends on the section type (regular, fullwidth or specialty).
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param $module_slug - The module slug for which additional slugs are looked up
|
||||
*
|
||||
* @return array - The list of the additional slugs
|
||||
*/
|
||||
public function get_module_additional_slugs( $module_slug ) {
|
||||
if ( ! empty( self::$_module_additional_slugs[ $module_slug ] ) ) {
|
||||
return self::$_module_additional_slugs[ $module_slug ];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns builder Global Presets settings.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function get_global_presets() {
|
||||
return $this->_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the gives preset ID exists
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug
|
||||
* @param string $preset_id
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_module_preset_exist( $module_slug, $preset_id ) {
|
||||
return isset( $this->_settings->{$module_slug}->presets->{$preset_id} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a default preset ID for the given module type
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_module_default_preset_id( $module_slug ) {
|
||||
return isset( $this->_settings->{$module_slug}->default )
|
||||
? $this->_settings->{$module_slug}->default
|
||||
: self::MODULE_INITIAL_PRESET_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the module preset ID
|
||||
* If the preset ID doesn't exist it will return the default preset ID
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug
|
||||
* @param array $module_attrs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_module_preset_id( $module_slug, $module_attrs ) {
|
||||
$preset_id = et_()->array_get( $module_attrs, self::MODULE_PRESET_ATTRIBUTE, false );
|
||||
|
||||
if ( ! $preset_id || ! $this->is_module_preset_exist( $module_slug, $preset_id ) ) {
|
||||
return $this->get_module_default_preset_id( $module_slug );
|
||||
}
|
||||
|
||||
return $preset_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the module preset by the given preset ID
|
||||
* Returns an empty object if no preset found
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug
|
||||
* @param string $preset_id
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function get_module_preset( $module_slug, $preset_id ) {
|
||||
if ( isset( $this->_settings->{$module_slug}->presets->{$preset_id} ) ) {
|
||||
return (object) $this->_settings->{$module_slug}->presets->{$preset_id};
|
||||
}
|
||||
|
||||
return (object) array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Global Presets settings for the particular module.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug - The module slug
|
||||
* @param array $attrs - The module attributes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_module_presets_settings( $module_slug, $attrs ) {
|
||||
$result = array();
|
||||
|
||||
$real_preset_id = $this->get_module_preset_id( $module_slug, $attrs );
|
||||
|
||||
if ( isset( $this->_settings->{$module_slug}->presets->{$real_preset_id}->settings ) ) {
|
||||
$result = (array) $this->_settings->{$module_slug}->presets->{$real_preset_id}->settings;
|
||||
}
|
||||
|
||||
$result = $this->maybe_set_global_colors( $result );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Global Presets settings with global colors injected.
|
||||
*
|
||||
* @since ??
|
||||
*
|
||||
* @param array $attrs - The module attributes.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function maybe_set_global_colors( $attrs ) {
|
||||
if ( empty( $attrs['global_colors_info'] ) ) {
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
$gc_info = json_decode( $attrs['global_colors_info'], true );
|
||||
|
||||
foreach ( $gc_info as $color_id => $option_names ) {
|
||||
foreach ( $option_names as $option_name ) {
|
||||
$attrs[ $option_name ] = $color_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether customizer settings migrated or not
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_customizer_migrated() {
|
||||
return et_get_option( self::CUSTOMIZER_SETTINGS_MIGRATED_FLAG, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether Custom Defaults settings migrated or not
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function are_custom_defaults_migrated() {
|
||||
return et_get_option( self::CUSTOM_DEFAULTS_MIGRATED_FLAG, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates Module Customizer settings to Custom Defaults
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param array $defaults - The list of modules default settings
|
||||
*/
|
||||
public function migrate_customizer_settings( $defaults ) {
|
||||
$template_directory = get_template_directory();
|
||||
|
||||
require_once $template_directory . '/includes/module-customizer/migrations.php';
|
||||
|
||||
$migrations = ET_Module_Customizer_Migrations::instance();
|
||||
|
||||
list (
|
||||
$custom_defaults,
|
||||
$custom_defaults_unmigrated,
|
||||
) = $migrations->migrate( $defaults );
|
||||
|
||||
et_update_option( self::CUSTOM_DEFAULTS_OPTION, (object) $custom_defaults );
|
||||
et_update_option( self::CUSTOMIZER_SETTINGS_MIGRATED_FLAG, true );
|
||||
|
||||
if ( ! empty( $custom_defaults_unmigrated ) ) {
|
||||
et_update_option( self::CUSTOM_DEFAULTS_UNMIGRATED_OPTION, (object) $custom_defaults_unmigrated );
|
||||
} else {
|
||||
et_update_option( self::CUSTOM_DEFAULTS_UNMIGRATED_OPTION, false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates `_initial` module presets structure
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $module_slug
|
||||
* @param array $all_modules
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function generate_module_initial_presets_structure( $module_slug, $all_modules ) {
|
||||
$structure = (object) array();
|
||||
$module_slug_converted = isset( self::$_module_import_types_conversion_map[ $module_slug ] )
|
||||
? self::$_module_import_types_conversion_map[ $module_slug ]
|
||||
: $module_slug;
|
||||
|
||||
$preset_name = isset( $all_modules[ $module_slug_converted ]->name )
|
||||
? sprintf( esc_html__( '%s Preset', 'et_builder' ), $all_modules[ $module_slug_converted ]->name )
|
||||
: esc_html__( 'Preset', 'et_builder' );
|
||||
|
||||
$structure->default = '_initial';
|
||||
$structure->presets = (object) array();
|
||||
$structure->presets->_initial = (object) array();
|
||||
$structure->presets->_initial->name = et_core_esc_previously( "{$preset_name} 1" );
|
||||
$structure->presets->_initial->created = 0;
|
||||
$structure->presets->_initial->updated = 0;
|
||||
$structure->presets->_initial->version = ET_BUILDER_PRODUCT_VERSION;
|
||||
$structure->presets->_initial->settings = (object) array();
|
||||
|
||||
return $structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Custom Defaults to the new Global Presets format
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param object $custom_defaults - The previous Custom Defaults
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function migrate_custom_defaults_to_global_presets( $custom_defaults ) {
|
||||
$all_modules = ET_Builder_Element::get_modules();
|
||||
$presets = (object) array();
|
||||
|
||||
foreach ( $custom_defaults as $module => $settings ) {
|
||||
$presets->$module = self::generate_module_initial_presets_structure( $module, $all_modules );
|
||||
|
||||
foreach ( $settings as $setting => $value ) {
|
||||
$presets->$module->presets->_initial->settings->$setting = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $presets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrates existing Custom Defaults to the Global Presets structure
|
||||
*
|
||||
* @since 4.5.0
|
||||
*/
|
||||
public function migrate_custom_defaults() {
|
||||
if ( self::are_custom_defaults_migrated() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Re-run migration to Global Presets if a user has not yet saved any presets.
|
||||
if ( et_is_builder_plugin_active() && ! empty( (array) $this->_settings ) ) {
|
||||
et_update_option( self::CUSTOM_DEFAULTS_MIGRATED_FLAG, true );
|
||||
return;
|
||||
}
|
||||
|
||||
$custom_defaults = et_get_option( self::CUSTOM_DEFAULTS_OPTION, false );
|
||||
|
||||
if ( ! $custom_defaults ) {
|
||||
$custom_defaults = (object) array();
|
||||
}
|
||||
|
||||
$global_presets = self::migrate_custom_defaults_to_global_presets( $custom_defaults );
|
||||
|
||||
et_update_option( self::GLOBAL_PRESETS_OPTION, $global_presets );
|
||||
$this->_settings = $global_presets;
|
||||
|
||||
et_update_option( self::CUSTOM_DEFAULTS_MIGRATED_FLAG, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles theme version rollback.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $product_name - The short name of the product rolling back.
|
||||
* @param string $rollback_from_version
|
||||
* @param string $rollback_to_version
|
||||
*/
|
||||
public function after_version_rollback( $product_name, $rollback_from_version, $rollback_to_version ) {
|
||||
if ( ! isset( self::$allowed_products[ $product_name ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 0 > version_compare( $rollback_to_version, self::$allowed_products[ $product_name ] ) ) {
|
||||
et_delete_option( self::CUSTOM_DEFAULTS_MIGRATED_FLAG );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts module type (slug).
|
||||
* Used to separate Global Presets settings for modules sharing the same slug but having different meaning
|
||||
* For example: Regular, Fullwidth and Specialty section types
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $type - The module type (slug)
|
||||
* @param array $attrs - The module attributes
|
||||
*
|
||||
* @return string - The converted module type (slug)
|
||||
*/
|
||||
public function maybe_convert_module_type( $type, $attrs ) {
|
||||
if ( isset( self::$_module_types_conversion_map[ $type ] ) ) {
|
||||
// @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
|
||||
$type = call_user_func_array(
|
||||
array( $this, self::$_module_types_conversion_map[ $type ] ),
|
||||
array( $attrs, $type )
|
||||
);
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Section module slug to appropriate slug used in Global Presets
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param array $attrs - The section attributes
|
||||
*
|
||||
* @return string - The converted section type depends on the section attributes
|
||||
*/
|
||||
protected function _convert_section_type( $attrs ) {
|
||||
if ( isset( $attrs['fullwidth'] ) && 'on' === $attrs['fullwidth'] ) {
|
||||
return 'et_pb_section_fullwidth';
|
||||
}
|
||||
|
||||
if ( isset( $attrs['specialty'] ) && 'on' === $attrs['specialty'] ) {
|
||||
return 'et_pb_section_specialty';
|
||||
}
|
||||
|
||||
return 'et_pb_section';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Slide module slug to appropriate slug used in Global Presets
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return string - The converted slide type depends on the parent slider type
|
||||
*/
|
||||
protected function _convert_slide_type() {
|
||||
global $et_pb_slider_parent_type;
|
||||
|
||||
if ( 'et_pb_fullwidth_slider' === $et_pb_slider_parent_type ) {
|
||||
return 'et_pb_slide_fullwidth';
|
||||
}
|
||||
|
||||
return 'et_pb_slide';
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Column module slug to appropriate slug used in Global Presets
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @return string - The converted column type
|
||||
*/
|
||||
protected function _convert_column_type( $attrs, $type ) {
|
||||
global $et_pb_parent_section_type;
|
||||
|
||||
if ( 'et_pb_column_inner' === $type ) {
|
||||
return 'et_pb_column';
|
||||
}
|
||||
|
||||
if ( 'et_pb_specialty_section' === $et_pb_parent_section_type
|
||||
|| ( isset( $attrs['specialty_columns'] ) && '' !== $attrs['specialty_columns'] ) ) {
|
||||
return 'et_pb_column_specialty';
|
||||
}
|
||||
|
||||
return 'et_pb_column';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters Global Presets setting to avoid non plain values like arrays or objects
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param $value - The Global Presets setting value
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function _filter_global_presets_setting_value( $value ) {
|
||||
return ! is_object( $value ) && ! is_array( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs Global Presets format normalization.
|
||||
* Usually used to cast format from array to object
|
||||
* Also used to normalize global colors
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param $presets - The object representing Global Presets settings
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
protected function _normalize_global_presets( $presets ) {
|
||||
$result = (object) array();
|
||||
|
||||
foreach ( $presets as $module => $preset_structure ) {
|
||||
if ( isset( $preset_structure->presets ) ) {
|
||||
$result->$module = (object) array();
|
||||
$result->$module->presets = (object) array();
|
||||
|
||||
foreach ( $preset_structure->presets as $preset_id => $preset ) {
|
||||
$result->$module->presets->$preset_id = (object) array();
|
||||
$result->$module->presets->$preset_id->name = $preset->name;
|
||||
$result->$module->presets->$preset_id->created = $preset->created;
|
||||
$result->$module->presets->$preset_id->updated = $preset->updated;
|
||||
$result->$module->presets->$preset_id->version = $preset->version;
|
||||
|
||||
if ( isset( $preset->settings ) ) {
|
||||
$result->$module->presets->$preset_id->settings = (object) array();
|
||||
|
||||
$settings_filtered = array_filter(
|
||||
(array) $preset->settings,
|
||||
array(
|
||||
$this,
|
||||
'_filter_global_presets_setting_value',
|
||||
)
|
||||
);
|
||||
|
||||
// Since we still support PHP 5.2 we can't use `array_filter` with array keys
|
||||
// So check if defaults have empty key
|
||||
if ( isset( $settings_filtered[''] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $settings_filtered as $setting_name => $value ) {
|
||||
$result->$module->presets->$preset_id->settings->$setting_name = $value;
|
||||
}
|
||||
|
||||
// Insert correct global color IDs for affected settings.
|
||||
$global_colors_info = isset( $settings_filtered['global_colors_info'] ) ? json_decode( $settings_filtered['global_colors_info'], true ) : array();
|
||||
|
||||
if ( ! empty( $global_colors_info ) ) {
|
||||
foreach ( $global_colors_info as $color_id => $options_list ) {
|
||||
if ( empty( $options_list ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $options_list as $global_color_option ) {
|
||||
if ( isset( $result->$module->presets->$preset_id->settings->$global_color_option ) ) {
|
||||
$result->$module->presets->$preset_id->settings->$global_color_option = $color_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result->$module->presets->$preset->settings = (object) array();
|
||||
}
|
||||
}
|
||||
|
||||
$result->$module->default = $preset_structure->default;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
ET_Builder_Global_Presets_Settings::instance();
|
||||
@@ -0,0 +1,550 @@
|
||||
<?php
|
||||
/**
|
||||
* Gutenberg editor typography.
|
||||
*
|
||||
* @package Builder
|
||||
* @subpackage Gutenberg
|
||||
* @since 4.7.6
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* Class use theme's chosen fonts in Gutenberg editor.
|
||||
*
|
||||
* Class ET_GB_Editor_Typography
|
||||
*/
|
||||
class ET_GB_Editor_Typography {
|
||||
|
||||
/**
|
||||
* `ET_GB_Editor_Typography` instance.
|
||||
*
|
||||
* @var ET_GB_Editor_Typography
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
/**
|
||||
* TB's body layout post
|
||||
*
|
||||
* @var WP_Post
|
||||
*/
|
||||
private $_body_layout_post;
|
||||
|
||||
/**
|
||||
* The `et_pb_post_content` shortcode content extracted from the TB's body layout post content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_post_content_shortcode;
|
||||
|
||||
/**
|
||||
* The `et_pb_post_title shortcode` content extracted from the TB's body layout post content
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_post_title_shortcode;
|
||||
|
||||
/**
|
||||
* CSS selector to target text content inside GB editor
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_body_selector;
|
||||
|
||||
/**
|
||||
* CSS selector to target post title inside GB editor
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_heading_selector;
|
||||
|
||||
/**
|
||||
* List of HTML element used in post content.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $body_selectors;
|
||||
|
||||
/**
|
||||
* List of HTML heading levels.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $heading_selectors;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* ET_GB_Editor_Typography constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
if ( ! et_core_is_gutenberg_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->register_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class instance.
|
||||
*
|
||||
* @return object class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
|
||||
if ( null === self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks
|
||||
*/
|
||||
public function register_hooks() {
|
||||
add_action( 'admin_footer', array( $this, 'enqueue_block_typography_styles' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the class.
|
||||
*/
|
||||
private function _initialize() {
|
||||
global $post;
|
||||
|
||||
// Bail early if no post found.
|
||||
if ( empty( $post ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$body_selectors = array( 'p', 'ol', 'ul', 'dl', 'dt' );
|
||||
$this->_body_selector = self::_generate_selectors( self::$body_selectors, '.editor-styles-wrapper .wp-block .wp-block-freeform ' );
|
||||
$this->_body_selector .= ',' . self::_generate_selectors( self::$body_selectors, '.block-editor-block-list__layout ', '.wp-block' );
|
||||
|
||||
self::$heading_selectors = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' );
|
||||
$this->_heading_selector = self::_generate_selectors( self::$heading_selectors, '.editor-styles-wrapper .wp-block .wp-block-freeform ' );
|
||||
$this->_heading_selector .= ',' . self::_generate_selectors( self::$heading_selectors, '.editor-styles-wrapper ', '.rich-text' );
|
||||
$this->_heading_selector .= ',.edit-post-visual-editor__post-title-wrapper .editor-post-title__block .editor-post-title__input';
|
||||
|
||||
$tb_layouts = et_theme_builder_get_template_layouts( ET_Theme_Builder_Request::from_post( $post->ID ) );
|
||||
|
||||
// Bail if body layouts is not set current post.
|
||||
if ( ! isset( $tb_layouts[ ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE ] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$body_layout = $tb_layouts[ ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE ];
|
||||
$body_layout_id = et_()->array_get( $body_layout, 'id' );
|
||||
$this->_body_layout_post = get_post( $body_layout_id );
|
||||
|
||||
$this->_initialize_shortcode( '_post_content_shortcode', et_theme_builder_get_post_content_modules() );
|
||||
$this->_initialize_shortcode( '_post_title_shortcode', array( 'et_pb_post_title' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the et_pb_post_content and et_pb_post_title shortcode from the body layout post content.
|
||||
*
|
||||
* @param string $prop {@see self::$_post_content_shortcode} or {@see self::$_post_title_shortcode} property.
|
||||
* @param array $tagnames Shortcode tagnames.
|
||||
*/
|
||||
private function _initialize_shortcode( $prop, $tagnames ) {
|
||||
$regex = get_shortcode_regex( $tagnames );
|
||||
|
||||
if ( preg_match_all( "/$regex/", $this->_body_layout_post->post_content, $matches ) ) {
|
||||
$post_title_shortcodes = et_()->array_get( $matches, '0' );
|
||||
|
||||
// Take the style from the first Post Title module that has the title enabled.
|
||||
foreach ( $post_title_shortcodes as $post_title_shortcode ) {
|
||||
if ( false === strpos( $post_title_shortcode, 'title="off"' ) ) {
|
||||
$this->{$prop} = $post_title_shortcode;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
} elseif ( preg_match_all( "/$regex/", $this->_body_layout_post->post_content, $matches, PREG_SET_ORDER ) ) {
|
||||
$this->{$prop} = et_()->array_get(
|
||||
$matches,
|
||||
'0.0'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print GB typography style.
|
||||
*/
|
||||
public function enqueue_block_typography_styles() {
|
||||
|
||||
if ( ! ( method_exists( get_current_screen(), 'is_block_editor' ) && get_current_screen()->is_block_editor() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_initialize();
|
||||
|
||||
$styles = '';
|
||||
|
||||
$styles .= $this->get_body_styles();
|
||||
$styles .= $this->get_title_styles();
|
||||
$styles .= $this->get_tb_styles();
|
||||
|
||||
// phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- Inline style.
|
||||
wp_register_style( 'divi-block-editor-styles', false );
|
||||
wp_enqueue_style( 'divi-block-editor-styles' );
|
||||
wp_add_inline_style( 'divi-block-editor-styles', $styles );
|
||||
|
||||
// Enqueue google fonts.
|
||||
et_builder_print_font();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the post content style.
|
||||
*/
|
||||
public function get_body_styles() {
|
||||
|
||||
$body_styles = '';
|
||||
|
||||
$body_font = esc_html( et_get_option( 'body_font' ) );
|
||||
|
||||
if ( ! empty( $body_font ) && 'none' !== $body_font ) {
|
||||
et_builder_enqueue_font( $body_font );
|
||||
$font_family = et_builder_get_font_family( $body_font );
|
||||
|
||||
$body_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'font-family',
|
||||
'value' => str_replace( 'font-family: ', '', $font_family ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_font_height = esc_html( et_get_option( 'body_font_height' ) );
|
||||
|
||||
if ( ! empty( $body_font_height ) ) {
|
||||
$body_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'line-height',
|
||||
'value' => $body_font_height,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_font_size = esc_html( et_get_option( 'body_font_size' ) );
|
||||
|
||||
if ( ! empty( $body_font_size ) ) {
|
||||
$body_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => $body_font_size,
|
||||
'suffix' => 'px',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_font_color = esc_html( et_get_option( 'font_color' ) );
|
||||
|
||||
if ( ! empty( $body_font_color ) ) {
|
||||
$body_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'color',
|
||||
'value' => $body_font_color,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $body_styles ) ) {
|
||||
$body_styles = sprintf( '%1$s { %2$s }', $this->_body_selector, $body_styles );
|
||||
}
|
||||
|
||||
$link_color = esc_html( et_get_option( 'link_color' ) );
|
||||
|
||||
if ( ! empty( $link_color ) ) {
|
||||
$body_styles .= et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'color',
|
||||
'value' => $link_color,
|
||||
'selector' => '.block-editor-block-list__layout .wp-block a, .editor-styles-wrapper .wp-block .wp-block-freeform a',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $body_styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print post title styles.
|
||||
*/
|
||||
public function get_title_styles() {
|
||||
|
||||
$title_styles = '';
|
||||
|
||||
$heading_font = esc_html( et_get_option( 'heading_font' ) );
|
||||
|
||||
// Fallback to the body font.
|
||||
if ( empty( $heading_font ) || 'none' === $heading_font ) {
|
||||
$heading_font = esc_html( et_get_option( 'body_font' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $heading_font ) && 'none' !== $heading_font ) {
|
||||
et_builder_enqueue_font( $heading_font );
|
||||
$font_family = et_builder_get_font_family( $heading_font );
|
||||
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'font-family',
|
||||
'value' => str_replace( 'font-family: ', '', $font_family ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_header_spacing = esc_html( et_get_option( 'body_header_spacing' ) );
|
||||
|
||||
if ( ! empty( $body_header_spacing ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'letter-spacing',
|
||||
'value' => $body_header_spacing,
|
||||
'suffix' => 'px',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$header_color = esc_html( et_get_option( 'header_color' ) );
|
||||
|
||||
if ( ! empty( $header_color ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'color',
|
||||
'value' => $header_color,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_header_height = esc_html( et_get_option( 'body_header_height' ) );
|
||||
|
||||
if ( ! empty( $body_header_height ) && '1' !== $body_header_height ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'line-height',
|
||||
'value' => $body_header_height,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$body_header_style = esc_html( et_get_option( 'body_header_style' ) );
|
||||
|
||||
if ( ! empty( $body_header_style ) ) {
|
||||
// Convert string into array.
|
||||
$styles_array = explode( '|', $body_header_style );
|
||||
|
||||
if ( in_array( 'bold', $styles_array, true ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'font-weight',
|
||||
'value' => 'bold',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( 'italic', $styles_array, true ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'font-style',
|
||||
'value' => 'italic',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( 'uppercase', $styles_array, true ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'text-transform',
|
||||
'value' => 'uppercase',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( in_array( 'underline', $styles_array, true ) ) {
|
||||
$title_styles .= et_builder_generate_css_style(
|
||||
array(
|
||||
'style' => 'text-decoration',
|
||||
'value' => 'underline',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$body_header_size = esc_html( et_get_option( 'body_header_size' ) );
|
||||
|
||||
if ( ! empty( $title_styles ) ) {
|
||||
$title_styles = sprintf( '%1$s { %2$s }', $this->_heading_selector, $title_styles );
|
||||
}
|
||||
|
||||
if ( ! empty( $body_header_size ) ) {
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => $body_header_size,
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h1',
|
||||
)
|
||||
);
|
||||
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => intval( $body_header_size * .86 ),
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h2',
|
||||
)
|
||||
);
|
||||
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => intval( $body_header_size * .73 ),
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h3',
|
||||
)
|
||||
);
|
||||
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => intval( $body_header_size * .6 ),
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h4',
|
||||
)
|
||||
);
|
||||
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => intval( $body_header_size * .53 ),
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h5',
|
||||
)
|
||||
);
|
||||
|
||||
$title_styles .= ',' . et_builder_generate_css(
|
||||
array(
|
||||
'style' => 'font-size',
|
||||
'value' => intval( $body_header_size * .47 ),
|
||||
'suffix' => 'px',
|
||||
'selector' => '.editor-styles-wrapper .wp-block .wp-block-freeform h6',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $title_styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print TB's style.
|
||||
*/
|
||||
public function get_tb_styles() {
|
||||
|
||||
if ( empty( $this->_post_content_shortcode ) && empty( $this->_post_title_shortcode ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'ET_Builder_Element' ) ) {
|
||||
require_once ET_BUILDER_DIR . 'class-et-builder-value.php';
|
||||
require_once ET_BUILDER_DIR . 'class-et-builder-element.php';
|
||||
require_once ET_BUILDER_DIR . 'ab-testing.php';
|
||||
et_builder_init_global_settings();
|
||||
et_builder_add_main_elements();
|
||||
et_builder_settings_init();
|
||||
ET_Builder_Element::set_media_queries();
|
||||
}
|
||||
|
||||
// To generate the styles from the shortcode, this do_shortcode will intialize et_pb_post_content and et_pb_post_title modules classes.
|
||||
ob_start();
|
||||
do_shortcode( $this->_post_title_shortcode . $this->_post_content_shortcode );
|
||||
ob_end_clean();
|
||||
|
||||
// Get style generated by modules.
|
||||
$tb_style = ET_Builder_Element::get_style();
|
||||
|
||||
$have_post_content_style = preg_match( '/\.et_pb_post_content_0 { (.*) }/', $tb_style, $matches );
|
||||
if ( $have_post_content_style && isset( $matches[1] ) ) {
|
||||
$et_pb_post_content_styles = explode( ';', $matches[1] );
|
||||
$typography_properties = array(
|
||||
'color',
|
||||
'font-family',
|
||||
'font-size',
|
||||
'font-weight',
|
||||
'font-style',
|
||||
'text-align',
|
||||
'text-shadow',
|
||||
'letter-spacing',
|
||||
'line-height',
|
||||
'text-transform',
|
||||
'text-decoration',
|
||||
'text-decoration-style',
|
||||
);
|
||||
|
||||
$post_content_style = '';
|
||||
|
||||
foreach ( $et_pb_post_content_styles as $et_pb_post_content_style ) {
|
||||
$style = explode( ':', $et_pb_post_content_style ); // explode CSS property and value.
|
||||
$css_property = trim( et_()->array_get( $style, '0' ) );
|
||||
if ( in_array( $css_property, $typography_properties, true ) ) {
|
||||
$post_content_style .= $css_property . ':' . et_()->array_get( $style, '1' ) . ';';
|
||||
}
|
||||
}
|
||||
|
||||
$tb_style = $this->_body_selector . ' {' . $post_content_style . '}' . $tb_style;
|
||||
}
|
||||
|
||||
foreach ( self::$heading_selectors as $heading_selector ) {
|
||||
$tb_style = str_replace( ".et_pb_post_content_0 $heading_selector ", ".editor-styles-wrapper .wp-block .wp-block-freeform $heading_selector ,.editor-styles-wrapper $heading_selector.rich-text ", $tb_style );
|
||||
}
|
||||
|
||||
$tb_style = str_replace( '.et_pb_post_content_0 a ', '.editor-styles-wrapper .wp-block .wp-block-freeform a,.block-editor-block-list__layout .wp-block a ', $tb_style );
|
||||
$tb_style = str_replace( array( '.et_pb_post_content_0 ul li ', '.et_pb_post_content_0.et_pb_post_content ul li' ), '.editor-styles-wrapper .wp-block .wp-block-freeform ul li,.block-editor-block-list__layout ul li ', $tb_style );
|
||||
$tb_style = str_replace( array( '.et_pb_post_content_0 ol li ', '.et_pb_post_content_0.et_pb_post_content ol li' ), '.editor-styles-wrapper .wp-block .wp-block-freeform ol li,.block-editor-block-list__layout ol li ', $tb_style );
|
||||
$tb_style = str_replace( array( 'et_pb_post_content_0 ul ', '.et_pb_post_content_0.et_pb_post_content ul ' ), '.editor-styles-wrapper .wp-block .wp-block-freeform ul.wp-block,.block-editor-block-list__layout ul.wp-block ', $tb_style );
|
||||
$tb_style = str_replace( array( '.et_pb_post_content_0 ol ', '.et_pb_post_content_0.et_pb_post_content ol ' ), '.editor-styles-wrapper .wp-block .wp-block-freeform ol.wp-block,.block-editor-block-list__layout ol.wp-block ', $tb_style );
|
||||
$tb_style = str_replace( array( '.et_pb_post_content_0 blockquote ', '.et_pb_post_content_0.et_pb_post_content blockquote' ), '.editor-styles-wrapper .wp-block .wp-block-freeform ol,.block-editor-block-list__layout blockquote ', $tb_style );
|
||||
|
||||
// Replace the post title style selectors with editor's post title selector.
|
||||
$tb_style = str_replace( array( '.et_pb_post_title_0 .entry-title', '.et_pb_post_title_0 .et_pb_title_container h1.entry-title, .et_pb_post_title_0 .et_pb_title_container h2.entry-title, .et_pb_post_title_0 .et_pb_title_container h3.entry-title, .et_pb_post_title_0 .et_pb_title_container h4.entry-title, .et_pb_post_title_0 .et_pb_title_container h5.entry-title, .et_pb_post_title_0 .et_pb_title_container h6.entry-title' ), '.edit-post-visual-editor__post-title-wrapper .editor-post-title__block .editor-post-title__input', $tb_style );
|
||||
|
||||
// Enqueue fonts.
|
||||
$fonts_regex = '/font-family:\s+[\'"]([a-zA-Z0-9\s]+)[\'"]/';
|
||||
$has_fonts = preg_match_all( $fonts_regex, $tb_style, $matches, PREG_SET_ORDER );
|
||||
if ( false !== $has_fonts && isset( $match[1] ) ) {
|
||||
foreach ( $matches as $match ) {
|
||||
et_builder_enqueue_font( $match[1] );
|
||||
}
|
||||
}
|
||||
|
||||
return $tb_style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate css selectors from prefixes and suffixes.
|
||||
*
|
||||
* @param array $selectors Selectors list.
|
||||
* @param string $prefix Selector prefix.
|
||||
* @param string $suffix Selector suffix.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function _generate_selectors( $selectors, $prefix, $suffix = '' ) {
|
||||
$prepared_selectors = '';
|
||||
|
||||
foreach ( (array) $selectors as $selector ) {
|
||||
$prepared_selectors .= $prefix . $selector . $suffix . ',';
|
||||
}
|
||||
|
||||
return rtrim( $prepared_selectors, ',' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Initialize ET_GB_Editor_Typography.
|
||||
ET_GB_Editor_Typography::instance();
|
||||
@@ -0,0 +1,676 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class ET_GB_Block_Layout {
|
||||
/**
|
||||
* @var ET_GB_Block_Layout
|
||||
*/
|
||||
private static $_instance;
|
||||
|
||||
private $block_name = 'divi/layout';
|
||||
|
||||
function __construct() {
|
||||
if ( ! et_core_is_gutenberg_active() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->register_block();
|
||||
$this->register_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class instance
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return object class instance
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === self::$_instance ) {
|
||||
self::$_instance = new self();
|
||||
}
|
||||
|
||||
return self::$_instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register block
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function register_block() {
|
||||
register_block_type(
|
||||
$this->block_name,
|
||||
array(
|
||||
'attributes' => array(
|
||||
'layoutContent' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function register_hooks() {
|
||||
// Admin screen
|
||||
add_action( 'admin_init', array( $this, 'register_portability_on_builder_page' ) );
|
||||
|
||||
// Block preview inside gutenberg
|
||||
add_action( 'template_include', array( $this, 'register_preview_template' ) );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_block_preview_styles_scripts' ), 15 );
|
||||
add_action( 'wp_footer', array( $this, 'enqueue_block_preview_footer_styles_scripts' ) );
|
||||
add_action( 'pre_get_posts', array( $this, 'modify_layout_content_condition' ), 20 );
|
||||
|
||||
add_filter( 'body_class', array( $this, 'add_body_classnames' ) );
|
||||
add_filter( 'et_pb_section_data_attributes', array( $this, 'add_section_boxshadow_attributes' ), 10, 3 );
|
||||
add_filter( 'the_content', array( $this, 'modify_layout_content_output' ), 1 );
|
||||
add_filter( 'get_post_metadata', array( $this, 'modify_layout_content_builder_meta' ), 10, 4 );
|
||||
add_filter( 'et_fb_load_raw_post_content', array( $this, 'modify_layout_content_visual_builder_raw_post_content' ) );
|
||||
add_filter( 'et_builder_render_layout', array( $this, 'modify_theme_builder_body_layout' ), 7 );
|
||||
|
||||
// Block rendering on frontend
|
||||
add_filter( 'render_block', array( $this, 'render_block' ), 100, 2 );
|
||||
add_filter( 'get_the_excerpt', array( $this, 'get_the_post_excerpt' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current request is Divi Layout preview for block request. Layout block preview page
|
||||
* is only valid for logged in user with edit_posts cap with query string for activating block
|
||||
* layout preview and its nonce to verify it.
|
||||
*
|
||||
* Initially, is_singular() check existed but reusable block at `wp_block` CPT and any other CPT
|
||||
* that has no frontend due to its post type registration sets `public` attribute to `false`
|
||||
* renders layout block preview at non singular page makes is_singular() check need to be dropped
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_layout_block_preview() {
|
||||
return isset( $_GET['et_block_layout_preview'] ) && et_core_security_check(
|
||||
'edit_posts',
|
||||
'et_block_layout_preview',
|
||||
'et_block_layout_preview_nonce',
|
||||
'_GET',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current builder shortcode rendering is done inside layout block
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_layout_block() {
|
||||
global $et_is_layout_block;
|
||||
|
||||
// Ensure the returned value is bool
|
||||
return $et_is_layout_block ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register portability which is needed to import premade and saved Layout via Divi Library;
|
||||
* Portability is intentionally disabled on builder page by `et_builder_should_load_framework()`
|
||||
* nevertheless excluding GB there doesn't work because it is being too early before any
|
||||
* GB check is hooked. Thus Register another portability for GB + builder page
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function register_portability_on_builder_page() {
|
||||
global $pagenow;
|
||||
|
||||
// No permission, can't load library UI in the first place
|
||||
if ( ! et_pb_is_allowed( 'divi_library' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Exit if current page is not saved edit page
|
||||
$is_edit_page = 'post.php' === $pagenow && isset( $_GET['post'] );
|
||||
|
||||
if ( ! $is_edit_page ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = intval( $_GET['post'] );
|
||||
|
||||
// Exit if current page doesn't use Gutenberg
|
||||
if ( ! use_block_editor_for_post_type( get_post_type( $post_id ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Exit if current page doesn't use builder
|
||||
if ( ! et_pb_is_pagebuilder_used( $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Register portability
|
||||
et_core_portability_register(
|
||||
'et_builder',
|
||||
array(
|
||||
'name' => esc_html__( 'Divi Builder Layout', 'et_builder' ),
|
||||
'type' => 'post',
|
||||
'view' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter rendered blocks on FE.
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @since ?? Filter core/post-excerpt rendered output.
|
||||
*
|
||||
* @param string $block_content Saved & serialized block data.
|
||||
* @param array $block Block info.
|
||||
*/
|
||||
public function render_block( $block_content, $block ) {
|
||||
// Core - Post Excerpt block.
|
||||
if ( 'core/post-excerpt' === $block['blockName'] ) {
|
||||
return $this->get_rendered_post_excerpt( $block_content, true );
|
||||
}
|
||||
|
||||
// Divi - Layout block.
|
||||
if ( 'divi/layout' === $block['blockName'] ) {
|
||||
global $et_is_layout_block;
|
||||
|
||||
// Set flag.
|
||||
$et_is_layout_block = true;
|
||||
|
||||
// Render block content's shortcode. Block content actually can be rendered without this
|
||||
// method and only depending to WordPress' `do_shortcode` hooked into `the_content`. However
|
||||
// layout block need to set global for detecting that shortcode is rendered inside layout
|
||||
// block hence the early shortcode rendering between global variables.
|
||||
$block_content = do_shortcode( $block_content );
|
||||
|
||||
// Reset flag.
|
||||
$et_is_layout_block = false;
|
||||
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
return $block_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter post excerpt of REST API request.
|
||||
*
|
||||
* @since 4.9.10
|
||||
* @since ?? Only filter post excerpt rendered from REST API request. This API request
|
||||
* is being used by Block Editor.
|
||||
*
|
||||
* @param string $post_excerpt Current post excerpt rendered.
|
||||
*
|
||||
* @return string Modified post excerpt.
|
||||
*/
|
||||
public function get_the_post_excerpt( $post_excerpt ) {
|
||||
// Bail early if current request is not REST API request.
|
||||
if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
|
||||
return $post_excerpt;
|
||||
}
|
||||
|
||||
return $this->get_rendered_post_excerpt( $post_excerpt );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rendered post excerpt built with builder. Always return rendered $post_excerpt
|
||||
* because it's already wrapped with Post Excerpt block wrapper.
|
||||
*
|
||||
* @since ??
|
||||
*
|
||||
* @param string $post_excerpt Current rendered post excerpt.
|
||||
* @param boolean $is_wrapped Whether the post excerpt is wrapped or not.
|
||||
*
|
||||
* @return string Old or new rendered post excerpt.
|
||||
*/
|
||||
public function get_rendered_post_excerpt( $post_excerpt, $is_wrapped = false ) {
|
||||
// Bail early if no global post. Need to get the post here due to some issues with
|
||||
// 3rd party plugins regarding missing 2nd arg on the `get_the_excerpt` filter.
|
||||
$post = get_post();
|
||||
if ( empty( $post ) ) {
|
||||
return $post_excerpt;
|
||||
}
|
||||
|
||||
if ( ! empty( $post->post_excerpt ) ) {
|
||||
return $post_excerpt;
|
||||
}
|
||||
|
||||
// Bail early if Builder framework is not loaded. There are some cases where 3rd
|
||||
// party plugins run scan without visiting theme functions file.
|
||||
if ( ! function_exists( 'et_builder_load_framework' ) ) {
|
||||
return $post_excerpt;
|
||||
}
|
||||
|
||||
if ( ! et_pb_is_pagebuilder_used( $post->ID ) ) {
|
||||
return $post_excerpt;
|
||||
}
|
||||
|
||||
static $et_rendered_post_excerpt = array();
|
||||
|
||||
// Bail early if current post is already processed.
|
||||
if ( isset( $et_rendered_post_excerpt[ $post->ID ] ) ) {
|
||||
return $et_rendered_post_excerpt[ $post->ID ];
|
||||
}
|
||||
|
||||
// 1. Ensure all the ET shortcode are registered.
|
||||
if ( ! did_action( 'et_builder_ready' ) ) {
|
||||
// When the `get_the_excerpt` filter is called by Query Loop block on the FE,
|
||||
// the `ET_Builder_Element` class is loaded properly but no ET shortcode is
|
||||
// registered yet. In this case, we can call `et_builder_init_global_settings`
|
||||
// & `et_builder_add_main_elements` methods directly. However, this class is not
|
||||
// loaded on the Block Editor, so we have to load all related files manually
|
||||
// before we can call those methods to register the shortcode.
|
||||
if ( ! class_exists( 'ET_Builder_Element' ) ) {
|
||||
require_once ET_BUILDER_DIR . 'class-et-builder-value.php';
|
||||
require_once ET_BUILDER_DIR . 'class-et-builder-element.php';
|
||||
require_once ET_BUILDER_DIR . 'ab-testing.php';
|
||||
}
|
||||
|
||||
et_builder_init_global_settings();
|
||||
et_builder_add_main_elements();
|
||||
et_builder_settings_init();
|
||||
}
|
||||
|
||||
// 2. Generate Builder post excerpt.
|
||||
// WordPress post excerpt length comes from `excerpt_length` filter. And, it's
|
||||
// words based length, not characters based length.
|
||||
$excerpt_length = apply_filters( 'excerpt_length', 55 );
|
||||
$new_post_excerpt = et_core_intentionally_unescaped( wpautop( et_delete_post_first_video( truncate_post( $excerpt_length, false, $post, true, true ) ) ), 'html' );
|
||||
|
||||
// 3. Ensure to return the block wrapper if the $post_excerpt is already wrapped.
|
||||
if ( $is_wrapped ) {
|
||||
$wrapper = '/(<p class="wp-block-post-excerpt__excerpt">)(.*?)(<a|<\/p>)/';
|
||||
$new_post_excerpt = wp_strip_all_tags( $new_post_excerpt );
|
||||
$new_post_excerpt = preg_replace( $wrapper, "$1{$new_post_excerpt}$3", $post_excerpt );
|
||||
}
|
||||
|
||||
$et_rendered_post_excerpt[ $post->ID ] = $new_post_excerpt;
|
||||
|
||||
return $new_post_excerpt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overwrite template path if current request is Divi Layout block preview
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function register_preview_template( $template ) {
|
||||
if ( self::is_layout_block_preview() ) {
|
||||
// disable admin bar
|
||||
show_admin_bar( false );
|
||||
|
||||
// Use layout block specific template for render layout block preview (headerless
|
||||
// and footerless templates). BFB template was initialy used for this for DRY reason
|
||||
// but its #page-container-bfb causing styling issues
|
||||
return ET_BUILDER_DIR . 'templates/block-layout-preview.php';
|
||||
}
|
||||
|
||||
// return original template
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Theme Builder's template settings of current (layout block preview) page
|
||||
*
|
||||
* @since 4.3.4
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_preview_tb_template() {
|
||||
// Identify current request, and get applicable TB template for current page
|
||||
$request = ET_Theme_Builder_Request::from_current();
|
||||
$templates = et_theme_builder_get_theme_builder_templates( true );
|
||||
$settings = et_theme_builder_get_flat_template_settings_options();
|
||||
$tb_template = $request->get_template( $templates, $settings );
|
||||
|
||||
// Define template properties as variables for readability
|
||||
$template_id = et_()->array_get( $tb_template, 'id', 0 );
|
||||
$layout_id = et_()->array_get( $tb_template, 'layouts.body.id', 0 );
|
||||
$layout_enabled = et_()->array_get( $tb_template, 'layouts.body.enabled', false );
|
||||
$layout_override = et_()->array_get( $tb_template, 'layouts.body.override', false );
|
||||
$has_layout = $layout_id && $layout_enabled && $layout_override;
|
||||
|
||||
return array(
|
||||
'layout_id' => $layout_id,
|
||||
'layout_enabled' => $layout_enabled,
|
||||
'template_id' => $template_id,
|
||||
'has_layout' => $has_layout,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Early scripts and styles queue for Layout Block Preview page
|
||||
* Need to queue early because `et-builder-modules-script` uses localize scripts on this method
|
||||
*
|
||||
* @since 4.4.1 Compatibility fixes for WP 5.4
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function enqueue_block_preview_styles_scripts() {
|
||||
if ( ! self::is_layout_block_preview() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( et_fb_enabled() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Enqueue frame helper if it hasn't been queued
|
||||
if ( ! wp_script_is( 'et-frame-helpers', 'enqueued' ) ) {
|
||||
wp_enqueue_script(
|
||||
'et-frame-helpers',
|
||||
ET_BUILDER_URI . '/frontend-builder/build/frame-helpers.js',
|
||||
array(),
|
||||
ET_BUILDER_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
// frontend-builder-scripts.js handle might change when scripts are minified
|
||||
$builder_script_handle = apply_filters(
|
||||
'et_builder_modules_script_handle',
|
||||
'et-builder-modules-script'
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
$builder_script_handle,
|
||||
'ETBlockLayoutModulesScript',
|
||||
array(
|
||||
// blockId is dash separated alphanumeric uuid value
|
||||
'blockId' => sanitize_title( et_()->array_get( $_POST, 'et_editor_block_id', 0 ) ),
|
||||
|
||||
// Make layout shortcode available for ajax pagination request by outputting it
|
||||
// as JS params so the pagination ajax request can have identical page on next
|
||||
// request. Thus any custom script has no business being here: as long as the same
|
||||
// module shortcode exist on next page it should be okay. Hence, kses em all
|
||||
// regardless user capability to reduce security concern
|
||||
'layoutContent' => wp_kses_post( et_()->array_get( $_POST, 'et_layout_block_layout_content', '' ) ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Late scripts and styles queue for Layout Block Preview page
|
||||
* Need to queue late because localize script needs to populate settings from rendered modules
|
||||
*
|
||||
* @since 4.4.1 Renamed into `enqueue_block_preview_footer_styles_scripts`. Localize script
|
||||
* value which is used by `et-builder-modules-script` is queued on earlier hook
|
||||
* @since 4.1.0
|
||||
*/
|
||||
public function enqueue_block_preview_footer_styles_scripts() {
|
||||
if ( ! self::is_layout_block_preview() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Frontend preview adjustment should only be called on layout block preview frame
|
||||
// and shouldn't be called on layout block builder
|
||||
if ( ! et_fb_enabled() ) {
|
||||
wp_enqueue_script(
|
||||
'et-block-layout-preview',
|
||||
ET_BUILDER_URI . '/scripts/block-layout-frontend-preview.js',
|
||||
array( 'jquery' ),
|
||||
ET_BUILDER_PRODUCT_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'et-block-layout-preview',
|
||||
'ETBlockLayoutPreview',
|
||||
array(
|
||||
// blockId is dash separated alphanumeric uuid value
|
||||
'blockId' => sanitize_title( et_()->array_get( $_POST, 'et_editor_block_id', 0 ) ),
|
||||
|
||||
// Exposed module settings for layout block preview for making nescessary adjustments
|
||||
'assistiveSettings' => ET_Builder_Element::get_layout_block_assistive_settings(),
|
||||
|
||||
// Exposed Divi breakpoint minimum widths
|
||||
'breakpointMinWidths' => et_pb_responsive_options()->get_breakpoint_min_widths(),
|
||||
|
||||
// Divi style mode
|
||||
'styleModes' => array(
|
||||
'desktop',
|
||||
'tablet',
|
||||
'phone',
|
||||
'hover',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Disabled link modal, originally added for classic builder preview
|
||||
wp_enqueue_style(
|
||||
'et-block-layout-preview-style',
|
||||
ET_BUILDER_URI . '/styles/preview-layout-block.css',
|
||||
array(),
|
||||
ET_BUILDER_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add builder classname on body class if layout block exist on the page
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array classname
|
||||
*
|
||||
* @return array modified classname
|
||||
*/
|
||||
public function add_body_classnames( $classes ) {
|
||||
if ( self::is_layout_block_preview() ) {
|
||||
$classes[] = 'et-db';
|
||||
$classes[] = 'et-block-layout-preview';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add box shadow's highest offset value if box shadow is used on section so block preview area
|
||||
* can adjust its padding to make section's box shadow previewable on block preview
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_section_boxshadow_attributes( $attributes, $props, $render_count ) {
|
||||
$box_shadow_style = et_()->array_get( $props, 'box_shadow_style', '' );
|
||||
|
||||
// Only apply on layout block and box shadow is set
|
||||
if ( ! self::is_layout_block_preview() || '' === $box_shadow_style || 'none' === $box_shadow_style ) {
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
// List of box shadow attribute that might affect how tall the box shadow is
|
||||
$spread = et_()->array_get( $props, 'box_shadow_spread', '' );
|
||||
$blur = et_()->array_get( $props, 'box_shadow_blur', '' );
|
||||
$vertical = et_()->array_get( $props, 'box_shadow_vertical', '' );
|
||||
|
||||
$values = array(
|
||||
'spread' => absint( $spread ),
|
||||
'blur' => absint( $blur ),
|
||||
'vertical' => absint( $vertical ),
|
||||
);
|
||||
|
||||
// Sort attributes; there's no way to safely convert all unit (em, rem, etc) into one
|
||||
// specific unit accurately, so this assumes that all values are in px
|
||||
asort( $values );
|
||||
|
||||
// Point to the last array
|
||||
end( $values );
|
||||
|
||||
// Get last array keys
|
||||
$highest_attribute_key = key( $values );
|
||||
|
||||
// Add attribute with higest value into DOM data-* attribute so it can be referenced
|
||||
$attributes['box-shadow-offset'] = et_()->array_get( $props, 'box_shadow_' . $highest_attribute_key, '' );
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify layout content condition. Preview template should consider itself is_single = true
|
||||
*
|
||||
* @since 4.1.0
|
||||
* @since 4.4.1 don't overwrite `p` and `post_type` query vars if homepage displays static page
|
||||
*
|
||||
* @param object
|
||||
*/
|
||||
public function modify_layout_content_condition( $query ) {
|
||||
if ( $query->is_main_query() && self::is_layout_block_preview() ) {
|
||||
// Set to `false` to avoid home specific classname and attribute being printed. This is
|
||||
// specifically needed on CPT which is not publicly queryable / doesn't have frontend
|
||||
// page such as reusable block's `wp_block` CPT
|
||||
$query->is_home = false;
|
||||
|
||||
// Set to `true` so `#et-boc` wrapper is correctly added
|
||||
$query->is_single = true;
|
||||
$query->is_singular = true;
|
||||
|
||||
// Query name doesn't exist while post_id is passed via query string means current
|
||||
// layout block preview is rendered on CPT that doesn't publicly queryable / doesn't
|
||||
// have registered frontend page such `wp_block`. Manually set post id and post type
|
||||
// to avoid current query fetches ALL posts on `post` post type. However, bail if
|
||||
// current page has page_id. This means the current page, most likely homepage URL when
|
||||
// it has `name` query like this, renders static page on its homepage URL (defined at
|
||||
// dashboard > settings > your homepage display). Not doing this will cause current
|
||||
// homepage has incorrect post type and id which leads to 404 preview page which
|
||||
// will prevent the preview page from being rendered
|
||||
if ( ! isset( $query->query['name'] ) && 0 === $query->get( 'page_id' ) ) {
|
||||
if ( isset( $_GET['et_post_id'] ) ) {
|
||||
$query->set( 'p', intval( $_GET['et_post_id'] ) );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['et_post_type'] ) ) {
|
||||
$query->set( 'post_type', sanitize_text_field( $_GET['et_post_type'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify layout content content output based on layout shortcode layout sent over POST for
|
||||
* previewing layout block on gutenberg editor
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $content post's content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function modify_layout_content_output( $content ) {
|
||||
if ( self::is_layout_block_preview() && is_main_query() ) {
|
||||
$content = et_()->array_get( $_POST, 'et_layout_block_layout_content', '' );
|
||||
|
||||
// If user don't have posting unfiltered html capability, strip scripts
|
||||
if ( ! current_user_can( 'unfiltered_html' ) ) {
|
||||
$content = wp_kses_post( $content );
|
||||
}
|
||||
|
||||
return wp_unslash( $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify post meta for enabling builder status and disabling static css if current request is
|
||||
* layout block preview
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param null $value
|
||||
* @param int $object_id
|
||||
* @param string $meta_key
|
||||
* @param bool $single
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function modify_layout_content_builder_meta( $value, $object_id, $meta_key, $single ) {
|
||||
// Force enable builder on layout block preview page request
|
||||
if ( '_et_pb_use_builder' === $meta_key && self::is_layout_block_preview() ) {
|
||||
return 'on';
|
||||
}
|
||||
|
||||
// Force disable static CSS on layout block preview page request so static CSS doesn't cache
|
||||
// incorrect stylesheet and break layout block styling
|
||||
if ( '_et_pb_static_css_file' === $meta_key && self::is_layout_block_preview() ) {
|
||||
return 'off';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify raw post content for visual builder for layout content edit screen
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $post_content
|
||||
*
|
||||
* @return string modified post content
|
||||
*/
|
||||
public function modify_layout_content_visual_builder_raw_post_content( $post_content ) {
|
||||
if ( self::is_layout_block_preview() ) {
|
||||
// Explicitly set post_id value based on query string because layout block's edit
|
||||
// window of CPT that has no frontend page such as reusable block's `wp_block` CPT
|
||||
// might use other / last post loop for rendering visual builder structure since its
|
||||
// own post data isn't publicly queryable
|
||||
$post_id = intval( et_()->array_get( $_GET, 'et_post_id', get_the_ID() ) );
|
||||
$block_id = sanitize_title( et_()->array_get( $_GET, 'blockId' ) );
|
||||
|
||||
$key = "_et_block_layout_preview_{$block_id}";
|
||||
$post_content = wp_unslash( get_post_meta( $post_id, $key, true ) );
|
||||
}
|
||||
|
||||
return $post_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify Theme Builder body layout that is used on layout block preview
|
||||
*
|
||||
* @since 4.3.4
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function modify_theme_builder_body_layout( $content ) {
|
||||
// Skip if current request isn't layout block preview
|
||||
if ( ! self::is_layout_block_preview() ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Get `et_pb_post_content` shortcode inside layout by pulling regex and matching it.
|
||||
// `et_pb_post_content` has to exist, otherwise `the_content()` won't be rendered; Return
|
||||
// plain `et_pb_post_content` shortcode if current layout doesn't have any
|
||||
$post_content_regex = get_shortcode_regex( et_theme_builder_get_post_content_modules() );
|
||||
|
||||
preg_match_all( "/$post_content_regex/", $content, $post_content_module, PREG_SET_ORDER );
|
||||
|
||||
$post_content_shortcode = et_()->array_get(
|
||||
$post_content_module,
|
||||
'0.0',
|
||||
'[et_pb_post_content][/et_pb_post_content]'
|
||||
);
|
||||
|
||||
// Return `et_pb_post_content` wrapped by section > row > column which has no unwanted
|
||||
// styling. TB body layout might have any module imaginable while in context of layout block
|
||||
// preview, only `et_pb_post_content` matters because its typography setting can override
|
||||
// default typography styling
|
||||
return '[et_pb_section admin_label="section" custom_padding="0px|0px|0px|0px"]
|
||||
[et_pb_row admin_label="row" custom_padding="0px|0px|0px|0px" custom_margin="0px|0px|0px|0px" width="100%"]
|
||||
[et_pb_column type="4_4"]' . $post_content_shortcode . '[/et_pb_column]
|
||||
[/et_pb_row]
|
||||
[/et_pb_section]';
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize ET_GB_Block_Layout
|
||||
ET_GB_Block_Layout::instance();
|
||||
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ET_GB_Utils_Conversion
|
||||
*
|
||||
* Handling Gutenberg serialized content conversion into builder shortcode layout
|
||||
*/
|
||||
class ET_GB_Utils_Conversion {
|
||||
// Populate all layout block which is placed inside other block. Layout block contains
|
||||
// section which has to be the first level element once converted into VB content
|
||||
private $deep_layout_blocks = array();
|
||||
|
||||
// Layout list. Layout block got its own section. Others are concatenated into text module
|
||||
private $layout_list = array();
|
||||
|
||||
// Temporary variable to hold non layout block into one
|
||||
private $text_module_content = '';
|
||||
|
||||
// Serialized layout
|
||||
private $shortcode_layout = '';
|
||||
|
||||
/**
|
||||
* Check if given block is layout block
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @todo being set as static so it is easier to be used outside this class. If being used quite
|
||||
* frequently, probably consider wrap this into function. Not needed at the moment tho
|
||||
*
|
||||
* @param array $block Parsed block.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_layout_block( $block = array() ) {
|
||||
$block_name = et_()->array_get( $block, 'blockName', '' );
|
||||
|
||||
return 'divi/layout' === $block_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if given block is reusable block
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @todo being set as static so it is easier to be used outside this class. If being used quite
|
||||
* frequently, probably consider wrap this into function. Not needed at the moment tho
|
||||
*
|
||||
* @param array $block Parsed block.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_reusable_block( $block = array() ) {
|
||||
$block_name = et_()->array_get( $block, 'blockName', '' );
|
||||
|
||||
return 'core/block' === $block_name && et_()->array_get( $block, 'attrs.ref' ) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get reusable block's parsed content. NOTE: WordPress has built in `render_block_core_block()`
|
||||
* but it renders the block and its content instead of parse its content.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @see render_block_core_block()
|
||||
*
|
||||
* @todo being set as static so it is easier to be used outside this class. If being used quite
|
||||
* frequently, probably consider wrap this into function. Not needed at the moment tho
|
||||
*
|
||||
* @param array $block Parsed block.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_reusable_block_content( $block ) {
|
||||
$block_id = et_()->array_get( $block, 'attrs.ref' );
|
||||
$block_data = get_post( $block_id );
|
||||
|
||||
if ( ! $block_data || 'wp_block' !== $block_data->post_type || 'publish' !== $block_data->post_status ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return parse_blocks( $block_data->post_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse reusable block by getting its content and append it as innerBlocks
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array Parsed block.
|
||||
*
|
||||
* @return array Modified parsed block.
|
||||
*/
|
||||
public static function parse_reusable_block( $block ) {
|
||||
$reusable_block_data = self::get_reusable_block_content( $block );
|
||||
$block['innerBlocks'] = array_merge( $block['innerBlocks'], $reusable_block_data );
|
||||
|
||||
// Unset reusable block's ref attribute so reusable block content is no longer fetched
|
||||
unset( $block['attrs']['ref'] );
|
||||
|
||||
// Change block into group so its content is being rendered
|
||||
$block['blockName'] = 'core/group';
|
||||
|
||||
// Recreate innerContent which is used by block parser to render innerBlock.
|
||||
// See: `render_block()`'s `$block['innerContent'] as $chunk` loop
|
||||
$block['innerContent'] = array_merge(
|
||||
array( '<div class="wp-block-group"><div class="wp-block-group__inner-container">' ),
|
||||
array_fill( 0, count( $block['innerBlocks'] ), null ),
|
||||
array( '</div></div>' )
|
||||
);
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull layout block that is located deep inside inner blocks. Layout block contains section;
|
||||
* in builder, section has to be on the first level of document
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param array $block Parsed block.
|
||||
*/
|
||||
private function pull_layout_block( $block ) {
|
||||
// Pull and populate layout block. Layout block contains section(s) so it should be rendered
|
||||
// on first level layout, below Gutenberg content inside text module
|
||||
if ( self::is_layout_block( $block ) ) {
|
||||
// Pull layout block and populate list of layout block located on inner blocks
|
||||
$this->deep_layout_blocks[] = $block;
|
||||
|
||||
// Remove innerContent and innerHTML value because inner block can't be simply removed
|
||||
// due to nested block rendering relies on `$block['innerContent']` making cross reference
|
||||
// on `$block['innerBlocks']` and removing them causes error (see: `render_block()`'s
|
||||
// `$block['innerContent'] as $chunk` loop). Thus, set deep layout block's content empty
|
||||
// so it doesn't get rendered
|
||||
$block['innerHTML'] = '';
|
||||
$block['innerContent'] = array();
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
// Reusable block's content is not saved inside block; Thus Get reusable block's content,
|
||||
// append it as innerBlock, and pull layout block if exist.
|
||||
if ( self::is_reusable_block( $block ) ) {
|
||||
$block = self::parse_reusable_block( $block );
|
||||
}
|
||||
|
||||
// Recursively loop over block then pull Layout Block
|
||||
if ( ! empty( $block['innerBlocks'] ) ) {
|
||||
$block['innerBlocks'] = array_map(
|
||||
array( $this, 'pull_layout_block' ),
|
||||
$block['innerBlocks']
|
||||
);
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert serialized block into shortcode layout
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $serialized_block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function block_to_shortcode( $serialized_block = '' ) {
|
||||
// Wrapper div needs to be trimmed
|
||||
$layout_open_tag = '<div class="wp-block-divi-layout">';
|
||||
$layout_open_length = strlen( $layout_open_tag );
|
||||
$layout_close_tag = '</div>';
|
||||
$layout_close_length = strlen( $layout_close_tag );
|
||||
|
||||
// Parsed blocks
|
||||
$blocks = parse_blocks( $serialized_block );
|
||||
|
||||
// Loop blocks
|
||||
foreach ( $blocks as $block ) {
|
||||
if ( self::is_layout_block( $block ) ) {
|
||||
// Append currently populated non-Layout Block into one before layout block is appended
|
||||
if ( ! empty( $this->text_module_content ) ) {
|
||||
$this->layout_list[] = $this->text_module_content;
|
||||
|
||||
// Reset text module content so next non-layout block is placed below current layout block
|
||||
$this->text_module_content = '';
|
||||
}
|
||||
|
||||
$this->layout_list[] = $block;
|
||||
} else {
|
||||
// Reusable block's content is not saved inside block; Thus Get reusable block's
|
||||
// content, append it as innerBlock, and pull layout block if exist.
|
||||
if ( self::is_reusable_block( $block ) ) {
|
||||
$block = self::parse_reusable_block( $block );
|
||||
}
|
||||
|
||||
// Pull any Layout Block inside nested block if there's any
|
||||
if ( ! empty( $block['innerBlocks'] ) ) {
|
||||
$block['innerBlocks'] = array_map(
|
||||
array( $this, 'pull_layout_block' ),
|
||||
$block['innerBlocks']
|
||||
);
|
||||
}
|
||||
|
||||
// Populate block into temporary text module content buffer
|
||||
$this->text_module_content .= render_block( $block );
|
||||
}
|
||||
}
|
||||
|
||||
// Populate remaining non-layout block into layout list
|
||||
if ( ! empty( $this->text_module_content ) ) {
|
||||
$this->layout_list[] = $this->text_module_content;
|
||||
|
||||
// Reset
|
||||
$this->text_module_content = '';
|
||||
}
|
||||
|
||||
// Loop over populated content and render it into shortcode layout
|
||||
foreach ( array_merge( $this->layout_list, $this->deep_layout_blocks ) as $item ) {
|
||||
if ( self::is_layout_block( $item ) ) {
|
||||
$shortcode_layout = trim( et_()->array_get( $item, 'innerHTML', '' ) );
|
||||
|
||||
// Remove layout content opening <div>
|
||||
if ( $layout_open_tag === substr( $shortcode_layout, 0, $layout_open_length ) ) {
|
||||
$shortcode_layout = substr( $shortcode_layout, $layout_open_length );
|
||||
}
|
||||
|
||||
// Remove layout content closing </div>
|
||||
if ( $layout_close_tag === substr( $shortcode_layout, ( 0 - $layout_close_length ) ) ) {
|
||||
$shortcode_layout = substr( $shortcode_layout, 0, ( 0 - $layout_close_length ) );
|
||||
}
|
||||
|
||||
$this->shortcode_layout .= $shortcode_layout;
|
||||
} else {
|
||||
$text_module = '[et_pb_text]' . $item . '[/et_pb_text]';
|
||||
$column = '[et_pb_column type="4_4"]' . $text_module . '[/et_pb_column]';
|
||||
$row = '[et_pb_row admin_label="row"]' . $column . '[/et_pb_row]';
|
||||
$this->shortcode_layout .= '[et_pb_section admin_label="section"]' . $row . '[/et_pb_section]';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->shortcode_layout;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert gutenberg block layout into shortcode.
|
||||
* NOTE: There is JS version for activation via Gutenberg. See: `convertBlockToShortcode()`
|
||||
*
|
||||
* @since 4.1.0
|
||||
*
|
||||
* @param string $post_content Post content / serialized block.
|
||||
*
|
||||
* @return string Shortcode layout.
|
||||
*/
|
||||
function et_builder_convert_block_to_shortcode( $post_content ) {
|
||||
$conversion = new ET_GB_Utils_Conversion();
|
||||
|
||||
return $conversion->block_to_shortcode( $post_content );
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
/**
|
||||
* Generalized dynamic content implementation to make it usable for WooCommerce Modules.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle ajax requests to resolve post content.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function et_builder_ajax_resolve_post_content() {
|
||||
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'et_fb_resolve_post_content' ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
|
||||
et_core_die();
|
||||
}
|
||||
|
||||
$_ = ET_Core_Data_Utils::instance();
|
||||
$post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
|
||||
// phpcs:disable ET.Sniffs.ValidatedSanitizedInput -- All values from `$_POST['groups']` and `$_POST['overrides']` arrays value are being sanitized before use in following foreach loop.
|
||||
$groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? $_POST['groups'] : array();
|
||||
$overrides = isset( $_POST['overrides'] ) && is_array( $_POST['overrides'] ) ? $_POST['overrides'] : array();
|
||||
// phpcs:enable
|
||||
$overrides = array_map( 'wp_kses_post', $overrides );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
$invalid_permissions = ! current_user_can( 'edit_post', $post_id );
|
||||
$invalid_post = null === $post;
|
||||
|
||||
if ( $invalid_permissions || $invalid_post ) {
|
||||
et_core_die();
|
||||
}
|
||||
|
||||
$response = array();
|
||||
|
||||
foreach ( $groups as $hash => $field_group ) {
|
||||
$group = sanitize_text_field( isset( $field_group['group'] ) ? (string) $field_group['group'] : '' );
|
||||
$field = isset( $field_group['field'] ) ? sanitize_text_field( (string) $field_group['field'] ) : '';
|
||||
$settings = isset( $field_group['settings'] ) && is_array( $field_group['settings'] ) ? wp_unslash( $field_group['settings'] ) : array();
|
||||
$settings = array_map( 'wp_kses_post', $settings );
|
||||
$is_content = $_->array_get( $field_group, 'attribute' ) === 'content';
|
||||
$response[ $hash ] = apply_filters( "et_builder_resolve_{$group}_post_content_field", $field, $settings, $post_id, $overrides, $is_content );
|
||||
}
|
||||
|
||||
wp_send_json_success( $response );
|
||||
}
|
||||
add_action( 'wp_ajax_et_builder_resolve_post_content', 'et_builder_ajax_resolve_post_content' );
|
||||
|
||||
/**
|
||||
* List terms for a given post.
|
||||
*
|
||||
* @since 3.17.2
|
||||
*
|
||||
* @param array $terms List of terms.
|
||||
* @param boolean $link Whether return link or label.
|
||||
* @param string $separator Terms separators.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function et_builder_list_terms( $terms, $link = true, $separator = ' | ' ) {
|
||||
$output = array();
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$label = esc_html( $term->name );
|
||||
|
||||
if ( $link ) {
|
||||
$label = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url( get_term_link( $term ) ),
|
||||
et_core_esc_previously( $label )
|
||||
);
|
||||
}
|
||||
|
||||
$output[] = $label;
|
||||
}
|
||||
|
||||
return implode( esc_html( $separator ), $output );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title for the current page be it a post, a tax archive, search etc.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @param integer $post_id Post id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function et_builder_get_current_title( $post_id = 0 ) {
|
||||
if ( 0 === $post_id ) {
|
||||
$post_id = get_the_ID();
|
||||
}
|
||||
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
if ( ! ET_Builder_Element::is_theme_builder_layout() || is_singular() ) {
|
||||
return get_the_title( $post_id );
|
||||
}
|
||||
|
||||
if ( is_front_page() ) {
|
||||
return __( 'Home', 'et_builder' );
|
||||
}
|
||||
|
||||
if ( is_home() ) {
|
||||
return __( 'Blog', 'et_builder' );
|
||||
}
|
||||
|
||||
if ( is_404() ) {
|
||||
return __( 'No Results Found', 'et_builder' );
|
||||
}
|
||||
|
||||
if ( is_search() ) {
|
||||
return sprintf( __( 'Results for "%1$s"', 'et_builder' ), get_search_query() );
|
||||
}
|
||||
|
||||
if ( is_author() ) {
|
||||
return get_the_author();
|
||||
}
|
||||
|
||||
if ( is_post_type_archive() ) {
|
||||
return post_type_archive_title( '', false );
|
||||
}
|
||||
|
||||
if ( is_category() || is_tag() || is_tax() ) {
|
||||
return single_term_title( '', false );
|
||||
}
|
||||
|
||||
return get_the_archive_title();
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Ajax service which searches through posts.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle ajax requests to search for posts.
|
||||
*
|
||||
* @since 3.26.7
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function et_builder_ajax_search_posts() {
|
||||
et_core_security_check( 'edit_posts', 'et_builder_search_posts', 'nonce', '_GET' );
|
||||
|
||||
$current_page = isset( $_GET['page'] ) ? (int) $_GET['page'] : 0;
|
||||
$current_page = max( $current_page, 1 );
|
||||
$post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( $_GET['post_type'] ) : '';
|
||||
$value = isset( $_GET['value'] ) ? sanitize_text_field( $_GET['value'] ) : '';
|
||||
$search = isset( $_GET['search'] ) ? sanitize_text_field( $_GET['search'] ) : '';
|
||||
$prepend_value = (int) $value > 0;
|
||||
$results_per_page = 20;
|
||||
$results = array(
|
||||
'results' => array(),
|
||||
'meta' => array(),
|
||||
);
|
||||
$include_current_post = '1' === (string) et_()->array_get( $_GET, 'include_current_post', '0' );
|
||||
$include_latest_post = '1' === (string) et_()->array_get( $_GET, 'include_latest_post', '0' );
|
||||
|
||||
$public_post_types = et_builder_get_public_post_types();
|
||||
|
||||
if ( ! isset( $public_post_types[ $post_type ] ) ) {
|
||||
$post_type = 'post';
|
||||
}
|
||||
|
||||
$post_type_object = get_post_type_object( $post_type );
|
||||
$post_type_label = $post_type_object ? $post_type_object->labels->singular_name : '';
|
||||
|
||||
$query = array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $results_per_page,
|
||||
'post_status' => 'attachment' === $post_type ? 'inherit' : 'publish',
|
||||
's' => $search,
|
||||
'orderby' => 'date',
|
||||
'order' => 'desc',
|
||||
'paged' => $current_page,
|
||||
);
|
||||
|
||||
if ( $prepend_value ) {
|
||||
$value_post = get_post( $value );
|
||||
|
||||
if ( $value_post && 'publish' === $value_post->post_status && $value_post->post_type === $post_type ) {
|
||||
$results['results'][] = array(
|
||||
'value' => $value,
|
||||
'label' => et_core_intentionally_unescaped( wp_strip_all_tags( $value_post->post_title ), 'react_jsx' ),
|
||||
'meta' => array(
|
||||
'post_type' => et_core_intentionally_unescaped( $post_type_label, 'react_jsx' ),
|
||||
),
|
||||
);
|
||||
|
||||
// We will manually prepend the current value so we need to reduce the number of results.
|
||||
$query['posts_per_page'] -= 1;
|
||||
$query['post__not_in'] = array( $value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'attachment' === $post_type ) {
|
||||
add_filter( 'posts_join', 'et_builder_ajax_search_posts_query_join' );
|
||||
add_filter( 'posts_where', 'et_builder_ajax_search_posts_query_where' );
|
||||
}
|
||||
|
||||
$posts = new WP_Query( $query );
|
||||
|
||||
if ( 'attachment' === $post_type ) {
|
||||
remove_filter( 'posts_join', 'et_builder_ajax_search_posts_query_join' );
|
||||
remove_filter( 'posts_where', 'et_builder_ajax_search_posts_query_where' );
|
||||
}
|
||||
|
||||
if ( $include_current_post && ! empty( $posts->posts ) ) {
|
||||
$current_post_type = sanitize_text_field( et_()->array_get( $_GET, 'current_post_type', 'post' ) );
|
||||
$current_post_type = isset( $public_post_types[ $current_post_type ] ) ? $current_post_type : 'post';
|
||||
$current_post_type_object = get_post_type_object( $current_post_type );
|
||||
$current_post_type_label = $current_post_type_object ? $current_post_type_object->labels->singular_name : '';
|
||||
|
||||
$results['results'][] = array(
|
||||
'value' => 'current',
|
||||
// Translators: %1$s: Post type singular name.
|
||||
'label' => et_core_intentionally_unescaped( sprintf( __( 'This %1$s', 'et_builder' ), $current_post_type_label ), 'react_jsx' ),
|
||||
'meta' => array(
|
||||
'post_type' => et_core_intentionally_unescaped( $current_post_type_label, 'react_jsx' ),
|
||||
),
|
||||
);
|
||||
|
||||
$query['posts_per_page'] -= 1;
|
||||
}
|
||||
|
||||
if ( $include_latest_post && ! empty( $posts->posts ) ) {
|
||||
$results['results'][] = array(
|
||||
'value' => 'latest',
|
||||
// Translators: %1$s: Post type singular name.
|
||||
'label' => et_core_intentionally_unescaped(
|
||||
sprintf(
|
||||
__( 'Latest %1$s', 'et_builder' ),
|
||||
$post_type_label
|
||||
),
|
||||
'react_jsx'
|
||||
),
|
||||
'meta' => array(
|
||||
'post_type' => et_core_intentionally_unescaped( $post_type_label, 'react_jsx' ),
|
||||
),
|
||||
);
|
||||
|
||||
$query['posts_per_page'] -= 1;
|
||||
}
|
||||
|
||||
foreach ( $posts->posts as $post ) {
|
||||
$results['results'][] = array(
|
||||
'value' => (int) $post->ID,
|
||||
'label' => et_core_intentionally_unescaped( wp_strip_all_tags( $post->post_title ), 'react_jsx' ),
|
||||
'meta' => array(
|
||||
'post_type' => et_core_intentionally_unescaped( $post_type_label, 'react_jsx' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$results['meta']['pagination'] = array(
|
||||
'results' => array(
|
||||
'per_page' => (int) $results_per_page,
|
||||
'total' => (int) $posts->found_posts,
|
||||
),
|
||||
'pages' => array(
|
||||
'current' => (int) $current_page,
|
||||
'total' => (int) $posts->max_num_pages,
|
||||
),
|
||||
);
|
||||
|
||||
wp_send_json_success( $results );
|
||||
}
|
||||
add_action( 'wp_ajax_et_builder_search_posts', 'et_builder_ajax_search_posts' );
|
||||
|
||||
/**
|
||||
* Join the parent post for attachments queries.
|
||||
*
|
||||
* @since 3.27.3
|
||||
*
|
||||
* @param string $join The JOIN clause of the query.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function et_builder_ajax_search_posts_query_join( $join ) {
|
||||
global $wpdb;
|
||||
|
||||
$join .= " LEFT JOIN `$wpdb->posts` AS `parent` ON `parent`.`ID` = `$wpdb->posts`.`post_parent` ";
|
||||
|
||||
return $join;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter attachments based on the parent post status, if any.
|
||||
*
|
||||
* @since 3.27.3
|
||||
*
|
||||
* @param string $where The WHERE clause of the query.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function et_builder_ajax_search_posts_query_where( $where ) {
|
||||
global $wpdb;
|
||||
|
||||
$public_post_types = array_keys( et_builder_get_public_post_types() );
|
||||
|
||||
// Add an empty value to:
|
||||
// - Avoid syntax error for `IN ()` when there are no public post types.
|
||||
// - Cause the query to only return posts with no parent when there are no public post types.
|
||||
$public_post_types[] = '';
|
||||
|
||||
$where .= $wpdb->prepare(
|
||||
' AND (
|
||||
`parent`.`ID` IS NULL OR (
|
||||
`parent`.`post_status` = %s
|
||||
AND
|
||||
`parent`.`post_type` IN (' . implode( ',', array_fill( 0, count( $public_post_types ), '%s' ) ) . ')
|
||||
)
|
||||
)',
|
||||
array_merge( array( 'publish' ), $public_post_types )
|
||||
);
|
||||
|
||||
return $where;
|
||||
}
|
||||
159
wp/plugins/divi-builder/includes/builder/feature/window.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Function collection related to window.
|
||||
*
|
||||
* @package Divi
|
||||
* @sub-package Builder
|
||||
* @since 4.6.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get scroll location of all preview mode of all builder context
|
||||
* These are sorted by the time it was added to Divi (older to newer)
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function et_builder_get_builder_scroll_locations() {
|
||||
return array(
|
||||
// Frontend - what user sees.
|
||||
'fe' => array(
|
||||
'desktop' => 'app',
|
||||
'tablet' => 'app',
|
||||
'phone' => 'app',
|
||||
),
|
||||
|
||||
// Visual Builder - The most complex one
|
||||
// It used to use "faux responsive" while smaller breakpoints are simulated using more
|
||||
// specific CSS; but since true responsive which is derivation of BFB is introduced,
|
||||
// builder is rendered inside iframe on actual window width; To keep it seamless it needs
|
||||
// some trick and switching scroll location, hence these more complex scroll location.
|
||||
'vb' => array(
|
||||
'desktop' => 'app',
|
||||
'tablet' => 'top',
|
||||
'phone' => 'top',
|
||||
'zoom' => 'top',
|
||||
'wireframe' => 'app',
|
||||
),
|
||||
|
||||
// New Builder Experience - The Backend Frontend Builder (BFB)
|
||||
// Loads builder app inside iframe, but need to avoid the iframe having vertical scroll
|
||||
// for UX reason. User only need to scroll the main window's scroll hence the builder
|
||||
// app is rendered on its 100vh height and all scroll locations are located on top window.
|
||||
'bfb' => array(
|
||||
'desktop' => 'top',
|
||||
'tablet' => 'top',
|
||||
'phone' => 'top',
|
||||
'zoom' => 'top',
|
||||
'wireframe' => 'top',
|
||||
),
|
||||
|
||||
// Theme Builder
|
||||
// Builder is rendered on modal with 100vh on app window; all scroll is on top window.
|
||||
'tb' => array(
|
||||
'desktop' => 'top',
|
||||
'tablet' => 'top',
|
||||
'phone' => 'top',
|
||||
'zoom' => 'top',
|
||||
'wireframe' => 'top',
|
||||
),
|
||||
|
||||
// Layout Block's Builder
|
||||
// Reusing theme builder component, hence the shared characteristics.
|
||||
'lbb' => array(
|
||||
'desktop' => 'top',
|
||||
'tablet' => 'top',
|
||||
'phone' => 'top',
|
||||
'zoom' => 'top',
|
||||
'wireframe' => 'top',
|
||||
),
|
||||
|
||||
// Layout Block Preview
|
||||
// Preview Layout Block's frontend appearance inside Gutenberg block; similar to BFB but
|
||||
// what is being rendered is frontend component. Hence it displays 100vh preview height
|
||||
// for UX reason and all scroll happpens in top window.
|
||||
'lbp' => array(
|
||||
'desktop' => 'top',
|
||||
'tablet' => 'top',
|
||||
'phone' => 'top',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get window scroll location
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function et_builder_get_window_scroll_locations() {
|
||||
return array( 'app', 'top' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current builder type
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return string app|top
|
||||
*/
|
||||
function et_builder_get_current_builder_type() {
|
||||
$type = 'fe';
|
||||
|
||||
if ( ET_GB_Block_Layout::is_layout_block_preview() ) {
|
||||
$type = 'lbp';
|
||||
|
||||
// Layout Block builder reuses Theme Builder's modal component.
|
||||
if ( et_builder_tb_enabled() ) {
|
||||
$type = 'lbb';
|
||||
}
|
||||
} elseif ( et_builder_tb_enabled() ) {
|
||||
$type = 'tb';
|
||||
} elseif ( et_builder_bfb_enabled() ) {
|
||||
$type = 'bfb';
|
||||
} elseif ( et_core_is_fb_enabled() ) {
|
||||
$type = 'vb';
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scroll location on all breakpoints of current builder type
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function et_builder_get_onload_scroll_locations() {
|
||||
$builder_scroll_locations = et_builder_get_builder_scroll_locations();
|
||||
$builder_type = et_builder_get_current_builder_type();
|
||||
|
||||
return et_()->array_get( $builder_scroll_locations, $builder_type, array( 'desktop' => 'app' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get on page load scroll location of current builder type
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @return string app|top
|
||||
*/
|
||||
function et_builder_get_onload_scroll_location() {
|
||||
$builder_scroll_locations = et_builder_get_builder_scroll_locations();
|
||||
$builder_type = et_builder_get_current_builder_type();
|
||||
|
||||
// Default view mode doesn't change and consistent scroll location on all modes / breakpoint.
|
||||
if ( in_array( $builder_type, array( 'fe', 'lbp' ), true ) ) {
|
||||
return et_()->array_get( $builder_scroll_locations, "{$builder_type}.desktop" );
|
||||
}
|
||||
|
||||
// Default view mode might be changed via app preference modal.
|
||||
$app_preferences = et_fb_app_preferences_settings();
|
||||
$default_view_mode = et_()->array_get( $app_preferences, 'view_mode.default' );
|
||||
$view_mode = et_get_option( 'et_fb_pref_view_mode', $default_view_mode );
|
||||
|
||||
return et_()->array_get( $builder_scroll_locations, "{$builder_type}.{$view_mode}", 'app' );
|
||||
}
|
||||
1170
wp/plugins/divi-builder/includes/builder/framework.php
Normal file
@@ -0,0 +1,674 @@
|
||||
Bundle.js Development Credits And Associated Licenses
|
||||
=====================================================
|
||||
|
||||
bundle.js makes use of several pieces of open source software. When possible, each file
|
||||
that contains such open source software has been clearly identified in the source
|
||||
code comments and associate licenses and copyright info have been included. In
|
||||
addition, we have listed all open source software included and their associated
|
||||
licenses and copyright disclaimers in this file for easier access. Files listed below
|
||||
are categorized by submodule.
|
||||
|
||||
TinyMCE Visual/Text Module Adaptation
|
||||
-------------------------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
Sourced from WP-Calypso
|
||||
https://github.com/Automattic/wp-calypso
|
||||
|
||||
Adapted from WordPress
|
||||
|
||||
@copyright 2016 by the WordPress contributors.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
This program incorporates work covered by the following copyright and
|
||||
permission notices:
|
||||
|
||||
b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com - http://tidakada.com
|
||||
|
||||
b2 is released under the GPL
|
||||
|
||||
WordPress - Web publishing software
|
||||
|
||||
Copyright 2003-2010 by the contributors
|
||||
|
||||
WordPress is released under the GPL
|
||||
```
|
||||
|
||||
TinyMCE Media Upload Functions sendAttachment & addMedia
|
||||
--------------------------------------------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
Code From WordPress
|
||||
|
||||
@copyright 2016 by the WordPress contributors.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
This program incorporates work covered by the following copyright and
|
||||
permission notices:
|
||||
|
||||
b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com - http://tidakada.com
|
||||
|
||||
b2 is released under the GPL
|
||||
|
||||
WordPress - Web publishing software
|
||||
|
||||
Copyright 2003-2010 by the contributors
|
||||
|
||||
WordPress is released under the GPL
|
||||
```
|
||||
|
||||
CodeMirror
|
||||
--------------------------------------------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
|
||||
Classnames
|
||||
----------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Jed Watson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
Flux
|
||||
----
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
BSD License
|
||||
|
||||
For Flux software
|
||||
|
||||
Copyright (c) 2014-2015, Facebook, Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
Neither the name Facebook nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
```
|
||||
|
||||
HTML Entities
|
||||
-------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Dulin Marat
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
|
||||
Key Mirror
|
||||
----------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
Copyright 2013-2014 Facebook, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
Lodash
|
||||
-------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
||||
|
||||
Based on Underscore.js, copyright Jeremy Ashkenas,
|
||||
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
||||
|
||||
This software consists of voluntary contributions made by many
|
||||
individuals. For exact contribution history, see the revision history
|
||||
available at https://github.com/lodash/lodash
|
||||
|
||||
The following license applies to all parts of this software except as
|
||||
documented below:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Copyright and related rights for sample code are waived via CC0. Sample
|
||||
code is defined as all source code displayed within the prose of the
|
||||
documentation.
|
||||
|
||||
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
Files located in the node_modules and vendor directories are externally
|
||||
maintained libraries used by this software which have their own
|
||||
licenses; we recommend you read them, as their terms may differ from the
|
||||
terms above.
|
||||
```
|
||||
|
||||
Object Assign
|
||||
-------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
|
||||
React
|
||||
-----
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React Pure Render Mixin Addon
|
||||
-----------------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React DOM
|
||||
---------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React DND
|
||||
---------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Dan Abramov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React DND HTML5 Backend
|
||||
-----------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Dan Abramov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React Ink
|
||||
---------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Viget Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React Motion
|
||||
------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 React Motion authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React Resize Detector
|
||||
---------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) React Resize Detector authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
React Tooltip
|
||||
-------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Wang Zixiao
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
Underscore
|
||||
---------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative
|
||||
Reporters & Editors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
React TinyMCE
|
||||
-------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Ethan Vizitei
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
|
||||
WordPress Autosave
|
||||
------------------
|
||||
|
||||
includes/builder/frontend-builder/bundle.js
|
||||
|
||||
```text
|
||||
Adapted from WordPress
|
||||
|
||||
@copyright 2016 by the WordPress contributors.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
This program incorporates work covered by the following copyright and
|
||||
permission notices:
|
||||
|
||||
b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com - http://tidakada.com
|
||||
|
||||
b2 is released under the GPL
|
||||
|
||||
WordPress - Web publishing software
|
||||
|
||||
Copyright 2003-2010 by the contributors
|
||||
|
||||
WordPress is released under the GPL
|
||||
```
|
||||
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
add_action( 'wp_enqueue_scripts', 'et_builder_enqueue_assets_head' );
|
||||
add_action( 'wp_enqueue_scripts', 'et_builder_enqueue_assets_main' );
|
||||
|
||||
function et_fb_enqueue_google_maps_dependency( $dependencies ) {
|
||||
|
||||
if ( et_pb_enqueue_google_maps_script() ) {
|
||||
$dependencies[] = 'google-maps-api';
|
||||
}
|
||||
|
||||
return $dependencies;
|
||||
}
|
||||
add_filter( 'et_fb_bundle_dependencies', 'et_fb_enqueue_google_maps_dependency' );
|
||||
|
||||
function et_fb_load_portability() {
|
||||
et_core_register_admin_assets();
|
||||
et_core_load_component( 'portability' );
|
||||
|
||||
// Register the Builder individual layouts portability.
|
||||
et_core_portability_register(
|
||||
'et_builder',
|
||||
array(
|
||||
'name' => esc_html__( 'Divi Builder Layout', 'et_builder' ),
|
||||
'type' => 'post',
|
||||
'view' => true,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function et_fb_get_dynamic_asset( $prefix, $post_type = false, $update = false ) {
|
||||
|
||||
if ( false === $post_type ) {
|
||||
global $post;
|
||||
$post_type = isset( $post->post_type ) ? $post->post_type : 'post';
|
||||
}
|
||||
|
||||
$post_type = apply_filters( 'et_builder_cache_post_type', $post_type, $prefix );
|
||||
|
||||
$post_type = sanitize_file_name( $post_type );
|
||||
|
||||
if ( ! in_array( $prefix, array( 'helpers', 'definitions' ) ) ) {
|
||||
$prefix = '';
|
||||
}
|
||||
|
||||
// Per language Cache due to definitions/helpers being localized.
|
||||
$lang = sanitize_file_name( get_user_locale() );
|
||||
$cache = sprintf( '%s/%s', ET_Core_PageResource::get_cache_directory(), $lang );
|
||||
$files = glob( sprintf( '%s/%s-%s-*.js', $cache, $prefix, $post_type ) );
|
||||
$exists = is_array( $files ) && count( $files ) > 0;
|
||||
|
||||
if ( $exists ) {
|
||||
$file = $files[0];
|
||||
$uniq = array_reverse( explode( '-', basename( $file, '.js' ) ) );
|
||||
$uniq = $uniq[0];
|
||||
}
|
||||
|
||||
$updated = false;
|
||||
|
||||
if ( $update || ! $exists ) {
|
||||
// Make sure cache folder exists
|
||||
wp_mkdir_p( $cache );
|
||||
|
||||
// We (currently) use just 2 prefixes: 'helpers' and 'definitions'.
|
||||
// Each prefix has its content generated via a custom function called via the hook system:
|
||||
// add_filter( 'et_fb_get_asset_definitions', 'et_fb_get_asset_definitions', 10, 2 );
|
||||
// add_filter( 'et_fb_get_asset_helpers', 'et_fb_get_asset_helpers', 10, 2 );
|
||||
$content = apply_filters( "et_fb_get_asset_$prefix", false, $post_type );
|
||||
if ( $exists && $update ) {
|
||||
// Compare with old one (when a previous version exists)
|
||||
$update = et_()->WPFS()->get_contents( $file ) !== $content;
|
||||
}
|
||||
if ( ( $update || ! $exists ) ) {
|
||||
|
||||
if ( ET_BUILDER_KEEP_OLDEST_CACHED_ASSETS && count( $files ) > 0 ) {
|
||||
// Files are ordered by timestamp, first one is always the oldest
|
||||
array_shift( $files );
|
||||
}
|
||||
|
||||
if ( ET_BUILDER_PURGE_OLD_CACHED_ASSETS ) {
|
||||
foreach ( $files as $file ) {
|
||||
// Delete old version.
|
||||
@unlink( $file );
|
||||
}
|
||||
}
|
||||
|
||||
// Write the file only if it did not exist or its content changed
|
||||
$uniq = str_replace( '.', '', (string) microtime( true ) );
|
||||
$file = sprintf( '%s/%s-%s-%s.js', $cache, $prefix, $post_type, $uniq );
|
||||
|
||||
if ( wp_is_writable( dirname( $file ) ) && et_()->WPFS()->put_contents( $file, $content ) ) {
|
||||
$updated = true;
|
||||
$exists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$url = ! $exists ? false : sprintf(
|
||||
'%s/%s-%s-%s.js',
|
||||
et_()->path( et_core_cache_dir()->url, $lang ),
|
||||
$prefix,
|
||||
$post_type,
|
||||
$uniq
|
||||
);
|
||||
|
||||
return array(
|
||||
'url' => $url,
|
||||
'updated' => $updated,
|
||||
);
|
||||
}
|
||||
|
||||
function et_fb_backend_helpers_boot( $helpers ) {
|
||||
$helpers['boot'] = 'fast';
|
||||
return $helpers;
|
||||
}
|
||||
|
||||
function et_fb_app_only_bundle_deps( $deps = null ) {
|
||||
static $_deps = array();
|
||||
|
||||
// Set deps if argument is passed.
|
||||
if ( $deps ) {
|
||||
// Some bundle deps are still required in top window.
|
||||
$top = array(
|
||||
'jquery',
|
||||
'underscore',
|
||||
'jquery-ui-core',
|
||||
'jquery-ui-draggable',
|
||||
'jquery-ui-resizable',
|
||||
'jquery-ui-sortable',
|
||||
'jquery-effects-core',
|
||||
'iris',
|
||||
'wp-color-picker',
|
||||
'wp-color-picker-alpha',
|
||||
'et-profiler',
|
||||
'react-tiny-mce',
|
||||
'et_pb_admin_date_addon_js',
|
||||
'google-maps-api',
|
||||
'react',
|
||||
'react-dom',
|
||||
'wp-hooks',
|
||||
|
||||
// If minified JS is served, minified JS script name is outputted instead
|
||||
apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' ),
|
||||
);
|
||||
$_deps = array_diff( $deps, $top );
|
||||
}
|
||||
|
||||
return $_deps;
|
||||
}
|
||||
|
||||
function et_fb_enqueue_assets() {
|
||||
global $wp_version;
|
||||
|
||||
et_fb_load_portability();
|
||||
|
||||
$ver = ET_BUILDER_VERSION;
|
||||
$root = ET_BUILDER_URI;
|
||||
$app = ET_FB_URI;
|
||||
$assets = ET_FB_ASSETS_URI;
|
||||
|
||||
// Get WP major version
|
||||
$wp_major_version = substr( $wp_version, 0, 3 );
|
||||
|
||||
wp_register_script( 'react-tiny-mce', "{$assets}/vendors/tinymce.min.js" );
|
||||
|
||||
if ( version_compare( $wp_major_version, '4.5', '<' ) ) {
|
||||
$jQuery_ui = 'et_pb_admin_date_js';
|
||||
wp_register_script( $jQuery_ui, "{$root}/scripts/ext/jquery-ui-1.10.4.custom.min.js", array( 'jquery' ), $ver, true );
|
||||
} else {
|
||||
$jQuery_ui = 'jquery-ui-datepicker';
|
||||
}
|
||||
|
||||
wp_register_script( 'et_pb_admin_date_addon_js', "{$root}/scripts/ext/jquery-ui-timepicker-addon.js", array( $jQuery_ui ), $ver, true );
|
||||
|
||||
// `wp-shortcode` script handle is used by Gutenberg
|
||||
wp_register_script( 'et-wp-shortcode', includes_url() . 'js/shortcode.js', array(), $wp_version );
|
||||
|
||||
wp_register_script( 'jquery-tablesorter', ET_BUILDER_URI . '/scripts/ext/jquery.tablesorter.min.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
|
||||
|
||||
wp_register_script( 'chart', ET_BUILDER_URI . '/scripts/ext/chart.min.js', array(), ET_BUILDER_VERSION, true );
|
||||
|
||||
/** This filter is documented in includes/builder/framework.php */
|
||||
$builder_modules_script_handle = apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' );
|
||||
|
||||
$dependencies_list = array(
|
||||
'jquery',
|
||||
'jquery-ui-core',
|
||||
'jquery-ui-draggable',
|
||||
'jquery-ui-resizable',
|
||||
'underscore',
|
||||
'jquery-ui-sortable',
|
||||
'jquery-effects-core',
|
||||
'iris',
|
||||
'wp-color-picker',
|
||||
'wp-color-picker-alpha',
|
||||
'et_pb_admin_date_addon_js',
|
||||
'et-wp-shortcode',
|
||||
'heartbeat',
|
||||
'wp-mediaelement',
|
||||
'jquery-tablesorter',
|
||||
'chart',
|
||||
'react',
|
||||
'react-dom',
|
||||
'react-tiny-mce',
|
||||
$builder_modules_script_handle,
|
||||
);
|
||||
|
||||
if ( ! wp_script_is( 'wp-hooks', 'registered' ) ) {
|
||||
// Use bundled wp-hooks script when WP < 5.0
|
||||
wp_register_script( 'wp-hooks', "{$assets}/backports/hooks.js" );
|
||||
$dependencies_list[] = 'wp-hooks';
|
||||
}
|
||||
|
||||
// Add dependency on et-shortcode-js only if Divi Theme is used or ET Shortcodes plugin activated
|
||||
if ( ! et_is_builder_plugin_active() || et_is_shortcodes_plugin_active() ) {
|
||||
$dependencies_list[] = 'et-shortcodes-js';
|
||||
}
|
||||
|
||||
$cached_assets_deps = array();
|
||||
if ( defined( 'ET_BUILDER_CACHE_ASSETS' ) && ET_BUILDER_CACHE_ASSETS ) {
|
||||
// Use cached files for helpers and definitions
|
||||
foreach ( array( 'helpers', 'definitions' ) as $asset ) {
|
||||
if ( $url = et_()->array_get( et_fb_get_dynamic_asset( $asset ), 'url' ) ) {
|
||||
// The asset exists, we can add it to bundle's dependencies
|
||||
$key = "et-dynamic-asset-$asset";
|
||||
/**
|
||||
* Filters the dependencies of cached assets.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param array $deps.
|
||||
* @param string $key.
|
||||
*/
|
||||
$deps = apply_filters( 'et_builder_dynamic_asset_deps', array(), $key );
|
||||
$cached_assets_deps = array_merge( $cached_assets_deps, $deps );
|
||||
wp_register_script( $key, $url, $deps, ET_BUILDER_VERSION );
|
||||
$dependencies_list[] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fb_bundle_dependencies = apply_filters( 'et_fb_bundle_dependencies', $dependencies_list );
|
||||
|
||||
// Adding concatenated script as dependencies for script debugging
|
||||
if ( et_load_unminified_scripts() ) {
|
||||
array_push(
|
||||
$fb_bundle_dependencies,
|
||||
'easypiechart',
|
||||
'salvattore',
|
||||
'hashchange'
|
||||
);
|
||||
}
|
||||
|
||||
if ( et_pb_enqueue_google_maps_script() ) {
|
||||
wp_enqueue_script(
|
||||
'google-maps-api',
|
||||
esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'key' => et_pb_get_google_api_key(),
|
||||
'callback' => 'initMap',
|
||||
),
|
||||
is_ssl() ? 'https://maps.googleapis.com/maps/api/js' : 'http://maps.googleapis.com/maps/api/js'
|
||||
)
|
||||
),
|
||||
array(),
|
||||
'3',
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
// enqueue the Avada script before 'et-frontend-builder' to make sure easypiechart ( and probably some others ) override the scripts from Avada.
|
||||
if ( wp_script_is( 'avada' ) ) {
|
||||
// dequeue Avada script
|
||||
wp_dequeue_script( 'avada' );
|
||||
// enqueue it before 'et-frontend-builder'
|
||||
wp_enqueue_script( 'avada' );
|
||||
}
|
||||
|
||||
et_fb_enqueue_react();
|
||||
|
||||
// Detect if it's a production build by checking if `bundle.css` exists.
|
||||
$is_production = file_exists( sprintf( '%sfrontend-builder/build/bundle.css', ET_BUILDER_DIR ) );
|
||||
$external_assets = wp_script_is( 'et-dynamic-asset-helpers', 'registered' );
|
||||
|
||||
if ( $is_production && $external_assets && ! et_builder_bfb_enabled() && ! et_builder_tb_enabled() ) {
|
||||
// Set bundle deps.
|
||||
et_fb_app_only_bundle_deps( array_merge( $fb_bundle_dependencies, $cached_assets_deps ) );
|
||||
add_filter( 'script_loader_tag', 'et_fb_app_src', 10, 3 );
|
||||
// Enqueue the top window VB boot script.
|
||||
et_fb_enqueue_bundle( 'et-frontend-builder', 'boot.js', $fb_bundle_dependencies );
|
||||
// Add boot mode to helpers.
|
||||
add_filter( 'et_fb_backend_helpers', 'et_fb_backend_helpers_boot' );
|
||||
} else {
|
||||
// Enqueue the appropriate bundle js (hot/start/build)
|
||||
et_fb_enqueue_bundle( 'et-frontend-builder', 'bundle.js', $fb_bundle_dependencies );
|
||||
}
|
||||
|
||||
// Search for additional bundles
|
||||
$additional_bundles = array();
|
||||
// CSS is now splitted as well.
|
||||
foreach ( array_merge(
|
||||
glob( ET_BUILDER_DIR . 'frontend-builder/build/bundle.*.css' ),
|
||||
glob( ET_BUILDER_DIR . 'frontend-builder/build/bundle.*.js' )
|
||||
) as $chunk ) {
|
||||
$additional_bundles[] = "{$app}/build/" . basename( $chunk );
|
||||
}
|
||||
// Pass bundle path and additional bundles to preload
|
||||
wp_localize_script(
|
||||
'et-frontend-builder',
|
||||
'et_webpack_bundle',
|
||||
array(
|
||||
'path' => "{$app}/build/",
|
||||
'preload' => $additional_bundles,
|
||||
)
|
||||
);
|
||||
|
||||
// Enqueue failure notice script.
|
||||
wp_enqueue_script( 'et-frontend-builder-failure', "{$assets}/scripts/failure_notice.js", array(), ET_BUILDER_PRODUCT_VERSION, true );
|
||||
wp_localize_script(
|
||||
'et-frontend-builder-failure',
|
||||
'et_fb_options',
|
||||
array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
||||
'et_admin_load_nonce' => wp_create_nonce( 'et_admin_load_nonce' ),
|
||||
'memory_limit_increased' => esc_html__( 'Your memory limit has been increased', 'et_builder' ),
|
||||
'memory_limit_not_increased' => esc_html__( "Your memory limit can't be changed automatically", 'et_builder' ),
|
||||
)
|
||||
);
|
||||
|
||||
// WP Auth Check (allows user to log in again when session expires).
|
||||
wp_enqueue_style( 'wp-auth-check' );
|
||||
wp_enqueue_script( 'wp-auth-check' );
|
||||
add_action( 'wp_print_footer_scripts', 'et_fb_output_wp_auth_check_html', 5 );
|
||||
|
||||
do_action( 'et_fb_enqueue_assets' );
|
||||
}
|
||||
|
||||
function et_fb_app_src( $tag, $handle, $src ) {
|
||||
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
|
||||
// Replace boot with bundle in app window.
|
||||
if ( 'et-frontend-builder' === $handle ) {
|
||||
$bundle_url = esc_url( str_replace( 'boot.js', 'bundle.js', $src ) );
|
||||
return str_replace( 'src=', sprintf( 'data-et-vb-app-src="%1$s" src=', $bundle_url ), $tag );
|
||||
}
|
||||
|
||||
// Only load (most) bundle deps in app window.
|
||||
if ( in_array( $handle, et_fb_app_only_bundle_deps(), true ) ) {
|
||||
return sprintf( '<script data-et-vb-app-src="%1$s"></script>', esc_url( $src ) );
|
||||
}
|
||||
return $tag;
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable admin bar styling for HTML in VB. BFB doesn't loaded admin bar and VB loads admin bar
|
||||
* on top window which makes built-in admin bar styling irrelevant because admin bar is affected by
|
||||
* top window width instead of app window width (while app window width changes based on preview mode)
|
||||
*
|
||||
* @see _admin_bar_bump_cb()
|
||||
*/
|
||||
function et_fb_disable_admin_bar_style() {
|
||||
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
|
||||
}
|
||||
add_action( 'wp', 'et_fb_disable_admin_bar_style', 15 );
|
||||
|
||||
|
||||
function et_fb_output_wp_auth_check_html() {
|
||||
// A <button> element is used for the close button which looks ugly in Chrome. Use <a> element instead.
|
||||
ob_start();
|
||||
wp_auth_check_html();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$output = str_replace(
|
||||
array( '<button type="button"', '</button>' ),
|
||||
array( '<a href="#"', '</a>' ),
|
||||
$output
|
||||
);
|
||||
|
||||
echo et_core_intentionally_unescaped( $output, 'html' );
|
||||
}
|
||||
|
||||
|
||||
function et_fb_set_editor_available_cookie() {
|
||||
global $post;
|
||||
$post_id = isset( $post->ID ) ? $post->ID : false;
|
||||
if ( ! headers_sent() && ! empty( $post_id ) ) {
|
||||
setcookie( 'et-editor-available-post-' . $post_id . '-fb', 'fb', time() + ( MINUTE_IN_SECONDS * 30 ), SITECOOKIEPATH, false, is_ssl() );
|
||||
}
|
||||
}
|
||||
add_action( 'et_fb_framework_loaded', 'et_fb_set_editor_available_cookie' );
|
||||
@@ -0,0 +1,623 @@
|
||||
this["wp"] = this["wp"] || {}; this["wp"]["hooks"] =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = 366);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ 366:
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
||||
/**
|
||||
* Validate a namespace string.
|
||||
*
|
||||
* @param {string} namespace The namespace to validate - should take the form
|
||||
* `vendor/plugin/function`.
|
||||
*
|
||||
* @return {boolean} Whether the namespace is valid.
|
||||
*/
|
||||
function validateNamespace(namespace) {
|
||||
if ('string' !== typeof namespace || '' === namespace) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_validateNamespace = (validateNamespace);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/validateHookName.js
|
||||
/**
|
||||
* Validate a hookName string.
|
||||
*
|
||||
* @param {string} hookName The hook name to validate. Should be a non empty string containing
|
||||
* only numbers, letters, dashes, periods and underscores. Also,
|
||||
* the hook name cannot begin with `__`.
|
||||
*
|
||||
* @return {boolean} Whether the hook name is valid.
|
||||
*/
|
||||
function validateHookName(hookName) {
|
||||
if ('string' !== typeof hookName || '' === hookName) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (/^__/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name cannot begin with `__`.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_validateHookName = (validateHookName);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createAddHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will add a hook.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that adds a new hook.
|
||||
*/
|
||||
|
||||
function createAddHook(hooks) {
|
||||
/**
|
||||
* Adds the hook to the appropriate hooks container.
|
||||
*
|
||||
* @param {string} hookName Name of hook to add
|
||||
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
||||
* @param {Function} callback Function to call when the hook is run
|
||||
* @param {?number} priority Priority of this hook (default=10)
|
||||
*/
|
||||
return function addHook(hookName, namespace, callback) {
|
||||
var priority = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
|
||||
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ('function' !== typeof callback) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook callback must be a function.');
|
||||
return;
|
||||
} // Validate numeric priority
|
||||
|
||||
|
||||
if ('number' !== typeof priority) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('If specified, the hook priority must be a number.');
|
||||
return;
|
||||
}
|
||||
|
||||
var handler = {
|
||||
callback: callback,
|
||||
priority: priority,
|
||||
namespace: namespace
|
||||
};
|
||||
|
||||
if (hooks[hookName]) {
|
||||
// Find the correct insert index of the new hook.
|
||||
var handlers = hooks[hookName].handlers;
|
||||
var i;
|
||||
|
||||
for (i = handlers.length; i > 0; i--) {
|
||||
if (priority >= handlers[i - 1].priority) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i === handlers.length) {
|
||||
// If append, operate via direct assignment.
|
||||
handlers[i] = handler;
|
||||
} else {
|
||||
// Otherwise, insert before index via splice.
|
||||
handlers.splice(i, 0, handler);
|
||||
} // We may also be currently executing this hook. If the callback
|
||||
// we're adding would come after the current callback, there's no
|
||||
// problem; otherwise we need to increase the execution index of
|
||||
// any other runs by 1 to account for the added element.
|
||||
|
||||
|
||||
(hooks.__current || []).forEach(function (hookInfo) {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// This is the first hook of its type.
|
||||
hooks[hookName] = {
|
||||
handlers: [handler],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
|
||||
if (hookName !== 'hookAdded') {
|
||||
doAction('hookAdded', hookName, namespace, callback, priority);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createAddHook = (createAddHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will remove a specified hook or all
|
||||
* hooks by the given name.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
* @param {boolean} removeAll Whether to remove all callbacks for a hookName, without regard to namespace. Used to create `removeAll*` functions.
|
||||
*
|
||||
* @return {Function} Function that removes hooks.
|
||||
*/
|
||||
|
||||
function createRemoveHook(hooks, removeAll) {
|
||||
/**
|
||||
* Removes the specified callback (or all callbacks) from the hook with a
|
||||
* given hookName and namespace.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to modify.
|
||||
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
||||
*
|
||||
* @return {number} The number of callbacks removed.
|
||||
*/
|
||||
return function removeHook(hookName, namespace) {
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!removeAll && !build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
} // Bail if no hooks exist by this name
|
||||
|
||||
|
||||
if (!hooks[hookName]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var handlersRemoved = 0;
|
||||
|
||||
if (removeAll) {
|
||||
handlersRemoved = hooks[hookName].handlers.length;
|
||||
hooks[hookName] = {
|
||||
runs: hooks[hookName].runs,
|
||||
handlers: []
|
||||
};
|
||||
} else {
|
||||
// Try to find the specified callback to remove.
|
||||
var handlers = hooks[hookName].handlers;
|
||||
|
||||
var _loop = function _loop(i) {
|
||||
if (handlers[i].namespace === namespace) {
|
||||
handlers.splice(i, 1);
|
||||
handlersRemoved++; // This callback may also be part of a hook that is
|
||||
// currently executing. If the callback we're removing
|
||||
// comes after the current callback, there's no problem;
|
||||
// otherwise we need to decrease the execution index of any
|
||||
// other runs by 1 to account for the removed element.
|
||||
|
||||
(hooks.__current || []).forEach(function (hookInfo) {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex--;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = handlers.length - 1; i >= 0; i--) {
|
||||
_loop(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (hookName !== 'hookRemoved') {
|
||||
doAction('hookRemoved', hookName, namespace);
|
||||
}
|
||||
|
||||
return handlersRemoved;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createRemoveHook = (createRemoveHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHasHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether any handlers are
|
||||
* attached to a particular hook.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns whether any handlers are
|
||||
* attached to a particular hook.
|
||||
*/
|
||||
function createHasHook(hooks) {
|
||||
/**
|
||||
* Returns how many handlers are attached for the given hook.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to check for.
|
||||
*
|
||||
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
||||
*/
|
||||
return function hasHook(hookName) {
|
||||
return hookName in hooks;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createHasHook = (createHasHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createRunHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will execute all callbacks
|
||||
* registered to a hook of the specified type, optionally returning the final
|
||||
* value of the call chain.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
* @param {?boolean} returnFirstArg Whether each hook callback is expected to
|
||||
* return its first argument.
|
||||
*
|
||||
* @return {Function} Function that runs hook callbacks.
|
||||
*/
|
||||
function createRunHook(hooks, returnFirstArg) {
|
||||
/**
|
||||
* Runs all callbacks for the specified hook.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to run.
|
||||
* @param {...*} args Arguments to pass to the hook callbacks.
|
||||
*
|
||||
* @return {*} Return value of runner, if applicable.
|
||||
*/
|
||||
return function runHooks(hookName) {
|
||||
if (!hooks[hookName]) {
|
||||
hooks[hookName] = {
|
||||
handlers: [],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
|
||||
hooks[hookName].runs++;
|
||||
var handlers = hooks[hookName].handlers;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (!handlers || !handlers.length) {
|
||||
return returnFirstArg ? args[0] : undefined;
|
||||
}
|
||||
|
||||
var hookInfo = {
|
||||
name: hookName,
|
||||
currentIndex: 0
|
||||
};
|
||||
|
||||
hooks.__current.push(hookInfo);
|
||||
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
var handler = handlers[hookInfo.currentIndex];
|
||||
var result = handler.callback.apply(null, args);
|
||||
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
|
||||
hooks.__current.pop();
|
||||
|
||||
if (returnFirstArg) {
|
||||
return args[0];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createRunHook = (createRunHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the name of the
|
||||
* currently running hook, or `null` if no hook of the given type is currently
|
||||
* running.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns the current hook.
|
||||
*/
|
||||
function createCurrentHook(hooks) {
|
||||
/**
|
||||
* Returns the name of the currently running hook, or `null` if no hook of
|
||||
* the given type is currently running.
|
||||
*
|
||||
* @return {?string} The name of the currently running hook, or
|
||||
* `null` if no hook is currently running.
|
||||
*/
|
||||
return function currentHook() {
|
||||
if (!hooks.__current || !hooks.__current.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return hooks.__current[hooks.__current.length - 1].name;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createCurrentHook = (createCurrentHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether a hook is
|
||||
* currently being executed.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns whether a hook is currently
|
||||
* being executed.
|
||||
*/
|
||||
function createDoingHook(hooks) {
|
||||
/**
|
||||
* Returns whether a hook is currently being executed.
|
||||
*
|
||||
* @param {?string} hookName The name of the hook to check for. If
|
||||
* omitted, will check for any hook being executed.
|
||||
*
|
||||
* @return {boolean} Whether the hook is being executed.
|
||||
*/
|
||||
return function doingHook(hookName) {
|
||||
// If the hookName was not passed, check for any current hook.
|
||||
if ('undefined' === typeof hookName) {
|
||||
return 'undefined' !== typeof hooks.__current[0];
|
||||
} // Return the __current hook.
|
||||
|
||||
|
||||
return hooks.__current[0] ? hookName === hooks.__current[0].name : false;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createDoingHook = (createDoingHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createDidHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the number of times a
|
||||
* hook has been called.
|
||||
*
|
||||
* @param {Object} hooks Stored hooks, keyed by hook name.
|
||||
*
|
||||
* @return {Function} Function that returns a hook's call count.
|
||||
*/
|
||||
|
||||
function createDidHook(hooks) {
|
||||
/**
|
||||
* Returns the number of times an action has been fired.
|
||||
*
|
||||
* @param {string} hookName The hook name to check.
|
||||
*
|
||||
* @return {number} The number of times the hook has run.
|
||||
*/
|
||||
return function didHook(hookName) {
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return hooks[hookName] && hooks[hookName].runs ? hooks[hookName].runs : 0;
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createDidHook = (createDidHook);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/createHooks.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns an instance of the hooks object.
|
||||
*
|
||||
* @return {Object} Object that contains all hooks.
|
||||
*/
|
||||
|
||||
function createHooks() {
|
||||
var actions = Object.create(null);
|
||||
var filters = Object.create(null);
|
||||
actions.__current = [];
|
||||
filters.__current = [];
|
||||
return {
|
||||
addAction: build_module_createAddHook(actions),
|
||||
addFilter: build_module_createAddHook(filters),
|
||||
removeAction: build_module_createRemoveHook(actions),
|
||||
removeFilter: build_module_createRemoveHook(filters),
|
||||
hasAction: build_module_createHasHook(actions),
|
||||
hasFilter: build_module_createHasHook(filters),
|
||||
removeAllActions: build_module_createRemoveHook(actions, true),
|
||||
removeAllFilters: build_module_createRemoveHook(filters, true),
|
||||
doAction: build_module_createRunHook(actions),
|
||||
applyFilters: build_module_createRunHook(filters, true),
|
||||
currentAction: build_module_createCurrentHook(actions),
|
||||
currentFilter: build_module_createCurrentHook(filters),
|
||||
doingAction: build_module_createDoingHook(actions),
|
||||
doingFilter: build_module_createDoingHook(filters),
|
||||
didAction: build_module_createDidHook(actions),
|
||||
didFilter: build_module_createDidHook(filters),
|
||||
actions: actions,
|
||||
filters: filters
|
||||
};
|
||||
}
|
||||
|
||||
/* harmony default export */ var build_module_createHooks = (createHooks);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@wordpress/hooks/build-module/index.js
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addAction", function() { return addAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addFilter", function() { return addFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAction", function() { return removeAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeFilter", function() { return removeFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAction", function() { return hasAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasFilter", function() { return hasFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAllActions", function() { return removeAllActions; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAllFilters", function() { return removeAllFilters; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doAction", function() { return doAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyFilters", function() { return applyFilters; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentAction", function() { return currentAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currentFilter", function() { return currentFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doingAction", function() { return doingAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "doingFilter", function() { return doingFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "didAction", function() { return didAction; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "didFilter", function() { return didFilter; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "actions", function() { return build_module_actions; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filters", function() { return build_module_filters; });
|
||||
/* concated harmony reexport createHooks */__webpack_require__.d(__webpack_exports__, "createHooks", function() { return build_module_createHooks; });
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
var _createHooks = build_module_createHooks(),
|
||||
addAction = _createHooks.addAction,
|
||||
addFilter = _createHooks.addFilter,
|
||||
removeAction = _createHooks.removeAction,
|
||||
removeFilter = _createHooks.removeFilter,
|
||||
hasAction = _createHooks.hasAction,
|
||||
hasFilter = _createHooks.hasFilter,
|
||||
removeAllActions = _createHooks.removeAllActions,
|
||||
removeAllFilters = _createHooks.removeAllFilters,
|
||||
doAction = _createHooks.doAction,
|
||||
applyFilters = _createHooks.applyFilters,
|
||||
currentAction = _createHooks.currentAction,
|
||||
currentFilter = _createHooks.currentFilter,
|
||||
doingAction = _createHooks.doingAction,
|
||||
doingFilter = _createHooks.doingFilter,
|
||||
didAction = _createHooks.didAction,
|
||||
didFilter = _createHooks.didFilter,
|
||||
build_module_actions = _createHooks.actions,
|
||||
build_module_filters = _createHooks.filters;
|
||||
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! This minified app bundle contains open source software from several third party developers. Please review CREDITS.md in the root directory or LICENSE.md in the current directory for complete licensing, copyright and patent information. This file and the included code may not be redistributed without the attributions listed in LICENSE.md, including associate copyright notices and licensing information. */
|
||||
/*! This minified app bundle contains open source software from several third party developers. Please review CREDITS.md in the root directory or LICENSE.md in the current directory for complete licensing, copyright and patent information. This file and the included code may not be redistributed without the attributions listed in LICENSE.md, including associate copyright notices and licensing information. */
|
||||
.et_pb_modal_overlay.et_modal_on_top.et_pb_failure_notification_modal.et_pb_new_template_modal{z-index:99999;position:relative}.et_pb_modal_overlay a.et_pb_reload_builder{transition:background .5s;background-color:#008bdb;cursor:pointer;border-radius:0;-webkit-border-radius:0;padding:0;margin:0;font-size:18px;font-weight:600;width:100%;display:inline-block;float:left;height:68px;line-height:68px;text-align:center;color:#fff;text-decoration:none;border:none}body .et_pb_new_template_modal.et_modal_on_top .et_pb_prompt_dont_proceed{padding:21px!important}.et_builder_modal_action_button,.et_pb_modal_overlay a.et_pb_reload_builder{font-weight:700}.et_pb_new_template_modal .et_pb_prompt_modal h2{font-weight:400!important}.et_pb_new_template_modal .et-pb-modal-close:before{font-weight:600}
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! This minified app bundle contains open source software from several third party developers. Please review CREDITS.md in the root directory or LICENSE.md in the current directory for complete licensing, copyright and patent information. This file and the included code may not be redistributed without the attributions listed in LICENSE.md, including associate copyright notices and licensing information. */
|
||||
/*! This minified app bundle contains open source software from several third party developers. Please review CREDITS.md in the root directory or LICENSE.md in the current directory for complete licensing, copyright and patent information. This file and the included code may not be redistributed without the attributions listed in LICENSE.md, including associate copyright notices and licensing information. */
|
||||
#et-boc,#et-fb-app-frame,.et-l{width:100%;height:100%;position:absolute;top:0;right:0;left:0}#et-fb-app-frame{z-index:2}#et-boc{transform:translateZ(-1px)}#main-footer,#main-header,#top-header,.et-l--footer,.et-l--header{display:none}#et-boc .et-fb-iframe-ancestor,.et-fb-iframe-ancestor,.et_vertical_nav #et-main-area.et-fb-iframe-ancestor{width:100vw!important;max-width:100vw!important;height:100vh!important;margin:0!important;padding:0!important;display:block!important;border:none!important;box-shadow:none!important;transform:none!important;filter:none!important}.et-fb-root-ancestor #et-boc,.et-fb-root-ancestor #et-boc .et-l{background:#f1f5f9}.et-fb-preview--phone #et-boc,.et-fb-preview--phone #et-boc .et-l,.et-fb-preview--tablet #et-boc,.et-fb-preview--tablet #et-boc .et-l{position:absolute;width:100%;height:100%}.et-fb-preview--phone body,.et-fb-preview--phone body.custom-background,.et-fb-preview--tablet body,.et-fb-preview--tablet body.custom-background,.et-fb-preview--zoom body,.et-fb-preview--zoom body.custom-background{background:#f1f5f9}.et-fb-preview--wireframe .et_pb_3rd_party_theme #et-boc,.et-fb-preview--wireframe .et_pb_3rd_party_theme #et-boc .et-l,.et-fb-preview--wireframe .et_pb_3rd_party_theme #wpadminbar,.et-fb-preview--wireframe .et_pb_3rd_party_theme .media-modal-backdrop{z-index:9999999}.et-fb-preview--wireframe .et_pb_3rd_party_theme .media-modal{z-index:99999991}.et_pb_3rd_party_theme .media-modal button,.et_pb_3rd_party_theme .media-modal input[type=button],.et_pb_3rd_party_theme .media-modal input[type=submit]{font-weight:400}.et_pb_3rd_party_theme .media-modal button.media-modal-close:hover{background:none}
|
||||
|
After Width: | Height: | Size: 166 B |
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<svg id="bigplay" viewBox="0 0 100 200" style="background-color:#ffffff00" version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"
|
||||
x="0px" y="0px" width="100px" height="200px"
|
||||
>
|
||||
<g id="dark">
|
||||
<path id="Polygon" d="M 72.5 49.5 L 38.75 68.9856 L 38.75 30.0144 L 72.5 49.5 Z" fill="#ffffff" opacity="0.75" />
|
||||
<path id="Ellipse" d="M 13 50.5 C 13 29.7891 29.7891 13 50.5 13 C 71.2109 13 88 29.7891 88 50.5 C 88 71.2109 71.2109 88 50.5 88 C 29.7891 88 13 71.2109 13 50.5 Z" stroke="#ffffff" stroke-width="5" fill="none" opacity="0.75"/>
|
||||
</g>
|
||||
<g id="light">
|
||||
<path id="Polygon2" d="M 72.5 149.5 L 38.75 168.9856 L 38.75 130.0144 L 72.5 149.5 Z" fill="#ffffff" opacity="1.0" />
|
||||
<path id="Ellipse2" d="M 13 150.5 C 13 129.7891 29.7891 113 50.5 113 C 71.2109 113 88 129.7891 88 150.5 C 88 171.211 71.2109 188 50.5 188 C 29.7891 188 13 171.211 13 150.5 Z" stroke="#ffffff" stroke-width="5" fill="none" opacity="1.0"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 7.0 KiB |
@@ -0,0 +1,2 @@
|
||||
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";(function(e){function t(){return e("#wp-admin-bar-et-disable-visual-builder a").attr("href")}e("body").on("click",".et_builder_increase_memory",(function(){var t=e(this);return e.ajax({type:"POST",dataType:"json",url:et_fb_options.ajaxurl,data:{action:"et_pb_increase_memory_limit",et_admin_load_nonce:et_fb_options.et_admin_load_nonce},success:function(e){_.isUndefined(e.success)?t.addClass("et_builder_modal_action_button_fail").prop("disabled",!0).text(et_fb_options.memory_limit_not_increased):t.addClass("et_builder_modal_action_button_success").text(et_fb_options.memory_limit_increased)}}),!1})),e("body").on("click",".et-builder-timeout .et-core-modal-action",(function(){return location.reload(),!1})),e("body").on("click",".et-builder-timeout .et-core-modal-close, .et-builder-timeout",(function(){return location.assign(t()),!1})),e("body").on("click",".et-theme-builder-no-post-content .et-core-modal-close, .et-theme-builder-no-post-content",(function(n){e(n.target).is(".et-core-modal-action")||(n.preventDefault(),location.assign(t()))}))}).call(this,n(1))},function(e,t){e.exports=jQuery}]);
|
||||
//# sourceMappingURL=failure_notice.js.map
|
||||
14
wp/plugins/divi-builder/includes/builder/frontend-builder/assets/vendors/LICENSE.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
TinyMCE
|
||||
-------
|
||||
|
||||
includes/builder/frontend-builder/assets/vendors/tinymce.min.js
|
||||
includes/builder/frontend-builder/assets/vendors/tinymce-skin/
|
||||
|
||||
```text
|
||||
Copyright (c) 2016 Ephox
|
||||
|
||||
Licensed under the GPLv2.1.
|
||||
|
||||
See /LICENSE.md for the full GPLv2 license.
|
||||
```
|
||||
|
||||
3
wp/plugins/divi-builder/includes/builder/frontend-builder/assets/vendors/langs/readme.md
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
This is where language files should be placed.
|
||||
|
||||
Please DO NOT translate these directly use this service: https://www.transifex.com/projects/p/tinymce/
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.util.Tools"),s=function(t,e,n){var r="UL"===e?"InsertUnorderedList":"InsertOrderedList";t.execCommand(r,!1,!1===n?null:{"list-style-type":n})},o=function(n){n.addCommand("ApplyUnorderedListStyle",function(t,e){s(n,"UL",e["list-style-type"])}),n.addCommand("ApplyOrderedListStyle",function(t,e){s(n,"OL",e["list-style-type"])})},e=function(t){var e=t.getParam("advlist_number_styles","default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman");return e?e.split(/[ ,]/):[]},n=function(t){var e=t.getParam("advlist_bullet_styles","default,circle,disc,square");return e?e.split(/[ ,]/):[]},u=function(t){return t&&/^(TH|TD)$/.test(t.nodeName)},c=function(r){return function(t){return t&&/^(OL|UL|DL)$/.test(t.nodeName)&&(n=t,(e=r).$.contains(e.getBody(),n));var e,n}},d=function(t){var e=t.dom.getParent(t.selection.getNode(),"ol,ul");return t.dom.getStyle(e,"listStyleType")||""},p=function(t){return a.map(t,function(t){return{text:t.replace(/\-/g," ").replace(/\b\w/g,function(t){return t.toUpperCase()}),data:"default"===t?"":t}})},f=function(i,l){return function(t){var o=t.control;i.on("NodeChange",function(t){var e=function(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return n;return-1}(t.parents,u),n=-1!==e?t.parents.slice(0,e):t.parents,r=a.grep(n,c(i));o.active(0<r.length&&r[0].nodeName===l)})}},m=function(e,t,n,r,o,i){var l;e.addButton(t,{active:!1,type:"splitbutton",tooltip:n,menu:p(i),onPostRender:f(e,o),onshow:(l=e,function(t){var e=d(l);t.control.items().each(function(t){t.active(t.settings.data===e)})}),onselect:function(t){s(e,o,t.control.settings.data)},onclick:function(){e.execCommand(r)}})},r=function(t,e,n,r,o,i){var l,a,s,u,c;0<i.length?m(t,e,n,r,o,i):(a=e,s=n,u=r,c=o,(l=t).addButton(a,{active:!1,type:"button",tooltip:s,onPostRender:f(l,c),onclick:function(){l.execCommand(u)}}))},i=function(t){r(t,"numlist","Numbered list","InsertOrderedList","OL",e(t)),r(t,"bullist","Bullet list","InsertUnorderedList","UL",n(t))};t.add("advlist",function(t){var e,n,r;n="lists",r=(e=t).settings.plugins?e.settings.plugins:"",-1!==a.inArray(r.split(/[ ,]/),n)&&(i(t),o(t))})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(t){return/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)},e=function(t){var e=t.selection.getNode();return"A"===e.tagName&&""===t.dom.getAttrib(e,"href")?e.id||e.name:""},i=function(t,e){var n=t.selection.getNode();"A"===n.tagName&&""===t.dom.getAttrib(n,"href")?(n.removeAttribute("name"),n.id=e,t.undoManager.add()):(t.focus(),t.selection.collapse(!0),t.execCommand("mceInsertContent",!1,t.dom.createHTML("a",{id:e})))},n=function(r){var t=e(r);r.windowManager.open({title:"Anchor",body:{type:"textbox",name:"id",size:40,label:"Id",value:t},onsubmit:function(t){var e,n,o=t.data.id;e=r,(a(n=o)?(i(e,n),0):(e.windowManager.alert("Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),1))&&t.preventDefault()}})},o=function(t){t.addCommand("mceAnchor",function(){n(t)})},r=function(o){return function(t){for(var e=0;e<t.length;e++)(n=t[e]).attr("href")||!n.attr("id")&&!n.attr("name")||n.firstChild||t[e].attr("contenteditable",o);var n}},c=function(t){t.on("PreInit",function(){t.parser.addNodeFilter("a",r("false")),t.serializer.addNodeFilter("a",r(null))})},d=function(t){t.addButton("anchor",{icon:"anchor",tooltip:"Anchor",cmd:"mceAnchor",stateSelector:"a:not([href])"}),t.addMenuItem("anchor",{icon:"anchor",text:"Anchor",context:"insert",cmd:"mceAnchor"})};t.add("anchor",function(t){c(t),o(t),d(t)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=tinymce.util.Tools.resolve("tinymce.Env"),m=function(e){return e.getParam("autolink_pattern",/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+\-]+@)(.+)$/i)},y=function(e){return e.getParam("default_link_target","")},o=function(e,t){if(t<0&&(t=0),3===e.nodeType){var n=e.data.length;n<t&&(t=n)}return t},k=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setStart(t,o(t,n)):e.setStartBefore(t)},p=function(e,t,n){1!==t.nodeType||t.hasChildNodes()?e.setEnd(t,o(t,n)):e.setEndAfter(t)},r=function(e,t,n){var i,o,r,a,f,s,d,l,c,u,g=m(e),h=y(e);if("A"!==e.selection.getNode().tagName){if((i=e.selection.getRng(!0).cloneRange()).startOffset<5){if(!(l=i.endContainer.previousSibling)){if(!i.endContainer.firstChild||!i.endContainer.firstChild.nextSibling)return;l=i.endContainer.firstChild.nextSibling}if(c=l.length,k(i,l,c),p(i,l,c),i.endOffset<5)return;o=i.endOffset,a=l}else{if(3!==(a=i.endContainer).nodeType&&a.firstChild){for(;3!==a.nodeType&&a.firstChild;)a=a.firstChild;3===a.nodeType&&(k(i,a,0),p(i,a,a.nodeValue.length))}o=1===i.endOffset?2:i.endOffset-1-t}for(r=o;k(i,a,2<=o?o-2:0),p(i,a,1<=o?o-1:0),o-=1," "!==(u=i.toString())&&""!==u&&160!==u.charCodeAt(0)&&0<=o-2&&u!==n;);var C;(C=i.toString())===n||" "===C||160===C.charCodeAt(0)?(k(i,a,o),p(i,a,r),o+=1):(0===i.startOffset?k(i,a,0):k(i,a,o),p(i,a,r)),"."===(s=i.toString()).charAt(s.length-1)&&p(i,a,r-1),(d=(s=i.toString().trim()).match(g))&&("www."===d[1]?d[1]="http://www.":/@$/.test(d[1])&&!/^mailto:/.test(d[1])&&(d[1]="mailto:"+d[1]),f=e.selection.getBookmark(),e.selection.setRng(i),e.execCommand("createlink",!1,d[1]+d[2]),h&&e.dom.setAttrib(e.selection.getNode(),"target",h),e.selection.moveToBookmark(f),e.nodeChanged())}},t=function(t){var n;t.on("keydown",function(e){13!==e.keyCode||r(t,-1,"")}),i.ie?t.on("focus",function(){if(!n){n=!0;try{t.execCommand("AutoUrlDetect",!1,!0)}catch(e){}}}):(t.on("keypress",function(e){41!==e.keyCode||r(t,-1,"(")}),t.on("keyup",function(e){32!==e.keyCode||r(t,0,"")}))};e.add("autolink",function(e){t(e)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var i=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return i(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),y=tinymce.util.Tools.resolve("tinymce.Env"),r=tinymce.util.Tools.resolve("tinymce.util.Delay"),h=function(t){return parseInt(t.getParam("autoresize_min_height",t.getElement().offsetHeight),10)},v=function(t){return parseInt(t.getParam("autoresize_max_height",0),10)},o=function(t){return t.getParam("autoresize_overflow_padding",1)},a=function(t){return t.getParam("autoresize_bottom_margin",50)},n=function(t){return t.getParam("autoresize_on_init",!0)},u=function(t,e,n,i,o){r.setEditorTimeout(t,function(){_(t,e),n--?u(t,e,n,i,o):o&&o()},i)},S=function(t,e){var n=t.getBody();n&&(n.style.overflowY=e?"":"hidden",e||(n.scrollTop=0))},_=function(t,e){var n,i,o,r,a,u,s,l,g,c,f,d=t.dom;if(i=t.getDoc())if((m=t).plugins.fullscreen&&m.plugins.fullscreen.isFullscreen())S(t,!0);else{var m;o=i.body,r=h(t),u=d.getStyle(o,"margin-top",!0),s=d.getStyle(o,"margin-bottom",!0),l=d.getStyle(o,"padding-top",!0),g=d.getStyle(o,"padding-bottom",!0),c=d.getStyle(o,"border-top-width",!0),f=d.getStyle(o,"border-bottom-width",!0),a=o.offsetHeight+parseInt(u,10)+parseInt(s,10)+parseInt(l,10)+parseInt(g,10)+parseInt(c,10)+parseInt(f,10),(isNaN(a)||a<=0)&&(a=y.ie?o.scrollHeight:y.webkit&&0===o.clientHeight?0:o.offsetHeight),a>h(t)&&(r=a);var p=v(t);p&&p<a?(r=p,S(t,!0)):S(t,!1),r!==e.get()&&(n=r-e.get(),d.setStyle(t.iframeElement,"height",r+"px"),e.set(r),y.webkit&&n<0&&_(t,e))}},s={setup:function(i,e){i.on("init",function(){var t,e,n=i.dom;t=o(i),e=a(i),!1!==t&&n.setStyles(i.getBody(),{paddingLeft:t,paddingRight:t}),!1!==e&&n.setStyles(i.getBody(),{paddingBottom:e})}),i.on("nodechange setcontent keyup FullscreenStateChanged",function(t){_(i,e)}),n(i)&&i.on("init",function(){u(i,e,20,100,function(){u(i,e,5,1e3)})})},resize:_},l=function(t,e){t.addCommand("mceAutoResize",function(){s.resize(t,e)})};t.add("autoresize",function(t){if(!t.inline){var e=i(0);l(t,e),s.setup(t,e)}})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(a){"use strict";var i=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return i(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),u=function(t,e){var n=t||e,r=/^(\d+)([ms]?)$/.exec(""+n);return(r[2]?{s:1e3,m:6e4}[r[2]]:1)*parseInt(n,10)},s=function(t){var e=t.getParam("autosave_prefix","tinymce-autosave-{path}{query}{hash}-{id}-");return e=(e=(e=(e=e.replace(/\{path\}/g,a.document.location.pathname)).replace(/\{query\}/g,a.document.location.search)).replace(/\{hash\}/g,a.document.location.hash)).replace(/\{id\}/g,t.id)},c=function(t,e){var n=t.settings.forced_root_block;return""===(e=o.trim(void 0===e?t.getBody().innerHTML:e))||new RegExp("^<"+n+"[^>]*>((\xa0| |[ \t]|<br[^>]*>)+?|)</"+n+">|<br>$","i").test(e)},f=function(t){var e=parseInt(r.getItem(s(t)+"time"),10)||0;return!((new Date).getTime()-e>u(t.settings.autosave_retention,"20m")&&(l(t,!1),1))},l=function(t,e){var n=s(t);r.removeItem(n+"draft"),r.removeItem(n+"time"),!1!==e&&t.fire("RemoveDraft")},m=function(t){var e=s(t);!c(t)&&t.isDirty()&&(r.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),r.setItem(e+"time",(new Date).getTime().toString()),t.fire("StoreDraft"))},v=function(t){var e=s(t);f(t)&&(t.setContent(r.getItem(e+"draft"),{format:"raw"}),t.fire("RestoreDraft"))},d=function(t,e){var n=u(t.settings.autosave_interval,"30s");e.get()||(setInterval(function(){t.removed||m(t)},n),e.set(!0))},g=function(t){t.undoManager.transact(function(){v(t),l(t)}),t.focus()};function y(r){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o.concat(t);return r.apply(null,n)}}var p=tinymce.util.Tools.resolve("tinymce.EditorManager");p._beforeUnloadHandler=function(){var e;return o.each(p.get(),function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e};var h=function(n,r){return function(t){var e=t.control;e.disabled(!f(n)),n.on("StoreDraft RestoreDraft RemoveDraft",function(){e.disabled(!f(n))}),d(n,r)}};t.add("autosave",function(t){var e,n,r,o=i(!1);return a.window.onbeforeunload=p._beforeUnloadHandler,n=o,(e=t).addButton("restoredraft",{title:"Restore last draft",onclick:function(){g(e)},onPostRender:h(e,n)}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:function(){g(e)},onPostRender:h(e,n),context:"file"}),t.on("init",function(){t.getParam("autosave_restore_when_empty",!1)&&t.dom.isEmpty(t.getBody())&&v(t)}),{hasDraft:y(f,r=t),storeDraft:y(m,r),restoreDraft:y(v,r),removeDraft:y(l,r),isEmpty:y(c,r)}})}(window);
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var o=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(e){e=t.trim(e);var o=function(o,t){e=e.replace(o,t)};return o(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]"),o(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),o(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),o(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]"),o(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]"),o(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]"),o(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]"),o(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]"),o(/<font>(.*?)<\/font>/gi,"$1"),o(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]"),o(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]"),o(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]"),o(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]"),o(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]"),o(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]"),o(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]"),o(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]"),o(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]"),o(/<\/(strong|b)>/gi,"[/b]"),o(/<(strong|b)>/gi,"[b]"),o(/<\/(em|i)>/gi,"[/i]"),o(/<(em|i)>/gi,"[i]"),o(/<\/u>/gi,"[/u]"),o(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]"),o(/<u>/gi,"[u]"),o(/<blockquote[^>]*>/gi,"[quote]"),o(/<\/blockquote>/gi,"[/quote]"),o(/<br \/>/gi,"\n"),o(/<br\/>/gi,"\n"),o(/<br>/gi,"\n"),o(/<p>/gi,""),o(/<\/p>/gi,"\n"),o(/ |\u00a0/gi," "),o(/"/gi,'"'),o(/</gi,"<"),o(/>/gi,">"),o(/&/gi,"&"),e},i=function(e){e=t.trim(e);var o=function(o,t){e=e.replace(o,t)};return o(/\n/gi,"<br />"),o(/\[b\]/gi,"<strong>"),o(/\[\/b\]/gi,"</strong>"),o(/\[i\]/gi,"<em>"),o(/\[\/i\]/gi,"</em>"),o(/\[u\]/gi,"<u>"),o(/\[\/u\]/gi,"</u>"),o(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>'),o(/\[url\](.*?)\[\/url\]/gi,'<a href="$1">$1</a>'),o(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />'),o(/\[color=(.*?)\](.*?)\[\/color\]/gi,'<font color="$1">$2</font>'),o(/\[code\](.*?)\[\/code\]/gi,'<span class="codeStyle">$1</span> '),o(/\[quote.*?\](.*?)\[\/quote\]/gi,'<span class="quoteStyle">$1</span> '),e};o.add("bbcode",function(){return{init:function(o){o.on("beforeSetContent",function(o){o.content=i(o.content)}),o.on("postProcess",function(o){o.set&&(o.content=i(o.content)),o.get&&(o.content=e(o.content))})}}})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),o=function(t){return t.getParam("code_dialog_width",600)},i=function(t){return t.getParam("code_dialog_height",Math.min(n.DOM.getViewPort().h-200,500))},c=function(t,n){t.focus(),t.undoManager.transact(function(){t.setContent(n)}),t.selection.setCursorLocation(),t.nodeChanged()},d=function(t){return t.getContent({source_view:!0})},e=function(n){var t=o(n),e=i(n);n.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:t,minHeight:e,spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(t){c(n,t.data.code)}}).find("#code").value(d(n))},u=function(t){t.addCommand("mceCodeEditor",function(){e(t)})},a=function(t){t.addButton("code",{icon:"code",tooltip:"Source code",onclick:function(){e(t)}}),t.addMenuItem("code",{icon:"code",text:"Source code",onclick:function(){e(t)}})};t.add("code",function(t){return u(t),a(t),{}})}();
|
||||
@@ -0,0 +1,138 @@
|
||||
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */
|
||||
/**
|
||||
* prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: black;
|
||||
text-shadow: 0 1px white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
@media print {
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
text-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #f5f2f0;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #a67f59;
|
||||
background: hsla(0, 0%, 100%, .5);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
.token.function {
|
||||
color: #DD4A68;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=tinymce.util.Tools.resolve("tinymce.util.Color"),a=function(e,n){e.find("#preview")[0].getEl().style.background=n},o=function(e,n){var i=l(n),t=i.toRgb();e.fromJSON({r:t.r,g:t.g,b:t.b,hex:i.toHex().substr(1)}),a(e,i.toHex())},t=function(e,n,i){var t=e.windowManager.open({title:"Color",items:{type:"container",layout:"flex",direction:"row",align:"stretch",padding:5,spacing:10,items:[{type:"colorpicker",value:i,onchange:function(){var e=this.rgb();t&&(t.find("#r").value(e.r),t.find("#g").value(e.g),t.find("#b").value(e.b),t.find("#hex").value(this.value().substr(1)),a(t,this.value()))}},{type:"form",padding:0,labelGap:5,defaults:{type:"textbox",size:7,value:"0",flex:1,spellcheck:!1,onchange:function(){var e,n,i=t.find("colorpicker")[0];if(e=this.name(),n=this.value(),"hex"===e)return o(t,n="#"+n),void i.value(n);n={r:t.find("#r").value(),g:t.find("#g").value(),b:t.find("#b").value()},i.value(n),o(t,n)}},items:[{name:"r",label:"R",autofocus:1},{name:"g",label:"G"},{name:"b",label:"B"},{name:"hex",label:"#",value:"000000"},{name:"preview",type:"container",border:1}]}]},onSubmit:function(){n("#"+t.toJSON().hex)}});o(t,i)};e.add("colorpicker",function(i){i.settings.color_picker_callback||(i.settings.color_picker_callback=function(e,n){t(i,e,n)})})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var o=function(t){var n=t,e=function(){return n};return{get:e,set:function(t){n=t},clone:function(){return o(e())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(t){return{isContextMenuVisible:function(){return t.get()}}},r=function(t){return t.settings.contextmenu_never_use_native},u=function(t){return t.getParam("contextmenu","link openlink image inserttable | cell row column deletetable")},l=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=function(t){return l.DOM.select(t.settings.ui_container)[0]},a=function(t,n){return{x:t,y:n}},f=function(t,n,e){return a(t.x+n,t.y+e)},m=function(t,n){if(t&&"static"!==l.DOM.getStyle(t,"position",!0)){var e=l.DOM.getPos(t),o=e.x-t.scrollLeft,i=e.y-t.scrollTop;return f(n,-o,-i)}return f(n,0,0)},c=function(t,n){if(t.inline)return m(s(t),a((u=n).pageX,u.pageY));var e,o,i,r,u,c=(e=t.getContentAreaContainer(),o=a((r=n).clientX,r.clientY),i=l.DOM.getPos(e),f(o,i.x,i.y));return m(s(t),c)},g=tinymce.util.Tools.resolve("tinymce.ui.Factory"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),y=function(t,n,e,o){null===o.get()?o.set(function(e,n){var t,o,i=[];o=u(e),v.each(o.split(/[ ,]/),function(t){var n=e.menuItems[t];"|"===t&&(n={text:t}),n&&(n.shortcut="",i.push(n))});for(var r=0;r<i.length;r++)"|"===i[r].text&&(0!==r&&r!==i.length-1||i.splice(r,1));return(t=g.create("menu",{items:i,context:"contextmenu",classes:"contextmenu"})).uiContainer=s(e),t.renderTo(s(e)),t.on("hide",function(t){t.control===this&&n.set(!1)}),e.on("remove",function(){t.remove(),t=null}),t}(t,e)):o.get().show(),o.get().moveTo(n.x,n.y),e.set(!0)},x=function(e,o,i){e.on("contextmenu",function(t){var n;n=e,(!t.ctrlKey||r(n))&&(t.preventDefault(),y(e,c(e,t),o,i))})};t.add("contextmenu",function(t){var n=o(null),e=o(!1);return x(t,e,n),i(e)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.Tools"),e=function(t,e){var i,n=t.dom,o=t.selection.getSelectedBlocks();o.length&&(i=n.getAttrib(o[0],"dir"),c.each(o,function(t){n.getParent(t.parentNode,'*[dir="'+e+'"]',n.getRoot())||n.setAttrib(t,"dir",i!==e?e:null)}),t.nodeChanged())},i=function(t){t.addCommand("mceDirectionLTR",function(){e(t,"ltr")}),t.addCommand("mceDirectionRTL",function(){e(t,"rtl")})},n=function(e){var i=[];return c.each("h1 h2 h3 h4 h5 h6 div p".split(" "),function(t){i.push(t+"[dir="+e+"]")}),i.join(",")},o=function(t){t.addButton("ltr",{title:"Left to right",cmd:"mceDirectionLTR",stateSelector:n("ltr")}),t.addButton("rtl",{title:"Right to left",cmd:"mceDirectionRTL",stateSelector:n("rtl")})};t.add("directionality",function(t){i(t),o(t)})}();
|
||||
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 329 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 342 B |
|
After Width: | Height: | Size: 340 B |
|
After Width: | Height: | Size: 336 B |
|
After Width: | Height: | Size: 338 B |
|
After Width: | Height: | Size: 343 B |
|
After Width: | Height: | Size: 321 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 344 B |
|
After Width: | Height: | Size: 338 B |
|
After Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 337 B |
|
After Width: | Height: | Size: 350 B |
|
After Width: | Height: | Size: 336 B |
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),e=tinymce.util.Tools.resolve("tinymce.util.Tools"),n=[["cool","cry","embarassed","foot-in-mouth"],["frown","innocent","kiss","laughing"],["money-mouth","sealed","smile","surprised"],["tongue-out","undecided","wink","yell"]],i=function(i){var o;return o='<table role="list" class="mce-grid">',e.each(n,function(t){o+="<tr>",e.each(t,function(t){var e=i+"/img/smiley-"+t+".gif";o+='<td><a href="#" data-mce-url="'+e+'" data-mce-alt="'+t+'" tabindex="-1" role="option" aria-label="'+t+'"><img src="'+e+'" style="width: 18px; height: 18px" role="presentation" /></a></td>'}),o+="</tr>"}),o+="</table>"},o=function(a,t){var e=i(t);a.addButton("emoticons",{type:"panelbutton",panel:{role:"application",autohide:!0,html:e,onclick:function(t){var e,i,o,n=a.dom.getParent(t.target,"a");n&&(e=a,i=n.getAttribute("data-mce-url"),o=n.getAttribute("data-mce-alt"),e.insertContent(e.dom.createHTML("img",{src:i,alt:o})),this.hide())}},tooltip:"Emoticons"})};t.add("emoticons",function(t,e){o(t,e)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(m){"use strict";var i=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return i(t())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return{isFullscreen:function(){return null!==e.get()}}},n=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),g=function(e,n){e.fire("FullscreenStateChanged",{state:n})},w=n.DOM,r=function(e,n){var t,r,l,i,o,c,s=m.document.body,u=m.document.documentElement,d=n.get(),a=function(){var e,n,t,i;w.setStyle(l,"height",(t=m.window,i=m.document.body,i.offsetWidth&&(e=i.offsetWidth,n=i.offsetHeight),t.innerWidth&&t.innerHeight&&(e=t.innerWidth,n=t.innerHeight),{w:e,h:n}).h-(r.clientHeight-l.clientHeight))},h=function(){w.unbind(m.window,"resize",a)};if(t=(r=e.getContainer()).style,i=(l=e.getContentAreaContainer().firstChild).style,d)i.width=d.iframeWidth,i.height=d.iframeHeight,d.containerWidth&&(t.width=d.containerWidth),d.containerHeight&&(t.height=d.containerHeight),w.removeClass(s,"mce-fullscreen"),w.removeClass(u,"mce-fullscreen"),w.removeClass(r,"mce-fullscreen"),o=d.scrollPos,m.window.scrollTo(o.x,o.y),w.unbind(m.window,"resize",d.resizeHandler),e.off("remove",d.removeHandler),n.set(null),g(e,!1);else{var f={scrollPos:(c=w.getViewPort(),{x:c.x,y:c.y}),containerWidth:t.width,containerHeight:t.height,iframeWidth:i.width,iframeHeight:i.height,resizeHandler:a,removeHandler:h};i.width=i.height="100%",t.width=t.height="",w.addClass(s,"mce-fullscreen"),w.addClass(u,"mce-fullscreen"),w.addClass(r,"mce-fullscreen"),w.bind(m.window,"resize",a),e.on("remove",h),a(),n.set(f),g(e,!0)}},l=function(e,n){e.addCommand("mceFullScreen",function(){r(e,n)})},o=function(t){return function(e){var n=e.control;t.on("FullscreenStateChanged",function(e){n.active(e.state)})}},c=function(e){e.addMenuItem("fullscreen",{text:"Fullscreen",shortcut:"Ctrl+Shift+F",selectable:!0,cmd:"mceFullScreen",onPostRender:o(e),context:"view"}),e.addButton("fullscreen",{active:!1,tooltip:"Fullscreen",cmd:"mceFullScreen",onPostRender:o(e)})};e.add("fullscreen",function(e){var n=i(null);return e.settings.inline||(l(e,n),c(e),e.addShortcut("Ctrl+Shift+F","","mceFullScreen")),t(n)})}(window);
|
||||
BIN
wp/plugins/divi-builder/includes/builder/frontend-builder/assets/vendors/plugins/help/img/logo.png
vendored
Normal file
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(n){n.addCommand("InsertHorizontalRule",function(){n.execCommand("mceInsertContent",!1,"<hr />")})},o=function(n){n.addButton("hr",{icon:"hr",tooltip:"Horizontal line",cmd:"InsertHorizontalRule"}),n.addMenuItem("hr",{icon:"hr",text:"Horizontal line",cmd:"InsertHorizontalRule",context:"insert"})};n.add("hr",function(n){t(n),o(n)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),v=tinymce.util.Tools.resolve("tinymce.EditorManager"),h=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=function(e){return e.getParam("importcss_merge_classes")},n=function(e){return e.getParam("importcss_exclusive")},_=function(e){return e.getParam("importcss_selector_converter")},r=function(e){return e.getParam("importcss_selector_filter")},i=function(e){return e.getParam("importcss_groups")},u=function(e){return e.getParam("importcss_append")},l=function(e){return e.getParam("importcss_file_filter")},a=function(t){return"string"==typeof t?function(e){return-1!==e.indexOf(t)}:t instanceof RegExp?function(e){return t.test(e)}:t},f=function(f,e,m){var g=[],n={};function p(e,t){var n,r,i,c=e.href;if(r=c,i=h.cacheSuffix,"string"==typeof r&&(r=r.replace("?"+i,"").replace("&"+i,"")),(c=r)&&m(c,t)&&(o=c,u=(s=f).settings,!(l=!1!==u.skin&&(u.skin||"lightgray"))||o!==(u.skin_url?s.documentBaseURI.toAbsolute(u.skin_url):v.baseURL+"/skins/"+l)+"/content"+(s.inline?".inline":"")+".min.css")){var s,o,u,l;y.each(e.imports,function(e){p(e,!0)});try{n=e.cssRules||e.rules}catch(a){}y.each(n,function(e){e.styleSheet?p(e.styleSheet,!0):e.selectorText&&y.each(e.selectorText.split(","),function(e){g.push(y.trim(e))})})}}y.each(f.contentCSS,function(e){n[e]=!0}),m||(m=function(e,t){return t||n[e]});try{y.each(e.styleSheets,function(e){p(e)})}catch(t){}return g},x=function(e,t){var n,r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(r){var i=r[1],c=r[2].substr(1).split(".").join(" "),s=y.makeMap("a,img");return r[1]?(n={title:t},e.schema.getTextBlockElements()[i]?n.block=i:e.schema.getBlockElements()[i]||s[i.toLowerCase()]?n.selector=i:n.inline=i):r[2]&&(n={inline:"span",title:t.substr(1),classes:c}),!1!==o(e)?n.classes=c:n.attributes={"class":c},n}},T=function(e,t){return null===t||!1!==n(e)},c=x,t=function(h){h.on("renderFormatsMenu",function(e){var t,p={},c=a(r(h)),v=e.control,s=(t=i(h),y.map(t,function(e){return y.extend({},e,{original:e,selectors:{},filter:a(e.filter),item:{text:e.title,menu:[]}})})),o=function(e,t){if(f=e,g=p,!(T(h,m=t)?f in g:f in m.selectors)){u=e,a=p,T(h,l=t)?a[u]=!0:l.selectors[u]=!0;var n=(c=(i=h).plugins.importcss,s=e,((o=t)&&o.selector_converter?o.selector_converter:_(i)?_(i):function(){return x(i,s)}).call(c,s,o));if(n){var r=n.name||d.DOM.uniqueId();return h.formatter.register(r,n),y.extend({},v.settings.itemDefaults,{text:n.title,format:r})}}var i,c,s,o,u,l,a,f,m,g;return null};u(h)||v.items().remove(),y.each(f(h,e.doc||h.getDoc(),a(l(h))),function(n){if(-1===n.indexOf(".mce-")&&(!c||c(n))){var e=(r=s,i=n,y.grep(r,function(e){return!e.filter||e.filter(i)}));if(0<e.length)y.each(e,function(e){var t=o(n,e);t&&e.item.menu.push(t)});else{var t=o(n,null);t&&v.add(t)}}var r,i}),y.each(s,function(e){0<e.item.menu.length&&v.add(e.item)}),e.control.renderNew()})},s=function(t){return{convertSelectorToFormat:function(e){return c(t,e)}}};e.add("importcss",function(e){return t(e),s(e)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var r=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return r(n())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=function(e){return e.getParam("insertdatetime_timeformat",e.translate("%H:%M:%S"))},a=function(e){return e.getParam("insertdatetime_formats",["%H:%M:%S","%Y-%m-%d","%I:%M:%S %p","%D"])},t=function(e){return e.getParam("insertdatetime_dateformat",e.translate("%Y-%m-%d"))},i=n,o=a,u=function(e){var t=a(e);return 0<t.length?t[0]:n(e)},m=function(e){return e.getParam("insertdatetime_element",!1)},c="Sun Mon Tue Wed Thu Fri Sat Sun".split(" "),l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" "),s="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),d="January February March April May June July August September October November December".split(" "),p=function(e,t){if((e=""+e).length<t)for(var n=0;n<t-e.length;n++)e="0"+e;return e},f=function(e,t,n){return n=n||new Date,t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace("%D","%m/%d/%Y")).replace("%r","%I:%M:%S %p")).replace("%Y",""+n.getFullYear())).replace("%y",""+n.getYear())).replace("%m",p(n.getMonth()+1,2))).replace("%d",p(n.getDate(),2))).replace("%H",""+p(n.getHours(),2))).replace("%M",""+p(n.getMinutes(),2))).replace("%S",""+p(n.getSeconds(),2))).replace("%I",""+((n.getHours()+11)%12+1))).replace("%p",n.getHours()<12?"AM":"PM")).replace("%B",""+e.translate(d[n.getMonth()]))).replace("%b",""+e.translate(s[n.getMonth()]))).replace("%A",""+e.translate(l[n.getDay()]))).replace("%a",""+e.translate(c[n.getDay()]))).replace("%%","%")},g=function(e,t){if(m(e)){var n=f(e,t),r=void 0;r=/%[HMSIp]/.test(t)?f(e,"%Y-%m-%dT%H:%M"):f(e,"%Y-%m-%d");var a=e.dom.getParent(e.selection.getStart(),"time");a?(o=a,u=r,c=n,l=(i=e).dom.create("time",{datetime:u},c),o.parentNode.insertBefore(l,o),i.dom.remove(o),i.selection.select(l,!0),i.selection.collapse(!1)):e.insertContent('<time datetime="'+r+'">'+n+"</time>")}else e.insertContent(f(e,t));var i,o,u,c,l},y=f,M=function(e){e.addCommand("mceInsertDate",function(){g(e,t(e))}),e.addCommand("mceInsertTime",function(){g(e,i(e))})},v=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=function(t,n){var r,a,e,i=(a=n,e=o(r=t),v.map(e,function(e){return{text:y(r,e),onclick:function(){a.set(e),g(r,e)}}}));t.addButton("insertdatetime",{type:"splitbutton",title:"Insert date/time",menu:i,onclick:function(){var e=n.get();g(t,e||u(t))}}),t.addMenuItem("insertdatetime",{icon:"date",text:"Date/time",menu:i,context:"insert"})};e.add("insertdatetime",function(e){var t=r(null);M(e),S(e,t)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=function(a){a.settings.inline_styles=!1,a.on("init",function(){var e,t,n,i;e=a,t="p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img",n=o.explode(e.settings.font_size_style_values),i=e.schema,e.formatter.register({alignleft:{selector:t,attributes:{align:"left"}},aligncenter:{selector:t,attributes:{align:"center"}},alignright:{selector:t,attributes:{align:"right"}},alignjustify:{selector:t,attributes:{align:"justify"}},bold:[{inline:"b",remove:"all"},{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}}],italic:[{inline:"i",remove:"all"},{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}}],underline:[{inline:"u",remove:"all"},{inline:"span",styles:{textDecoration:"underline"},exact:!0}],strikethrough:[{inline:"strike",remove:"all"},{inline:"span",styles:{textDecoration:"line-through"},exact:!0}],fontname:{inline:"font",attributes:{face:"%value"}},fontsize:{inline:"font",attributes:{size:function(e){return o.inArray(n,e.value)+1}}},forecolor:{inline:"font",attributes:{color:"%value"}},hilitecolor:{inline:"font",styles:{backgroundColor:"%value"}}}),o.each("b,i,u,strike".split(","),function(e){i.addValidElements(e+"[*]")}),i.getElementRule("font")||i.addValidElements("font[face|size|color|style]"),o.each(t.split(","),function(e){var t=i.getElementRule(e);t&&(t.attributes.align||(t.attributes.align={},t.attributesOrder.push("align")))})})},n=function(i){i.addButton("fontsizeselect",function(){var o=[],e=i.settings.fontsizeFormats||"8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7";return i.$.each(e.split(" "),function(e,t){var n=t,i=t,a=t.split("=");1<a.length&&(n=a[0],i=a[1]),o.push({text:n,value:i})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:o,fixedWidth:!0,onPostRender:function(){var t=this;i.on("NodeChange",function(){var e;(e=i.dom.getParent(i.selection.getNode(),"font"))?t.value(e.size):t.value("")})},onclick:function(e){e.control.settings.value&&i.execCommand("FontSize",!1,e.control.settings.value)}}}),i.addButton("fontselect",function(){var n=[],e=function(e){for(var t=(e=e.replace(/;$/,"").split(";")).length;t--;)e[t]=e[t].split("=");return e}(i.settings.font_formats||"Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats");return i.$.each(e,function(e,t){n.push({text:{raw:t[0]},value:t[1],textStyle:-1===t[1].indexOf("dings")?"font-family:"+t[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:n,fixedWidth:!0,onPostRender:function(){var t=this;i.on("NodeChange",function(){var e;(e=i.dom.getParent(i.selection.getNode(),"font"))?t.value(e.face):t.value("")})},onselect:function(e){e.control.settings.value&&i.execCommand("FontName",!1,e.control.settings.value)}}})};e.add("legacyoutput",function(e){t(e),n(e)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var n=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=function(n,e){var t,i=(t=n).plugins.visualchars&&t.plugins.visualchars.isEnabled()?'<span class="mce-nbsp"> </span>':" ";n.insertContent(function(n,e){for(var t="",i=0;i<e;i++)t+=n;return t}(i,e)),n.dom.setAttrib(n.dom.select("span.mce-nbsp"),"data-mce-bogus","1")},e=function(n){n.addCommand("mceNonBreaking",function(){i(n,1)})},o=tinymce.util.Tools.resolve("tinymce.util.VK"),a=function(n){var e=n.getParam("nonbreaking_force_tab",0);return"boolean"==typeof e?!0===e?3:0:e},t=function(e){var t=a(e);0<t&&e.on("keydown",function(n){if(n.keyCode===o.TAB&&!n.isDefaultPrevented()){if(n.shiftKey)return;n.preventDefault(),n.stopImmediatePropagation(),i(e,t)}})},r=function(n){n.addButton("nonbreaking",{title:"Nonbreaking space",cmd:"mceNonBreaking"}),n.addMenuItem("nonbreaking",{icon:"nonbreaking",text:"Nonbreaking space",cmd:"mceNonBreaking",context:"insert"})};n.add("nonbreaking",function(n){e(n),r(n),t(n)})}();
|
||||
@@ -0,0 +1 @@
|
||||
!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.util.Tools"),l=function(t){return t.getParam("noneditable_noneditable_class","mceNonEditable")},u=function(t){return t.getParam("noneditable_editable_class","mceEditable")},f=function(t){var n=t.getParam("noneditable_regexp",[]);return n&&n.constructor===RegExp?[n]:n},s=function(n){return function(t){return-1!==(" "+t.attr("class")+" ").indexOf(n)}},d=function(i,o,c){return function(t){var n=arguments,e=n[n.length-2],r=0<e?o.charAt(e-1):"";if('"'===r)return t;if(">"===r){var a=o.lastIndexOf("<",e);if(-1!==a&&-1!==o.substring(a,e).indexOf('contenteditable="false"'))return t}return'<span class="'+c+'" data-mce-content="'+i.dom.encode(n[0])+'">'+i.dom.encode("string"==typeof n[1]?n[1]:n[0])+"</span>"}},n=function(n){var t,e,r="contenteditable";t=" "+c.trim(u(n))+" ",e=" "+c.trim(l(n))+" ";var a=s(t),i=s(e),o=f(n);n.on("PreInit",function(){0<o.length&&n.on("BeforeSetContent",function(t){!function(t,n,e){var r=n.length,a=e.content;if("raw"!==e.format){for(;r--;)a=a.replace(n[r],d(t,a,l(t)));e.content=a}}(n,o,t)}),n.parser.addAttributeFilter("class",function(t){for(var n,e=t.length;e--;)n=t[e],a(n)?n.attr(r,"true"):i(n)&&n.attr(r,"false")}),n.serializer.addAttributeFilter(r,function(t){for(var n,e=t.length;e--;)n=t[e],(a(n)||i(n))&&(0<o.length&&n.attr("data-mce-content")?(n.name="#text",n.type=3,n.raw=!0,n.value=n.attr("data-mce-content")):n.attr(r,null))})})};t.add("noneditable",function(t){n(t)})}();
|
||||