ad-list
5 months ago
conditions
5 months ago
notices
1 year ago
upgrades
1 year ago
ad-conditions-string-operators.php
3 months ago
checks.php
3 months ago
index.php
7 years ago
modal.php
3 months ago
overview-addons-line.php
5 months ago
overview-notice-row.php
1 year ago
overview-widget.php
1 year ago
placement-form.php
1 year ago
placement-injection-top.php
1 year ago
placement-types.php
3 years ago
placements-ad-label.php
1 year ago
placements-inline-css.php
1 year ago
placements-item.php
1 year ago
post-list-filter-dropdown.php
5 months ago
setting-license.php
1 year ago
support-callout.php
1 year ago
modal.php
80 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Advanced Ads - Backend modal |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.0.0 |
| 8 | * |
| 9 | * @var string $modal_slug Unique slug that can be addressed by a link or button. |
| 10 | * @var string $modal_content The modal content. May contain HTML. |
| 11 | * @var string $modal_title The modal title. |
| 12 | * @var string $cancel_action Show/Hide cancel button. |
| 13 | * @var string $close_action Adds another close button that can trigger an action. |
| 14 | * @var string $close_form Add a form ID. This form will be submitted after clicking the close and action button. |
| 15 | * @var string $close_validation A JavaScript validation function. The function has to return true or the form won't be submitted. |
| 16 | */ |
| 17 | |
| 18 | $close_validation_object = [ |
| 19 | 'function' => $close_validation, |
| 20 | 'modal_id' => "#modal-$modal_slug", |
| 21 | ]; |
| 22 | |
| 23 | ?> |
| 24 | <script> |
| 25 | document.addEventListener( 'DOMContentLoaded', function () { |
| 26 | document.querySelector( '#modal-<?php echo esc_attr( $modal_slug ); ?>' ).closeValidation = <?php echo wp_json_encode( $close_validation_object ); ?>; |
| 27 | <?php if ( $close_action && $close_form ) : ?> |
| 28 | document.querySelector( '#modal-<?php echo esc_attr( $modal_slug ); ?> .advads-modal-close-action' ).addEventListener( 'click', function ( event ) { |
| 29 | modal_submit_form( event, '<?php echo esc_attr( $close_form ); ?>', '#modal-<?php echo esc_attr( $modal_slug ); ?>', '<?php echo esc_attr( $close_validation ); ?>' ); |
| 30 | } ); |
| 31 | <?php endif; ?> |
| 32 | } ); |
| 33 | </script> |
| 34 | <dialog id="modal-<?php echo esc_attr( $modal_slug ); ?>" class="advads-modal" data-modal-id="<?php echo esc_attr( $modal_slug ); ?>" autofocus> |
| 35 | <a href="#close" class="advads-modal-close-background">Close</a> |
| 36 | <div class="advads-modal-content"> |
| 37 | <div class="advads-modal-header"> |
| 38 | <h2> |
| 39 | <?php echo esc_html( $modal_title ); ?> |
| 40 | </h2> |
| 41 | <a href="#close" class="advads-modal-close" title="<?php esc_html_e( 'Cancel', 'advanced-ads' ); ?>"> |
| 42 | <span class="dashicons dashicons-no-alt"></span> |
| 43 | </a> |
| 44 | </div> |
| 45 | <div class="advads-modal-body"> |
| 46 | <?php |
| 47 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- modal content may contain any kind of custom html |
| 48 | echo $modal_content; |
| 49 | ?> |
| 50 | </div> |
| 51 | <div class="advads-modal-footer"> |
| 52 | <div class="tablenav bottom"> |
| 53 | <?php if ( false === $cancel_action ) : ?> |
| 54 | <a href="#close" class="button button-secondary advads-modal-close"> |
| 55 | <?php esc_html_e( 'Cancel', 'advanced-ads' ); ?> |
| 56 | </a> |
| 57 | <?php endif; ?> |
| 58 | |
| 59 | <?php if ( $close_action ) : ?> |
| 60 | <?php if ( $close_form ) : ?> |
| 61 | <button type="submit" form="<?php echo esc_attr( $close_form ); ?>" class="button button-primary advads-modal-close-action"> |
| 62 | <?php |
| 63 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- close action may contain custom html like button bar, image or span tag e.g. |
| 64 | echo $close_action; |
| 65 | ?> |
| 66 | </button> |
| 67 | <?php else : ?> |
| 68 | <a href="#close" class="button button-primary advads-modal-close-action"> |
| 69 | <?php |
| 70 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- close action may contain custom html like button bar, image or span tag e.g. |
| 71 | echo $close_action; |
| 72 | ?> |
| 73 | </a> |
| 74 | <?php endif; ?> |
| 75 | <?php endif; ?> |
| 76 | </div> |
| 77 | </div> |
| 78 | </div> |
| 79 | </dialog> |
| 80 |