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/feature
File: woocommerce-modules.php
$body_classes = get_body_class();
[1000] Fix | Delete
[1001] Fix | Delete
// Add Class only to WooCommerce Shop page if built using Divi (i.e. Divi Shop page).
[1002] Fix | Delete
if ( ! ( function_exists( 'is_shop' ) && is_shop() ) ) {
[1003] Fix | Delete
return $classes;
[1004] Fix | Delete
}
[1005] Fix | Delete
[1006] Fix | Delete
// Add Class only when the WooCommerce Shop page is built using Divi.
[1007] Fix | Delete
if ( ! et_builder_wc_is_non_product_post_type() ) {
[1008] Fix | Delete
return $classes;
[1009] Fix | Delete
}
[1010] Fix | Delete
[1011] Fix | Delete
// Precautionary check: $body_classes should always be an array.
[1012] Fix | Delete
if ( ! is_array( $body_classes ) ) {
[1013] Fix | Delete
return $classes;
[1014] Fix | Delete
}
[1015] Fix | Delete
[1016] Fix | Delete
// Add Class only when the <body> tag does not contain them.
[1017] Fix | Delete
$woocommerce_classes = array( 'woocommerce', 'woocommerce-page' );
[1018] Fix | Delete
$common_classes = array_intersect( $body_classes, array(
[1019] Fix | Delete
'woocommerce',
[1020] Fix | Delete
'woocommerce-page',
[1021] Fix | Delete
) );
[1022] Fix | Delete
if ( is_array( $common_classes )
[1023] Fix | Delete
&& count( $woocommerce_classes ) === count( $common_classes ) ) {
[1024] Fix | Delete
return $classes;
[1025] Fix | Delete
}
[1026] Fix | Delete
[1027] Fix | Delete
// Precautionary check: $classes should always be an array.
[1028] Fix | Delete
if ( ! is_array( $classes ) ) {
[1029] Fix | Delete
return $classes;
[1030] Fix | Delete
}
[1031] Fix | Delete
[1032] Fix | Delete
$classes[] = 'woocommerce';
[1033] Fix | Delete
$classes[] = 'woocommerce-page';
[1034] Fix | Delete
[1035] Fix | Delete
return $classes;
[1036] Fix | Delete
}
[1037] Fix | Delete
[1038] Fix | Delete
/**
[1039] Fix | Delete
* Sets the Product page layout post meta on two occurrences.
[1040] Fix | Delete
*
[1041] Fix | Delete
* They are 1) On WP Admin Publish/Update post 2) On VB Save.
[1042] Fix | Delete
*
[1043] Fix | Delete
* @param int $post_id
[1044] Fix | Delete
*
[1045] Fix | Delete
* @since 3.29
[1046] Fix | Delete
*/
[1047] Fix | Delete
function et_builder_set_product_page_layout_meta( $post_id ) {
[1048] Fix | Delete
$post = get_post( $post_id );
[1049] Fix | Delete
if ( ! $post ) {
[1050] Fix | Delete
return;
[1051] Fix | Delete
}
[1052] Fix | Delete
[1053] Fix | Delete
/*
[1054] Fix | Delete
* The Product page layout post meta adds no meaning to the Post when the Builder is not used.
[1055] Fix | Delete
* Hence the meta key/value is removed, when the Builder is turned off.
[1056] Fix | Delete
*/
[1057] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( $post_id ) ) {
[1058] Fix | Delete
delete_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_LAYOUT_META_KEY );
[1059] Fix | Delete
return;
[1060] Fix | Delete
}
[1061] Fix | Delete
[1062] Fix | Delete
// Do not update Product page layout post meta when it contains a value.
[1063] Fix | Delete
$product_page_layout = get_post_meta(
[1064] Fix | Delete
$post_id,
[1065] Fix | Delete
ET_BUILDER_WC_PRODUCT_PAGE_LAYOUT_META_KEY,
[1066] Fix | Delete
true
[1067] Fix | Delete
);
[1068] Fix | Delete
if ( $product_page_layout ) {
[1069] Fix | Delete
return;
[1070] Fix | Delete
}
[1071] Fix | Delete
[1072] Fix | Delete
$product_page_layout = et_get_option(
[1073] Fix | Delete
'et_pb_woocommerce_page_layout',
[1074] Fix | Delete
'et_build_from_scratch'
[1075] Fix | Delete
);
[1076] Fix | Delete
[1077] Fix | Delete
update_post_meta(
[1078] Fix | Delete
$post_id,
[1079] Fix | Delete
ET_BUILDER_WC_PRODUCT_PAGE_LAYOUT_META_KEY,
[1080] Fix | Delete
sanitize_text_field( $product_page_layout )
[1081] Fix | Delete
);
[1082] Fix | Delete
}
[1083] Fix | Delete
[1084] Fix | Delete
/**
[1085] Fix | Delete
* Sets the Product content status as modified during VB save.
[1086] Fix | Delete
*
[1087] Fix | Delete
* This avoids setting the default WooCommerce Modules layout more than once.
[1088] Fix | Delete
*
[1089] Fix | Delete
* @link https://github.com/elegantthemes/Divi/issues/16420
[1090] Fix | Delete
*
[1091] Fix | Delete
* @param int $post_id Post ID.
[1092] Fix | Delete
*
[1093] Fix | Delete
*/
[1094] Fix | Delete
function et_builder_set_product_content_status( $post_id ) {
[1095] Fix | Delete
if ( 0 === absint( $post_id ) ) {
[1096] Fix | Delete
return;
[1097] Fix | Delete
}
[1098] Fix | Delete
[1099] Fix | Delete
if ( 'product' !== get_post_type( $post_id ) || 'modified' === get_post_meta( $post_id,
[1100] Fix | Delete
ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY, true ) ) {
[1101] Fix | Delete
return;
[1102] Fix | Delete
}
[1103] Fix | Delete
[1104] Fix | Delete
update_post_meta( $post_id, ET_BUILDER_WC_PRODUCT_PAGE_CONTENT_STATUS_META_KEY, 'modified' );
[1105] Fix | Delete
}
[1106] Fix | Delete
[1107] Fix | Delete
/**
[1108] Fix | Delete
* Gets Woocommerce Tabs for the given Product ID.
[1109] Fix | Delete
*
[1110] Fix | Delete
* @since 4.4.2
[1111] Fix | Delete
*/
[1112] Fix | Delete
function et_builder_get_woocommerce_tabs() {
[1113] Fix | Delete
// Nonce verification.
[1114] Fix | Delete
et_core_security_check( 'edit_posts', 'et_builder_get_woocommerce_tabs', 'nonce' );
[1115] Fix | Delete
[1116] Fix | Delete
$_ = et_();
[1117] Fix | Delete
$product_id = $_->array_get( $_POST, 'product', 0 );
[1118] Fix | Delete
[1119] Fix | Delete
if ( null === $product_id || ! et_is_woocommerce_plugin_active() ) {
[1120] Fix | Delete
wp_send_json_error();
[1121] Fix | Delete
}
[1122] Fix | Delete
[1123] Fix | Delete
// Allow Latest Product ID which is a string 'latest'.
[1124] Fix | Delete
// `This Product` tabs are defined in et_fb_current_page_params()
[1125] Fix | Delete
if ( ! in_array( $product_id, array( 'current', 'latest' ) ) && 0 === absint( $product_id ) ) {
[1126] Fix | Delete
wp_send_json_error();
[1127] Fix | Delete
}
[1128] Fix | Delete
[1129] Fix | Delete
$tabs = ET_Builder_Module_Woocommerce_Tabs::get_tabs( array( 'product' => $product_id ) );
[1130] Fix | Delete
[1131] Fix | Delete
wp_send_json_success( $tabs );
[1132] Fix | Delete
}
[1133] Fix | Delete
[1134] Fix | Delete
/**
[1135] Fix | Delete
* Returns alternative hook to make Woo Extra Product Options display fields in FE when TB is
[1136] Fix | Delete
* enabled.
[1137] Fix | Delete
*
[1138] Fix | Delete
* - The Woo Extra Product Options addon does not display the extra fields on the FE.
[1139] Fix | Delete
* - This is because the original hook i.e. `woocommerce_before_single_product` in the plugin
[1140] Fix | Delete
* is not triggered when TB is enabled.
[1141] Fix | Delete
* - Hence return a suitable hook that is fired for all types of Products i.e. Simple, Variable,
[1142] Fix | Delete
* etc.
[1143] Fix | Delete
*
[1144] Fix | Delete
* @see WEPOF_Product_Options_Frontend::define_public_hooks()
[1145] Fix | Delete
*
[1146] Fix | Delete
* @since 4.0.9
[1147] Fix | Delete
*
[1148] Fix | Delete
* @return string WooCommerce Hook that is being fired on TB enabled Product pages.
[1149] Fix | Delete
*/
[1150] Fix | Delete
function et_builder_trigger_extra_product_options( $hook ) {
[1151] Fix | Delete
return 'woocommerce_before_add_to_cart_form';
[1152] Fix | Delete
}
[1153] Fix | Delete
[1154] Fix | Delete
/**
[1155] Fix | Delete
* Strip Builder shortcodes to avoid nested parsing.
[1156] Fix | Delete
*
[1157] Fix | Delete
* @see https://github.com/elegantthemes/Divi/issues/18682
[1158] Fix | Delete
*
[1159] Fix | Delete
* @param string $content
[1160] Fix | Delete
*
[1161] Fix | Delete
* @since 4.3.3
[1162] Fix | Delete
*
[1163] Fix | Delete
* @return string
[1164] Fix | Delete
*/
[1165] Fix | Delete
function et_builder_avoid_nested_shortcode_parsing( $content ) {
[1166] Fix | Delete
// Strip shortcodes only on non-builder pages that contain Builder shortcodes.
[1167] Fix | Delete
if ( et_pb_is_pagebuilder_used( get_the_ID() ) ) {
[1168] Fix | Delete
return $content;
[1169] Fix | Delete
}
[1170] Fix | Delete
[1171] Fix | Delete
// WooCommerce layout loads when builder is not enabled.
[1172] Fix | Delete
// So strip builder shortcodes from Post content.
[1173] Fix | Delete
if ( function_exists( 'is_product' ) && is_product() ) {
[1174] Fix | Delete
return et_strip_shortcodes( $content );
[1175] Fix | Delete
}
[1176] Fix | Delete
[1177] Fix | Delete
// Strip builder shortcodes from non-product pages.
[1178] Fix | Delete
// Only Tabs shortcode is checked since that causes nested rendering.
[1179] Fix | Delete
if ( has_shortcode( $content, 'et_pb_wc_tabs' ) ) {
[1180] Fix | Delete
return et_strip_shortcodes( $content );
[1181] Fix | Delete
}
[1182] Fix | Delete
[1183] Fix | Delete
return $content;
[1184] Fix | Delete
}
[1185] Fix | Delete
[1186] Fix | Delete
/**
[1187] Fix | Delete
* Parses Product description to
[1188] Fix | Delete
*
[1189] Fix | Delete
* - converts any [embed][/embed] shortcode to its respective HTML.
[1190] Fix | Delete
* - strips `et_` shortcodes to avoid nested rendering in Woo Tabs module.
[1191] Fix | Delete
* - adds <p> tag to keep the paragraph sanity.
[1192] Fix | Delete
* - runs other shortcodes if any using do_shortcode.
[1193] Fix | Delete
*
[1194] Fix | Delete
* @since 4.4.1
[1195] Fix | Delete
*
[1196] Fix | Delete
* @param string $description
[1197] Fix | Delete
*
[1198] Fix | Delete
* @return string
[1199] Fix | Delete
*/
[1200] Fix | Delete
function et_builder_wc_parse_description( $description ) {
[1201] Fix | Delete
if ( ! is_string( $description ) ) {
[1202] Fix | Delete
return $description;
[1203] Fix | Delete
}
[1204] Fix | Delete
[1205] Fix | Delete
[1206] Fix | Delete
global $wp_embed;
[1207] Fix | Delete
[1208] Fix | Delete
$parsed_description = et_strip_shortcodes( $description );
[1209] Fix | Delete
$parsed_description = $wp_embed->run_shortcode( $parsed_description );
[1210] Fix | Delete
$parsed_description = do_shortcode( $parsed_description );
[1211] Fix | Delete
$parsed_description = wpautop( $parsed_description );
[1212] Fix | Delete
[1213] Fix | Delete
return $parsed_description;
[1214] Fix | Delete
}
[1215] Fix | Delete
[1216] Fix | Delete
/**
[1217] Fix | Delete
* Entry point for the woocommerce-modules.php file.
[1218] Fix | Delete
*
[1219] Fix | Delete
* @since 3.29
[1220] Fix | Delete
*/
[1221] Fix | Delete
function et_builder_wc_init() {
[1222] Fix | Delete
// global $post won't be available with `after_setup_theme` hook and hence `wp` hook is used.
[1223] Fix | Delete
add_action( 'wp', 'et_builder_wc_override_default_layout' );
[1224] Fix | Delete
[1225] Fix | Delete
// Add WooCommerce class names on non-`product` CPT which uses builder
[1226] Fix | Delete
add_filter( 'body_class', 'et_builder_wc_add_body_class' );
[1227] Fix | Delete
add_filter( 'et_builder_inner_content_class', 'et_builder_wc_add_inner_content_class' );
[1228] Fix | Delete
add_filter( 'et_builder_outer_content_class', 'et_builder_wc_add_outer_content_class' );
[1229] Fix | Delete
[1230] Fix | Delete
[1231] Fix | Delete
// Load WooCommerce related scripts
[1232] Fix | Delete
add_action( 'wp_enqueue_scripts', 'et_builder_wc_load_scripts', 15 );
[1233] Fix | Delete
[1234] Fix | Delete
add_filter(
[1235] Fix | Delete
'et_builder_skip_content_activation',
[1236] Fix | Delete
'et_builder_wc_skip_initial_content',
[1237] Fix | Delete
10,
[1238] Fix | Delete
2
[1239] Fix | Delete
);
[1240] Fix | Delete
[1241] Fix | Delete
// Show Product Content dropdown settings under
[1242] Fix | Delete
// Divi Theme Options ⟶ Builder ⟶ Post TYpe Integration.
[1243] Fix | Delete
add_filter( 'et_builder_settings_definitions', 'et_builder_wc_add_settings' );
[1244] Fix | Delete
[1245] Fix | Delete
/**
[1246] Fix | Delete
* Adds the metabox only to Product post type.
[1247] Fix | Delete
*
[1248] Fix | Delete
* This is achieved using the post type hook - add_meta_boxes_{post_type}.
[1249] Fix | Delete
*
[1250] Fix | Delete
* @see https://codex.wordpress.org/Plugin_API/Action_Reference/add_meta_boxes
[1251] Fix | Delete
*
[1252] Fix | Delete
* @since 3.29
[1253] Fix | Delete
*/
[1254] Fix | Delete
add_action( 'add_meta_boxes_product', 'et_builder_wc_long_description_metabox_register' );
[1255] Fix | Delete
[1256] Fix | Delete
// Saves the long description metabox data.
[1257] Fix | Delete
// Since `et_pb_metabox_settings_save_details()` already uses `save_post` hook
[1258] Fix | Delete
// to save `_et_pb_old_content` post meta,
[1259] Fix | Delete
// we use this additional hook `et_pb_old_content_updated`.
[1260] Fix | Delete
add_action( 'et_pb_old_content_updated', 'et_builder_wc_long_description_metabox_save', 10, 3 );
[1261] Fix | Delete
[1262] Fix | Delete
// 01. Sets the initial Content when `Use Divi Builder` button is clicked
[1263] Fix | Delete
// in the Admin dashboard.
[1264] Fix | Delete
// 02. Sets the initial Content when `Enable Visual Builder` is clicked.
[1265] Fix | Delete
add_filter(
[1266] Fix | Delete
'et_fb_load_raw_post_content',
[1267] Fix | Delete
'et_builder_wc_set_initial_content',
[1268] Fix | Delete
10,
[1269] Fix | Delete
2
[1270] Fix | Delete
);
[1271] Fix | Delete
[1272] Fix | Delete
add_action( 'et_save_post', 'et_builder_set_product_page_layout_meta' );
[1273] Fix | Delete
[1274] Fix | Delete
/*
[1275] Fix | Delete
* Set the Product modified status as modified upon save to make sure default layout is not
[1276] Fix | Delete
* loaded more than one time.
[1277] Fix | Delete
*
[1278] Fix | Delete
* @see https://github.com/elegantthemes/Divi/issues/16420
[1279] Fix | Delete
*/
[1280] Fix | Delete
add_action( 'et_update_post', 'et_builder_set_product_content_status' );
[1281] Fix | Delete
[1282] Fix | Delete
/*
[1283] Fix | Delete
* Handle get Woocommerce tabs AJAX call initiated by Tabs checkbox in settings modal.
[1284] Fix | Delete
*/
[1285] Fix | Delete
add_action( 'wp_ajax_et_builder_get_woocommerce_tabs', 'et_builder_get_woocommerce_tabs' );
[1286] Fix | Delete
[1287] Fix | Delete
/*
[1288] Fix | Delete
* Fix Woo Extra Product Options addon compatibility.
[1289] Fix | Delete
* @see https://github.com/elegantthemes/Divi/issues/17909
[1290] Fix | Delete
*/
[1291] Fix | Delete
add_filter( 'thwepof_hook_name_before_single_product', 'et_builder_trigger_extra_product_options' );
[1292] Fix | Delete
[1293] Fix | Delete
/*
[1294] Fix | Delete
* Fix nested parsing on non-builder product pages w/ shortcode content.
[1295] Fix | Delete
* @see https://github.com/elegantthemes/Divi/issues/18682
[1296] Fix | Delete
*/
[1297] Fix | Delete
add_filter( 'the_content', 'et_builder_avoid_nested_shortcode_parsing' );
[1298] Fix | Delete
[1299] Fix | Delete
add_filter( 'et_builder_wc_description', 'et_builder_wc_parse_description' );
[1300] Fix | Delete
}
[1301] Fix | Delete
[1302] Fix | Delete
et_builder_wc_init();
[1303] Fix | Delete
[1304] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function