condition-author.php
1 year ago
condition-device.php
1 year ago
condition-is-or-not.php
1 year ago
condition-number.php
3 years ago
condition-operator.php
1 year ago
condition-string.php
2 years ago
conditions-form.php
5 months ago
display-conditions-list.php
1 year ago
no-option.php
1 year ago
not-selected.php
4 years ago
visitor-conditions-list.php
1 year ago
condition-author.php
75 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for the Author display condition |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * |
| 7 | * @var string $name Form name attribute. |
| 8 | * @var int $max_authors Number of maximum author entries to show. |
| 9 | */ |
| 10 | |
| 11 | ?> |
| 12 | <div class="advads-conditions-single advads-buttonset"> |
| 13 | <?php |
| 14 | if ( count( $authors ) >= $max_authors ) : |
| 15 | // show active authors. |
| 16 | ?> |
| 17 | <div class="advads-conditions-authors-buttons dynamic-search"> |
| 18 | <?php |
| 19 | foreach ( $authors as $_author ) : |
| 20 | // don’t use strict comparision because $values contains strings. |
| 21 | if ( in_array( $_author->ID, $values ) ) : // phpcs:ignore |
| 22 | $author_name = $_author->display_name; |
| 23 | $field_id = 'advads-conditions-' . absint( $_author->ID ) . $rand; |
| 24 | ?> |
| 25 | <label class="button advads-button advads-ui-state-active"> |
| 26 | <span class="advads-button-text"> |
| 27 | <?php echo esc_attr( $author_name ); ?> |
| 28 | <input type="hidden" |
| 29 | name="<?php echo esc_attr( $name ); ?>[value][]" |
| 30 | value="<?php echo absint( $_author->ID ); ?>"> |
| 31 | </span> |
| 32 | </label> |
| 33 | <?php |
| 34 | endif; |
| 35 | endforeach; |
| 36 | ?> |
| 37 | </div> |
| 38 | <span class="advads-conditions-authors-show-search button" title="<?php echo esc_html_x( 'add more authors', 'display the authors search field on ad edit page', 'advanced-ads' ); ?>"> |
| 39 | + |
| 40 | </span> |
| 41 | <br/> |
| 42 | <input type="text" class="advads-conditions-authors-search" |
| 43 | data-input-name="<?php echo esc_attr( $name ); ?>[value][]" |
| 44 | placeholder="<?php esc_html_e( 'author name or id', 'advanced-ads' ); ?>"/> |
| 45 | <?php |
| 46 | else : |
| 47 | $max_counter = $max_authors; |
| 48 | foreach ( $authors as $_author ) { |
| 49 | if ( $max_counter <= 0 ) { |
| 50 | return false; |
| 51 | } |
| 52 | --$max_counter; |
| 53 | // don’t use strict comparision because $values contains strings. |
| 54 | if ( in_array( $_author->ID, $values ) ) { // phpcs:ignore |
| 55 | $_val = 1; |
| 56 | } else { |
| 57 | $_val = 0; |
| 58 | } |
| 59 | $author_name = $_author->display_name; |
| 60 | $field_id = 'advads-conditions-' . absint( $_author->ID ) . $rand; |
| 61 | ?> |
| 62 | <label class="button advads-button" |
| 63 | for="<?php echo esc_attr( $field_id ); ?>"> |
| 64 | <?php echo esc_attr( $author_name ); ?> |
| 65 | </label><input type="checkbox" |
| 66 | id="<?php echo esc_attr( $field_id ); ?>" |
| 67 | name="<?php echo esc_attr( $name ); ?>[value][]" <?php checked( $_val, 1 ); ?> |
| 68 | value="<?php echo absint( $_author->ID ); ?>"> |
| 69 | <?php |
| 70 | } |
| 71 | include ADVADS_ABSPATH . 'admin/views/conditions/not-selected.php'; |
| 72 | endif; |
| 73 | ?> |
| 74 | </div> |
| 75 |