Skip to content
Snippets Groups Projects
Commit 5287b0e0 authored by Erick Hitter's avatar Erick Hitter
Browse files

Provide way to limit commands that can be scheduled

parent f7c9097f
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
<?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',
);
}
<?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';
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment