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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder
File: functions.php
[3500] Fix | Delete
/**
[3501] Fix | Delete
* et_save_post hook.
[3502] Fix | Delete
*
[3503] Fix | Delete
* @hooked et_builder_set_product_page_layout_meta - 10
[3504] Fix | Delete
*
[3505] Fix | Delete
* @param int $post_id
[3506] Fix | Delete
*/
[3507] Fix | Delete
do_action( 'et_save_post', $post_id );
[3508] Fix | Delete
[3509] Fix | Delete
// Do not process Page Settings if BFB is enabled. Were saving it via ajax.
[3510] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[3511] Fix | Delete
// But we still need to save old content
[3512] Fix | Delete
if ( isset( $_POST['et_pb_old_content'] ) ) {
[3513] Fix | Delete
update_post_meta( $post_id, '_et_pb_old_content', $_POST['et_pb_old_content'] );
[3514] Fix | Delete
// WooCommerce Modules needs the following hook.
[3515] Fix | Delete
[3516] Fix | Delete
/**
[3517] Fix | Delete
* Fires after the `_et_pb_old_content` post meta is updated.
[3518] Fix | Delete
*
[3519] Fix | Delete
* In case you want to over-ride `_et_pb_old_content` content, this is the hook you should use.
[3520] Fix | Delete
* @see et_builder_wc_long_description_metabox_save()
[3521] Fix | Delete
*
[3522] Fix | Delete
* @since 3.29
[3523] Fix | Delete
*
[3524] Fix | Delete
* @param int $post_id Post ID.
[3525] Fix | Delete
* $param WP_Post $post The Post.
[3526] Fix | Delete
* $param array $_POST Request variables. This could be used for Nonce verification, etc.
[3527] Fix | Delete
*/
[3528] Fix | Delete
do_action( 'et_pb_old_content_updated', $post_id, $post, $_POST );
[3529] Fix | Delete
} else {
[3530] Fix | Delete
delete_post_meta( $post_id, '_et_pb_old_content' );
[3531] Fix | Delete
}
[3532] Fix | Delete
return $post_id;
[3533] Fix | Delete
}
[3534] Fix | Delete
[3535] Fix | Delete
// Only run AB Testing-related update sequence if AB Testing is allowed
[3536] Fix | Delete
if ( et_pb_is_allowed( 'ab_testing' ) ) {
[3537] Fix | Delete
// Delete AB Testing settings' autosave
[3538] Fix | Delete
delete_post_meta( $post_id, '_et_pb_use_ab_testing_draft' );
[3539] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_subjects_draft' );
[3540] Fix | Delete
[3541] Fix | Delete
if ( isset( $_POST['et_pb_use_ab_testing'] ) && in_array( $_POST['et_pb_use_ab_testing'], array( 'on', 'off' ) ) ) {
[3542] Fix | Delete
update_post_meta( $post_id, '_et_pb_use_ab_testing', sanitize_text_field( $_POST['et_pb_use_ab_testing'] ) );
[3543] Fix | Delete
[3544] Fix | Delete
if ( 'on' === $_POST['et_pb_use_ab_testing'] ) {
[3545] Fix | Delete
if ( ! get_post_meta( $post_id, '_et_pb_ab_testing_id', true ) ) {
[3546] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_testing_id', rand() );
[3547] Fix | Delete
}
[3548] Fix | Delete
} else {
[3549] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_testing_id' );
[3550] Fix | Delete
delete_post_meta( $post_id, 'et_pb_subjects_cache' );
[3551] Fix | Delete
et_pb_ab_remove_stats( $post_id );
[3552] Fix | Delete
}
[3553] Fix | Delete
} else {
[3554] Fix | Delete
delete_post_meta( $post_id, '_et_pb_use_ab_testing' );
[3555] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_testing_id' );
[3556] Fix | Delete
}
[3557] Fix | Delete
[3558] Fix | Delete
if ( isset( $_POST['et_pb_ab_subjects'] ) && '' !== $_POST['et_pb_ab_subjects'] ) {
[3559] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_subjects', sanitize_text_field( et_prevent_duplicate_item( $_POST['et_pb_ab_subjects'], ',') ) );
[3560] Fix | Delete
} else {
[3561] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_subjects' );
[3562] Fix | Delete
}
[3563] Fix | Delete
[3564] Fix | Delete
if ( isset( $_POST['et_pb_ab_goal_module'] ) && '' !== $_POST['et_pb_ab_goal_module'] ) {
[3565] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_goal_module', sanitize_text_field( $_POST['et_pb_ab_goal_module'] ) );
[3566] Fix | Delete
} else {
[3567] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_goal_module' );
[3568] Fix | Delete
}
[3569] Fix | Delete
[3570] Fix | Delete
if ( isset( $_POST['et_pb_ab_stats_refresh_interval'] ) && '' !== $_POST['et_pb_ab_stats_refresh_interval'] ) {
[3571] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_stats_refresh_interval', sanitize_text_field( $_POST['et_pb_ab_stats_refresh_interval'] ) );
[3572] Fix | Delete
} else {
[3573] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_stats_refresh_interval' );
[3574] Fix | Delete
}
[3575] Fix | Delete
}
[3576] Fix | Delete
[3577] Fix | Delete
if ( isset( $_POST['et_pb_old_content'] ) ) {
[3578] Fix | Delete
update_post_meta( $post_id, '_et_pb_old_content', $_POST['et_pb_old_content'] );
[3579] Fix | Delete
} else {
[3580] Fix | Delete
delete_post_meta( $post_id, '_et_pb_old_content' );
[3581] Fix | Delete
}
[3582] Fix | Delete
[3583] Fix | Delete
et_builder_update_settings( null, $post_id );
[3584] Fix | Delete
[3585] Fix | Delete
if ( isset( $_POST['et_pb_unsynced_global_attrs'] ) ) {
[3586] Fix | Delete
$unsynced_options_array = stripslashes( sanitize_text_field( $_POST['et_pb_unsynced_global_attrs'] ) );
[3587] Fix | Delete
update_post_meta( $post_id, '_et_pb_excluded_global_options', $unsynced_options_array );
[3588] Fix | Delete
}
[3589] Fix | Delete
[3590] Fix | Delete
return $post_id;
[3591] Fix | Delete
}
[3592] Fix | Delete
add_action( 'save_post', 'et_pb_metabox_settings_save_details', 10, 2 );
[3593] Fix | Delete
[3594] Fix | Delete
function et_pb_set_et_saved_cookie( $post_id, $post ) {
[3595] Fix | Delete
global $pagenow;
[3596] Fix | Delete
[3597] Fix | Delete
if ( 'post.php' !== $pagenow ) return $post_id;
[3598] Fix | Delete
[3599] Fix | Delete
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
[3600] Fix | Delete
return $post_id;
[3601] Fix | Delete
[3602] Fix | Delete
$post_type = get_post_type_object( $post->post_type );
[3603] Fix | Delete
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
[3604] Fix | Delete
return $post_id;
[3605] Fix | Delete
}
[3606] Fix | Delete
[3607] Fix | Delete
if ( ! isset( $_POST['et_pb_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_pb_settings_nonce'], basename( __FILE__ ) ) ) {
[3608] Fix | Delete
return $post_id;
[3609] Fix | Delete
}
[3610] Fix | Delete
[3611] Fix | Delete
// delete
[3612] Fix | Delete
setcookie( 'et-saving-post-' . $post_id . '-bb', 'bb', time() - DAY_IN_SECONDS, SITECOOKIEPATH, false, is_ssl() );
[3613] Fix | Delete
// set
[3614] Fix | Delete
setcookie( 'et-saved-post-' . $post_id . '-bb', 'bb', time() + MINUTE_IN_SECONDS * 5, SITECOOKIEPATH, false, is_ssl() );
[3615] Fix | Delete
}
[3616] Fix | Delete
[3617] Fix | Delete
add_action( 'save_post', 'et_pb_set_et_saved_cookie', 10, 2 );
[3618] Fix | Delete
[3619] Fix | Delete
/**
[3620] Fix | Delete
* Handling title-less & content-less switching from backend builder to normal editor
[3621] Fix | Delete
* @param int $maybe_empty whether the wp_insert_post content is empty or not
[3622] Fix | Delete
* @param array $postarr all $_POST data that is being passed to wp_insert_post()
[3623] Fix | Delete
* @return int whether wp_insert_post content should be considered empty or not
[3624] Fix | Delete
*/
[3625] Fix | Delete
function et_pb_ensure_builder_activation_switching( $maybe_empty, $postarr ) {
[3626] Fix | Delete
// Consider wp_insert_post() content is not empty if incoming et_pb_use_builder is `off` while currently saved _et_pb_use_builder value is `on`
[3627] Fix | Delete
if ( isset( $postarr['et_pb_use_builder'] ) && 'off' === $postarr['et_pb_use_builder'] && isset( $postarr['post_ID'] ) && et_pb_is_pagebuilder_used( $postarr['post_ID'] ) ) {
[3628] Fix | Delete
return false;
[3629] Fix | Delete
}
[3630] Fix | Delete
[3631] Fix | Delete
return $maybe_empty;
[3632] Fix | Delete
}
[3633] Fix | Delete
add_filter( 'wp_insert_post_empty_content', 'et_pb_ensure_builder_activation_switching', 10, 2 );
[3634] Fix | Delete
[3635] Fix | Delete
function et_pb_before_main_editor( $post ) {
[3636] Fix | Delete
if ( ! et_builder_enabled_for_post( $post->ID ) ) {
[3637] Fix | Delete
return;
[3638] Fix | Delete
}
[3639] Fix | Delete
[3640] Fix | Delete
$_et_builder_use_builder = get_post_meta( $post->ID, '_et_pb_use_builder', true );
[3641] Fix | Delete
$is_builder_used = 'on' === $_et_builder_use_builder;
[3642] Fix | Delete
$last_builder_version_used = get_post_meta( $post->ID, '_et_builder_version', true ); // Examples: 'BB|Divi|3.0.30' 'VB|Divi|3.0.30'
[3643] Fix | Delete
[3644] Fix | Delete
$_et_builder_use_ab_testing = et_builder_bfb_enabled() ? false : get_post_meta( $post->ID, '_et_pb_use_ab_testing', true );
[3645] Fix | Delete
$_et_builder_ab_stats_refresh_interval = et_builder_bfb_enabled() ? false : et_pb_ab_get_refresh_interval( $post->ID );
[3646] Fix | Delete
$_et_builder_ab_subjects = et_builder_bfb_enabled() ? false : get_post_meta( $post->ID, '_et_pb_ab_subjects', true );
[3647] Fix | Delete
$_et_builder_ab_goal_module = et_builder_bfb_enabled() ? false : et_pb_ab_get_goal_module( $post->ID );
[3648] Fix | Delete
[3649] Fix | Delete
$builder_always_enabled = apply_filters('et_builder_always_enabled', false, $post->post_type, $post );
[3650] Fix | Delete
if ( 'et_pb_layout' === $post->post_type ) {
[3651] Fix | Delete
// No matter what, in Divi Library we always want the builder
[3652] Fix | Delete
$builder_always_enabled = true;
[3653] Fix | Delete
}
[3654] Fix | Delete
if ( $builder_always_enabled ) {
[3655] Fix | Delete
$is_builder_used = true;
[3656] Fix | Delete
$_et_builder_use_builder = 'on';
[3657] Fix | Delete
}
[3658] Fix | Delete
[3659] Fix | Delete
// TODO, need to change the output of these buttons if BFB
[3660] Fix | Delete
[3661] Fix | Delete
// Add button only if current user is allowed to use it otherwise display placeholder with all required data
[3662] Fix | Delete
if ( et_pb_is_allowed( 'divi_builder_control' ) ) {
[3663] Fix | Delete
$buttons = sprintf('<a href="#" id="et_pb_toggle_builder" data-builder="%2$s" data-editor="%3$s" class="button button-primary button-large%4$s%5$s">%1$s</a>',
[3664] Fix | Delete
( $is_builder_used ? esc_html__( 'Return To Standard Editor', 'et_builder' ) : esc_html__( 'Use The Divi Builder', 'et_builder' ) ),
[3665] Fix | Delete
esc_html__( 'Use The Divi Builder', 'et_builder' ),
[3666] Fix | Delete
esc_html__( 'Return To Standard Editor', 'et_builder' ),
[3667] Fix | Delete
( $is_builder_used ? ' et_pb_builder_is_used' : '' ),
[3668] Fix | Delete
( $builder_always_enabled ? ' et_pb_hidden' : '' )
[3669] Fix | Delete
);
[3670] Fix | Delete
[3671] Fix | Delete
// add in the visual builder button only on appropriate post types
[3672] Fix | Delete
// also, don't add the button on page if it set as static posts page
[3673] Fix | Delete
if ( et_builder_fb_enabled_for_post( $post->ID ) && et_pb_is_allowed( 'use_visual_builder' ) && ! et_is_extra_library_layout( $post->ID ) && $post->ID !== get_option( 'page_for_posts' ) ) {
[3674] Fix | Delete
$buttons .= sprintf('<a href="%1$s" id="et_pb_fb_cta" class="button button-primary button-large%3$s%4$s">%2$s</a>',
[3675] Fix | Delete
esc_url( et_fb_get_vb_url() ),
[3676] Fix | Delete
esc_html__( 'Build On The Front End', 'et_builder' ),
[3677] Fix | Delete
( $builder_always_enabled ? ' et-first-child' : '' ),
[3678] Fix | Delete
( et_pb_is_pagebuilder_used( $post->ID ) ? ' et_pb_ready' : '' )
[3679] Fix | Delete
);
[3680] Fix | Delete
}
[3681] Fix | Delete
[3682] Fix | Delete
printf( '<div class="et_pb_toggle_builder_wrapper%1$s"%4$s>%2$s</div><div id="et_pb_main_editor_wrap"%3$s>',
[3683] Fix | Delete
( $is_builder_used ? ' et_pb_builder_is_used' : '' ),
[3684] Fix | Delete
et_core_esc_previously( $buttons ),
[3685] Fix | Delete
( $is_builder_used ? ' class="et_pb_post_body_hidden"' : '' ),
[3686] Fix | Delete
( et_builder_bfb_enabled() ? ' style="opacity: 0;"' : '' )
[3687] Fix | Delete
);
[3688] Fix | Delete
} else {
[3689] Fix | Delete
printf( '<div class="et_pb_toggle_builder_wrapper%2$s"%3$s></div><div id="et_pb_main_editor_wrap"%1$s>',
[3690] Fix | Delete
( $is_builder_used ? ' class="et_pb_post_body_hidden"' : '' ),
[3691] Fix | Delete
( $is_builder_used ? ' et_pb_builder_is_used' : '' ),
[3692] Fix | Delete
( et_builder_bfb_enabled() ? ' style="opacity: 0;"' : '' )
[3693] Fix | Delete
);
[3694] Fix | Delete
}
[3695] Fix | Delete
[3696] Fix | Delete
if ( ! et_builder_bfb_enabled() ) {
[3697] Fix | Delete
$module_fields_dependencies = json_encode( ET_Builder_Element::get_field_dependencies( $post->post_type ) );
[3698] Fix | Delete
[3699] Fix | Delete
echo et_core_esc_previously("
[3700] Fix | Delete
<script>
[3701] Fix | Delete
window.et_pb_module_field_dependencies = JSON.parse( '{$module_fields_dependencies}' );
[3702] Fix | Delete
</script>");
[3703] Fix | Delete
}
[3704] Fix | Delete
[3705] Fix | Delete
?>
[3706] Fix | Delete
<p class="et_pb_page_settings" style="display: none;">
[3707] Fix | Delete
<?php wp_nonce_field( basename( __FILE__ ), 'et_pb_settings_nonce' ); ?>
[3708] Fix | Delete
<input type="hidden" id="et_pb_last_post_modified" name="et_pb_last_post_modified" value="<?php echo esc_attr( $post->post_modified ); ?>" />
[3709] Fix | Delete
<input type="hidden" id="et_pb_use_builder" name="et_pb_use_builder" value="<?php echo esc_attr( $_et_builder_use_builder ); ?>" />
[3710] Fix | Delete
<input type="hidden" id="et_builder_version" name="et_builder_version" value="<?php echo esc_attr( $last_builder_version_used ); ?>" />
[3711] Fix | Delete
<input type="hidden" autocomplete="off" id="et_pb_use_ab_testing" name="et_pb_use_ab_testing" value="<?php echo esc_attr( $_et_builder_use_ab_testing ); ?>">
[3712] Fix | Delete
<input type="hidden" autocomplete="off" id="_et_pb_ab_stats_refresh_interval" name="et_pb_ab_stats_refresh_interval" value="<?php echo esc_attr( $_et_builder_ab_stats_refresh_interval ); ?>">
[3713] Fix | Delete
<input type="hidden" autocomplete="off" id="et_pb_ab_subjects" name="et_pb_ab_subjects" value="<?php echo esc_attr( $_et_builder_ab_subjects ); ?>">
[3714] Fix | Delete
<input type="hidden" autocomplete="off" id="et_pb_ab_goal_module" name="et_pb_ab_goal_module" value="<?php echo esc_attr( $_et_builder_ab_goal_module ); ?>">
[3715] Fix | Delete
<?php et_pb_builder_settings_hidden_inputs( $post->ID ); ?>
[3716] Fix | Delete
<?php et_pb_builder_global_library_inputs( $post->ID ); ?>
[3717] Fix | Delete
[3718] Fix | Delete
<textarea id="et_pb_old_content" name="et_pb_old_content"><?php echo esc_attr( get_post_meta( $post->ID, '_et_pb_old_content', true ) ); ?></textarea>
[3719] Fix | Delete
</p>
[3720] Fix | Delete
<?php
[3721] Fix | Delete
}
[3722] Fix | Delete
[3723] Fix | Delete
function et_pb_after_main_editor( $post ) {
[3724] Fix | Delete
if ( ! et_builder_enabled_for_post( $post->ID ) ) {
[3725] Fix | Delete
return;
[3726] Fix | Delete
}
[3727] Fix | Delete
echo '</div> <!-- #et_pb_main_editor_wrap -->';
[3728] Fix | Delete
}
[3729] Fix | Delete
[3730] Fix | Delete
function et_pb_setup_main_editor() {
[3731] Fix | Delete
if ( ! et_core_is_gutenberg_enabled() ) {
[3732] Fix | Delete
add_action( 'edit_form_after_title', 'et_pb_before_main_editor' );
[3733] Fix | Delete
add_action( 'edit_form_after_editor', 'et_pb_after_main_editor' );
[3734] Fix | Delete
}
[3735] Fix | Delete
}
[3736] Fix | Delete
add_action( 'add_meta_boxes', 'et_pb_setup_main_editor', 11 );
[3737] Fix | Delete
[3738] Fix | Delete
function et_pb_admin_scripts_styles( $hook ) {
[3739] Fix | Delete
global $typenow, $pagenow;
[3740] Fix | Delete
[3741] Fix | Delete
//load css file for the Divi menu
[3742] Fix | Delete
wp_enqueue_style( 'library-menu-styles', ET_BUILDER_URI . '/styles/library_menu.css', array(), ET_BUILDER_VERSION );
[3743] Fix | Delete
[3744] Fix | Delete
if ( $hook === 'widgets.php' ) {
[3745] Fix | Delete
wp_enqueue_script( 'et_pb_widgets_js', ET_BUILDER_URI . '/scripts/ext/widgets.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
[3746] Fix | Delete
[3747] Fix | Delete
wp_localize_script( 'et_pb_widgets_js', 'et_pb_options', apply_filters( 'et_pb_options_admin', array(
[3748] Fix | Delete
'ajaxurl' => admin_url( 'admin-ajax.php' ),
[3749] Fix | Delete
'et_admin_load_nonce' => wp_create_nonce( 'et_admin_load_nonce' ),
[3750] Fix | Delete
'widget_info' => sprintf( '<div id="et_pb_widget_area_create"><p>%1$s.</p><p>%2$s.</p><p><label>%3$s <input id="et_pb_new_widget_area_name" value="" /></label><button class="button button-primary et_pb_create_widget_area">%4$s</button></p><p class="et_pb_widget_area_result"></p></div>',
[3751] Fix | Delete
esc_html__( 'Here you can create new widget areas for use in the Sidebar module', 'et_builder' ),
[3752] Fix | Delete
esc_html__( 'Note: Naming your widget area "sidebar 1", "sidebar 2", "sidebar 3", "sidebar 4" or "sidebar 5" will cause conflicts with this theme', 'et_builder' ),
[3753] Fix | Delete
esc_html__( 'Widget Name', 'et_builder' ),
[3754] Fix | Delete
esc_html__( 'Create', 'et_builder' )
[3755] Fix | Delete
),
[3756] Fix | Delete
'delete_string' => esc_html__( 'Delete', 'et_builder' ),
[3757] Fix | Delete
) ) );
[3758] Fix | Delete
[3759] Fix | Delete
wp_enqueue_style( 'et_pb_widgets_css', ET_BUILDER_URI . '/styles/widgets.css', array(), ET_BUILDER_VERSION );
[3760] Fix | Delete
[3761] Fix | Delete
return;
[3762] Fix | Delete
}
[3763] Fix | Delete
[3764] Fix | Delete
// Do not enqueue BB assets if GB is active on this page
[3765] Fix | Delete
if ( et_core_is_gutenberg_enabled() ) {
[3766] Fix | Delete
return;
[3767] Fix | Delete
}
[3768] Fix | Delete
[3769] Fix | Delete
if ( ! in_array( $hook, array( 'post-new.php', 'post.php' ) ) ) return;
[3770] Fix | Delete
[3771] Fix | Delete
/*
[3772] Fix | Delete
* Load the builder javascript and css files for custom post types
[3773] Fix | Delete
* custom post types can be added using et_builder_post_types filter
[3774] Fix | Delete
*/
[3775] Fix | Delete
[3776] Fix | Delete
$post_types = et_builder_get_builder_post_types();
[3777] Fix | Delete
$on_enabled_post_type = isset( $typenow ) && in_array( $typenow, $post_types );
[3778] Fix | Delete
$on_enabled_post = isset( $pagenow ) && 'post.php' === $pagenow && isset( $_GET['post'] ) && et_builder_enabled_for_post( intval( $_GET['post'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
[3779] Fix | Delete
[3780] Fix | Delete
if ( $on_enabled_post_type || $on_enabled_post ) {
[3781] Fix | Delete
wp_enqueue_style( 'et_bb_bfb_common', ET_BUILDER_URI . '/styles/bb_bfb_common.css', array(), ET_BUILDER_VERSION );
[3782] Fix | Delete
[3783] Fix | Delete
// Boot one builders assets or the other
[3784] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[3785] Fix | Delete
et_bfb_enqueue_scripts();
[3786] Fix | Delete
[3787] Fix | Delete
// do not load BFB if builder is disabled on page
[3788] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( get_the_ID() ) ) {
[3789] Fix | Delete
return;
[3790] Fix | Delete
}
[3791] Fix | Delete
[3792] Fix | Delete
// BFB loads builder modal outside the iframe using react portal. external scripts
[3793] Fix | Delete
// that is used on modal needs to be enqueued
[3794] Fix | Delete
et_builder_enqueue_assets_main();
[3795] Fix | Delete
[3796] Fix | Delete
et_builder_enqueue_open_sans();
[3797] Fix | Delete
[3798] Fix | Delete
if ( $secondary_css_bundles = glob( ET_BUILDER_DIR . 'frontend-builder/build/bundle.*.css' ) ) {
[3799] Fix | Delete
$bundles = array( 'et-frontend-builder' );
[3800] Fix | Delete
[3801] Fix | Delete
foreach ( $secondary_css_bundles as $css_bundle ) {
[3802] Fix | Delete
$slug = basename( $css_bundle, '.css' );
[3803] Fix | Delete
$parts = explode( '.', $slug, -1 );
[3804] Fix | Delete
[3805] Fix | Delete
// Drop "bundle" from array
[3806] Fix | Delete
array_shift( $parts );
[3807] Fix | Delete
[3808] Fix | Delete
$slug = implode( '-', $parts );
[3809] Fix | Delete
[3810] Fix | Delete
et_fb_enqueue_bundle( "et-fb-{$slug}", basename( $css_bundle ), $bundles, null );
[3811] Fix | Delete
[3812] Fix | Delete
$bundles[] = $slug;
[3813] Fix | Delete
}
[3814] Fix | Delete
}
[3815] Fix | Delete
[3816] Fix | Delete
// Hooks for theme/plugin specific styling which complements visual builder
[3817] Fix | Delete
do_action( 'et_bfb_boot' );
[3818] Fix | Delete
} else {
[3819] Fix | Delete
et_pb_add_builder_page_js_css();
[3820] Fix | Delete
}
[3821] Fix | Delete
}
[3822] Fix | Delete
}
[3823] Fix | Delete
add_action( 'admin_enqueue_scripts', 'et_pb_admin_scripts_styles', 10, 1 );
[3824] Fix | Delete
[3825] Fix | Delete
/**
[3826] Fix | Delete
* Disable emoji detection script on edit page which has Backend Builder on it.
[3827] Fix | Delete
* WordPress automatically replaces emoji with plain image for backward compatibility
[3828] Fix | Delete
* on older browsers. This causes issue when emoji is used on header or other input
[3829] Fix | Delete
* text field because (when the modal is saved, shortcode is generated, and emoji
[3830] Fix | Delete
* is being replaced with plain image) it creates incorrect attribute markup
[3831] Fix | Delete
* such as `title="I <img class="emoji" src="../heart.png" /> WP"` and causes
[3832] Fix | Delete
* the whole input text value to be disappeared
[3833] Fix | Delete
* @return void
[3834] Fix | Delete
*/
[3835] Fix | Delete
function et_pb_remove_emoji_detection_script() {
[3836] Fix | Delete
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
[3837] Fix | Delete
global $pagenow;
[3838] Fix | Delete
[3839] Fix | Delete
$disable_emoji_detection = false;
[3840] Fix | Delete
[3841] Fix | Delete
// Disable emoji detection script on editing page which has Backend Builder
[3842] Fix | Delete
// global $post isn't available at admin_init, so retrieve $post data manually
[3843] Fix | Delete
if ( 'post.php' === $pagenow && isset( $_GET['post'] ) ) {
[3844] Fix | Delete
$post_id = (int) $_GET['post'];
[3845] Fix | Delete
$post = get_post( $post_id );
[3846] Fix | Delete
[3847] Fix | Delete
if ( et_builder_enabled_for_post( $post->ID ) ) {
[3848] Fix | Delete
$disable_emoji_detection = true;
[3849] Fix | Delete
}
[3850] Fix | Delete
}
[3851] Fix | Delete
[3852] Fix | Delete
// Disable emoji detection script on post new page which has Backend Builder
[3853] Fix | Delete
$has_post_type_query = isset( $_GET['post_type'] );
[3854] Fix | Delete
if ( 'post-new.php' === $pagenow && ( ! $has_post_type_query || ( $has_post_type_query && in_array( $_GET['post_type'], et_builder_get_builder_post_types() ) ) ) ) {
[3855] Fix | Delete
$disable_emoji_detection = true;
[3856] Fix | Delete
}
[3857] Fix | Delete
[3858] Fix | Delete
if ( $disable_emoji_detection ) {
[3859] Fix | Delete
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
[3860] Fix | Delete
}
[3861] Fix | Delete
// phpcs:enable
[3862] Fix | Delete
}
[3863] Fix | Delete
add_action( 'admin_init', 'et_pb_remove_emoji_detection_script' );
[3864] Fix | Delete
[3865] Fix | Delete
/**
[3866] Fix | Delete
* Disable emoji detection script on visual builder
[3867] Fix | Delete
* WordPress automatically replaces emoji with plain image for backward compatibility
[3868] Fix | Delete
* on older browsers. This causes issue when emoji is used on header or other input
[3869] Fix | Delete
* text field because the staticize emoji creates HTML markup which appears to be
[3870] Fix | Delete
* invalid on input[type="text"] field such as `title="I <img class="emoji"
[3871] Fix | Delete
* src="../heart.png" /> WP"` and causes the input text value to be escaped and
[3872] Fix | Delete
* disappeared
[3873] Fix | Delete
* @return void
[3874] Fix | Delete
*/
[3875] Fix | Delete
function et_fb_remove_emoji_detection_script() {
[3876] Fix | Delete
global $post;
[3877] Fix | Delete
[3878] Fix | Delete
// Disable emoji detection script on visual builder. React's auto escaping will
[3879] Fix | Delete
// remove all staticized emoji when being opened on modal's input field
[3880] Fix | Delete
if ( isset( $post->ID ) && et_fb_is_enabled( $post->ID ) ) {
[3881] Fix | Delete
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
[3882] Fix | Delete
}
[3883] Fix | Delete
}
[3884] Fix | Delete
add_action( 'wp', 'et_fb_remove_emoji_detection_script' );
[3885] Fix | Delete
[3886] Fix | Delete
function et_pb_fix_builder_shortcodes( $content ) {
[3887] Fix | Delete
if ( is_admin() ) {
[3888] Fix | Delete
// ET_Builder_Element is not loaded in the administration and some plugins call
[3889] Fix | Delete
// the_content there (e.g. WP File Manager).
[3890] Fix | Delete
return $content;
[3891] Fix | Delete
}
[3892] Fix | Delete
[3893] Fix | Delete
$is_theme_builder = ET_Builder_Element::is_theme_builder_layout();
[3894] Fix | Delete
$is_singular = is_singular() && 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true );
[3895] Fix | Delete
[3896] Fix | Delete
// if the builder is used for the page, get rid of random p tags
[3897] Fix | Delete
if ( $is_theme_builder || $is_singular ) {
[3898] Fix | Delete
$content = et_pb_fix_shortcodes( $content );
[3899] Fix | Delete
}
[3900] Fix | Delete
[3901] Fix | Delete
return $content;
[3902] Fix | Delete
}
[3903] Fix | Delete
add_filter( 'the_content', 'et_pb_fix_builder_shortcodes' );
[3904] Fix | Delete
add_filter( 'et_builder_render_layout', 'et_pb_fix_builder_shortcodes' );
[3905] Fix | Delete
[3906] Fix | Delete
function et_pb_the_content_prep_code_module_for_wpautop( $content ) {
[3907] Fix | Delete
if ( 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true ) ) {
[3908] Fix | Delete
$content = et_pb_prep_code_module_for_wpautop( $content );
[3909] Fix | Delete
}
[3910] Fix | Delete
return $content;
[3911] Fix | Delete
}
[3912] Fix | Delete
add_filter( 'the_content', 'et_pb_the_content_prep_code_module_for_wpautop', 0 );
[3913] Fix | Delete
add_filter( 'et_builder_render_layout', 'et_pb_the_content_prep_code_module_for_wpautop', 0 );
[3914] Fix | Delete
[3915] Fix | Delete
// generate the html for "Add new template" Modal in Library
[3916] Fix | Delete
if ( ! function_exists( 'et_pb_generate_new_layout_modal' ) ) {
[3917] Fix | Delete
function et_pb_generate_new_layout_modal() {
[3918] Fix | Delete
$template_type_option_output = '';
[3919] Fix | Delete
$template_module_tabs_option_output = '';
[3920] Fix | Delete
$template_global_option_output = '';
[3921] Fix | Delete
$layout_cat_option_output = '';
[3922] Fix | Delete
[3923] Fix | Delete
$template_type_options = apply_filters( 'et_pb_new_layout_template_types', array(
[3924] Fix | Delete
'module' => esc_html__( 'Module', 'et_builder' ),
[3925] Fix | Delete
'fullwidth_module' => esc_html__( 'Fullwidth Module', 'et_builder' ),
[3926] Fix | Delete
'row' => esc_html__( 'Row', 'et_builder' ),
[3927] Fix | Delete
'section' => esc_html__( 'Section', 'et_builder' ),
[3928] Fix | Delete
'fullwidth_section' => esc_html__( 'Fullwidth Section', 'et_builder' ),
[3929] Fix | Delete
'specialty_section' => esc_html__( 'Specialty Section', 'et_builder' ),
[3930] Fix | Delete
'layout' => et_builder_i18n( 'Layout' ),
[3931] Fix | Delete
) );
[3932] Fix | Delete
[3933] Fix | Delete
// construct output for the template type option
[3934] Fix | Delete
if ( ! empty( $template_type_options ) ) {
[3935] Fix | Delete
$template_type_option_output = sprintf(
[3936] Fix | Delete
'<br><label>%1$s:</label>
[3937] Fix | Delete
<select id="new_template_type">',
[3938] Fix | Delete
esc_html__( 'Layout Type', 'et_builder' )
[3939] Fix | Delete
);
[3940] Fix | Delete
[3941] Fix | Delete
foreach( $template_type_options as $option_id => $option_name ) {
[3942] Fix | Delete
$template_type_option_output .= sprintf(
[3943] Fix | Delete
'<option value="%1$s">%2$s</option>',
[3944] Fix | Delete
esc_attr( $option_id ),
[3945] Fix | Delete
esc_html( $option_name )
[3946] Fix | Delete
);
[3947] Fix | Delete
}
[3948] Fix | Delete
[3949] Fix | Delete
$template_type_option_output .= '</select>';
[3950] Fix | Delete
}
[3951] Fix | Delete
[3952] Fix | Delete
$template_global_option_output = apply_filters( 'et_pb_new_layout_global_option', sprintf(
[3953] Fix | Delete
'<br><label>%1$s<input type="checkbox" value="global" id="et_pb_template_global"></label>',
[3954] Fix | Delete
esc_html__( 'Global', 'et_builder' )
[3955] Fix | Delete
) );
[3956] Fix | Delete
[3957] Fix | Delete
// construct output for the layout category option
[3958] Fix | Delete
$layout_cat_option_output .= sprintf(
[3959] Fix | Delete
'<br><label>%1$s</label>',
[3960] Fix | Delete
esc_html__( 'Add To Categories', 'et_builder' )
[3961] Fix | Delete
);
[3962] Fix | Delete
[3963] Fix | Delete
$layout_categories = apply_filters( 'et_pb_new_layout_cats_array', get_terms( 'layout_category', array( 'hide_empty' => false ) ) );
[3964] Fix | Delete
if ( is_array( $layout_categories ) && ! empty( $layout_categories ) ) {
[3965] Fix | Delete
$layout_cat_option_output .= '<div class="layout_cats_container">';
[3966] Fix | Delete
[3967] Fix | Delete
foreach( $layout_categories as $category ) {
[3968] Fix | Delete
$layout_cat_option_output .= sprintf(
[3969] Fix | Delete
'<label>%1$s<input type="checkbox" value="%2$s"/></label>',
[3970] Fix | Delete
esc_html( $category->name ),
[3971] Fix | Delete
esc_attr( $category->term_id )
[3972] Fix | Delete
);
[3973] Fix | Delete
}
[3974] Fix | Delete
[3975] Fix | Delete
$layout_cat_option_output .= '</div>';
[3976] Fix | Delete
}
[3977] Fix | Delete
[3978] Fix | Delete
$layout_cat_option_output .= '<input type="text" value="" id="et_pb_new_cat_name" class="regular-text">';
[3979] Fix | Delete
[3980] Fix | Delete
$output = sprintf(
[3981] Fix | Delete
'<div class="et_pb_modal_overlay et_modal_on_top et_pb_new_template_modal">
[3982] Fix | Delete
<div class="et_pb_prompt_modal">
[3983] Fix | Delete
<h2>%1$s</h2>
[3984] Fix | Delete
<div class="et_pb_prompt_modal_inside">
[3985] Fix | Delete
<label>%2$s:</label>
[3986] Fix | Delete
<input type="text" value="" id="et_pb_new_template_name" class="regular-text">
[3987] Fix | Delete
%6$s
[3988] Fix | Delete
%3$s
[3989] Fix | Delete
%4$s
[3990] Fix | Delete
%5$s
[3991] Fix | Delete
%7$s
[3992] Fix | Delete
<input id="et_builder_layout_built_for_post_type" type="hidden" value="page">
[3993] Fix | Delete
</div>
[3994] Fix | Delete
<a href="#"" class="et_pb_prompt_dont_proceed et-pb-modal-close"></a>
[3995] Fix | Delete
<div class="et_pb_prompt_buttons">
[3996] Fix | Delete
<br>
[3997] Fix | Delete
<span class="spinner"></span>
[3998] Fix | Delete
<input type="submit" class="et_pb_create_template button-primary et_pb_prompt_proceed">
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function