lesterchan / wp-sweep

WP-Sweep allows you to clean up unused, orphaned and duplicated data in your WordPress. It also optimizes your database tables.
https://wordpress.org/plugins/wp-sweep/
152 stars 23 forks source link

Support for YITH WooCommerce Multi Vendor Premium plugin #49

Closed andreagrillo closed 6 years ago

andreagrillo commented 7 years ago

Hi,

I'm Andrea from yithemes.com I write to you because I need to add the support for your plugin and our multi vendor plugin.

The YITH WooCommerce Multi Vendor Premium plugin create a new product taxonomy to simulate a marketplace and, when an user create it for first time, this taxonomy haven't any product linked to it, but this not means it's an orphan terms.

How can I exclude the yith vendor term ?

Let me know. Thanks Have a nice day

AG

lesterchan commented 7 years ago

Hi,

You can use this filter to filter it off.

See https://github.com/lesterchan/wp-sweep/blob/master/wp-sweep.php#L789

andreagrillo commented 7 years ago

Hi @lesterchan

Thanks for your answer. I create this code:

add_filter( 'wp_sweep_excluded_taxonomies', 'yith_wcmv_wp_sweep_excluded_taxonomies' );

if( ! function_exists( 'yith_wcmv_wp_sweep_excluded_taxonomies' ) ){
    function yith_wcmv_wp_sweep_excluded_taxonomies( $excluded_taxonomies ){

        if( function_exists( 'YITH_Vendors' ) ){
            $excluded_taxonomies[] = YITH_Vendors()->get_taxonomy_name();
        }

        return $excluded_taxonomies;
    }
}

and if you execute a var_dump of $excluded_taxonomies array all seems to works fine, but in sweep page the unused term of vendor taxonomy are ready to be clean:

https://www.dropbox.com/s/mx3cys57lkaytf7/Selection_827.png?dl=0

and this is the results:

https://www.dropbox.com/s/c8rlqylii87b8uy/Selection_828.png?dl=0

Do you have another solution ? Anything wrong in my code ? For testing you can download the multi vendor plugin here: https://wordpress.org/plugins/yith-woocommerce-product-vendors/

I'm look forward to hearing from you. Bye AG

szepeviktor commented 7 years ago

array_merge() would prevent duplicates.

-- +36204242498 Ezen a készüléken sok az elütés. Elnézést!

On July 14, 2017 10:33:43 AM CEST, Andrea Grillo notifications@github.com wrote:

Hi @lesterchan

Thanks for your answer. I create this code:

`add_filter( 'wp_sweep_excluded_taxonomies', 'yith_wcmv_wp_sweep_excluded_taxonomies' );

if( ! function_exists( 'yith_wcmv_wp_sweep_excluded_taxonomies' ) ){ function yith_wcmv_wp_sweep_excluded_taxonomies( $excluded_taxonomies ){

   if( function_exists( 'YITH_Vendors' ) ){
     $excluded_taxonomies[] = YITH_Vendors()->get_taxonomy_name();
   }

   return $excluded_taxonomies;

} }`

and if you execute a var_dump of $excluded_taxonomies array all seems to works fine, but in sweep page the unused term of vendor taxonomy are ready to be clean:

https://www.dropbox.com/s/mx3cys57lkaytf7/Selection_827.png?dl=0

and this is the results:

https://www.dropbox.com/s/c8rlqylii87b8uy/Selection_828.png?dl=0

Do you have another solution ? Anything wrong in my code ? For testing you can download the multi vendor plugin here: https://wordpress.org/plugins/yith-woocommerce-product-vendors/

I'm look forward to hearing from you. Bye AG

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/lesterchan/wp-sweep/issues/49#issuecomment-315303985

andreagrillo commented 7 years ago

ummmm but the array have the taxonomy name inside it, but doesn't works.

lesterchan commented 7 years ago

How about var_dump the SQL https://github.com/lesterchan/wp-sweep/blob/master/wp-sweep.php#L452? This is the SQL that is used to retrieve the Details

szepeviktor commented 7 years ago
if ( function_exists( 'YITH_Vendors' ) ) :
add_filter( 'wp_sweep_excluded_taxonomies', 'yith_wcmv_wp_sweep_excluded_taxonomies' );

function yith_wcmv_wp_sweep_excluded_taxonomies( $excluded_taxonomies ) {

    $excluded_taxonomies[] = YITH_Vendors()->get_taxonomy_name();
    return array_unique( $excluded_taxonomies );
}
endif;