class-ajax.php
3 months ago
class-bulk-edit.php
3 months ago
class-create-modal.php
3 months ago
class-edit-modal.php
2 months ago
class-list-table.php
1 week ago
class-quick-edit.php
2 months ago
class-create-modal.php
57 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Placement Create Modal. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.50.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Admin\Placements; |
| 11 | |
| 12 | use AdvancedAds\Modal; |
| 13 | use AdvancedAds\Entities; |
| 14 | use AdvancedAds\Framework\Interfaces\Integration_Interface; |
| 15 | |
| 16 | defined( 'ABSPATH' ) || exit; |
| 17 | |
| 18 | /** |
| 19 | * Placement Create Modal. |
| 20 | */ |
| 21 | class Create_Modal implements Integration_Interface { |
| 22 | |
| 23 | /** |
| 24 | * Hook into WordPress. |
| 25 | * |
| 26 | * @return void |
| 27 | */ |
| 28 | public function hooks(): void { |
| 29 | add_action( 'admin_footer', [ $this, 'render_modal' ] ); |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Load the modal for creating a new Placement. |
| 34 | * |
| 35 | * @return void |
| 36 | */ |
| 37 | public function render_modal(): void { |
| 38 | global $wp_query; |
| 39 | |
| 40 | ob_start(); |
| 41 | $placements_description = 0 === $wp_query->found_posts ? Entities::get_placement_description() : ''; |
| 42 | include ADVADS_ABSPATH . 'views/admin/placements/create-modal/new-modal-content.php'; |
| 43 | |
| 44 | // @TODO Add old JS validation errors to the Modal - advads_validate_new_form in `admin/assets/js/admin.js`. |
| 45 | Modal::create( |
| 46 | [ |
| 47 | 'modal_slug' => 'placement-new', |
| 48 | 'modal_content' => ob_get_clean(), |
| 49 | 'modal_title' => __( 'New Placement', 'advanced-ads' ), |
| 50 | 'close_action' => __( 'Save New Placement', 'advanced-ads' ), |
| 51 | 'close_form' => 'advads-placements-new-form', |
| 52 | 'close_validation' => 'advads_validate_new_form', |
| 53 | ] |
| 54 | ); |
| 55 | } |
| 56 | } |
| 57 |