PluginProbe
Parse.ly / 3.16.1
Parse.ly v3.16.1
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / Metadata / class-metadata-builder.php

class-metadata-builder.php in Parse.ly 3.16.1, at src/Metadata/class-metadata-builder.php

692 lines 21.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Front Page Metadata Builder class
4 *
5 * @package Parsely
6 * @since 3.4.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\Metadata;
12
13 use Parsely\Parsely;
14 use WP_Post;
15 use WP_User;
16
17 use function Parsely\Utils\get_default_category;
18
19 /**
20 * Abstract class that implements modular builders for Metadata.
21 *
22 * It should be extended in subclasses that implement a particular page view to render
23 * metadata for. Specifically, the `get_metadata()` method should be implemented.
24 *
25 * @since 1.0.0
26 * @since 3.3.0 Logic extracted from Parsely\Parsely class to separate file/class.
27 *
28 * @phpstan-import-type Parsely_Options from Parsely
29 */
30 abstract class Metadata_Builder {
31 /**
32 * Instance of Parsely class.
33 *
34 * @var Parsely
35 */
36 protected $parsely;
37
38 /**
39 * Array holding the metadata keys and values.
40 *
41 * @var array<string, mixed>
42 */
43 protected $metadata = array();
44
45 /**
46 * Constructor.
47 *
48 * @param Parsely $parsely Instance of Parsely class.
49 */
50 public function __construct( Parsely $parsely ) {
51 $this->parsely = $parsely;
52 }
53
54 /**
55 * Generates the metadata object by calling the build_* methods and
56 * returns the value.
57 *
58 * @since 3.4.0
59 *
60 * @return array<string, mixed>
61 */
62 abstract public function get_metadata(): array;
63
64 /**
65 * Builds basic metadata present in all pages.
66 *
67 * @since 3.4.0
68 */
69 protected function build_basic(): void {
70 $this->metadata['@context'] = 'https://schema.org';
71 $this->metadata['@type'] = 'WebPage';
72 }
73
74 /**
75 * Populates the url field in the metadata object.
76 *
77 * @since 3.4.0
78 */
79 protected function build_url(): void {
80 $this->metadata['url'] = $this->get_current_url();
81 }
82
83 /**
84 * Populates the @type field in the metadata object.
85 *
86 * @param WP_Post $post The post/page for which to populate the field.
87 * @param string $parsely_type Parse.ly post type. Can be 'post' or 'non-post'.
88 *
89 * @since 3.4.0
90 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
91 */
92 protected function build_type( WP_Post $post, string $parsely_type ): void {
93 $default_type = 'post' === $parsely_type ? 'NewsArticle' : 'WebPage';
94
95 /**
96 * Filters the JSON-LD @type.
97 *
98 * @since 2.5.0
99 *
100 * @param string $jsonld_type JSON-LD @type value, default is NewsArticle.
101 * @param int $id Post ID.
102 * @param string $post_type The Post type in WordPress.
103 */
104 $type = apply_filters( 'wp_parsely_post_type', $default_type, $post->ID, $post->post_type );
105 $supported_types = $this->parsely->get_all_supported_types();
106
107 // Validate type before passing it further as an invalid type will not be recognized by Parse.ly.
108 if ( ! in_array( $type, $supported_types, true ) ) {
109 $error = sprintf(
110 /* translators: 1: JSON @type like NewsArticle, 2: URL */
111 __( '@type %1$s is not supported by Parse.ly. Please use a type mentioned in %2$s', 'wp-parsely' ),
112 $type,
113 'https://docs.parse.ly/metadata-jsonld/#distinguishing-between-posts-and-non-posts-pages'
114 );
115 // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
116 trigger_error( esc_html( $error ), E_USER_WARNING );
117 $type = $default_type;
118 }
119
120 $this->metadata['@type'] = $type;
121 }
122
123 /**
124 * Populates the mainEntityOfPage field in the metadata object.
125 *
126 * @param string $build_url_type Parse.ly post type to use for building the
127 * URL. Can be 'post' or 'non-post'.
128 *
129 * @since 3.4.0
130 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
131 */
132 protected function build_main_entity( string $build_url_type ): void {
133 $this->metadata['mainEntityOfPage'] = array(
134 '@type' => 'WebPage',
135 '@id' => $this->get_current_url( $build_url_type ),
136 );
137 }
138
139 /**
140 * Populates the author and creator fields in the metadata object.
141 *
142 * @since 3.4.0
143 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
144 *
145 * @param WP_Post $post The post/page for which to populate the fields.
146 */
147 protected function build_author( WP_Post $post ): void {
148 $authors = $this->get_author_names( $post );
149 $author_objects = array();
150 foreach ( $authors as $author ) {
151 $author_tag = array(
152 '@type' => 'Person',
153 'name' => $author,
154 );
155 $author_objects[] = $author_tag;
156 }
157 $this->metadata['author'] = $author_objects;
158 $this->metadata['creator'] = $authors;
159 }
160
161 /**
162 * Populates the publisher field in the metadata object.
163 *
164 * @since 3.4.0
165 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
166 */
167 protected function build_publisher(): void {
168 $this->metadata['publisher'] = array(
169 '@type' => 'Organization',
170 'name' => get_bloginfo( 'name' ),
171 'logo' => $this->parsely->get_options()['logo'],
172 );
173 }
174
175 /**
176 * Populates all the fields related to time in the metadata object.
177 *
178 * @param WP_Post $post The post/page for which to populate the field.
179 *
180 * @since 3.0.2
181 * @since 3.3.0 Moved to class-metadata.
182 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
183 */
184 protected function build_metadata_post_times( WP_Post $post ): void {
185 $date_format = 'Y-m-d\TH:i:s\Z';
186 $post_created_gmt = get_post_time( $date_format, true, $post );
187
188 if ( false === $post_created_gmt ) {
189 return;
190 }
191
192 $this->metadata['dateCreated'] = $post_created_gmt;
193 $this->metadata['datePublished'] = $post_created_gmt;
194 $this->metadata['dateModified'] = $post_created_gmt;
195
196 $post_modified_gmt = get_post_modified_time( $date_format, true, $post );
197
198 if ( false !== $post_modified_gmt && $post_modified_gmt > $post_created_gmt ) {
199 $this->metadata['dateModified'] = $post_modified_gmt;
200 }
201 }
202
203 /**
204 * Populates the articleSection field in the metadata object.
205 *
206 * @since 3.4.0
207 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
208 *
209 * @param WP_Post $post The post/page for which to populate the field.
210 */
211 protected function build_article_section( WP_Post $post ): void {
212 $this->metadata['articleSection'] = $this->get_category_name( $post, $this->parsely->get_options() );
213 }
214
215 /**
216 * Populates the keywords field in the metadata object.
217 *
218 * @since 3.4.0
219 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
220 *
221 * @param WP_Post $post The post/page for which to populate the field.
222 */
223 protected function build_keywords( WP_Post $post ): void {
224 $options = $this->parsely->get_options();
225 $tags = $this->get_tags( $post->ID );
226 if ( $options['cats_as_tags'] ) {
227 $tags = array_merge( $tags, $this->get_categories( $post->ID ) );
228 // add custom taxonomy values.
229 $tags = array_merge( $tags, $this->get_custom_taxonomy_values( $post ) );
230 }
231 // The function 'mb_strtolower' is not enabled by default in php, so this check
232 // falls back to the native php function 'strtolower' if necessary.
233 if ( function_exists( 'mb_strtolower' ) ) {
234 $lowercase_callback = 'mb_strtolower';
235 } else {
236 $lowercase_callback = 'strtolower';
237 }
238 if ( $options['lowercase_tags'] ) {
239 $tags = array_map( $lowercase_callback, $tags );
240 }
241
242 /**
243 * Filters the post tags that are used as metadata keywords.
244 *
245 * @since 1.8.0
246 *
247 * @param array<string> $tags Post tags.
248 * @param int $ID Post ID.
249 */
250 $tags = apply_filters( 'wp_parsely_post_tags', $tags, $post->ID );
251 $tags = array_map( array( $this, 'clean_value' ), $tags );
252
253 $this->metadata['keywords'] = array_values( array_unique( $tags ) );
254 }
255
256 /**
257 * Populates the thumbnailUrl field in the metadata object.
258 *
259 * @param WP_Post $post The post/page for which to populate the field.
260 *
261 * @since 3.4.0
262 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
263 */
264 protected function build_thumbnail_url( WP_Post $post ): void {
265 $thumb_url = get_the_post_thumbnail_url( $post, 'thumbnail' );
266 if ( ! is_string( $thumb_url ) ) {
267 $thumb_url = '';
268 }
269 $this->metadata['thumbnailUrl'] = $thumb_url;
270 }
271
272 /**
273 * Populates the image field in the metadata object.
274 *
275 * @param WP_Post $post The post/page for which to populate the field.
276 *
277 * @since 3.4.0
278 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
279 */
280 protected function build_image( WP_Post $post ): void {
281 $image_url = get_the_post_thumbnail_url( $post, 'full' );
282 if ( ! is_string( $image_url ) ) {
283 $image_url = '';
284 }
285 $this->metadata['image'] = array(
286 '@type' => 'ImageObject',
287 'url' => $image_url,
288 );
289 }
290
291 /**
292 * Sanitizes string content.
293 *
294 * @since 2.6.0
295 * @since 3.4.0 Moved to class-metadata-builder.
296 *
297 * @param string|null $val The content you'd like sanitized.
298 * @return string
299 */
300 protected function clean_value( ?string $val ): string {
301 if ( null === $val ) {
302 return '';
303 }
304
305 return trim( wp_strip_all_tags( str_replace( array( "\n", "\r" ), '', $val ) ) );
306 }
307
308 /**
309 * Gets the URL of the current PHP script.
310 *
311 * A fall-back implementation to determine permalink.
312 *
313 * @since 3.0.0 $parsely_type Default parameter changed to `non-post`.
314 * @since 3.4.0 Moved to class-metadata-builder.
315 *
316 * @param string $parsely_type Optional. Parse.ly post type you're interested in, either 'post'
317 * or 'non-post'. Default is 'non-post'.
318 * @param int $post_id Optional. ID of the post you want to get the URL for. Default is
319 * 0, which means the global `$post` is used.
320 * @return string
321 */
322 protected function get_current_url( string $parsely_type = 'non-post', int $post_id = 0 ): string {
323 if ( 'post' === $parsely_type ) {
324 $permalink = (string) get_permalink( $post_id );
325
326 /**
327 * Filters the permalink for a post.
328 *
329 * @since 1.14.0
330 * @since 2.5.0 Added $post_id.
331 *
332 * @param string $permalink The permalink URL or false if post does not exist.
333 * @param string $parsely_type Parse.ly type ("post" or "non-post").
334 * @param int $post_id ID of the post you want to get the URL for. May be 0, so
335 * $permalink will be for the global $post.
336 */
337 $url = apply_filters( 'wp_parsely_permalink', $permalink, $parsely_type, $post_id );
338 } else {
339 $request_uri = isset( $_SERVER['REQUEST_URI'] )
340 ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) )
341 : '';
342
343 $url = home_url( $request_uri );
344 }
345
346 $options = $this->parsely->get_options();
347 return $options['force_https_canonicals']
348 ? str_replace( 'http://', 'https://', $url )
349 : str_replace( 'https://', 'http://', $url );
350 }
351
352 /**
353 * Returns a properly cleaned category/taxonomy value and will optionally
354 * use the top-level category/taxonomy value, if so instructed via the
355 * use_top_level_cats option.
356 *
357 * @since 3.3.0 Moved to class-metadata.
358 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
359 *
360 * @param WP_Post $post_obj The object for the post.
361 * @param Parsely_Options $parsely_options The parsely options.
362 * @return string Cleaned category name for the post in question.
363 */
364 private function get_category_name( WP_Post $post_obj, $parsely_options ): string {
365 $taxonomy_dropdown_choice = get_the_terms( $post_obj->ID, $parsely_options['custom_taxonomy_section'] );
366 // Get top-level taxonomy name for chosen taxonomy and assign to $parent_name; it will be used
367 // as the category value if 'use_top_level_cats' option is checked.
368 // Assign as the default category name if no value is checked for the chosen taxonomy.
369 $category_name = get_cat_name( get_default_category() );
370 if ( false !== $taxonomy_dropdown_choice && ! is_wp_error( $taxonomy_dropdown_choice ) ) {
371 if ( $parsely_options['use_top_level_cats'] ) {
372 $first_term = array_shift( $taxonomy_dropdown_choice );
373 if ( null !== $first_term ) {
374 $term_name = $this->get_top_level_term( $first_term->term_id, $first_term->taxonomy );
375 }
376 } else {
377 $term_name = $this->get_bottom_level_term( $post_obj->ID, $parsely_options['custom_taxonomy_section'] );
378 }
379
380 if ( isset( $term_name ) && is_string( $term_name ) && 0 < strlen( $term_name ) ) {
381 $category_name = $term_name;
382 }
383 }
384
385 /**
386 * Filters the constructed category name.
387 *
388 * @since 1.8.0
389 *
390 * @param string $category Category name.
391 * @param WP_Post $post_obj Post object.
392 * @param array<string, mixed> $parsely_options The Parsely options.
393 */
394 $category_name = apply_filters( 'wp_parsely_post_category', $category_name, $post_obj, $parsely_options );
395
396 return $this->clean_value( $category_name );
397 }
398
399 /**
400 * Returns the top-most category/taxonomy value in a hierarchy given a
401 * taxonomy value's ID.
402 *
403 * (WordPress calls taxonomy values 'terms').
404 *
405 * @since 3.3.0 Moved to class-metadata.
406 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
407 *
408 * @param int $term_id The ID of the top level term.
409 * @param string $taxonomy_name The name of the taxonomy.
410 * @return string|false $parent The top level name of the category/taxonomy.
411 */
412 private function get_top_level_term( int $term_id, string $taxonomy_name ) {
413 $parent = get_term_by( 'id', $term_id, $taxonomy_name );
414
415 while ( false !== $parent && isset( $parent->parent ) && 0 !== $parent->parent ) {
416 $parent = get_term_by( 'id', $parent->parent, $taxonomy_name );
417 }
418
419 return $parent->name ?? false;
420 }
421
422 /**
423 * Returns the bottom-most category/taxonomy value in a hierarchy given a
424 * post ID.
425 *
426 * (WordPress calls taxonomy values 'terms').
427 *
428 * @since 3.3.0 Moved to class-metadata.
429 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
430 *
431 * @param int $post_id The post id you're interested in.
432 * @param string $taxonomy_name The name of the taxonomy.
433 * @return string Name of the custom taxonomy.
434 */
435 private function get_bottom_level_term( int $post_id, string $taxonomy_name ): string {
436 $terms = get_the_terms( $post_id, $taxonomy_name );
437
438 if ( ! is_array( $terms ) ) {
439 return '';
440 }
441
442 $term_ids = wp_list_pluck( $terms, 'term_id' );
443 $parents = array_filter( wp_list_pluck( $terms, 'parent' ) );
444
445 // Get array of IDs of terms which are not parents.
446 $term_ids_not_parents = array_diff( $term_ids, $parents );
447 // Get corresponding term objects, which are mapped to array index keys.
448 $terms_not_parents = array_intersect_key( $terms, $term_ids_not_parents );
449 // remove array index keys.
450 $terms_not_parents_cleaned = array_values( $terms_not_parents );
451
452 if ( isset( $terms_not_parents_cleaned[0] ) ) {
453 // If you assign multiple child terms in a custom taxonomy, will only return the first.
454 return $terms_not_parents_cleaned[0]->name;
455 }
456
457 return '';
458 }
459
460 /**
461 * Retrieves all the authors for a post as an array. Can include multiple
462 * authors if the Co-Authors Plus plugin is in use.
463 *
464 * @since 3.3.0 Moved to class-metadata.
465 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
466 *
467 * @param WP_Post $post The post object.
468 * @return array<string>
469 */
470 private function get_author_names( WP_Post $post ): array {
471 $authors = $this->get_coauthor_names( $post->ID );
472 if ( 0 === count( $authors ) ) {
473 $post_author = get_user_by( 'id', $post->post_author );
474 if ( false !== $post_author ) {
475 $authors = array( $post_author );
476 }
477 }
478
479 /**
480 * Filters the list of author WP_User objects for a post.
481 *
482 * @since 1.14.0
483 *
484 * @param array<WP_User> $authors One or more authors as WP_User objects.
485 * @param WP_Post $post Post object.
486 */
487 $authors = apply_filters( 'wp_parsely_pre_authors', $authors, $post );
488
489 // Getting the author name for each author.
490 $authors = array_map( array( $this, 'get_author_name' ), $authors );
491
492 /**
493 * Filters the list of author names for a post.
494 *
495 * @since 1.14.0
496 *
497 * @param array<string> $authors One or more author names.
498 * @param WP_Post $post Post object.
499 */
500 $authors = apply_filters( 'wp_parsely_post_authors', $authors, $post );
501
502 return array_map( array( $this, 'clean_value' ), $authors );
503 }
504
505 /**
506 * Returns a list of coauthors for a post assuming the Co-Authors Plus plugin
507 * is installed.
508 *
509 * Borrowed from
510 * https://github.com/Automattic/Co-Authors-Plus/blob/master/template-tags.php#L3-35
511 *
512 * @since 3.3.0 Moved to class-metadata.
513 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
514 *
515 * @param int $post_id The ID of the post.
516 * @return array<WP_User> List of coauthors, or an empty array if the Co-Authors Plus plugin is not active.
517 */
518 private function get_coauthor_names( int $post_id ): array {
519 $coauthors = array();
520 if ( class_exists( 'coauthors_plus' ) ) {
521 global $post, $post_ID, $coauthors_plus;
522
523 if ( $post_id <= 0 && $post_ID ) {
524 $post_id = $post_ID;
525 }
526
527 if ( ! $post_id && $post ) {
528 $post_id = $post->ID;
529 }
530
531 if ( $post_id ) {
532 $coauthor_terms = get_the_terms( $post_id, $coauthors_plus->coauthor_taxonomy );
533
534 if ( is_array( $coauthor_terms ) ) {
535 foreach ( $coauthor_terms as $coauthor ) {
536 $coauthor_slug = preg_replace( '#^cap-#', '', $coauthor->slug );
537 $post_author = $coauthors_plus->get_coauthor_by( 'user_nicename', $coauthor_slug );
538 // In case the user has been deleted while plugin was deactivated.
539 if ( false !== $post_author ) {
540 $coauthors[] = new WP_User( $post_author );
541 }
542 }
543 } elseif ( ! $coauthors_plus->force_guest_authors ) {
544 if ( $post && $post_id === $post->ID ) {
545 $post_author = get_userdata( $post->post_author );
546 }
547 if ( isset( $post_author ) && false !== $post_author ) {
548 $coauthors[] = $post_author;
549 }
550 }
551 // The empty else case is because if we force guest authors, we don't ever care what value wp_posts.post_author has.
552 }
553 }
554 return $coauthors;
555 }
556
557 /**
558 * Determines author name from display name, falling back to firstname
559 * lastname, then nickname and finally the nicename.
560 *
561 * @since 3.3.0 Moved to class-metadata.
562 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
563 *
564 * @param ?WP_User $author The author of the post.
565 * @return string An author name.
566 */
567 private function get_author_name( ?WP_User $author ): string {
568 // Gracefully handle situation where no author is available.
569 if ( null === $author ) {
570 return '';
571 }
572
573 if ( '' !== $author->display_name ) {
574 return $author->display_name;
575 }
576
577 $author_name = $author->user_firstname . ' ' . $author->user_lastname;
578 if ( ' ' !== $author_name ) {
579 return $author_name;
580 }
581
582 if ( '' !== $author->nickname ) {
583 return $author->nickname;
584 }
585
586 if ( '' !== $author->user_nicename ) {
587 return $author->user_nicename;
588 }
589
590 return '';
591 }
592
593 /**
594 * Returns the tags associated with this page or post.
595 *
596 * @since 3.3.0 Moved to class-metadata.
597 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
598 *
599 * @param int $post_id The ID of the post you're trying to get tags for.
600 * @return array<string> The tags of the post represented by the post id.
601 */
602 private function get_tags( int $post_id ): array {
603 /**
604 * Variable.
605 *
606 * @var array<\WP_Term|null>|\WP_Error
607 */
608 $post_tags = wp_get_post_tags( $post_id );
609 $tags = array();
610
611 if ( ! is_wp_error( $post_tags ) ) {
612 foreach ( $post_tags as $wp_tag ) {
613 if ( null !== $wp_tag ) {
614 $tags[] = $wp_tag->name;
615 }
616 }
617 }
618
619 return $tags;
620 }
621
622 /**
623 * Returns an array of all the child categories for the current post.
624 *
625 * @since 3.3.0 Moved to class-metadata.
626 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
627 *
628 * @param int $post_id The ID of the post you're trying to get categories for.
629 * @param string $delimiter What character will delimit the categories.
630 * @return array<string> All the child categories of the current post.
631 */
632 private function get_categories( int $post_id, string $delimiter = '/' ): array {
633 $tags = array();
634 foreach ( get_the_category( $post_id ) as $category ) {
635 $hierarchy = get_category_parents( $category->term_id, false, $delimiter );
636 if ( ! is_wp_error( $hierarchy ) ) {
637 $tags[] = rtrim( $hierarchy, '/' );
638 }
639 }
640 // Take last element in the hierarchy, a string representing the full
641 // parent->child tree, and split it into individual category names.
642 $last_tag = end( $tags );
643 if ( false !== $last_tag ) {
644 $tags = explode( '/', $last_tag );
645 }
646
647 // Remove default category name from tags if needed.
648 $default_category_name = get_cat_name( get_default_category() );
649 return array_diff( $tags, array( $default_category_name ) );
650 }
651
652 /**
653 * Gets all term names from all custom taxonomies assigned to a post.
654 *
655 * @since 3.3.0 Moved to class-metadata.
656 * @since 3.4.0 Moved to class-post-builder.
657 * @since 3.14.0 Moved from `Post_Builder` to `Metadata_Builder`.
658 *
659 * @param WP_Post $post_obj The post object to find the terms for.
660 * @return array<string> Term names.
661 */
662 private function get_custom_taxonomy_values( WP_Post $post_obj ): array {
663 // Filter out default WordPress taxonomies.
664 $all_taxonomies = array_diff(
665 get_taxonomies(),
666 array( 'post_tag', 'nav_menu', 'author', 'link_category', 'post_format' )
667 );
668
669 /**
670 * Filters the taxonomies.
671 *
672 * @since 3.11.0
673 *
674 * @param array<string> $all_taxonomies Taxonomies.
675 * @param WP_Post $post_obj Post object.
676 */
677 $all_taxonomies = apply_filters( 'wp_parsely_custom_taxonomies', $all_taxonomies, $post_obj );
678 $all_values = array();
679
680 foreach ( $all_taxonomies as $taxonomy ) {
681 $custom_taxonomy_objects = get_the_terms( $post_obj->ID, $taxonomy );
682 if ( is_array( $custom_taxonomy_objects ) ) {
683 foreach ( $custom_taxonomy_objects as $custom_taxonomy_object ) {
684 $all_values[] = $custom_taxonomy_object->name;
685 }
686 }
687 }
688
689 return $all_values;
690 }
691 }
692