Completed
Push — develop ( 45137e...afa03d )
by Naveen
02:50
created

Wordlift_Entity_Service   F

Complexity

Total Complexity 60

Size/Duplication

Total Lines 624
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 624
rs 3.576
c 0
b 0
f 0
wmc 60
lcom 3
cbo 6

20 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A get_instance() 0 4 1
A is_entity() 0 29 5
A get_classification_scope_for() 0 19 4
A is_used() 0 42 4
A get_entity_post_by_uri() 0 4 1
B save_post() 0 27 10
A set_alternative_labels() 0 26 5
A get_alternative_labels() 0 4 1
A get_labels() 0 4 1
A edit_form_before_permalink() 0 21 3
A get_uri() 0 14 4
A get_alternative_label_input() 0 4 1
A count() 0 26 2
A add_criterias() 0 31 1
A create() 0 25 4
A get_related_entities() 0 4 1
A get() 0 11 1
A valid_entity_post_types() 0 7 1
B get_uri_for_post() 0 36 9

How to fix   Complexity   

Complex Class

Complex classes like Wordlift_Entity_Service often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Wordlift_Entity_Service, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * Services: Entity Service.
4
 *
5
 * @since 3.1.0
6
 * @package Wordlift
7
 * @subpackage Wordlift/includes
8
 */
9
10
use Wordlift\Object_Type_Enum;
11
12
/**
13
 * Provide entity-related services.
14
 *
15
 * @since 3.1.0
16
 * @package Wordlift
17
 * @subpackage Wordlift/includes
18
 */
19
class Wordlift_Entity_Service {
20
21
	/**
22
	 * The Log service.
23
	 *
24
	 * @since  3.2.0
25
	 * @access private
26
	 * @var \Wordlift_Log_Service $log The Log service.
27
	 */
28
	private $log;
29
30
	/**
31
	 * The UI service.
32
	 *
33
	 * @since  3.2.0
34
	 * @access private
35
	 * @var \Wordlift_UI_Service $ui_service The UI service.
36
	 */
37
	private $ui_service;
38
39
	/**
40
	 * The {@link Wordlift_Relation_Service} instance.
41
	 *
42
	 * @since  3.15.0
43
	 * @access private
44
	 * @var \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
45
	 */
46
	private $relation_service;
47
48
	/**
49
	 * The {@link Wordlift_Entity_Uri_Service} instance.
50
	 *
51
	 * @since  3.16.3
52
	 * @access private
53
	 * @var \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
54
	 */
55
	private $entity_uri_service;
56
57
	/**
58
	 * The entity post type name.
59
	 *
60
	 * @since 3.1.0
61
	 */
62
	const TYPE_NAME = 'entity';
63
64
	/**
65
	 * The alternative label meta key.
66
	 *
67
	 * @since 3.2.0
68
	 */
69
	const ALTERNATIVE_LABEL_META_KEY = '_wl_alt_label';
70
71
	/**
72
	 * The alternative label input template.
73
	 *
74
	 * @since 3.2.0
75
	 */
76
	// TODO: this should be moved to a class that deals with HTML code.
77
	const ALTERNATIVE_LABEL_INPUT_TEMPLATE = '<div class="wl-alternative-label">
78
                <label class="screen-reader-text" id="wl-alternative-label-prompt-text" for="wl-alternative-label">Enter alternative label here</label>
79
                <input name="wl_alternative_label[]" size="30" value="%s" id="wl-alternative-label" type="text">
80
                <button class="button wl-delete-button">%s</button>
81
                </div>';
82
83
	/**
84
	 * A singleton instance of the Entity service.
85
	 *
86
	 * @since  3.2.0
87
	 * @access private
88
	 * @var \Wordlift_Entity_Service $instance A singleton instance of the Entity service.
89
	 */
90
	private static $instance;
91
92
	/**
93
	 * Create a Wordlift_Entity_Service instance.
94
	 *
95
	 * @param \Wordlift_UI_Service $ui_service The UI service.
96
	 * @param \Wordlift_Relation_Service $relation_service The {@link Wordlift_Relation_Service} instance.
97
	 * @param \Wordlift_Entity_Uri_Service $entity_uri_service The {@link Wordlift_Entity_Uri_Service} instance.
98
	 *
99
	 * @since 3.2.0
100
	 *
101
	 */
102
	public function __construct( $ui_service, $relation_service, $entity_uri_service ) {
103
104
		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Entity_Service' );
105
106
		$this->ui_service         = $ui_service;
107
		$this->relation_service   = $relation_service;
108
		$this->entity_uri_service = $entity_uri_service;
109
110
		// Set the singleton instance.
111
		self::$instance = $this;
112
	}
113
114
	/**
115
	 * Get the singleton instance of the Entity service.
116
	 *
117
	 * @return \Wordlift_Entity_Service The singleton instance of the Entity service.
118
	 * @since 3.2.0
119
	 */
120
	public static function get_instance() {
121
122
		return self::$instance;
123
	}
124
125
	/**
126
	 * Determines whether a post is an entity or not. Entity is in this context
127
	 * something which is not an article.
128
	 *
129
	 * @param int $post_id A post id.
130
	 *
131
	 * @return bool Return true if the post is an entity otherwise false.
132
	 * @since 3.1.0
133
	 *
134
	 */
135
	public function is_entity( $post_id ) {
136
137
		$terms = wp_get_object_terms( $post_id, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
138
139
		if ( is_wp_error( $terms ) ) {
140
			$this->log->error( "Cannot get the terms for post $post_id: " . $terms->get_error_message() );
141
142
			return false;
143
		}
144
145
		if ( empty( $terms ) ) {
146
			return false;
147
		}
148
149
		/*
150
		 * We don't consider an `article` to be an entity.
151
		 *
152
		 * @since 3.20.0 At least one associated mustn't be an `article`.
153
		 *
154
		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
155
		 */
156
		foreach ( $terms as $term ) {
157
			if ( 1 !== preg_match( '~(^|-)article$~', $term->slug ) ) {
158
				return true;
159
			}
160
		}
161
162
		return false;
163
	}
164
165
	/**
166
	 * Get the proper classification scope for a given entity post
167
	 *
168
	 * @param integer $post_id An entity post id.
169
	 *
170
	 * @param string $default The default classification scope, `what` if not
171
	 *                         provided.
172
	 *
173
	 * @return string Returns a classification scope (e.g. 'what').
174
	 * @since 3.5.0
175
	 *
176
	 */
177
	public function get_classification_scope_for( $post_id, $default = WL_WHAT_RELATION ) {
178
179
		if ( false === $this->is_entity( $post_id ) ) {
180
			return $default;
181
		}
182
183
		// Retrieve the entity type
184
		$entity_type_arr = Wordlift_Entity_Type_Service::get_instance()->get( $post_id );
185
		$entity_type     = str_replace( 'wl-', '', $entity_type_arr['css_class'] );
186
		// Retrieve classification boxes configuration
187
		$classification_boxes = unserialize( WL_CORE_POST_CLASSIFICATION_BOXES );
188
		foreach ( $classification_boxes as $cb ) {
189
			if ( in_array( $entity_type, $cb['registeredTypes'] ) ) {
190
				return $cb['id'];
191
			}
192
		}
193
194
		return $default;
195
	}
196
197
	/**
198
	 * Check whether a {@link WP_Post} is used.
199
	 *
200
	 * @param int $post_id The {@link WP_Post}'s id.
201
	 *
202
	 * @return bool|null Null if it's not an entity, otherwise true if it's used.
203
	 */
204
	public function is_used( $post_id ) {
205
206
		if ( false === $this->is_entity( $post_id ) ) {
207
			return null;
208
		}
209
		// Retrieve the post
210
		$entity = get_post( $post_id );
211
212
		global $wpdb;
213
		// Retrieve Wordlift relation instances table name
214
		$table_name = wl_core_get_relation_instances_table_name();
215
216
		// Check is it's referenced / related to another post / entity
217
		$stmt = $wpdb->prepare(
218
			"SELECT COUNT(*) FROM $table_name WHERE  object_id = %d",
219
			$entity->ID
220
		);
221
222
		// Perform the query
223
		$relation_instances = (int) $wpdb->get_var( $stmt );
224
		// If there is at least one relation instance for the current entity, then it's used
225
		if ( 0 < $relation_instances ) {
226
			return true;
227
		}
228
229
		// Check if the entity uri is used as meta_value
230
		$stmt = $wpdb->prepare(
231
			"SELECT COUNT(*) FROM $wpdb->postmeta WHERE post_id != %d AND meta_value = %s",
232
			$entity->ID,
233
			wl_get_entity_uri( $entity->ID )
0 ignored issues
show
Deprecated Code introduced by
The function wl_get_entity_uri() has been deprecated with message: use Wordlift_Entity_Service::get_instance()->get_uri( $post_id )

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
234
		);
235
		// Perform the query
236
		$meta_instances = (int) $wpdb->get_var( $stmt );
237
238
		// If there is at least one meta that refers the current entity uri, then current entity is used
239
		if ( 0 < $meta_instances ) {
240
			return true;
241
		}
242
243
		// If we are here, it means the current entity is not used at the moment
244
		return false;
245
	}
246
247
	/**
248
	 * Find entity posts by the entity URI. Entity as searched by their entity URI or same as.
249
	 *
250
	 * @param string $uri The entity URI.
251
	 *
252
	 * @return WP_Post|null A WP_Post instance or null if not found.
253
	 * @deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
254
	 *
255
	 * @since      3.16.3 deprecated in favor of Wordlift_Entity_Uri_Service->get_entity( $uri );
256
	 * @since      3.2.0
257
	 *
258
	 */
259
	public function get_entity_post_by_uri( $uri ) {
260
261
		return $this->entity_uri_service->get_entity( $uri );
262
	}
263
264
	/**
265
	 * Fires once a post has been saved. This function uses the $_REQUEST, therefore
266
	 * we check that the post we're saving is the current post.
267
	 *
268
	 * @see   https://github.com/insideout10/wordlift-plugin/issues/363
269
	 *
270
	 * @since 3.2.0
271
	 *
272
	 * @param int $post_id Post ID.
273
	 * @param WP_Post $post Post object.
274
	 * @param bool $update Whether this is an existing post being updated or not.
275
	 */
276
	public function save_post( $post_id, $post, $update ) {
0 ignored issues
show
Unused Code introduced by
The parameter $update is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
277
278
		// Avoid doing anything if post is autosave or a revision.
279
		if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
280
			return;
281
		}
282
283
		// We're setting the alternative label that have been provided via the UI
284
		// (in fact we're using $_REQUEST), while save_post may be also called
285
		// programmatically by some other function: we need to check therefore if
286
		// the $post_id in the save_post call matches the post id set in the request.
287
		//
288
		// If this is not the current post being saved or if it's not an entity, return.
289
		if ( ! isset( $_REQUEST['post_ID'] ) || $_REQUEST['post_ID'] != $post_id || ! $this->is_entity( $post_id ) ) {
290
			return;
291
		}
292
293
		// Get the alt labels from the request (or empty array).
294
		$alt_labels = isset( $_REQUEST['wl_alternative_label'] ) ? $_REQUEST['wl_alternative_label'] : array();
295
296
		if ( ( ! empty( $_POST['content'] ) && ! empty( $_POST['post_content'] ) ) || isset( $_REQUEST['wl_alternative_label'] ) ) {
297
			// This is via classic editor, so set the alternative labels.
298
			$this->set_alternative_labels( $post_id, $alt_labels );
299
		}
300
301
302
	}
303
304
	/**
305
	 * Set the alternative labels.
306
	 *
307
	 * @param int $post_id The post id.
308
	 * @param array $alt_labels An array of labels.
309
	 *
310
	 * @since 3.2.0
311
	 *
312
	 */
313
	public function set_alternative_labels( $post_id, $alt_labels ) {
314
315
		// Bail out if post id is not numeric. We add this check as we found a WP install that was sending a WP_Error
316
		// instead of post id.
317
		if ( ! is_numeric( $post_id ) ) {
318
			return;
319
		}
320
321
		// Force $alt_labels to be an array
322
		if ( ! is_array( $alt_labels ) ) {
323
			$alt_labels = array( $alt_labels );
324
		}
325
326
		$this->log->debug( "Setting alternative labels [ post id :: $post_id ][ alt labels :: " . implode( ',', $alt_labels ) . " ]" );
327
328
		// Delete all the existing alternate labels.
329
		delete_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
330
331
		// Set the alternative labels.
332
		foreach ( $alt_labels as $alt_label ) {
333
			if ( ! empty( $alt_label ) ) {
334
				add_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY, $alt_label );
335
			}
336
		}
337
338
	}
339
340
	/**
341
	 * Retrieve the alternate labels.
342
	 *
343
	 * @param int $post_id Post id.
344
	 *
345
	 * @return mixed An array  of alternative labels.
346
	 * @since 3.2.0
347
	 *
348
	 */
349
	public function get_alternative_labels( $post_id ) {
350
351
		return get_post_meta( $post_id, self::ALTERNATIVE_LABEL_META_KEY );
352
	}
353
354
	/**
355
	 * Retrieve the labels for an entity, i.e. the title + the synonyms.
356
	 *
357
	 * @param int $post_id The entity {@link WP_Post} id.
358
	 *
359
	 * @return array An array with the entity title and labels.
360
	 * @since 3.12.0
361
	 *
362
	 */
363
	public function get_labels( $post_id ) {
364
365
		return array_merge( (array) get_the_title( $post_id ), $this->get_alternative_labels( $post_id ) );
366
	}
367
368
	/**
369
	 * Fires before the permalink field in the edit form (this event is available in WP from 4.1.0).
370
	 *
371
	 * @param WP_Post $post Post object.
372
	 *
373
	 * @since 3.2.0
374
	 *
375
	 */
376
	public function edit_form_before_permalink( $post ) {
377
378
		// If it's not an entity, return.
379
		if ( ! $this->is_entity( $post->ID ) ) {
380
			return;
381
		}
382
383
		// Print the input template.
384
		$this->ui_service->print_template( 'wl-tmpl-alternative-label-input', $this->get_alternative_label_input() );
385
386
		// Print all the currently set alternative labels.
387
		foreach ( $this->get_alternative_labels( $post->ID ) as $alt_label ) {
388
389
			echo $this->get_alternative_label_input( $alt_label );
390
391
		};
392
393
		// Print the button.
394
		$this->ui_service->print_button( 'wl-add-alternative-labels-button', __( 'Add more titles', 'wordlift' ) );
395
396
	}
397
398
	/**
399
	 * Get the URI for the entity with the specified post id.
400
	 *
401
	 * @param int $post_id The entity post id.
402
	 *
403
	 * @return null|string The entity URI or NULL if not found or the dataset URI is not configured.
404
	 * @since 3.6.0
405
	 *
406
	 */
407
	private function get_uri_for_post( $post_id ) {
408
409
		$log = Wordlift_Log_Service::get_logger( get_class() );
410
411
		// If a null is given, nothing to do
412
		if ( is_null( $post_id ) ) {
413
			return null;
414
		}
415
416
		$dataset_uri = wl_configuration_get_redlink_dataset_uri();
0 ignored issues
show
Deprecated Code introduced by
The function wl_configuration_get_redlink_dataset_uri() has been deprecated with message: use Wordlift_Configuration_Service::get_instance()->get_dataset_uri();

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
417
418
		if ( empty( $dataset_uri ) ) {
419
			// Continue even if the dataset uri is not properly configured. It is handled in function wl_build_entity_uri()
420
			$log->debug( 'Continuing, dataset uri not configured...' );
421
		}
422
423
		$uri = get_post_meta( $post_id, WL_ENTITY_URL_META_NAME, true );
424
425
		/*
426
		 * Consider the URI invalid if it doesn't start with the dataset URI.
427
		 *
428
		 * @see https://github.com/insideout10/wordlift-plugin/issues/996
429
		 */
430
		if ( null === $dataset_uri || 0 !== strpos( $uri, $dataset_uri ) ) {
431
			$uri = null;
432
		}
433
434
		// Set the URI if it isn't set yet.
435
		$post_status = get_post_status( $post_id );
436
		if ( empty( $uri ) && 'auto-draft' !== $post_status && 'revision' !== $post_status && 'inherit' !== $post_status ) {
437
			$uri = wl_build_entity_uri( $post_id );
438
			wl_set_entity_uri( $post_id, $uri );
439
		}
440
441
		return $uri;
442
	}
443
444
	public function get_uri( $object_id, $type = Object_Type_Enum::POST ) {
445
446
		if ( Object_Type_Enum::POST === $type ) {
447
			return $this->get_uri_for_post( $object_id );
448
		}
449
450
		if ( Object_Type_Enum::USER === $type ) {
451
			$uri = Wordlift_User_Service::get_instance()->get_uri( $object_id );
452
453
			return ( false === $uri ? null : $uri );
454
		}
455
456
		return null;
457
	}
458
459
	/**
460
	 * Get the alternative label input HTML code.
461
	 *
462
	 * @param string $value The input value.
463
	 *
464
	 * @return string The input HTML code.
465
	 * @since 3.2.0
466
	 *
467
	 */
468
	private function get_alternative_label_input( $value = '' ) {
469
470
		return sprintf( self::ALTERNATIVE_LABEL_INPUT_TEMPLATE, esc_attr( $value ), __( 'Delete', 'wordlift' ) );
471
	}
472
473
	/**
474
	 * Get the number of entity posts published in this blog.
475
	 *
476
	 * @return int The number of published entity posts.
477
	 * @since 3.6.0
478
	 *
479
	 */
480
	public function count() {
481
		global $wpdb;
482
483
		// Try to get the count from the transient.
484
		$count = get_transient( '_wl_entity_service__count' );
485
		if ( false !== $count ) {
486
			return $count;
487
		}
488
489
		// Query the count.
490
		$count = $wpdb->get_var( $wpdb->prepare(
491
			"SELECT COUNT( DISTINCT( tr.object_id ) )"
492
			. " FROM {$wpdb->term_relationships} tr"
493
			. " INNER JOIN {$wpdb->term_taxonomy} tt"
494
			. "  ON tt.taxonomy = %s AND tt.term_taxonomy_id = tr.term_taxonomy_id"
495
			. " INNER JOIN {$wpdb->terms} t"
496
			. "  ON t.term_id = tt.term_id AND t.name != %s",
497
			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
498
			'article'
499
		) );
500
501
		// Store the count in cache.
502
		set_transient( '_wl_entity_service__count', $count, 900 );
503
504
		return $count;
505
	}
506
507
	/**
508
	 * Add the entity filtering criterias to the arguments for a `get_posts`
509
	 * call.
510
	 *
511
	 * @param array $args The arguments for a `get_posts` call.
512
	 *
513
	 * @return array The arguments for a `get_posts` call.
514
	 * @since 3.15.0
515
	 *
516
	 */
517
	public static function add_criterias( $args ) {
518
519
		// Build an optimal tax-query.
520
		$tax_query = array(
521
			'relation' => 'AND',
522
			array(
523
				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
524
				'operator' => 'EXISTS',
525
			),
526
			array(
527
				'taxonomy' => Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
528
				'field'    => 'slug',
529
				'terms'    => 'article',
530
				'operator' => 'NOT IN',
531
			),
532
		);
533
534
		return $args + array(
535
				'post_type' => Wordlift_Entity_Service::valid_entity_post_types(),
536
				/*
537
				 * Ensure compatibility with Polylang.
538
				 *
539
				 * @see https://github.com/insideout10/wordlift-plugin/issues/855.
540
				 * @see https://wordpress.org/support/topic/parse_query-filter-adds-language-taxonomy-to-query/.
541
				 *
542
				 * @since 3.19.5
543
				 */
544
				'lang'      => '',
545
				'tax_query' => $tax_query,
546
			);
547
	}
548
549
	/**
550
	 * Create a new entity.
551
	 *
552
	 * @param string $name The entity name.
553
	 * @param string $type_uri The entity's type URI.
554
	 * @param null $logo The entity logo id (or NULL if none).
555
	 * @param string $status The post status, by default 'publish'.
556
	 *
557
	 * @return int|WP_Error The entity post id or a {@link WP_Error} in case the `wp_insert_post` call fails.
558
	 * @since 3.9.0
559
	 *
560
	 */
561
	public function create( $name, $type_uri, $logo = null, $status = 'publish' ) {
562
563
		// Create an entity for the publisher.
564
		$post_id = @wp_insert_post( array(
565
			'post_type'    => self::TYPE_NAME,
566
			'post_title'   => $name,
567
			'post_status'  => $status,
568
			'post_content' => '',
569
		) );
570
571
		// Return the error if any.
572
		if ( is_wp_error( $post_id ) ) {
573
			return $post_id;
574
		}
575
576
		// Set the entity logo.
577
		if ( $logo && is_numeric( $logo ) ) {
578
			set_post_thumbnail( $post_id, $logo );
579
		}
580
581
		// Set the entity type.
582
		Wordlift_Entity_Type_Service::get_instance()->set( $post_id, $type_uri );
583
584
		return $post_id;
585
	}
586
587
	/**
588
	 * Get the entities related to the one with the specified id. By default only
589
	 * published entities will be returned.
590
	 *
591
	 * @param int $id The post id.
592
	 * @param string $post_status The target post status (default = publish).
593
	 *
594
	 * @return array An array of post ids.
595
	 * @since 3.10.0
596
	 *
597
	 */
598
	public function get_related_entities( $id, $post_status = 'publish' ) {
599
600
		return $this->relation_service->get_objects( $id, 'ids', null, $post_status );
601
	}
602
603
	/**
604
	 * Get the list of entities.
605
	 *
606
	 * @param array $params Custom parameters for WordPress' own {@link get_posts} function.
607
	 *
608
	 * @return array An array of entity posts.
609
	 * @since 3.12.2
610
	 *
611
	 */
612
	public function get( $params = array() ) {
613
614
		// Set the defaults.
615
		$defaults = array( 'post_type' => 'entity' );
616
617
		// Merge the defaults with the provided parameters.
618
		$args = wp_parse_args( $params, $defaults );
619
620
		// Call the `get_posts` function.
621
		return get_posts( $args );
622
	}
623
624
	/**
625
	 * The list of post type names which can be used for entities
626
	 *
627
	 * Criteria is that the post type is public. The list of valid post types
628
	 * can be overridden with a filter.
629
	 *
630
	 * @return array Array containing the names of the valid post types.
631
	 * @since 3.15.0
632
	 *
633
	 */
634
	static function valid_entity_post_types() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
635
636
		// Ignore builtins in the call to avoid getting attachments.
637
		$post_types = array( 'post', 'page', self::TYPE_NAME, 'product' );
638
639
		return apply_filters( 'wl_valid_entity_post_types', $post_types );
640
	}
641
642
}
643