PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.1
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / inc / class-wpseo-custom-taxonomies.php

class-wpseo-custom-taxonomies.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.1, at inc/class-wpseo-custom-taxonomies.php

73 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO
6 */
7
8 /**
9 * WPSEO_Custom_Taxonomies.
10 */
11 class WPSEO_Custom_Taxonomies {
12
13 /**
14 * Custom taxonomies cache.
15 *
16 * @var array|null
17 */
18 protected static $custom_taxonomies = null;
19
20 /**
21 * Gets the names of the custom taxonomies, prepends 'ct_' and 'ct_desc', and returns them in an array.
22 *
23 * @return array The custom taxonomy prefixed names.
24 */
25 public static function get_custom_taxonomies() {
26 // Use cached value if available.
27 if ( self::$custom_taxonomies !== null ) {
28 return self::$custom_taxonomies;
29 }
30
31 self::$custom_taxonomies = [];
32 $args = [
33 'public' => true,
34 '_builtin' => false,
35 ];
36 $custom_taxonomies = get_taxonomies( $args, 'names', 'and' );
37
38 if ( is_array( $custom_taxonomies ) ) {
39 foreach ( $custom_taxonomies as $custom_taxonomy ) {
40 array_push(
41 self::$custom_taxonomies,
42 self::add_custom_taxonomies_prefix( $custom_taxonomy ),
43 self::add_custom_taxonomies_description_prefix( $custom_taxonomy ),
44 );
45 }
46 }
47
48 return self::$custom_taxonomies;
49 }
50
51 /**
52 * Adds the ct_ prefix to a taxonomy.
53 *
54 * @param string $taxonomy The taxonomy to prefix.
55 *
56 * @return string The prefixed taxonomy.
57 */
58 private static function add_custom_taxonomies_prefix( $taxonomy ) {
59 return 'ct_' . $taxonomy;
60 }
61
62 /**
63 * Adds the ct_desc_ prefix to a taxonomy.
64 *
65 * @param string $taxonomy The taxonomy to prefix.
66 *
67 * @return string The prefixed taxonomy.
68 */
69 private static function add_custom_taxonomies_description_prefix( $taxonomy ) {
70 return 'ct_desc_' . $taxonomy;
71 }
72 }
73