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