Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up every sentence about migrate to sync, and grammar #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions class/command.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<?php

/**
* Migrate your DB using WP Sync DB.
* Sync your DB using WP Sync DB.
*/
class WPSDBCLI extends WP_CLI_Command {

/**
* Run a migration.
* Run a syncing.
*
* ## OPTIONS
*
* <profile>
* : ID of the profile to use for the migration.
* : ID of the profile to use for the syncing.
*
* ## EXAMPLES
*
* wp wpsdb migrate 1
* wp wpsdb sync 1
*
* @synopsis <profile>
*
* @since 1.0
*/
public function migrate( $args, $assoc_args ) {
public function sync( $args, $assoc_args ) {
$profile = $args[0];

$result = wpsdb_migrate( $profile );
$result = wpsdb_sync( $profile );

if ( true === $result ) {
WP_CLI::success( __( 'Migration successful.', 'wp-sync-db-cli' ) );
WP_CLI::success( __( 'Syncing successful.', 'wp-sync-db-cli' ) );
return;
}

Expand Down
78 changes: 39 additions & 39 deletions class/wpsdb-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function __construct( $plugin_file_path ) {
if( ! $this->meets_version_requirements( '1.4b1' ) ) return;
}

function cli_migration( $profile ) {
function cli_syncing( $profile ) {
global $wpsdb;
$wpsdb_settings = get_option( 'wpsdb_settings' );
--$profile;
Expand All @@ -19,13 +19,13 @@ function cli_migration( $profile ) {
if( ! isset( $wpsdb_settings['profiles'][$profile] ) ) return $this->cli_error( __( 'Profile ID not found.', 'wp-sync-db-cli' ) );

$this->set_time_limit();
$wpsdb->set_cli_migration();
$wpsdb->set_cli_syncing();

$profile = apply_filters( 'wpsdb_cli_profile_before_migration', $wpsdb_settings['profiles'][$profile] );
$profile = apply_filters( 'wpsdb_cli_profile_before_syncing', $wpsdb_settings['profiles'][$profile] );
$connection_info = explode( "\n", $profile['connection_info'] );
$form_data = http_build_query( $profile );

if( 'savefile' == $profile['action'] ) return $this->cli_error( __( 'Exports not supported for CLI migrations. Please instead select push or pull instead.', 'wp-sync-db-cli' ) );
if( 'savefile' == $profile['action'] ) return $this->cli_error( __( 'Exports not supported for CLI syncing. Please instead select push or pull instead.', 'wp-sync-db-cli' ) );

do_action( 'wpsdb_cli_before_verify_connection_to_remote_site', $profile );

Expand All @@ -38,16 +38,16 @@ function cli_migration( $profile ) {
if( is_wp_error( $verify_connection_response = $this->verify_cli_response( $response, 'ajax_verify_connection_to_remote_site()' ) ) ) return $verify_connection_response;

$verify_connection_response = apply_filters( 'wpsdb_cli_verify_connection_response', $verify_connection_response );
do_action( 'wpsdb_cli_before_initiate_migration', $profile, $verify_connection_response );
do_action( 'wpsdb_cli_before_initiate_syncing', $profile, $verify_connection_response );

// this request does one last verification check and creates export / backup files (if required)
$_POST['form_data'] = $form_data;
$_POST['stage'] = ( '0' == $profile['create_backup'] ) ? 'migrate' : 'backup';
$_POST = apply_filters( 'wpsdb_cli_initiate_migration_args', $_POST, $profile, $verify_connection_response );
$response = $wpsdb->ajax_initiate_migration();
if( is_wp_error( $initiate_migration_response = $this->verify_cli_response( $response, 'ajax_initiate_migration()' ) ) ) return $initiate_migration_response;
$_POST['stage'] = ( '0' == $profile['create_backup'] ) ? 'sync' : 'backup';
$_POST = apply_filters( 'wpsdb_cli_initiate_syncing_args', $_POST, $profile, $verify_connection_response );
$response = $wpsdb->ajax_initiate_syncing();
if( is_wp_error( $initiate_syncing_response = $this->verify_cli_response( $response, 'ajax_initiate_syncing()' ) ) ) return $initiate_syncing_response;

$initiate_migration_response = apply_filters( 'wpsdb_cli_initiate_migration_response', $initiate_migration_response );
$initiate_syncing_response = apply_filters( 'wpsdb_cli_initiate_syncing_response', $initiate_syncing_response );

// determine which tables to backup (if required)
$tables_to_backup = array();
Expand All @@ -70,34 +70,34 @@ function cli_migration( $profile ) {
}
}
}
$tables_to_backup = apply_filters( 'wpsdb_cli_tables_to_backup', $tables_to_backup, $profile, $verify_connection_response, $initiate_migration_response );
$tables_to_backup = apply_filters( 'wpsdb_cli_tables_to_backup', $tables_to_backup, $profile, $verify_connection_response, $initiate_syncing_response );

// determine which tables to migrate
$tables_to_migrate = array();
// determine which tables to sync
$tables_to_sync = array();
if( 'push' == $profile['action'] ) {
if( 'migrate_only_with_prefix' == $profile['table_migrate_option'] ) {
$tables_to_migrate = $this->get_tables( 'prefix' );
} elseif( 'migrate_select' == $profile['table_migrate_option'] ) {
$tables_to_migrate = array_intersect( $profile['select_tables'], $this->get_tables() );
if( 'sync_only_with_prefix' == $profile['table_sync_option'] ) {
$tables_to_sync = $this->get_tables( 'prefix' );
} elseif( 'sync_select' == $profile['table_sync_option'] ) {
$tables_to_sync = array_intersect( $profile['select_tables'], $this->get_tables() );
}
} elseif( 'pull' == $profile['action'] ) {
if( 'migrate_only_with_prefix' == $profile['table_migrate_option'] ) {
$tables_to_migrate = $verify_connection_response['prefixed_tables'];
} elseif( 'migrate_select' == $profile['table_migrate_option'] ) {
$tables_to_migrate = array_intersect( $profile['select_tables'], $verify_connection_response['tables'] );
if( 'sync_only_with_prefix' == $profile['table_sync_option'] ) {
$tables_to_sync = $verify_connection_response['prefixed_tables'];
} elseif( 'sync_select' == $profile['table_sync_option'] ) {
$tables_to_sync = array_intersect( $profile['select_tables'], $verify_connection_response['tables'] );
}
}
$tables_to_migrate = apply_filters( 'wpsdb_cli_tables_to_migrate', $tables_to_migrate, $profile, $verify_connection_response, $initiate_migration_response );
$tables_to_sync = apply_filters( 'wpsdb_cli_tables_to_sync', $tables_to_sync, $profile, $verify_connection_response, $initiate_syncing_response );

$_POST['dump_filename'] = $initiate_migration_response['dump_filename'];
$_POST['dump_filename'] = $initiate_syncing_response['dump_filename'];
$_POST['gzip'] = ( '1' == $verify_connection_response['gzip'] ) ? 1 : 0;
$_POST['bottleneck'] = $verify_connection_response['bottleneck'];
$_POST['prefix'] = $verify_connection_response['prefix'];

$tables_to_process = ( 'backup' == $_POST['stage'] ) ? $tables_to_backup : $tables_to_migrate;
$tables_to_process = ( 'backup' == $_POST['stage'] ) ? $tables_to_backup : $tables_to_sync;
$stage_interator = ( 'backup' == $_POST['stage'] ) ? 1 : 2;

do_action( 'wpsdb_cli_before_migrate_tables', $profile, $verify_connection_response, $initiate_migration_response );
do_action( 'wpsdb_cli_before_sync_tables', $profile, $verify_connection_response, $initiate_syncing_response );

do {
foreach( $tables_to_process as $key => $table ) {
Expand All @@ -112,36 +112,36 @@ function cli_migration( $profile ) {

$_POST['current_row'] = $current_row;
$_POST['primary_keys'] = $primary_keys;
$_POST = apply_filters( 'wpsdb_cli_migrate_table_args', $_POST, $profile, $verify_connection_response, $initiate_migration_response );
$response = $wpsdb->ajax_migrate_table();
if( is_wp_error( $migrate_table_response = $this->verify_cli_response( $response, 'ajax_migrate_table()' ) ) ) return $migrate_table_response;
$migrate_table_response = apply_filters( 'wpsdb_cli_migrate_table_response', $migrate_table_response, $_POST, $profile, $verify_connection_response, $initiate_migration_response );
$_POST = apply_filters( 'wpsdb_cli_sync_table_args', $_POST, $profile, $verify_connection_response, $initiate_syncing_response );
$response = $wpsdb->ajax_sync_table();
if( is_wp_error( $sync_table_response = $this->verify_cli_response( $response, 'ajax_sync_table()' ) ) ) return $sync_table_response;
$sync_table_response = apply_filters( 'wpsdb_cli_sync_table_response', $sync_table_response, $_POST, $profile, $verify_connection_response, $initiate_syncing_response );

$current_row = $migrate_table_response['current_row'];
$primary_keys = $migrate_table_response['primary_keys'];
$current_row = $sync_table_response['current_row'];
$primary_keys = $sync_table_response['primary_keys'];

} while ( -1 != $current_row );
}
++$stage_interator;
$_POST['stage'] = 'migrate';
$tables_to_process = $tables_to_migrate;
$_POST['stage'] = 'sync';
$tables_to_process = $tables_to_sync;

} while ( $stage_interator < 3 );

do_action( 'wpsdb_cli_before_finalize_migration', $profile, $verify_connection_response, $initiate_migration_response );
do_action( 'wpsdb_cli_before_finalize_syncing', $profile, $verify_connection_response, $initiate_syncing_response );

$finalize_migration_response = apply_filters( 'wpsdb_cli_finalize_migration', true, $profile, $verify_connection_response, $initiate_migration_response );
if( is_wp_error( $finalize_migration_response ) ) return $finalize_migration_response;
$finalize_syncing_response = apply_filters( 'wpsdb_cli_finalize_syncing', true, $profile, $verify_connection_response, $initiate_syncing_response );
if( is_wp_error( $finalize_syncing_response ) ) return $finalize_syncing_response;

$_POST['tables'] = implode( ',', $tables_to_process );
$_POST['temp_prefix'] = $verify_connection_response['temp_prefix'];
$_POST = apply_filters( 'wpsdb_cli_finalize_migration_args', $_POST, $profile, $verify_connection_response, $initiate_migration_response );
$_POST = apply_filters( 'wpsdb_cli_finalize_syncing_args', $_POST, $profile, $verify_connection_response, $initiate_syncing_response );
// don't send redundant POST variables
$_POST = $this->filter_post_elements( $_POST, array( 'action', 'intent', 'url', 'key', 'form_data', 'prefix', 'type', 'location', 'tables', 'temp_prefix' ) );
$response = trim( $wpsdb->ajax_finalize_migration() );
$response = trim( $wpsdb->ajax_finalize_syncing() );
if( ! empty( $response ) ) return $this->cli_error( $response );

do_action( 'wpsdb_cli_after_finalize_migration', $profile, $verify_connection_response, $initiate_migration_response );
do_action( 'wpsdb_cli_after_finalize_syncing', $profile, $verify_connection_response, $initiate_syncing_response );

return true;
}
Expand Down
50 changes: 0 additions & 50 deletions languages/wp-sync-db-cli-en.pot

This file was deleted.

75 changes: 75 additions & 0 deletions languages/wp-sync-db-cli.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Loco Gettext template
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: WP Sync DB CLI\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-21 13:55+0000\n"
"POT-Revision-Date: Sat Sep 24 2016 12:19:01 GMT+0200 (W. Europe Standard "
"Time)\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: \n"
"Language: \n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Generator: Loco - https://localise.biz/\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SearchPath-0: ..\n"
"X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
"__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
"_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
"esc_attr__:1;esc_html__:1;esc_attr_e:1;esc_html_e:1;esc_attr_x:1,2c;"
"esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2"

#. Name of the plugin
msgid "WP Sync DB CLI"
msgstr ""

#. Description of the plugin
msgid ""
"An extension to WP Sync DB, allows you to execute syncing using a function "
"call or via WP-CLI"
msgstr ""

#. Author of the plugin
msgid "Sean Lang"
msgstr ""

#. Author URI of the plugin
msgid "http://slang.cx"
msgstr ""

#: ../wp-sync-db-cli.php:35
msgid "WP Sync DB CLI class not available"
msgstr ""

#: ../class/command.php:30
msgid "Syncing successful."
msgstr ""

#: ../class/wpsdb-cli.php:17
msgid "Please update WP Sync DB."
msgstr ""

#: ../class/wpsdb-cli.php:18
msgid "Profile ID missing."
msgstr ""

#: ../class/wpsdb-cli.php:19
msgid "Profile ID not found."
msgstr ""

#: ../class/wpsdb-cli.php:28
msgid ""
"Exports not supported for CLI syncing. Please instead select push or pull "
"instead."
msgstr ""

#: ../class/wpsdb-cli.php:156
#, php-format
msgid "%1$s was expecting a JSON response, instead we received: %2$s"
msgstr ""
8 changes: 4 additions & 4 deletions wp-sync-db-cli.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/*
Plugin Name: WP Sync DB CLI
GitHub Plugin URI: slang800/wp-sync-db-cli
Description: An extension to WP Sync DB, allows you to execute migrations using a function call or via WP-CLI
Description: An extension to WP Sync DB, allows you to execute syncing using a function call or via WP-CLI
Author: Sean Lang
Version: 1.0b1
Author URI: http://slang.cx
GitHub Plugin URI: wp-sync-db/wp-sync-db-cli
Network: True
*/

Expand All @@ -29,10 +29,10 @@ function wp_sync_db_cli_loaded() {
}
add_action( 'plugins_loaded', 'wp_sync_db_cli_loaded', 20 );

function wpsdb_migrate( $profile ) {
function wpsdb_sync( $profile ) {
global $wpsdb_cli;
if( empty( $wpsdb_cli ) ) {
return new WP_Error( 'wpsdb_cli_error', __( 'WP Sync DB CLI class not available', 'wp-sync-db-cli' ) );
}
return $wpsdb_cli->cli_migration( $profile );
return $wpsdb_cli->cli_syncing( $profile );
}