| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Search Form |
| 5 |
* |
| 6 |
* @link https://plugins360.com |
| 7 |
* @since 2.5.7 |
| 8 |
* |
| 9 |
* @package Automatic_YouTube_Gallery |
| 10 |
*/ |
| 11 |
|
| 12 |
// Build attributes |
| 13 |
$source_type = sanitize_text_field( $attributes['type'] ); |
| 14 |
|
| 15 |
$params = array( |
| 16 |
'uid' => sanitize_text_field( $attributes['uid'] ), |
| 17 |
'post_id' => (int) $attributes['post_id'], |
| 18 |
'type' => $source_type, |
| 19 |
'src' => sanitize_text_field( $attributes[ $source_type ] ), |
| 20 |
'order' => sanitize_text_field( $attributes['order'] ), // Works only when type = "search". |
| 21 |
'sort_by' => ! empty( $attributes['sort_by'] ) ? sanitize_key( $attributes['sort_by'] ) : 'date', // Works only when type = "db". |
| 22 |
'sort_order' => ! empty( $attributes['sort_order'] ) ? sanitize_key( $attributes['sort_order'] ) : 'desc', // Works only when type = "db". |
| 23 |
'sort_seed' => ! empty( $attributes['sort_seed'] ) ? (int) $attributes['sort_seed'] : 0, // Works only when type = "db" + sort_by = "random". |
| 24 |
'duration_filter' => ! empty( $attributes['duration_filter'] ) ? sanitize_key( $attributes['duration_filter'] ) : '', // Works only when type = "db". |
| 25 |
'duration' => ! empty( $attributes['duration'] ) ? (int) $attributes['duration'] : 0, // Works only when type = "db". |
| 26 |
'limit' => (int) $attributes['limit'], // Works only when type = "search". |
| 27 |
'per_page' => (int) $attributes['per_page'], |
| 28 |
'cache' => (int) $attributes['cache'], |
| 29 |
'columns' => ! empty( $attributes['columns'] ) ? (int) $attributes['columns'] : 1, |
| 30 |
'thumb_ratio' => ! empty( $attributes['thumb_ratio'] ) ? (float) $attributes['thumb_ratio'] : 56.25, |
| 31 |
'thumb_title' => ! empty( $attributes['thumb_title'] ) ? (int) $attributes['thumb_title'] : 0, |
| 32 |
'thumb_title_length' => ! empty( $attributes['thumb_title_length'] ) ? (int) $attributes['thumb_title_length'] : 0, |
| 33 |
'thumb_excerpt' => ! empty( $attributes['thumb_excerpt'] ) ? (int) $attributes['thumb_excerpt'] : 0, |
| 34 |
'thumb_excerpt_length' => ! empty( $attributes['thumb_excerpt_length'] ) ? (int) $attributes['thumb_excerpt_length'] : 0, |
| 35 |
'player_description' => ! empty( $attributes['player_description'] ) ? (int) $attributes['player_description'] : 0 |
| 36 |
); |
| 37 |
|
| 38 |
$params = apply_filters( 'ayg_search_form_params', $params, $attributes ); |
| 39 |
$params = apply_filters( 'ayg_search_form_args', $params, $attributes ); // Deprecated for consistency in version 2.7.2 |
| 40 |
|
| 41 |
// Signed last, so the signature covers the values that are actually sent — including any a filter |
| 42 |
// changed above. It ties the gallery UID to its source and cache duration, so the AJAX endpoint |
| 43 |
// can tell a genuine set from one a visitor put together. See ayg_get_gallery_signature(). |
| 44 |
$params['signature'] = ayg_get_gallery_signature( |
| 45 |
isset( $params['uid'] ) ? $params['uid'] : '', |
| 46 |
isset( $params['type'] ) ? $params['type'] : '', |
| 47 |
isset( $params['src'] ) ? $params['src'] : '', |
| 48 |
isset( $params['cache'] ) ? $params['cache'] : 0 |
| 49 |
); |
| 50 |
?> |
| 51 |
<ayg-search-form data-params="<?php echo esc_attr( wp_json_encode( $params ) ); ?>"> |
| 52 |
<form class="ayg-search-form"> |
| 53 |
<input type="text" class="ayg-search-input" placeholder="<?php esc_attr_e( 'Search Videos', 'automatic-youtube-gallery' ); ?>" /> |
| 54 |
<button type="button" class="ayg-search-btn"> |
| 55 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 56 |
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" /> |
| 57 |
</svg> |
| 58 |
</button> |
| 59 |
<button type="button" class="ayg-reset-btn" style="display: none;"> |
| 60 |
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"> |
| 61 |
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /> |
| 62 |
</svg> |
| 63 |
</button> |
| 64 |
</form> |
| 65 |
</ayg-search-form> |