(.*?)<\/select>/s', '
$2
', $dropdown_list ); // Output $html = '
'; $html .= sprintf( '', esc_attr( $input_placeholder ) ); $html .= ''; $html .= '
'; if ( $echo ) { echo $html; } else { return $html; } } /** * Get the category breadcrumbs. * * @since 3.8.4 * @param object $term The current term object. * @return string Category breadcrumbs. */ function aiovg_get_category_breadcrumbs( $term = null ) { $page_settings = aiovg_get_option( 'aiovg_page_settings' ); $id = $page_settings['category']; if ( empty( $id ) ) return ''; $crumbs = array(); // Home Page $crumbs[] = array( 'text' => __( 'Home', 'all-in-one-video-gallery' ), 'url' => home_url() ); // Single Category Page if ( $term ) { // Include the main categories page $post = get_post( $id ); $crumbs[] = array( 'text' => $post->post_title, 'url' => get_permalink( $id ) ); // Include the parent categories if available if ( $ancestors = get_ancestors( $term->term_id, 'aiovg_categories' ) ) { $ancestors = array_reverse( $ancestors ); foreach ( $ancestors as $term_id ) { if ( $parent_term = get_term_by( 'term_id', $term_id, 'aiovg_categories' ) ) { $crumbs[] = array( 'text' => $parent_term->name, 'url' => aiovg_get_category_page_url( $parent_term ) ); } } } // Include the current category page $crumbs[] = array( 'text' => $term->name ); } else { // Include the main categories page $post = get_post( $id ); $crumbs[] = array( 'text' => $post->post_title ); } // Output $html = ''; $crumbs = apply_filters( 'aiovg_breadcrumb_links', $crumbs, $term, 'aiovg_categories' ); if ( ! empty( $crumbs ) ) { $links = array(); foreach ( $crumbs as $crumb ) { if ( isset( $crumb['url'] ) ) { $links[] = sprintf( '%s', esc_url( $crumb['url'] ), wp_kses_post( $crumb['text'] ) ); } else { $links[] = sprintf( '%s', wp_kses_post( $crumb['text'] ) ); } } $separator = apply_filters( 'aiovg_breadcrumb_separator', ' ยป ' ); $html = '

' . implode( $separator, $links ) . '

'; } return $html; } /** * Get the like / dislike button. * * @since 3.6.1 * @param int $post_id Video post ID. * @return string HTML string. */ function aiovg_get_like_button( $post_id ) { $attributes = array(); $attributes[] = sprintf( 'post_id="%d"', $post_id ); $likes = (int) get_post_meta( $post_id, 'likes', true ); $attributes[] = sprintf( 'likes="%d"', $likes ); $dislikes = (int) get_post_meta( $post_id, 'dislikes', true ); $attributes[] = sprintf( 'dislikes="%d"', $dislikes ); $user_id = get_current_user_id(); if ( $user_id > 0 ) { $liked = (array) get_user_meta( $user_id, 'aiovg_videos_likes' ); $disliked = (array) get_user_meta( $user_id, 'aiovg_videos_dislikes' ); } else { $likes_settings = aiovg_get_option( 'aiovg_likes_settings' ); $liked = array(); $disliked = array(); if ( empty( $likes_settings['login_required_to_vote'] ) ) { if ( isset( $_COOKIE['aiovg_videos_likes'] ) ) { $liked = explode( '|', $_COOKIE['aiovg_videos_likes'] ); $liked = array_map( 'intval', $liked ); } if ( isset( $_COOKIE['aiovg_videos_dislikes'] ) ) { $disliked = explode( '|', $_COOKIE['aiovg_videos_dislikes'] ); $disliked = array_map( 'intval', $disliked ); } } } if ( in_array( $post_id, $liked ) ) { $attributes[] = 'liked'; } elseif ( in_array( $post_id, $disliked ) ) { $attributes[] = 'disliked'; } $attributes[] = 'loaded'; // Return return sprintf( '', implode( ' ', $attributes ) ); } /** * Get player HTML. * * @since 1.0.0 * @param int $post_id Post ID. * @param array $atts Player configuration data. * @return string $html Player HTML. */ function aiovg_get_player_html( $post_id = 0, $atts = array() ) { $player = AIOVG_Player::get_instance(); return $player->create( $post_id, $atts ); } /** * Wraps the shortcode output HTML string with filters. * * @since 4.0.1 * @param string $content Default shortcode HTML output (the gallery itself). * @param array $attributes An associative array of shortcode attributes. * @return string Combined output of filters + gallery. */ function aiovg_wrap_with_filters( $content, $attributes ) { if ( empty( $attributes['filters_keyword'] ) && empty( $attributes['filters_category'] ) && empty( $attributes['filters_tag'] ) && empty( $attributes['filters_sort'] ) ) { return $content; } $json_params = aiovg_prepare_attributes_for_ajax( $attributes ); $attributes['template'] = sanitize_text_field( $attributes['filters_template'] ); $attributes['has_keyword'] = (int) $attributes['filters_keyword']; $attributes['has_category'] = (int) $attributes['filters_category']; $attributes['has_tag'] = (int) $attributes['filters_tag']; $attributes['has_sort'] = (int) $attributes['filters_sort']; $attributes['has_search_button'] = ( 'search' == $attributes['filters_mode'] ) ? 1 : 0; $attributes['has_reset_button'] = (int) $attributes['filters_reset_button']; $attributes['target'] = 'current'; $attributes['categories_selected'] = $attributes['category']; $attributes['tags_selected'] = $attributes['tag']; // Auto-switch to "compact" template if only the keyword field is shown if ( empty( $attributes['has_category'] ) && empty( $attributes['has_tag'] ) && empty( $attributes['has_sort'] ) ) { $attributes['template'] = 'compact'; } // Current page ID, useful for search form target $attributes['search_page_id'] = aiovg_get_current_page_id(); // Enqueue dependencies wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-public' ); if ( 'search' != $attributes['filters_mode'] ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-search' ); } if ( ! empty( $attributes['has_category'] ) || ! empty( $attributes['has_tag'] ) ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-select' ); } if ( ! empty( $attributes['show_pagination'] ) || ! empty( $attributes['show_more'] ) ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-pagination' ); } // Capture filter form output ob_start(); include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . 'public/templates/search-form-template-' . sanitize_file_name( $attributes['template'] ) . '.php', $attributes ); $filters = ob_get_clean(); // Now load the combined layout (filters + videos) $data_params = ( 'ajax' == $attributes['filters_mode'] ) ? wp_json_encode( $json_params ) : ''; $html = sprintf( '
', esc_attr( $attributes['filters_position'] ), esc_attr( $data_params ) ); if ( 'ajax' == $attributes['filters_mode'] ) { $html .= ''; } $html .= $filters; $html .= $content; $html .= '
'; return $html; } /** * Category thumbnail HTML output. * * @since 1.5.7 * @param WP_Term $term WP term object. * @param array $atts Array of attributes. */ function the_aiovg_category_thumbnail( $term, $attributes ) { include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . 'public/templates/category-thumbnail.php', $attributes ); } /** * Add content after player. * * @since 3.6.1 * @param int $post_id Video post ID. * @param array $attributes Array of attributes. */ function the_aiovg_content_after_player( $post_id, $attributes ) { $post_id = (int) $post_id; $content = ''; if ( ! empty( $attributes['show_player_like_button'] ) ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-likes' ); $content .= aiovg_get_like_button( $post_id ); } if ( ! empty( $attributes['show_player_comment_button'] ) ) { $content .= ''; if ( comments_open( $post_id ) ) { $icon = ' '; $content .= sprintf( '', esc_url( get_comments_link( $post_id ) ), $icon, esc_html__( 'Leave a Comment', 'all-in-one-video-gallery' ) ); } $content .= ''; } $content = apply_filters( 'aiovg_content_after_player', $content, $post_id, $attributes ); if ( ! empty( $content ) ) { echo '
'; echo $content; echo '
'; } } /** * Add content after thumbnail. * * @since 3.6.1 * @param array $attributes Array of attributes. */ function the_aiovg_content_after_thumbnail( $attributes ) { $content = apply_filters( 'aiovg_content_after_thumbnail', '', $attributes ); if ( ! empty( $content ) ) { echo '
'; echo $content; echo '
'; } } /** * Add content after thumbnail image. * * @since 4.3.7 * @param array $attributes Array of attributes. */ function the_aiovg_content_after_thumbnail_image( $attributes ) { $content = apply_filters( 'aiovg_content_after_thumbnail_image', '', $attributes ); if ( ! empty( $content ) ) { echo $content; } } /** * Display the video excerpt. * * @since 1.0.0 * @param int $char_length Excerpt length. */ function the_aiovg_excerpt( $char_length ) { $excerpt = aiovg_get_excerpt( 0, $char_length ); if ( ! empty( $excerpt ) ) { $excerpt = wp_kses_post( $excerpt ); $excerpt = do_shortcode( $excerpt ); } echo $excerpt; } /** * Display more button on gallery pages. * * @since 2.5.1 * @param int $numpages The total amount of pages. * @param array $atts Array of attributes. */ function the_aiovg_more_button( $numpages = '', $atts = array() ) { if ( empty( $numpages ) ) { $numpages = 1; } $paged = 1; if ( isset( $atts['paged'] ) ) { $paged = (int) $atts['paged']; } if ( empty( $atts['more_link'] ) ) { // Ajax if ( $paged < $numpages ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-pagination' ); $json_params = aiovg_prepare_attributes_for_ajax( $atts ); echo sprintf( '', esc_attr( wp_json_encode( $json_params ) ) ); echo sprintf( '', $numpages, $paged, esc_html( $atts['more_label'] ) ); echo ''; } } else { echo ''; echo sprintf( '', esc_url( $atts['more_link'] ), esc_html( $atts['more_label'] ) ); echo ''; } } /** * Display paginated links on gallery pages. * * @since 1.0.0 * @param int $numpages The total amount of pages. * @param int $pagerange How many numbers to either side of current page. * @param int $paged The current page number. * @param array $atts Array of attributes. */ function the_aiovg_pagination( $numpages = '', $pagerange = '', $paged = '', $atts = array() ) { if ( empty( $numpages ) ) { $numpages = 1; } if ( empty( $pagerange ) ) { $pagination_settings = aiovg_get_option( 'aiovg_pagination_settings' ); $pagerange = isset( $pagination_settings['mid_size'] ) ? (int) $pagination_settings['mid_size'] : 2; if ( empty( $pagerange ) ) { $pagerange = 2; } } if ( empty( $paged ) ) { $paged = aiovg_get_page_number(); } // Construct the pagination arguments to enter into our paginate_links function $arr_params = array(); parse_str( $_SERVER['QUERY_STRING'], $queries ); if ( ! empty( $queries ) ) { $arr_params = array_keys( $queries ); } $base = aiovg_remove_query_arg( $arr_params, get_pagenum_link( 1 ) ); if ( ! get_option( 'permalink_structure' ) || isset( $_GET['aiovg'] ) ) { $prefix = strpos( $base, '?' ) ? '&' : '?'; $format = $prefix . 'paged=%#%'; } else { $prefix = ( '/' == substr( $base, -1 ) ) ? '' : '/'; $format = $prefix . 'page/%#%'; } $pagination_args = array( 'base' => $base . '%_%', 'format' => $format, 'total' => $numpages, 'current' => $paged, 'show_all' => false, 'end_size' => 1, 'mid_size' => $pagerange, 'prev_next' => true, 'prev_text' => __( '«', 'all-in-one-video-gallery' ), 'next_text' => __( '»', 'all-in-one-video-gallery' ), 'type' => 'array', 'add_args' => false, 'add_fragment' => '' ); $pagination_args = apply_filters( 'aiovg_pagination_args', $pagination_args, $numpages, $pagerange, $paged, $atts ); $paginate_links = paginate_links( $pagination_args ); if ( is_array( $paginate_links ) ) { $is_ajax = isset( $atts['pagination_ajax'] ) && ! empty( $atts['pagination_ajax'] ); if ( $is_ajax ) { wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-pagination' ); $json_params = aiovg_prepare_attributes_for_ajax( $atts ); printf( '', esc_attr( wp_json_encode( $json_params ) ), $paged ); } else { echo ''; } echo ''; echo '
'; echo sprintf( __( 'Page %d of %d', 'all-in-one-video-gallery' ), $paged, $numpages ); echo '
'; echo '
'; } } /** * Display a notice if PHP limits are below recommended values. * * @since 4.5.2 */ function the_aiovg_php_server_limits_notice() { $recommended_memory = 256; // MB $recommended_time = 120; // seconds $current_memory = (int) str_replace( 'M', '', ini_get( 'memory_limit' ) ); $current_time = (int) ini_get( 'max_execution_time' ); $errors = array(); if ( $current_memory < $recommended_memory ) { $errors[] = sprintf( __( 'Your PHP memory limit is %dMB. It is recommended to have at least %dMB for smooth import/export operations.', 'all-in-one-video-gallery' ), $current_memory, $recommended_memory ); } if ( $current_time < $recommended_time ) { $errors[] = sprintf( __( 'Your PHP max execution time is %d seconds. It is recommended to have at least %d seconds to avoid timeouts during batch processing.', 'all-in-one-video-gallery' ), $current_time, $recommended_time ); } if ( ! empty( $errors ) ) { foreach ( $errors as $error ) { printf( '
%s
', esc_html( $error ) ); } } } /** * Display a video player. * * @since 1.0.0 * @param int $post_id Post ID. * @param array $atts Player configuration data. */ function the_aiovg_player( $post_id = 0, $atts = array() ) { echo aiovg_get_player_html( $post_id, $atts ); } /** * Display social sharing buttons. * * @since 1.0.0 */ function the_aiovg_socialshare_buttons() { if ( ! is_singular( 'aiovg_videos' ) ) { return false; } global $post; $socialshare_settings = aiovg_get_option( 'aiovg_socialshare_settings' ); // Get current page url $url = get_permalink(); $url_encoded = rawurlencode( $url ); // Get current page title $title = rawurlencode( get_the_title() ); // Get image $image_data = aiovg_get_image( $post->ID, 'large' ); $image = $image_data['src']; // Build sharing buttons $buttons = array(); if ( isset( $socialshare_settings['services']['facebook'] ) ) { $buttons['facebook'] = array( 'icon' => 'aiovg-icon-facebook', 'text' => __( 'Facebook', 'all-in-one-video-gallery' ), 'url' => "https://www.facebook.com/sharer/sharer.php?u={$url_encoded}" ); } if ( isset( $socialshare_settings['services']['twitter'] ) ) { $buttons['twitter'] = array( 'icon' => 'aiovg-icon-twitter', 'text' => __( 'Twitter', 'all-in-one-video-gallery' ), 'url' => "https://twitter.com/intent/tweet?text={$title}&url={$url_encoded}" ); } if ( isset( $socialshare_settings['services']['linkedin'] ) ) { $buttons['linkedin'] = array( 'icon' => 'aiovg-icon-linkedin', 'text' => __( 'Linkedin', 'all-in-one-video-gallery' ), 'url' => "https://www.linkedin.com/shareArticle?url={$url_encoded}&title={$title}" ); } if ( isset( $socialshare_settings['services']['pinterest'] ) ) { $buttons['pinterest'] = array( 'icon' => 'aiovg-icon-pinterest', 'text' => __( 'Pin It', 'all-in-one-video-gallery' ), 'url' => "https://pinterest.com/pin/create/button/?url={$url_encoded}&media={$image}&description={$title}" ); } if ( isset( $socialshare_settings['services']['tumblr'] ) ) { $tumblr_url = "https://www.tumblr.com/share/link?url={$url_encoded}&name={$title}"; $description = sanitize_text_field( aiovg_get_excerpt( $post->ID, 160, '', false ) ); if ( ! empty( $description ) ) { $description = rawurlencode( $description ); $tumblr_url .= "&description={$description}"; } $buttons['tumblr'] = array( 'icon' => 'aiovg-icon-tumblr', 'text' => __( 'Tumblr', 'all-in-one-video-gallery' ), 'url' => $tumblr_url ); } if ( isset( $socialshare_settings['services']['whatsapp'] ) ) { if ( wp_is_mobile() ) { $whatsapp_url = "whatsapp://send?text={$title} {$url_encoded}"; } else { $whatsapp_url = "https://api.whatsapp.com/send?text={$title}%20{$url_encoded}"; } $buttons['whatsapp'] = array( 'icon' => 'aiovg-icon-whatsapp', 'text' => __( 'WhatsApp', 'all-in-one-video-gallery' ), 'url' => $whatsapp_url ); } if ( isset( $socialshare_settings['services']['email'] ) ) { $email_subject = sprintf( __( 'Check out the "%s"', 'all-in-one-video-gallery' ), $title ); $email_body = sprintf( __( 'Check out the "%s" at %s', 'all-in-one-video-gallery' ), $title, $url ); $email_url = "mailto:?subject={$email_subject}&body={$email_body}"; $buttons['email'] = array( 'icon' => 'aiovg-icon-email', 'text' => __( 'Email', 'all-in-one-video-gallery' ), 'url' => $email_url ); } $buttons = apply_filters( 'aiovg_socialshare_buttons', $buttons ); if ( count( $buttons ) ) { wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-icons' ); $html = '
'; foreach ( $buttons as $label => $button ) { $html .= sprintf( '', esc_attr( $label ), esc_attr( $button['url'] ), esc_attr( $button['text'] ), ( isset( $button['icon'] ) ? esc_attr( $button['icon'] ) : '' ) ); } $html .= '
'; echo apply_filters( 'the_aiovg_socialshare_buttons', $html, $buttons ); } } /** * Build & display attributes using the $atts array. * * @since 1.0.0 * @param array $atts Array of attributes. */ function the_aiovg_video_attributes( $atts ) { echo aiovg_combine_video_attributes( $atts ); } /** * Video thumbnail HTML output. * * @since 1.5.7 * @param WP_Post $post WP post object. * @param array $atts Array of attributes. */ function the_aiovg_video_thumbnail( $post, $attributes ) { $template = 'video-thumbnail.php'; if ( isset( $attributes['thumbnail_style'] ) && 'image-left' == $attributes['thumbnail_style'] ) { $template = 'video-thumbnail-image-left.php'; } include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . "public/templates/{$template}", $attributes ); }