'aiovg_videos', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids' ); $ids = get_posts( $query ); $post_id = ! empty( $ids ) ? $ids[0] : 0; } // Enqueue style dependencies wp_enqueue_style( AIOVG_PLUGIN_SLUG ); // Return return aiovg_get_player_html( $post_id, $atts ); } /** * Filter the post content. * * @since 1.0.0 * @param string $content Content of the current post. * @return string $content Modified Content. */ public function the_content( $content ) { if ( is_singular( 'aiovg_videos' ) && in_the_loop() && is_main_query() ) { global $post; // Vars $video_settings = get_option( 'aiovg_video_settings' ); $attributes = array( 'id' => $post->ID, 'show_category' => isset( $video_settings['display']['category'] ), 'show_date' => isset( $video_settings['display']['date'] ), 'show_user' => isset( $video_settings['display']['user'] ), 'show_views' => isset( $video_settings['display']['views'] ), 'related' => isset( $video_settings['display']['related'] ) ); $attributes['categories'] = get_the_terms( get_the_ID(), 'aiovg_categories' ); // Enqueue style dependencies wp_enqueue_style( AIOVG_PLUGIN_SLUG ); // Process output ob_start(); include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . 'public/templates/single-video.php' ); $content = ob_get_clean(); } return $content; } /** * Get player page URL. * * @since 1.0.0 * @param string $url Player page URL. * @param int $post_id Post ID. * @param array $atts Player configuration data. * @return string $url Filtered URL ( if applicable ). */ public function get_player_page_url( $url, $post_id, $atts ) { $type = get_post_meta( $post_id, 'type', true ); if ( 'embedcode' == $type ) { $embedcode = get_post_meta( $post_id, 'embedcode', true ); $document = new DOMDocument(); $document->loadHTML( $embedcode ); $iframes = $document->getElementsByTagName( 'iframe' ); $url = $iframes->item(0)->getAttribute( 'src' ); } return $url; } /** * Update video views count. * * @since 1.0.0 */ public function ajax_callback_update_views_count() { if ( isset( $_POST['post_id'] ) ) { $post_id = (int) $_POST['post_id']; if( $post_id > 0 ) { check_ajax_referer( 'aiovg_video_{$post_id}_views_nonce', 'security' ); aiovg_update_views_count( $post_id ); } } wp_die(); } }