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/clone/wp-conte.../themes/Divi/includes/builder/frontend...
File: view.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Boots Frond End Builder App,
[3] Fix | Delete
*
[4] Fix | Delete
* @return string Front End Builder wrap if main query, $content otherwise.
[5] Fix | Delete
*/
[6] Fix | Delete
function et_fb_app_boot( $content ) {
[7] Fix | Delete
// Instances of React app
[8] Fix | Delete
static $instances = 0;
[9] Fix | Delete
$is_new_page = isset( $_GET['is_new_page'] ) && '1' === $_GET['is_new_page'];
[10] Fix | Delete
[11] Fix | Delete
$main_query_post = ET_Post_Stack::get_main_post();
[12] Fix | Delete
$main_query_post_type = $main_query_post ? $main_query_post->post_type : '';
[13] Fix | Delete
[14] Fix | Delete
if ( ET_Builder_Element::is_theme_builder_layout() && ! et_theme_builder_is_layout_post_type( $main_query_post_type ) ) {
[15] Fix | Delete
// Prevent boot if we are rendering a TB layout and not the real WP Query post.
[16] Fix | Delete
return $content;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
// Don't boot the app if the builder is not in use
[20] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( get_the_ID() ) || doing_filter( 'get_the_excerpt' ) ) {
[21] Fix | Delete
// Skip this when content should be loaded from other post or page to not mess with the default content
[22] Fix | Delete
if ( $is_new_page ) {
[23] Fix | Delete
return;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
return $content;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
$class = apply_filters( 'et_fb_app_preloader_class', 'et-fb-page-preloading' );
[30] Fix | Delete
[31] Fix | Delete
if ( '' !== $class ) {
[32] Fix | Delete
$class = sprintf( ' class="%1$s"', esc_attr( $class ) );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
// Only return React app wrapper for the main query.
[36] Fix | Delete
if ( is_main_query() ) {
[37] Fix | Delete
// Keep track of instances in case is_main_query() is true multiple times for the same page
[38] Fix | Delete
// This happens in 2017 theme when multiple Divi enabled pages are assigned to Front Page Sections
[39] Fix | Delete
$instances++;
[40] Fix | Delete
$output = sprintf( '<div id="et-fb-app"%1$s></div>', $class );
[41] Fix | Delete
// No need to add fallback content on a new page.
[42] Fix | Delete
if ( $instances > 1 && ! $is_new_page ) {
[43] Fix | Delete
// uh oh, we might have multiple React app in the same page, let's also add rendered content and deal with it later using JS
[44] Fix | Delete
$output .= sprintf( '<div class="et_fb_fallback_content" style="display: none">%s</div>', $content );
[45] Fix | Delete
// Stop shortcode object processor so that shortcode in the content are treated normaly.
[46] Fix | Delete
et_fb_reset_shortcode_object_processing();
[47] Fix | Delete
}
[48] Fix | Delete
return $output;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
// Stop shortcode object processor so that shortcode in the content are treated normaly.
[52] Fix | Delete
et_fb_reset_shortcode_object_processing();
[53] Fix | Delete
[54] Fix | Delete
return $content;
[55] Fix | Delete
}
[56] Fix | Delete
add_filter( 'the_content', 'et_fb_app_boot', 1 );
[57] Fix | Delete
add_filter( 'et_builder_render_layout', 'et_fb_app_boot', 1 );
[58] Fix | Delete
[59] Fix | Delete
function et_fb_wp_nav_menu( $menu ) {
[60] Fix | Delete
// Ensure we fix any unclosed HTML tags in menu since they would break the VB
[61] Fix | Delete
return et_core_fix_unclosed_html_tags( $menu );
[62] Fix | Delete
}
[63] Fix | Delete
add_filter( 'wp_nav_menu', 'et_fb_wp_nav_menu' );
[64] Fix | Delete
[65] Fix | Delete
function et_builder_maybe_include_bfb_template( $template ) {
[66] Fix | Delete
if ( et_builder_bfb_enabled() && ! is_admin() ) {
[67] Fix | Delete
return ET_BUILDER_DIR . 'frontend-builder/bfb-template.php';
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
return $template;
[71] Fix | Delete
}
[72] Fix | Delete
add_filter( 'template_include', 'et_builder_maybe_include_bfb_template', 99 );
[73] Fix | Delete
[74] Fix | Delete
[75] Fix | Delete
function et_fb_dynamic_sidebar_ob_start() {
[76] Fix | Delete
global $et_fb_dynamic_sidebar_buffering;
[77] Fix | Delete
[78] Fix | Delete
if ( $et_fb_dynamic_sidebar_buffering ) {
[79] Fix | Delete
echo force_balance_tags( ob_get_clean() );
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
$et_fb_dynamic_sidebar_buffering = true;
[83] Fix | Delete
[84] Fix | Delete
ob_start();
[85] Fix | Delete
}
[86] Fix | Delete
add_action( 'dynamic_sidebar', 'et_fb_dynamic_sidebar_ob_start' );
[87] Fix | Delete
[88] Fix | Delete
function et_fb_dynamic_sidebar_after_ob_get_clean() {
[89] Fix | Delete
global $et_fb_dynamic_sidebar_buffering;
[90] Fix | Delete
[91] Fix | Delete
if ( $et_fb_dynamic_sidebar_buffering ) {
[92] Fix | Delete
echo force_balance_tags( ob_get_clean() );
[93] Fix | Delete
[94] Fix | Delete
$et_fb_dynamic_sidebar_buffering = false;
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
add_action( 'dynamic_sidebar_after', 'et_fb_dynamic_sidebar_after_ob_get_clean' );
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Added frontend builder assets.
[101] Fix | Delete
* Note: loading assets on head is way too early, computedVars returns undefined on header.
[102] Fix | Delete
*
[103] Fix | Delete
* @return void
[104] Fix | Delete
*/
[105] Fix | Delete
function et_fb_wp_footer() {
[106] Fix | Delete
et_fb_enqueue_assets();
[107] Fix | Delete
[108] Fix | Delete
// TODO: this is specific to Audio Module and we should conditionally call it once we have
[109] Fix | Delete
// $content set as an object, we can then to a check whether the audio module is
[110] Fix | Delete
// present.
[111] Fix | Delete
remove_all_filters( 'wp_audio_shortcode_library' );
[112] Fix | Delete
remove_all_filters( 'wp_audio_shortcode' );
[113] Fix | Delete
remove_all_filters( 'wp_audio_shortcode_class');
[114] Fix | Delete
}
[115] Fix | Delete
add_action( 'wp_footer', 'et_fb_wp_footer' );
[116] Fix | Delete
[117] Fix | Delete
/**
[118] Fix | Delete
* Added frontend builder specific body class
[119] Fix | Delete
* @todo load conditionally, only when the frontend builder is used
[120] Fix | Delete
*
[121] Fix | Delete
* @param array initial <body> classes
[122] Fix | Delete
* @return array modified <body> classes
[123] Fix | Delete
*/
[124] Fix | Delete
function et_fb_add_body_class( $classes ) {
[125] Fix | Delete
$classes[] = 'et-fb';
[126] Fix | Delete
[127] Fix | Delete
if ( is_rtl() && 'on' === et_get_option( 'divi_disable_translations', 'off' ) ) {
[128] Fix | Delete
$classes[] = 'et-fb-no-rtl';
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[132] Fix | Delete
$classes[] = 'et-bfb';
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if ( et_builder_tb_enabled() ) {
[136] Fix | Delete
$classes[] = 'et-tb';
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
return $classes;
[140] Fix | Delete
}
[141] Fix | Delete
add_filter( 'body_class', 'et_fb_add_body_class' );
[142] Fix | Delete
[143] Fix | Delete
/**
[144] Fix | Delete
* Added BFB specific body class
[145] Fix | Delete
* @todo load conditionally, only when the frontend builder is used
[146] Fix | Delete
*
[147] Fix | Delete
* @param string initial <body> classes
[148] Fix | Delete
* @return string modified <body> classes
[149] Fix | Delete
*/
[150] Fix | Delete
function et_fb_add_admin_body_class( $classes ) {
[151] Fix | Delete
if ( is_rtl() && 'on' === et_get_option( 'divi_disable_translations', 'off' ) ) {
[152] Fix | Delete
$classes .= ' et-fb-no-rtl';
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[156] Fix | Delete
$classes .= ' et-bfb';
[157] Fix | Delete
[158] Fix | Delete
$post_id = et_core_page_resource_get_the_ID();
[159] Fix | Delete
$post_type = get_post_type( $post_id );
[160] Fix | Delete
[161] Fix | Delete
// Add layout classes when on library page
[162] Fix | Delete
if ( 'et_pb_layout' === $post_type ) {
[163] Fix | Delete
$layout_type = et_fb_get_layout_type( $post_id );
[164] Fix | Delete
$layout_scope = et_fb_get_layout_term_slug( $post_id, 'scope' );
[165] Fix | Delete
[166] Fix | Delete
$classes .= " et_pb_library_page_top-${layout_type}";
[167] Fix | Delete
$classes .= " et_pb_library_page_top-${layout_scope}";
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
return $classes;
[172] Fix | Delete
}
[173] Fix | Delete
add_filter( 'admin_body_class', 'et_fb_add_admin_body_class' );
[174] Fix | Delete
[175] Fix | Delete
/**
[176] Fix | Delete
* Remove visual builder preloader classname on BFB because BFB spins the preloader on parent level to avoid flash of unstyled elements
[177] Fix | Delete
*
[178] Fix | Delete
* @param string builder preloader classname
[179] Fix | Delete
* @return string modified builder preloader classname
[180] Fix | Delete
*/
[181] Fix | Delete
function et_bfb_app_preloader_class( $classname ) {
[182] Fix | Delete
return et_builder_bfb_enabled() ? '' : $classname;
[183] Fix | Delete
}
[184] Fix | Delete
add_filter( 'et_fb_app_preloader_class', 'et_bfb_app_preloader_class' );
[185] Fix | Delete
[186] Fix | Delete
function et_builder_inject_preboot_script() {
[187] Fix | Delete
$et_debug = defined( 'ET_DEBUG' ) && ET_DEBUG;
[188] Fix | Delete
$preboot = array(
[189] Fix | Delete
'debug' => $et_debug || DiviExtensions::is_debugging_extension(),
[190] Fix | Delete
'is_BFB' => et_builder_bfb_enabled(),
[191] Fix | Delete
'is_TB' => et_builder_tb_enabled(),
[192] Fix | Delete
);
[193] Fix | Delete
[194] Fix | Delete
$preboot_path = ET_BUILDER_DIR . 'frontend-builder/build/preboot.js';
[195] Fix | Delete
if ( file_exists( $preboot_path ) ) {
[196] Fix | Delete
$preboot_script = et_()->WPFS()->get_contents( $preboot_path );
[197] Fix | Delete
} else {
[198] Fix | Delete
// if the file doesn't exists, it means we're using `yarn hot`
[199] Fix | Delete
$site_url = wp_parse_url( get_site_url() );
[200] Fix | Delete
$hot = "{$site_url['scheme']}://{$site_url['host']}:31495/preboot.js";
[201] Fix | Delete
$curl = curl_init();
[202] Fix | Delete
curl_setopt_array(
[203] Fix | Delete
$curl,
[204] Fix | Delete
array(
[205] Fix | Delete
CURLOPT_RETURNTRANSFER => 1,
[206] Fix | Delete
CURLOPT_URL => $hot,
[207] Fix | Delete
)
[208] Fix | Delete
);
[209] Fix | Delete
$preboot_script = curl_exec( $curl );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
echo "
[213] Fix | Delete
<script id='et-builder-preboot'>
[214] Fix | Delete
var et_fb_preboot = " . wp_json_encode( $preboot ) . ";
[215] Fix | Delete
[216] Fix | Delete
// Disable Google Tag Manager
[217] Fix | Delete
window.dataLayer = [{'gtm.blacklist': ['google', 'nonGoogleScripts', 'customScripts', 'customPixels', 'nonGooglePixels']}];
[218] Fix | Delete
[219] Fix | Delete
{$preboot_script}
[220] Fix | Delete
</script>
[221] Fix | Delete
";
[222] Fix | Delete
}
[223] Fix | Delete
add_action( 'wp_head', 'et_builder_inject_preboot_script', 0 );
[224] Fix | Delete
[225] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function