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
'quick_actions_recent_category' => array(
[1000] Fix | Delete
'type' => 'string',
[1001] Fix | Delete
'default' => '',
[1002] Fix | Delete
'max_length' => 100,
[1003] Fix | Delete
),
[1004] Fix | Delete
'modal_preference' => array(
[1005] Fix | Delete
'type' => 'string',
[1006] Fix | Delete
'default' => 'default',
[1007] Fix | Delete
'options' => array(
[1008] Fix | Delete
'default' => esc_html__( 'Last Used Position', 'et_builder' ),
[1009] Fix | Delete
'minimum' => esc_html__( 'Floating Minimum Size', 'et_builder' ),
[1010] Fix | Delete
'fullscreen' => esc_html__( 'Fullscreen', 'et_builder' ),
[1011] Fix | Delete
'left' => esc_html__( 'Fixed Left Sidebar', 'et_builder' ),
[1012] Fix | Delete
'right' => esc_html__( 'Fixed Right Sidebar', 'et_builder' ),
[1013] Fix | Delete
'bottom' => esc_html__( 'Fixed Bottom Panel', 'et_builder' ),
[1014] Fix | Delete
// TODO, disabled until further notice (Issue #3930 & #5859)
[1015] Fix | Delete
// 'top' => esc_html__( 'Fixed Top Panel', 'et_builder' ),
[1016] Fix | Delete
),
[1017] Fix | Delete
),
[1018] Fix | Delete
'modal_snap_location' => array(
[1019] Fix | Delete
'type' => 'string',
[1020] Fix | Delete
'default' => '',
[1021] Fix | Delete
),
[1022] Fix | Delete
'modal_snap' => array(
[1023] Fix | Delete
'type' => 'bool',
[1024] Fix | Delete
'default' => false,
[1025] Fix | Delete
),
[1026] Fix | Delete
'modal_fullscreen' => array(
[1027] Fix | Delete
'type' => 'bool',
[1028] Fix | Delete
'default' => false,
[1029] Fix | Delete
),
[1030] Fix | Delete
'modal_dimension_width' => array(
[1031] Fix | Delete
'type' => 'int',
[1032] Fix | Delete
'default' => 400,
[1033] Fix | Delete
),
[1034] Fix | Delete
'modal_dimension_height' => array(
[1035] Fix | Delete
'type' => 'int',
[1036] Fix | Delete
'default' => 400,
[1037] Fix | Delete
),
[1038] Fix | Delete
'modal_position_x' => array(
[1039] Fix | Delete
'type' => 'int',
[1040] Fix | Delete
'default' => 30,
[1041] Fix | Delete
),
[1042] Fix | Delete
'modal_position_y' => array(
[1043] Fix | Delete
'type' => 'int',
[1044] Fix | Delete
'default' => 50,
[1045] Fix | Delete
),
[1046] Fix | Delete
'toolbar_click' => array(
[1047] Fix | Delete
'type' => 'bool',
[1048] Fix | Delete
'default' => false,
[1049] Fix | Delete
),
[1050] Fix | Delete
'toolbar_desktop' => array(
[1051] Fix | Delete
'type' => 'bool',
[1052] Fix | Delete
'default' => true,
[1053] Fix | Delete
),
[1054] Fix | Delete
'toolbar_grid' => array(
[1055] Fix | Delete
'type' => 'bool',
[1056] Fix | Delete
'default' => false,
[1057] Fix | Delete
),
[1058] Fix | Delete
'toolbar_hover' => array(
[1059] Fix | Delete
'type' => 'bool',
[1060] Fix | Delete
'default' => false,
[1061] Fix | Delete
),
[1062] Fix | Delete
'toolbar_phone' => array(
[1063] Fix | Delete
'type' => 'bool',
[1064] Fix | Delete
'default' => true,
[1065] Fix | Delete
),
[1066] Fix | Delete
'toolbar_tablet' => array(
[1067] Fix | Delete
'type' => 'bool',
[1068] Fix | Delete
'default' => true,
[1069] Fix | Delete
),
[1070] Fix | Delete
'toolbar_wireframe' => array(
[1071] Fix | Delete
'type' => 'bool',
[1072] Fix | Delete
'default' => true,
[1073] Fix | Delete
),
[1074] Fix | Delete
'toolbar_zoom' => array(
[1075] Fix | Delete
'type' => 'bool',
[1076] Fix | Delete
'default' => true,
[1077] Fix | Delete
),
[1078] Fix | Delete
'lv_modal_dimension_height' => array(
[1079] Fix | Delete
'type' => 'int',
[1080] Fix | Delete
'default' => 0,
[1081] Fix | Delete
),
[1082] Fix | Delete
'lv_modal_dimension_width' => array(
[1083] Fix | Delete
'type' => 'int',
[1084] Fix | Delete
'default' => 0,
[1085] Fix | Delete
),
[1086] Fix | Delete
'lv_modal_position_x' => array(
[1087] Fix | Delete
'type' => 'int',
[1088] Fix | Delete
'default' => 0,
[1089] Fix | Delete
),
[1090] Fix | Delete
'lv_modal_position_y' => array(
[1091] Fix | Delete
'type' => 'int',
[1092] Fix | Delete
'default' => 0,
[1093] Fix | Delete
),
[1094] Fix | Delete
);
[1095] Fix | Delete
[1096] Fix | Delete
return apply_filters( 'et_fb_app_preferences_defaults', $app_preferences );
[1097] Fix | Delete
}
[1098] Fix | Delete
[1099] Fix | Delete
function et_fb_unsynced_preferences() {
[1100] Fix | Delete
/**
[1101] Fix | Delete
* Filters the preferences list which should not be synced between Visual Builder and Backend Visual Builder.
[1102] Fix | Delete
*
[1103] Fix | Delete
* @since 3.18
[1104] Fix | Delete
*
[1105] Fix | Delete
* @param array
[1106] Fix | Delete
*/
[1107] Fix | Delete
return apply_filters( 'et_fb_app_preferences_unsynced', array( 'view_mode', 'toolbar_click', 'toolbar_desktop', 'toolbar_grid', 'toolbar_hover', 'toolbar_phone', 'toolbar_tablet', 'toolbar_wireframe', 'toolbar_zoom', 'modal_preference' ) );
[1108] Fix | Delete
}
[1109] Fix | Delete
[1110] Fix | Delete
function et_fb_app_preferences() {
[1111] Fix | Delete
$app_preferences = et_fb_app_preferences_settings();
[1112] Fix | Delete
if (et_is_builder_plugin_active()) {
[1113] Fix | Delete
// Since Divi Builder Plugin is always 'limited', need to use a different
[1114] Fix | Delete
// condition to prefix the options when BFB is used.
[1115] Fix | Delete
$limited_prefix = et_builder_bfb_enabled() ? 'limited_' : '';
[1116] Fix | Delete
} else {
[1117] Fix | Delete
$limited_prefix = et_builder_is_limited_mode() ? 'limited_' : '';
[1118] Fix | Delete
}
[1119] Fix | Delete
[1120] Fix | Delete
foreach ( $app_preferences as $preference_key => $preference ) {
[1121] Fix | Delete
$option_name = 'et_fb_pref_' . $preference_key;
[1122] Fix | Delete
[1123] Fix | Delete
// Some preferences should not be synced between VB and Limited VB
[1124] Fix | Delete
if ( in_array( $preference_key, et_fb_unsynced_preferences() ) ) {
[1125] Fix | Delete
$option_name = 'et_fb_pref_' . $limited_prefix . $preference_key;
[1126] Fix | Delete
}
[1127] Fix | Delete
[1128] Fix | Delete
$option_value = et_get_option( $option_name, $preference['default'], '', true );
[1129] Fix | Delete
[1130] Fix | Delete
// If options available, verify returned value against valid options. Return default if fails
[1131] Fix | Delete
if ( isset( $preference['options'] ) ) {
[1132] Fix | Delete
$options = $preference['options'];
[1133] Fix | Delete
$valid_options = isset( $options[0] ) ? $options : array_keys( $options );
[1134] Fix | Delete
[1135] Fix | Delete
if ( ! in_array( (string) $option_value, $valid_options ) ) {
[1136] Fix | Delete
$option_value = $preference['default'];
[1137] Fix | Delete
}
[1138] Fix | Delete
}
[1139] Fix | Delete
[1140] Fix | Delete
// Exceptional preference. Snap left is not supported in Limited mode, so replace it with default
[1141] Fix | Delete
if ( '' !== $limited_prefix && 'modal_snap_location' === $preference_key && 'left' === $option_value ) {
[1142] Fix | Delete
$option_value = $preference['default'];
[1143] Fix | Delete
}
[1144] Fix | Delete
[1145] Fix | Delete
$app_preferences[ $preference_key ]['value'] = $option_value;
[1146] Fix | Delete
}
[1147] Fix | Delete
[1148] Fix | Delete
return apply_filters( 'et_fb_app_preferences', $app_preferences );
[1149] Fix | Delete
}
[1150] Fix | Delete
[1151] Fix | Delete
/**
[1152] Fix | Delete
* Woocommerce Components for visual builder
[1153] Fix | Delete
*
[1154] Fix | Delete
* @since 4.0.1
[1155] Fix | Delete
*
[1156] Fix | Delete
* @return array
[1157] Fix | Delete
*/
[1158] Fix | Delete
function et_fb_current_page_woocommerce_components() {
[1159] Fix | Delete
$is_product_cpt = 'product' === get_post_type();
[1160] Fix | Delete
$is_tb = et_builder_tb_enabled();
[1161] Fix | Delete
$cpt_has_wc_components = $is_product_cpt || $is_tb;
[1162] Fix | Delete
$has_wc_components = et_is_woocommerce_plugin_active() && $cpt_has_wc_components;
[1163] Fix | Delete
[1164] Fix | Delete
if ( $has_wc_components && $is_tb ) {
[1165] Fix | Delete
// Set upsells ID for upsell module in TB
[1166] Fix | Delete
ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder::set_tb_upsells_ids();
[1167] Fix | Delete
[1168] Fix | Delete
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder in TB
[1169] Fix | Delete
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
[1170] Fix | Delete
[1171] Fix | Delete
// Set product categories and tags in TB
[1172] Fix | Delete
add_filter( 'get_the_terms', 'et_theme_builder_wc_terms', 10, 3 );
[1173] Fix | Delete
[1174] Fix | Delete
// Use Divi's image placeholder in TB
[1175] Fix | Delete
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'et_builder_wc_placeholder_img' );
[1176] Fix | Delete
}
[1177] Fix | Delete
[1178] Fix | Delete
$woocommerce_components = ! $has_wc_components ? array() : array(
[1179] Fix | Delete
'et_pb_wc_add_to_cart' => ET_Builder_Module_Woocommerce_Add_To_Cart::get_add_to_cart(),
[1180] Fix | Delete
'et_pb_wc_additional_info' => ET_Builder_Module_Woocommerce_Additional_Info::get_additional_info(),
[1181] Fix | Delete
'et_pb_wc_breadcrumb' => ET_Builder_Module_Woocommerce_Breadcrumb::get_breadcrumb(),
[1182] Fix | Delete
'et_pb_wc_cart_notice' => ET_Builder_Module_Woocommerce_Cart_Notice::get_cart_notice(),
[1183] Fix | Delete
'et_pb_wc_description' => ET_Builder_Module_Woocommerce_Description::get_description(),
[1184] Fix | Delete
'et_pb_wc_images' => ET_Builder_Module_Woocommerce_Images::get_images(),
[1185] Fix | Delete
'et_pb_wc_meta' => ET_Builder_Module_Woocommerce_Meta::get_meta(),
[1186] Fix | Delete
'et_pb_wc_price' => ET_Builder_Module_Woocommerce_Price::get_price(),
[1187] Fix | Delete
'et_pb_wc_rating' => ET_Builder_Module_Woocommerce_Rating::get_rating(),
[1188] Fix | Delete
'et_pb_wc_reviews' => ET_Builder_Module_Woocommerce_Reviews::get_reviews_html(),
[1189] Fix | Delete
'et_pb_wc_stock' => ET_Builder_Module_Woocommerce_Stock::get_stock(),
[1190] Fix | Delete
'et_pb_wc_tabs' => ET_Builder_Module_Woocommerce_Tabs::get_tabs(),
[1191] Fix | Delete
'et_pb_wc_title' => ET_Builder_Module_Woocommerce_Title::get_title(),
[1192] Fix | Delete
'et_pb_wc_related_products' => ET_Builder_Module_Woocommerce_Related_Products::get_related_products(),
[1193] Fix | Delete
'et_pb_wc_upsells' => ET_Builder_Module_Woocommerce_Upsells::get_upsells(),
[1194] Fix | Delete
);
[1195] Fix | Delete
[1196] Fix | Delete
return $woocommerce_components;
[1197] Fix | Delete
}
[1198] Fix | Delete
[1199] Fix | Delete
/**
[1200] Fix | Delete
* Array of WooCommerce Tabs.
[1201] Fix | Delete
*
[1202] Fix | Delete
* @since 4.4.2 Fixed fatal error @link https://github.com/elegantthemes/Divi/issues/19404
[1203] Fix | Delete
* @since 4.4.2 Added Custom Tabs support.
[1204] Fix | Delete
*
[1205] Fix | Delete
* @used-by et_fb_current_page_params()
[1206] Fix | Delete
*
[1207] Fix | Delete
* @return array
[1208] Fix | Delete
*/
[1209] Fix | Delete
function et_fb_woocommerce_tabs() {
[1210] Fix | Delete
global $product, $post;
[1211] Fix | Delete
$old_product = $product;
[1212] Fix | Delete
$old_post = $post;
[1213] Fix | Delete
[1214] Fix | Delete
if ( ! isset( $product ) && et_is_woocommerce_plugin_active() ) {
[1215] Fix | Delete
$product = ET_Builder_Module_Helper_Woocommerce_Modules::get_product( 'latest' );
[1216] Fix | Delete
[1217] Fix | Delete
if ( $product ) {
[1218] Fix | Delete
$post = get_post( $product->get_id() );
[1219] Fix | Delete
} else {
[1220] Fix | Delete
$product = $old_product;
[1221] Fix | Delete
return ET_Builder_Module_Helper_Woocommerce_Modules::get_default_tab_options();
[1222] Fix | Delete
}
[1223] Fix | Delete
}
[1224] Fix | Delete
[1225] Fix | Delete
// On non-product post types, the filter will cause fatal error
[1226] Fix | Delete
// unless we have global $product set.
[1227] Fix | Delete
$tabs = apply_filters( 'woocommerce_product_tabs', array() );
[1228] Fix | Delete
$options = array();
[1229] Fix | Delete
[1230] Fix | Delete
foreach ( $tabs as $name => $tab ) {
[1231] Fix | Delete
$options[ $name ] = array(
[1232] Fix | Delete
'value' => $name,
[1233] Fix | Delete
'label' => $tab['title'],
[1234] Fix | Delete
);
[1235] Fix | Delete
}
[1236] Fix | Delete
[1237] Fix | Delete
// Reset global $product.
[1238] Fix | Delete
$product = $old_product;
[1239] Fix | Delete
$post = $old_post;
[1240] Fix | Delete
[1241] Fix | Delete
return $options;
[1242] Fix | Delete
}
[1243] Fix | Delete
[1244] Fix | Delete
/**
[1245] Fix | Delete
* Get the category taxonomy associated with a given post type.
[1246] Fix | Delete
*
[1247] Fix | Delete
* @since 4.0.6
[1248] Fix | Delete
*
[1249] Fix | Delete
* @param string $post_type
[1250] Fix | Delete
*
[1251] Fix | Delete
* @return string|bool
[1252] Fix | Delete
*/
[1253] Fix | Delete
function et_builder_get_category_taxonomy( $post_type ) {
[1254] Fix | Delete
static $cache = array();
[1255] Fix | Delete
[1256] Fix | Delete
// Address common cases.
[1257] Fix | Delete
switch ( $post_type ) {
[1258] Fix | Delete
case 'page':
[1259] Fix | Delete
return false;
[1260] Fix | Delete
case 'post':
[1261] Fix | Delete
return 'category';
[1262] Fix | Delete
case 'project':
[1263] Fix | Delete
return 'project_category';
[1264] Fix | Delete
case 'product':
[1265] Fix | Delete
return 'product_cat';
[1266] Fix | Delete
}
[1267] Fix | Delete
[1268] Fix | Delete
if ( isset( $cache[ $post_type ] ) ) {
[1269] Fix | Delete
// Use cached value.
[1270] Fix | Delete
return $cache[ $post_type ];
[1271] Fix | Delete
}
[1272] Fix | Delete
[1273] Fix | Delete
// Unknown post_type, guess the taxonomy
[1274] Fix | Delete
$taxonomies = get_object_taxonomies( $post_type, 'names' );
[1275] Fix | Delete
[1276] Fix | Delete
foreach ( array( 'category', 'cat' ) as $pattern ) {
[1277] Fix | Delete
$matches = preg_grep( '/' . $pattern . '$/', $taxonomies );
[1278] Fix | Delete
if ( ! empty( $matches ) ) {
[1279] Fix | Delete
return $cache[ $post_type ] = reset( $matches );
[1280] Fix | Delete
}
[1281] Fix | Delete
}
[1282] Fix | Delete
[1283] Fix | Delete
// Tough luck.
[1284] Fix | Delete
return $cache[ $post_type ] = false;
[1285] Fix | Delete
}
[1286] Fix | Delete
[1287] Fix | Delete
/**
[1288] Fix | Delete
* Retrieve a post's category terms as a list with specified format.
[1289] Fix | Delete
*
[1290] Fix | Delete
* @since 4.0.6
[1291] Fix | Delete
*
[1292] Fix | Delete
* @param string $separator Optional. Separate items using this.
[1293] Fix | Delete
*
[1294] Fix | Delete
* @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
[1295] Fix | Delete
*/
[1296] Fix | Delete
function et_builder_get_the_term_list( $separator = '' ) {
[1297] Fix | Delete
$id = get_the_ID();
[1298] Fix | Delete
$taxonomy = et_builder_get_category_taxonomy( get_post_type( $id ) );
[1299] Fix | Delete
[1300] Fix | Delete
return $taxonomy ? get_the_term_list( $id, $taxonomy, $before = '', $separator ) : false;
[1301] Fix | Delete
}
[1302] Fix | Delete
[1303] Fix | Delete
/**
[1304] Fix | Delete
* Define current-page related data that are needed by frontend builder. Backend parser also uses this
[1305] Fix | Delete
* to sanitize updated value for computed data
[1306] Fix | Delete
*
[1307] Fix | Delete
* @return array
[1308] Fix | Delete
*/
[1309] Fix | Delete
function et_fb_current_page_params() {
[1310] Fix | Delete
global $post, $authordata, $paged;
[1311] Fix | Delete
[1312] Fix | Delete
// Get current page url
[1313] Fix | Delete
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
[1314] Fix | Delete
[1315] Fix | Delete
// Fallback for preview
[1316] Fix | Delete
if ( empty( $authordata ) && isset( $post->post_author ) ) {
[1317] Fix | Delete
$authordata = get_userdata( $post->post_author ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited
[1318] Fix | Delete
}
[1319] Fix | Delete
[1320] Fix | Delete
// Get comment count
[1321] Fix | Delete
$comment_count = isset( $post->ID ) ? get_comments_number( $post->ID ) : 0;
[1322] Fix | Delete
[1323] Fix | Delete
// WordPress' _n() only supports singular n plural, thus we do comment count to text manually
[1324] Fix | Delete
if ( $comment_count === 0 ) {
[1325] Fix | Delete
$comment_count_text = __( 'No Comments', 'et_builder' );
[1326] Fix | Delete
} elseif ( $comment_count === 1 ) {
[1327] Fix | Delete
$comment_count_text = __( '1 Comment', 'et_builder' );
[1328] Fix | Delete
} else {
[1329] Fix | Delete
$comment_count_text = sprintf( __( '%d Comments', 'et_builder' ), $comment_count );
[1330] Fix | Delete
}
[1331] Fix | Delete
[1332] Fix | Delete
// Get current page paginated data
[1333] Fix | Delete
$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
[1334] Fix | Delete
[1335] Fix | Delete
// Get thumbnail size
[1336] Fix | Delete
$thumbnail_size = isset( $post->ID ) && 'post' === get_post_type( $post->ID ) && 'et_full_width_page' === get_post_meta( $post->ID, '_et_pb_page_layout', true ) ? 'et-pb-post-main-image-fullwidth-large' : 'large';
[1337] Fix | Delete
[1338] Fix | Delete
$post_id = isset( $post->ID ) ? $post->ID : (int) et_()->array_get( $_POST, 'current_page.id' );
[1339] Fix | Delete
$exclude_woo = wp_doing_ajax() || ! et_is_woocommerce_plugin_active() || 'latest' === ET_Builder_Module_Helper_Woocommerce_Modules::get_product_default();
[1340] Fix | Delete
[1341] Fix | Delete
$default_categories = array( get_term_by( 'name', 'Uncategorized', 'category' ) );
[1342] Fix | Delete
$categories = et_pb_get_post_categories( $post_id, $default_categories );
[1343] Fix | Delete
[1344] Fix | Delete
$current_page = array(
[1345] Fix | Delete
'url' => esc_url( $current_url ),
[1346] Fix | Delete
'permalink' => esc_url( remove_query_arg( 'et_fb', $current_url ) ),
[1347] Fix | Delete
'backendBuilderUrl' => esc_url( sprintf( admin_url('/post.php?post=%d&action=edit'), get_the_ID() ) ),
[1348] Fix | Delete
'id' => isset( $post->ID ) ? $post->ID : false,
[1349] Fix | Delete
'title' => esc_html( get_the_title() ),
[1350] Fix | Delete
'thumbnailUrl' => isset( $post->ID ) ? esc_url( get_the_post_thumbnail_url( $post->ID, $thumbnail_size ) ) : '',
[1351] Fix | Delete
'thumbnailId' => isset( $post->ID ) ? get_post_thumbnail_id( $post->ID ) : '',
[1352] Fix | Delete
'authorName' => esc_html( get_the_author() ),
[1353] Fix | Delete
'authorUrl' => isset( $authordata->ID ) && isset( $authordata->user_nicename ) ? esc_html( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ) : false,
[1354] Fix | Delete
'authorUrlTitle' => sprintf( esc_html__( 'Posts by %s', 'et_builder' ), get_the_author() ),
[1355] Fix | Delete
'date' => intval( get_the_time('U') ),
[1356] Fix | Delete
'categories' => $categories,
[1357] Fix | Delete
'commentsPopup' => esc_html( $comment_count_text ),
[1358] Fix | Delete
'commentsCount' => esc_html( $comment_count ),
[1359] Fix | Delete
'comments_popup_tb' => esc_html__( '12 Comments', 'et_builder' ),
[1360] Fix | Delete
'paged' => is_front_page() ? $et_paged : $paged,
[1361] Fix | Delete
'post_modified' => isset( $post->ID ) ? esc_attr( $post->post_modified ) : '',
[1362] Fix | Delete
'lang' => get_locale(),
[1363] Fix | Delete
'blockId' => ET_GB_Block_Layout::is_layout_block_preview() ? sanitize_title( et_()->array_get( $_GET, 'blockId', '' ) ) : '',
[1364] Fix | Delete
'langCode' => get_locale(),
[1365] Fix | Delete
'page_layout' => $post_id ? get_post_meta( $post_id, '_et_pb_page_layout', true ) : '',
[1366] Fix | Delete
'woocommerceComponents' => $exclude_woo ? array() : et_fb_current_page_woocommerce_components(),
[1367] Fix | Delete
'woocommerceTabs' => et_builder_tb_enabled() && et_is_woocommerce_plugin_active() ?
[1368] Fix | Delete
ET_Builder_Module_Helper_Woocommerce_Modules::get_default_tab_options() : et_fb_woocommerce_tabs(),
[1369] Fix | Delete
);
[1370] Fix | Delete
[1371] Fix | Delete
return apply_filters( 'et_fb_current_page_params', $current_page );
[1372] Fix | Delete
}
[1373] Fix | Delete
[1374] Fix | Delete
function et_pb_process_computed_property() {
[1375] Fix | Delete
if ( !isset( $_POST['et_pb_process_computed_property_nonce'] ) || !wp_verify_nonce( $_POST['et_pb_process_computed_property_nonce'], 'et_pb_process_computed_property_nonce' ) ) {
[1376] Fix | Delete
die( -1 );
[1377] Fix | Delete
}
[1378] Fix | Delete
[1379] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1380] Fix | Delete
die( -1 );
[1381] Fix | Delete
}
[1382] Fix | Delete
[1383] Fix | Delete
if ( ! isset( $_POST['depends_on'], $_POST['conditional_tags'], $_POST['current_page'] ) ) {
[1384] Fix | Delete
// Shouldn't even be a possibility, but...
[1385] Fix | Delete
// Since computing `__page` can exit here too, we need to json_encode the reponse.
[1386] Fix | Delete
// This is needed in case jQuery migrate is disabled (eg via plugin) otherwise the AJAX success callback
[1387] Fix | Delete
// won't be executed (because json is malformed)
[1388] Fix | Delete
die( json_encode( null ) );
[1389] Fix | Delete
}
[1390] Fix | Delete
[1391] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[1392] Fix | Delete
[1393] Fix | Delete
$depends_on = $_POST['depends_on'];
[1394] Fix | Delete
$conditional_tags = $_POST['conditional_tags'];
[1395] Fix | Delete
$current_page = $_POST['current_page'];
[1396] Fix | Delete
[1397] Fix | Delete
// allowlist keys
[1398] Fix | Delete
$conditional_tags = array_intersect_key( $conditional_tags, et_fb_conditional_tag_params() );
[1399] Fix | Delete
$current_page = array_intersect_key( $current_page, et_fb_current_page_params() );
[1400] Fix | Delete
[1401] Fix | Delete
// sanitize values
[1402] Fix | Delete
$conditional_tags = $utils->sanitize_text_fields( $conditional_tags );
[1403] Fix | Delete
$current_page = $utils->sanitize_text_fields( $current_page );
[1404] Fix | Delete
[1405] Fix | Delete
if ( empty( $current_page['id'] ) || ! current_user_can( 'edit_post', $current_page['id'] ) ) {
[1406] Fix | Delete
die( -1 );
[1407] Fix | Delete
}
[1408] Fix | Delete
[1409] Fix | Delete
// $_POST['depends_on'] is a single dimensional assoc array created by jQuery.ajax data param, sanitize each key and value, they will both be strings
[1410] Fix | Delete
foreach ( $depends_on as $key => $value ) {
[1411] Fix | Delete
[1412] Fix | Delete
if ( et_()->includes( $value, '%' ) ) {
[1413] Fix | Delete
// `sanitize_text_fields` removes octets `%[a-f0-9]{2}` and would zap icon values / `%date`
[1414] Fix | Delete
// so we prefix octets with `_` to protected them and remove the prefix after sanitization.
[1415] Fix | Delete
$prepared_value = preg_replace( '/%([a-f0-9]{2})/', '%_$1', $value );
[1416] Fix | Delete
$sanitized_value = preg_replace( '/%_([a-f0-9]{2})/', '%$1', sanitize_text_field( $prepared_value ) );
[1417] Fix | Delete
} else {
[1418] Fix | Delete
$sanitized_value = sanitize_text_field( $value );
[1419] Fix | Delete
}
[1420] Fix | Delete
[1421] Fix | Delete
$depends_on[ sanitize_text_field( $key ) ] = $sanitized_value;
[1422] Fix | Delete
[1423] Fix | Delete
}
[1424] Fix | Delete
$module_slug = sanitize_text_field( $_POST['module_type'] );
[1425] Fix | Delete
$post_type = sanitize_text_field( $_POST['post_type'] );
[1426] Fix | Delete
$computed_property = sanitize_text_field( $_POST['computed_property'] );
[1427] Fix | Delete
[1428] Fix | Delete
// get all fields for module
[1429] Fix | Delete
$fields = ET_Builder_Element::get_module_fields( $post_type, $module_slug );
[1430] Fix | Delete
[1431] Fix | Delete
// make sure only valid fields are being passed through
[1432] Fix | Delete
$depends_on = array_intersect_key( $depends_on, $fields );
[1433] Fix | Delete
[1434] Fix | Delete
// computed property field
[1435] Fix | Delete
$field = $fields[ $computed_property ];
[1436] Fix | Delete
[1437] Fix | Delete
$callback = $field['computed_callback'];
[1438] Fix | Delete
[1439] Fix | Delete
if ( is_callable( $callback ) ) {
[1440] Fix | Delete
// @phpcs:ignore Generic.PHP.ForbiddenFunctions.Found
[1441] Fix | Delete
die( json_encode( call_user_func( $callback, $depends_on, $conditional_tags, $current_page ) ) );
[1442] Fix | Delete
} else {
[1443] Fix | Delete
die( -1 );
[1444] Fix | Delete
}
[1445] Fix | Delete
}
[1446] Fix | Delete
add_action( 'wp_ajax_et_pb_process_computed_property', 'et_pb_process_computed_property' );
[1447] Fix | Delete
[1448] Fix | Delete
function et_fb_process_to_shortcode( $object, $options = array(), $library_item_type = '', $escape_content_slashes = true ) {
[1449] Fix | Delete
$output = '';
[1450] Fix | Delete
$_object = array();
[1451] Fix | Delete
[1452] Fix | Delete
$options = wp_parse_args( $options, array(
[1453] Fix | Delete
'force_valid_slugs' => false,
[1454] Fix | Delete
'post_type' => false,
[1455] Fix | Delete
'apply_global_presets' => false,
[1456] Fix | Delete
) );
[1457] Fix | Delete
[1458] Fix | Delete
$global_presets_manager = ET_Builder_Global_Presets_Settings::instance();
[1459] Fix | Delete
[1460] Fix | Delete
// do not proceed if $object is empty
[1461] Fix | Delete
if ( empty( $object ) ) {
[1462] Fix | Delete
return '';
[1463] Fix | Delete
}
[1464] Fix | Delete
[1465] Fix | Delete
$font_icon_fields = ! empty( $options['post_type'] ) ? ET_Builder_Element::get_font_icon_fields( $options['post_type'] ) : false;
[1466] Fix | Delete
$structure_types = ET_Builder_Element::get_structure_module_slugs();
[1467] Fix | Delete
[1468] Fix | Delete
if ( in_array( $library_item_type, array( 'module', 'row' ) ) ) {
[1469] Fix | Delete
$excluded_elements = array();
[1470] Fix | Delete
[1471] Fix | Delete
switch ( $library_item_type ) {
[1472] Fix | Delete
case 'module':
[1473] Fix | Delete
$excluded_elements = array( 'et_pb_section', 'et_pb_row', 'et_pb_column' );
[1474] Fix | Delete
break;
[1475] Fix | Delete
case 'row':
[1476] Fix | Delete
$excluded_elements = array( 'et_pb_section' );
[1477] Fix | Delete
break;
[1478] Fix | Delete
}
[1479] Fix | Delete
[1480] Fix | Delete
foreach ( $object as $item ) {
[1481] Fix | Delete
// do not proceed if $item is empty
[1482] Fix | Delete
if ( empty( $item ) ) {
[1483] Fix | Delete
continue;
[1484] Fix | Delete
}
[1485] Fix | Delete
[1486] Fix | Delete
while ( in_array( $item['type'], $excluded_elements ) ) {
[1487] Fix | Delete
$item = $item['content'][0];
[1488] Fix | Delete
}
[1489] Fix | Delete
[1490] Fix | Delete
$_object[] = $item;
[1491] Fix | Delete
}
[1492] Fix | Delete
} else {
[1493] Fix | Delete
$_object = $object;
[1494] Fix | Delete
}
[1495] Fix | Delete
[1496] Fix | Delete
if ( $options['force_valid_slugs'] ) {
[1497] Fix | Delete
// we need to supply a reasonable default post type to get a simple list of slugs,
[1498] Fix | Delete
// otherwise the function will return an array of arrays of slugs for every possible post_type.
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function