Example #1
0
 function __construct($plugin_file_path)
 {
     parent::__construct($plugin_file_path);
     global $wpmdbpro;
     $this->wpmdb =& $this->wpmdbpro;
     $this->wpmdbpro = $wpmdbpro;
     // add support for extra args
     add_filter('wpmdb_cli_filter_get_profile_data_from_args', array($this, 'add_extra_args_for_pro_export'), 10, 3);
     // extend get_tables_to_migrate with migrate_select
     add_filter('wpmdb_cli_tables_to_migrate', array($this, 'tables_to_migrate_include_select'), 10, 1);
 }
 /**
  * Perform CLI migration.
  *
  * @param mixed $profile Profile key or array
  *
  * @return void
  */
 protected function _perform_cli_migration($profile)
 {
     $wpmdb_cli = null;
     //load correct cli class
     if (function_exists('wpmdb_pro_cli')) {
         $wpmdb_cli = wpmdb_pro_cli();
     } else {
         $wpmdb_cli = wpmdb_cli();
     }
     if (empty($wpmdb_cli)) {
         WP_CLI::error(__('WP Migrate DB CLI class not available.', 'wp-migrate-db-cli'));
         return;
     }
     $result = $wpmdb_cli->cli_migration($profile);
     if (!is_wp_error($result)) {
         $success_msg = sprintf(__('Export saved to: %s', 'wp-migrate-db-cli'), $result);
         if ('find_replace' === $profile['action']) {
             $success_msg = __('Find & Replace complete', 'wp-migrate-db-cli');
         }
         WP_CLI::success($success_msg);
     } elseif (is_wp_error($result)) {
         WP_CLI::error(WPMDB_CLI::cleanup_message($result->get_error_message()));
     }
 }