Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
25358b92
Verified
Commit
25358b92
authored
Dec 05, 2016
by
Erick Hitter
Browse files
Initial setup for plugin's native CLI commands
Includes basics of a purge command
parent
b75aa9f0
Changes
3
Show whitespace changes
Inline
Side-by-side
includes/class-main.php
View file @
25358b92
...
...
@@ -22,6 +22,7 @@ class Main extends Singleton {
require
__DIR__
.
'/class-internal-events.php'
;
require
__DIR__
.
'/class-rest-api.php'
;
require
__DIR__
.
'/functions.php'
;
require
__DIR__
.
'/wp-cli.php'
;
// Block normal cron execution
$this
->
set_constants
();
...
...
includes/wp-cli.php
0 → 100644
View file @
25358b92
<?php
namespace
Automattic\WP\Cron_Control
;
if
(
defined
(
'\WP_CLI'
)
&&
\
WP_CLI
)
{
require
__DIR__
.
'/wp-cli/class-one-time-fixers.php'
;
}
includes/wp-cli/class-one-time-fixers.php
0 → 100644
View file @
25358b92
<?php
namespace
Automattic\WP\Cron_Control\CLI
;
class
One_Time_Fixers
extends
\
WPCOM_VIP_CLI_Command
{
/**
* Remove corrupt Cron Control data resulting from initial plugin deployment
*
* eg.: `wp --allow-root cron-control remove-all-plugin-data`
*
* @subcommand remove-all-plugin-data
*/
public
function
purge
(
$args
,
$assoc_args
)
{
\
WP_CLI
::
line
(
'CRON CONTROL'
);
\
WP_CLI
::
line
(
"This process will remove all CPT data for the Cron Control plugin
\n
"
);
global
$wpdb
;
$items
=
$wpdb
->
get_results
(
$wpdb
->
prepare
(
"SELECT ID, post_title FROM
{
$wpdb
->
posts
}
WHERE post_type = %s LIMIT 250;"
,
'a8c_cron_ctrl_event'
)
);
if
(
is_array
(
$items
)
&&
!
empty
(
$items
)
)
{
foreach
(
$items
as
$item
)
{
\
WP_CLI
::
line
(
"
{
$item
->
ID
}
, `
{
$item
->
post_title
}
`"
);
if
(
isset
(
$assoc_args
[
'dry-run'
]
)
&&
'false'
===
$assoc_args
[
'dry-run'
]
)
{
\
WP_CLI
::
line
(
'Removing...'
);
wp_delete_post
(
$item
->
ID
,
true
);
\
WP_CLI
::
line
(
''
);
}
}
}
if
(
isset
(
$assoc_args
[
'dry-run'
]
)
&&
'false'
===
$assoc_args
[
'dry-run'
]
)
{
wp_cache_delete
(
'a8c_cron_ctrl_option'
);
\
WP_CLI
::
line
(
"Cleared Cron Control cache
\n
"
);
}
\
WP_CLI
::
line
(
"
\n
All done"
);
}
}
\
WP_CLI
::
add_command
(
'cron-control'
,
'Automattic\WP\Cron_Control\CLI\One_Time_Fixers'
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment