get_player_settings();
$general_settings = aiovg_get_option( 'aiovg_general_settings' );
$lazyloading = ! empty( $general_settings['lazyloading'] ) ? 'loading="lazy" ' : '';
$popup_content = __( 'Open Popup', 'all-in-one-video-gallery' );
$is_image = 0;
if ( ! isset( $this->args['content'] ) ) {
$poster = $this->get_poster();
if ( ! empty( $poster ) ) {
$popup_content = sprintf( '
', esc_url( $poster ), $lazyloading );
$is_image = 1;
}
} else {
$popup_content = trim( (string) $this->args['content'] );
if ( $popup_content && filter_var( $popup_content, FILTER_VALIDATE_URL ) ) {
$parsed = wp_parse_url( $popup_content );
// Allow only http / https URLs
if ( isset( $parsed['scheme'] ) && in_array( $parsed['scheme'], array( 'http', 'https' ) ) ) {
$popup_content = sprintf( '
', esc_url( $popup_content ), $lazyloading );
$is_image = 1;
}
}
}
if ( $is_image ) {
$icon = '';
if ( $this->post_id > 0 && 'aiovg_videos' == $this->post_type ) {
if ( ! $this->has_access && ! $this->is_trailer ) {
$icon = '';
}
}
$popup_content .= $icon;
}
// Enqueue dependencies
wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-magnific-popup' );
if ( $is_image ) wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-public' );
wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-premium-public' );
wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-magnific-popup' );
wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-template-popup' );
// Process output
$this->args['autoplay'] = 1;
$this->embed_url = aiovg_get_player_page_url( $this->post_id, $this->args );
$classes = array();
$classes[] = 'aiovg-video-template-popup';
if ( $is_image ) $classes[] = 'aiovg-is-image';
$html = sprintf(
'%s',
implode( ' ', $classes ),
esc_url( $this->embed_url ),
(float) $player_settings['ratio'],
$popup_content
);
return $html;
}
}