-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-cli-amplifier.php
64 lines (57 loc) · 1.66 KB
/
wp-cli-amplifier.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* Plugin Name: Cli Amplifier
* Description: Useful collection of extended wp cli custom commands to help with various tasks that will help with maintaining the website
* Version: 1.0
* Author: Aleksej Vukomanovic
* License: GPLv2 or later
*/
if (!defined('ABSPATH')) {
exit;
}
if ( ! defined( 'WCA_COMMANDS' ) ) {
define( 'WCA_COMMANDS', 'commands/' );
}
// commands list
$commands = [
'change-author',
'change-post-status',
'delete-trashed-posts',
'regenerate-featured-images',
'remove-shortcode-from-content',
'update-image-alt-tags',
'update-post-slugs',
];
/**
* Include file for a custom wp cli command
*
* @param $command_name string command file name
*/
function wca_include_command( $command_name )
{
require_once WCA_COMMANDS . "$command_name.php";
}
/**
* include the array of command names
*
* @param $comamnds array
*/
function wca_include_commands( $commands )
{
foreach ( $commands as $command )
{
wca_include_command( $command );
}
}
if (defined('WP_CLI') && WP_CLI) {
// include all commands php files
wca_include_commands( $commands );
// register commands
WP_CLI::add_command( 'ca', 'Change_Author_WP_CLI_Command' );
WP_CLI::add_command( 'ppd', 'PPD_WP_CLI_Command' );
WP_CLI::add_command( 'dtp', 'Delete_Trashed_Posts_WP_CLI_Command' );
WP_CLI::add_command( 'brfi', 'Bulk_Regenerate_Featured_Images_WP_CLI_Command' );
WP_CLI::add_command( 'brsc', 'Bulk_Remove_Shortcodes_WP_CLI_Command' );
WP_CLI::add_command( 'buiat', 'Bulk_Update_Empty_Image_Alt_Tags_WP_CLI_Command' );
WP_CLI::add_command( 'bus', 'Bulk_Update_Post_Slugs_WP_CLI_Command' );
}