Shortcode.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\MultiFormGoals\MultiFormGoal; |
| 4 | |
| 5 | use Give\MultiFormGoals\MultiFormGoal\Model as MultiFormGoal; |
| 6 | |
| 7 | class Shortcode { |
| 8 | |
| 9 | /** |
| 10 | * Registers Multi-Form Goal Shortcode |
| 11 | * |
| 12 | * @since 2.9.0 |
| 13 | **/ |
| 14 | public function addShortcode() { |
| 15 | add_shortcode( 'give_multi_form_goal', [ $this, 'renderCallback' ] ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Returns Shortcode markup |
| 20 | * |
| 21 | * @since 2.9.0 |
| 22 | **/ |
| 23 | public function renderCallback( $attributes ) { |
| 24 | error_log( serialize( $attributes ) ); |
| 25 | $attributes = shortcode_atts( |
| 26 | [ |
| 27 | 'ids' => [], |
| 28 | 'tags' => [], |
| 29 | 'categories' => [], |
| 30 | 'goal' => '1000', |
| 31 | 'enddate' => '', |
| 32 | 'color' => '#28c77b', |
| 33 | 'heading' => 'Example Heading', |
| 34 | 'image' => GIVE_PLUGIN_URL . 'assets/dist/images/onboarding-preview-form-image.min.jpg', |
| 35 | 'summary' => 'This is a summary.', |
| 36 | |
| 37 | ], |
| 38 | $attributes, |
| 39 | 'give_multi_form_goal' |
| 40 | ); |
| 41 | $multiFormGoal = new MultiFormGoal( |
| 42 | [ |
| 43 | 'ids' => $attributes['ids'], |
| 44 | 'tags' => $attributes['tags'], |
| 45 | 'categories' => $attributes['categories'], |
| 46 | 'goal' => $attributes['goal'], |
| 47 | 'enddate' => $attributes['enddate'], |
| 48 | 'color' => $attributes['color'], |
| 49 | 'heading' => $attributes['heading'], |
| 50 | 'imageSrc' => $attributes['image'], |
| 51 | 'summary' => $attributes['summary'], |
| 52 | ] |
| 53 | ); |
| 54 | return $multiFormGoal->getOutput(); |
| 55 | } |
| 56 | } |
| 57 |