Save the file into your Plugin directory, and from admin panel, activate the plugin. On activation this will query for all the WooCommerce products with post_status
trash
and update them with status publish
.
Please test the plugin first in your end, and then apply to the live site.
<?php
/**
* Plugin Name: WooCommerce Trash Recovery
* Plugin URI: http://wordpress.stackexchange.com/q/218859/22728
*/
/**
* Trash retrival for WooCommerce
* @return void
*/
function wpse218859_trash_to_publish_on_activation() {
$prod_query = new WP_Query(
array(
'post_type' => 'product',
'post_status' => 'trash',
'posts_per_page' => -1
)
);
while( $prod_query->have_posts() ) : $prod_query->the_post();
wp_update_post(array(
'ID' => get_the_ID(),
'post_status' => 'publish'
));
endwhile;
wp_reset_postdata();
}
register_activation_hook( __FILE__, 'wpse218859_trash_to_publish_on_activation' );
Deactivate and delete it, after completion.