Passed
Push — add/471 ( 1979ae...abc1b1 )
by Virginia
05:13
created
includes/classes/class-lsx-schema-graph-piece.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 use \Yoast\WP\SEO\Generators\Schema\Abstract_Schema_Piece;
13 13
 
14
-if ( class_exists( 'Abstract_Schema_Piece' ) ) {
14
+if (class_exists('Abstract_Schema_Piece')) {
15 15
 	class LSX_Schema_Graph_Piece extends Abstract_Schema_Piece {
16 16
 		/**
17 17
 		 * A value object with context variables.
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 		 *
55 55
 		 * @param \WPSEO_Schema_Context $context A value object with context variables.
56 56
 		 */
57
-		public function __construct( WPSEO_Schema_Context $context ) {
57
+		public function __construct(WPSEO_Schema_Context $context) {
58 58
 			$this->context      = $context;
59 59
 			$this->place_ids    = array();
60
-			$this->post         = get_post( $this->context->id );
61
-			$this->post_url     = get_permalink( $this->context->id );
60
+			$this->post         = get_post($this->context->id);
61
+			$this->post_url     = get_permalink($this->context->id);
62 62
 			$this->is_top_level = false;
63
-			if ( is_object( $this->post ) && isset( $this->post->post_parent ) && ( false === $this->post->post_parent || 0 === $this->post->post_parent || '' === $this->post->post_parent ) ) {
63
+			if (is_object($this->post) && isset($this->post->post_parent) && (false === $this->post->post_parent || 0 === $this->post->post_parent || '' === $this->post->post_parent)) {
64 64
 				$this->is_top_level = true;
65 65
 			}
66 66
 		}
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 		 * @return bool
71 71
 		 */
72 72
 		public function is_needed() {
73
-			if ( ! is_singular() ) {
73
+			if ( ! is_singular()) {
74 74
 				return false;
75 75
 			}
76
-			if ( false === $this->context->site_represents ) {
76
+			if (false === $this->context->site_represents) {
77 77
 				return false;
78 78
 			}
79
-			return LSX_Schema_Utils::is_type( get_post_type(), $this->post_type );
79
+			return LSX_Schema_Utils::is_type(get_post_type(), $this->post_type);
80 80
 		}
81 81
 		/**
82 82
 		 * Returns Review data.
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 		 * @param  boolean  $include_aggregate
96 96
 		 * @return array    $data
97 97
 		 */
98
-		public function add_reviews( $data, $data_key = 'reviews', $include_aggregate = true ) {
99
-			$reviews       = get_post_meta( $this->context->id, 'review_to_' . $this->post_type, false );
98
+		public function add_reviews($data, $data_key = 'reviews', $include_aggregate = true) {
99
+			$reviews       = get_post_meta($this->context->id, 'review_to_' . $this->post_type, false);
100 100
 			$reviews_array = array();
101
-			if ( ! empty( $reviews ) ) {
101
+			if ( ! empty($reviews)) {
102 102
 				$aggregate_value = 1;
103 103
 				$review_count    = 0;
104
-				foreach ( $reviews as $review_id ) {
105
-					$rating      = get_post_meta( $review_id, 'rating', true );
106
-					$author      = get_post_meta( $review_id, 'reviewer_name', true );
107
-					$description = wp_strip_all_tags( get_the_excerpt( $review_id ) );
104
+				foreach ($reviews as $review_id) {
105
+					$rating      = get_post_meta($review_id, 'rating', true);
106
+					$author      = get_post_meta($review_id, 'reviewer_name', true);
107
+					$description = wp_strip_all_tags(get_the_excerpt($review_id));
108 108
 					$review_args = array(
109 109
 						'author'     => $author,
110 110
 						'reviewBody' => $description,
111 111
 					);
112 112
 					// Add in the review rating.
113
-					if ( false !== $rating && '' !== $rating && '0' !== $rating && 0 !== $rating ) {
113
+					if (false !== $rating && '' !== $rating && '0' !== $rating && 0 !== $rating) {
114 114
 						$review_args['reviewRating'] = array(
115 115
 							'@type'       => 'Rating',
116 116
 							'ratingValue' => $rating,
117 117
 						);
118 118
 					}
119
-					$reviews_array = LSX_Schema_Utils::add_review( $reviews_array, $review_id, $this->context, $review_args );
119
+					$reviews_array = LSX_Schema_Utils::add_review($reviews_array, $review_id, $this->context, $review_args);
120 120
 					$review_count++;
121 121
 				}
122
-				if ( ! empty( $reviews_array ) ) {
123
-					if ( true === $include_aggregate ) {
122
+				if ( ! empty($reviews_array)) {
123
+					if (true === $include_aggregate) {
124 124
 						$data['aggregateRating'] = array(
125 125
 							'@type'       => 'AggregateRating',
126 126
 							'ratingValue' => (string) $aggregate_value,
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 							'worstRating' => '1',
130 130
 						);
131 131
 					}
132
-					$data[ $data_key ] = $reviews_array;
132
+					$data[$data_key] = $reviews_array;
133 133
 				}
134 134
 			}
135 135
 			return $data;
@@ -141,30 +141,30 @@  discard block
 block discarded – undo
141 141
 		 * @param  string $data_key
142 142
 		 * @return array  $data
143 143
 		 */
144
-		public function add_articles( $data, $data_key = 'subjectOf' ) {
145
-			$posts       = get_post_meta( $this->context->id, 'post_to_' . $this->post_type, false );
144
+		public function add_articles($data, $data_key = 'subjectOf') {
145
+			$posts       = get_post_meta($this->context->id, 'post_to_' . $this->post_type, false);
146 146
 			$posts_array = array();
147
-			if ( ! empty( $posts ) ) {
148
-				foreach ( $posts as $post_id ) {
147
+			if ( ! empty($posts)) {
148
+				foreach ($posts as $post_id) {
149 149
 					$post_args = array(
150
-						'articleBody' => wp_strip_all_tags( get_the_excerpt( $post_id ) ),
151
-						'headline'    => get_the_title( $post_id ),
150
+						'articleBody' => wp_strip_all_tags(get_the_excerpt($post_id)),
151
+						'headline'    => get_the_title($post_id),
152 152
 					);
153
-					$section   = get_the_term_list( $post_id, 'category' );
154
-					if ( ! is_wp_error( $section ) && '' !== $section && false !== $section ) {
155
-						$post_args['articleSection'] = wp_strip_all_tags( $section );
153
+					$section = get_the_term_list($post_id, 'category');
154
+					if ( ! is_wp_error($section) && '' !== $section && false !== $section) {
155
+						$post_args['articleSection'] = wp_strip_all_tags($section);
156 156
 					}
157
-					if ( $this->context->site_represents_reference ) {
157
+					if ($this->context->site_represents_reference) {
158 158
 						$post_args['publisher'] = $this->context->site_represents_reference;
159 159
 					}
160
-					$image_url = get_the_post_thumbnail_url( $post_id, 'lsx-thumbnail-wide' );
161
-					if ( false !== $image_url ) {
160
+					$image_url = get_the_post_thumbnail_url($post_id, 'lsx-thumbnail-wide');
161
+					if (false !== $image_url) {
162 162
 						$post_args['image'] = $image_url;
163 163
 					}
164
-					$posts_array = LSX_Schema_Utils::add_article( $posts_array, $post_id, $this->context, $post_args );
164
+					$posts_array = LSX_Schema_Utils::add_article($posts_array, $post_id, $this->context, $post_args);
165 165
 				}
166
-				if ( ! empty( $posts_array ) ) {
167
-					$data[ $data_key ] = $posts_array;
166
+				if ( ! empty($posts_array)) {
167
+					$data[$data_key] = $posts_array;
168 168
 				}
169 169
 			}
170 170
 			return $data;
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 		 *
177 177
 		 * @return array $data
178 178
 		 */
179
-		public function add_connections( $data ) {
179
+		public function add_connections($data) {
180 180
 			$connections_array = array();
181
-			if ( $this->is_top_level ) {
182
-				$connections_array = $this->add_regions( $connections_array );
183
-				$connections_array = $this->add_accommodation( $connections_array );
184
-				if ( ! empty( $connections_array ) ) {
181
+			if ($this->is_top_level) {
182
+				$connections_array = $this->add_regions($connections_array);
183
+				$connections_array = $this->add_accommodation($connections_array);
184
+				if ( ! empty($connections_array)) {
185 185
 					$data['containsPlace'] = $connections_array;
186 186
 				}
187 187
 			} else {
188
-				$connections_array             = $this->add_countries( $connections_array );
188
+				$connections_array = $this->add_countries($connections_array);
189 189
 				$data['containedInPlace'] = $connections_array;
190 190
 				$connections_array          = array();
191
-				$connections_array          = $this->add_accommodation( $connections_array );
191
+				$connections_array          = $this->add_accommodation($connections_array);
192 192
 				$data['containsPlace'] = $connections_array;
193 193
 			}
194 194
 			return $data;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 		 *
203 203
 		 * @return array $data Review data.
204 204
 		 */
205
-		public function add_taxonomy_terms( $data, $data_key, $taxonomy ) {
205
+		public function add_taxonomy_terms($data, $data_key, $taxonomy) {
206 206
 			/**
207 207
 			 * Filter: 'lsx_schema_' . $this->post_type . '_' . $data_key . '_taxonomy' - Allow changing the taxonomy used to assign keywords to a post type Review data.
208 208
 			 *
209 209
 			 * @api string $taxonomy The chosen taxonomy.
210 210
 			 */
211
-			$taxonomy = apply_filters( 'lsx_schema_' . $this->post_type . '_' . $data_key . '_taxonomy', $taxonomy );
212
-			return LSX_Schema_Utils::add_terms( $data, $this->context->id, $data_key, $taxonomy );
211
+			$taxonomy = apply_filters('lsx_schema_' . $this->post_type . '_' . $data_key . '_taxonomy', $taxonomy);
212
+			return LSX_Schema_Utils::add_terms($data, $this->context->id, $data_key, $taxonomy);
213 213
 		}
214 214
 		/**
215 215
 		 * Adds the custom field value for the supplied key
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 		 *
222 222
 		 * @return array $data Review data.
223 223
 		 */
224
-		public function add_custom_field( $data, $data_key, $meta_key, $single = true ) {
225
-			$value = get_post_meta( $this->context->id, $meta_key, $single );
226
-			if ( '' !== $value && false !== $value ) {
227
-				$data[ $data_key ] = $value;
224
+		public function add_custom_field($data, $data_key, $meta_key, $single = true) {
225
+			$value = get_post_meta($this->context->id, $meta_key, $single);
226
+			if ('' !== $value && false !== $value) {
227
+				$data[$data_key] = $value;
228 228
 			}
229 229
 			return $data;
230 230
 		}
Please login to merge, or discard this patch.