-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpcampus-slide40.php
61 lines (60 loc) · 1.39 KB
/
wpcampus-slide40.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
<?php
/**
* Plugin Name: wpcampus
* Plugin URI: https://gilzow.com/wpcampus
* Description: Greet WPCampus attendees
* Author: Paul Gilzow
* Author URI: https://gilzow.com/
* Text Domain: wpcampus
* Domain Path: /languages
* Version: 0.1.0
*
* @package WPCAMPUS
*/
if ( ! defined('WP_CLI') ) {
return;
}
/**
* Welcomes a user to WPCampus 2023
*
* ## OPTIONS
* [<name>...]
* : Name of the persons to greet
* ---
* default: John
* options:
* - John
* - Paul
* - George
* - Ringo
* ---
*
* [--subject=<subject>]
* : What topic sessions interests this person
*
* ## EXAMPLES
*
* # Welcome a user
* $ wp wpcampus --subject=InfoSec
* Welcome to WPCampus, John!!!
* You are interested in sessions on InfoSec.
*
* # Welcome several users
* $ wp wpcampus Paul Ringo George
* Welcome to WPCampus, Paul, Ringo, George!!!
*/
WP_CLI::add_command('wpcampus',function ($args, $assoc_args){
$msg = "Welcome to WPCampus";
$last = array_key_last($args);
foreach ($args as $index => $name) {
$msg .= ', ';
if ($index === $last && 1 !== count($args)) {
$msg .= 'and ';
}
$msg .= $name;
}
echo $msg,'!!!',PHP_EOL;
if(isset($assoc_args['subject'])) {
echo "You are interested in sessions on ${assoc_args['subject']}", PHP_EOL;
}
});