AdminNoticeHandler.php
5 years ago
RequestHandler.php
5 years ago
TopLevelMenuRedirect.php
5 years ago
TopLevelMenuRedirect.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Onboarding\Setup\Handlers; |
| 4 | |
| 5 | defined( 'ABSPATH' ) || exit; |
| 6 | |
| 7 | /** |
| 8 | * Redirect the top level "Donations" menu to the Setup submenu. |
| 9 | * This normalizes the Setup Page URL so that assets load correctly. |
| 10 | */ |
| 11 | class TopLevelMenuRedirect implements RequestHandler { |
| 12 | |
| 13 | /** |
| 14 | * @inheritdoc |
| 15 | * |
| 16 | * @since 2.8.0 |
| 17 | */ |
| 18 | public function maybeHandle() { |
| 19 | if ( isset( $_GET['page'] ) && 'give-setup' == $_GET['page'] && ! isset( $_GET['post_type'] ) ) { |
| 20 | $this->handle(); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @inheritdoc |
| 26 | * |
| 27 | * @since 2.8.0 |
| 28 | */ |
| 29 | public function handle() { |
| 30 | wp_redirect( |
| 31 | $this->getRedirectUrl() |
| 32 | ); |
| 33 | exit; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @since 2.8.0 |
| 38 | */ |
| 39 | protected function getRedirectUrl() { |
| 40 | return add_query_arg( |
| 41 | [ |
| 42 | 'post_type' => 'give_forms', |
| 43 | 'page' => 'give-setup', |
| 44 | ], |
| 45 | admin_url( 'edit.php' ) |
| 46 | ); |
| 47 | } |
| 48 | } |
| 49 |