SuccessNotice.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonorDashboards\Admin; |
| 4 | |
| 5 | class SuccessNotice |
| 6 | { |
| 7 | |
| 8 | /** |
| 9 | * Reigster success notice |
| 10 | * |
| 11 | * @since 2.10.0 |
| 12 | * @return void |
| 13 | * |
| 14 | */ |
| 15 | public function register() |
| 16 | { |
| 17 | if ($this->shouldRenderOutput()) { |
| 18 | $this->renderOutput(); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Return true if notice should be rendered, false if not |
| 24 | * |
| 25 | * @since 2.10.0 |
| 26 | * @return boolean |
| 27 | * |
| 28 | */ |
| 29 | protected function shouldRenderOutput() |
| 30 | { |
| 31 | return isset($_GET['give-generated-donor-dashboard-page']); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Render notice output |
| 36 | * |
| 37 | * @since 2.10.0 |
| 38 | * @return void |
| 39 | * |
| 40 | */ |
| 41 | protected function renderOutput() |
| 42 | { |
| 43 | echo $this->getOutput(); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Get notice output |
| 48 | * |
| 49 | * @since 2.10.0 |
| 50 | * @return string |
| 51 | * |
| 52 | */ |
| 53 | protected function getOutput() |
| 54 | { |
| 55 | ob_start(); |
| 56 | $output = ''; |
| 57 | require $this->getTemplatePath(); |
| 58 | $output = ob_get_contents(); |
| 59 | ob_end_clean(); |
| 60 | |
| 61 | return $output; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get template path for notice output |
| 66 | * |
| 67 | * @since 2.10.0 |
| 68 | * @return string |
| 69 | * |
| 70 | */ |
| 71 | protected function getTemplatePath() |
| 72 | { |
| 73 | return GIVE_PLUGIN_DIR . '/src/DonorDashboards/resources/views/successnotice.php'; |
| 74 | } |
| 75 | } |
| 76 |