object = new WPSEO_Video_Schema_VideoObject( $context ); $pieces[] = $this->object; return $pieces; } /** * Changes Article Schema output. * * @param array $data Article Schema data. * * @return array $data Article Schema data. */ public function filter_article( $data ) { if ( $this->object->is_needed() ) { $data['video'] = array( $this->get_video_id() ); } return $data; } /** * Changes WebPage Schema output. * * @param array $data WebPage Schema data. * * @return array $data WebPage Schema data. */ public function filter_webpage( $data ) { if ( ! is_singular() ) { return $data; } /** * Filter: 'wpseo_schema_article_post_types' - Allow changing for which post types we output Article schema. * * @api string[] $post_types The post types for which we output Article. */ $post_types = apply_filters( 'wpseo_schema_article_post_types', array( 'post' ) ); if ( in_array( get_post_type(), $post_types, true ) ) { return $data; } if ( $this->object->is_needed() ) { $data['video'] = array( $this->get_video_id() ); } return $data; } /** * Returns an array with the video identifier. * * @return array Array with the video identifier. */ private function get_video_id() { return array( '@id' => WPSEO_Frontend::get_instance()->canonical( false ) . self::VIDEO_HASH ); } }