Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: functions.php
)
[10000] Fix | Delete
);
[10001] Fix | Delete
}
[10002] Fix | Delete
add_action( 'admin_bar_menu', 'et_fb_add_admin_bar_link', 999 );
[10003] Fix | Delete
[10004] Fix | Delete
/**
[10005] Fix | Delete
* Retrieve and process saved Layouts.
[10006] Fix | Delete
* It different than the function which retrieves saved Sections, Rows and Modules from library because layouts require different processing
[10007] Fix | Delete
*/
[10008] Fix | Delete
function et_fb_get_saved_layouts() {
[10009] Fix | Delete
if ( ! isset( $_POST['et_fb_retrieve_library_modules_nonce'] ) || ! wp_verify_nonce( $_POST['et_fb_retrieve_library_modules_nonce'], 'et_fb_retrieve_library_modules_nonce' ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
[10010] Fix | Delete
die( -1 );
[10011] Fix | Delete
}
[10012] Fix | Delete
[10013] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[10014] Fix | Delete
die( -1 );
[10015] Fix | Delete
}
[10016] Fix | Delete
[10017] Fix | Delete
// Reduce number of results per page if we're hosted on wpengine to avoid 500 error due to memory allocation.
[10018] Fix | Delete
// This is caused by one of their custom mu-plugins doing additional stuff but we have no control over there.
[10019] Fix | Delete
$page_size = function_exists( 'is_wpe' ) || function_exists( 'is_wpe_snapshot' ) ? 25 : 50;
[10020] Fix | Delete
$post_type = ! empty( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : 'post';
[10021] Fix | Delete
$layouts_type = ! empty( $_POST['et_load_layouts_type'] ) ? sanitize_text_field( $_POST['et_load_layouts_type'] ) : 'all';
[10022] Fix | Delete
$start_from = ! empty( $_POST['et_templates_start_page'] ) ? sanitize_text_field( $_POST['et_templates_start_page'] ) : 0;
[10023] Fix | Delete
[10024] Fix | Delete
$post_type = apply_filters( 'et_pb_show_all_layouts_built_for_post_type', $post_type, $layouts_type );
[10025] Fix | Delete
[10026] Fix | Delete
$all_layouts_data = et_pb_retrieve_templates( 'layout', '', 'false', '0', $post_type, $layouts_type, array( $start_from, $page_size ) );
[10027] Fix | Delete
$all_layouts_data_processed = $all_layouts_data;
[10028] Fix | Delete
$next_page = 'none';
[10029] Fix | Delete
[10030] Fix | Delete
if ( 0 !== $start_from && empty( $all_layouts_data ) ) {
[10031] Fix | Delete
$all_layouts_data_processed = array();
[10032] Fix | Delete
} else {
[10033] Fix | Delete
if ( empty( $all_layouts_data ) ) {
[10034] Fix | Delete
$all_layouts_data_processed = array( 'error' => esc_html__( 'You have not saved any items to your Divi Library yet. Once an item has been saved to your library, it will appear here for easy use.', 'et_builder' ) );
[10035] Fix | Delete
} else {
[10036] Fix | Delete
foreach ( $all_layouts_data as $index => $data ) {
[10037] Fix | Delete
$all_layouts_data_processed[ $index ]['shortcode'] = et_fb_process_shortcode( $data['shortcode'] );
[10038] Fix | Delete
}
[10039] Fix | Delete
$next_page = $start_from + $page_size;
[10040] Fix | Delete
}
[10041] Fix | Delete
}
[10042] Fix | Delete
[10043] Fix | Delete
$json_templates = wp_json_encode(
[10044] Fix | Delete
array(
[10045] Fix | Delete
'templates_data' => $all_layouts_data_processed,
[10046] Fix | Delete
'next_page' => $next_page,
[10047] Fix | Delete
)
[10048] Fix | Delete
);
[10049] Fix | Delete
[10050] Fix | Delete
die( et_core_intentionally_unescaped( $json_templates, 'html' ) );
[10051] Fix | Delete
}
[10052] Fix | Delete
[10053] Fix | Delete
add_action( 'wp_ajax_et_fb_get_saved_layouts', 'et_fb_get_saved_layouts' );
[10054] Fix | Delete
[10055] Fix | Delete
/**
[10056] Fix | Delete
* Ajax Callback: Process imported content.
[10057] Fix | Delete
*/
[10058] Fix | Delete
function et_fb_process_imported_content() {
[10059] Fix | Delete
if ( ! isset( $_POST['et_fb_process_imported_data_nonce'] ) || ! wp_verify_nonce( $_POST['et_fb_process_imported_data_nonce'], 'et_fb_process_imported_data_nonce' ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
[10060] Fix | Delete
die( -1 );
[10061] Fix | Delete
}
[10062] Fix | Delete
[10063] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[10064] Fix | Delete
die( -1 );
[10065] Fix | Delete
}
[10066] Fix | Delete
[10067] Fix | Delete
// phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- Value in `$_POST['et_raw_shortcode']` is processed by `et_fb_process_shortcode` and being returned in ajax response.
[10068] Fix | Delete
$processed_shortcode = isset( $_POST['et_raw_shortcode'] ) ? et_fb_process_shortcode( stripslashes( $_POST['et_raw_shortcode'] ) ) : '';
[10069] Fix | Delete
[10070] Fix | Delete
die( wp_json_encode( $processed_shortcode ) );
[10071] Fix | Delete
}
[10072] Fix | Delete
add_action( 'wp_ajax_et_fb_process_imported_content', 'et_fb_process_imported_content' );
[10073] Fix | Delete
[10074] Fix | Delete
/**
[10075] Fix | Delete
* Builder initial content.
[10076] Fix | Delete
*
[10077] Fix | Delete
* @param string $content post content.
[10078] Fix | Delete
* @param integer $post_id post id.
[10079] Fix | Delete
*
[10080] Fix | Delete
* @return string
[10081] Fix | Delete
*/
[10082] Fix | Delete
function et_fb_maybe_get_bfb_initial_content( $content, $post_id ) {
[10083] Fix | Delete
$from_post = filter_input( INPUT_GET, 'from_post', FILTER_SANITIZE_STRING );
[10084] Fix | Delete
if ( ! empty( $from_post ) && 'empty' !== $from_post ) {
[10085] Fix | Delete
$copy_content_from = get_post( $from_post );
[10086] Fix | Delete
$existing_content = $copy_content_from->post_content;
[10087] Fix | Delete
[10088] Fix | Delete
if ( '' !== $existing_content && has_shortcode( $existing_content, 'et_pb_section' ) ) {
[10089] Fix | Delete
return $existing_content;
[10090] Fix | Delete
}
[10091] Fix | Delete
}
[10092] Fix | Delete
[10093] Fix | Delete
// process the content only for BFB.
[10094] Fix | Delete
if ( ! et_builder_bfb_enabled() ) {
[10095] Fix | Delete
return $content;
[10096] Fix | Delete
}
[10097] Fix | Delete
[10098] Fix | Delete
// If content already has a section, it means builder is active and activation has to be
[10099] Fix | Delete
// skipped to avoid nested and unwanted builder structure.
[10100] Fix | Delete
if ( has_shortcode( $content, 'et_pb_section' ) ) {
[10101] Fix | Delete
return $content;
[10102] Fix | Delete
}
[10103] Fix | Delete
[10104] Fix | Delete
// Save old content.
[10105] Fix | Delete
$saved_old_content = get_post_meta( $post_id, '_et_pb_old_content', true );
[10106] Fix | Delete
$save_old_content = false;
[10107] Fix | Delete
$post = get_post( $post_id );
[10108] Fix | Delete
[10109] Fix | Delete
if ( '' !== $content ) {
[10110] Fix | Delete
$save_old_content = update_post_meta( $post_id, '_et_pb_old_content', $content );
[10111] Fix | Delete
}
[10112] Fix | Delete
[10113] Fix | Delete
/**
[10114] Fix | Delete
* Filters the flag that sets default Content during Builder activation.
[10115] Fix | Delete
*
[10116] Fix | Delete
* @since 3.29
[10117] Fix | Delete
*
[10118] Fix | Delete
* @used-by et_builder_wc_init()
[10119] Fix | Delete
*/
[10120] Fix | Delete
if ( apply_filters( 'et_builder_skip_content_activation', false, $post ) ) {
[10121] Fix | Delete
return $content;
[10122] Fix | Delete
}
[10123] Fix | Delete
[10124] Fix | Delete
if ( true !== $save_old_content && $saved_old_content !== $content && '' !== $content ) {
[10125] Fix | Delete
return $content;
[10126] Fix | Delete
}
[10127] Fix | Delete
[10128] Fix | Delete
$text_module = '' !== $content ? '[et_pb_text admin_label="Text"]' . $content . '[/et_pb_text]' : '';
[10129] Fix | Delete
[10130] Fix | Delete
// Re-format content.
[10131] Fix | Delete
$updated_content =
[10132] Fix | Delete
'[et_pb_section admin_label="section"]
[10133] Fix | Delete
[et_pb_row admin_label="row"]
[10134] Fix | Delete
[et_pb_column type="4_4"]' . $text_module . '[/et_pb_column]
[10135] Fix | Delete
[/et_pb_row]
[10136] Fix | Delete
[/et_pb_section]';
[10137] Fix | Delete
[10138] Fix | Delete
return $updated_content;
[10139] Fix | Delete
}
[10140] Fix | Delete
[10141] Fix | Delete
/**
[10142] Fix | Delete
* Called via async AJAX call after the builder rendered. It will regenerate both helper/definitions files.
[10143] Fix | Delete
* If their content changed, the builder will trigger a page reload to use the updated cached files.
[10144] Fix | Delete
*/
[10145] Fix | Delete
function et_fb_update_builder_assets() {
[10146] Fix | Delete
if ( ! isset( $_POST['et_fb_helper_nonce'] ) || ! wp_verify_nonce( $_POST['et_fb_helper_nonce'], 'et_fb_update_helper_assets_nonce' ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
[10147] Fix | Delete
die( -1 );
[10148] Fix | Delete
}
[10149] Fix | Delete
[10150] Fix | Delete
$post_id = ! empty( $_POST['et_post_id'] ) ? sanitize_text_field( $_POST['et_post_id'] ) : '';
[10151] Fix | Delete
[10152] Fix | Delete
if ( ! current_user_can( 'edit_post', $post_id ) ) {
[10153] Fix | Delete
die( -1 );
[10154] Fix | Delete
}
[10155] Fix | Delete
[10156] Fix | Delete
// Set current post as global $post.
[10157] Fix | Delete
$post = get_post( $post_id ); // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
[10158] Fix | Delete
[10159] Fix | Delete
$post_type = ! empty( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : 'post';
[10160] Fix | Delete
[10161] Fix | Delete
// Update helpers cached js file.
[10162] Fix | Delete
$helpers = et_fb_get_dynamic_asset( 'helpers', $post_type, true );
[10163] Fix | Delete
// Update definitions cached js file.
[10164] Fix | Delete
$definitions = et_fb_get_dynamic_asset( 'definitions', $post_type, true );
[10165] Fix | Delete
[10166] Fix | Delete
// When either definitions or helpers needs an update, also clear modules cache.
[10167] Fix | Delete
if ( $definitions['updated'] || $helpers['updated'] ) {
[10168] Fix | Delete
$modules_cache = ET_Builder_Element::get_cache_filename( $post_type );
[10169] Fix | Delete
[10170] Fix | Delete
if ( file_exists( $modules_cache ) ) {
[10171] Fix | Delete
@unlink( $modules_cache ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- `unlink` may fail with the permissions denied error.
[10172] Fix | Delete
}
[10173] Fix | Delete
}
[10174] Fix | Delete
[10175] Fix | Delete
die(
[10176] Fix | Delete
wp_json_encode(
[10177] Fix | Delete
array(
[10178] Fix | Delete
'helpers' => $helpers,
[10179] Fix | Delete
'definitions' => $definitions,
[10180] Fix | Delete
)
[10181] Fix | Delete
)
[10182] Fix | Delete
);
[10183] Fix | Delete
}
[10184] Fix | Delete
add_action( 'wp_ajax_et_fb_update_builder_assets', 'et_fb_update_builder_assets' );
[10185] Fix | Delete
[10186] Fix | Delete
/**
[10187] Fix | Delete
* Returns builder definitions.
[10188] Fix | Delete
*
[10189] Fix | Delete
* @param string $post_type post type.
[10190] Fix | Delete
*
[10191] Fix | Delete
* @return array
[10192] Fix | Delete
*/
[10193] Fix | Delete
function et_fb_get_builder_definitions( $post_type ) {
[10194] Fix | Delete
[10195] Fix | Delete
// force render builder data when retrieving builder definition to ensure definitions retrieved via ajax call
[10196] Fix | Delete
// equal to definitions retrieved on wp_footer when no dynamic asset cache found.
[10197] Fix | Delete
add_filter( 'et_builder_module_force_render', '__return_true' );
[10198] Fix | Delete
[10199] Fix | Delete
$fields_data = array();
[10200] Fix | Delete
$fields_data['custom_css'] = ET_Builder_Element::get_custom_css_fields( $post_type );
[10201] Fix | Delete
$fields_data['advanced_fields'] = ET_Builder_Element::get_advanced_fields( $post_type );
[10202] Fix | Delete
$fields_data['general_fields'] = ET_Builder_Element::get_general_fields( $post_type );
[10203] Fix | Delete
$fields_data['childModuleTitles'] = ET_Builder_Element::get_child_module_titles( $post_type );
[10204] Fix | Delete
$fields_data['optionsToggles'] = ET_Builder_Element::get_toggles( $post_type );
[10205] Fix | Delete
$fields_data['customTabs'] = ET_Builder_Element::get_tabs( $post_type );
[10206] Fix | Delete
$fields_data['customTabsFields'] = ET_Builder_Element::get_settings_modal_tabs_fields( $post_type );
[10207] Fix | Delete
$fields_data['customLayoutsTabs'] = ET_Builder_Library::builder_library_modal_custom_tabs( $post_type );
[10208] Fix | Delete
$fields_data['moduleItemsConfig'] = ET_Builder_Element::get_module_items_configs( $post_type );
[10209] Fix | Delete
$fields_data['moduleTransitions'] = ET_Builder_Element::get_modules_transitions( $post_type );
[10210] Fix | Delete
$fields_data['contact_form_input_defaults'] = et_fb_process_shortcode(
[10211] Fix | Delete
sprintf(
[10212] Fix | Delete
'[et_pb_contact_field field_title="%1$s" field_type="input" field_id="Name" required_mark="on" fullwidth_field="off" /][et_pb_contact_field field_title="%2$s" field_type="email" field_id="Email" required_mark="on" fullwidth_field="off" /][et_pb_contact_field field_title="%3$s" field_type="text" field_id="Message" required_mark="on" fullwidth_field="on" /]',
[10213] Fix | Delete
esc_attr__( 'Name', 'et_builder' ),
[10214] Fix | Delete
esc_attr__( 'Email Address', 'et_builder' ),
[10215] Fix | Delete
esc_attr__( 'Message', 'et_builder' )
[10216] Fix | Delete
)
[10217] Fix | Delete
);
[10218] Fix | Delete
[10219] Fix | Delete
// Remove duplicates from field definitions.
[10220] Fix | Delete
$map = array();
[10221] Fix | Delete
$unique_fields = array();
[10222] Fix | Delete
$unique_count = 0;
[10223] Fix | Delete
[10224] Fix | Delete
foreach ( array( 'custom_css', 'general_fields', 'advanced_fields' ) as $source ) {
[10225] Fix | Delete
$definitions = &$fields_data[ $source ];
[10226] Fix | Delete
$module_names = array_keys( $definitions );
[10227] Fix | Delete
[10228] Fix | Delete
foreach ( $module_names as $module_name ) {
[10229] Fix | Delete
$module = &$definitions[ $module_name ];
[10230] Fix | Delete
$setting_names = array_keys( $module );
[10231] Fix | Delete
[10232] Fix | Delete
foreach ( $setting_names as $setting_name ) {
[10233] Fix | Delete
$setting = &$module[ $setting_name ];
[10234] Fix | Delete
[10235] Fix | Delete
if ( 'advanced_defaults' === $setting_name ) {
[10236] Fix | Delete
// advanced_defaults are just duplicated data, we can rebuilt them later.
[10237] Fix | Delete
$setting = false;
[10238] Fix | Delete
continue;
[10239] Fix | Delete
}
[10240] Fix | Delete
[10241] Fix | Delete
$key = wp_json_encode( $setting );
[10242] Fix | Delete
[10243] Fix | Delete
if ( ! isset( $map[ $key ] ) ) {
[10244] Fix | Delete
// Found a duplicate here.
[10245] Fix | Delete
$unique_fields[] = $setting;
[10246] Fix | Delete
$map[ $key ] = $unique_count++;
[10247] Fix | Delete
}
[10248] Fix | Delete
[10249] Fix | Delete
$setting = $map[ $key ];
[10250] Fix | Delete
}
[10251] Fix | Delete
}
[10252] Fix | Delete
}
[10253] Fix | Delete
[10254] Fix | Delete
// Remove force builder data render.
[10255] Fix | Delete
remove_filter( 'et_builder_module_force_render', '__return_true' );
[10256] Fix | Delete
[10257] Fix | Delete
// No longer needed.
[10258] Fix | Delete
unset( $map );
[10259] Fix | Delete
[10260] Fix | Delete
// Include the unique fields in the AJAX payload.
[10261] Fix | Delete
$fields_data['unique_fields'] = $unique_fields;
[10262] Fix | Delete
[10263] Fix | Delete
return $fields_data;
[10264] Fix | Delete
}
[10265] Fix | Delete
[10266] Fix | Delete
/**
[10267] Fix | Delete
* Returns builder shortcode object.
[10268] Fix | Delete
*
[10269] Fix | Delete
* @param string $post_type the post type.
[10270] Fix | Delete
* @param integer $post_id the post id.
[10271] Fix | Delete
* @param string $layout_type layout type.
[10272] Fix | Delete
*
[10273] Fix | Delete
* @return array
[10274] Fix | Delete
*/
[10275] Fix | Delete
function et_fb_get_builder_shortcode_object( $post_type, $post_id, $layout_type ) {
[10276] Fix | Delete
[10277] Fix | Delete
// We need to store the current post when this function is executed in a wp-admin page
[10278] Fix | Delete
// to prevent post based modules included in the shortcode from altering the loop.
[10279] Fix | Delete
global $post;
[10280] Fix | Delete
$backup = $post;
[10281] Fix | Delete
[10282] Fix | Delete
$fields_data = array();
[10283] Fix | Delete
add_filter( 'et_builder_module_force_render', '__return_true' );
[10284] Fix | Delete
[10285] Fix | Delete
$post_data = get_post( $post_id );
[10286] Fix | Delete
$post_data_post_modified = gmdate( 'U', strtotime( $post_data->post_modified ) );
[10287] Fix | Delete
$post_content = $post_data->post_content;
[10288] Fix | Delete
[10289] Fix | Delete
// if autosave exists here, return it with the real content, autosave.js and getServerSavedPostData() will look for it.
[10290] Fix | Delete
$current_user_id = get_current_user_id();
[10291] Fix | Delete
// Store one autosave per author. If there is already an autosave, overwrite it.
[10292] Fix | Delete
$autosave = wp_get_post_autosave( $post_id, $current_user_id );
[10293] Fix | Delete
[10294] Fix | Delete
if ( ! empty( $autosave ) ) {
[10295] Fix | Delete
$autosave_post_modified = gmdate( 'U', strtotime( $autosave->post_modified ) );
[10296] Fix | Delete
[10297] Fix | Delete
if ( $autosave_post_modified > $post_data_post_modified ) {
[10298] Fix | Delete
$fields_data['autosave_shortcode_object'] = et_fb_process_shortcode( $autosave->post_content );
[10299] Fix | Delete
$fields_data['has_newer_autosave'] = true;
[10300] Fix | Delete
} else {
[10301] Fix | Delete
$fields_data['has_newer_autosave'] = false;
[10302] Fix | Delete
}
[10303] Fix | Delete
// Delete the autosave, becuase we will present the option to use the autosave to the user, and they will use it or not
[10304] Fix | Delete
// we need to delete the db copy now.
[10305] Fix | Delete
wp_delete_post_revision( $autosave->ID );
[10306] Fix | Delete
}
[10307] Fix | Delete
[10308] Fix | Delete
switch ( $layout_type ) {
[10309] Fix | Delete
case 'module':
[10310] Fix | Delete
$use_fullwidth_section = false !== strpos( $post_content, '[et_pb_fullwidth_' ) ? true : false;
[10311] Fix | Delete
// Remove module placeholders.
[10312] Fix | Delete
$post_content = false !== strpos( $post_content, 'et_pb_fullwidth_module_placeholder' ) || false !== strpos( $post_content, 'et_pb_module_placeholder' ) ? '' : $post_content;
[10313] Fix | Delete
[10314] Fix | Delete
if ( ! $use_fullwidth_section ) {
[10315] Fix | Delete
$post_content = sprintf( '[et_pb_row][et_pb_column type="4_4"]%1$s[/et_pb_column][/et_pb_row]', $post_content );
[10316] Fix | Delete
}
[10317] Fix | Delete
[10318] Fix | Delete
$post_content = sprintf(
[10319] Fix | Delete
'[et_pb_section%2$s]%1$s[/et_pb_section]',
[10320] Fix | Delete
$post_content,
[10321] Fix | Delete
$use_fullwidth_section ? ' fullwidth="on"' : ''
[10322] Fix | Delete
);
[10323] Fix | Delete
[10324] Fix | Delete
break;
[10325] Fix | Delete
case 'row':
[10326] Fix | Delete
$post_content = '[et_pb_section]' . $post_content . '[/et_pb_section]';
[10327] Fix | Delete
break;
[10328] Fix | Delete
}
[10329] Fix | Delete
[10330] Fix | Delete
$post_content = et_fb_maybe_get_bfb_initial_content( $post_content, $post_id );
[10331] Fix | Delete
[10332] Fix | Delete
/**
[10333] Fix | Delete
* Filters the raw post content when the Builder is loaded.
[10334] Fix | Delete
*
[10335] Fix | Delete
* @since 3.29
[10336] Fix | Delete
*
[10337] Fix | Delete
* @param string $post_content The raw/unprocessed post content.
[10338] Fix | Delete
* @param int $post_id Post ID.
[10339] Fix | Delete
*/
[10340] Fix | Delete
$post_content = apply_filters( 'et_fb_load_raw_post_content', $post_content, $post_id );
[10341] Fix | Delete
[10342] Fix | Delete
$fields_data['shortcode_object'] = et_fb_process_shortcode( $post_content );
[10343] Fix | Delete
[10344] Fix | Delete
remove_filter( 'et_builder_module_force_render', '__return_true' );
[10345] Fix | Delete
[10346] Fix | Delete
// Restore post.
[10347] Fix | Delete
$post = $backup; // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- This is legit way of setting global $post.
[10348] Fix | Delete
setup_postdata( $post );
[10349] Fix | Delete
[10350] Fix | Delete
return $fields_data;
[10351] Fix | Delete
}
[10352] Fix | Delete
[10353] Fix | Delete
/**
[10354] Fix | Delete
* Ajax Callback: Retrieve builder data on frontend app load.
[10355] Fix | Delete
*/
[10356] Fix | Delete
function et_fb_retrieve_builder_data() {
[10357] Fix | Delete
if ( ! isset( $_POST['et_fb_helper_nonce'] ) || ! wp_verify_nonce( $_POST['et_fb_helper_nonce'], 'et_fb_load_helper_assets_nonce' ) ) { // phpcs:ignore ET.Sniffs.ValidatedSanitizedInput -- The nonce value is used only for comparision in the `wp_verify_nonce`.
[10358] Fix | Delete
die( -1 );
[10359] Fix | Delete
}
[10360] Fix | Delete
[10361] Fix | Delete
$post_id = ! empty( $_POST['et_post_id'] ) ? sanitize_text_field( $_POST['et_post_id'] ) : '';
[10362] Fix | Delete
[10363] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
[10364] Fix | Delete
die( -1 );
[10365] Fix | Delete
}
[10366] Fix | Delete
[10367] Fix | Delete
$post_type = ! empty( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : 'post';
[10368] Fix | Delete
[10369] Fix | Delete
$layout_type = ! empty( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : '';
[10370] Fix | Delete
[10371] Fix | Delete
$fields_data = array_merge(
[10372] Fix | Delete
et_fb_get_builder_definitions( $post_type ),
[10373] Fix | Delete
et_fb_get_builder_shortcode_object( $post_type, $post_id, $layout_type )
[10374] Fix | Delete
);
[10375] Fix | Delete
[10376] Fix | Delete
// Enable zlib compression.
[10377] Fix | Delete
et_builder_enable_zlib_compression();
[10378] Fix | Delete
[10379] Fix | Delete
die( wp_json_encode( $fields_data ) );
[10380] Fix | Delete
}
[10381] Fix | Delete
add_action( 'wp_ajax_et_fb_retrieve_builder_data', 'et_fb_retrieve_builder_data' );
[10382] Fix | Delete
[10383] Fix | Delete
/**
[10384] Fix | Delete
* Replaces site_url in a json string with its protocol-less version.
[10385] Fix | Delete
*
[10386] Fix | Delete
* @param string $json The json string that contain site url.
[10387] Fix | Delete
*
[10388] Fix | Delete
* @return string
[10389] Fix | Delete
*/
[10390] Fix | Delete
function et_fb_remove_site_url_protocol( $json ) {
[10391] Fix | Delete
$no_proto = str_replace( '/', '\/', preg_replace( '#^\w+:#', '', get_site_url() ) );
[10392] Fix | Delete
$from = array(
[10393] Fix | Delete
"https:$no_proto" => $no_proto,
[10394] Fix | Delete
"http:$no_proto" => $no_proto,
[10395] Fix | Delete
);
[10396] Fix | Delete
return strtr( $json, $from );
[10397] Fix | Delete
}
[10398] Fix | Delete
[10399] Fix | Delete
/**
[10400] Fix | Delete
* Used to update the content of the cached definitions js file.
[10401] Fix | Delete
*
[10402] Fix | Delete
* @param string $content content? @todo Add param description.
[10403] Fix | Delete
* @param string $post_type Post type? @todo Add param description.
[10404] Fix | Delete
*
[10405] Fix | Delete
* @return string
[10406] Fix | Delete
*/
[10407] Fix | Delete
function et_fb_get_asset_definitions( $content, $post_type ) {
[10408] Fix | Delete
$definitions = et_fb_get_builder_definitions( $post_type );
[10409] Fix | Delete
return sprintf(
[10410] Fix | Delete
'window.ETBuilderBackend=jQuery.extend(true,%s,window.ETBuilderBackend)',
[10411] Fix | Delete
et_fb_remove_site_url_protocol( wp_json_encode( $definitions, ET_BUILDER_JSON_ENCODE_OPTIONS ) )
[10412] Fix | Delete
);
[10413] Fix | Delete
}
[10414] Fix | Delete
add_filter( 'et_fb_get_asset_definitions', 'et_fb_get_asset_definitions', 10, 2 );
[10415] Fix | Delete
[10416] Fix | Delete
/**
[10417] Fix | Delete
* Return Divi options setting page link.
[10418] Fix | Delete
*
[10419] Fix | Delete
* @return mixed|string|void
[10420] Fix | Delete
*/
[10421] Fix | Delete
function et_pb_get_options_page_link() {
[10422] Fix | Delete
// Builder plugin has different path to options page.
[10423] Fix | Delete
if ( et_is_builder_plugin_active() ) {
[10424] Fix | Delete
return admin_url( 'admin.php?page=et_divi_options#tab_et_dashboard_tab_content_api_main' );
[10425] Fix | Delete
}
[10426] Fix | Delete
[10427] Fix | Delete
return apply_filters( 'et_pb_theme_options_link', admin_url( 'admin.php?page=et_divi_options' ) );
[10428] Fix | Delete
}
[10429] Fix | Delete
[10430] Fix | Delete
/**
[10431] Fix | Delete
* Localization: Product tour text.
[10432] Fix | Delete
*
[10433] Fix | Delete
* @param integer $post_id The post id to determine the Save/Publish button text from post status.
[10434] Fix | Delete
*
[10435] Fix | Delete
* @return array
[10436] Fix | Delete
*/
[10437] Fix | Delete
function et_fb_get_product_tour_text( $post_id ) {
[10438] Fix | Delete
$post_status = get_post_status( $post_id );
[10439] Fix | Delete
[10440] Fix | Delete
$product_tour_text = array(
[10441] Fix | Delete
'start' => array(
[10442] Fix | Delete
'title' => esc_html__( 'Welcome To The Divi Builder', 'et_builder' ),
[10443] Fix | Delete
'description' => sprintf(
[10444] Fix | Delete
// translators: %10$s: Tour video overlay, %1$s: "Section" - label, %2$s: Add icon markup, %3$s: "Row" - label, %4$s: Add icon markup, %5$s: "Modules" - label, %6$s: Add icon markup, %7$s: Settings gear icon markup, %9$s: Documentation link markup.
[10445] Fix | Delete
__( '%10$sBuilding beautiful pages is a breeze using the Visual Builder. To get started, add a new %1$s to your page by pressing the %2$s button. Next, add a %3$s of columns inside your section by pressing the %4$s button. Finally, start adding some content %5$s inside your columns by pressing the %6$s button. You can customize the design and content of any element on the page by pressing the %7$s button. If you ever need help, visit our %9$s page for a full list of tutorials.', 'et_builder' ),
[10446] Fix | Delete
sprintf( '<span class="et_fb_tour_text et_fb_tour_text_blue">%1$s</span>', esc_html__( 'Section' ) ),
[10447] Fix | Delete
'<span class="et_fb_tour_icon et_fb_tour_icon_blue"><svg viewBox="0 0 28 28" preserveAspectRatio="xMidYMid meet" shapeRendering="geometricPrecision"><g><path d="M18 13h-3v-3a1 1 0 0 0-2 0v3h-3a1 1 0 0 0 0 2h3v3a1 1 0 0 0 2 0v-3h3a1 1 0 0 0 0-2z" fillRule="evenodd" /></g></svg></span>',
[10448] Fix | Delete
sprintf( '<span class="et_fb_tour_text et_fb_tour_text_green">%1$s</span>', esc_html__( 'Row' ) ),
[10449] Fix | Delete
'<span class="et_fb_tour_icon et_fb_tour_icon_green"><svg viewBox="0 0 28 28" preserveAspectRatio="xMidYMid meet" shapeRendering="geometricPrecision"><g><path d="M18 13h-3v-3a1 1 0 0 0-2 0v3h-3a1 1 0 0 0 0 2h3v3a1 1 0 0 0 2 0v-3h3a1 1 0 0 0 0-2z" fillRule="evenodd" /></g></svg></span>',
[10450] Fix | Delete
sprintf( '<span class="et_fb_tour_text et_fb_tour_text_black">%1$s</span>', esc_html__( 'Modules' ) ),
[10451] Fix | Delete
'<span class="et_fb_tour_icon"><svg viewBox="0 0 28 28" preserveAspectRatio="xMidYMid meet" shapeRendering="geometricPrecision"><g><path d="M18 13h-3v-3a1 1 0 0 0-2 0v3h-3a1 1 0 0 0 0 2h3v3a1 1 0 0 0 2 0v-3h3a1 1 0 0 0 0-2z" fillRule="evenodd" /></g></svg></span>',
[10452] Fix | Delete
'<span class="et_fb_tour_icon"><svg viewBox="0 0 28 28" preserveAspectRatio="xMidYMid meet" shapeRendering="geometricPrecision"><g><path d="M20.426 13.088l-1.383-.362a.874.874 0 0 1-.589-.514l-.043-.107a.871.871 0 0 1 .053-.779l.721-1.234a.766.766 0 0 0-.116-.917 6.682 6.682 0 0 0-.252-.253.768.768 0 0 0-.917-.116l-1.234.722a.877.877 0 0 1-.779.053l-.107-.044a.87.87 0 0 1-.513-.587l-.362-1.383a.767.767 0 0 0-.73-.567h-.358a.768.768 0 0 0-.73.567l-.362 1.383a.878.878 0 0 1-.513.589l-.107.044a.875.875 0 0 1-.778-.054l-1.234-.722a.769.769 0 0 0-.918.117c-.086.082-.17.166-.253.253a.766.766 0 0 0-.115.916l.721 1.234a.87.87 0 0 1 .053.779l-.043.106a.874.874 0 0 1-.589.514l-1.382.362a.766.766 0 0 0-.567.731v.357a.766.766 0 0 0 .567.731l1.383.362c.266.07.483.26.588.513l.043.107a.87.87 0 0 1-.053.779l-.721 1.233a.767.767 0 0 0 .115.917c.083.087.167.171.253.253a.77.77 0 0 0 .918.116l1.234-.721a.87.87 0 0 1 .779-.054l.107.044a.878.878 0 0 1 .513.589l.362 1.383a.77.77 0 0 0 .731.567h.356a.766.766 0 0 0 .73-.567l.362-1.383a.878.878 0 0 1 .515-.589l.107-.044a.875.875 0 0 1 .778.054l1.234.721c.297.17.672.123.917-.117.087-.082.171-.166.253-.253a.766.766 0 0 0 .116-.917l-.721-1.234a.874.874 0 0 1-.054-.779l.044-.107a.88.88 0 0 1 .589-.513l1.383-.362a.77.77 0 0 0 .567-.731v-.357a.772.772 0 0 0-.569-.724v-.005zm-6.43 3.9a2.986 2.986 0 1 1 2.985-2.986 3 3 0 0 1-2.985 2.987v-.001z" fillRule="evenodd" /></g></svg></span>',
[10453] Fix | Delete
'<span class="et_fb_tour_text et_fb_tour_text_black">?</span>',
[10454] Fix | Delete
sprintf( '<a target="_blank" href="https://www.elegantthemes.com/documentation/divi/" class="et_fb_tour_text et_fb_tour_text_black">%1$s</a>', esc_html__( 'Documentation' ) ),
[10455] Fix | Delete
sprintf(
[10456] Fix | Delete
'<div class="et-fb-tour-video-overlay" data-video="https://www.youtube.com/embed/JXZIGZqr9OE?rel=0&autoplay=1">
[10457] Fix | Delete
<img src="%1$s"/>
[10458] Fix | Delete
<div class="et-fb-play-overlay"></div>
[10459] Fix | Delete
</div>',
[10460] Fix | Delete
esc_url( ET_BUILDER_URI . '/frontend-builder/assets/img/product-tour-intro.jpg' )
[10461] Fix | Delete
)
[10462] Fix | Delete
),
[10463] Fix | Delete
'endButtonText' => esc_html__( 'Start Building', 'et_builder' ),
[10464] Fix | Delete
'skipButtonText' => esc_html__( 'Take the Tour', 'et_builder' ),
[10465] Fix | Delete
),
[10466] Fix | Delete
'loadLayout' => array(
[10467] Fix | Delete
'title' => esc_html__( 'Load A New Layout', 'et_builder' ),
[10468] Fix | Delete
'description' => esc_html__( 'Loading pre-made layouts is a great way to jump-start your new page. The Divi Builder comes with dozens of layouts to choose from, and you can find lots of great free layouts online too. You can save your favorite layouts to the Divi Library and load them on new pages or share them with the community. Click the highlighted button to open the layouts menu and select a pre-made layout.', 'et_builder' ),
[10469] Fix | Delete
),
[10470] Fix | Delete
'selectLayoutPack' => array(
[10471] Fix | Delete
'title' => esc_html__( 'Choose A Layout Pack', 'et_builder' ),
[10472] Fix | Delete
'description' => esc_html__( 'Here you can see a list of pre-made layout packs that ship with the Divi Builder. You can also access layouts that you have saved to your Divi Library. Choose the “Divi Builder Demo” layout pack to see the layouts it includes.', 'et_builder' ),
[10473] Fix | Delete
),
[10474] Fix | Delete
'loadLayoutItem' => array(
[10475] Fix | Delete
'title' => esc_html__( 'Choose A Layout To Start With', 'et_builder' ),
[10476] Fix | Delete
'description' => esc_html__( 'Now you can see more details about the layout pack as well as a list of the layouts it includes. Click “Use Layout” to apply the layout to your page.', 'et_builder' ),
[10477] Fix | Delete
),
[10478] Fix | Delete
'addSection' => array(
[10479] Fix | Delete
'title' => esc_html__( 'Add A New Section', 'et_builder' ),
[10480] Fix | Delete
'description' => sprintf(
[10481] Fix | Delete
// translators: %1$s: "Sections" - label, %2$s: "Rows" - label.
[10482] Fix | Delete
__( 'Now that your pre-made layout has been loaded, we can start adding new content to the page. The Divi Builder organizes content using %1$s, %2$s and Modules. Sections are the largest organizational element. Click the highlighted button to add a new section to the page.', 'et_builder' ),
[10483] Fix | Delete
sprintf( '<span class="et_fb_tour_text_blue">%1$s</span>', esc_html__( 'Sections' ) ),
[10484] Fix | Delete
sprintf( '<span class="et_fb_tour_text_green">%1$s</span>', esc_html__( 'Rows' ) )
[10485] Fix | Delete
),
[10486] Fix | Delete
),
[10487] Fix | Delete
'selectSectionType' => array(
[10488] Fix | Delete
'title' => esc_html__( 'Choose A Section Type', 'et_builder' ),
[10489] Fix | Delete
'description' => sprintf(
[10490] Fix | Delete
// translators: %1$s: "Regular" - label text, %2$s: "Specialty" - label tex, %3$s: "Fullwidth" - label tex.
[10491] Fix | Delete
__( 'The Divi Builder has three different section types. %1$s sections conform to the standard width of your page layout. %2$s Sections can be used to create advanced sidebar layouts. %3$s sections extend the full width of your page and can be used with fullwidth modules. Click the “Regular” section button to add a new section to your page.', 'et_builder' ),
[10492] Fix | Delete
sprintf( '<span class="et_fb_tour_text_blue">%1$s</span>', esc_html__( 'Regular' ) ),
[10493] Fix | Delete
sprintf( '<span class="et_fb_tour_text_red">%1$s</span>', esc_html__( 'Specialty' ) ),
[10494] Fix | Delete
sprintf( '<span class="et_fb_tour_text_purple">%1$s</span>', esc_html__( 'Fullwidth' ) )
[10495] Fix | Delete
),
[10496] Fix | Delete
),
[10497] Fix | Delete
'selectRow' => array(
[10498] Fix | Delete
'title' => esc_html__( 'Add A New Row Of Columns', 'et_builder' ),
[10499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function