Completed
Push — develop ( 7cc3ce...19a2e7 )
by Naveen
01:13 queued 11s
created
wordlift/content/wordpress/class-wordpress-permalink-content-service.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @return Content_Service
20 20
 	 */
21 21
 	public static function get_instance() {
22
-		if ( ! isset( self::$instance ) ) {
22
+		if ( ! isset(self::$instance)) {
23 23
 			self::$instance = new self();
24 24
 		}
25 25
 
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return Wordpress_Content|null
33 33
 	 */
34
-	function get_by_entity_id( $uri ) {
35
-		if ( ! preg_match( '@.*#(\w+)/(\d+)@', $uri, $matches ) ) {
34
+	function get_by_entity_id($uri) {
35
+		if ( ! preg_match('@.*#(\w+)/(\d+)@', $uri, $matches)) {
36 36
 			return null;
37 37
 		}
38 38
 
39 39
 		$type_name = $matches[1];
40 40
 		$id        = $matches[2];
41
-		switch ( Object_Type_Enum::from_string( $type_name ) ) {
41
+		switch (Object_Type_Enum::from_string($type_name)) {
42 42
 			case Object_Type_Enum::POST:
43
-				return new Wordpress_Content( get_post( $id ) );
43
+				return new Wordpress_Content(get_post($id));
44 44
 			case Object_Type_Enum::TERM:
45
-				return new Wordpress_Content( get_term( $id ) );
45
+				return new Wordpress_Content(get_term($id));
46 46
 			case Object_Type_Enum::USER:
47
-				return new Wordpress_Content( get_user_by( 'ID', $id ) );
47
+				return new Wordpress_Content(get_user_by('ID', $id));
48 48
 		}
49 49
 
50 50
 		return null;
@@ -54,16 +54,16 @@  discard block
 block discarded – undo
54 54
 	 * Get a
55 55
 	 * @throws Exception
56 56
 	 */
57
-	function get_by_entity_id_or_same_as( $uri ) {
57
+	function get_by_entity_id_or_same_as($uri) {
58 58
 		// If the URL is in the local site URL, then try to find a corresponding post.
59
-		if ( 0 === strpos( $uri, site_url() ) ) {
60
-			return $this->get_by_entity_id( $uri );
59
+		if (0 === strpos($uri, site_url())) {
60
+			return $this->get_by_entity_id($uri);
61 61
 		}
62 62
 
63 63
 		// Otherwise look in sameAs.
64 64
 		global $wpdb;
65 65
 
66
-		$row = $wpdb->get_row( $wpdb->prepare( "
66
+		$row = $wpdb->get_row($wpdb->prepare("
67 67
 			SELECT content_type, content_id
68 68
 			FROM (
69 69
 			    SELECT %d AS content_type, post_id AS content_id
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 		",
83 83
 			Object_Type_Enum::POST, $uri,
84 84
 			Object_Type_Enum::TERM, $uri,
85
-			Object_Type_Enum::USER, $uri ) );
85
+			Object_Type_Enum::USER, $uri));
86 86
 
87
-		if ( ! isset( $row ) ) {
87
+		if ( ! isset($row)) {
88 88
 			return null;
89 89
 		}
90 90
 
91
-		switch ( (int) $row->content_type ) {
91
+		switch ((int) $row->content_type) {
92 92
 			case Object_Type_Enum::POST:
93
-				return new Wordpress_Content( get_post( $row->content_id ) );
93
+				return new Wordpress_Content(get_post($row->content_id));
94 94
 			case Object_Type_Enum::TERM:
95
-				return new Wordpress_Content( get_term( $row->content_id ) );
95
+				return new Wordpress_Content(get_term($row->content_id));
96 96
 			case Object_Type_Enum::USER:
97
-				return new Wordpress_Content( get_user_by( 'ID', $row->content_id ) );
97
+				return new Wordpress_Content(get_user_by('ID', $row->content_id));
98 98
 			default:
99 99
 				return null;
100 100
 		}
@@ -106,30 +106,30 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return string|void|null
108 108
 	 */
109
-	function get_entity_id( $content_id ) {
109
+	function get_entity_id($content_id) {
110 110
 		$type = $content_id->get_type();
111 111
 		$id   = $content_id->get_id();
112 112
 
113
-		switch ( $type ) {
113
+		switch ($type) {
114 114
 			case Object_Type_Enum::POST:
115
-				$base_uri = get_permalink( $id );
115
+				$base_uri = get_permalink($id);
116 116
 				break;
117 117
 			case Object_Type_Enum::TERM:
118
-				$base_uri = get_term_link( $id );
118
+				$base_uri = get_term_link($id);
119 119
 				break;
120 120
 			case Object_Type_Enum::USER:
121
-				$base_uri = get_author_posts_url( $id );
121
+				$base_uri = get_author_posts_url($id);
122 122
 				break;
123 123
 			default:
124 124
 				return null;
125 125
 		}
126 126
 
127
-		$type_name = Object_Type_Enum::to_string( $type );
127
+		$type_name = Object_Type_Enum::to_string($type);
128 128
 
129 129
 		return "$base_uri#$type_name/$id";
130 130
 	}
131 131
 
132
-	function set_entity_id( $content_id, $uri ) {
132
+	function set_entity_id($content_id, $uri) {
133 133
 		// do nothing.
134 134
 	}
135 135
 
@@ -138,15 +138,15 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return bool|void
140 140
 	 */
141
-	function supports( $content_id ) {
142
-		return in_array( $content_id->get_type(), array(
141
+	function supports($content_id) {
142
+		return in_array($content_id->get_type(), array(
143 143
 			Object_Type_Enum::POST,
144 144
 			Object_Type_Enum::TERM,
145 145
 			Object_Type_Enum::USER,
146
-		) );
146
+		));
147 147
 	}
148 148
 
149
-	function delete( $content_id ) {
149
+	function delete($content_id) {
150 150
 		// Ignore, we don't store any data.
151 151
 	}
152 152
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-entity-service.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @since 3.2.0
82 82
 	 */
83 83
 	protected function __construct() {
84
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
84
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Entity_Service');
85 85
 
86 86
 		$this->entity_uri_service = Wordlift_Entity_Uri_Service::get_instance();
87 87
 		$this->relation_service   = Wordlift_Relation_Service::get_instance();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public static function get_instance() {
107 107
 
108
-		if ( ! isset( self::$instance ) ) {
108
+		if ( ! isset(self::$instance)) {
109 109
 			self::$instance = new self();
110 110
 		}
111 111
 
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 	 * @since 3.1.0
123 123
 	 *
124 124
 	 */
125
-	public function is_entity( $post_id ) {
125
+	public function is_entity($post_id) {
126 126
 
127 127
 		// Improve performance by giving for granted that a product is an entity.
128
-		if ( 'product' === get_post_type( $post_id ) ) {
128
+		if ('product' === get_post_type($post_id)) {
129 129
 			return true;
130 130
 		}
131 131
 
132
-		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
132
+		$terms = wp_get_object_terms($post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
133 133
 
134
-		if ( is_wp_error( $terms ) ) {
135
-			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
134
+		if (is_wp_error($terms)) {
135
+			$this->log->error("Cannot get the terms for post $post_id: ".$terms->get_error_message());
136 136
 
137 137
 			return false;
138 138
 		}
139 139
 
140
-		if ( empty( $terms ) ) {
140
+		if (empty($terms)) {
141 141
 			return false;
142 142
 		}
143 143
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 		 *
149 149
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
150 150
 		 */
151
-		foreach ( $terms as $term ) {
152
-			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
151
+		foreach ($terms as $term) {
152
+			if (1 !== preg_match('~(^|-)article$~', $term->slug)) {
153 153
 				return true;
154 154
 			}
155 155
 		}
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 	 * @since 3.5.0
170 170
 	 *
171 171
 	 */
172
-	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
172
+	public function get_classification_scope_for($post_id, $default = WL_WHAT_RELATION) {
173 173
 
174
-		if ( false === $this->is_entity( $post_id ) ) {
174
+		if (false === $this->is_entity($post_id)) {
175 175
 			return $default;
176 176
 		}
177 177
 
178 178
 		// Retrieve the entity type
179
-		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
180
-		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
179
+		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get($post_id);
180
+		$entity_type     = str_replace('wl-', '', $entity_type_arr['css_class']);
181 181
 		// Retrieve classification boxes configuration
182
-		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
183
-		foreach ( $classification_boxes as $cb ) {
184
-			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
182
+		$classification_boxes = unserialize(WL_CORE_POST_CLASSIFICATION_BOXES);
183
+		foreach ($classification_boxes as $cb) {
184
+			if (in_array($entity_type, $cb['registeredTypes'])) {
185 185
 				return $cb['id'];
186 186
 			}
187 187
 		}
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
198 198
 	 */
199
-	public function is_used( $post_id ) {
199
+	public function is_used($post_id) {
200 200
 
201
-		if ( false === $this->is_entity( $post_id ) ) {
201
+		if (false === $this->is_entity($post_id)) {
202 202
 			return null;
203 203
 		}
204 204
 		// Retrieve the post
205
-		$entity = get_post( $post_id );
205
+		$entity = get_post($post_id);
206 206
 
207 207
 		global $wpdb;
208 208
 		// Retrieve Wordlift relation instances table name
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 		);
216 216
 
217 217
 		// Perform the query
218
-		$relation_instances = (int) $wpdb->get_var( $stmt );
218
+		$relation_instances = (int) $wpdb->get_var($stmt);
219 219
 		// If there is at least one relation instance for the current entity, then it's used
220
-		if ( 0 < $relation_instances ) {
220
+		if (0 < $relation_instances) {
221 221
 			return true;
222 222
 		}
223 223
 
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 		$stmt = $wpdb->prepare(
226 226
 			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
227 227
 			$entity->ID,
228
-			wl_get_entity_uri( $entity->ID )
228
+			wl_get_entity_uri($entity->ID)
229 229
 		);
230 230
 		// Perform the query
231
-		$meta_instances = (int) $wpdb->get_var( $stmt );
231
+		$meta_instances = (int) $wpdb->get_var($stmt);
232 232
 
233 233
 		// If there is at least one meta that refers the current entity uri, then current entity is used
234
-		if ( 0 < $meta_instances ) {
234
+		if (0 < $meta_instances) {
235 235
 			return true;
236 236
 		}
237 237
 
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @since      3.2.0
252 252
 	 *
253 253
 	 */
254
-	public function get_entity_post_by_uri( $uri ) {
254
+	public function get_entity_post_by_uri($uri) {
255 255
 
256
-		return $this->entity_uri_service->get_entity( $uri );
256
+		return $this->entity_uri_service->get_entity($uri);
257 257
 	}
258 258
 
259 259
 	/**
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @param WP_Post $post Post object.
269 269
 	 * @param bool $update Whether this is an existing post being updated or not.
270 270
 	 */
271
-	public function save_post( $post_id, $post, $update ) {
271
+	public function save_post($post_id, $post, $update) {
272 272
 
273 273
 		// Avoid doing anything if post is autosave or a revision.
274
-		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
274
+		if (wp_is_post_autosave($post) || wp_is_post_revision($post)) {
275 275
 			return;
276 276
 		}
277 277
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 		// the $post_id in the save_post call matches the post id set in the request.
282 282
 		//
283 283
 		// If this is not the current post being saved or if it's not an entity, return.
284
-		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
284
+		if ( ! isset($_REQUEST['post_ID']) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity($post_id)) {
285 285
 			return;
286 286
 		}
287 287
 
288 288
 		// Get the alt labels from the request (or empty array).
289
-		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? (array) $_REQUEST['wl_alternative_label'] : array();
289
+		$alt_labels = isset($_REQUEST['wl_alternative_label']) ? (array) $_REQUEST['wl_alternative_label'] : array();
290 290
 
291
-		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
291
+		if (( ! empty($_POST['content']) && ! empty($_POST['post_content'])) || isset($_REQUEST['wl_alternative_label'])) {
292 292
 			// This is via classic editor, so set the alternative labels.
293
-			$this->set_alternative_labels( $post_id, $alt_labels );
293
+			$this->set_alternative_labels($post_id, $alt_labels);
294 294
 		}
295 295
 
296 296
 
@@ -305,35 +305,35 @@  discard block
 block discarded – undo
305 305
 	 * @since 3.2.0
306 306
 	 *
307 307
 	 */
308
-	public function set_alternative_labels( $post_id, $alt_labels ) {
308
+	public function set_alternative_labels($post_id, $alt_labels) {
309 309
 
310 310
 		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
311 311
 		// instead of post id.
312
-		if ( ! is_numeric( $post_id ) ) {
312
+		if ( ! is_numeric($post_id)) {
313 313
 			return;
314 314
 		}
315 315
 
316 316
 		// Force $alt_labels to be an array
317
-		if ( ! is_array( $alt_labels ) ) {
318
-			$alt_labels = array( $alt_labels );
317
+		if ( ! is_array($alt_labels)) {
318
+			$alt_labels = array($alt_labels);
319 319
 		}
320 320
 
321
-		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
321
+		$this->log->debug("Setting alternative labels [ post id :: $post_id ][ alt labels :: ".implode(',', $alt_labels)." ]");
322 322
 
323 323
 		// Delete all the existing alternate labels.
324
-		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
324
+		delete_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
325 325
 
326 326
 		// Save only unique synonymns.
327
-		$alt_labels = array_unique( $alt_labels );
327
+		$alt_labels = array_unique($alt_labels);
328 328
 
329 329
 		// Set the alternative labels.
330
-		foreach ( $alt_labels as $alt_label ) {
330
+		foreach ($alt_labels as $alt_label) {
331 331
 
332 332
 			// Strip html code from synonym.
333
-			$alt_label = wp_strip_all_tags( $alt_label );
333
+			$alt_label = wp_strip_all_tags($alt_label);
334 334
 
335
-			if ( ! empty( $alt_label ) ) {
336
-				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label );
335
+			if ( ! empty($alt_label)) {
336
+				add_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY, (string) $alt_label);
337 337
 			}
338 338
 		}
339 339
 
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	 * @since 3.2.0
349 349
 	 *
350 350
 	 */
351
-	public function get_alternative_labels( $post_id ) {
351
+	public function get_alternative_labels($post_id) {
352 352
 
353
-		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
353
+		return get_post_meta($post_id, self::ALTERNATIVE_LABEL_META_KEY);
354 354
 	}
355 355
 
356 356
 	/**
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 * @return array An array with the entity title and labels.
363 363
 	 * @since 3.12.0
364 364
 	 */
365
-	public function get_labels( $post_id, $object_type = Object_Type_Enum::POST ) {
366
-		if ( $object_type === Object_Type_Enum::POST ) {
367
-			return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
365
+	public function get_labels($post_id, $object_type = Object_Type_Enum::POST) {
366
+		if ($object_type === Object_Type_Enum::POST) {
367
+			return array_merge((array) get_the_title($post_id), $this->get_alternative_labels($post_id));
368 368
 		}
369 369
 
370 370
 		// Term Reference dont have synonyms yet.
@@ -379,44 +379,44 @@  discard block
 block discarded – undo
379 379
 	 * @since 3.2.0
380 380
 	 *
381 381
 	 */
382
-	public function edit_form_before_permalink( $post ) {
382
+	public function edit_form_before_permalink($post) {
383 383
 
384 384
 		// If it's not an entity, return.
385
-		if ( ! $this->is_entity( $post->ID ) ) {
385
+		if ( ! $this->is_entity($post->ID)) {
386 386
 			return;
387 387
 		}
388 388
 
389 389
 		// If disabled by filter, return.
390
-		if ( ! apply_filters( 'wl_feature__enable__add-synonyms', true ) ) {
390
+		if ( ! apply_filters('wl_feature__enable__add-synonyms', true)) {
391 391
 			return;
392 392
 		}
393 393
 
394 394
 		// Print the input template.
395
-		Wordlift_UI_Service::print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
395
+		Wordlift_UI_Service::print_template('wl-tmpl-alternative-label-input', $this->get_alternative_label_input());
396 396
 
397 397
 		// Print all the currently set alternative labels.
398
-		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
398
+		foreach ($this->get_alternative_labels($post->ID) as $alt_label) {
399 399
 
400
-			echo $this->get_alternative_label_input( $alt_label );
400
+			echo $this->get_alternative_label_input($alt_label);
401 401
 
402 402
 		};
403 403
 
404 404
 		// Print the button.
405
-		Wordlift_UI_Service::print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
405
+		Wordlift_UI_Service::print_button('wl-add-alternative-labels-button', __('Add more titles', 'wordlift'));
406 406
 
407 407
 	}
408 408
 
409
-	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
409
+	public function get_uri($object_id, $type = Object_Type_Enum::POST) {
410 410
 		$content_service = Wordpress_Content_Service::get_instance();
411
-		$entity_id       = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
411
+		$entity_id       = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type));
412 412
 		$dataset_uri     = Wordlift_Configuration_Service::get_instance()->get_dataset_uri();
413 413
 
414
-		if ( ! isset( $entity_id ) || ( $dataset_uri && 0 !== strpos( $entity_id, $dataset_uri ) ) ) {
415
-			$rel_uri = Entity_Uri_Generator::create_uri( $type, $object_id );
414
+		if ( ! isset($entity_id) || ($dataset_uri && 0 !== strpos($entity_id, $dataset_uri))) {
415
+			$rel_uri = Entity_Uri_Generator::create_uri($type, $object_id);
416 416
 			try {
417
-				$content_service->set_entity_id( new Wordpress_Content_Id( $object_id, $type ), $rel_uri );
418
-				$entity_id = $content_service->get_entity_id( new Wordpress_Content_Id( $object_id, $type ) );
419
-			} catch ( Exception $e ) {
417
+				$content_service->set_entity_id(new Wordpress_Content_Id($object_id, $type), $rel_uri);
418
+				$entity_id = $content_service->get_entity_id(new Wordpress_Content_Id($object_id, $type));
419
+			} catch (Exception $e) {
420 420
 				return null;
421 421
 			}
422 422
 		}
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
 	 * @since 3.2.0
434 434
 	 *
435 435
 	 */
436
-	private function get_alternative_label_input( $value = '' ) {
436
+	private function get_alternative_label_input($value = '') {
437 437
 
438
-		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
438
+		return sprintf(self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr($value), __('Delete', 'wordlift'));
439 439
 	}
440 440
 
441 441
 	/**
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 		global $wpdb;
450 450
 
451 451
 		// Try to get the count from the transient.
452
-		$count = get_transient( '_wl_entity_service__count' );
453
-		if ( false !== $count ) {
452
+		$count = get_transient('_wl_entity_service__count');
453
+		if (false !== $count) {
454 454
 			return $count;
455 455
 		}
456 456
 
457 457
 		// Query the count.
458
-		$count = $wpdb->get_var( $wpdb->prepare(
458
+		$count = $wpdb->get_var($wpdb->prepare(
459 459
 			"SELECT COUNT( DISTINCT( tr.object_id ) )"
460 460
 			. " FROM {$wpdb->term_relationships} tr"
461 461
 			. " INNER JOIN {$wpdb->term_taxonomy} tt"
@@ -464,10 +464,10 @@  discard block
 block discarded – undo
464 464
 			. "  ON t.term_id = tt.term_id AND t.name != %s",
465 465
 			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
466 466
 			'article'
467
-		) );
467
+		));
468 468
 
469 469
 		// Store the count in cache.
470
-		set_transient( '_wl_entity_service__count', $count, 900 );
470
+		set_transient('_wl_entity_service__count', $count, 900);
471 471
 
472 472
 		return $count;
473 473
 	}
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 	 * @since 3.15.0
483 483
 	 *
484 484
 	 */
485
-	public static function add_criterias( $args ) {
485
+	public static function add_criterias($args) {
486 486
 
487 487
 		// Build an optimal tax-query.
488 488
 		$tax_query = array(
@@ -526,28 +526,28 @@  discard block
 block discarded – undo
526 526
 	 * @since 3.9.0
527 527
 	 *
528 528
 	 */
529
-	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
529
+	public function create($name, $type_uri, $logo = null, $status = 'publish') {
530 530
 
531 531
 		// Create an entity for the publisher.
532
-		$post_id = @wp_insert_post( array(
532
+		$post_id = @wp_insert_post(array(
533 533
 			'post_type'    => self::TYPE_NAME,
534 534
 			'post_title'   => $name,
535 535
 			'post_status'  => $status,
536 536
 			'post_content' => '',
537
-		) );
537
+		));
538 538
 
539 539
 		// Return the error if any.
540
-		if ( is_wp_error( $post_id ) ) {
540
+		if (is_wp_error($post_id)) {
541 541
 			return $post_id;
542 542
 		}
543 543
 
544 544
 		// Set the entity logo.
545
-		if ( $logo && is_numeric( $logo ) ) {
546
-			set_post_thumbnail( $post_id, $logo );
545
+		if ($logo && is_numeric($logo)) {
546
+			set_post_thumbnail($post_id, $logo);
547 547
 		}
548 548
 
549 549
 		// Set the entity type.
550
-		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
550
+		Wordlift_Entity_Type_Service::get_instance()->set($post_id, $type_uri);
551 551
 
552 552
 		return $post_id;
553 553
 	}
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
 	 * @since 3.10.0
564 564
 	 *
565 565
 	 */
566
-	public function get_related_entities( $id, $post_status = 'publish' ) {
566
+	public function get_related_entities($id, $post_status = 'publish') {
567 567
 
568
-		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
568
+		return $this->relation_service->get_objects($id, 'ids', null, $post_status);
569 569
 	}
570 570
 
571 571
 	/**
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 	 * @since 3.12.2
578 578
 	 *
579 579
 	 */
580
-	public function get( $params = array() ) {
580
+	public function get($params = array()) {
581 581
 
582 582
 		// Set the defaults.
583
-		$defaults = array( 'post_type' => 'entity' );
583
+		$defaults = array('post_type' => 'entity');
584 584
 
585 585
 		// Merge the defaults with the provided parameters.
586
-		$args = wp_parse_args( $params, $defaults );
586
+		$args = wp_parse_args($params, $defaults);
587 587
 
588 588
 		// Call the `get_posts` function.
589
-		return get_posts( $args );
589
+		return get_posts($args);
590 590
 	}
591 591
 
592 592
 	/**
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
 	static function valid_entity_post_types() {
603 603
 
604 604
 		// Ignore builtins in the call to avoid getting attachments.
605
-		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
605
+		$post_types = array('post', 'page', self::TYPE_NAME, 'product');
606 606
 
607
-		return apply_filters( 'wl_valid_entity_post_types', $post_types );
607
+		return apply_filters('wl_valid_entity_post_types', $post_types);
608 608
 	}
609 609
 
610 610
 }
Please login to merge, or discard this patch.