Last active
January 3, 2023 08:11
-
-
Save theRealRizeo/c59039193b309a0b9a5c9f4b2409e406 to your computer and use it in GitHub Desktop.
WP Cloner custom clone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array_of_post_types = array( | |
'attachment', | |
'page', | |
'post', | |
'product', | |
'revision', | |
'wp_global_styles', | |
); | |
$array_of_tables = array( | |
'wp_actionscheduler_actions', | |
'wp_actionscheduler_claims', | |
'wp_actionscheduler_groups', | |
'wp_actionscheduler_logs', | |
'wp_commentmeta', | |
'wp_comments', | |
'wp_links', | |
'wp_options', | |
'wp_postmeta', | |
'wp_posts', | |
'wp_term_relationships', | |
'wp_term_taxonomy', | |
'wp_termmeta', | |
'wp_terms', | |
'wp_wc_admin_note_actions', | |
'wp_wc_admin_notes', | |
'wp_wc_category_lookup', | |
'wp_wc_customer_lookup', | |
'wp_wc_download_log', | |
'wp_wc_order_coupon_lookup', | |
'wp_wc_order_product_lookup', | |
'wp_wc_order_stats', | |
'wp_wc_order_tax_lookup', | |
'wp_wc_product_attributes_lookup', | |
'wp_wc_product_download_directories', | |
'wp_wc_product_meta_lookup', | |
'wp_wc_rate_limits', | |
'wp_wc_reserved_stock', | |
'wp_wc_tax_rate_classes', | |
'wp_wc_webhooks', | |
'wp_woocommerce_api_keys', | |
'wp_woocommerce_attribute_taxonomies', | |
'wp_woocommerce_downloadable_product_permissions', | |
'wp_woocommerce_log', | |
'wp_woocommerce_order_itemmeta', | |
'wp_woocommerce_order_items', | |
'wp_woocommerce_payment_tokenmeta', | |
'wp_woocommerce_payment_tokens', | |
'wp_woocommerce_sessions', | |
'wp_woocommerce_shipping_zone_locations', | |
'wp_woocommerce_shipping_zone_methods', | |
'wp_woocommerce_shipping_zones', | |
'wp_woocommerce_tax_rate_locations', | |
'wp_woocommerce_tax_rates', | |
); | |
$request = array( | |
'clone_mode' => 'core', | |
'source_id' => 1, // any blog/site id on network. | |
'target_name' => 'test1', | |
'target_title' => 'test1', | |
'tables_to_clone' => $array_of_tables, | |
'debug' => 1, | |
'do_copy_posts' => 1, | |
'post_types_to_clone' => $array_of_post_types, // can customize post types . . . | |
'do_copy_files' => 1, | |
// 'do_copy_users' => 0, | |
'flush_cache' => 1, | |
'clone_nonce' => wp_create_nonce( 'ns_cloner' ), | |
); | |
// This is required to bootstrap the required plugin classes. | |
ns_cloner()->init(); | |
foreach ( $request as $key => $value ) { | |
ns_cloner_request()->set( $key, $value ); | |
} | |
ns_cloner_request()->set_up_vars(); | |
ns_cloner_request()->save(); | |
// Run init to begin. | |
ns_cloner()->process_manager->init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment