DonationFactory.php
5 years ago
DonationFormFactory.php
5 years ago
DonorFactory.php
5 years ago
LogFactory.php
5 years ago
PageFactory.php
5 years ago
RevenueFactory.php
5 years ago
PageFactory.php
68 lines
| 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 | * Donor definition |
| 15 | * |
| 16 | * @return array |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | public function definition() { |
| 20 | return [ |
| 21 | 'post_title' => 'GiveWP Demonstration page', |
| 22 | 'post_content' => $this->getContent(), |
| 23 | 'post_status' => 'publish', |
| 24 | 'post_author' => $this->randomAuthor(), |
| 25 | 'post_type' => 'page', |
| 26 | ]; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Page content |
| 31 | * |
| 32 | * @return string |
| 33 | * @since 1.0.0 |
| 34 | */ |
| 35 | public function getContent() { |
| 36 | |
| 37 | $giveShortcodes = $this->getGiveShortcodes(); |
| 38 | |
| 39 | $content = ''; |
| 40 | |
| 41 | foreach ( $giveShortcodes as $shortcode ) { |
| 42 | $content .= "<h3>[{$shortcode}]</h3>"; |
| 43 | $content .= "[{$shortcode}]"; |
| 44 | } |
| 45 | |
| 46 | return $content; |
| 47 | |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get GiveWP shortcodes |
| 52 | * |
| 53 | * @return array |
| 54 | */ |
| 55 | private function getGiveShortcodes() { |
| 56 | |
| 57 | $shortcodes = []; |
| 58 | |
| 59 | foreach ( $GLOBALS['shortcode_tags'] as $shortcode => $action ) { |
| 60 | if ( false !== strpos( $shortcode, 'give_' ) ) { |
| 61 | $shortcodes[] = $shortcode; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return $shortcodes; |
| 66 | } |
| 67 | } |
| 68 |