Skip to content

Instantly share code, notes, and snippets.

@theRealRizeo
Created January 24, 2023 06:26
Show Gist options
  • Save theRealRizeo/06cc6abeab31ae9961390cd4b6df2306 to your computer and use it in GitHub Desktop.
Save theRealRizeo/06cc6abeab31ae9961390cd4b6df2306 to your computer and use it in GitHub Desktop.
Cloner search and replace pro version
<?php
$array_of_post_types = array(
'attachment',
'page',
'post',
'revision',
'wp_global_styles',
);
$array_of_tables = array(
'wp_commentmeta',
'wp_comments',
'wp_links',
'wp_options',
'wp_postmeta',
'wp_posts',
'wp_term_relationships',
'wp_term_taxonomy',
'wp_termmeta',
'wp_terms',
);
$request = array(
'clone_mode' => 'clone_over',
'source_id' => 1, // any blog/site id on network.
'clone_over_target_ids' => array( 2 ), // target site id in array.
'clone_over_target_title' => 'Targe Title',
'target_title' => 'test1',
'custom_search' => array( 'search1', 'search2' ),
'custom_replace' => array( 'replace1', 'replace2' ),
'_caller' => 'Registration',
'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