Advanced_Ads_Modal.php
3 years ago
EDD_SL_Plugin_Updater.php
4 years ago
ad-ajax.php
3 years ago
ad-debug.php
3 years ago
ad-expiration.php
3 years ago
ad-health-notices.php
3 years ago
ad-model.php
3 years ago
ad-select.php
3 years ago
ad.php
3 years ago
ad_ajax_callbacks.php
3 years ago
ad_group.php
3 years ago
ad_placements.php
3 years ago
ad_type_abstract.php
3 years ago
ad_type_content.php
3 years ago
ad_type_dummy.php
3 years ago
ad_type_group.php
3 years ago
ad_type_image.php
3 years ago
ad_type_plain.php
3 years ago
checks.php
3 years ago
compatibility.php
3 years ago
display-conditions.php
3 years ago
filesystem.php
3 years ago
frontend-notices.php
3 years ago
frontend_checks.php
3 years ago
in-content-injector.php
3 years ago
inline-css.php
3 years ago
plugin.php
3 years ago
upgrades.php
6 years ago
utils.php
3 years ago
visitor-conditions.php
3 years ago
widget.php
3 years ago
Advanced_Ads_Modal.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Basic Modal class to separate concerns. |
| 5 | */ |
| 6 | class Advanced_Ads_Modal { |
| 7 | /** |
| 8 | * Default values for the view file. |
| 9 | * |
| 10 | * @var array |
| 11 | */ |
| 12 | private $view_arguments = array( |
| 13 | 'modal_slug' => '', |
| 14 | 'modal_content' => '', |
| 15 | 'modal_title' => '', |
| 16 | 'close_action' => '', |
| 17 | 'close_form' => '', |
| 18 | 'close_validation' => '', |
| 19 | ); |
| 20 | |
| 21 | /** |
| 22 | * Modal constructor. |
| 23 | * |
| 24 | * @param array $arguments The passed view arguments, overwriting the default values. |
| 25 | * @param bool $render Whether to render the modal from the constructor. Defaults to true. |
| 26 | */ |
| 27 | public function __construct( array $arguments, $render = true ) { |
| 28 | $this->view_arguments = array_intersect_key( wp_parse_args( array_map( 'strval', $arguments ), $this->view_arguments ), $this->view_arguments ); |
| 29 | |
| 30 | if ( $render ) { |
| 31 | $this->render(); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Render the modal. |
| 37 | * |
| 38 | * @return void |
| 39 | */ |
| 40 | public function render() { |
| 41 | // phpcs:ignore WordPress.PHP.DontExtract.extract_extract -- we have ensured, the array only contains the variables defined by the defaults. Variables are documented and escaped in the view file. |
| 42 | extract( $this->view_arguments, EXTR_OVERWRITE ); |
| 43 | |
| 44 | require ADVADS_BASE_PATH . 'admin/views/modal.php'; |
| 45 | } |
| 46 | } |
| 47 |