PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.17.0
GiveWP – Donation Plugin and Fundraising Platform v2.17.0
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / TestData / Addons / RecurringDonations / PageSeedCommand.php
PageSeedCommand.php
56 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\TestData\Addons\RecurringDonations;
4
5 use WP_CLI;
6
7 /**
8 * Class PageSeedCommand
9 * @package Give\TestData\RecurringDonations
10 *
11 * A WP-CLI command for seeding recuring donations demonstration page.
12 */
13 class PageSeedCommand {
14
15 /**
16 * @var PageFactory
17 */
18 private $pageFactory;
19
20 public function __construct( PageFactory $pageFactory ) {
21 $this->pageFactory = $pageFactory;
22 }
23
24 /**
25 * Generates Recurring Donations demonstartion page
26 *
27 * [--preview=<preview>]
28 * : Preview generated data
29 * default: false
30 *
31 * ## EXAMPLES
32 *
33 * wp give recurring-demonstration-page --preview=true
34 *
35 * @when after_wp_load
36 */
37 public function __invoke( $args, $assocArgs ) {
38 $preview = WP_CLI\Utils\get_flag_value( $assocArgs, 'preview', $default = false );
39
40 $page = $this->pageFactory->definition();
41
42 if ( $preview ) {
43 WP_CLI\Utils\format_items(
44 'table',
45 [ $page ],
46 array_keys( $page )
47 );
48 } else {
49 $progress = WP_CLI\Utils\make_progress_bar( 'Generating Recurring Donations demonstration page', 1 );
50
51 wp_insert_post( $page );
52 $progress->finish();
53 }
54 }
55 }
56