'aiovg_videos', 'post_status' => 'publish', 'posts_per_page' => 1, 'fields' => 'ids' ); $ids = get_posts( $query ); $post_id = ! empty( $ids ) ? $ids[0] : 0; } } // Enqueue dependencies wp_enqueue_style( AIOVG_PLUGIN_SLUG ); wp_enqueue_script( 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 dependencies wp_enqueue_style( AIOVG_PLUGIN_SLUG ); wp_enqueue_script( 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; } /** * 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(); } }