PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.19.6
GiveWP – Donation Plugin and Fundraising Platform v2.19.6
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 / Factories / PageFactory.php
PageFactory.php
69 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\Factories;
4
5 use Give\TestData\Framework\Factory;
6
7 /**
8 * Class PageFactory
9 * @package Give\TestData\Factories
10 */
11 class PageFactory extends Factory
12 {
13
14 /**
15 * Donor definition
16 *
17 * @since 1.0.0
18 * @return array
19 */
20 public function definition()
21 {
22 return [
23 'post_title' => 'GiveWP Demonstration page',
24 'post_content' => $this->getContent(),
25 'post_status' => 'publish',
26 'post_author' => $this->randomAuthor(),
27 'post_type' => 'page',
28 ];
29 }
30
31 /**
32 * Page content
33 *
34 * @since 1.0.0
35 * @return string
36 */
37 public function getContent()
38 {
39 $giveShortcodes = $this->getGiveShortcodes();
40
41 $content = '';
42
43 foreach ($giveShortcodes as $shortcode) {
44 $content .= "<h3>[{$shortcode}]</h3>";
45 $content .= "[{$shortcode}]";
46 }
47
48 return $content;
49 }
50
51 /**
52 * Get GiveWP shortcodes
53 *
54 * @return array
55 */
56 private function getGiveShortcodes()
57 {
58 $shortcodes = [];
59
60 foreach ($GLOBALS['shortcode_tags'] as $shortcode => $action) {
61 if (false !== strpos($shortcode, 'give_')) {
62 $shortcodes[] = $shortcode;
63 }
64 }
65
66 return $shortcodes;
67 }
68 }
69