'','subclass' => '', 'id' => 'AQVG_default', 'video_count' => '10', 'style' => 'grid', 'columns' => '3'), $atts ); global $wpdb; $table_name = $wpdb->prefix . "video_gallery"; $vids = $wpdb->get_results( "SELECT `video_title`,`video_url` FROM $table_name" ); $getting_style = strtolower(preg_replace("/[^a-zA-Z]/", "", $a['style'])); $getting_column = preg_replace('/[^0-9]/','',$a['columns']); $getting_videocount = preg_replace('/[^0-9]/','',$a['video_count']); $getting_id = preg_replace("/[^a-zA-Z]/", "", $a['id']); $total_videos = 0; $output = ''; if($getting_column >= 6){ return; } if($getting_style == 'grid' || $getting_style == 'masonry' || $getting_style == 'flat'){ $output .= '
'; foreach ($vids as $vid) { if($total_videos == $getting_videocount){ break; } if( Aqua_CheckYoutube($vid->video_url) == false){ $total_videos ++; $output .= '
'; $output .= ''; $output .= '

'.$vid->video_title.'

'; $output .= '
'; } } $output .= '
'; }else{ return; } return $output; } add_shortcode('aqvg', 'AQVG_FrontendVideos'); function Aqua_CheckYoutube($url) { return preg_match("/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/", $url); } function Aqua_YoutubeID($url) { $pattern = '%^# Match any youtube URL (?:https?://)? # Optional scheme. Either http or https (?:www\.)? # Optional www subdomain (?: # Group host alternatives youtu\.be/ # Either youtu.be, | youtube\.com # or youtube.com (?: # Group path alternatives /embed/ # Either /embed/ | /v/ # or /v/ | .*v= # or /watch\?v= ) # End path alternatives. ) # End host alternatives. ([\w-]{10,12}) # Allow 10-12 for 11 char youtube id. ($|&).* # if additional parameters are also in query string after video id. $%x' ; $result = preg_match($pattern, $url, $matches); if (false !== $result) { return $matches[1]; } return false; } function AQVG_youtube_frontend_videos( $atts ) { wp_enqueue_style( 'AQVG_client_style_css' ); wp_enqueue_script( 'AQVG_client_js' ); $a = shortcode_atts( array('class' => '','subclass' => '', 'id' => 'AQVG_default', 'video_count' => '10', 'style' => 'grid', 'columns' => '3'), $atts ); global $wpdb; $table_name = $wpdb->prefix . "video_gallery"; $vids = $wpdb->get_results( "SELECT `video_title`,`video_url` FROM $table_name" ); $getting_style = strtolower(preg_replace("/[^a-zA-Z]/", "", $a['style'])); $getting_column = preg_replace('/[^0-9]/','',$a['columns']); $getting_videocount1 = preg_replace('/[^0-9]/','',$a['video_count']); $getting_id = preg_replace("/[^a-zA-Z]/", "", $a['id']); $total_videos1 = 0; $output = ''; if($getting_column >= 6){ return; } if($getting_style == 'grid' || $getting_style == 'masonry' || $getting_style == 'flat'){ $output .= '
'; foreach ($vids as $vid) { if($total_videos1 == $getting_videocount1){ break; } if( Aqua_CheckYoutube($vid->video_url) == true){ $total_videos1 ++; $getyoutube_vid = Aqua_YoutubeID($vid->video_url); $output .= '
'; $output .= ''; $output .= '

'.$vid->video_title.'

'; $output .= '
'; } } } $output .= '
'; return $output; } add_shortcode( 'aqvg_youtube', 'AQVG_youtube_frontend_videos' );