| @@ -1,10 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace SureCart\Controllers\Admin; |
| 4 | 4 | |
| 5 | -use SureCartCore\Responses\RedirectResponse; | |
| 6 | - | |
| 7 | 5 | abstract class AdminController { |
| 8 | 6 | /** |
| 9 | 7 | * Preload API Request Paths |
| 10 | 8 | * |
| @@ -31,62 +29,21 @@ | ||
| 31 | 29 | |
| 32 | 30 | /** |
| 33 | 31 | * The header. |
| 34 | 32 | * |
| 35 | - * @param array $args The arguments. | |
| 36 | - * | |
| 37 | 33 | * @return void |
| 38 | 34 | */ |
| 39 | - public function withHeader( $args ) { | |
| 35 | + public function withHeader( $breadcrumbs ) { | |
| 40 | 36 | add_action( |
| 41 | 37 | 'in_admin_header', |
| 42 | - function () use ( $args ) { | |
| 38 | + function() use ( $breadcrumbs ) { | |
| 43 | 39 | return \SureCart::render( |
| 44 | 40 | 'layouts/partials/admin-header', |
| 45 | 41 | [ |
| 46 | - 'breadcrumbs' => $args['breadcrumbs'] ?? [], | |
| 47 | - 'suffix' => $args['suffix'] ?? '', | |
| 48 | - 'claim_url' => ! \SureCart::account()->claimed ? \SureCart::routeUrl( 'account.claim' ) : '', | |
| 49 | - 'claim_expired' => \SureCart::account()->claim_expired ?? false, | |
| 50 | - 'report_url' => $args['report_url'] ?? '', | |
| 51 | - 'enhanced_view_promo' => $args['enhanced_view_promo'] ?? null, | |
| 42 | + 'breadcrumbs' => $breadcrumbs, | |
| 43 | + 'claim_url' => ! \SureCart::account()->claimed ? \SureCart::routeUrl( 'account.claim' ) : '', | |
| 52 | 44 | ] |
| 53 | 45 | ); |
| 54 | 46 | } |
| 55 | 47 | ); |
| 56 | - } | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * Add notices. | |
| 60 | - * | |
| 61 | - * @param array $items The notices. | |
| 62 | - * | |
| 63 | - * @return void | |
| 64 | - */ | |
| 65 | - public function withNotices( $items ) { | |
| 66 | - add_action( | |
| 67 | - 'admin_notices', | |
| 68 | - function () use ( $items ) { | |
| 69 | - foreach ( $items as $key => $item ) { | |
| 70 | - if ( (bool) ( $_REQUEST[ $key ] ?? false ) ) { | |
| 71 | - ?> | |
| 72 | - <div class="notice notice-success is-dismissible"> | |
| 73 | - <p><?php echo esc_html( $item ); ?></p> | |
| 74 | - </div> | |
| 75 | - <?php | |
| 76 | - } | |
| 77 | - } | |
| 78 | - } | |
| 79 | - ); | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * Redirect back to the previous page. | |
| 84 | - * | |
| 85 | - * @param @param \SureCartCore\Requests\RequestInterface $request Request. | |
| 86 | - * | |
| 87 | - * @return \SureCartCore\Responses\RedirectResponse | |
| 88 | - */ | |
| 89 | - public function redirectBack( $request ) { | |
| 90 | - return ( new RedirectResponse( $request ) )->back(); | |
| 91 | 48 | } |
| 92 | 49 | } |