Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: functions.php
* @param boolean $is_cache Whether to use WordPress Object Cache or not.
[3500] Fix | Delete
* @return string
[3501] Fix | Delete
*/
[3502] Fix | Delete
function et_builder_get_oembed( $url, $group = 'video', $is_cache = true ) {
[3503] Fix | Delete
$item_src = esc_url( $url );
[3504] Fix | Delete
[3505] Fix | Delete
// Temporarily save embedded item on page load only. Use the item source as the
[3506] Fix | Delete
// key, so some modules with the same item can share it.
[3507] Fix | Delete
$item_embed = $is_cache ? wp_cache_get( $item_src, $group ) : false;
[3508] Fix | Delete
[3509] Fix | Delete
if ( ! $item_embed ) {
[3510] Fix | Delete
$item_embed = wp_oembed_get( $item_src );
[3511] Fix | Delete
[3512] Fix | Delete
if ( $is_cache ) {
[3513] Fix | Delete
wp_cache_set( $item_src, $item_embed, $group );
[3514] Fix | Delete
}
[3515] Fix | Delete
}
[3516] Fix | Delete
[3517] Fix | Delete
return apply_filters( 'et_builder_get_oembed', $item_embed, $url, $group, $is_cache );
[3518] Fix | Delete
}
[3519] Fix | Delete
endif;
[3520] Fix | Delete
[3521] Fix | Delete
if ( ! function_exists( 'et_pb_set_video_oembed_thumbnail_resolution' ) ) :
[3522] Fix | Delete
/**
[3523] Fix | Delete
* Replace YouTube video thumbnails to high resolution if the high resolution image exists.
[3524] Fix | Delete
*
[3525] Fix | Delete
* @param string $image_src thumbnail image src.
[3526] Fix | Delete
* @param string $resolution thumbnail image resolutions.
[3527] Fix | Delete
*
[3528] Fix | Delete
* @return string
[3529] Fix | Delete
*/
[3530] Fix | Delete
function et_pb_set_video_oembed_thumbnail_resolution( $image_src, $resolution = 'default' ) {
[3531] Fix | Delete
// Replace YouTube video thumbnails to high resolution if the high resolution image exists.
[3532] Fix | Delete
if ( 'high' === $resolution && false !== strpos( $image_src, 'hqdefault.jpg' ) ) {
[3533] Fix | Delete
$high_res_image_src = str_replace( 'hqdefault.jpg', 'maxresdefault.jpg', $image_src );
[3534] Fix | Delete
$protocol = is_ssl() ? 'https://' : 'http://';
[3535] Fix | Delete
$processed_image_url = esc_url( str_replace( '//', $protocol, $high_res_image_src ), array( 'http', 'https' ) );
[3536] Fix | Delete
$response = wp_remote_get( $processed_image_url, array( 'timeout' => 30 ) );
[3537] Fix | Delete
[3538] Fix | Delete
// Youtube doesn't guarantee that high res image exists for any video, so we need to check whether it exists and fallback to default image in case of error.
[3539] Fix | Delete
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
[3540] Fix | Delete
return $image_src;
[3541] Fix | Delete
}
[3542] Fix | Delete
[3543] Fix | Delete
return $high_res_image_src;
[3544] Fix | Delete
}
[3545] Fix | Delete
[3546] Fix | Delete
return $image_src;
[3547] Fix | Delete
}
[3548] Fix | Delete
endif;
[3549] Fix | Delete
[3550] Fix | Delete
/**
[3551] Fix | Delete
* Return all registered sidebars.
[3552] Fix | Delete
*
[3553] Fix | Delete
* @return mixed|void
[3554] Fix | Delete
*/
[3555] Fix | Delete
function et_builder_get_widget_areas_list() {
[3556] Fix | Delete
global $wp_registered_sidebars;
[3557] Fix | Delete
[3558] Fix | Delete
$widget_areas = array();
[3559] Fix | Delete
[3560] Fix | Delete
foreach ( $wp_registered_sidebars as $sidebar_key => $sidebar ) {
[3561] Fix | Delete
$widget_areas[ $sidebar_key ] = array(
[3562] Fix | Delete
'name' => $sidebar['name'],
[3563] Fix | Delete
);
[3564] Fix | Delete
}
[3565] Fix | Delete
[3566] Fix | Delete
return apply_filters( 'et_builder_get_widget_areas_list', $widget_areas );
[3567] Fix | Delete
}
[3568] Fix | Delete
[3569] Fix | Delete
if ( ! function_exists( 'et_builder_get_widget_areas' ) ) :
[3570] Fix | Delete
/**
[3571] Fix | Delete
* Return widget areas dropdown html.
[3572] Fix | Delete
*/
[3573] Fix | Delete
function et_builder_get_widget_areas() {
[3574] Fix | Delete
$wp_registered_sidebars = et_builder_get_widget_areas_list();
[3575] Fix | Delete
$et_pb_widgets = get_theme_mod( 'et_pb_widgets' );
[3576] Fix | Delete
[3577] Fix | Delete
$output = '<select name="et_pb_area" id="et_pb_area">';
[3578] Fix | Delete
[3579] Fix | Delete
foreach ( $wp_registered_sidebars as $id => $options ) {
[3580] Fix | Delete
$selected = sprintf(
[3581] Fix | Delete
'<%%= typeof( et_pb_area ) !== "undefined" && "%1$s" === et_pb_area ? " selected=\'selected\'" : "" %%>',
[3582] Fix | Delete
esc_html( $id )
[3583] Fix | Delete
);
[3584] Fix | Delete
[3585] Fix | Delete
$output .= sprintf(
[3586] Fix | Delete
'<option value="%1$s"%2$s>%3$s</option>',
[3587] Fix | Delete
esc_attr( $id ),
[3588] Fix | Delete
$selected,
[3589] Fix | Delete
esc_html( $options['name'] )
[3590] Fix | Delete
);
[3591] Fix | Delete
}
[3592] Fix | Delete
[3593] Fix | Delete
$output .= '</select>';
[3594] Fix | Delete
[3595] Fix | Delete
return $output;
[3596] Fix | Delete
}
[3597] Fix | Delete
endif;
[3598] Fix | Delete
[3599] Fix | Delete
if ( ! function_exists( 'et_pb_export_layouts_interface' ) ) :
[3600] Fix | Delete
/**
[3601] Fix | Delete
* Display 'Manage Categories' button at top in Layout wp admin edit screen.
[3602] Fix | Delete
*/
[3603] Fix | Delete
function et_pb_export_layouts_interface() {
[3604] Fix | Delete
if ( ! current_user_can( 'export' ) ) {
[3605] Fix | Delete
wp_die( esc_html__( 'You do not have sufficient permissions to export the content of this site.', 'et_builder' ) );
[3606] Fix | Delete
}
[3607] Fix | Delete
[3608] Fix | Delete
?>
[3609] Fix | Delete
<a href="<?php echo et_core_esc_wp( admin_url( 'edit-tags.php?taxonomy=layout_category' ) ); ?>" id="et_load_category_page"><?php esc_html_e( 'Manage Categories', 'et_builder' ); ?></a>
[3610] Fix | Delete
<?php
[3611] Fix | Delete
echo et_core_esc_previously( et_builder_portability_link( 'et_builder_layouts', array( 'class' => 'et-pb-portability-button' ) ) );
[3612] Fix | Delete
}
[3613] Fix | Delete
endif;
[3614] Fix | Delete
[3615] Fix | Delete
add_action( 'export_wp', 'et_pb_edit_export_query' );
[3616] Fix | Delete
/**
[3617] Fix | Delete
* Add filter for the export query.
[3618] Fix | Delete
*/
[3619] Fix | Delete
function et_pb_edit_export_query() {
[3620] Fix | Delete
add_filter( 'query', 'et_pb_edit_export_query_filter' );
[3621] Fix | Delete
}
[3622] Fix | Delete
[3623] Fix | Delete
/**
[3624] Fix | Delete
* Export query.
[3625] Fix | Delete
*
[3626] Fix | Delete
* @param WP_Query $query object.
[3627] Fix | Delete
*
[3628] Fix | Delete
* @return string|void
[3629] Fix | Delete
*/
[3630] Fix | Delete
function et_pb_edit_export_query_filter( $query ) {
[3631] Fix | Delete
// Apply filter only once.
[3632] Fix | Delete
remove_filter( 'query', 'et_pb_edit_export_query_filter' );
[3633] Fix | Delete
[3634] Fix | Delete
et_core_nonce_verified_previously();
[3635] Fix | Delete
[3636] Fix | Delete
// ensure user can export.
[3637] Fix | Delete
if ( ! current_user_can( 'export' ) ) {
[3638] Fix | Delete
return $query;
[3639] Fix | Delete
}
[3640] Fix | Delete
[3641] Fix | Delete
global $wpdb;
[3642] Fix | Delete
[3643] Fix | Delete
$content = ! empty( $_GET['content'] ) ? sanitize_text_field( $_GET['content'] ) : '';
[3644] Fix | Delete
[3645] Fix | Delete
if ( ET_BUILDER_LAYOUT_POST_TYPE !== $content ) {
[3646] Fix | Delete
return $query;
[3647] Fix | Delete
}
[3648] Fix | Delete
[3649] Fix | Delete
$sql = '';
[3650] Fix | Delete
$i = 0;
[3651] Fix | Delete
$possible_types = array(
[3652] Fix | Delete
'layout',
[3653] Fix | Delete
'section',
[3654] Fix | Delete
'row',
[3655] Fix | Delete
'module',
[3656] Fix | Delete
'fullwidth_section',
[3657] Fix | Delete
'specialty_section',
[3658] Fix | Delete
'fullwidth_module',
[3659] Fix | Delete
);
[3660] Fix | Delete
[3661] Fix | Delete
foreach ( $possible_types as $template_type ) {
[3662] Fix | Delete
$selected_type = 'et_pb_template_' . $template_type;
[3663] Fix | Delete
[3664] Fix | Delete
if ( isset( $_GET[ $selected_type ] ) ) {
[3665] Fix | Delete
if ( 0 === $i ) {
[3666] Fix | Delete
$sql = " AND ( `{$wpdb->term_relationships}`.term_taxonomy_id = %d";
[3667] Fix | Delete
} else {
[3668] Fix | Delete
$sql .= " OR `{$wpdb->term_relationships}`.term_taxonomy_id = %d";
[3669] Fix | Delete
}
[3670] Fix | Delete
[3671] Fix | Delete
$sql_args[] = (int) $_GET[ $selected_type ];
[3672] Fix | Delete
[3673] Fix | Delete
$i++;
[3674] Fix | Delete
}
[3675] Fix | Delete
}
[3676] Fix | Delete
[3677] Fix | Delete
if ( '' !== $sql ) {
[3678] Fix | Delete
$sql .= ' )';
[3679] Fix | Delete
$sql = sprintf(
[3680] Fix | Delete
'SELECT ID FROM %4$s
[3681] Fix | Delete
INNER JOIN %3$s ON ( %4$s.ID = %3$s.object_id )
[3682] Fix | Delete
WHERE %4$s.post_type = "%1$s"
[3683] Fix | Delete
AND %4$s.post_status != "auto-draft"
[3684] Fix | Delete
%2$s',
[3685] Fix | Delete
ET_BUILDER_LAYOUT_POST_TYPE,
[3686] Fix | Delete
$sql,
[3687] Fix | Delete
$wpdb->term_relationships,
[3688] Fix | Delete
$wpdb->posts
[3689] Fix | Delete
);
[3690] Fix | Delete
$query = $wpdb->prepare( $sql, $sql_args ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Value of the $sql is safely prepared above.
[3691] Fix | Delete
}
[3692] Fix | Delete
[3693] Fix | Delete
return $query;
[3694] Fix | Delete
}
[3695] Fix | Delete
[3696] Fix | Delete
/**
[3697] Fix | Delete
* Initialize builder metabox in BFB.
[3698] Fix | Delete
*/
[3699] Fix | Delete
function et_pb_setup_theme() {
[3700] Fix | Delete
add_action( 'add_meta_boxes', 'et_pb_add_custom_box', 10, 2 );
[3701] Fix | Delete
add_action( 'add_meta_boxes', 'et_builder_prioritize_meta_box', 999999 );
[3702] Fix | Delete
add_filter( 'hidden_meta_boxes', 'et_pb_hidden_meta_boxes' );
[3703] Fix | Delete
}
[3704] Fix | Delete
add_action( 'init', 'et_pb_setup_theme', 11 );
[3705] Fix | Delete
[3706] Fix | Delete
/**
[3707] Fix | Delete
* Override metaboxes order to ensure Divi Builder metabox has top position.
[3708] Fix | Delete
*
[3709] Fix | Delete
* @since 3.17.3
[3710] Fix | Delete
*
[3711] Fix | Delete
* @param string $value Custom value.
[3712] Fix | Delete
*
[3713] Fix | Delete
* @return string
[3714] Fix | Delete
*/
[3715] Fix | Delete
function et_builder_override_meta_boxes_order( $value ) {
[3716] Fix | Delete
static $custom = false;
[3717] Fix | Delete
[3718] Fix | Delete
// Store the value on the first call;.
[3719] Fix | Delete
$custom = false === $custom ? $value : $custom;
[3720] Fix | Delete
[3721] Fix | Delete
return $custom;
[3722] Fix | Delete
}
[3723] Fix | Delete
[3724] Fix | Delete
/**
[3725] Fix | Delete
* Forcefully prioritize the Divi Builder metabox to be at the top.
[3726] Fix | Delete
* User drag&drop metabox order customizations are still supported.
[3727] Fix | Delete
* Required since not all plugins properly register their metaboxes in the add_meta_boxes hook.
[3728] Fix | Delete
*
[3729] Fix | Delete
* @since 3.17.2
[3730] Fix | Delete
*
[3731] Fix | Delete
* @return void
[3732] Fix | Delete
*/
[3733] Fix | Delete
function et_builder_prioritize_meta_box() {
[3734] Fix | Delete
global $wp_meta_boxes;
[3735] Fix | Delete
[3736] Fix | Delete
$screen = get_current_screen();
[3737] Fix | Delete
[3738] Fix | Delete
// Only prioritize Divi Builder metabox if current post type has Divi Builder enabled.
[3739] Fix | Delete
if ( ! in_array( $screen->post_type, et_builder_get_enabled_builder_post_types(), true ) ) {
[3740] Fix | Delete
return;
[3741] Fix | Delete
}
[3742] Fix | Delete
[3743] Fix | Delete
// Get custom order.
[3744] Fix | Delete
$page = $screen->id;
[3745] Fix | Delete
$option_name = "meta-box-order_$page";
[3746] Fix | Delete
$custom = get_user_option( $option_name );
[3747] Fix | Delete
[3748] Fix | Delete
foreach ( $wp_meta_boxes as $page => $contexts ) {
[3749] Fix | Delete
foreach ( $contexts as $context => $priorities ) {
[3750] Fix | Delete
foreach ( $priorities as $priority => $boxes ) {
[3751] Fix | Delete
if ( ! isset( $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ] ) ) {
[3752] Fix | Delete
continue;
[3753] Fix | Delete
}
[3754] Fix | Delete
[3755] Fix | Delete
$divi = $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ];
[3756] Fix | Delete
[3757] Fix | Delete
unset( $boxes[ ET_BUILDER_LAYOUT_POST_TYPE ] );
[3758] Fix | Delete
[3759] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride -- Push "The Divi Builder" metabox at top by updating `$wp_meta_boxes`.
[3760] Fix | Delete
$wp_meta_boxes[ $page ][ $context ][ $priority ] = array_merge( array( ET_BUILDER_LAYOUT_POST_TYPE => $divi ), $boxes );
[3761] Fix | Delete
[3762] Fix | Delete
// If our mbox is the first one in custom ordering.
[3763] Fix | Delete
if ( is_array( $custom ) && 0 === strpos( $custom[ $context ], ET_BUILDER_LAYOUT_POST_TYPE ) ) {
[3764] Fix | Delete
// Find all metaboxes that are not included in custom order.
[3765] Fix | Delete
$sorted = explode( ',', $custom[ $context ] );
[3766] Fix | Delete
$add = array_diff( array_keys( $boxes ), $sorted );
[3767] Fix | Delete
[3768] Fix | Delete
if ( $add ) {
[3769] Fix | Delete
// Add them after Divi.
[3770] Fix | Delete
$custom[ $context ] = implode( ',', array_merge( array( ET_BUILDER_LAYOUT_POST_TYPE ), $add, array_slice( $sorted, 1 ) ) );
[3771] Fix | Delete
[3772] Fix | Delete
// Store the custom value.
[3773] Fix | Delete
et_builder_override_meta_boxes_order( $custom );
[3774] Fix | Delete
// and override `get_user_option` so WP will use it.
[3775] Fix | Delete
add_filter( "get_user_option_{$option_name}", 'et_builder_override_meta_boxes_order' );
[3776] Fix | Delete
}
[3777] Fix | Delete
}
[3778] Fix | Delete
}
[3779] Fix | Delete
}
[3780] Fix | Delete
}
[3781] Fix | Delete
}
[3782] Fix | Delete
[3783] Fix | Delete
/**
[3784] Fix | Delete
* The page builders require the WP Heartbeat script in order to function. We ensure the heartbeat
[3785] Fix | Delete
* is loaded with the page builders by scheduling this callback to run right before scripts
[3786] Fix | Delete
* are output to the footer. {@see 'admin_enqueue_scripts', 'wp_footer'}
[3787] Fix | Delete
*/
[3788] Fix | Delete
function et_builder_maybe_ensure_heartbeat_script() {
[3789] Fix | Delete
// Don't perform any actions on 'wp_footer' if VB is not active.
[3790] Fix | Delete
if ( 'wp_footer' === current_filter() && empty( $_GET['et_fb'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification -- This function does not change any state, and is therefore not susceptible to CSRF.
[3791] Fix | Delete
return;
[3792] Fix | Delete
}
[3793] Fix | Delete
[3794] Fix | Delete
// We have to check both 'registered' AND 'enqueued' to cover cases where heartbeat has been
[3795] Fix | Delete
// de-registered because 'enqueued' will return `true` for a de-registered script at this stage.
[3796] Fix | Delete
$heartbeat_okay = wp_script_is( 'heartbeat', 'registered' ) && wp_script_is( 'heartbeat', 'enqueued' );
[3797] Fix | Delete
$autosave_okay = wp_script_is( 'autosave', 'registered' ) && wp_script_is( 'autosave', 'enqueued' );
[3798] Fix | Delete
[3799] Fix | Delete
if ( '1' === et_()->array_get( $_GET, 'et_bfb', '0' ) ) { // phpcs:ignore WordPress.Security.NonceVerification -- This function does not change any state, and is therefore not susceptible to CSRF.
[3800] Fix | Delete
// Do not enqueue WP autosave in the BFB iframe because it doesn't include #content / #excerpt / #title
[3801] Fix | Delete
// and will result in empty (browser) backups (note: still included in top window).
[3802] Fix | Delete
$autosave_okay = true;
[3803] Fix | Delete
[3804] Fix | Delete
wp_dequeue_script( 'autosave' );
[3805] Fix | Delete
}
[3806] Fix | Delete
[3807] Fix | Delete
if ( $heartbeat_okay && $autosave_okay ) {
[3808] Fix | Delete
return;
[3809] Fix | Delete
}
[3810] Fix | Delete
[3811] Fix | Delete
$suffix = SCRIPT_DEBUG ? '' : '.min';
[3812] Fix | Delete
[3813] Fix | Delete
// phpcs:disable WordPress.WP.EnqueuedResourceParameters -- Version numbers are not set to load latest scripts from the WP Core.
[3814] Fix | Delete
if ( ! $heartbeat_okay ) {
[3815] Fix | Delete
$heartbeat_src = "/wp-includes/js/heartbeat{$suffix}.js";
[3816] Fix | Delete
// wp-hooks was introduced in WP 5.0.
[3817] Fix | Delete
$deps = wp_script_is( 'wp-hooks', 'registered' ) ? array( 'jquery', 'wp-hooks' ) : array( 'jquery' );
[3818] Fix | Delete
wp_enqueue_script( 'heartbeat', $heartbeat_src, $deps, false, true );
[3819] Fix | Delete
wp_localize_script( 'heartbeat', 'heartbeatSettings', apply_filters( 'heartbeat_settings', array() ) );
[3820] Fix | Delete
}
[3821] Fix | Delete
[3822] Fix | Delete
if ( ! $autosave_okay ) {
[3823] Fix | Delete
$autosave_src = "/wp-includes/js/autosave{$suffix}.js";
[3824] Fix | Delete
wp_enqueue_script( 'autosave', $autosave_src, array( 'heartbeat' ), false, true );
[3825] Fix | Delete
}
[3826] Fix | Delete
// phpcs:enable
[3827] Fix | Delete
}
[3828] Fix | Delete
[3829] Fix | Delete
/**
[3830] Fix | Delete
* Enqueue dashicons in front-end if they are not enqueued (that happens when not logged in as admin).
[3831] Fix | Delete
*/
[3832] Fix | Delete
function et_builder_maybe_enqueue_dashicons() {
[3833] Fix | Delete
if ( wp_style_is( 'dashicons' ) ) {
[3834] Fix | Delete
return;
[3835] Fix | Delete
}
[3836] Fix | Delete
[3837] Fix | Delete
wp_enqueue_style( 'dashicons' );
[3838] Fix | Delete
}
[3839] Fix | Delete
add_action( 'admin_print_scripts-post-new.php', 'et_builder_maybe_ensure_heartbeat_script', 9 );
[3840] Fix | Delete
add_action( 'admin_print_scripts-post.php', 'et_builder_maybe_ensure_heartbeat_script', 9 );
[3841] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_maybe_enqueue_dashicons', 19 );
[3842] Fix | Delete
add_action( 'wp_footer', 'et_builder_maybe_ensure_heartbeat_script', 19 );
[3843] Fix | Delete
[3844] Fix | Delete
/**
[3845] Fix | Delete
* Set builder post type.
[3846] Fix | Delete
*
[3847] Fix | Delete
* @param string $post_type post type.
[3848] Fix | Delete
*/
[3849] Fix | Delete
function et_builder_set_post_type( $post_type = '' ) {
[3850] Fix | Delete
global $et_builder_post_type, $post;
[3851] Fix | Delete
[3852] Fix | Delete
$et_builder_post_type = ! empty( $post_type ) ? $post_type : $post->post_type;
[3853] Fix | Delete
}
[3854] Fix | Delete
[3855] Fix | Delete
/**
[3856] Fix | Delete
* Saves Metabox settings.
[3857] Fix | Delete
*
[3858] Fix | Delete
* @since 3.29.2 Included check to verify if constant exists before use.
[3859] Fix | Delete
* Throws error otherwise from PHP7.2.x
[3860] Fix | Delete
*
[3861] Fix | Delete
* @param int $post_id post id.
[3862] Fix | Delete
* @param WP_Post $post object.
[3863] Fix | Delete
*
[3864] Fix | Delete
* @return int
[3865] Fix | Delete
*/
[3866] Fix | Delete
function et_pb_metabox_settings_save_details( $post_id, $post ) {
[3867] Fix | Delete
global $pagenow;
[3868] Fix | Delete
[3869] Fix | Delete
if ( 'post.php' !== $pagenow ) {
[3870] Fix | Delete
return $post_id;
[3871] Fix | Delete
}
[3872] Fix | Delete
[3873] Fix | Delete
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
[3874] Fix | Delete
return $post_id;
[3875] Fix | Delete
}
[3876] Fix | Delete
[3877] Fix | Delete
// do not update builder post meta when Preview is loading.
[3878] Fix | Delete
if ( isset( $_POST['wp-preview'] ) && 'dopreview' === $_POST['wp-preview'] ) {
[3879] Fix | Delete
return $post_id;
[3880] Fix | Delete
}
[3881] Fix | Delete
[3882] Fix | Delete
$post_type = get_post_type_object( $post->post_type );
[3883] Fix | Delete
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) {
[3884] Fix | Delete
return $post_id;
[3885] Fix | Delete
}
[3886] Fix | Delete
[3887] Fix | Delete
if ( ! isset( $_POST['et_pb_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_pb_settings_nonce'], basename( __FILE__ ) ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
[3888] Fix | Delete
return $post_id;
[3889] Fix | Delete
}
[3890] Fix | Delete
[3891] Fix | Delete
if ( isset( $_POST['et_pb_use_builder'] ) ) {
[3892] Fix | Delete
$et_pb_use_builder_input = sanitize_text_field( $_POST['et_pb_use_builder'] );
[3893] Fix | Delete
[3894] Fix | Delete
update_post_meta( $post_id, '_et_pb_use_builder', $et_pb_use_builder_input );
[3895] Fix | Delete
[3896] Fix | Delete
if ( ! empty( $_POST['et_builder_version'] ) ) {
[3897] Fix | Delete
update_post_meta( $post_id, '_et_builder_version', sanitize_text_field( $_POST['et_builder_version'] ) );
[3898] Fix | Delete
}
[3899] Fix | Delete
[3900] Fix | Delete
$et_pb_show_page_creation_input = isset( $_POST['et_pb_show_page_creation'] ) ? sanitize_text_field( $_POST['et_pb_show_page_creation'] ) : false;
[3901] Fix | Delete
[3902] Fix | Delete
if ( 'on' === $et_pb_show_page_creation_input ) {
[3903] Fix | Delete
// Set page creation flow to on.
[3904] Fix | Delete
update_post_meta( $post_id, '_et_pb_show_page_creation', 'on' );
[3905] Fix | Delete
} elseif ( 'off' === $et_pb_show_page_creation_input ) {
[3906] Fix | Delete
// Delete page creation flow.
[3907] Fix | Delete
delete_post_meta( $post_id, '_et_pb_show_page_creation' );
[3908] Fix | Delete
} elseif ( false === $et_pb_show_page_creation_input && 'on' === $et_pb_use_builder_input ) {
[3909] Fix | Delete
$et_pb_show_page_creation_meta = get_post_meta( $post_id, '_et_pb_show_page_creation', true );
[3910] Fix | Delete
[3911] Fix | Delete
// Strip non-printable characters.
[3912] Fix | Delete
$post_content_cleaned = preg_replace( '/[\x00-\x1F\x7F]/u', '', $post->post_content );
[3913] Fix | Delete
[3914] Fix | Delete
preg_match_all( '/\[et_pb_section(.*?)?\]\[et_pb_row(.*?)?\]\[et_pb_column(.*?)?\](.+?)\[\/et_pb_column\]\[\/et_pb_row\]\[\/et_pb_section\]/m', $post_content_cleaned, $matches );
[3915] Fix | Delete
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
[3916] Fix | Delete
if ( 'on' === $et_pb_show_page_creation_meta ) {
[3917] Fix | Delete
// Set page creation flow to on.
[3918] Fix | Delete
update_post_meta( $post_id, '_et_pb_show_page_creation', 'off' );
[3919] Fix | Delete
}
[3920] Fix | Delete
} else {
[3921] Fix | Delete
delete_post_meta( $post_id, '_et_pb_show_page_creation' );
[3922] Fix | Delete
}
[3923] Fix | Delete
}
[3924] Fix | Delete
[3925] Fix | Delete
if ( 'on' !== $et_pb_use_builder_input ) {
[3926] Fix | Delete
if ( defined( 'ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY' ) ) {
[3927] Fix | Delete
delete_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY );
[3928] Fix | Delete
}
[3929] Fix | Delete
}
[3930] Fix | Delete
} else {
[3931] Fix | Delete
delete_post_meta( $post_id, '_et_pb_use_builder' );
[3932] Fix | Delete
delete_post_meta( $post_id, '_et_builder_version' );
[3933] Fix | Delete
if ( defined( 'ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY' ) ) {
[3934] Fix | Delete
delete_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY );
[3935] Fix | Delete
}
[3936] Fix | Delete
}
[3937] Fix | Delete
[3938] Fix | Delete
/**
[3939] Fix | Delete
* The et_save_post hook.
[3940] Fix | Delete
*
[3941] Fix | Delete
* @hooked et_builder_set_product_page_layout_meta - 10
[3942] Fix | Delete
*
[3943] Fix | Delete
* @param int $post_id
[3944] Fix | Delete
*/
[3945] Fix | Delete
do_action( 'et_save_post', $post_id );
[3946] Fix | Delete
[3947] Fix | Delete
// Do not process Page Settings if BFB is enabled. Were saving it via ajax.
[3948] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[3949] Fix | Delete
// But we still need to save old content.
[3950] Fix | Delete
if ( isset( $_POST['et_pb_old_content'] ) ) {
[3951] Fix | Delete
update_post_meta( $post_id, '_et_pb_old_content', $_POST['et_pb_old_content'] );
[3952] Fix | Delete
// WooCommerce Modules needs the following hook.
[3953] Fix | Delete
[3954] Fix | Delete
/**
[3955] Fix | Delete
* Fires after the `_et_pb_old_content` post meta is updated.
[3956] Fix | Delete
*
[3957] Fix | Delete
* In case you want to over-ride `_et_pb_old_content` content, this is the hook you should use.
[3958] Fix | Delete
*
[3959] Fix | Delete
* @see et_builder_wc_long_description_metabox_save()
[3960] Fix | Delete
*
[3961] Fix | Delete
* @since 3.29
[3962] Fix | Delete
*
[3963] Fix | Delete
* @param int $post_id Post ID.
[3964] Fix | Delete
* $param WP_Post $post The Post.
[3965] Fix | Delete
* $param array $_POST Request variables. This could be used for Nonce verification, etc.
[3966] Fix | Delete
*/
[3967] Fix | Delete
do_action( 'et_pb_old_content_updated', $post_id, $post, $_POST );
[3968] Fix | Delete
} else {
[3969] Fix | Delete
delete_post_meta( $post_id, '_et_pb_old_content' );
[3970] Fix | Delete
}
[3971] Fix | Delete
return $post_id;
[3972] Fix | Delete
}
[3973] Fix | Delete
[3974] Fix | Delete
// Only run AB Testing-related update sequence if AB Testing is allowed.
[3975] Fix | Delete
if ( et_pb_is_allowed( 'ab_testing' ) ) {
[3976] Fix | Delete
// Delete AB Testing settings' autosave.
[3977] Fix | Delete
delete_post_meta( $post_id, '_et_pb_use_ab_testing_draft' );
[3978] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_subjects_draft' );
[3979] Fix | Delete
[3980] Fix | Delete
if ( isset( $_POST['et_pb_use_ab_testing'] ) && in_array( $_POST['et_pb_use_ab_testing'], array( 'on', 'off' ), true ) ) {
[3981] Fix | Delete
update_post_meta( $post_id, '_et_pb_use_ab_testing', sanitize_text_field( $_POST['et_pb_use_ab_testing'] ) );
[3982] Fix | Delete
[3983] Fix | Delete
if ( 'on' === $_POST['et_pb_use_ab_testing'] ) {
[3984] Fix | Delete
if ( ! get_post_meta( $post_id, '_et_pb_ab_testing_id', true ) ) {
[3985] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_testing_id', wp_rand() );
[3986] Fix | Delete
}
[3987] Fix | Delete
} else {
[3988] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_testing_id' );
[3989] Fix | Delete
delete_post_meta( $post_id, 'et_pb_subjects_cache' );
[3990] Fix | Delete
et_pb_ab_remove_stats( $post_id );
[3991] Fix | Delete
}
[3992] Fix | Delete
} else {
[3993] Fix | Delete
delete_post_meta( $post_id, '_et_pb_use_ab_testing' );
[3994] Fix | Delete
delete_post_meta( $post_id, '_et_pb_ab_testing_id' );
[3995] Fix | Delete
}
[3996] Fix | Delete
[3997] Fix | Delete
if ( isset( $_POST['et_pb_ab_subjects'] ) && '' !== $_POST['et_pb_ab_subjects'] ) {
[3998] Fix | Delete
update_post_meta( $post_id, '_et_pb_ab_subjects', et_prevent_duplicate_item( sanitize_text_field( $_POST['et_pb_ab_subjects'] ), ',' ) );
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function