| Server IP : 35.201.19.92 / Your IP : 216.73.216.212 Web Server : nginx System : Linux pod-200961 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200098 ( 200098) PHP Version : 8.2.34 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/questfamilyday/wp-content/plugins/wp-seopress-pro/src/CommandLine/ |
Upload File : |
<?php
namespace SEOPressPro\CommandLine;
use WP_CLI_Command;
use WP_CLI;
class AI extends WP_CLI_Command {
/**
* This command generate title with AI.
*
* ## OPTIONS
*
* [--id=<value>]
* : List of Post ID separated by comma.
*
* [--meta=<value>]
* : Which meta to generate. Optional. Default: empty value for title + meta description
*
* [--language=<value>]
* : Which language to use to generate the metadata. Optional. Default: en_US
*
* [--autosave=<value>]
* : Boolean. Optional. Default: true
*
* ## EXAMPLES
*
* wp seopress ai metadata --id=1 --meta=title --language=en_US
*/
public function metadata( $args, $assoc_args ) {
if ( is_null( seopress_pro_get_service( 'Completions' ) ) ) {
WP_CLI::line( "SEOPress is not up to date. Please update SEOPress to the latest version." );
return;
}
$post_ids = isset( $assoc_args['id'] ) ? explode( ',', $assoc_args['id'] ) : null;
if ( is_null( $post_ids ) || empty( $post_ids ) ) {
WP_CLI::line( "Post IDs are missing from the arguments." );
return;
}
$meta = isset( $assoc_args['meta'] ) ? $assoc_args['meta'] : '';
$language = isset( $assoc_args['language'] ) ? $assoc_args['language'] : 'en_US';
$autosave = isset( $assoc_args['autosave'] ) ? $assoc_args['autosave'] : true;
foreach ( $post_ids as $post_id ) {
$data = seopress_pro_get_service( 'Completions' )->generateTitlesDesc( $post_id, $meta, $language, $autosave );
$data_str = wp_json_encode( $data, JSON_PRETTY_PRINT );
WP_CLI::line( 'Result for Post ID ' . $post_id . ':' );
WP_CLI::line( $data_str );
}
}
/**
* This command generate alt text with AI.
*
* ## OPTIONS
*
* [--id=<value>]
* : List of Attachment ID separated by comma.
*
* [--autosave=<value>]
* : Boolean. Optional. Default: true
*
* [--language=<value>]
* : Which language to use to generate the alternative text. Optional. Default: en_US
*
* [--update_empty_alt_text=<value>]
* : Boolean. Optional. Default: true
*
* ## EXAMPLES
*
* wp seopress ai alt_text --id=1 --language=en_US
*/
public function alt_text( $args, $assoc_args ) {
if ( is_null( seopress_pro_get_service( 'Completions' ) ) ) {
WP_CLI::line( "SEOPress is not up to date. Please update SEOPress to the latest version." );
return;
}
$post_ids = isset( $assoc_args['id'] ) ? explode( ',', $assoc_args['id'] ) : null;
if ( is_null( $post_ids ) || empty( $post_ids ) ) {
WP_CLI::line( "Post IDs are missing from the arguments." );
return;
}
$language = isset( $assoc_args['language'] ) ? $assoc_args['language'] : 'en_US';
$autosave = isset( $assoc_args['autosave'] ) ? $assoc_args['autosave'] : true;
$update_empty_alt_text = isset( $assoc_args['update_empty_alt_text'] ) ? $assoc_args['update_empty_alt_text'] : true;
foreach ( $post_ids as $post_id ) {
$data = seopress_pro_get_service( 'Completions' )->generateImgAltText( $post_id, $autosave, $language, $update_empty_alt_text );
$data_str = wp_json_encode( $data, JSON_PRETTY_PRINT );
WP_CLI::line( 'Result for Attachment ID ' . $post_id . ':' );
WP_CLI::line( $data_str );
}
}
}