Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: functions.php
'has_no_permission' => array(
[5000] Fix | Delete
'title' => esc_html__( 'Unauthorized Action', 'et_builder' ),
[5001] Fix | Delete
'desc' => esc_html__( 'You do not have permission to edit the module, row or section in this split test.', 'et_builder' ),
[5002] Fix | Delete
),
[5003] Fix | Delete
[5004] Fix | Delete
// AB Testing.
[5005] Fix | Delete
'select_ab_testing_subject' => $ab_settings['select_subject'],
[5006] Fix | Delete
'select_ab_testing_goal' => $ab_settings['select_goal'],
[5007] Fix | Delete
'configure_ab_testing_alternative' => $ab_settings['configure_alternative'],
[5008] Fix | Delete
'select_ab_testing_winner_first' => $ab_settings['select_winner_first'],
[5009] Fix | Delete
'select_ab_testing_subject_first' => $ab_settings['select_subject_first'],
[5010] Fix | Delete
'select_ab_testing_goal_first' => $ab_settings['select_goal_first'],
[5011] Fix | Delete
'cannot_select_subject_parent_as_goal' => $ab_settings['cannot_select_subject_parent_as_goal'],
[5012] Fix | Delete
'cannot_select_global_children_as_subject' => $ab_settings['cannot_select_global_children_as_subject'],
[5013] Fix | Delete
'cannot_select_global_children_as_goal' => $ab_settings['cannot_select_global_children_as_goal'],
[5014] Fix | Delete
[5015] Fix | Delete
// Save to Library.
[5016] Fix | Delete
'cannot_save_app_layout_has_ab_testing' => $ab_settings['cannot_save_app_layout_has_ab_testing'],
[5017] Fix | Delete
'cannot_save_section_layout_has_ab_testing' => $ab_settings['cannot_save_section_layout_has_ab_testing'],
[5018] Fix | Delete
'cannot_save_row_layout_has_ab_testing' => $ab_settings['cannot_save_row_layout_has_ab_testing'],
[5019] Fix | Delete
'cannot_save_row_inner_layout_has_ab_testing' => $ab_settings['cannot_save_row_inner_layout_has_ab_testing'],
[5020] Fix | Delete
'cannot_save_module_layout_has_ab_testing' => $ab_settings['cannot_save_module_layout_has_ab_testing'],
[5021] Fix | Delete
[5022] Fix | Delete
// Load / Clear Layout.
[5023] Fix | Delete
'cannot_load_layout_has_ab_testing' => $ab_settings['cannot_load_layout_has_ab_testing'],
[5024] Fix | Delete
'cannot_clear_layout_has_ab_testing' => $ab_settings['cannot_clear_layout_has_ab_testing'],
[5025] Fix | Delete
[5026] Fix | Delete
// Cannot Import / Export Layout (Portability).
[5027] Fix | Delete
'cannot_import_export_layout_has_ab_testing' => $ab_settings['cannot_import_export_layout_has_ab_testing'],
[5028] Fix | Delete
[5029] Fix | Delete
// Moving Goal / Subject.
[5030] Fix | Delete
'cannot_move_module_goal_out_from_subject' => $ab_settings['cannot_move_module_goal_out_from_subject'],
[5031] Fix | Delete
'cannot_move_row_goal_out_from_subject' => $ab_settings['cannot_move_row_goal_out_from_subject'],
[5032] Fix | Delete
'cannot_move_goal_into_subject' => $ab_settings['cannot_move_goal_into_subject'],
[5033] Fix | Delete
'cannot_move_subject_into_goal' => $ab_settings['cannot_move_subject_into_goal'],
[5034] Fix | Delete
[5035] Fix | Delete
// Cloning + Has Goal.
[5036] Fix | Delete
'cannot_clone_section_has_goal' => $ab_settings['cannot_clone_section_has_goal'],
[5037] Fix | Delete
'cannot_clone_row_has_goal' => $ab_settings['cannot_clone_row_has_goal'],
[5038] Fix | Delete
[5039] Fix | Delete
// Removing + Has Goal.
[5040] Fix | Delete
'cannot_remove_section_has_goal' => $ab_settings['cannot_remove_section_has_goal'],
[5041] Fix | Delete
'cannot_remove_row_has_goal' => $ab_settings['cannot_remove_row_has_goal'],
[5042] Fix | Delete
[5043] Fix | Delete
// Removing + Has Unremovable Subjects.
[5044] Fix | Delete
'cannot_remove_section_has_unremovable_subject' => $ab_settings['cannot_remove_section_has_unremovable_subject'],
[5045] Fix | Delete
'cannot_remove_row_has_unremovable_subject' => $ab_settings['cannot_remove_row_has_unremovable_subject'],
[5046] Fix | Delete
[5047] Fix | Delete
// View stats summary table heading.
[5048] Fix | Delete
'view_stats_thead_titles' => $ab_settings['view_stats_thead_titles'],
[5049] Fix | Delete
);
[5050] Fix | Delete
wp_localize_script( 'et_pb_admin_js', 'et_pb_ab_js_options', apply_filters( 'et_pb_ab_js_options', $pb_ab_js_options ) );
[5051] Fix | Delete
[5052] Fix | Delete
$pb_help_options = array(
[5053] Fix | Delete
'shortcuts' => et_builder_get_shortcuts( 'bb' ),
[5054] Fix | Delete
);
[5055] Fix | Delete
wp_localize_script( 'et_pb_admin_js', 'et_pb_help_options', apply_filters( 'et_pb_help_options', $pb_help_options ) );
[5056] Fix | Delete
[5057] Fix | Delete
et_core_load_main_fonts();
[5058] Fix | Delete
[5059] Fix | Delete
wp_enqueue_style( 'et_pb_admin_css', ET_BUILDER_URI . '/styles/style.css', array(), ET_BUILDER_VERSION );
[5060] Fix | Delete
wp_enqueue_style( 'et_pb_admin_date_css', ET_BUILDER_URI . '/styles/jquery-ui-1.12.1.custom.css', array(), ET_BUILDER_VERSION );
[5061] Fix | Delete
[5062] Fix | Delete
wp_add_inline_style( 'et_pb_admin_css', et_pb_ab_get_subject_rank_colors_style() );
[5063] Fix | Delete
}
[5064] Fix | Delete
endif;
[5065] Fix | Delete
[5066] Fix | Delete
/**
[5067] Fix | Delete
* Set et-editor-available-post-* cookie
[5068] Fix | Delete
*/
[5069] Fix | Delete
function et_pb_set_editor_available_cookie() {
[5070] Fix | Delete
$post_id = isset( $_GET['post'] ) ? absint( $_GET['post'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification -- This function does not change any state, and is therefore not susceptible to CSRF.
[5071] Fix | Delete
[5072] Fix | Delete
$headers_sent = headers_sent();
[5073] Fix | Delete
[5074] Fix | Delete
if ( et_builder_should_load_framework() && is_admin() && ! $headers_sent && ! empty( $post_id ) ) {
[5075] Fix | Delete
setcookie( 'et-editor-available-post-' . $post_id . '-bb', 'bb', time() + ( MINUTE_IN_SECONDS * 30 ), SITECOOKIEPATH, false, is_ssl() );
[5076] Fix | Delete
}
[5077] Fix | Delete
}
[5078] Fix | Delete
add_action( 'admin_init', 'et_pb_set_editor_available_cookie' );
[5079] Fix | Delete
[5080] Fix | Delete
/**
[5081] Fix | Delete
* List of history meta.
[5082] Fix | Delete
*
[5083] Fix | Delete
* @return array History meta.
[5084] Fix | Delete
*/
[5085] Fix | Delete
function et_pb_history_localization() {
[5086] Fix | Delete
return array(
[5087] Fix | Delete
'verb' => array(
[5088] Fix | Delete
'did' => esc_html__( 'Did', 'et_builder' ),
[5089] Fix | Delete
'added' => esc_html__( 'Added', 'et_builder' ),
[5090] Fix | Delete
'edited' => esc_html__( 'Edited', 'et_builder' ),
[5091] Fix | Delete
'removed' => esc_html__( 'Removed', 'et_builder' ),
[5092] Fix | Delete
'moved' => esc_html__( 'Moved', 'et_builder' ),
[5093] Fix | Delete
'expanded' => esc_html__( 'Expanded', 'et_builder' ),
[5094] Fix | Delete
'collapsed' => esc_html__( 'Collapsed', 'et_builder' ),
[5095] Fix | Delete
'locked' => esc_html__( 'Locked', 'et_builder' ),
[5096] Fix | Delete
'unlocked' => esc_html__( 'Unlocked', 'et_builder' ),
[5097] Fix | Delete
'cloned' => esc_html__( 'Cloned', 'et_builder' ),
[5098] Fix | Delete
'cleared' => esc_html__( 'Cleared', 'et_builder' ),
[5099] Fix | Delete
'enabled' => esc_html__( 'Enabled', 'et_builder' ),
[5100] Fix | Delete
'disabled' => esc_html__( 'Disabled', 'et_builder' ),
[5101] Fix | Delete
'copied' => esc_html__( 'Copied', 'et_builder' ),
[5102] Fix | Delete
'reset' => esc_html__( 'Reset', 'et_builder' ),
[5103] Fix | Delete
'cut' => esc_html__( 'Cut', 'et_builder' ),
[5104] Fix | Delete
'pasted' => esc_html__( 'Pasted', 'et_builder' ),
[5105] Fix | Delete
'pasted_styles' => esc_html__( 'Pasted Styles', 'et_builder' ),
[5106] Fix | Delete
'renamed' => esc_html__( 'Renamed', 'et_builder' ),
[5107] Fix | Delete
'loaded' => esc_html__( 'Loaded', 'et_builder' ),
[5108] Fix | Delete
'turnon' => esc_html__( 'Turned On', 'et_builder' ),
[5109] Fix | Delete
'turnoff' => esc_html__( 'Turned Off', 'et_builder' ),
[5110] Fix | Delete
'globalon' => esc_html__( 'Made Global', 'et_builder' ),
[5111] Fix | Delete
'globaloff' => esc_html__( 'Disabled Global', 'et_builder' ),
[5112] Fix | Delete
'configured' => esc_html__( 'Configured', 'et_builder' ),
[5113] Fix | Delete
'find_replace' => esc_html__( 'Find & Replace', 'et_builder' ),
[5114] Fix | Delete
'extend_styles' => esc_html__( 'Extend Styles', 'et_builder' ),
[5115] Fix | Delete
'imported' => esc_html__( 'Imported From Layout', 'et_builder' ),
[5116] Fix | Delete
'presetCreated' => esc_html__( 'Preset Created For', 'et_builder' ),
[5117] Fix | Delete
'presetNameChanged' => esc_html__( 'Preset Name Changed For', 'et_builder' ),
[5118] Fix | Delete
'presetDeleted' => esc_html__( 'Preset Deleted For', 'et_builder' ),
[5119] Fix | Delete
'presetAssignedAsDefault' => esc_html__( 'Preset Assigned As Default For', 'et_builder' ),
[5120] Fix | Delete
),
[5121] Fix | Delete
'noun' => array(
[5122] Fix | Delete
'section' => esc_html__( 'Section', 'et_builder' ),
[5123] Fix | Delete
'saved_section' => esc_html__( 'Saved Section', 'et_builder' ),
[5124] Fix | Delete
'fullwidth_section' => esc_html__( 'Fullwidth Section', 'et_builder' ),
[5125] Fix | Delete
'specialty_section' => esc_html__( 'Specialty Section', 'et_builder' ),
[5126] Fix | Delete
'column' => esc_html__( 'Column', 'et_builder' ),
[5127] Fix | Delete
'row' => esc_html__( 'Row', 'et_builder' ),
[5128] Fix | Delete
'saved_row' => esc_html__( 'Saved Row', 'et_builder' ),
[5129] Fix | Delete
'module' => esc_html__( 'Module', 'et_builder' ),
[5130] Fix | Delete
'saved_module' => esc_html__( 'Saved Module', 'et_builder' ),
[5131] Fix | Delete
'page' => esc_html__( 'Page', 'et_builder' ),
[5132] Fix | Delete
'layout' => et_builder_i18n( 'Layout' ),
[5133] Fix | Delete
'abtesting' => esc_html__( 'Split Testing', 'et_builder' ),
[5134] Fix | Delete
'settings' => esc_html__( 'Settings', 'et_builder' ),
[5135] Fix | Delete
),
[5136] Fix | Delete
'addition' => array(
[5137] Fix | Delete
'phone' => esc_html__( 'on Phone', 'et_builder' ),
[5138] Fix | Delete
'tablet' => esc_html__( 'on Tablet', 'et_builder' ),
[5139] Fix | Delete
'desktop' => esc_html__( 'on Desktop', 'et_builder' ),
[5140] Fix | Delete
),
[5141] Fix | Delete
);
[5142] Fix | Delete
}
[5143] Fix | Delete
[5144] Fix | Delete
/**
[5145] Fix | Delete
* Page Settings Metabox code is included in builder.js which won't be loaded unless BB is.
[5146] Fix | Delete
* In such cases (eg BFB or GB are enabled) we provide the mbox js logic in a separate file.
[5147] Fix | Delete
*
[5148] Fix | Delete
* @return void
[5149] Fix | Delete
*/
[5150] Fix | Delete
function et_pb_metabox_scripts() {
[5151] Fix | Delete
// Only act if `builder.js` isn't enqueued.
[5152] Fix | Delete
if ( ! wp_script_is( 'et_pb_admin_js' ) ) {
[5153] Fix | Delete
global $typenow;
[5154] Fix | Delete
wp_enqueue_script( 'et_page_settings_metabox_js', ET_BUILDER_URI . '/scripts/page-settings-metabox.js', array( 'jquery' ), ET_BUILDER_PRODUCT_VERSION, true );
[5155] Fix | Delete
$pb_options = array(
[5156] Fix | Delete
'post_type' => $typenow,
[5157] Fix | Delete
'is_third_party_post_type' => et_builder_is_post_type_custom( $typenow ) ? 'yes' : 'no',
[5158] Fix | Delete
);
[5159] Fix | Delete
wp_localize_script( 'et_page_settings_metabox_js', 'et_pb_options', $pb_options );
[5160] Fix | Delete
}
[5161] Fix | Delete
}
[5162] Fix | Delete
[5163] Fix | Delete
/**
[5164] Fix | Delete
* Prevents the Builder mbox from being hidden.
[5165] Fix | Delete
*
[5166] Fix | Delete
* @param string[] $hidden all hidden metaboxes.
[5167] Fix | Delete
*
[5168] Fix | Delete
* @return mixed
[5169] Fix | Delete
*/
[5170] Fix | Delete
function et_pb_hidden_meta_boxes( $hidden ) {
[5171] Fix | Delete
$found = array_search( 'et_pb_layout', $hidden, true );
[5172] Fix | Delete
if ( false !== $found ) {
[5173] Fix | Delete
unset( $hidden[ $found ] );
[5174] Fix | Delete
}
[5175] Fix | Delete
return $hidden;
[5176] Fix | Delete
}
[5177] Fix | Delete
[5178] Fix | Delete
/**
[5179] Fix | Delete
* Add "The Divi Builder" BB metabox.
[5180] Fix | Delete
*
[5181] Fix | Delete
* @param string $post_type post type.
[5182] Fix | Delete
* @param WP_Post $post post object.
[5183] Fix | Delete
*/
[5184] Fix | Delete
function et_pb_add_custom_box( $post_type, $post ) {
[5185] Fix | Delete
add_action( 'admin_enqueue_scripts', 'et_pb_metabox_scripts', 99 );
[5186] Fix | Delete
// Do not add BB metabox if GB is active on this page.
[5187] Fix | Delete
if ( et_core_is_gutenberg_enabled() ) {
[5188] Fix | Delete
return;
[5189] Fix | Delete
}
[5190] Fix | Delete
[5191] Fix | Delete
// Do not add BB metabox if builder is not activate on this page.
[5192] Fix | Delete
if ( et_builder_bfb_enabled() && ! et_pb_is_pagebuilder_used( $post->ID ) ) {
[5193] Fix | Delete
return;
[5194] Fix | Delete
}
[5195] Fix | Delete
[5196] Fix | Delete
$post_types = et_builder_get_builder_post_types();
[5197] Fix | Delete
$add = in_array( $post_type, $post_types, true );
[5198] Fix | Delete
[5199] Fix | Delete
if ( ! $add && ! empty( $post ) && et_builder_enabled_for_post( $post->ID ) ) {
[5200] Fix | Delete
$add = true;
[5201] Fix | Delete
}
[5202] Fix | Delete
[5203] Fix | Delete
if ( $add ) {
[5204] Fix | Delete
add_meta_box( ET_BUILDER_LAYOUT_POST_TYPE, esc_html__( 'The Divi Builder', 'et_builder' ), 'et_pb_pagebuilder_meta_box', $post_type, 'normal', 'high' );
[5205] Fix | Delete
}
[5206] Fix | Delete
}
[5207] Fix | Delete
[5208] Fix | Delete
if ( ! function_exists( 'et_pb_get_the_author_posts_link' ) ) :
[5209] Fix | Delete
/**
[5210] Fix | Delete
* Return a post author link markup.
[5211] Fix | Delete
*/
[5212] Fix | Delete
function et_pb_get_the_author_posts_link() {
[5213] Fix | Delete
global $authordata, $post;
[5214] Fix | Delete
[5215] Fix | Delete
// Fallback for preview.
[5216] Fix | Delete
if ( empty( $authordata ) && isset( $post->post_author ) ) {
[5217] Fix | Delete
$authordata = get_userdata( $post->post_author ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- If $authordata is not set then set it.
[5218] Fix | Delete
}
[5219] Fix | Delete
[5220] Fix | Delete
// If $authordata is empty, don't continue.
[5221] Fix | Delete
if ( empty( $authordata ) ) {
[5222] Fix | Delete
return;
[5223] Fix | Delete
}
[5224] Fix | Delete
[5225] Fix | Delete
$link = sprintf(
[5226] Fix | Delete
'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
[5227] Fix | Delete
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
[5228] Fix | Delete
// translators: post author name.
[5229] Fix | Delete
esc_attr( sprintf( __( 'Posts by %s', 'et_builder' ), get_the_author() ) ),
[5230] Fix | Delete
get_the_author()
[5231] Fix | Delete
);
[5232] Fix | Delete
return apply_filters( 'the_author_posts_link', $link );
[5233] Fix | Delete
}
[5234] Fix | Delete
endif;
[5235] Fix | Delete
[5236] Fix | Delete
if ( ! function_exists( 'et_pb_get_comments_popup_link' ) ) :
[5237] Fix | Delete
/**
[5238] Fix | Delete
* Return comments link.
[5239] Fix | Delete
*
[5240] Fix | Delete
* @param bool|string $zero text to display when 0 comments.
[5241] Fix | Delete
* @param bool|string $one text to display when 1 comment.
[5242] Fix | Delete
* @param bool|string $more text to display for more than 1 comments.
[5243] Fix | Delete
*/
[5244] Fix | Delete
function et_pb_get_comments_popup_link( $zero = false, $one = false, $more = false ) {
[5245] Fix | Delete
$id = get_the_ID();
[5246] Fix | Delete
$number = get_comments_number( $id );
[5247] Fix | Delete
[5248] Fix | Delete
if ( 0 === $number && ! comments_open() && ! pings_open() ) {
[5249] Fix | Delete
return;
[5250] Fix | Delete
}
[5251] Fix | Delete
[5252] Fix | Delete
if ( $number > 1 ) {
[5253] Fix | Delete
// translators: more comments text.
[5254] Fix | Delete
$output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments', 'et_builder' ) : $more );
[5255] Fix | Delete
} elseif ( 0 === $number ) {
[5256] Fix | Delete
$output = ( false === $zero ) ? __( 'No Comments', 'et_builder' ) : $zero;
[5257] Fix | Delete
} else { // must be one.
[5258] Fix | Delete
$output = ( false === $one ) ? __( '1 Comment', 'et_builder' ) : $one;
[5259] Fix | Delete
}
[5260] Fix | Delete
[5261] Fix | Delete
do_action( 'et_builder_before_comments_number' );
[5262] Fix | Delete
[5263] Fix | Delete
$link = '<span class="comments-number"><a href="' . esc_url( get_permalink() . '#respond' ) . '">' . apply_filters( 'comments_number', esc_html( $output ), esc_html( $number ) ) . '</a></span>';
[5264] Fix | Delete
[5265] Fix | Delete
do_action( 'et_builder_after_comments_number' );
[5266] Fix | Delete
[5267] Fix | Delete
return $link;
[5268] Fix | Delete
}
[5269] Fix | Delete
endif;
[5270] Fix | Delete
[5271] Fix | Delete
if ( ! function_exists( 'et_pb_postinfo_meta' ) ) :
[5272] Fix | Delete
/**
[5273] Fix | Delete
* Return post meta.
[5274] Fix | Delete
*
[5275] Fix | Delete
* @param string[] $postinfo post info e.g date, author, categories.
[5276] Fix | Delete
* @param string $date_format date format.
[5277] Fix | Delete
* @param string $comment_zero text to display for 0 comments.
[5278] Fix | Delete
* @param string $comment_one text to display for 1 comments.
[5279] Fix | Delete
* @param string $comment_more text to display for more comments.
[5280] Fix | Delete
*/
[5281] Fix | Delete
function et_pb_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ) {
[5282] Fix | Delete
$postinfo_meta = array();
[5283] Fix | Delete
[5284] Fix | Delete
if ( in_array( 'author', $postinfo, true ) ) {
[5285] Fix | Delete
$postinfo_meta[] = ' ' . esc_html__( 'by', 'et_builder' ) . ' <span class="author vcard">' . et_pb_get_the_author_posts_link() . '</span>';
[5286] Fix | Delete
}
[5287] Fix | Delete
[5288] Fix | Delete
if ( in_array( 'date', $postinfo, true ) ) {
[5289] Fix | Delete
$postinfo_meta[] = '<span class="published">' . esc_html( get_the_time( wp_unslash( $date_format ) ) ) . '</span>';
[5290] Fix | Delete
}
[5291] Fix | Delete
[5292] Fix | Delete
if ( in_array( 'categories', $postinfo, true ) ) {
[5293] Fix | Delete
$categories_list = get_the_category_list( ', ' );
[5294] Fix | Delete
[5295] Fix | Delete
// do not output anything if no categories retrieved.
[5296] Fix | Delete
if ( '' !== $categories_list ) {
[5297] Fix | Delete
$postinfo_meta[] = $categories_list;
[5298] Fix | Delete
}
[5299] Fix | Delete
}
[5300] Fix | Delete
[5301] Fix | Delete
if ( in_array( 'comments', $postinfo, true ) ) {
[5302] Fix | Delete
$postinfo_meta[] = et_pb_get_comments_popup_link( $comment_zero, $comment_one, $comment_more );
[5303] Fix | Delete
}
[5304] Fix | Delete
[5305] Fix | Delete
return implode( ' | ', array_filter( $postinfo_meta ) );
[5306] Fix | Delete
}
[5307] Fix | Delete
endif;
[5308] Fix | Delete
[5309] Fix | Delete
[5310] Fix | Delete
if ( ! function_exists( 'et_pb_fix_shortcodes' ) ) {
[5311] Fix | Delete
/**
[5312] Fix | Delete
* Fix shortcodes? @todo Add function doc.
[5313] Fix | Delete
*
[5314] Fix | Delete
* @param string $content post content.
[5315] Fix | Delete
* @param bool $is_raw_content whether content is row.
[5316] Fix | Delete
*
[5317] Fix | Delete
* @return string|string[]|null
[5318] Fix | Delete
*/
[5319] Fix | Delete
function et_pb_fix_shortcodes( $content, $is_raw_content = false ) {
[5320] Fix | Delete
// Turn back the "data-et-target-link" attribute as "target" attribte
[5321] Fix | Delete
// that has been made before saving the content in "et_fb_process_to_shortcode" function.
[5322] Fix | Delete
if ( false !== strpos( $content, 'data-et-target-link=' ) ) {
[5323] Fix | Delete
$content = str_replace( ' data-et-target-link=', ' target=', $content );
[5324] Fix | Delete
}
[5325] Fix | Delete
[5326] Fix | Delete
if ( $is_raw_content ) {
[5327] Fix | Delete
$content = et_builder_replace_code_content_entities( $content );
[5328] Fix | Delete
$content = ET_Builder_Element::convert_smart_quotes_and_amp( $content );
[5329] Fix | Delete
}
[5330] Fix | Delete
[5331] Fix | Delete
$slugs = ET_Builder_Element::get_module_slugs_by_post_type();
[5332] Fix | Delete
[5333] Fix | Delete
// The current patterns take care to replace only the shortcodes that extends `ET_Builder_Element` class
[5334] Fix | Delete
// In order to avoid cases like this: `[3:45]<br>`
[5335] Fix | Delete
// The pattern looks like this `(\[\/?(et_pb_section|et_pb_column|et_pb_row)[^\]]*\])`.
[5336] Fix | Delete
$shortcode_pattern = sprintf( '(\[\/?(%s)[^\]]*\])', implode( '|', $slugs ) );
[5337] Fix | Delete
$opening_pattern = '(<br\s*\/?>|<p>|\n)+';
[5338] Fix | Delete
$closing_pattern = '(<br\s*\/?>|<\/p>|\n)+';
[5339] Fix | Delete
$space_pattern = '[\s*|\n]*';
[5340] Fix | Delete
[5341] Fix | Delete
// Replace `]</p>`, `]<br>` `]\n` with `]`
[5342] Fix | Delete
// Make sure to remove any closing `</p>` tags or line breaks or new lines after shortcode tag.
[5343] Fix | Delete
$pattern_1 = sprintf( '/%1$s%2$s%3$s/', $shortcode_pattern, $space_pattern, $closing_pattern );
[5344] Fix | Delete
[5345] Fix | Delete
// Replace `<p>[`, `<br>[` `\n[` with `[`
[5346] Fix | Delete
// Make sure to remove any opening `<p>` tags or line breaks or new lines before shortcode tag.
[5347] Fix | Delete
$pattern_2 = sprintf( '/%1$s%2$s%3$s/', $opening_pattern, $space_pattern, $shortcode_pattern );
[5348] Fix | Delete
[5349] Fix | Delete
$content = preg_replace( $pattern_1, '$1', $content );
[5350] Fix | Delete
$content = preg_replace( $pattern_2, '$2', $content );
[5351] Fix | Delete
[5352] Fix | Delete
return $content;
[5353] Fix | Delete
}
[5354] Fix | Delete
}
[5355] Fix | Delete
[5356] Fix | Delete
if ( ! function_exists( 'et_pb_load_global_module' ) ) {
[5357] Fix | Delete
/**
[5358] Fix | Delete
* Return gloval module content.
[5359] Fix | Delete
*
[5360] Fix | Delete
* @param integer $global_id layout id.
[5361] Fix | Delete
* @param string $row_type row type.
[5362] Fix | Delete
* @param string $prev_bg Previous background color.
[5363] Fix | Delete
* @param string $next_bg next background color.
[5364] Fix | Delete
*
[5365] Fix | Delete
* @return string|string[]|null
[5366] Fix | Delete
*/
[5367] Fix | Delete
function et_pb_load_global_module( $global_id, $row_type = '', $prev_bg = '', $next_bg = '' ) {
[5368] Fix | Delete
$global_shortcode = '';
[5369] Fix | Delete
[5370] Fix | Delete
if ( '' !== $global_id ) {
[5371] Fix | Delete
$query = new WP_Query(
[5372] Fix | Delete
array(
[5373] Fix | Delete
'p' => (int) $global_id,
[5374] Fix | Delete
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
[5375] Fix | Delete
)
[5376] Fix | Delete
);
[5377] Fix | Delete
[5378] Fix | Delete
if ( ! empty( $query->post ) ) {
[5379] Fix | Delete
// Call the_post() to properly configure post data. Make sure to call the_post() and
[5380] Fix | Delete
// wp_reset_postdata() only if the posts result exist to avoid unexpected issues.
[5381] Fix | Delete
$query->the_post();
[5382] Fix | Delete
[5383] Fix | Delete
wp_reset_postdata();
[5384] Fix | Delete
[5385] Fix | Delete
$global_shortcode = $query->post->post_content;
[5386] Fix | Delete
[5387] Fix | Delete
if ( '' !== $row_type && 'et_pb_row_inner' === $row_type ) {
[5388] Fix | Delete
$global_shortcode = str_replace( 'et_pb_row', 'et_pb_row_inner', $global_shortcode );
[5389] Fix | Delete
$global_shortcode = str_replace( 'et_pb_column', 'et_pb_column_inner', $global_shortcode );
[5390] Fix | Delete
}
[5391] Fix | Delete
}
[5392] Fix | Delete
}
[5393] Fix | Delete
[5394] Fix | Delete
// Set provided prev_background_color.
[5395] Fix | Delete
if ( ! empty( $prev_bg ) ) {
[5396] Fix | Delete
$global_shortcode = preg_replace( '/prev_background_color="(.*?)"/', 'prev_background_color="' . $prev_bg . '"', $global_shortcode, 1 );
[5397] Fix | Delete
}
[5398] Fix | Delete
[5399] Fix | Delete
// Set provided next_background_color.
[5400] Fix | Delete
if ( ! empty( $next_bg ) ) {
[5401] Fix | Delete
$global_shortcode = preg_replace( '/next_background_color="(.*?)"/', 'next_background_color="' . $next_bg . '"', $global_shortcode, 1 );
[5402] Fix | Delete
}
[5403] Fix | Delete
[5404] Fix | Delete
return $global_shortcode;
[5405] Fix | Delete
}
[5406] Fix | Delete
}
[5407] Fix | Delete
[5408] Fix | Delete
if ( ! function_exists( 'et_pb_extract_shortcode_content' ) ) {
[5409] Fix | Delete
/**
[5410] Fix | Delete
* Return the shortcode content.
[5411] Fix | Delete
*
[5412] Fix | Delete
* @param string $content content.
[5413] Fix | Delete
* @param string $shortcode_name shortcode name.
[5414] Fix | Delete
*
[5415] Fix | Delete
* @return bool|false|string
[5416] Fix | Delete
*/
[5417] Fix | Delete
function et_pb_extract_shortcode_content( $content, $shortcode_name ) {
[5418] Fix | Delete
[5419] Fix | Delete
$start = strpos( $content, ']' ) + 1;
[5420] Fix | Delete
$end = strrpos( $content, '[/' . $shortcode_name );
[5421] Fix | Delete
[5422] Fix | Delete
if ( false !== $end ) {
[5423] Fix | Delete
$content = substr( $content, $start, $end - $start );
[5424] Fix | Delete
} else {
[5425] Fix | Delete
$content = (bool) false;
[5426] Fix | Delete
}
[5427] Fix | Delete
[5428] Fix | Delete
return $content;
[5429] Fix | Delete
}
[5430] Fix | Delete
}
[5431] Fix | Delete
[5432] Fix | Delete
if ( ! function_exists( 'et_pb_remove_shortcode_content' ) ) {
[5433] Fix | Delete
/**
[5434] Fix | Delete
* Remove the content part of the shortcode.
[5435] Fix | Delete
*
[5436] Fix | Delete
* @param string $content content.
[5437] Fix | Delete
* @param string $shortcode_name shortcode name.
[5438] Fix | Delete
*
[5439] Fix | Delete
* @return string|string[]
[5440] Fix | Delete
*/
[5441] Fix | Delete
function et_pb_remove_shortcode_content( $content, $shortcode_name ) {
[5442] Fix | Delete
$shortcode_content = et_pb_extract_shortcode_content( $content, $shortcode_name );
[5443] Fix | Delete
[5444] Fix | Delete
if ( $shortcode_content ) {
[5445] Fix | Delete
// Anchor to the ][ brackets around the content so content that appears in
[5446] Fix | Delete
// attributes does not get removed as well.
[5447] Fix | Delete
return str_replace( ']' . $shortcode_content . '[', '][', $content );
[5448] Fix | Delete
}
[5449] Fix | Delete
[5450] Fix | Delete
return $content;
[5451] Fix | Delete
}
[5452] Fix | Delete
}
[5453] Fix | Delete
[5454] Fix | Delete
if ( ! function_exists( 'et_pb_get_global_module_content' ) ) {
[5455] Fix | Delete
/**
[5456] Fix | Delete
* Return global module content.
[5457] Fix | Delete
*
[5458] Fix | Delete
* @param string $content content.
[5459] Fix | Delete
* @param string $shortcode_name shortcode slug.
[5460] Fix | Delete
* @param bool $for_inner_row whether we getting module content for inner row.
[5461] Fix | Delete
*
[5462] Fix | Delete
* @return bool|false|string|string[]|null
[5463] Fix | Delete
*/
[5464] Fix | Delete
function et_pb_get_global_module_content( $content, $shortcode_name, $for_inner_row = false ) {
[5465] Fix | Delete
// Do not apply autop to code modules.
[5466] Fix | Delete
if ( in_array( $shortcode_name, array( 'et_pb_code', 'et_pb_fullwidth_code' ), true ) ) {
[5467] Fix | Delete
return et_pb_extract_shortcode_content( $content, $shortcode_name );
[5468] Fix | Delete
}
[5469] Fix | Delete
[5470] Fix | Delete
$original_code_modules = array();
[5471] Fix | Delete
$shortcode_content = et_pb_extract_shortcode_content( $content, $shortcode_name );
[5472] Fix | Delete
[5473] Fix | Delete
// Getting content for Global row when it's turned to inner row in specialty section
[5474] Fix | Delete
// Need to make sure it wrapped in et_pb_column_inner, not et_pb_column.
[5475] Fix | Delete
if ( $for_inner_row && false === strpos( $shortcode_content, '[et_pb_column_inner' ) ) {
[5476] Fix | Delete
$shortcode_content = str_replace( 'et_pb_column', 'et_pb_column_inner', $shortcode_content );
[5477] Fix | Delete
}
[5478] Fix | Delete
[5479] Fix | Delete
// Get all the code and fullwidth code modules from content.
[5480] Fix | Delete
preg_match_all( '/(\[et_pb(_fullwidth_code|_code).+?\[\/et_pb(_fullwidth_code|_code)\])/s', $shortcode_content, $original_code_modules );
[5481] Fix | Delete
[5482] Fix | Delete
$global_content = et_pb_fix_shortcodes( wpautop( $shortcode_content ) );
[5483] Fix | Delete
[5484] Fix | Delete
// Replace content modified by wpautop for code and fullwidth code modules with original content.
[5485] Fix | Delete
if ( ! empty( $original_code_modules ) ) {
[5486] Fix | Delete
global $et_pb_global_code_replacements;
[5487] Fix | Delete
[5488] Fix | Delete
$et_pb_global_code_replacements = $original_code_modules[0];
[5489] Fix | Delete
$global_content = preg_replace_callback( '/(\[et_pb(_fullwidth_code|_code).+?\[\/et_pb(_fullwidth_code|_code)\])/s', 'et_builder_get_global_code_replacement', $global_content );
[5490] Fix | Delete
}
[5491] Fix | Delete
[5492] Fix | Delete
return $global_content;
[5493] Fix | Delete
}
[5494] Fix | Delete
}
[5495] Fix | Delete
[5496] Fix | Delete
if ( ! function_exists( 'et_builder_get_global_code_replacement' ) ) {
[5497] Fix | Delete
/**
[5498] Fix | Delete
* Retrieve the global code original instance to replace the modified in global code shortcode.
[5499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function