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
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/themify-.../includes/plugin-c...
File: woocommerce.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Builder Plugin Compatibility Code
[2] Fix | Delete
*
[3] Fix | Delete
* @package Themify_Builder
[4] Fix | Delete
* @subpackage Themify_Builder/classes
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
class Themify_Builder_Plugin_Compat_WooCommerce {
[8] Fix | Delete
[9] Fix | Delete
static function init() {
[10] Fix | Delete
$description_hook = themify_get( 'setting-product_description_type','long',true );
[11] Fix | Delete
if ( ! is_admin() ) {
[12] Fix | Delete
$description_hook = $description_hook==='long' || !$description_hook? 'the_content' : 'woocommerce_short_description';
[13] Fix | Delete
add_filter( $description_hook, array( __CLASS__, 'single_product_builder_content') );
[14] Fix | Delete
if('woocommerce_short_description'===$description_hook){
[15] Fix | Delete
add_action( 'woocommerce_variable_add_to_cart', array( __CLASS__, 'remove_builder_content_variation' ) );
[16] Fix | Delete
} else {
[17] Fix | Delete
/* prevent static content from showing in short description */
[18] Fix | Delete
add_filter( 'woocommerce_short_description', [ 'Themify_Builder', 'clear_static_content' ] );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
// Single Variations Plugin compatibility
[22] Fix | Delete
if( class_exists( 'Iconic_WSSV_Query',false ) ) {
[23] Fix | Delete
add_filter( 'pre_get_posts', array( __CLASS__, 'add_variations_to_product_query' ), 50, 1 );
[24] Fix | Delete
}
[25] Fix | Delete
}
[26] Fix | Delete
elseif('short'===$description_hook){
[27] Fix | Delete
global $pagenow;
[28] Fix | Delete
if(($pagenow === 'post-new.php' && isset($_GET['post_type']) && 'product'===$_GET['post_type']) || ('post.php' === $pagenow && isset($_GET['post']) && 'product'===get_post_type( $_GET['post']))){
[29] Fix | Delete
add_filter( 'themify_builder_active_vars', array( __CLASS__, 'short_desc_builder_badge' ) );
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
add_action( 'woocommerce_archive_description', array( __CLASS__, 'wc_builder_shop_page' ), 11 );
[33] Fix | Delete
add_action( 'woocommerce_before_template_part', array( __CLASS__, 'before_woocommerce_templates' ) );
[34] Fix | Delete
add_action( 'woocommerce_after_template_part', array( __CLASS__, 'after_woocommerce_templates' ) );
[35] Fix | Delete
add_filter( 'woocommerce_short_description', array( __CLASS__, 'fix_static_content_on_shop_page' ) );
[36] Fix | Delete
add_filter( 'woocommerce_product_tabs', array( __CLASS__, 'woocommerce_product_tabs' ) );
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* disable Builder on Shop page
[40] Fix | Delete
* self::wc_builder_shop_page() handles this
[41] Fix | Delete
*/
[42] Fix | Delete
add_action( 'woocommerce_before_main_content', array( __CLASS__, 'woocommerce_before_main_content' ) );
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/*
[46] Fix | Delete
* Localize a value to add builder static content to short description
[47] Fix | Delete
* */
[48] Fix | Delete
public static function short_desc_builder_badge(array $vars ):array {
[49] Fix | Delete
$vars['short_badge'] = true;
[50] Fix | Delete
return $vars;
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
public static function woocommerce_before_main_content() {
[54] Fix | Delete
if ( themify_is_shop() ) {
[55] Fix | Delete
Themify_Builder::reset_builder_query( 'reset' );
[56] Fix | Delete
add_action( 'woocommerce_after_main_content', array( __CLASS__, 'woocommerce_after_main_content' ) );
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
public static function woocommerce_after_main_content() {
[61] Fix | Delete
Themify_Builder::reset_builder_query( 'restore' );
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Remove builder content filter from variation short description
[66] Fix | Delete
*/
[67] Fix | Delete
public static function remove_builder_content_variation() {
[68] Fix | Delete
global $post;
[69] Fix | Delete
if ( $post->post_type === 'product' && is_product()) {
[70] Fix | Delete
remove_filter( 'woocommerce_short_description', array( __CLASS__, 'single_product_builder_content') );
[71] Fix | Delete
}
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Show builder on Shop page.
[76] Fix | Delete
*
[77] Fix | Delete
* @access public
[78] Fix | Delete
*/
[79] Fix | Delete
public static function wc_builder_shop_page() {
[80] Fix | Delete
if ( themify_is_shop() ) {
[81] Fix | Delete
echo self::show_builder_content( Themify_Builder_Model::get_ID() );
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Avoid render buider content in WooCommerce content
[87] Fix | Delete
*/
[88] Fix | Delete
[89] Fix | Delete
public static function before_woocommerce_templates() {
[90] Fix | Delete
if( Themify_Builder_Model::is_front_builder_activate() ) {
[91] Fix | Delete
remove_filter( 'the_content', array( 'Themify_Builder', 'builder_show_on_front'), 11 );
[92] Fix | Delete
}
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
public static function after_woocommerce_templates() {
[96] Fix | Delete
if( Themify_Builder_Model::is_front_builder_activate() ) {
[97] Fix | Delete
add_filter( 'the_content', array( 'Themify_Builder', 'builder_show_on_front' ), 11 );
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Removes Builder static content from Shop page
[103] Fix | Delete
*
[104] Fix | Delete
* @return string
[105] Fix | Delete
*/
[106] Fix | Delete
public static function fix_static_content_on_shop_page(string $content='' ):string {
[107] Fix | Delete
if ( is_post_type_archive( 'product' ) ) {
[108] Fix | Delete
$content = ThemifyBuilder_Data_Manager::update_static_content_string( '', $content );
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return $content;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
/**
[115] Fix | Delete
* Ensure "Description" product tab is visible on frontend even if there are no description,
[116] Fix | Delete
* so that Builder frontend editor can be used.
[117] Fix | Delete
*
[118] Fix | Delete
* Hooked to "woocommerce_product_tabs"
[119] Fix | Delete
*/
[120] Fix | Delete
public static function woocommerce_product_tabs(array $tabs ):array {
[121] Fix | Delete
if ( ! isset( $tabs['description'] ) && Themify_Builder_Model::is_frontend_editor_page()&& is_singular( 'product' ) ) {
[122] Fix | Delete
$tabs['description'] = array(
[123] Fix | Delete
'title' => __( 'Description', 'themify' ),
[124] Fix | Delete
'priority' => 10,
[125] Fix | Delete
'callback' => 'woocommerce_product_description_tab',
[126] Fix | Delete
);
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
return $tabs;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
private static function show_builder_content(int $id,string $content=''):string{
[133] Fix | Delete
return Themify_Builder::render( $id, $content );
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Render builder content for Single products
[138] Fix | Delete
*
[139] Fix | Delete
* @access public
[140] Fix | Delete
* @return string
[141] Fix | Delete
*/
[142] Fix | Delete
public static function single_product_builder_content(string $content='' ):string {
[143] Fix | Delete
global $post;
[144] Fix | Delete
if ( isset( $post->post_type ) && $post->post_type === 'product' && is_product()) {
[145] Fix | Delete
$content = self::show_builder_content( $post->ID, $content );
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
return $content;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
public static function add_variations_to_product_query($q){
[152] Fix | Delete
if ('product' !== $q->get('post_type') && !$q->is_search ) {
[153] Fix | Delete
return $q;
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
// Add product variations to the query
[157] Fix | Delete
$post_type = (array) $q->get( 'post_type' );
[158] Fix | Delete
$post_type[] = 'product_variation';
[159] Fix | Delete
if ( ! in_array( 'product', $post_type,true ) ) {
[160] Fix | Delete
$post_type[] = 'product';
[161] Fix | Delete
}
[162] Fix | Delete
$q->set( 'post_type', array_filter( $post_type ) );
[163] Fix | Delete
[164] Fix | Delete
// Don't get variations with unpublished parents
[165] Fix | Delete
$unpublished_variable_product_ids = Iconic_WSSV_Query::get_unpublished_variable_product_ids();
[166] Fix | Delete
if ( ! empty( $unpublished_variable_product_ids ) ) {
[167] Fix | Delete
$q->set( 'post_parent__not_in', array_merge( (array) $q->get( 'post_parent__not_in' ), $unpublished_variable_product_ids ) );
[168] Fix | Delete
}
[169] Fix | Delete
[170] Fix | Delete
// Don't get variations with missing parents :(
[171] Fix | Delete
$variation_ids_with_missing_parent = Iconic_WSSV_Query::get_variation_ids_with_missing_parent();
[172] Fix | Delete
if ( ! empty( $variation_ids_with_missing_parent ) ) {
[173] Fix | Delete
$q->set( 'post__not_in', array_merge( (array) $q->get( 'post__not_in' ), $variation_ids_with_missing_parent ) );
[174] Fix | Delete
}
[175] Fix | Delete
// update the tax query to include our variations
[176] Fix | Delete
$q->set( 'tax_query', Iconic_WSSV_Query::update_tax_query( (array) $q->get( 'tax_query' ) ) );
[177] Fix | Delete
[178] Fix | Delete
return $q;
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function