Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit45df398

Browse files
committed
Print out token on command line programmatically
1 parentb98a5a4 commit45df398

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

‎class/command.php‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ public function create_profile( $args, $assoc_args ) {
115115
return;
116116
}
117117

118+
/**
119+
* Echo out the DB token. For use in automation.
120+
*
121+
* ## EXAMPLES
122+
*
123+
* wp wpsdb connection-info
124+
*
125+
* @since 1.0
126+
* @subcommand connection-info
127+
*/
128+
publicfunctionconnection_info($args,$assoc_args ) {
129+
$result =wpsdb_cli_connection_info();
130+
131+
if ($result ) {
132+
WP_CLI::log($result );
133+
return;
134+
}
135+
136+
WP_CLI::warning($result->get_error_message() );
137+
return;
138+
}
139+
118140
}
119141

120142
WP_CLI::add_command('wpsdb','WPSDBCLI' );

‎class/wpsdb-cli.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ function keys_from_kebab_case_to_snake_case( $array ) {
4747
return$result;
4848
}
4949

50+
functioncli_connection_info( ) {
51+
$wpsdb_settings =get_option('wpsdb_settings' );
52+
53+
if ($wpsdb_settings['key'] ) {
54+
return$wpsdb_settings['key'];
55+
}else {
56+
return$this->cli_error(__('Key could not be found in Migrate DB - this is not expected.','wp-sync-db-cli' ) );
57+
}
58+
}
59+
5060
functioncli_create_profile($name,$assoc_args ) {
5161
$wpsdb_settings =get_option('wpsdb_settings' );
5262

‎wp-sync-db-cli.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ function wpsdb_migrate( $profile ) {
3737
return$wpsdb_cli->cli_migration($profile );
3838
}
3939

40+
functionwpsdb_cli_connection_info() {
41+
global$wpsdb_cli;
42+
if(empty($wpsdb_cli ) ) {
43+
returnnewWP_Error('wpsdb_cli_error',__('WP Sync DB CLI class not available','wp-sync-db-cli' ) );
44+
}
45+
return$wpsdb_cli->cli_connection_info();
46+
}
47+
4048
functionwpdsb_create_profile($name,$assoc_args ) {
4149
global$wpsdb_cli;
4250
if(empty($wpsdb_cli ) ) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp