PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
4.16.8.1 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 All 254 releases
give / src / TestData / Addons / RecurringDonations / PageSeedCommand.php

PageSeedCommand.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/TestData/Addons/RecurringDonations/PageSeedCommand.php

59 lines 1.3 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 recurring donation's demonstration page.
12 */
13 class PageSeedCommand
14 {
15
16 /**
17 * @var PageFactory
18 */
19 private $pageFactory;
20
21 public function __construct(PageFactory $pageFactory)
22 {
23 $this->pageFactory = $pageFactory;
24 }
25
26 /**
27 * Generates Recurring Donation's demonstration page
28 *
29 * [--preview=<preview>]
30 * : Preview generated data
31 * default: false
32 *
33 * ## EXAMPLES
34 *
35 * wp give recurring-demonstration-page --preview=true
36 *
37 * @when after_wp_load
38 */
39 public function __invoke($args, $assocArgs)
40 {
41 $preview = WP_CLI\Utils\get_flag_value($assocArgs, 'preview', $default = false);
42
43 $page = $this->pageFactory->definition();
44
45 if ($preview) {
46 WP_CLI\Utils\format_items(
47 'table',
48 [$page],
49 array_keys($page)
50 );
51 } else {
52 $progress = WP_CLI\Utils\make_progress_bar('Generating Recurring Donations demonstration page', 1);
53
54 wp_insert_post($page);
55 $progress->finish();
56 }
57 }
58 }
59