Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../themes/Divi/includes/builder/frontend...
File: assets.php
<?php
[0] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_enqueue_assets_head' );
[1] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_enqueue_assets_main' );
[2] Fix | Delete
[3] Fix | Delete
function et_fb_enqueue_google_maps_dependency( $dependencies ) {
[4] Fix | Delete
[5] Fix | Delete
if ( et_pb_enqueue_google_maps_script() ) {
[6] Fix | Delete
$dependencies[] = 'google-maps-api';
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
return $dependencies;
[10] Fix | Delete
}
[11] Fix | Delete
add_filter( 'et_fb_bundle_dependencies', 'et_fb_enqueue_google_maps_dependency' );
[12] Fix | Delete
[13] Fix | Delete
function et_fb_load_portability() {
[14] Fix | Delete
et_core_register_admin_assets();
[15] Fix | Delete
et_core_load_component( 'portability' );
[16] Fix | Delete
[17] Fix | Delete
// Register the Builder individual layouts portability.
[18] Fix | Delete
et_core_portability_register( 'et_builder', array(
[19] Fix | Delete
'name' => esc_html__( 'Divi Builder Layout', 'et_builder' ),
[20] Fix | Delete
'type' => 'post',
[21] Fix | Delete
'view' => true,
[22] Fix | Delete
) );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
function et_fb_get_dynamic_asset( $prefix, $post_type = false, $update = false ) {
[26] Fix | Delete
[27] Fix | Delete
if ( false === $post_type ) {
[28] Fix | Delete
global $post;
[29] Fix | Delete
$post_type = isset( $post->post_type ) ? $post->post_type : 'post';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$post_type = apply_filters( 'et_builder_cache_post_type', $post_type, $prefix );
[33] Fix | Delete
[34] Fix | Delete
$post_type = sanitize_file_name( $post_type );
[35] Fix | Delete
[36] Fix | Delete
if ( ! in_array( $prefix, array( 'helpers', 'definitions' ) ) ) {
[37] Fix | Delete
$prefix = '';
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
// Per language Cache due to definitions/helpers being localized.
[41] Fix | Delete
$lang = sanitize_file_name( get_user_locale() );
[42] Fix | Delete
$cache = sprintf( '%s/%s', ET_Core_PageResource::get_cache_directory(), $lang );
[43] Fix | Delete
$files = glob( sprintf( '%s/%s-%s-*.js', $cache, $prefix, $post_type ) );
[44] Fix | Delete
$exists = is_array( $files ) && count( $files ) > 0;
[45] Fix | Delete
[46] Fix | Delete
if ( $exists ) {
[47] Fix | Delete
$file = $files[0];
[48] Fix | Delete
$uniq = array_reverse( explode( '-', basename( $file, '.js' ) ) );
[49] Fix | Delete
$uniq = $uniq[0];
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
$updated = false;
[53] Fix | Delete
[54] Fix | Delete
if ( $update || ! $exists ) {
[55] Fix | Delete
// Make sure cache folder exists
[56] Fix | Delete
wp_mkdir_p( $cache );
[57] Fix | Delete
[58] Fix | Delete
// We (currently) use just 2 prefixes: 'helpers' and 'definitions'.
[59] Fix | Delete
// Each prefix has its content generated via a custom function called via the hook system:
[60] Fix | Delete
// add_filter( 'et_fb_get_asset_definitions', 'et_fb_get_asset_definitions', 10, 2 );
[61] Fix | Delete
// add_filter( 'et_fb_get_asset_helpers', 'et_fb_get_asset_helpers', 10, 2 );
[62] Fix | Delete
$content = apply_filters( "et_fb_get_asset_$prefix", false, $post_type );
[63] Fix | Delete
if ( $exists && $update ) {
[64] Fix | Delete
// Compare with old one (when a previous version exists)
[65] Fix | Delete
$update = et_()->WPFS()->get_contents( $file ) !== $content;
[66] Fix | Delete
}
[67] Fix | Delete
if ( ( $update || ! $exists ) ) {
[68] Fix | Delete
[69] Fix | Delete
if ( ET_BUILDER_KEEP_OLDEST_CACHED_ASSETS && count( $files ) > 0 ) {
[70] Fix | Delete
// Files are ordered by timestamp, first one is always the oldest
[71] Fix | Delete
array_shift( $files );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
if ( ET_BUILDER_PURGE_OLD_CACHED_ASSETS ) {
[75] Fix | Delete
foreach ( $files as $file ) {
[76] Fix | Delete
// Delete old version.
[77] Fix | Delete
@unlink( $file );
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
// Write the file only if it did not exist or its content changed
[82] Fix | Delete
$uniq = str_replace( '.', '', (string) microtime( true ) );
[83] Fix | Delete
$file = sprintf( '%s/%s-%s-%s.js', $cache, $prefix, $post_type, $uniq );
[84] Fix | Delete
[85] Fix | Delete
if ( wp_is_writable( dirname( $file ) ) && et_()->WPFS()->put_contents( $file, $content ) ) {
[86] Fix | Delete
$updated = true;
[87] Fix | Delete
$exists = true;
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
$url = ! $exists ? false : sprintf(
[93] Fix | Delete
'%s/%s-%s-%s.js',
[94] Fix | Delete
et_()->path( et_core_cache_dir()->url, $lang ),
[95] Fix | Delete
$prefix,
[96] Fix | Delete
$post_type,
[97] Fix | Delete
$uniq
[98] Fix | Delete
);
[99] Fix | Delete
[100] Fix | Delete
return array(
[101] Fix | Delete
'url' => $url,
[102] Fix | Delete
'updated' => $updated,
[103] Fix | Delete
);
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
function et_fb_backend_helpers_boot( $helpers ) {
[107] Fix | Delete
$helpers['boot'] = 'fast';
[108] Fix | Delete
return $helpers;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
function et_fb_app_only_bundle_deps( $deps = null ) {
[112] Fix | Delete
static $_deps = array();
[113] Fix | Delete
[114] Fix | Delete
// Set deps if argument is passed.
[115] Fix | Delete
if ( $deps ) {
[116] Fix | Delete
// Some bundle deps are still required in top window.
[117] Fix | Delete
$top = array(
[118] Fix | Delete
'jquery',
[119] Fix | Delete
'underscore',
[120] Fix | Delete
'jquery-ui-core',
[121] Fix | Delete
'jquery-ui-draggable',
[122] Fix | Delete
'jquery-ui-resizable',
[123] Fix | Delete
'jquery-ui-sortable',
[124] Fix | Delete
'jquery-effects-core',
[125] Fix | Delete
'iris',
[126] Fix | Delete
'wp-color-picker',
[127] Fix | Delete
'wp-color-picker-alpha',
[128] Fix | Delete
'et-profiler',
[129] Fix | Delete
'react-tiny-mce',
[130] Fix | Delete
'et_pb_admin_date_addon_js',
[131] Fix | Delete
'google-maps-api',
[132] Fix | Delete
'react',
[133] Fix | Delete
'react-dom',
[134] Fix | Delete
'wp-hooks',
[135] Fix | Delete
[136] Fix | Delete
// If minified JS is served, minified JS script name is outputted instead
[137] Fix | Delete
apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' )
[138] Fix | Delete
);
[139] Fix | Delete
$_deps = array_diff( $deps, $top );
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
return $_deps;
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
function et_fb_enqueue_assets() {
[146] Fix | Delete
global $wp_version;
[147] Fix | Delete
[148] Fix | Delete
et_fb_load_portability();
[149] Fix | Delete
[150] Fix | Delete
$ver = ET_BUILDER_VERSION;
[151] Fix | Delete
$root = ET_BUILDER_URI;
[152] Fix | Delete
$app = ET_FB_URI;
[153] Fix | Delete
$assets = ET_FB_ASSETS_URI;
[154] Fix | Delete
[155] Fix | Delete
// Get WP major version
[156] Fix | Delete
$wp_major_version = substr( $wp_version, 0, 3 );
[157] Fix | Delete
[158] Fix | Delete
wp_register_script( 'react-tiny-mce', "{$assets}/vendors/tinymce.min.js" );
[159] Fix | Delete
[160] Fix | Delete
if ( version_compare( $wp_major_version, '4.5', '<' ) ) {
[161] Fix | Delete
$jQuery_ui = 'et_pb_admin_date_js';
[162] Fix | Delete
wp_register_script( $jQuery_ui, "{$root}/scripts/ext/jquery-ui-1.10.4.custom.min.js", array( 'jquery' ), $ver, true );
[163] Fix | Delete
} else {
[164] Fix | Delete
$jQuery_ui = 'jquery-ui-datepicker';
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
wp_register_script( 'et_pb_admin_date_addon_js', "{$root}/scripts/ext/jquery-ui-timepicker-addon.js", array( $jQuery_ui ), $ver, true );
[168] Fix | Delete
[169] Fix | Delete
// `wp-shortcode` script handle is used by Gutenberg
[170] Fix | Delete
wp_register_script( 'et-wp-shortcode', includes_url() . 'js/shortcode.js', array(), $wp_version );
[171] Fix | Delete
[172] Fix | Delete
wp_register_script( 'jquery-tablesorter', ET_BUILDER_URI . '/scripts/ext/jquery.tablesorter.min.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[173] Fix | Delete
[174] Fix | Delete
wp_register_script( 'chart', ET_BUILDER_URI . '/scripts/ext/chart.min.js', array(), ET_BUILDER_VERSION, true );
[175] Fix | Delete
[176] Fix | Delete
/** This filter is documented in includes/builder/framework.php */
[177] Fix | Delete
$builder_modules_script_handle = apply_filters( 'et_builder_modules_script_handle', 'et-builder-modules-script' );
[178] Fix | Delete
[179] Fix | Delete
$dependencies_list = array(
[180] Fix | Delete
'jquery',
[181] Fix | Delete
'jquery-ui-core',
[182] Fix | Delete
'jquery-ui-draggable',
[183] Fix | Delete
'jquery-ui-resizable',
[184] Fix | Delete
'underscore',
[185] Fix | Delete
'jquery-ui-sortable',
[186] Fix | Delete
'jquery-effects-core',
[187] Fix | Delete
'iris',
[188] Fix | Delete
'wp-color-picker',
[189] Fix | Delete
'wp-color-picker-alpha',
[190] Fix | Delete
'et_pb_admin_date_addon_js',
[191] Fix | Delete
'et-wp-shortcode',
[192] Fix | Delete
'heartbeat',
[193] Fix | Delete
'wp-mediaelement',
[194] Fix | Delete
'jquery-tablesorter',
[195] Fix | Delete
'chart',
[196] Fix | Delete
'react',
[197] Fix | Delete
'react-dom',
[198] Fix | Delete
'react-tiny-mce',
[199] Fix | Delete
$builder_modules_script_handle,
[200] Fix | Delete
);
[201] Fix | Delete
[202] Fix | Delete
if ( ! wp_script_is( 'wp-hooks', 'registered' ) ) {
[203] Fix | Delete
// Use bundled wp-hooks script when WP < 5.0
[204] Fix | Delete
wp_register_script( 'wp-hooks', "{$assets}/backports/hooks.js" );
[205] Fix | Delete
$dependencies_list[] = 'wp-hooks';
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
// Add dependency on et-shortcode-js only if Divi Theme is used or ET Shortcodes plugin activated
[209] Fix | Delete
if ( ! et_is_builder_plugin_active() || et_is_shortcodes_plugin_active() ) {
[210] Fix | Delete
$dependencies_list[] = 'et-shortcodes-js';
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
$cached_assets_deps = array();
[214] Fix | Delete
if ( defined( 'ET_BUILDER_CACHE_ASSETS' ) && ET_BUILDER_CACHE_ASSETS ) {
[215] Fix | Delete
// Use cached files for helpers and definitions
[216] Fix | Delete
foreach ( array( 'helpers', 'definitions' ) as $asset ) {
[217] Fix | Delete
if ( $url = et_()->array_get( et_fb_get_dynamic_asset( $asset ), 'url' ) ) {
[218] Fix | Delete
// The asset exists, we can add it to bundle's dependencies
[219] Fix | Delete
$key = "et-dynamic-asset-$asset";
[220] Fix | Delete
/**
[221] Fix | Delete
* Filters the dependencies of cached assets.
[222] Fix | Delete
*
[223] Fix | Delete
* @since ?
[224] Fix | Delete
*
[225] Fix | Delete
* @param array $deps.
[226] Fix | Delete
* @param string $key.
[227] Fix | Delete
*/
[228] Fix | Delete
$deps = apply_filters( 'et_builder_dynamic_asset_deps', array(), $key );
[229] Fix | Delete
$cached_assets_deps = array_merge( $cached_assets_deps, $deps );
[230] Fix | Delete
wp_register_script( $key, $url, $deps, ET_BUILDER_VERSION );
[231] Fix | Delete
$dependencies_list[] = $key;
[232] Fix | Delete
}
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
$fb_bundle_dependencies = apply_filters( 'et_fb_bundle_dependencies', $dependencies_list );
[237] Fix | Delete
[238] Fix | Delete
// Adding concatenated script as dependencies for script debugging
[239] Fix | Delete
if ( et_load_unminified_scripts() ) {
[240] Fix | Delete
array_push( $fb_bundle_dependencies,
[241] Fix | Delete
'easypiechart',
[242] Fix | Delete
'salvattore',
[243] Fix | Delete
'hashchange'
[244] Fix | Delete
);
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
if ( et_pb_enqueue_google_maps_script() ) {
[248] Fix | Delete
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 );
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
// enqueue the Avada script before 'et-frontend-builder' to make sure easypiechart ( and probably some others ) override the scripts from Avada.
[252] Fix | Delete
if ( wp_script_is( 'avada' ) ) {
[253] Fix | Delete
// dequeue Avada script
[254] Fix | Delete
wp_dequeue_script( 'avada' );
[255] Fix | Delete
// enqueue it before 'et-frontend-builder'
[256] Fix | Delete
wp_enqueue_script( 'avada' );
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
et_fb_enqueue_react();
[260] Fix | Delete
[261] Fix | Delete
// Detect if it's a production build by checking if `bundle.css` exists.
[262] Fix | Delete
$is_production = file_exists( sprintf( '%sfrontend-builder/build/bundle.css', ET_BUILDER_DIR ) );
[263] Fix | Delete
$external_assets = wp_script_is( 'et-dynamic-asset-helpers', 'registered' );
[264] Fix | Delete
[265] Fix | Delete
if ( $is_production && $external_assets && ! et_builder_bfb_enabled() && ! et_builder_tb_enabled() ) {
[266] Fix | Delete
// Set bundle deps.
[267] Fix | Delete
et_fb_app_only_bundle_deps( array_merge( $fb_bundle_dependencies, $cached_assets_deps ) );
[268] Fix | Delete
add_filter( 'script_loader_tag', 'et_fb_app_src', 10, 3 );
[269] Fix | Delete
// Enqueue the top window VB boot script.
[270] Fix | Delete
et_fb_enqueue_bundle( 'et-frontend-builder', 'boot.js', $fb_bundle_dependencies );
[271] Fix | Delete
// Add boot mode to helpers.
[272] Fix | Delete
add_filter( 'et_fb_backend_helpers', 'et_fb_backend_helpers_boot' );
[273] Fix | Delete
} else {
[274] Fix | Delete
// Enqueue the appropriate bundle js (hot/start/build)
[275] Fix | Delete
et_fb_enqueue_bundle( 'et-frontend-builder', 'bundle.js', $fb_bundle_dependencies );
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
// Search for additional bundles
[279] Fix | Delete
$additional_bundles = array();
[280] Fix | Delete
// CSS is now splitted as well.
[281] Fix | Delete
foreach ( array_merge(
[282] Fix | Delete
glob( ET_BUILDER_DIR . 'frontend-builder/build/bundle.*.css' ),
[283] Fix | Delete
glob( ET_BUILDER_DIR . 'frontend-builder/build/bundle.*.js' )
[284] Fix | Delete
) as $chunk ) {
[285] Fix | Delete
$additional_bundles[] = "{$app}/build/" . basename( $chunk );
[286] Fix | Delete
}
[287] Fix | Delete
// Pass bundle path and additional bundles to preload
[288] Fix | Delete
wp_localize_script( 'et-frontend-builder', 'et_webpack_bundle', array(
[289] Fix | Delete
'path' => "{$app}/build/",
[290] Fix | Delete
'preload' => $additional_bundles,
[291] Fix | Delete
));
[292] Fix | Delete
[293] Fix | Delete
// Enqueue failure notice script.
[294] Fix | Delete
wp_enqueue_script( 'et-frontend-builder-failure', "{$assets}/scripts/failure_notice.js", array(), ET_BUILDER_PRODUCT_VERSION, true );
[295] Fix | Delete
wp_localize_script( 'et-frontend-builder-failure', 'et_fb_options', array(
[296] Fix | Delete
'ajaxurl' => admin_url( 'admin-ajax.php' ),
[297] Fix | Delete
'et_admin_load_nonce' => wp_create_nonce( 'et_admin_load_nonce' ),
[298] Fix | Delete
'memory_limit_increased' => esc_html__( 'Your memory limit has been increased', 'et_builder' ),
[299] Fix | Delete
'memory_limit_not_increased' => esc_html__( "Your memory limit can't be changed automatically", 'et_builder' ),
[300] Fix | Delete
) );
[301] Fix | Delete
[302] Fix | Delete
// WP Auth Check (allows user to log in again when session expires).
[303] Fix | Delete
wp_enqueue_style( 'wp-auth-check' );
[304] Fix | Delete
wp_enqueue_script( 'wp-auth-check' );
[305] Fix | Delete
add_action( 'wp_print_footer_scripts', 'et_fb_output_wp_auth_check_html', 5 );
[306] Fix | Delete
[307] Fix | Delete
do_action( 'et_fb_enqueue_assets' );
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
function et_fb_app_src( $tag, $handle, $src ) {
[311] Fix | Delete
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript
[312] Fix | Delete
// Replace boot with bundle in app window.
[313] Fix | Delete
if ( 'et-frontend-builder' === $handle ) {
[314] Fix | Delete
$bundle_url = esc_url( str_replace( 'boot.js', 'bundle.js', $src ) );
[315] Fix | Delete
return str_replace( 'src=', sprintf( 'data-et-vb-app-src="%1$s" src=', $bundle_url ), $tag );
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
// Only load (most) bundle deps in app window.
[319] Fix | Delete
if ( in_array( $handle, et_fb_app_only_bundle_deps() )) {
[320] Fix | Delete
return sprintf( '<script data-et-vb-app-src="%1$s"></script>', esc_url( $src ) );
[321] Fix | Delete
}
[322] Fix | Delete
return $tag;
[323] Fix | Delete
// phpcs:enable
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
/**
[327] Fix | Delete
* Disable admin bar styling for HTML in VB. BFB doesn't loaded admin bar and VB loads admin bar
[328] Fix | Delete
* on top window which makes built-in admin bar styling irrelevant because admin bar is affected by
[329] Fix | Delete
* top window width instead of app window width (while app window width changes based on preview mode)
[330] Fix | Delete
*
[331] Fix | Delete
* @see _admin_bar_bump_cb()
[332] Fix | Delete
*/
[333] Fix | Delete
function et_fb_disable_admin_bar_style() {
[334] Fix | Delete
add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );
[335] Fix | Delete
}
[336] Fix | Delete
add_action( 'wp', 'et_fb_disable_admin_bar_style', 15 );
[337] Fix | Delete
[338] Fix | Delete
[339] Fix | Delete
function et_fb_output_wp_auth_check_html() {
[340] Fix | Delete
// A <button> element is used for the close button which looks ugly in Chrome. Use <a> element instead.
[341] Fix | Delete
ob_start();
[342] Fix | Delete
wp_auth_check_html();
[343] Fix | Delete
$output = ob_get_contents();
[344] Fix | Delete
ob_end_clean();
[345] Fix | Delete
[346] Fix | Delete
$output = str_replace(
[347] Fix | Delete
array( '<button type="button"', '</button>' ),
[348] Fix | Delete
array( '<a href="#"', '</a>' ),
[349] Fix | Delete
$output
[350] Fix | Delete
);
[351] Fix | Delete
[352] Fix | Delete
echo et_core_intentionally_unescaped( $output, 'html' );
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
[356] Fix | Delete
function et_fb_set_editor_available_cookie() {
[357] Fix | Delete
global $post;
[358] Fix | Delete
$post_id = isset( $post->ID ) ? $post->ID : false;
[359] Fix | Delete
if ( ! headers_sent() && !empty( $post_id ) ) {
[360] Fix | Delete
setcookie( 'et-editor-available-post-' . $post_id . '-fb', 'fb', time() + ( MINUTE_IN_SECONDS * 30 ), SITECOOKIEPATH, false, is_ssl() );
[361] Fix | Delete
}
[362] Fix | Delete
}
[363] Fix | Delete
add_action( 'et_fb_framework_loaded', 'et_fb_set_editor_available_cookie' );
[364] Fix | Delete
[365] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function