diff --git a/Gruntfile.js b/Gruntfile.js index 783c46334479722ef9618d56353e51e5197589bc..bd667a02b731bac7ce911b69bac88932f4e6042a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,7 @@ module.exports = function( grunt ) { addtextdomain: { options: { - textdomain: 'wp-cli-via-cron-control', + textdomain: 'wp-cli-cron-control-offload', }, update_all_domains: { options: { @@ -31,8 +31,8 @@ module.exports = function( grunt ) { target: { options: { domainPath: '/languages', - mainFile: 'wp-cli-via-cron-control.php', - potFilename: 'wp-cli-via-cron-control.pot', + mainFile: 'wp-cli-cron-control-offload.php', + potFilename: 'wp-cli-cron-control-offload.pot', potHeaders: { poedit: true, 'x-poedit-keywordslist': true diff --git a/includes/utils.php b/includes/utils.php new file mode 100644 index 0000000000000000000000000000000000000000..0e9e3c748c3cc1b3883662a146db403ccbbb56ed --- /dev/null +++ b/includes/utils.php @@ -0,0 +1,41 @@ +<?php + +namespace Automattic\WP\WP_CLI_Cron_Control_Offload; + +/** + * Check if subcommand is allowed + * + * @param string $subcommand + * @return bool + */ +function is_subcommand_allowed( $subcommand ) { + return in_array( $subcommand, get_subcommand_whitelist(), true ) && ! in_array( $subcommand, get_subcommand_blacklist(), true ); +} + +/** + * Most commands must be whitelisted + * + * @return array + */ +function get_subcommand_whitelist() { + return array(); +} + +/** + * Certain commands should never be supported + * + * @return array + */ +function get_subcommand_blacklist() { + return array( + 'cli', + 'config', + 'core', + 'cron', + 'db', + 'eval', + 'eval-file', + 'scaffold', + 'server', + ); +} diff --git a/wp-cli-cron-control-offload.php b/wp-cli-cron-control-offload.php index 649e8612a2c645896c2b1f78665cfb3bde98c2aa..ce7c3b2429497e146bc76727833f2ebe566b5ff2 100644 --- a/wp-cli-cron-control-offload.php +++ b/wp-cli-cron-control-offload.php @@ -1,11 +1,11 @@ <?php /** - * Plugin Name: WP-CLI Via Cron Control + * Plugin Name: WP-CLI Cron Control Offload * Plugin URI: https://automattic.com/ * Description: Schedule WP-CLI tasks to run via Cron Control * Author: Erick Hitter, Automattic * Author URI: https://vip.wordpress.com/ - * Text Domain: wp-cli-via-cron-control + * Text Domain: wp-cli-cron-control-offload * Domain Path: /languages * Version: 0.1.0 * @@ -16,5 +16,6 @@ namespace Automattic\WP\WP_CLI_Cron_Control_Offload; const ACTION = 'wp_cli_cron_control_offload'; +require_once __DIR__ . '/includes/utils.php'; require_once __DIR__ . '/includes/schedule.php'; require_once __DIR__ . '/includes/run.php';