PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.1.0
GiveWP – Donation Plugin and Fundraising Platform v4.1.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 / Commands / PageSeedCommand.php

PageSeedCommand.php in GiveWP – Donation Plugin and Fundraising Platform 4.1.0, at src/TestData/Commands/PageSeedCommand.php

60 lines 1.2 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\Commands;
4
5 use Give\TestData\Factories\PageFactory;
6 use WP_CLI;
7
8 /**
9 * Class DonorSeedCommand
10 * @package Give\TestData\Commands
11 *
12 * A WP-CLI command for seeding pages.
13 */
14 class PageSeedCommand
15 {
16
17 /**
18 * @var PageFactory
19 */
20 private $pageFactory;
21
22 public function __construct(PageFactory $pageFactory)
23 {
24 $this->pageFactory = $pageFactory;
25 }
26
27 /**
28 * Generates GiveWP demonstration page with all GiveWP shortcodes included
29 *
30 * [--preview=<preview>]
31 * : Preview generated data
32 * default: false
33 *
34 * ## EXAMPLES
35 *
36 * wp give test-demonstration-page --preview=true
37 *
38 * @when after_wp_load
39 */
40 public function __invoke($args, $assocArgs)
41 {
42 $preview = WP_CLI\Utils\get_flag_value($assocArgs, 'preview', $default = false);
43
44 $page = $this->pageFactory->definition();
45
46 if ($preview) {
47 WP_CLI\Utils\format_items(
48 'table',
49 [$page],
50 array_keys($page)
51 );
52 } else {
53 $progress = WP_CLI\Utils\make_progress_bar('Generating demonstration page', 1);
54
55 wp_insert_post($page);
56 $progress->finish();
57 }
58 }
59 }
60