• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / f050301100f5df0caf88b5f6cf2ec493f81e9bd4

19 Nov 2024 09:08AM UTC coverage: 54.641% (+0.004%) from 54.637%
f050301100f5df0caf88b5f6cf2ec493f81e9bd4

push

github

YoastBot
Bump version to 23.9 on free

7575 of 13561 branches covered (55.86%)

Branch coverage included in aggregate %.

29709 of 54673 relevant lines covered (54.34%)

41694.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/inc/class-post-type.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Inc
6
 */
7

8
/**
9
 * Represents the post type utils.
10
 */
11
class WPSEO_Post_Type {
12

13
        /**
14
         * Returns an array with the accessible post types.
15
         *
16
         * An accessible post type is a post type that is public and isn't set as no-index (robots).
17
         *
18
         * @return array Array with all the accessible post_types.
19
         */
20
        public static function get_accessible_post_types() {
36✔
21
                return YoastSEO()->helpers->post_type->get_accessible_post_types();
36✔
22
        }
23

24
        /**
25
         * Returns whether the passed post type is considered accessible.
26
         *
27
         * @param string $post_type The post type to check.
28
         *
29
         * @return bool Whether or not the post type is considered accessible.
30
         */
31
        public static function is_post_type_accessible( $post_type ) {
4✔
32
                return in_array( $post_type, self::get_accessible_post_types(), true );
4✔
33
        }
34

35
        /**
36
         * Checks if the request post type is public and indexable.
37
         *
38
         * @param string $post_type_name The name of the post type to lookup.
39
         *
40
         * @return bool True when post type is set to index.
41
         */
42
        public static function is_post_type_indexable( $post_type_name ) {
12✔
43
                return YoastSEO()->helpers->post_type->is_indexable( $post_type_name );
12✔
44
        }
45

46
        /**
47
         * Filters the attachment post type from an array with post_types.
48
         *
49
         * @param array $post_types The array to filter the attachment post type from.
50
         *
51
         * @return array The filtered array.
52
         */
53
        public static function filter_attachment_post_type( array $post_types ) {
4✔
54
                if ( WPSEO_Options::get( 'disable-attachment' ) === true ) {
4✔
55
                        unset( $post_types['attachment'] );
4✔
56
                }
57

58
                return $post_types;
4✔
59
        }
60

61
        /**
62
         * Checks if the post type is enabled in the REST API.
63
         *
64
         * @param string $post_type The post type to check.
65
         *
66
         * @return bool Whether or not the post type is available in the REST API.
67
         */
68
        public static function is_rest_enabled( $post_type ) {
4✔
69
                $post_type_object = get_post_type_object( $post_type );
4✔
70

71
                if ( $post_type_object === null ) {
4✔
72
                        return false;
4✔
73
                }
74

75
                return $post_type_object->show_in_rest === true;
4✔
76
        }
77

78
        /**
79
         * Checks if the current post type has an archive.
80
         *
81
         * Context: The has_archive value can be a string or a boolean. In most case it will be a boolean,
82
         * but it can be defined as a string. When it is a string the archive_slug will be overwritten to
83
         * define another endpoint.
84
         *
85
         * @param WP_Post_Type $post_type The post type object.
86
         *
87
         * @return bool True whether the post type has an archive.
88
         */
89
        public static function has_archive( $post_type ) {
10✔
90
                return YoastSEO()->helpers->post_type->has_archive( $post_type );
10✔
91
        }
92

93
        /**
94
         * Checks if the Yoast Metabox has been enabled for the post type.
95
         *
96
         * @param string $post_type The post type name.
97
         *
98
         * @return bool True whether the metabox is enabled.
99
         */
100
        public static function has_metabox_enabled( $post_type ) {
×
101
                return WPSEO_Options::get( 'display-metabox-pt-' . $post_type, false );
×
102
        }
103

104
        /* ********************* DEPRECATED METHODS ********************* */
105

106
        /**
107
         * Removes the notification related to the post types which have been made public.
108
         *
109
         * @deprecated 20.10
110
         * @codeCoverageIgnore
111
         *
112
         * @return void
113
         */
114
        public static function remove_post_types_made_public_notification() {
115
                _deprecated_function( __METHOD__, 'Yoast SEO 20.10', 'Content_Type_Visibility_Dismiss_Notifications::dismiss_notifications' );
116
                $notification_center = Yoast_Notification_Center::get();
117
                $notification_center->remove_notification_by_id( 'post-types-made-public' );
118
        }
119

120
        /**
121
         * Removes the notification related to the taxonomies which have been made public.
122
         *
123
         * @deprecated 20.10
124
         * @codeCoverageIgnore
125
         *
126
         * @return void
127
         */
128
        public static function remove_taxonomies_made_public_notification() {
129
                _deprecated_function( __METHOD__, 'Yoast SEO 20.10', 'Content_Type_Visibility_Dismiss_Notifications::dismiss_notifications' );
130
                $notification_center = Yoast_Notification_Center::get();
131
                $notification_center->remove_notification_by_id( 'taxonomies-made-public' );
132
        }
133
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc