PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.7.1
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.7.1
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
automatic-youtube-gallery / includes / functions.php

functions.php in Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels 2.7.1, at includes/functions.php

1,271 lines 42.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Helper Functions.
5 *
6 * @link https://plugins360.com
7 * @since 1.0.0
8 *
9 * @package Automatic_YouTube_Gallery
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 /**
18 * Build gallery HTML output.
19 *
20 * @since 1.0.0
21 * @param array $args An array of gallery options.
22 * @return mixed
23 */
24 function ayg_build_gallery( $args ) {
25 $general_settings = ayg_get_option( 'ayg_general_settings' );
26 $strings_settings = ayg_get_option( 'ayg_strings_settings' );
27
28 global $post;
29
30 // Vars
31 $fields = ayg_get_editor_fields();
32 $excluded_fields = array( 'popup' ); // Fields not part of attributes
33 $defaults = array();
34
35 foreach ( $fields as $key => $value ) {
36 foreach ( $value['fields'] as $field ) {
37 if ( in_array( $field['name'], $excluded_fields ) ) {
38 continue;
39 }
40
41 $defaults[ $field['name'] ] = $field['value'];
42 }
43 }
44
45 $defaults = array_merge( $defaults, (array) $strings_settings );
46 $attributes = shortcode_atts( $defaults, $args, 'automatic_youtube_gallery' );
47
48 $attributes['post_id'] = 0;
49 if ( isset( $post->ID ) ) {
50 $attributes['post_id'] = (int) $post->ID;
51 }
52
53 $attributes['columns'] = min( 12, (int) $attributes['columns'] );
54 if ( empty( $attributes['columns'] ) ) {
55 $attributes['columns'] = 3;
56 }
57
58 $attributes['limit'] = min( 500, (int) $attributes['limit'] );
59 if ( empty( $attributes['limit'] ) ) {
60 $attributes['limit'] = 500;
61 }
62
63 $attributes['per_page'] = min( 50, (int) $attributes['per_page'] );
64 if ( empty( $attributes['per_page'] ) ) {
65 $attributes['per_page'] = 50;
66 }
67
68 $source_type = sanitize_text_field( $attributes['type'] );
69 if ( 'livestream' == $source_type ) {
70 $attributes['livestream'] = $attributes['channel'];
71 }
72
73 $attributes['lazyload'] = 0;
74 if ( ! empty( $general_settings['lazyload'] ) ) {
75 $attributes['lazyload'] = 1;
76 }
77
78 $source_url = sanitize_text_field( $attributes[ $source_type ] );
79
80 if ( isset( $args['uid'] ) && ! empty( $args['uid'] ) ) {
81 $attributes['uid'] = sanitize_text_field( $args['uid'] );
82 } else {
83 $attributes['uid'] = md5( $source_type . $source_url );
84 }
85
86 $attributes['uid'] = apply_filters( 'ayg_gallery_id', $attributes['uid'], $args );
87
88 // Deprecated since v2.5.8. Retained for backward compatibility.
89 $deprecated_uid = md5( $source_type . $source_url . sanitize_text_field( $attributes['theme'] ) ); // Deprecated
90 if ( isset( $args['deprecated_uid'] ) && ! empty( $args['deprecated_uid'] ) ) {
91 $deprecated_uid = sanitize_text_field( $args['deprecated_uid'] );
92 }
93
94 // Get Videos
95 $api_params = array(
96 'uid' => $attributes['uid'],
97 'type' => $source_type,
98 'src' => $source_url,
99 'order' => sanitize_text_field( $attributes['order'] ), // Works only when type = "search".
100 'limit' => $attributes['limit'], // Works only when type = "search".
101 'maxResults' => $attributes['per_page'],
102 'cache' => (int) $attributes['cache']
103 );
104
105 $api_params = apply_filters( 'ayg_youtube_api_request_params', $api_params, $args );
106
107 $youtube_api = new AYG_YouTube_API();
108 $response = $youtube_api->query( $api_params );
109
110 // Process output
111 if ( ! isset( $response->error ) ) {
112 // Store Gallery ID
113 if ( $attributes['post_id'] > 0 && isset( $attributes['deeplinking'] ) && 1 == $attributes['deeplinking'] ) {
114 $pages = ayg_get_option( 'ayg_gallery_page_ids' );
115 $page_id = $attributes['post_id'];
116
117 if ( ! in_array( $page_id, $pages ) ) {
118 $pages[] = $page_id;
119 update_option( 'ayg_gallery_page_ids', $pages );
120 }
121 }
122
123 // Gallery
124 $videos = array();
125
126 $gallery_id_from_url = get_query_var( 'ayg_gallery_id' );
127 $video_id_from_url = get_query_var( 'ayg_video_id' );
128
129 if ( $attributes['uid'] == $gallery_id_from_url || $deprecated_uid == $gallery_id_from_url ) {
130 $video = ayg_db_get_video( $video_id_from_url );
131
132 if ( $video ) {
133 $videos[] = $video;
134 } else {
135 $video_id_from_url = '';
136 }
137 }
138
139 if ( isset( $response->videos ) ) {
140 if ( ! empty( $video_id_from_url ) ) {
141 foreach ( $response->videos as $video ) {
142 if ( $video->id != $video_id_from_url ) {
143 $videos[] = $video;
144 }
145 }
146 } else {
147 $videos = $response->videos;
148 }
149 }
150
151 // Pagination
152 if ( isset( $response->page_info ) ) {
153 $attributes = array_merge( $attributes, $api_params, $response->page_info );
154 }
155
156 // Theme
157 $theme = 'classic';
158
159 if ( 'video' == $source_type ) {
160 $theme = 'single';
161 } elseif ( 'livestream' == $source_type ) {
162 $theme = 'livestream';
163 } else {
164 if ( 1 == count( $videos ) ) {
165 $theme = 'single';
166 }
167 }
168
169 // Enqueue dependencies
170 wp_enqueue_style( AYG_SLUG . '-public' );
171
172 wp_enqueue_script( AYG_SLUG . '-public' );
173 if ( $attributes['theme'] == $theme && 'classic' == $attributes['theme'] ) {
174 wp_enqueue_script( AYG_SLUG . '-theme-classic' );
175 }
176
177 // Output
178 ob_start();
179 include ayg_get_template( AYG_DIR . "public/templates/theme-{$theme}.php", $attributes['theme'] );
180 return ob_get_clean();
181 } else {
182 return sprintf( '<div class="ayg ayg-error">%s</div>', wp_kses_post( $response->error_message ) );
183 }
184 }
185
186 /**
187 * Combine video attributes as a string.
188 *
189 * @since 2.5.0
190 * @param array $atts Array of video attributes.
191 * @param string Combined attributes string.
192 */
193 function ayg_combine_video_attributes( $atts ) {
194 $attributes = array();
195
196 foreach ( $atts as $key => $value ) {
197 if ( '' === $value ) {
198 $attributes[] = $key;
199 } else {
200 $attributes[] = sprintf( '%s="%s"', $key, $value );
201 }
202 }
203
204 return implode( ' ', $attributes );
205 }
206
207 /**
208 * Create custom database tables
209 *
210 * @since 2.1.0
211 */
212 function ayg_db_create_custom_tables() {
213 global $wpdb;
214
215 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
216 $charset_collate = $wpdb->get_charset_collate();
217
218 $videos_table = $wpdb->prefix . 'ayg_videos';
219
220 // Check if the videos table exists
221 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $videos_table ) );
222
223 if ( $wpdb->get_var( $query ) === $videos_table ) {
224 // Find and remove duplicate video IDs
225 $wpdb->query(
226 "DELETE v1 FROM $videos_table v1
227 INNER JOIN $videos_table v2
228 ON v1.id = v2.id AND v1.NUM > v2.NUM"
229 );
230 }
231
232 // Create the videos table
233 $sql = "CREATE TABLE $videos_table (
234 NUM bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
235 id varchar(100) NOT NULL,
236 title text NOT NULL,
237 description text NOT NULL,
238 thumbnails text NOT NULL,
239 duration varchar(25) NOT NULL,
240 status varchar(100) NOT NULL,
241 published_at varchar(100) NOT NULL,
242 published_at_datetime datetime NULL,
243 PRIMARY KEY (NUM),
244 UNIQUE KEY ayg_unique_video_id (id)
245 ) $charset_collate;";
246
247 dbDelta( $sql );
248
249 // Add UNIQUE KEY if it is not added
250 $existing_keys = $wpdb->get_results( "SHOW KEYS FROM $videos_table WHERE Key_name = 'ayg_unique_video_id'" );
251
252 if ( empty( $existing_keys ) ) {
253 $wpdb->query( "ALTER TABLE $videos_table ADD UNIQUE KEY ayg_unique_video_id (id)" );
254 }
255
256 // Create the galleries table
257 $galleries_table = $wpdb->prefix . 'ayg_galleries';
258
259 $sql = "CREATE TABLE $galleries_table (
260 NUM bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
261 video_id varchar(100) NOT NULL,
262 gallery_id varchar(100) NOT NULL,
263 PRIMARY KEY (NUM),
264 UNIQUE KEY ayg_unique_video_gallery (video_id, gallery_id),
265 INDEX ayg_idx_gallery_id (gallery_id)
266 ) $charset_collate;";
267
268 dbDelta( $sql );
269 }
270
271 /**
272 * Store videos in our custom database table "{$wpdb->prefix}ayg_videos"
273 *
274 * @since 2.1.0
275 * @param object $data YouTube API response object.
276 * @param array $attributes Array of user attributes.
277 */
278 function ayg_db_store_videos( $data, $attributes = array() ) {
279 if ( AYG_VERSION !== get_option( 'ayg_version' ) ) {
280 return false;
281 }
282
283 if ( isset( $data->kind ) && 'youtube#channelListResponse' == $data->kind ) {
284 return false;
285 }
286
287 if ( empty( $data->items ) || ! is_array( $data->items ) ) {
288 return false;
289 }
290
291 global $wpdb;
292
293 $items = $data->items;
294
295 // Store Videos
296 foreach ( $items as $item ) {
297 $row = array();
298
299 // Video ID
300 $row['id'] = '';
301
302 if ( isset( $item->snippet->resourceId ) && isset( $item->snippet->resourceId->videoId ) ) {
303 $row['id'] = $item->snippet->resourceId->videoId;
304 } elseif ( isset( $item->contentDetails ) && isset( $item->contentDetails->videoId ) ) {
305 $row['id'] = $item->contentDetails->videoId;
306 } elseif ( isset( $item->id ) && isset( $item->id->videoId ) ) {
307 $row['id'] = $item->id->videoId;
308 } elseif ( isset( $item->id ) ) {
309 $row['id'] = $item->id;
310 }
311
312 if ( empty( $row['id'] ) ) {
313 continue;
314 }
315
316 // Video title
317 $row['title'] = $item->snippet->title;
318
319 // Video description
320 $row['description'] = $item->snippet->description;
321
322 // Video thumbnails
323 $row['thumbnails'] = '';
324 if ( isset( $item->snippet->thumbnails ) ) {
325 $row['thumbnails'] = serialize( $item->snippet->thumbnails );
326 }
327
328 // Video duration
329 $row['duration'] = '';
330 if ( isset( $item->contentDetails ) && isset( $item->contentDetails->duration ) ) {
331 $row['duration'] = $item->contentDetails->duration;
332 }
333
334 // Video status
335 $row['status'] = 'private';
336
337 if ( isset( $item->status ) && ( 'public' == $item->status->privacyStatus || 'unlisted' == $item->status->privacyStatus ) ) {
338 $row['status'] = 'public';
339 }
340
341 if ( isset( $item->snippet->status ) && ( 'public' == $item->snippet->status->privacyStatus || 'unlisted' == $item->snippet->status->privacyStatus ) ) {
342 $row['status'] = 'public';
343 }
344
345 if ( 'youtube#searchResult' == $item->kind ) {
346 $row['status'] = 'public';
347 }
348
349 // Video publish date
350 $row['published_at'] = $item->snippet->publishedAt;
351
352 $datetime = new DateTime( $item->snippet->publishedAt );
353 $row['published_at_datetime'] = date_format( $datetime, 'Y-m-d H:i:s' );
354
355 // Store the video
356 $videos_table = $wpdb->prefix . 'ayg_videos';
357
358 $query = $wpdb->prepare(
359 "INSERT INTO $videos_table (id, title, description, thumbnails, duration, status, published_at, published_at_datetime)
360 VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
361 ON DUPLICATE KEY UPDATE
362 title = VALUES(title),
363 description = VALUES(description),
364 thumbnails = VALUES(thumbnails),
365 duration = VALUES(duration),
366 status = VALUES(status),
367 published_at = VALUES(published_at),
368 published_at_datetime = VALUES(published_at_datetime)",
369 $row['id'],
370 $row['title'],
371 $row['description'],
372 $row['thumbnails'],
373 $row['duration'],
374 $row['status'],
375 $row['published_at'],
376 $row['published_at_datetime']
377 );
378
379 $wpdb->query( $query );
380
381 // Store the gallery association
382 $gallery_id = isset( $attributes['uid'] ) ? $attributes['uid'] : '';
383 $source_type = isset( $attributes['type'] ) ? $attributes['type'] : 'videos';
384
385 if ( ! empty( $gallery_id ) && ! in_array( $source_type, array( 'video', 'livestream' ) ) ) {
386 $galleries_table = $wpdb->prefix . 'ayg_galleries';
387
388 $query = $wpdb->prepare(
389 "INSERT IGNORE INTO $galleries_table (video_id, gallery_id) VALUES (%s, %s)",
390 $row['id'],
391 $gallery_id
392 );
393
394 $wpdb->query( $query );
395 }
396 }
397 }
398
399 /**
400 * Get a single video record from our custom database table "{$wpdb->prefix}ayg_videos"
401 *
402 * @since 2.1.0
403 * @param string $video_id YouTube Video ID.
404 * @return mixed
405 */
406 function ayg_db_get_video( $video_id ) {
407 global $wpdb;
408
409 $cache_key = 'ayg_'. $video_id;
410 $row = wp_cache_get( $cache_key );
411
412 if ( false === $row ) {
413 $query = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}ayg_videos WHERE id = %s", $video_id );
414 $row = $wpdb->get_row( $query );
415
416 if ( $row ) {
417 if ( ! empty( $row->thumbnails ) ) {
418 $row->thumbnails = unserialize( $row->thumbnails );
419 }
420
421 wp_cache_set( $cache_key, $row );
422 }
423 }
424
425 return $row;
426 }
427
428 /**
429 * Dump our plugin transients.
430 *
431 * @since 2.1.0
432 */
433 function ayg_delete_cache() {
434 delete_option( 'ayg_gallery_page_ids' );
435
436 // Get the current list of transients
437 $transient_keys = ayg_get_option( 'ayg_transient_keys' );
438
439 // For each key, delete that transient
440 foreach ( $transient_keys as $key ) {
441 delete_transient( $key );
442 }
443
444 // Reset our DB value
445 update_option( 'ayg_transient_keys', array() );
446 }
447
448 /**
449 * Get current address bar URL.
450 *
451 * @since 2.1.0
452 * @return string Current Page URL.
453 */
454 function ayg_get_current_url() {
455 global $wp;
456 $current_url = home_url( add_query_arg( array(), $wp->request ) );
457
458 return $current_url;
459 }
460
461 /**
462 * Get default plugin settings.
463 *
464 * @since 1.6.4
465 * @return array $defaults Array of plugin settings.
466 */
467 function ayg_get_default_settings() {
468 $defaults = array(
469 'ayg_general_settings' => array(
470 'force_load_assets' => array(
471 'css' => 'css'
472 ),
473 'api_key' => '',
474 'lazyload' => 0,
475 'development_mode' => 0
476 ),
477 'ayg_strings_settings' => array(
478 'more_button_label' => __( 'Load More', 'automatic-youtube-gallery' ),
479 'previous_button_label' => __( 'Previous', 'automatic-youtube-gallery' ),
480 'next_button_label' => __( 'Next', 'automatic-youtube-gallery' ),
481 'show_more_label' => __( 'Show More', 'automatic-youtube-gallery' ),
482 'show_less_label' => __( 'Show Less', 'automatic-youtube-gallery' )
483 ),
484 'ayg_gallery_settings' => array(
485 'theme' => 'classic',
486 'columns' => 3,
487 'per_page' => 12,
488 'thumb_ratio' => 56.25,
489 'thumb_title' => 1,
490 'thumb_title_length' => 0,
491 'thumb_excerpt' => 1,
492 'thumb_excerpt_length' => 75,
493 'pagination' => 1,
494 'pagination_type' => 'more',
495 'scroll_top_offset' => 10
496 ),
497 'ayg_player_settings' => array(
498 'player_type' => 'youtube',
499 'player_color' => '#00b3ff',
500 'player_width' => '',
501 'player_ratio' => 56.25,
502 'player_title' => 1,
503 'player_description' => 1,
504 'autoplay' => 0,
505 'autoadvance' => 1,
506 'loop' => 0,
507 'muted' => 0,
508 'controls' => 1,
509 'modestbranding' => 1,
510 'cc_load_policy' => 0,
511 'iv_load_policy' => 0,
512 'hl' => '',
513 'cc_lang_pref' => '',
514 'privacy_enhanced_mode' => 0,
515 'origin' => 0
516 ),
517 'ayg_livestream_settings' => array(
518 'fallback_message' => __( 'Sorry, but the channel is not currently streaming live content. Please check back later.', 'automatic-youtube-gallery' )
519 ),
520 'ayg_privacy_settings' => array(
521 'cookie_consent' => 0,
522 'consent_message' => __( 'Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.', 'automatic-youtube-gallery' ),
523 'button_label' => __( 'Accept', 'automatic-youtube-gallery' )
524 )
525 );
526
527 return $defaults;
528 }
529
530 /**
531 * Get editor fields.
532 *
533 * @since 1.0.0
534 * @return array Array of fields.
535 */
536 function ayg_get_editor_fields() {
537 $fields = array(
538 'source' => array(
539 'label' => __( 'General', 'automatic-youtube-gallery' ),
540 'fields' => array(
541 array(
542 'name' => 'type',
543 'label' => __( 'Source Type', 'automatic-youtube-gallery' ),
544 'description' => '',
545 'type' => 'select',
546 'options' => array(
547 'playlist' => __( 'Playlist', 'automatic-youtube-gallery' ),
548 'channel' => __( 'Channel', 'automatic-youtube-gallery' ),
549 'username' => __( 'Username', 'automatic-youtube-gallery' ),
550 'search' => __( 'Search Keywords', 'automatic-youtube-gallery' ),
551 'video' => __( 'Single Video', 'automatic-youtube-gallery' ),
552 'livestream' => __( 'Livestream', 'automatic-youtube-gallery' ),
553 'videos' => __( 'Custom Videos List', 'automatic-youtube-gallery' )
554 ),
555 'value' => 'playlist',
556 'sanitize_callback' => 'sanitize_key'
557 ),
558 array(
559 'name' => 'playlist',
560 'label' => __( 'YouTube Playlist ID (or) URL', 'automatic-youtube-gallery' ),
561 'description' => sprintf( '%s: https://www.youtube.com/playlist?list=XXXXXXXXXX', __( 'Example', 'automatic-youtube-gallery' ) ),
562 'type' => 'url',
563 'value' => '',
564 'sanitize_callback' => 'sanitize_text_field'
565 ),
566 array(
567 'name' => 'channel',
568 'label' => __( 'YouTube Channel ID (or) a YouTube Video URL from the Channel', 'automatic-youtube-gallery' ),
569 'description' => sprintf( '%s: https://www.youtube.com/channel/XXXXXXXXXX', __( 'Example', 'automatic-youtube-gallery' ) ),
570 'type' => 'url',
571 'value' => '',
572 'sanitize_callback' => 'sanitize_text_field'
573 ),
574 array(
575 'name' => 'username',
576 'label' => __( 'YouTube Account Username', 'automatic-youtube-gallery' ),
577 'description' => sprintf( '%s: SanRosh', __( 'Example', 'automatic-youtube-gallery' ) ),
578 'type' => 'text',
579 'value' => '',
580 'sanitize_callback' => 'sanitize_text_field'
581 ),
582 array(
583 'name' => 'search',
584 'label' => __( 'Search Keywords', 'automatic-youtube-gallery' ),
585 'description' => sprintf( '%s: Cartoon (space:AND , -:NOT , |:OR)', __( 'Example', 'automatic-youtube-gallery' ) ),
586 'type' => 'text',
587 'value' => '',
588 'sanitize_callback' => 'sanitize_text_field'
589 ),
590 array(
591 'name' => 'video',
592 'label' => __( 'YouTube Video ID (or) URL', 'automatic-youtube-gallery' ),
593 'description' => sprintf( '%s: https://www.youtube.com/watch?v=XXXXXXXXXX', __( 'Example', 'automatic-youtube-gallery' ) ),
594 'type' => 'url',
595 'value' => '',
596 'sanitize_callback' => 'sanitize_text_field'
597 ),
598 array(
599 'name' => 'videos',
600 'label' => __( 'YouTube Video IDs (or) URLs', 'automatic-youtube-gallery' ),
601 'description' => sprintf( '%s: https://www.youtube.com/watch?v=XXXXXXXXXX', __( 'Example', 'automatic-youtube-gallery' ) ),
602 'type' => 'textarea',
603 'placeholder' => __( 'Enter one video per line', 'automatic-youtube-gallery' ),
604 'value' => '',
605 'sanitize_callback' => 'sanitize_text_field'
606 ),
607 array(
608 'name' => 'order',
609 'label' => __( 'Order Videos by', 'automatic-youtube-gallery' ),
610 'description' => '',
611 'type' => 'select',
612 'options' => array(
613 'date' => __( 'Date', 'automatic-youtube-gallery' ),
614 'rating' => __( 'Rating', 'automatic-youtube-gallery' ),
615 'relevance' => __( 'Relevance', 'automatic-youtube-gallery' ),
616 'title' => __( 'Title', 'automatic-youtube-gallery' ),
617 'viewCount' => __( 'View Count', 'automatic-youtube-gallery' )
618 ),
619 'value' => 'relevance',
620 'sanitize_callback' => 'sanitize_key'
621 ),
622 array(
623 'name' => 'limit',
624 'label' => __( 'Number of Videos', 'automatic-youtube-gallery' ),
625 'description' => __( 'Specifies the maximum number of videos that will appear in this gallery. Set to 0 for the maximum amount (500).', 'automatic-youtube-gallery' ),
626 'type' => 'number',
627 'min' => 0,
628 'max' => 500,
629 'value' => 0,
630 'sanitize_callback' => 'intval'
631 ),
632 array(
633 'name' => 'cache',
634 'label' => __( 'Cache Duration', 'automatic-youtube-gallery' ),
635 'description' => __( 'Specifies how frequently we should check your YouTube source for new videos/updates.', 'automatic-youtube-gallery' ),
636 'type' => 'select',
637 'options' => array(
638 '0' => ''. __( 'No Caching', 'automatic-youtube-gallery' ) . '',
639 '900' => __( '15 Minutes', 'automatic-youtube-gallery' ),
640 '1800' => __( '30 Minutes', 'automatic-youtube-gallery' ),
641 '3600' => __( '1 Hour', 'automatic-youtube-gallery' ),
642 '86400' => __( '1 Day', 'automatic-youtube-gallery' ),
643 '604800' => __( '1 Week', 'automatic-youtube-gallery' ),
644 '2419200' => __( '1 Month', 'automatic-youtube-gallery' )
645 ),
646 'value' => 86400,
647 'sanitize_callback' => 'intval'
648 )
649 )
650 ),
651 'gallery' => array(
652 'label' => __( 'Gallery (optional)', 'automatic-youtube-gallery' ),
653 'fields' => ayg_get_gallery_settings_fields()
654 ),
655 'player' => array(
656 'label' => __( 'Player (optional)', 'automatic-youtube-gallery' ),
657 'fields' => ayg_get_player_settings_fields()
658 ),
659 'search' => array(
660 'label' => __( 'Search Form (optional)', 'automatic-youtube-gallery' ),
661 'fields' => array(
662 array(
663 'name' => 'search_form',
664 'label' => __( 'Search Form', 'automatic-youtube-gallery' ),
665 'description' => sprintf(
666 __( 'Check this option to enable the search form. Having issues? <a href="%s" target="_blank" rel="noopener noreferrer">Check here</a>.', 'automatic-youtube-gallery' ),
667 'https://plugins360.com/automatic-youtube-gallery/searchform/'
668 ),
669 'type' => 'checkbox',
670 'value' => 0,
671 'sanitize_callback' => 'intval'
672 )
673 )
674 )
675 );
676
677 return apply_filters( 'ayg_editor_fields', $fields );
678 }
679
680 /**
681 * Get gallery settings fields.
682 *
683 * @since 1.0.0
684 * @return array $fields Array of fields.
685 */
686 function ayg_get_gallery_settings_fields() {
687 $gallery_settings = ayg_get_option( 'ayg_gallery_settings' );
688
689 $fields = array(
690 array(
691 'name' => 'theme',
692 'label' => __( 'Select Theme (Layout)', 'automatic-youtube-gallery' ),
693 'description' => ( ayg_fs()->is_not_paying() ? sprintf( __( '<a href="%s">Upgrade Pro</a> for more themes (Popup, Inline, Slider, Playlist).', 'automatic-youtube-gallery' ), esc_url( ayg_fs()->get_upgrade_url() ) ) : '' ),
694 'type' => 'select',
695 'options' => array(
696 'classic' => __( 'Classic', 'automatic-youtube-gallery' )
697 ),
698 'value' => $gallery_settings['theme'],
699 'sanitize_callback' => 'sanitize_key'
700 ),
701 array(
702 'name' => 'columns',
703 'label' => __( 'Columns', 'automatic-youtube-gallery' ),
704 'description' => __( 'Enter the number of columns you like to have in the gallery. Maximum of 12.', 'automatic-youtube-gallery' ),
705 'type' => 'number',
706 'min' => 0,
707 'max' => 12,
708 'value' => $gallery_settings['columns'],
709 'sanitize_callback' => 'intval'
710 ),
711 array(
712 'name' => 'per_page',
713 'label' => __( 'Videos per Page', 'automatic-youtube-gallery' ),
714 'description' => __( 'Enter the number of videos to show per page. Maximum of 50.', 'automatic-youtube-gallery' ),
715 'type' => 'number',
716 'min' => 0,
717 'max' => 50,
718 'value' => $gallery_settings['per_page'],
719 'sanitize_callback' => 'intval'
720 ),
721 array(
722 'name' => 'thumb_ratio',
723 'label' => __( 'Image Height (Ratio)', 'automatic-youtube-gallery' ),
724 'description' => __( 'Select the ratio value used to calculate the image height in the gallery thumbnails.', 'automatic-youtube-gallery' ),
725 'type' => 'select',
726 'options' => array(
727 '56.25' => __( 'Standard (16:9) — Default', 'automatic-youtube-gallery' ),
728 '177.78' => __( 'Shorts / Vertical (9:16)', 'automatic-youtube-gallery' ),
729 '75' => __( 'Classic (4:3)', 'automatic-youtube-gallery' )
730 ),
731 'value' => $gallery_settings['thumb_ratio'],
732 'sanitize_callback' => 'floatval'
733 ),
734 array(
735 'name' => 'thumb_title',
736 'label' => __( 'Show Video Title', 'automatic-youtube-gallery' ),
737 'description' => __( 'Check this option to show the video title in each gallery item.', 'automatic-youtube-gallery' ),
738 'type' => 'checkbox',
739 'value' => $gallery_settings['thumb_title'],
740 'sanitize_callback' => 'intval'
741 ),
742 array(
743 'name' => 'thumb_title_length',
744 'label' => __( 'Video Title Length', 'automatic-youtube-gallery' ),
745 'description' => __( 'Enter the number of characters you like to show in the title. Set 0 to show the whole title.', 'automatic-youtube-gallery' ),
746 'type' => 'number',
747 'min' => 0,
748 'max' => 500,
749 'value' => $gallery_settings['thumb_title_length'],
750 'sanitize_callback' => 'intval'
751 ),
752 array(
753 'name' => 'thumb_excerpt',
754 'label' => __( 'Show Video Excerpt (Short Description)', 'automatic-youtube-gallery' ),
755 'description' => __( 'Check this option to show the short description of a video in each gallery item.', 'automatic-youtube-gallery' ),
756 'type' => 'checkbox',
757 'value' => $gallery_settings['thumb_excerpt'],
758 'sanitize_callback' => 'intval'
759 ),
760 array(
761 'name' => 'thumb_excerpt_length',
762 'label' => __( 'Video Excerpt Length', 'automatic-youtube-gallery' ),
763 'description' => __( 'Enter the number of characters you like to have in the video excerpt. Set 0 to show the whole description.', 'automatic-youtube-gallery' ),
764 'type' => 'number',
765 'min' => 0,
766 'max' => 500,
767 'value' => $gallery_settings['thumb_excerpt_length'],
768 'sanitize_callback' => 'intval'
769 ),
770 array(
771 'name' => 'pagination',
772 'label' => __( 'Pagination', 'automatic-youtube-gallery' ),
773 'description' => __( 'Check this option to show the pagination.', 'automatic-youtube-gallery' ),
774 'type' => 'checkbox',
775 'value' => $gallery_settings['pagination'],
776 'sanitize_callback' => 'intval'
777 ),
778 array(
779 'name' => 'pagination_type',
780 'label' => __( 'Pagination Type', 'automatic-youtube-gallery' ),
781 'type' => 'select',
782 'options' => array(
783 'more' => __( 'More Button', 'automatic-youtube-gallery' ),
784 'pager' => __( 'Pager', 'automatic-youtube-gallery' )
785
786 ),
787 'value' => $gallery_settings['pagination_type'],
788 'sanitize_callback' => 'sanitize_key'
789 )
790 );
791
792 return apply_filters( 'ayg_gallery_settings_fields', $fields );
793 }
794
795 /**
796 * Retrieve a plugin option with fallback to default settings.
797 *
798 * @since 2.7.0
799 * @param string $option The option name to retrieve.
800 * @return mixed
801 */
802 function ayg_get_option( $option ) {
803 $defaults = ayg_get_default_settings();
804 $default = isset( $defaults[ $option ] ) ? $defaults[ $option ] : array();
805
806 $saved = get_option( $option, null );
807
808 // Option does not exist OR corrupted
809 if ( null === $saved || ! is_array( $saved ) ) {
810 return $default;
811 }
812
813 // Merge saved values with defaults
814 return wp_parse_args( $saved, $default );
815 }
816
817 /**
818 * Get video description to show on top of the player.
819 *
820 * @since 1.0.0
821 * @param stdClass $video YouTube video object.
822 * @param array $attributes Array of user attributes.
823 * @param int $words_count Number of words to show by default.
824 * @return string Video description.
825 */
826 function ayg_get_player_description( $video, $attributes = array(), $words_count = 30 ) {
827 $description = $video->description;
828
829 $words_array = explode( ' ', strip_tags( $description ) );
830 if ( count( $words_array ) > $words_count ) {
831 $show_more_label = ! empty( $attributes['show_more_label'] ) ? $attributes['show_more_label'] : __( 'Show More', 'automatic-youtube-gallery' );
832 $words_array[ $words_count ] = '<span class="ayg-player-description-dots">...</span></span><span class="ayg-player-description-more">' . $words_array[ $words_count ];
833
834 $description = '<span class="ayg-player-description-less">' . implode( ' ', $words_array ) . '</span>';
835 $description .= '<a href="#" class="ayg-player-description-toggle-btn">' . esc_html( $show_more_label ) . '</a>';
836 }
837
838 $description = nl2br( $description );
839 $description = make_clickable( $description );
840
841 return apply_filters( 'ayg_player_description', $description, $video, $attributes, $words_count );
842 }
843
844 /**
845 * Get player settings fields.
846 *
847 * @since 1.0.0
848 * @return array $fields Array of fields.
849 */
850 function ayg_get_player_settings_fields() {
851 $player_settings = ayg_get_option( 'ayg_player_settings' );
852
853 $fields = array(
854 array(
855 'name' => 'player_width',
856 'label' => __( 'Player Width', 'automatic-youtube-gallery' ),
857 'description' => __( 'In pixels. Maximum width of the player. Leave this field empty to scale 100% of its enclosing container/html element.', 'automatic-youtube-gallery' ),
858 'type' => 'text',
859 'value' => isset( $player_settings['player_width'] ) ? $player_settings['player_width'] : '',
860 'sanitize_callback' => 'ayg_sanitize_int'
861 ),
862 array(
863 'name' => 'player_ratio',
864 'label' => __( 'Player Height (Ratio)', 'automatic-youtube-gallery' ),
865 'description' => __( 'Select the ratio value used to calculate the player height.', 'automatic-youtube-gallery' ),
866 'type' => 'select',
867 'options' => array(
868 '56.25' => __( 'Standard (16:9) — Default', 'automatic-youtube-gallery' ),
869 '177.78' => __( 'Shorts / Vertical (9:16)', 'automatic-youtube-gallery' ),
870 '75' => __( 'Classic (4:3)', 'automatic-youtube-gallery' )
871 ),
872 'value' => $player_settings['player_ratio'],
873 'sanitize_callback' => 'floatval'
874 ),
875 array(
876 'name' => 'player_title',
877 'label' => __( 'Show Video Title', 'automatic-youtube-gallery' ),
878 'description' => __( 'Check this option to show the current playing video title on the bottom of the player.', 'automatic-youtube-gallery' ),
879 'type' => 'checkbox',
880 'value' => $player_settings['player_title'],
881 'sanitize_callback' => 'intval'
882 ),
883 array(
884 'name' => 'player_description',
885 'label' => __( 'Show Video Description', 'automatic-youtube-gallery' ),
886 'description' => __( 'Check this option to show the current playing video description on the bottom of the player.', 'automatic-youtube-gallery' ),
887 'type' => 'checkbox',
888 'value' => $player_settings['player_description'],
889 'sanitize_callback' => 'intval'
890 ),
891 array(
892 'name' => 'autoplay',
893 'label' => __( 'Autoplay', 'automatic-youtube-gallery' ),
894 'description' => __( 'Specifies whether the initial video will automatically start to play when the player loads.', 'automatic-youtube-gallery' ),
895 'type' => 'checkbox',
896 'value' => $player_settings['autoplay'],
897 'sanitize_callback' => 'intval'
898 ),
899 array(
900 'name' => 'autoadvance',
901 'label' => __( 'Autoplay Next Video', 'automatic-youtube-gallery' ),
902 'description' => __( 'Specifies whether to play the next video in the list automatically after previous one end.', 'automatic-youtube-gallery' ),
903 'type' => 'checkbox',
904 'value' => $player_settings['autoadvance'],
905 'sanitize_callback' => 'intval'
906 ),
907 array(
908 'name' => 'loop',
909 'label' => __( 'Loop', 'automatic-youtube-gallery' ),
910 'description' => __( 'In the case of a single video player, plays the initial video again and again. In the case of a gallery, plays the entire list in the gallery and then starts again at the first video.', 'automatic-youtube-gallery' ),
911 'type' => 'checkbox',
912 'value' => $player_settings['loop'],
913 'sanitize_callback' => 'intval'
914 ),
915 array(
916 'name' => 'muted',
917 'label' => __( 'Muted', 'automatic-youtube-gallery' ),
918 'description' => __( 'Check this option to turn OFF the audio output of the video by default.', 'automatic-youtube-gallery' ),
919 'type' => 'checkbox',
920 'value' => isset( $player_settings['muted'] ) ? $player_settings['muted'] : 0,
921 'sanitize_callback' => 'intval'
922 ),
923 array(
924 'name' => 'controls',
925 'label' => __( 'Show Player Controls', 'automatic-youtube-gallery' ),
926 'description' => __( 'Uncheck this option to hide the video player controls.', 'automatic-youtube-gallery' ),
927 'type' => 'checkbox',
928 'value' => $player_settings['controls'],
929 'sanitize_callback' => 'intval'
930 ),
931 array(
932 'name' => 'modestbranding',
933 'label' => __( 'Hide YouTube Logo', 'automatic-youtube-gallery' ),
934 'description' => __( "Lets you prevent the YouTube logo from displaying in the control bar. Note that a small YouTube text label will still display in the upper-right corner of a paused video when the user's mouse pointer hovers over the player.", 'automatic-youtube-gallery' ),
935 'type' => 'checkbox',
936 'value' => $player_settings['modestbranding'],
937 'sanitize_callback' => 'intval'
938 ),
939 array(
940 'name' => 'cc_load_policy',
941 'label' => __( 'Force Closed Captions', 'automatic-youtube-gallery' ),
942 'description' => __( 'Show captions by default, even if the user has turned captions off. The default behavior is based on user preference.', 'automatic-youtube-gallery' ),
943 'type' => 'checkbox',
944 'value' => $player_settings['cc_load_policy'],
945 'sanitize_callback' => 'intval'
946 ),
947 array(
948 'name' => 'iv_load_policy',
949 'label' => __( 'Show Annotations', 'automatic-youtube-gallery' ),
950 'description' => __( 'Choose whether to show annotations or not.', 'automatic-youtube-gallery' ),
951 'type' => 'checkbox',
952 'value' => $player_settings['iv_load_policy'],
953 'sanitize_callback' => 'intval'
954 ),
955 array(
956 'name' => 'hl',
957 'label' => __( 'Player Language', 'automatic-youtube-gallery' ),
958 'description' => sprintf(
959 __( 'Specifies the player\'s interface language. Set the field\'s value to an <a href="%s" target="_blank">ISO 639-1 two-letter language code.</a>', 'automatic-youtube-gallery' ),
960 'http://www.loc.gov/standards/iso639-2/php/code_list.php'
961 ),
962 'type' => 'text',
963 'value' => $player_settings['hl'],
964 'sanitize_callback' => 'sanitize_text_field'
965 ),
966 array(
967 'name' => 'cc_lang_pref',
968 'label' => __( 'Default Captions Language', 'automatic-youtube-gallery' ),
969 'description' => sprintf(
970 __( 'Specifies the default language that the player will use to display captions. Set the field\'s value to an <a href="%s" target="_blank">ISO 639-1 two-letter language code.</a>', 'automatic-youtube-gallery' ),
971 'http://www.loc.gov/standards/iso639-2/php/code_list.php'
972 ),
973 'type' => 'text',
974 'value' => $player_settings['cc_lang_pref'],
975 'sanitize_callback' => 'sanitize_text_field'
976 )
977 );
978
979 return $fields;
980 }
981
982
983 /**
984 * Get a single video page URL.
985 *
986 * @since 2.1.0
987 * @param stdClass $video YouTube video object.
988 * @param array $args An array of gallery options.
989 * @return string Single video URL.
990 */
991 function ayg_get_single_video_url( $video, $attributes ) {
992 return apply_filters( 'ayg_single_video_url', '', $video, $attributes );
993 }
994
995 /**
996 * Get filtered php template file path.
997 *
998 * @since 1.0.0
999 * @param array $template PHP file path.
1000 * @param string $theme Automatic YouTube Gallery Theme.
1001 * @return string Filtered file path.
1002 */
1003 function ayg_get_template( $template, $theme = '' ) {
1004 return apply_filters( 'ayg_load_template', $template, $theme );
1005 }
1006
1007 /**
1008 * Get unique ID.
1009 *
1010 * @since 1.0.0
1011 * @return string Unique ID.
1012 */
1013 function ayg_get_uniqid() {
1014 global $ayg_uniqid;
1015
1016 if ( ! $ayg_uniqid ) {
1017 $ayg_uniqid = 0;
1018 }
1019
1020 return uniqid() . ++$ayg_uniqid;
1021 }
1022
1023 /**
1024 * Get YouTube domain.
1025 *
1026 * @since 2.3.0
1027 * @return string YouTube embed domain.
1028 */
1029 function ayg_get_youtube_domain() {
1030 $player_settings = ayg_get_option( 'ayg_player_settings' );
1031
1032 $domain = 'https://www.youtube.com';
1033 if ( isset( $player_settings['privacy_enhanced_mode'] ) && ! empty( $player_settings['privacy_enhanced_mode'] ) ) {
1034 $domain = 'https://www.youtube-nocookie.com';
1035 }
1036
1037 return $domain;
1038 }
1039
1040 /**
1041 * Get the YouTube embed URL.
1042 *
1043 * @since 2.5.0
1044 * @param string $video_id YouTube video ID.
1045 * @param array $attributes Array of user attributes.
1046 * @return string Player embed URL.
1047 */
1048 function ayg_get_youtube_embed_url( $video_id, $attributes = array() ) {
1049 $player_settings = ayg_get_option( 'ayg_player_settings' );
1050
1051 $player_website = 'https://www.youtube.com';
1052 if ( isset( $player_settings['privacy_enhanced_mode'] ) && ! empty( $player_settings['privacy_enhanced_mode'] ) ) {
1053 $player_website = 'https://www.youtube-nocookie.com';
1054 }
1055
1056 if ( empty( $video_id ) ) {
1057 return '';
1058 }
1059
1060 $url = $player_website . '/embed/' . $video_id . '?enablejsapi=1&playsinline=1&rel=0';
1061
1062 if ( isset( $player_settings['origin'] ) && ! empty( $player_settings['origin'] ) ) {
1063 $site_url_parts = parse_url( site_url() );
1064 $origin = $site_url_parts['scheme'] . '://' . $site_url_parts['host'];
1065
1066 $url = add_query_arg( 'origin', $origin, $url );
1067 }
1068
1069 if ( ! is_array( $attributes ) ) {
1070 $attributes = (array) $attributes;
1071 }
1072
1073 $autoplay = isset( $attributes['autoplay'] ) ? (int) $attributes['autoplay'] : 0;
1074 if ( 1 == $autoplay ) {
1075 $url = add_query_arg( 'autoplay', 1, $url );
1076 }
1077
1078 $loop = isset( $attributes['loop'] ) ? (int) $attributes['loop'] : 0;
1079 if ( 1 == $loop ) {
1080 $url = add_query_arg( 'playlist', $video_id, $url );
1081 $url = add_query_arg( 'loop', 1, $url );
1082 }
1083
1084 $muted = isset( $attributes['muted'] ) ? (int) $attributes['muted'] : 0;
1085 if ( 1 == $muted ) {
1086 $url = add_query_arg( 'mute', 1, $url );
1087 }
1088
1089 $controls = isset( $attributes['controls'] ) ? (int) $attributes['controls'] : 1;
1090 if ( 0 == $controls ) {
1091 $url = add_query_arg( 'controls', 0, $url );
1092 }
1093
1094 $modestbranding = isset( $attributes['modestbranding'] ) ? (int) $attributes['modestbranding'] : 0;
1095 if ( 1 == $modestbranding ) {
1096 $url = add_query_arg( 'modestbranding', 1, $url );
1097 }
1098
1099 $cc_load_policy = isset( $attributes['cc_load_policy'] ) ? (int) $attributes['cc_load_policy'] : 0;
1100 if ( 1 == $cc_load_policy ) {
1101 $url = add_query_arg( 'cc_load_policy', 1, $url );
1102 }
1103
1104 $iv_load_policy = isset( $attributes['iv_load_policy'] ) ? (int) $attributes['iv_load_policy'] : 0;
1105 if ( 0 == $iv_load_policy ) {
1106 $url = add_query_arg( 'iv_load_policy', 3, $url );
1107 }
1108
1109 if ( isset( $attributes['hl'] ) && ! empty( $attributes['hl'] ) ) {
1110 $url = add_query_arg( 'hl', sanitize_text_field( $attributes['hl'] ), $url );
1111 }
1112
1113 if ( isset( $attributes['cc_lang_pref'] ) && ! empty( $attributes['cc_lang_pref'] ) ) {
1114 $url = add_query_arg( 'cc_lang_pref', sanitize_text_field( $attributes['cc_lang_pref'] ), $url );
1115 }
1116
1117 return apply_filters( 'ayg_youtube_embed_url', $url, $video_id, $attributes );
1118 }
1119
1120 /**
1121 * Inserts a new associative array after another associative array key.
1122 *
1123 * @since 2.1.0
1124 * @param string $key The associative array key to insert after.
1125 * @param array $array An array to insert in to.
1126 * @param array $new_array An array to insert.
1127 * @return array Updated array.
1128 */
1129 function ayg_insert_array_after( $key, $array, $new_array ) {
1130 if ( array_key_exists( $key, $array ) ) {
1131 $new = array();
1132
1133 foreach ( $array as $k => $value ) {
1134 $new[ $k ] = $value;
1135
1136 if ( $k === $key ) {
1137 foreach ( $new_array as $new_key => $new_value ) {
1138 $new[ $new_key ] = $new_value;
1139 }
1140 }
1141 }
1142
1143 return $new;
1144 }
1145
1146 return $array;
1147 }
1148
1149 /**
1150 * Detect if the client is using an iOS device (iPhone, iPad, or iPod).
1151 *
1152 * @return bool True if the user agent string suggests an iOS device, false otherwise.
1153 */
1154 function ayg_is_ios() {
1155 if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
1156 return false;
1157 }
1158
1159 $ua = strtolower( $_SERVER['HTTP_USER_AGENT'] );
1160
1161 if (
1162 strpos( $ua, 'iphone' ) !== false ||
1163 strpos( $ua, 'ipad' ) !== false ||
1164 strpos( $ua, 'ipod' ) !== false
1165 ) {
1166 return true;
1167 }
1168
1169 return false;
1170 }
1171
1172 /**
1173 * Sanitize the array inputs.
1174 *
1175 * @since 2.7.0
1176 * @param array $value Input array.
1177 * @return array Sanitized array.
1178 */
1179 function ayg_sanitize_array( $value ) {
1180 return ! empty( $value ) ? array_map( 'sanitize_text_field', $value ) : array();
1181 }
1182
1183 /**
1184 * Sanitize the integer inputs, accepts empty values.
1185 *
1186 * @since 1.0.0
1187 * @param string|int $value Input value.
1188 * @return string|int Sanitized value.
1189 */
1190 function ayg_sanitize_int( $value ) {
1191 $value = intval( $value );
1192 return ( 0 == $value ) ? '' : $value;
1193 }
1194
1195 /**
1196 * Trims text to a certain number of characters.
1197 *
1198 * @since 2.0.0
1199 * @param string $text Text to trim.
1200 * @param int $num_characters Number of characters.
1201 * @param string $append String to append to the end of the excerpt.
1202 * @return string Trimmed text.
1203 */
1204 function ayg_trim_words( $text, $num_characters, $append = '...' ) {
1205 $num_characters++;
1206
1207 $original_text = $text;
1208 $text = ( $num_characters > 1 ) ? wp_strip_all_tags( $original_text, true ) : nl2br( $original_text );
1209
1210 if ( $num_characters > 1 && mb_strlen( $text ) > $num_characters ) {
1211 $subex = mb_substr( $text, 0, $num_characters - 5 );
1212 $exwords = explode( ' ', $subex );
1213 $excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
1214
1215 if ( $excut < 0 ) {
1216 $text = mb_substr( $subex, 0, $excut );
1217 } else {
1218 $text = $subex;
1219 }
1220
1221 $text .= $append;
1222 }
1223
1224 return apply_filters( 'ayg_trim_words', $text, $original_text, $num_characters, $append );
1225 }
1226
1227 /**
1228 * Gallery HTML output.
1229 *
1230 * @since 1.0.0
1231 * @param array $video YouTube video object.
1232 * @param array $attributes Array of user attributes.
1233 */
1234 function the_ayg_gallery_thumbnail( $video, $attributes ) {
1235 include ayg_get_template( AYG_DIR . 'public/templates/thumbnail.php' );
1236 }
1237
1238 /**
1239 * Pagination HTML output.
1240 *
1241 * @since 1.0.0
1242 * @param array $attributes Array of user attributes.
1243 */
1244 function the_ayg_pagination( $attributes ) {
1245 if ( ! empty( $attributes['pagination'] ) ) {
1246 include ayg_get_template( AYG_DIR . 'public/templates/pagination.php' );
1247 }
1248 }
1249
1250 /**
1251 * Search Form HTML output.
1252 *
1253 * @since 2.5.7
1254 * @param array $attributes Array of user attributes.
1255 */
1256 function the_ayg_search_form( $attributes ) {
1257 if ( ! empty( $attributes['search_form'] ) ) {
1258 include ayg_get_template( AYG_DIR . 'public/templates/search-form.php' );
1259 }
1260 }
1261
1262 /**
1263 * Gallery HTML output.
1264 *
1265 * @since 2.5.0
1266 * @param array $video YouTube video object.
1267 * @param array $attributes Array of user attributes.
1268 */
1269 function the_ayg_player( $video, $attributes ) {
1270 include ayg_get_template( AYG_DIR . 'public/templates/player.php' );
1271 }