Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: framework.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if ( ! defined( 'ET_BUILDER_DIVI_LIBRARY_URL' ) ) {
[2] Fix | Delete
define( 'ET_BUILDER_DIVI_LIBRARY_URL', 'https://www.elegantthemes.com/layouts' );
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
if ( ! defined( 'ET_BUILDER_CSS_WRAPPER_PREFIX' ) ) {
[6] Fix | Delete
define( 'ET_BUILDER_CSS_WRAPPER_PREFIX', '.et-db' );
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
if ( ! defined( 'ET_BUILDER_CSS_CONTAINER_PREFIX' ) ) {
[10] Fix | Delete
define( 'ET_BUILDER_CSS_CONTAINER_PREFIX', '#et-boc' );
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
if ( ! defined( 'ET_BUILDER_CSS_LAYOUT_PREFIX' ) ) {
[14] Fix | Delete
define( 'ET_BUILDER_CSS_LAYOUT_PREFIX', ET_BUILDER_CSS_CONTAINER_PREFIX . ' .et-l' );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
if ( ! defined( 'ET_BUILDER_CSS_PREFIX' ) ) {
[18] Fix | Delete
define( 'ET_BUILDER_CSS_PREFIX', ET_BUILDER_CSS_WRAPPER_PREFIX . ' ' . ET_BUILDER_CSS_LAYOUT_PREFIX );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
if ( ! defined( 'ET_BUILDER_PLACEHOLDER_LANDSCAPE_IMAGE_DATA' ) ) {
[22] Fix | Delete
define( 'ET_BUILDER_PLACEHOLDER_LANDSCAPE_IMAGE_DATA', 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA4MCIgaGVpZ2h0PSI1NDAiIHZpZXdCb3g9IjAgMCAxMDgwIDU0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZmlsbD0iI0VCRUJFQiIgZD0iTTAgMGgxMDgwdjU0MEgweiIvPgogICAgICAgIDxwYXRoIGQ9Ik00NDUuNjQ5IDU0MGgtOTguOTk1TDE0NC42NDkgMzM3Ljk5NSAwIDQ4Mi42NDR2LTk4Ljk5NWwxMTYuMzY1LTExNi4zNjVjMTUuNjItMTUuNjIgNDAuOTQ3LTE1LjYyIDU2LjU2OCAwTDQ0NS42NSA1NDB6IiBmaWxsLW9wYWNpdHk9Ii4xIiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz4KICAgICAgICA8Y2lyY2xlIGZpbGwtb3BhY2l0eT0iLjA1IiBmaWxsPSIjMDAwIiBjeD0iMzMxIiBjeT0iMTQ4IiByPSI3MCIvPgogICAgICAgIDxwYXRoIGQ9Ik0xMDgwIDM3OXYxMTMuMTM3TDcyOC4xNjIgMTQwLjMgMzI4LjQ2MiA1NDBIMjE1LjMyNEw2OTkuODc4IDU1LjQ0NmMxNS42Mi0xNS42MiA0MC45NDgtMTUuNjIgNTYuNTY4IDBMMTA4MCAzNzl6IiBmaWxsLW9wYWNpdHk9Ii4yIiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz4KICAgIDwvZz4KPC9zdmc+Cg==' );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
if ( ! defined( 'ET_BUILDER_PLACEHOLDER_PORTRAIT_IMAGE_DATA' ) ) {
[26] Fix | Delete
define( 'ET_BUILDER_PLACEHOLDER_PORTRAIT_IMAGE_DATA', 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjUwMCIgdmlld0JveD0iMCAwIDUwMCA1MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIGZpbGw9IiNFQkVCRUIiIGQ9Ik0wIDBoNTAwdjUwMEgweiIvPgogICAgICAgIDxyZWN0IGZpbGwtb3BhY2l0eT0iLjEiIGZpbGw9IiMwMDAiIHg9IjY4IiB5PSIzMDUiIHdpZHRoPSIzNjQiIGhlaWdodD0iNTY4IiByeD0iMTgyIi8+CiAgICAgICAgPGNpcmNsZSBmaWxsLW9wYWNpdHk9Ii4xIiBmaWxsPSIjMDAwIiBjeD0iMjQ5IiBjeT0iMTcyIiByPSIxMDAiLz4KICAgIDwvZz4KPC9zdmc+Cg==' );
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
// Detect Codeception and load additional code required by tests.
[30] Fix | Delete
if ( class_exists( 'Codeception\TestCase\WPTestCase' ) ) {
[31] Fix | Delete
foreach ( glob( ET_BUILDER_DIR . 'tests/codeception/wpunit/*.php' ) as $test_file ) {
[32] Fix | Delete
require_once $test_file;
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
require_once ET_BUILDER_DIR . 'autoload.php';
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Retrieve a commonly used translation.
[40] Fix | Delete
*
[41] Fix | Delete
* @since 4.4.9
[42] Fix | Delete
*
[43] Fix | Delete
* @param string $key Translation key.
[44] Fix | Delete
* @param boolean $reset Reset cache.
[45] Fix | Delete
*
[46] Fix | Delete
* @return string
[47] Fix | Delete
*/
[48] Fix | Delete
function et_builder_i18n( $key, $reset = false ) {
[49] Fix | Delete
static $cache;
[50] Fix | Delete
[51] Fix | Delete
if ( true === $reset ) {
[52] Fix | Delete
$cache = array();
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
if ( ! isset( $cache[ $key ] ) ) {
[56] Fix | Delete
$cache[ $key ] = ET_Builder_I18n::get( $key );
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
return $cache[ $key ];
[60] Fix | Delete
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Resets commonly used translations cache.
[65] Fix | Delete
*
[66] Fix | Delete
* @since 4.4.9
[67] Fix | Delete
*
[68] Fix | Delete
* @return void
[69] Fix | Delete
*/
[70] Fix | Delete
function et_builder_i18n_reset_cache() {
[71] Fix | Delete
et_builder_i18n( '', true );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Escape translation with optional value and caches the result.
[76] Fix | Delete
*
[77] Fix | Delete
* @since 4.4.9
[78] Fix | Delete
*
[79] Fix | Delete
* @param string $text
[80] Fix | Delete
* @param string $value
[81] Fix | Delete
*
[82] Fix | Delete
* @return string.
[83] Fix | Delete
*/
[84] Fix | Delete
function et_esc_html_once( $text, $value = '' ) {
[85] Fix | Delete
static $cache = array();
[86] Fix | Delete
[87] Fix | Delete
if ( isset( $cache[ $text ][ $value ] ) ) {
[88] Fix | Delete
return $cache[ $text ][ $value ];
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
$escaped = esc_html( '' === $value ? $text : sprintf( $text, $value ) );
[92] Fix | Delete
[93] Fix | Delete
$cache[ $text ][ $value ] = $escaped;
[94] Fix | Delete
return $escaped;
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
require_once ET_BUILDER_DIR . 'compat/early.php';
[98] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/gutenberg/blocks/Layout.php';
[99] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/gutenberg/utils/Conversion.php';
[100] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/gutenberg/EditorTypography.php';
[101] Fix | Delete
require_once ET_BUILDER_DIR . 'core.php';
[102] Fix | Delete
require_once ET_BUILDER_DIR . 'conditions.php';
[103] Fix | Delete
require_once ET_BUILDER_DIR . 'post/PostStack.php';
[104] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/ClassicEditor.php';
[105] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/AjaxCache.php';
[106] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/post-content.php';
[107] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/dynamic-content.php';
[108] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/search-posts.php';
[109] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/ErrorReport.php';
[110] Fix | Delete
require_once ET_BUILDER_DIR . 'api/DiviExtensions.php';
[111] Fix | Delete
require_once ET_BUILDER_DIR . 'api/rest/BlockLayout.php';
[112] Fix | Delete
require_once ET_BUILDER_DIR . 'frontend-builder/theme-builder/theme-builder.php';
[113] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/global-presets/Settings.php';
[114] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/global-presets/History.php';
[115] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/window.php';
[116] Fix | Delete
[117] Fix | Delete
// Conditional Includes.
[118] Fix | Delete
if ( et_is_woocommerce_plugin_active() ) {
[119] Fix | Delete
require_once ET_BUILDER_DIR . 'feature/woocommerce-modules.php';
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
if ( wp_doing_ajax() && ! is_customize_preview() ) {
[123] Fix | Delete
define( 'WPE_HEARTBEAT_INTERVAL', et_builder_heartbeat_interval() );
[124] Fix | Delete
[125] Fix | Delete
// Default ajax request exceptions
[126] Fix | Delete
$builder_load_requests = array(
[127] Fix | Delete
'action' => array(
[128] Fix | Delete
'et_pb_get_backbone_template',
[129] Fix | Delete
'et_pb_get_backbone_templates',
[130] Fix | Delete
'et_pb_process_computed_property',
[131] Fix | Delete
'et_fb_ajax_render_shortcode',
[132] Fix | Delete
'et_fb_ajax_save',
[133] Fix | Delete
'et_fb_get_shortcode_from_fb_object',
[134] Fix | Delete
'et_fb_ajax_drop_autosave',
[135] Fix | Delete
'et_fb_get_saved_layouts',
[136] Fix | Delete
'et_fb_save_layout',
[137] Fix | Delete
'et_fb_update_layout',
[138] Fix | Delete
'et_pb_execute_content_shortcodes',
[139] Fix | Delete
'et_pb_ab_builder_data',
[140] Fix | Delete
'et_pb_create_ab_tables',
[141] Fix | Delete
'et_pb_update_stats_table',
[142] Fix | Delete
'et_pb_ab_clear_cache',
[143] Fix | Delete
'et_pb_ab_clear_stats',
[144] Fix | Delete
'et_fb_prepare_shortcode',
[145] Fix | Delete
'et_fb_process_imported_content',
[146] Fix | Delete
'et_fb_get_saved_templates',
[147] Fix | Delete
'et_fb_retrieve_builder_data',
[148] Fix | Delete
'et_fb_update_builder_assets',
[149] Fix | Delete
'et_pb_process_custom_font',
[150] Fix | Delete
'et_builder_email_add_account', // email opt-in module
[151] Fix | Delete
'et_builder_email_remove_account', // email opt-in module
[152] Fix | Delete
'et_builder_email_get_lists', // email opt-in module
[153] Fix | Delete
'et_builder_save_settings', // builder plugin dashboard (global builder settings)
[154] Fix | Delete
'save_epanel', // ePanel (global builder settings)
[155] Fix | Delete
'et_builder_library_get_layout',
[156] Fix | Delete
'et_builder_library_get_layouts_data',
[157] Fix | Delete
'et_fb_fetch_attachments',
[158] Fix | Delete
'et_pb_get_saved_templates',
[159] Fix | Delete
'et_builder_resolve_post_content',
[160] Fix | Delete
'et_builder_activate_bfb_auto_draft',
[161] Fix | Delete
'et_builder_toggle_bfb',
[162] Fix | Delete
'et_fb_error_report',
[163] Fix | Delete
'et_core_portability_import',
[164] Fix | Delete
'et_core_version_rollback',
[165] Fix | Delete
'update-theme',
[166] Fix | Delete
'et_safe_mode_update',
[167] Fix | Delete
'et_core_portability_export',
[168] Fix | Delete
'et_core_portability_import',
[169] Fix | Delete
'et_builder_migrate_module_customizer_phase_two',
[170] Fix | Delete
'et_builder_save_global_presets_history',
[171] Fix | Delete
'et_builder_retrieve_global_presets_history',
[172] Fix | Delete
'et_theme_builder_api_import_theme_builder_step',
[173] Fix | Delete
'et_pb_submit_subscribe_form',
[174] Fix | Delete
'et_builder_get_woocommerce_tabs',
[175] Fix | Delete
),
[176] Fix | Delete
);
[177] Fix | Delete
[178] Fix | Delete
// AJAX requests that use PHP modules cache for performance reasons.
[179] Fix | Delete
$builder_use_cache_actions = array(
[180] Fix | Delete
'heartbeat',
[181] Fix | Delete
'et_builder_retrieve_global_presets_history',
[182] Fix | Delete
'et_fb_get_saved_templates',
[183] Fix | Delete
'et_fb_ajax_save',
[184] Fix | Delete
'et_fb_ajax_drop_autosave',
[185] Fix | Delete
);
[186] Fix | Delete
[187] Fix | Delete
// Added built-in third party plugins support
[188] Fix | Delete
// Easy Digital Downloads
[189] Fix | Delete
if ( class_exists( 'Easy_Digital_Downloads' ) ) {
[190] Fix | Delete
$builder_load_requests['action'][] = 'edd_load_gateway';
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
// WooCommerce - it uses its own ajax endpoint instead of admin-ajax.php
[194] Fix | Delete
if ( class_exists( 'WooCommerce' ) ) {
[195] Fix | Delete
$builder_load_requests['wc-ajax'] = array(
[196] Fix | Delete
'update_order_review',
[197] Fix | Delete
);
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
// WPML.
[201] Fix | Delete
if ( class_exists( 'SitePress' ) ) {
[202] Fix | Delete
$builder_load_requests['action'][] = 'et_builder_wpml_translate_layout';
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
// Merging third party exceptions; built-in exceptions should not be removable
[206] Fix | Delete
$builder_custom_load_requests = apply_filters( 'et_builder_load_requests', array() );
[207] Fix | Delete
[208] Fix | Delete
if ( ! empty( $builder_custom_load_requests ) ) {
[209] Fix | Delete
foreach ( $builder_custom_load_requests as $builder_custom_query_string => $builder_custom_possible_values ) {
[210] Fix | Delete
if ( ! isset( $builder_load_requests[ $builder_custom_query_string ] ) ) {
[211] Fix | Delete
$builder_load_requests[ $builder_custom_query_string ] = $builder_custom_possible_values;
[212] Fix | Delete
} else {
[213] Fix | Delete
$builder_load_requests[ $builder_custom_query_string ] = array_merge( $builder_custom_possible_values, $builder_load_requests[ $builder_custom_query_string ] );
[214] Fix | Delete
}
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
// Legacy compatibility for action only request exception filter
[219] Fix | Delete
$builder_load_actions = apply_filters( 'et_builder_load_actions', array() );
[220] Fix | Delete
[221] Fix | Delete
if ( ! empty( $builder_load_actions ) ) {
[222] Fix | Delete
$builder_load_requests['action'] = array_merge( $builder_load_actions, $builder_load_requests['action'] );
[223] Fix | Delete
}
[224] Fix | Delete
[225] Fix | Delete
// Determine whether current AJAX request should load builder or not
[226] Fix | Delete
$load_builder_on_ajax = false;
[227] Fix | Delete
[228] Fix | Delete
// If current request's query string exists on list of possible values, load builder
[229] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
[230] Fix | Delete
foreach ( $builder_load_requests as $query_string => $possible_values ) {
[231] Fix | Delete
if ( isset( $_REQUEST[ $query_string ] ) && in_array( $_REQUEST[ $query_string ], $possible_values ) ) {
[232] Fix | Delete
$load_builder_on_ajax = true;
[233] Fix | Delete
[234] Fix | Delete
break;
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
define( 'ET_BUILDER_LOAD_ON_AJAX', $load_builder_on_ajax );
[239] Fix | Delete
[240] Fix | Delete
$action = et_()->array_get( $_POST, 'action', false );
[241] Fix | Delete
$force_builder_load = isset( $_POST['et_load_builder_modules'] ) && '1' === $_POST['et_load_builder_modules'];
[242] Fix | Delete
$force_memory_limit = 'et_fb_retrieve_builder_data' === $action;
[243] Fix | Delete
[244] Fix | Delete
if ( 'heartbeat' === $action ) {
[245] Fix | Delete
// if this is the heartbeat, and if its not packing our heartbeat data, then return
[246] Fix | Delete
if ( ! isset( $_REQUEST['data'] ) || ! isset( $_REQUEST['data']['et'] ) ) {
[247] Fix | Delete
return;
[248] Fix | Delete
}
[249] Fix | Delete
} elseif ( ! $force_builder_load && ! $load_builder_on_ajax ) {
[250] Fix | Delete
return;
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
if ( $force_memory_limit || et_should_memory_limit_increase() ) {
[254] Fix | Delete
et_increase_memory_limit();
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
if ( $action && in_array( $action, $builder_use_cache_actions ) ) {
[258] Fix | Delete
add_filter( 'et_builder_ajax_use_cache', '__return_true' );
[259] Fix | Delete
}
[260] Fix | Delete
// phpcs:enable
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
function et_builder_load_global_functions_script() {
[264] Fix | Delete
wp_enqueue_script( 'et-builder-modules-global-functions-script', ET_BUILDER_URI . '/frontend-builder/build/frontend-builder-global-functions.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[265] Fix | Delete
[266] Fix | Delete
// These are variable that is used on frontend's script utils module. The utils is used by
[267] Fix | Delete
// `et-builder-modules-global-functions-script` handle which is loaded earlier than other script
[268] Fix | Delete
// when minify js option is disabled hence being defined here. If minify JS option is enabled,
[269] Fix | Delete
// `et_builder_dequeue_minified_scripts()` will assign this to the minified bundle's handle.
[270] Fix | Delete
wp_localize_script(
[271] Fix | Delete
'et-builder-modules-global-functions-script',
[272] Fix | Delete
'et_builder_utils_params',
[273] Fix | Delete
array(
[274] Fix | Delete
'condition' => array(
[275] Fix | Delete
'diviTheme' => function_exists( 'et_divi_fonts_url' ),
[276] Fix | Delete
'extraTheme' => function_exists( 'et_extra_fonts_url' ),
[277] Fix | Delete
),
[278] Fix | Delete
'scrollLocations' => et_builder_get_window_scroll_locations(),
[279] Fix | Delete
'builderScrollLocations' => et_builder_get_onload_scroll_locations(),
[280] Fix | Delete
'onloadScrollLocation' => et_builder_get_onload_scroll_location(),
[281] Fix | Delete
'builderType' => et_builder_get_current_builder_type(),
[282] Fix | Delete
)
[283] Fix | Delete
);
[284] Fix | Delete
}
[285] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_load_global_functions_script', 7 );
[286] Fix | Delete
[287] Fix | Delete
function et_builder_load_modules_styles() {
[288] Fix | Delete
$current_page_id = apply_filters( 'et_is_ab_testing_active_post_id', get_the_ID() );
[289] Fix | Delete
$is_fb_enabled = et_core_is_fb_enabled();
[290] Fix | Delete
$ab_tests = function_exists( 'et_builder_ab_get_current_tests' ) ? et_builder_ab_get_current_tests() : array();
[291] Fix | Delete
$is_ab_testing = ! empty( $ab_tests );
[292] Fix | Delete
[293] Fix | Delete
$google_maps_api_url_args = array(
[294] Fix | Delete
'v' => 3,
[295] Fix | Delete
'key' => et_pb_get_google_api_key(),
[296] Fix | Delete
);
[297] Fix | Delete
$google_maps_api_url = add_query_arg( $google_maps_api_url_args, is_ssl() ? 'https://maps.googleapis.com/maps/api/js' : 'http://maps.googleapis.com/maps/api/js' );
[298] Fix | Delete
[299] Fix | Delete
wp_register_script( 'google-maps-api', esc_url_raw( $google_maps_api_url ), array(), ET_BUILDER_VERSION, true );
[300] Fix | Delete
wp_register_script( 'hashchange', ET_BUILDER_URI . '/scripts/ext/jquery.hashchange.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[301] Fix | Delete
wp_register_script( 'salvattore', ET_BUILDER_URI . '/scripts/ext/salvattore.min.js', array(), ET_BUILDER_VERSION, true );
[302] Fix | Delete
wp_register_script( 'easypiechart', ET_BUILDER_URI . '/scripts/ext/jquery.easypiechart.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[303] Fix | Delete
[304] Fix | Delete
wp_enqueue_script( 'divi-fitvids', ET_BUILDER_URI . '/scripts/ext/jquery.fitvids.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[305] Fix | Delete
wp_enqueue_script( 'waypoints', ET_BUILDER_URI . '/scripts/ext/waypoints.min.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[306] Fix | Delete
wp_enqueue_script( 'magnific-popup', ET_BUILDER_URI . '/scripts/ext/jquery.magnific-popup.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[307] Fix | Delete
wp_enqueue_script( 'et-jquery-touch-mobile', ET_BUILDER_URI . '/scripts/ext/jquery.mobile.custom.min.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[308] Fix | Delete
wp_enqueue_script( 'et-builder-modules-script', ET_BUILDER_URI . '/frontend-builder/build/frontend-builder-scripts.js', apply_filters( 'et_pb_frontend_builder_scripts_dependencies', array( 'jquery', 'et-jquery-touch-mobile' ) ), ET_BUILDER_VERSION, true );
[309] Fix | Delete
wp_enqueue_style( 'magnific-popup', ET_BUILDER_URI . '/styles/magnific_popup.css', array(), ET_BUILDER_VERSION );
[310] Fix | Delete
[311] Fix | Delete
$frontend_scripts_data = array(
[312] Fix | Delete
'builderCssContainerPrefix' => ET_BUILDER_CSS_CONTAINER_PREFIX,
[313] Fix | Delete
'builderCssLayoutPrefix' => ET_BUILDER_CSS_LAYOUT_PREFIX,
[314] Fix | Delete
);
[315] Fix | Delete
[316] Fix | Delete
wp_localize_script( 'et-builder-modules-script', 'et_frontend_scripts', $frontend_scripts_data );
[317] Fix | Delete
[318] Fix | Delete
// Load modules wrapper on CPT.
[319] Fix | Delete
// Use get_the_ID() explicitly so we decide based on the first post of an archive page.
[320] Fix | Delete
if ( et_builder_post_is_of_custom_post_type( get_the_ID() ) ) {
[321] Fix | Delete
wp_enqueue_script( 'et-builder-cpt-modules-wrapper', ET_BUILDER_URI . '/scripts/cpt-modules-wrapper.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[322] Fix | Delete
[323] Fix | Delete
$modules_wrapper_data = array(
[324] Fix | Delete
'builderCssContainerPrefix' => ET_BUILDER_CSS_CONTAINER_PREFIX,
[325] Fix | Delete
'builderCssLayoutPrefix' => ET_BUILDER_CSS_LAYOUT_PREFIX,
[326] Fix | Delete
);
[327] Fix | Delete
wp_localize_script( 'et-builder-cpt-modules-wrapper', 'et_modules_wrapper', $modules_wrapper_data );
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
if ( et_builder_has_limitation( 'register_fittext_script' ) ) {
[331] Fix | Delete
wp_register_script( 'fittext', ET_BUILDER_URI . '/scripts/ext/jquery.fittext.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
/**
[335] Fix | Delete
* Builder script handle name
[336] Fix | Delete
*
[337] Fix | Delete
* @since 3.??
[338] Fix | Delete
*
[339] Fix | Delete
* @param string
[340] Fix | Delete
*/
[341] Fix | Delete
$builder_modules_script_handle = apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' );
[342] Fix | Delete
[343] Fix | Delete
// Load main styles CSS file only if the Builder plugin is active
[344] Fix | Delete
if ( et_is_builder_plugin_active() ) {
[345] Fix | Delete
$style_suffix = et_load_unminified_styles() ? '' : '.unified';
[346] Fix | Delete
wp_enqueue_style( 'et-builder-modules-style', ET_BUILDER_URI . '/styles/frontend-builder-plugin-style' . $style_suffix . '.css', array(), ET_BUILDER_VERSION );
[347] Fix | Delete
}
[348] Fix | Delete
[349] Fix | Delete
// Load visible.min.js only if AB testing active on current page OR VB (because post settings is synced between VB and BB)
[350] Fix | Delete
if ( $is_ab_testing || $is_fb_enabled ) {
[351] Fix | Delete
wp_enqueue_script( 'et-jquery-visible-viewport', ET_BUILDER_URI . '/scripts/ext/jquery.visible.min.js', array( 'jquery', $builder_modules_script_handle ), ET_BUILDER_VERSION, true );
[352] Fix | Delete
}
[353] Fix | Delete
[354] Fix | Delete
$pb_custom_data = array(
[355] Fix | Delete
'ajaxurl' => is_ssl() ? admin_url( 'admin-ajax.php' ) : admin_url( 'admin-ajax.php', 'http' ),
[356] Fix | Delete
'images_uri' => get_template_directory_uri() . '/images',
[357] Fix | Delete
'builder_images_uri' => ET_BUILDER_URI . '/images',
[358] Fix | Delete
'et_frontend_nonce' => wp_create_nonce( 'et_frontend_nonce' ),
[359] Fix | Delete
'subscription_failed' => esc_html__( 'Please, check the fields below to make sure you entered the correct information.', 'et_builder' ),
[360] Fix | Delete
'et_ab_log_nonce' => wp_create_nonce( 'et_ab_testing_log_nonce' ),
[361] Fix | Delete
'fill_message' => esc_html__( 'Please, fill in the following fields:', 'et_builder' ),
[362] Fix | Delete
'contact_error_message' => esc_html__( 'Please, fix the following errors:', 'et_builder' ),
[363] Fix | Delete
'invalid' => esc_html__( 'Invalid email', 'et_builder' ),
[364] Fix | Delete
'captcha' => esc_html__( 'Captcha', 'et_builder' ),
[365] Fix | Delete
'prev' => esc_html__( 'Prev', 'et_builder' ),
[366] Fix | Delete
'previous' => esc_html__( 'Previous', 'et_builder' ),
[367] Fix | Delete
'next' => esc_html__( 'Next', 'et_builder' ),
[368] Fix | Delete
'wrong_captcha' => esc_html__( 'You entered the wrong number in captcha.', 'et_builder' ),
[369] Fix | Delete
'wrong_checkbox' => esc_html__( 'Checkbox', 'et_builder' ),
[370] Fix | Delete
'ignore_waypoints' => et_is_ignore_waypoints() ? 'yes' : 'no',
[371] Fix | Delete
'is_divi_theme_used' => function_exists( 'et_divi_fonts_url' ),
[372] Fix | Delete
'widget_search_selector' => apply_filters( 'et_pb_widget_search_selector', '.widget_search' ),
[373] Fix | Delete
'ab_tests' => $ab_tests,
[374] Fix | Delete
'is_ab_testing_active' => $is_ab_testing,
[375] Fix | Delete
'page_id' => $current_page_id,
[376] Fix | Delete
'unique_test_id' => get_post_meta( $current_page_id, '_et_pb_ab_testing_id', true ),
[377] Fix | Delete
'ab_bounce_rate' => '' !== get_post_meta( $current_page_id, '_et_pb_ab_bounce_rate_limit', true ) ? get_post_meta( $current_page_id, '_et_pb_ab_bounce_rate_limit', true ) : 5,
[378] Fix | Delete
'is_cache_plugin_active' => false === et_pb_detect_cache_plugins() ? 'no' : 'yes',
[379] Fix | Delete
'is_shortcode_tracking' => get_post_meta( $current_page_id, '_et_pb_enable_shortcode_tracking', true ),
[380] Fix | Delete
'tinymce_uri' => defined( 'ET_FB_ASSETS_URI' ) ? ET_FB_ASSETS_URI . '/vendors' : '',
[381] Fix | Delete
);
[382] Fix | Delete
[383] Fix | Delete
wp_localize_script( $builder_modules_script_handle, 'et_pb_custom', $pb_custom_data );
[384] Fix | Delete
[385] Fix | Delete
/**
[386] Fix | Delete
* Only load this during builder preview screen session
[387] Fix | Delete
*/
[388] Fix | Delete
if ( is_et_pb_preview() ) {
[389] Fix | Delete
// Set fixed protocol for preview URL to prevent cross origin issue
[390] Fix | Delete
$preview_scheme = is_ssl() ? 'https' : 'http';
[391] Fix | Delete
[392] Fix | Delete
// Get home url, then parse it
[393] Fix | Delete
$preview_origin_component = parse_url( home_url( '', $preview_scheme ) );
[394] Fix | Delete
[395] Fix | Delete
// Rebuild origin URL, strip sub-directory address if there's any (postMessage e.origin doesn't pass sub-directory address)
[396] Fix | Delete
$preview_origin = '';
[397] Fix | Delete
[398] Fix | Delete
// Perform check, prevent unnecessary error
[399] Fix | Delete
if ( isset( $preview_origin_component['scheme'] ) && isset( $preview_origin_component['host'] ) ) {
[400] Fix | Delete
$preview_origin = "{$preview_origin_component['scheme']}://{$preview_origin_component['host']}";
[401] Fix | Delete
[402] Fix | Delete
// Append port number if different port number is being used
[403] Fix | Delete
if ( isset( $preview_origin_component['port'] ) ) {
[404] Fix | Delete
$preview_origin = "{$preview_origin}:{$preview_origin_component['port']}";
[405] Fix | Delete
}
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
// Enqueue theme's style.css if it hasn't been enqueued (possibly being hardcoded by theme)
[409] Fix | Delete
if ( ! et_builder_has_theme_style_enqueued() && et_builder_has_limitation( 'force_enqueue_theme_style' ) ) {
[410] Fix | Delete
wp_enqueue_style( 'et-builder-theme-style-css', get_stylesheet_uri(), array() );
[411] Fix | Delete
}
[412] Fix | Delete
[413] Fix | Delete
wp_enqueue_style( 'et-builder-preview-style', ET_BUILDER_URI . '/styles/preview.css', array(), ET_BUILDER_VERSION );
[414] Fix | Delete
wp_enqueue_script( 'et-builder-preview-script', ET_BUILDER_URI . '/frontend-builder/build/frontend-builder-preview.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[415] Fix | Delete
[416] Fix | Delete
$preview_params_data = array(
[417] Fix | Delete
'preview_origin' => esc_url( $preview_origin ),
[418] Fix | Delete
'alert_origin_not_matched' => sprintf(
[419] Fix | Delete
esc_html__( 'Unauthorized access. Preview cannot be accessed outside %1$s.', 'et_builder' ),
[420] Fix | Delete
esc_url( home_url( '', $preview_scheme ) )
[421] Fix | Delete
),
[422] Fix | Delete
);
[423] Fix | Delete
[424] Fix | Delete
wp_localize_script( 'et-builder-preview-script', 'et_preview_params', $preview_params_data );
[425] Fix | Delete
}
[426] Fix | Delete
}
[427] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_load_modules_styles', 11 );
[428] Fix | Delete
[429] Fix | Delete
function et_builder_get_modules_js_data() {
[430] Fix | Delete
// Data shouldn't be loaded in Builder, so always pass an empty array there.
[431] Fix | Delete
$animation_data = et_core_is_fb_enabled() ? array() : et_builder_handle_animation_data();
[432] Fix | Delete
$animation_data_json = json_encode( $animation_data );
[433] Fix | Delete
[434] Fix | Delete
$link_options_data = et_core_is_fb_enabled() ? array() : et_builder_handle_link_options_data();
[435] Fix | Delete
$link_options_data_json = json_encode( $link_options_data );
[436] Fix | Delete
[437] Fix | Delete
if ( empty( $animation_data ) && empty( $link_options_data ) ) {
[438] Fix | Delete
return;
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
?>
[442] Fix | Delete
<script type="text/javascript">
[443] Fix | Delete
<?php if ( $animation_data ) : ?>
[444] Fix | Delete
var et_animation_data = <?php echo et_core_esc_previously( $animation_data_json ); ?>;
[445] Fix | Delete
<?php
[446] Fix | Delete
endif;
[447] Fix | Delete
[448] Fix | Delete
if ( $link_options_data ) :
[449] Fix | Delete
?>
[450] Fix | Delete
var et_link_options_data = <?php echo et_core_esc_previously( $link_options_data_json ); ?>;
[451] Fix | Delete
<?php endif; ?>
[452] Fix | Delete
</script>
[453] Fix | Delete
<?php
[454] Fix | Delete
}
[455] Fix | Delete
add_action( 'wp_footer', 'et_builder_get_modules_js_data' );
[456] Fix | Delete
[457] Fix | Delete
// Force Backbone templates cache to be cleared on language change to make sure the settings modal is translated
[458] Fix | Delete
// defaults for arguments are provided because their number is different for both the actions
[459] Fix | Delete
function et_pb_force_clear_template_cache( $meta_id = false, $object_id = false, $meta_key = false, $_meta_value = false ) {
[460] Fix | Delete
$current_action = current_action();
[461] Fix | Delete
[462] Fix | Delete
if ( ( 'updated_user_meta' === $current_action && 'locale' === $meta_key ) || 'update_option_WPLANG' === $current_action ) {
[463] Fix | Delete
et_update_option( 'et_pb_clear_templates_cache', true );
[464] Fix | Delete
}
[465] Fix | Delete
}
[466] Fix | Delete
add_action( 'update_option_WPLANG', 'et_pb_force_clear_template_cache' );
[467] Fix | Delete
add_action( 'updated_user_meta', 'et_pb_force_clear_template_cache', 10, 4 );
[468] Fix | Delete
[469] Fix | Delete
function et_builder_handle_animation_data( $element_data = false ) {
[470] Fix | Delete
static $data = array();
[471] Fix | Delete
static $data_classes = array();
[472] Fix | Delete
[473] Fix | Delete
if ( ! $element_data ) {
[474] Fix | Delete
return $data;
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
// This should not be possible but let's be safe
[478] Fix | Delete
if ( empty( $element_data['class'] ) ) {
[479] Fix | Delete
return;
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
// Prevent duplication animation data entries created by global modules
[483] Fix | Delete
if ( in_array( $element_data['class'], $data_classes ) ) {
[484] Fix | Delete
return;
[485] Fix | Delete
}
[486] Fix | Delete
[487] Fix | Delete
$data[] = et_core_esc_previously( $element_data );
[488] Fix | Delete
$data_classes[] = et_core_esc_previously( $element_data['class'] );
[489] Fix | Delete
}
[490] Fix | Delete
[491] Fix | Delete
function et_builder_handle_link_options_data( $element_data = false ) {
[492] Fix | Delete
static $data = array();
[493] Fix | Delete
static $data_classes = array();
[494] Fix | Delete
[495] Fix | Delete
if ( ! $element_data ) {
[496] Fix | Delete
return $data;
[497] Fix | Delete
}
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function