Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder
File: functions.php
$default_label = esc_html__( 'Give Me A Choice', 'et_builder' );
[1000] Fix | Delete
[1001] Fix | Delete
if ( $value_as_index ) {
[1002] Fix | Delete
$settings = array(
[1003] Fix | Delete
$default_label,
[1004] Fix | Delete
);
[1005] Fix | Delete
} else {
[1006] Fix | Delete
$settings = array(
[1007] Fix | Delete
'default' => $default_label,
[1008] Fix | Delete
);
[1009] Fix | Delete
}
[1010] Fix | Delete
[1011] Fix | Delete
foreach ( et_builder_page_creation_options() as $key => $option ) {
[1012] Fix | Delete
if ( ! et_()->array_get( $option, 'setting' ) ) {
[1013] Fix | Delete
continue;
[1014] Fix | Delete
}
[1015] Fix | Delete
[1016] Fix | Delete
if ( isset( $option['permission'] ) ) {
[1017] Fix | Delete
$capabilities = is_array( $option['permission'] ) ? $option['permission'] : explode( ',', $option['permission'] );
[1018] Fix | Delete
$allowed = array_filter( $capabilities, 'et_pb_is_allowed' );
[1019] Fix | Delete
[1020] Fix | Delete
if ( ! $allowed || count( $capabilities ) !== count( $allowed ) ) {
[1021] Fix | Delete
continue;
[1022] Fix | Delete
}
[1023] Fix | Delete
}
[1024] Fix | Delete
[1025] Fix | Delete
$value = $value_as_index ? $option['setting']['value_index'] : $key;
[1026] Fix | Delete
$label = et_()->array_get( $option, 'setting.label', $option['titleText'] );
[1027] Fix | Delete
[1028] Fix | Delete
$settings[ $value ] = $label;
[1029] Fix | Delete
}
[1030] Fix | Delete
[1031] Fix | Delete
return $settings;
[1032] Fix | Delete
}
[1033] Fix | Delete
endif;
[1034] Fix | Delete
[1035] Fix | Delete
/**
[1036] Fix | Delete
* Return an app preferences.
[1037] Fix | Delete
*
[1038] Fix | Delete
* @return mixed|void
[1039] Fix | Delete
*/
[1040] Fix | Delete
function et_fb_app_preferences_settings() {
[1041] Fix | Delete
$app_preferences = array(
[1042] Fix | Delete
'settings_bar_location' => array(
[1043] Fix | Delete
'type' => 'string',
[1044] Fix | Delete
'default' => 'bottom',
[1045] Fix | Delete
'options' => array(
[1046] Fix | Delete
'top-left',
[1047] Fix | Delete
'top',
[1048] Fix | Delete
'top-right',
[1049] Fix | Delete
'right',
[1050] Fix | Delete
'bottom-right',
[1051] Fix | Delete
'bottom',
[1052] Fix | Delete
'bottom-left',
[1053] Fix | Delete
'left',
[1054] Fix | Delete
),
[1055] Fix | Delete
),
[1056] Fix | Delete
'builder_animation' => array(
[1057] Fix | Delete
'type' => 'bool',
[1058] Fix | Delete
'default' => true,
[1059] Fix | Delete
),
[1060] Fix | Delete
'builder_display_modal_settings' => array(
[1061] Fix | Delete
'type' => 'bool',
[1062] Fix | Delete
'default' => false,
[1063] Fix | Delete
),
[1064] Fix | Delete
'builder_enable_dummy_content' => array(
[1065] Fix | Delete
'type' => 'bool',
[1066] Fix | Delete
'default' => true,
[1067] Fix | Delete
),
[1068] Fix | Delete
'event_mode' => array(
[1069] Fix | Delete
'type' => 'string',
[1070] Fix | Delete
'default' => 'hover',
[1071] Fix | Delete
'options' => array(
[1072] Fix | Delete
'hover' => esc_html__( 'Hover Mode', 'et_builder' ),
[1073] Fix | Delete
'click' => esc_html__( 'Click Mode', 'et_builder' ),
[1074] Fix | Delete
'grid' => esc_html__( 'Grid Mode', 'et_builder' ),
[1075] Fix | Delete
),
[1076] Fix | Delete
),
[1077] Fix | Delete
'view_mode' => array(
[1078] Fix | Delete
'type' => 'string',
[1079] Fix | Delete
'default' => et_builder_bfb_enabled() ? 'wireframe' : 'desktop',
[1080] Fix | Delete
'options' => array(
[1081] Fix | Delete
'desktop' => esc_html__( 'Desktop View', 'et_builder' ),
[1082] Fix | Delete
'tablet' => esc_html__( 'Tablet View', 'et_builder' ),
[1083] Fix | Delete
'phone' => esc_html__( 'Phone View', 'et_builder' ),
[1084] Fix | Delete
'wireframe' => esc_html__( 'Wireframe View', 'et_builder' ),
[1085] Fix | Delete
),
[1086] Fix | Delete
),
[1087] Fix | Delete
'hide_disabled_modules' => array(
[1088] Fix | Delete
'type' => 'bool',
[1089] Fix | Delete
'default' => false,
[1090] Fix | Delete
),
[1091] Fix | Delete
'history_intervals' => array(
[1092] Fix | Delete
'type' => 'int',
[1093] Fix | Delete
'default' => 1,
[1094] Fix | Delete
'options' => array(
[1095] Fix | Delete
'1' => esc_html__( 'After Every Action', 'et_builder' ),
[1096] Fix | Delete
'10' => esc_html__( 'After Every 10th Action', 'et_builder' ),
[1097] Fix | Delete
'20' => esc_html__( 'After Every 20th Action', 'et_builder' ),
[1098] Fix | Delete
'30' => esc_html__( 'After Every 30th Action', 'et_builder' ),
[1099] Fix | Delete
'40' => esc_html__( 'After Every 40th Action', 'et_builder' ),
[1100] Fix | Delete
),
[1101] Fix | Delete
),
[1102] Fix | Delete
'page_creation_flow' => array(
[1103] Fix | Delete
'type' => 'string',
[1104] Fix | Delete
'default' => 'default',
[1105] Fix | Delete
'options' => et_builder_page_creation_settings(),
[1106] Fix | Delete
),
[1107] Fix | Delete
'quick_actions_always_start_with' => array(
[1108] Fix | Delete
'type' => 'string',
[1109] Fix | Delete
'default' => 'nothing',
[1110] Fix | Delete
),
[1111] Fix | Delete
'quick_actions_show_recent_queries' => array(
[1112] Fix | Delete
'type' => 'string',
[1113] Fix | Delete
'default' => 'off',
[1114] Fix | Delete
),
[1115] Fix | Delete
'quick_actions_recent_queries' => array(
[1116] Fix | Delete
'type' => 'string',
[1117] Fix | Delete
'default' => '',
[1118] Fix | Delete
'max_length' => 100,
[1119] Fix | Delete
),
[1120] Fix | Delete
'quick_actions_recent_category' => array(
[1121] Fix | Delete
'type' => 'string',
[1122] Fix | Delete
'default' => '',
[1123] Fix | Delete
'max_length' => 100,
[1124] Fix | Delete
),
[1125] Fix | Delete
'modal_preference' => array(
[1126] Fix | Delete
'type' => 'string',
[1127] Fix | Delete
'default' => 'default',
[1128] Fix | Delete
'options' => array(
[1129] Fix | Delete
'default' => esc_html__( 'Last Used Position', 'et_builder' ),
[1130] Fix | Delete
'minimum' => esc_html__( 'Floating Minimum Size', 'et_builder' ),
[1131] Fix | Delete
'fullscreen' => esc_html__( 'Fullscreen', 'et_builder' ),
[1132] Fix | Delete
'left' => esc_html__( 'Fixed Left Sidebar', 'et_builder' ),
[1133] Fix | Delete
'right' => esc_html__( 'Fixed Right Sidebar', 'et_builder' ),
[1134] Fix | Delete
'bottom' => esc_html__( 'Fixed Bottom Panel', 'et_builder' ),
[1135] Fix | Delete
// TODO, disabled until further notice (Issue #3930 & #5859)
[1136] Fix | Delete
// 'top' => esc_html__( 'Fixed Top Panel', 'et_builder' ),.
[1137] Fix | Delete
),
[1138] Fix | Delete
),
[1139] Fix | Delete
'modal_snap_location' => array(
[1140] Fix | Delete
'type' => 'string',
[1141] Fix | Delete
'default' => '',
[1142] Fix | Delete
),
[1143] Fix | Delete
'modal_snap' => array(
[1144] Fix | Delete
'type' => 'bool',
[1145] Fix | Delete
'default' => false,
[1146] Fix | Delete
),
[1147] Fix | Delete
'modal_fullscreen' => array(
[1148] Fix | Delete
'type' => 'bool',
[1149] Fix | Delete
'default' => false,
[1150] Fix | Delete
),
[1151] Fix | Delete
'modal_dimension_width' => array(
[1152] Fix | Delete
'type' => 'int',
[1153] Fix | Delete
'default' => 400,
[1154] Fix | Delete
),
[1155] Fix | Delete
'modal_dimension_height' => array(
[1156] Fix | Delete
'type' => 'int',
[1157] Fix | Delete
'default' => 400,
[1158] Fix | Delete
),
[1159] Fix | Delete
'modal_position_x' => array(
[1160] Fix | Delete
'type' => 'int',
[1161] Fix | Delete
'default' => 30,
[1162] Fix | Delete
),
[1163] Fix | Delete
'modal_position_y' => array(
[1164] Fix | Delete
'type' => 'int',
[1165] Fix | Delete
'default' => 50,
[1166] Fix | Delete
),
[1167] Fix | Delete
'toolbar_click' => array(
[1168] Fix | Delete
'type' => 'bool',
[1169] Fix | Delete
'default' => false,
[1170] Fix | Delete
),
[1171] Fix | Delete
'toolbar_desktop' => array(
[1172] Fix | Delete
'type' => 'bool',
[1173] Fix | Delete
'default' => true,
[1174] Fix | Delete
),
[1175] Fix | Delete
'toolbar_grid' => array(
[1176] Fix | Delete
'type' => 'bool',
[1177] Fix | Delete
'default' => false,
[1178] Fix | Delete
),
[1179] Fix | Delete
'toolbar_hover' => array(
[1180] Fix | Delete
'type' => 'bool',
[1181] Fix | Delete
'default' => false,
[1182] Fix | Delete
),
[1183] Fix | Delete
'toolbar_phone' => array(
[1184] Fix | Delete
'type' => 'bool',
[1185] Fix | Delete
'default' => true,
[1186] Fix | Delete
),
[1187] Fix | Delete
'toolbar_tablet' => array(
[1188] Fix | Delete
'type' => 'bool',
[1189] Fix | Delete
'default' => true,
[1190] Fix | Delete
),
[1191] Fix | Delete
'toolbar_wireframe' => array(
[1192] Fix | Delete
'type' => 'bool',
[1193] Fix | Delete
'default' => true,
[1194] Fix | Delete
),
[1195] Fix | Delete
'toolbar_zoom' => array(
[1196] Fix | Delete
'type' => 'bool',
[1197] Fix | Delete
'default' => true,
[1198] Fix | Delete
),
[1199] Fix | Delete
'lv_modal_dimension_height' => array(
[1200] Fix | Delete
'type' => 'int',
[1201] Fix | Delete
'default' => 0,
[1202] Fix | Delete
),
[1203] Fix | Delete
'lv_modal_dimension_width' => array(
[1204] Fix | Delete
'type' => 'int',
[1205] Fix | Delete
'default' => 0,
[1206] Fix | Delete
),
[1207] Fix | Delete
'lv_modal_position_x' => array(
[1208] Fix | Delete
'type' => 'int',
[1209] Fix | Delete
'default' => 0,
[1210] Fix | Delete
),
[1211] Fix | Delete
'lv_modal_position_y' => array(
[1212] Fix | Delete
'type' => 'int',
[1213] Fix | Delete
'default' => 0,
[1214] Fix | Delete
),
[1215] Fix | Delete
// Re: "width/height": responsive dimensions presume portrait orientation.
[1216] Fix | Delete
'responsive_tablet_width' => array(
[1217] Fix | Delete
'type' => 'int',
[1218] Fix | Delete
'default' => 768,
[1219] Fix | Delete
),
[1220] Fix | Delete
'responsive_tablet_height' => array(
[1221] Fix | Delete
'type' => 'int',
[1222] Fix | Delete
'default' => 0,
[1223] Fix | Delete
),
[1224] Fix | Delete
'responsive_phone_width' => array(
[1225] Fix | Delete
'type' => 'int',
[1226] Fix | Delete
'default' => 400,
[1227] Fix | Delete
),
[1228] Fix | Delete
'responsive_phone_height' => array(
[1229] Fix | Delete
'type' => 'int',
[1230] Fix | Delete
'default' => 0,
[1231] Fix | Delete
),
[1232] Fix | Delete
'responsive_minimum_width' => array(
[1233] Fix | Delete
'type' => 'int',
[1234] Fix | Delete
'default' => 320,
[1235] Fix | Delete
),
[1236] Fix | Delete
'responsive_maximum_width' => array(
[1237] Fix | Delete
'type' => 'int',
[1238] Fix | Delete
'default' => 980,
[1239] Fix | Delete
),
[1240] Fix | Delete
);
[1241] Fix | Delete
[1242] Fix | Delete
return apply_filters( 'et_fb_app_preferences_defaults', $app_preferences );
[1243] Fix | Delete
}
[1244] Fix | Delete
[1245] Fix | Delete
/**
[1246] Fix | Delete
* Return the preferences list which should not be synced between Visual Builder and Backend Visual Builder.
[1247] Fix | Delete
*
[1248] Fix | Delete
* @return mixed|void
[1249] Fix | Delete
*/
[1250] Fix | Delete
function et_fb_unsynced_preferences() {
[1251] Fix | Delete
/**
[1252] Fix | Delete
* Filters the preferences list which should not be synced between Visual Builder and Backend Visual Builder.
[1253] Fix | Delete
*
[1254] Fix | Delete
* @since 3.18
[1255] Fix | Delete
*
[1256] Fix | Delete
* @param array
[1257] Fix | Delete
*/
[1258] 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' ) );
[1259] Fix | Delete
}
[1260] Fix | Delete
[1261] Fix | Delete
/**
[1262] Fix | Delete
* Return app preferences.
[1263] Fix | Delete
*
[1264] Fix | Delete
* @return mixed|void
[1265] Fix | Delete
*/
[1266] Fix | Delete
function et_fb_app_preferences() {
[1267] Fix | Delete
$app_preferences = et_fb_app_preferences_settings();
[1268] Fix | Delete
if ( et_is_builder_plugin_active() ) {
[1269] Fix | Delete
// Since Divi Builder Plugin is always 'limited', need to use a different
[1270] Fix | Delete
// condition to prefix the options when BFB is used.
[1271] Fix | Delete
$limited_prefix = et_builder_bfb_enabled() ? 'limited_' : '';
[1272] Fix | Delete
} else {
[1273] Fix | Delete
$limited_prefix = et_builder_is_limited_mode() ? 'limited_' : '';
[1274] Fix | Delete
}
[1275] Fix | Delete
[1276] Fix | Delete
foreach ( $app_preferences as $preference_key => $preference ) {
[1277] Fix | Delete
$option_name = 'et_fb_pref_' . $preference_key;
[1278] Fix | Delete
[1279] Fix | Delete
// Some preferences should not be synced between VB and Limited VB.
[1280] Fix | Delete
if ( in_array( $preference_key, et_fb_unsynced_preferences(), true ) ) {
[1281] Fix | Delete
$option_name = 'et_fb_pref_' . $limited_prefix . $preference_key;
[1282] Fix | Delete
}
[1283] Fix | Delete
[1284] Fix | Delete
$option_value = et_get_option( $option_name, $preference['default'], '', true );
[1285] Fix | Delete
[1286] Fix | Delete
// If options available, verify returned value against valid options. Return default if fails.
[1287] Fix | Delete
if ( isset( $preference['options'] ) ) {
[1288] Fix | Delete
$options = $preference['options'];
[1289] Fix | Delete
$valid_options = isset( $options[0] ) ? $options : array_keys( $options );
[1290] Fix | Delete
// phpcs:ignore WordPress.PHP.StrictInArray -- $valid_options array has strings and numbers values.
[1291] Fix | Delete
if ( ! in_array( (string) $option_value, $valid_options ) ) {
[1292] Fix | Delete
$option_value = $preference['default'];
[1293] Fix | Delete
}
[1294] Fix | Delete
}
[1295] Fix | Delete
[1296] Fix | Delete
// Exceptional preference. Snap left is not supported in Limited mode, so replace it with default.
[1297] Fix | Delete
if ( '' !== $limited_prefix && 'modal_snap_location' === $preference_key && 'left' === $option_value ) {
[1298] Fix | Delete
$option_value = $preference['default'];
[1299] Fix | Delete
}
[1300] Fix | Delete
[1301] Fix | Delete
$app_preferences[ $preference_key ]['value'] = $option_value;
[1302] Fix | Delete
}
[1303] Fix | Delete
[1304] Fix | Delete
return apply_filters( 'et_fb_app_preferences', $app_preferences );
[1305] Fix | Delete
}
[1306] Fix | Delete
[1307] Fix | Delete
/**
[1308] Fix | Delete
* Woocommerce Components for visual builder
[1309] Fix | Delete
*
[1310] Fix | Delete
* @since 4.0.1
[1311] Fix | Delete
*
[1312] Fix | Delete
* @return array
[1313] Fix | Delete
*/
[1314] Fix | Delete
function et_fb_current_page_woocommerce_components() {
[1315] Fix | Delete
$is_product_cpt = 'product' === get_post_type();
[1316] Fix | Delete
$is_tb = et_builder_tb_enabled();
[1317] Fix | Delete
$cpt_has_wc_components = $is_product_cpt || $is_tb;
[1318] Fix | Delete
$has_wc_components = et_is_woocommerce_plugin_active() && $cpt_has_wc_components;
[1319] Fix | Delete
[1320] Fix | Delete
if ( $has_wc_components && $is_tb ) {
[1321] Fix | Delete
// Set upsells ID for upsell module in TB.
[1322] Fix | Delete
ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder::set_tb_upsells_ids();
[1323] Fix | Delete
[1324] Fix | Delete
// Force set product's class to ET_Theme_Builder_Woocommerce_Product_Variable_Placeholder in TB.
[1325] Fix | Delete
add_filter( 'woocommerce_product_class', 'et_theme_builder_wc_product_class' );
[1326] Fix | Delete
[1327] Fix | Delete
// Set product categories and tags in TB.
[1328] Fix | Delete
add_filter( 'get_the_terms', 'et_theme_builder_wc_terms', 10, 3 );
[1329] Fix | Delete
[1330] Fix | Delete
// Use Divi's image placeholder in TB.
[1331] Fix | Delete
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'et_builder_wc_placeholder_img' );
[1332] Fix | Delete
}
[1333] Fix | Delete
[1334] Fix | Delete
$woocommerce_components = ! $has_wc_components ? array() : array(
[1335] Fix | Delete
'et_pb_wc_add_to_cart' => ET_Builder_Module_Woocommerce_Add_To_Cart::get_add_to_cart(),
[1336] Fix | Delete
'et_pb_wc_additional_info' => ET_Builder_Module_Woocommerce_Additional_Info::get_additional_info(),
[1337] Fix | Delete
'et_pb_wc_breadcrumb' => ET_Builder_Module_Woocommerce_Breadcrumb::get_breadcrumb(),
[1338] Fix | Delete
'et_pb_wc_cart_notice' => ET_Builder_Module_Woocommerce_Cart_Notice::get_cart_notice(),
[1339] Fix | Delete
'et_pb_wc_description' => ET_Builder_Module_Woocommerce_Description::get_description(),
[1340] Fix | Delete
'et_pb_wc_images' => ET_Builder_Module_Woocommerce_Images::get_images(),
[1341] Fix | Delete
'et_pb_wc_meta' => ET_Builder_Module_Woocommerce_Meta::get_meta(),
[1342] Fix | Delete
'et_pb_wc_price' => ET_Builder_Module_Woocommerce_Price::get_price(),
[1343] Fix | Delete
'et_pb_wc_rating' => ET_Builder_Module_Woocommerce_Rating::get_rating(),
[1344] Fix | Delete
'et_pb_wc_reviews' => ET_Builder_Module_Woocommerce_Reviews::get_reviews_html(),
[1345] Fix | Delete
'et_pb_wc_stock' => ET_Builder_Module_Woocommerce_Stock::get_stock(),
[1346] Fix | Delete
'et_pb_wc_tabs' => ET_Builder_Module_Woocommerce_Tabs::get_tabs(),
[1347] Fix | Delete
'et_pb_wc_title' => ET_Builder_Module_Woocommerce_Title::get_title(),
[1348] Fix | Delete
'et_pb_wc_related_products' => ET_Builder_Module_Woocommerce_Related_Products::get_related_products(),
[1349] Fix | Delete
'et_pb_wc_upsells' => ET_Builder_Module_Woocommerce_Upsells::get_upsells(),
[1350] Fix | Delete
);
[1351] Fix | Delete
[1352] Fix | Delete
return $woocommerce_components;
[1353] Fix | Delete
}
[1354] Fix | Delete
[1355] Fix | Delete
/**
[1356] Fix | Delete
* Array of WooCommerce Tabs.
[1357] Fix | Delete
*
[1358] Fix | Delete
* @since 4.4.2 Fixed fatal error @link https://github.com/elegantthemes/Divi/issues/19404
[1359] Fix | Delete
* @since 4.4.2 Added Custom Tabs support.
[1360] Fix | Delete
*
[1361] Fix | Delete
* @used-by et_fb_current_page_params()
[1362] Fix | Delete
*
[1363] Fix | Delete
* @return array
[1364] Fix | Delete
*/
[1365] Fix | Delete
function et_fb_woocommerce_tabs() {
[1366] Fix | Delete
global $product, $post;
[1367] Fix | Delete
$old_product = $product;
[1368] Fix | Delete
$old_post = $post;
[1369] Fix | Delete
[1370] Fix | Delete
if ( ! isset( $product ) && et_is_woocommerce_plugin_active() ) {
[1371] Fix | Delete
$product = ET_Builder_Module_Helper_Woocommerce_Modules::get_product( 'latest' );
[1372] Fix | Delete
[1373] Fix | Delete
if ( $product ) {
[1374] Fix | Delete
$post = get_post( $product->get_id() ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- Overriding global post is safe as original $post has been restored at the end.
[1375] Fix | Delete
} else {
[1376] Fix | Delete
$product = $old_product;
[1377] Fix | Delete
return ET_Builder_Module_Helper_Woocommerce_Modules::get_default_tab_options();
[1378] Fix | Delete
}
[1379] Fix | Delete
}
[1380] Fix | Delete
[1381] Fix | Delete
// On non-product post types, the filter will cause fatal error
[1382] Fix | Delete
// unless we have global $product set.
[1383] Fix | Delete
$tabs = apply_filters( 'woocommerce_product_tabs', array() );
[1384] Fix | Delete
$options = array();
[1385] Fix | Delete
[1386] Fix | Delete
foreach ( $tabs as $name => $tab ) {
[1387] Fix | Delete
$options[ $name ] = array(
[1388] Fix | Delete
'value' => $name,
[1389] Fix | Delete
'label' => $tab['title'],
[1390] Fix | Delete
);
[1391] Fix | Delete
}
[1392] Fix | Delete
[1393] Fix | Delete
// Reset global $product.
[1394] Fix | Delete
$product = $old_product;
[1395] Fix | Delete
$post = $old_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- Restoring original global $post data.
[1396] Fix | Delete
[1397] Fix | Delete
return $options;
[1398] Fix | Delete
}
[1399] Fix | Delete
[1400] Fix | Delete
/**
[1401] Fix | Delete
* Get the category taxonomy associated with a given post type.
[1402] Fix | Delete
*
[1403] Fix | Delete
* @since 4.0.6
[1404] Fix | Delete
*
[1405] Fix | Delete
* @param string $post_type Post type.
[1406] Fix | Delete
*
[1407] Fix | Delete
* @return string|bool
[1408] Fix | Delete
*/
[1409] Fix | Delete
function et_builder_get_category_taxonomy( $post_type ) {
[1410] Fix | Delete
static $cache = array();
[1411] Fix | Delete
[1412] Fix | Delete
// Address common cases.
[1413] Fix | Delete
switch ( $post_type ) {
[1414] Fix | Delete
case 'page':
[1415] Fix | Delete
return false;
[1416] Fix | Delete
case 'post':
[1417] Fix | Delete
return 'category';
[1418] Fix | Delete
case 'project':
[1419] Fix | Delete
return 'project_category';
[1420] Fix | Delete
case 'product':
[1421] Fix | Delete
return 'product_cat';
[1422] Fix | Delete
}
[1423] Fix | Delete
[1424] Fix | Delete
if ( isset( $cache[ $post_type ] ) ) {
[1425] Fix | Delete
// Use cached value.
[1426] Fix | Delete
return $cache[ $post_type ];
[1427] Fix | Delete
}
[1428] Fix | Delete
[1429] Fix | Delete
// Unknown post_type, guess the taxonomy.
[1430] Fix | Delete
$taxonomies = get_object_taxonomies( $post_type, 'names' );
[1431] Fix | Delete
[1432] Fix | Delete
foreach ( array( 'category', 'cat' ) as $pattern ) {
[1433] Fix | Delete
$matches = preg_grep( '/' . $pattern . '$/', $taxonomies );
[1434] Fix | Delete
if ( ! empty( $matches ) ) {
[1435] Fix | Delete
$cache[ $post_type ] = reset( $matches );
[1436] Fix | Delete
return $cache[ $post_type ];
[1437] Fix | Delete
}
[1438] Fix | Delete
}
[1439] Fix | Delete
[1440] Fix | Delete
// Tough luck.
[1441] Fix | Delete
$cache[ $post_type ] = false;
[1442] Fix | Delete
return $cache[ $post_type ];
[1443] Fix | Delete
}
[1444] Fix | Delete
[1445] Fix | Delete
/**
[1446] Fix | Delete
* Retrieve a post's category terms as a list with specified format.
[1447] Fix | Delete
*
[1448] Fix | Delete
* @since 4.0.6
[1449] Fix | Delete
*
[1450] Fix | Delete
* @param string $separator Optional. Separate items using this.
[1451] Fix | Delete
*
[1452] Fix | Delete
* @return string|false|WP_Error A list of terms on success, false if there are no terms, WP_Error on failure.
[1453] Fix | Delete
*/
[1454] Fix | Delete
function et_builder_get_the_term_list( $separator = '' ) {
[1455] Fix | Delete
$id = get_the_ID();
[1456] Fix | Delete
$taxonomy = et_builder_get_category_taxonomy( get_post_type( $id ) );
[1457] Fix | Delete
[1458] Fix | Delete
return $taxonomy ? get_the_term_list( $id, $taxonomy, $before = '', $separator ) : false;
[1459] Fix | Delete
}
[1460] Fix | Delete
[1461] Fix | Delete
/**
[1462] Fix | Delete
* Define current-page related data that are needed by frontend builder. Backend parser also uses this
[1463] Fix | Delete
* to sanitize updated value for computed data
[1464] Fix | Delete
*
[1465] Fix | Delete
* @return array
[1466] Fix | Delete
*/
[1467] Fix | Delete
function et_fb_current_page_params() {
[1468] Fix | Delete
global $post, $authordata, $paged;
[1469] Fix | Delete
[1470] Fix | Delete
// Get current page url.
[1471] Fix | Delete
[1472] Fix | Delete
$current_url = ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) ? ( is_ssl() ? 'https://' : 'http://' ) . sanitize_text_field( $_SERVER['HTTP_HOST'] ) . sanitize_text_field( $_SERVER['REQUEST_URI'] ) : '';
[1473] Fix | Delete
[1474] Fix | Delete
// Fallback for preview.
[1475] Fix | Delete
if ( empty( $authordata ) && isset( $post->post_author ) ) {
[1476] Fix | Delete
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- A fallback to set global $authordata.
[1477] Fix | Delete
$authordata = get_userdata( $post->post_author );
[1478] Fix | Delete
}
[1479] Fix | Delete
[1480] Fix | Delete
// Get comment count.
[1481] Fix | Delete
$comment_count = isset( $post->ID ) ? get_comments_number( $post->ID ) : 0;
[1482] Fix | Delete
[1483] Fix | Delete
// WordPress' _n() only supports singular n plural, thus we do comment count to text manually.
[1484] Fix | Delete
if ( 0 === $comment_count ) {
[1485] Fix | Delete
$comment_count_text = __( 'No Comments', 'et_builder' );
[1486] Fix | Delete
} elseif ( 1 === $comment_count ) {
[1487] Fix | Delete
$comment_count_text = __( '1 Comment', 'et_builder' );
[1488] Fix | Delete
} else {
[1489] Fix | Delete
// translators: comments count.
[1490] Fix | Delete
$comment_count_text = sprintf( __( '%d Comments', 'et_builder' ), $comment_count );
[1491] Fix | Delete
}
[1492] Fix | Delete
[1493] Fix | Delete
// Get current page paginated data.
[1494] Fix | Delete
$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
[1495] Fix | Delete
[1496] Fix | Delete
// Get thumbnail size.
[1497] 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';
[1498] Fix | Delete
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function