Issues (1082)

classes/class-lsx-to-team-schema.php (4 issues)

1
<?php
2
/**
3
 * The Team Schema for Tours
4
 *
5
 * @package tour-operator
6
 */
7
8
/**
9
 * Returns schema Review data.
10
 *
11
 * @since 10.2
12
 */
13
class LSX_TO_Team_Schema extends LSX_TO_Schema_Graph_Piece {
14
15
	/**
16
	 * Constructor.
17
	 *
18
	 * @param \WPSEO_Schema_Context $context A value object with context variables.
19
	 */
20
	public function __construct( WPSEO_Schema_Context $context ) {
21
		$this->post_type = 'team';
22
		parent::__construct( $context );
23
	}
0 ignored issues
show
Expected 2 blank lines after function; 1 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
24
25
	/**
26
	 * Returns Review data.
27
	 *
28
	 * @return array $data Review data.
29
	 */
30
	public function generate() {
31
		$data = array(
32
			'@type'            => array(
33
				'Person',
34
			),
35
			'@id'              => $this->context->canonical . '#person',
36
			'name'             => $this->post->post_title,
37
			'description'      => wp_strip_all_tags( $this->post->post_content ),
38
			'url'              => $this->post_url,
39
			'mainEntityOfPage' => array(
40
				'@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH,
41
			),
42
		);
43
44
		if ( $this->context->site_represents_reference ) {
45
			$data['worksFor'] = $this->context->site_represents_reference;
46
			$data['memberOf'] = $this->context->site_represents_reference;
47
		}
48
49
		$data = $this->add_taxonomy_terms( $data, 'jobTitle', 'role' );
50
		$data = $this->add_custom_field( $data, 'email', 'contact_email' );
51
		$data = $this->add_custom_field( $data, 'telephone', 'contact_number' );
52
		$data = $this->add_products( $data );
53
		$data = $this->add_offers( $data, 'makesOffer' );
54
		$data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context );
55
		return $data;
56
	}
57
58
	/**
59
	 * Adds the accommodation and tour products under the 'owns' parameter
60
	 *
61
	 * @param array $data
62
	 * @return array
63
	 */
64
	public function add_products( $data ) {
65
		$places_array = array();
66
		$places_array = $this->add_accommodation( $places_array );
67
		$places_array = $this->add_tours( $places_array );
68
		if ( ! empty( $places_array ) ) {
69
			$data['owns'] = $places_array;
70
		}
71
		return $data;
72
	}
0 ignored issues
show
Expected 2 blank lines after function; 0 found
Loading history...
Expected 1 blank line before closing function brace; 0 found
Loading history...
73
}
74