本文整理汇总了PHP中WP_CLI::add_command方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::add_command方法的具体用法?PHP WP_CLI::add_command怎么用?PHP WP_CLI::add_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::add_command方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
add_action('init', array($this, 'maybe_init_integrations'));
if (class_exists('WP_CLI_Command')) {
\WP_CLI::add_command('timber', 'Timber\\Integrations\\Timber_WP_CLI_Command');
}
}
示例2: init
public static function init()
{
add_action('init', array(__CLASS__, 'maybe_init_acftimber'));
if (class_exists('WP_CLI_Command')) {
WP_CLI::add_command('timber', 'Timber_WP_CLI_Command');
}
}
示例3: jetpack_load_custom_css
/**
* Module Name: Custom CSS
* Module Description: Tweak your site’s CSS without modifying your theme.
* Sort Order: 2
* First Introduced: 1.7
* Requires Connection: No
* Auto Activate: Yes
* Module Tags: Appearance
* Feature: Appearance
* Additional Search Queries: css, customize, custom, style, editor, less, sass, preprocessor, font, mobile, appearance, theme, stylesheet
*/
function jetpack_load_custom_css()
{
// If WordPress has the core version of Custom CSS, load our new version.
// @see https://core.trac.wordpress.org/changeset/38829
if (function_exists('wp_get_custom_css')) {
if (!function_exists('wp_update_custom_css_post')) {
wp_die('Please run a SVN up to get the latest version of trunk, or update to at least 4.7 RC1');
}
if (!Jetpack_Options::get_option('custom_css_4.7_migration')) {
include_once dirname(__FILE__) . '/custom-css/migrate-to-core.php';
} else {
if (defined('WP_CLI') && WP_CLI) {
function jetpack_custom_css_undo_data_migration_cli()
{
Jetpack_Options::delete_option('custom_css_4.7_migration');
WP_CLI::success(__('Option deleted, re-migrate via `wp jetpack custom-css migrate`.', 'jetpack'));
}
WP_CLI::add_command('jetpack custom-css undo-migrate', 'jetpack_custom_css_undo_data_migration_cli');
}
}
// TODO: END DELETE THIS
include_once dirname(__FILE__) . '/custom-css/custom-css/preprocessors.php';
include_once dirname(__FILE__) . '/custom-css/custom-css-4.7.php';
return;
}
include_once dirname(__FILE__) . "/custom-css/custom-css.php";
add_action('init', array('Jetpack_Custom_CSS', 'init'));
}
示例4: register_commands
/**
* Registers just a 'list' and 'run' command to the WC CLI
* since we only want to enable certain actions on the system status
* tools endpoints.
*/
public static function register_commands()
{
global $wp_rest_server;
$request = new WP_REST_Request('OPTIONS', '/wc/v1/system_status/tools');
$response = $wp_rest_server->dispatch($request);
$response_data = $response->get_data();
$parent = "wc tool";
$supported_commands = array('list', 'run');
foreach ($supported_commands as $command) {
$synopsis = array();
if ('run' === $command) {
$synopsis[] = array('name' => 'id', 'type' => 'positional', 'description' => __('The id for the resource.', 'woocommerce'), 'optional' => false);
$method = 'update_item';
$route = '/wc/v1/system_status/tools/(?P<id>[\\w-]+)';
} elseif ('list' === $command) {
$synopsis[] = array('name' => 'fields', 'type' => 'assoc', 'description' => __('Limit response to specific fields. Defaults to all fields.', 'woocommerce'), 'optional' => true);
$synopsis[] = array('name' => 'field', 'type' => 'assoc', 'description' => __('Get the value of an individual field.', 'woocommerce'), 'optional' => true);
$synopsis[] = array('name' => 'format', 'type' => 'assoc', 'description' => __('Render response in a particular format.', 'woocommerce'), 'optional' => true, 'default' => 'table', 'options' => array('table', 'json', 'csv', 'ids', 'yaml', 'count', 'headers', 'body', 'envelope'));
$method = 'list_items';
$route = '/wc/v1/system_status/tools';
}
$before_invoke = null;
if (empty($command_args['when']) && WP_CLI::get_config('debug')) {
$before_invoke = function () {
if (!defined('SAVEQUERIES')) {
define('SAVEQUERIES', true);
}
};
}
$rest_command = new WC_CLI_REST_Command('system_status_tool', $route, $response_data['schema']);
WP_CLI::add_command("{$parent} {$command}", array($rest_command, $method), array('synopsis' => $synopsis, 'when' => !empty($command_args['when']) ? $command_args['when'] : '', 'before_invoke' => $before_invoke));
}
}
示例5: __construct
protected function __construct()
{
if (false !== get_transient('_my-wp-backup-activated')) {
delete_transient('_my-wp-backup-activated');
wp_redirect(Admin::get_page_url(''));
}
self::$info = get_file_data(__FILE__, array('name' => 'Plugin Name', 'pluginUri' => 'Plugin URI', 'supportUri' => 'Support URI', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'authorUri' => 'Author URI', 'textDomain' => 'Text Domain', 'domainPath' => 'Domain Path', 'slug' => 'Slug', 'license' => 'License', 'licenseUri' => 'License URI'));
Admin::get_instance();
$options = get_site_option('my-wp-backup-options', Admin::$options);
self::$info['baseDir'] = plugin_dir_path(__FILE__);
self::$info['baseDirUrl'] = plugin_dir_url(__FILE__);
self::$info['backup_dir'] = trailingslashit(ABSPATH) . trailingslashit(ltrim($options['backup_dir'], '/'));
self::$info['root_dir'] = trailingslashit(ABSPATH);
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command('job', new Cli\Job());
\WP_CLI::add_command('backup', new Cli\Backup());
}
add_action('wp_backup_run_job', array(Job::get_instance(), 'cron_run'));
add_action('wp_backup_restore_backup', array(Backup::get_instance(), 'cron_run'));
$version = get_site_option(self::KEY_VERSION);
if (!$version || self::$info['version'] !== $version) {
if ($this->update_options()) {
update_site_option(self::KEY_VERSION, self::$info['version']);
}
}
}
示例6: __construct
/**
* Class constructor
*/
public function __construct()
{
$locate = $this->locate_plugin();
$this->locations = array('plugin' => $locate['plugin_basename'], 'dir' => $locate['dir_path'], 'url' => $locate['dir_url'], 'inc_dir' => $locate['dir_path'] . 'includes/', 'class_dir' => $locate['dir_path'] . 'classes/');
spl_autoload_register(array($this, 'autoload'));
// Load helper functions
require_once $this->locations['inc_dir'] . 'functions.php';
// Load DB helper interface/class
$driver = '\\WP_Stream\\DB';
if (class_exists($driver)) {
$this->db = new DB($this);
}
if (!$this->db) {
wp_die(esc_html__('Stream: Could not load chosen DB driver.', 'stream'), esc_html__('Stream DB Error', 'stream'));
}
// Load languages
add_action('plugins_loaded', array($this, 'i18n'));
// Load logger class
$this->log = apply_filters('wp_stream_log_handler', new Log($this));
// Load settings and connectors after widgets_init and before the default init priority
add_action('init', array($this, 'init'), 9);
// Add frontend indicator
add_action('wp_head', array($this, 'frontend_indicator'));
// Load admin area classes
if (is_admin() || defined('WP_STREAM_DEV_DEBUG') && WP_STREAM_DEV_DEBUG) {
$this->admin = new Admin($this);
$this->install = new Install($this);
}
// Load WP-CLI command
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command(self::WP_CLI_COMMAND, 'WP_Stream\\CLI');
}
}
示例7: initialize_modules
/**
* @throws Exception
*/
private function initialize_modules()
{
new Hello_Kushimoto_Dashboard_Widget($this->speaker);
new Hello_Kushimoto_Admin_Notices($this->speaker);
new Hello_Kushimoto_Shortcode($this->speaker);
if (defined('WP_CLI') and WP_CLI) {
Hello_Kushimoto_CLI::set_speaker($this->speaker);
WP_CLI::add_command('hello-kushimoto', 'Hello_Kushimoto_CLI');
}
}
示例8: wpcli
/**
* A loader for the WP:CLI class
*/
public function wpcli()
{
if ($this->wpcli) {
return TRUE;
}
require_once __DIR__ . '/class-go-newrelic-wpcli.php';
// declare the class to WP:CLI
WP_CLI::add_command('go-newrelic', 'SMC_NewRelic_Wpcli');
$this->wpcli = TRUE;
}
示例9: run
function run()
{
if (class_exists('WP_CLI_Command')) {
//make sure wp-cli is present
//Load temporary whitelist command
if (!class_exists('ITSEC_WP_CLI_Command_ITSEC')) {
require dirname(__FILE__) . '/class-itsec-wp-cli-command-itsec.php';
WP_CLI::add_command('itsec', 'ITSEC_WP_CLI_Command_ITSEC');
}
}
}
示例10: __construct
/**
* @param Hello_Kushimoto_Speaker $speaker
*/
public function __construct(Hello_Kushimoto_Speaker $speaker)
{
$this->speaker = $speaker;
load_plugin_textdomain('hello-kushimoto', false, plugin_basename(HELLO_KUSHIMOTO_DIR) . '/languages');
new Hello_Kushimoto_Dashboard_Widget($speaker);
new Hello_Kushimoto_Admin_Notices($speaker);
new Hello_Kushimoto_Shortcode($speaker);
if (defined('WP_CLI') and WP_CLI) {
Hello_Kushimoto_CLI::set_speaker($speaker);
WP_CLI::add_command('hello-kushimoto', 'Hello_Kushimoto_CLI');
}
}
示例11: on_load
public function on_load()
{
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command('parser', __NAMESPACE__ . '\\Command');
}
$this->relationships = new Relationships();
add_action('init', array($this, 'register_post_types'), 11);
add_action('init', array($this, 'register_taxonomies'), 11);
add_filter('wp_parser_get_arguments', array($this, 'make_args_safe'));
add_filter('wp_parser_return_type', array($this, 'humanize_separator'));
add_filter('post_type_link', array($this, 'method_permalink'), 10, 2);
}
示例12: init
public function init()
{
$meta = new Option(self::META_KEY);
$queue = new Option(self::QUEUE_KEY);
$generator = new Sri_Generator(self::CRON_HOOK, $meta, $queue);
$injector = new Sri_Injector($meta, $queue);
$registrar = new Registrar(['jquery' => ['footer' => true], 'jquery-core' => ['footer' => true, 'src' => 'https://code.jquery.com/jquery-%%VERSION%%.min.js'], 'jquery-migrate' => ['footer' => true, 'src' => 'https://code.jquery.com/jquery-migrate-%%VERSION%%.min.js']]);
$features = [$meta, $queue, $generator, $injector, $registrar];
foreach ($features as $feature) {
$feature->init();
}
if (defined('WP_CLI') && WP_CLI) {
\WP_CLI::add_command('sri', new Sri_Command($meta, $queue));
}
}
示例13: __construct
/**
* Class constructor
*/
private function __construct()
{
$this->version = '2.0.2';
$this->basename = plugin_basename(__FILE__);
$this->base_dir = plugin_dir_path(__FILE__);
$this->assets_url = plugin_dir_url(__FILE__) . 'assets/';
$this->page_slug = 'wpem';
$this->api_url = 'http://demo.wpeasymode.com/';
if (defined('WP_CLI') && WP_CLI) {
$composer_autoloader = __DIR__ . '/vendor/autoload.php';
if (file_exists($composer_autoloader)) {
// This is for enabling codeception
require_once $composer_autoloader;
}
\WP_CLI::add_command('easy-mode', sprintf('\\%s\\CLI', __NAMESPACE__));
return;
}
if (!is_admin()) {
return;
}
if (!$this->is_fresh_wp()) {
if (!$this->is_done()) {
add_filter('wpem_deactivate_plugins_on_quit', '__return_false');
wpem_quit();
}
return;
}
add_action('plugins_loaded', [$this, 'i18n']);
// Always allow external HTTP requests to our API
add_filter('http_request_host_is_external', function ($allow, $host, $url) {
$api_url = parse_url($this->api_url);
return $api_url['host'] === $host ? true : $allow;
}, 10, 3);
// Enqueue customizer if we are on this screen
add_action('load-customize.php', function () {
if (filter_input(INPUT_GET, static::SCREEN_ID)) {
new Customizer();
}
});
if ($this->is_done()) {
$this->self_destruct();
$this->deactivate();
add_action('init', [$this, 'maybe_redirect']);
return;
}
define('WPEM_DOING_STEPS', true);
$this->admin = new Admin();
}
示例14: __construct
/**
* Constructor
*/
public function __construct()
{
require_once 'say-what-settings.php';
$this->settings_instance = new SayWhatSettings();
if (is_admin()) {
require_once 'say-what-admin.php';
$this->admin_instance = new SayWhatAdmin($this->settings_instance);
}
require_once 'say-what-frontend.php';
$this->frontend_instance = new SayWhatFrontend($this->settings_instance);
if (defined('WP_CLI') && WP_CLI) {
require_once 'say-what-cli.class.php';
WP_CLI::add_command('say-what', 'SayWhatCli');
}
add_action('init', array($this, 'init'));
add_action('admin_init', array($this, 'admin_init'));
}
示例15: __construct
/**
* Called at load time, hooks into WP core
*/
public function __construct()
{
self::$instance =& $this;
if (is_admin()) {
$this->admin = new WordPress_GitHub_Sync_Admin();
}
$this->controller = new WordPress_GitHub_Sync_Controller();
register_activation_hook(__FILE__, array($this, 'activate'));
add_action('admin_notices', array($this, 'activation_notice'));
add_action('init', array(&$this, 'l10n'));
add_action('save_post', array(&$this, 'save_post_callback'));
add_action('delete_post', array(&$this, 'delete_post_callback'));
add_action('wp_ajax_nopriv_wpghs_sync_request', array(&$this, 'pull_posts'));
add_action('wpghs_export', array(&$this->controller, 'export_all'));
add_action('wpghs_import', array(&$this->controller, 'import_master'));
if (defined('WP_CLI') && WP_CLI) {
WP_CLI::add_command('wpghs', 'WordPress_GitHub_Sync_CLI');
}
}