@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | public function init() { |
32 | 32 | |
33 | 33 | $labels = array( |
34 | - 'name' => _x( 'Entity Types', 'taxonomy general name', 'wordlift' ), |
|
35 | - 'singular_name' => _x( 'Entity Type', 'taxonomy singular name', 'wordlift' ), |
|
36 | - 'search_items' => __( 'Search Entity Types', 'wordlift' ), |
|
37 | - 'all_items' => __( 'All Entity Types', 'wordlift' ), |
|
38 | - 'parent_item' => __( 'Parent Entity Type', 'wordlift' ), |
|
39 | - 'parent_item_colon' => __( 'Parent Entity Type:', 'wordlift' ), |
|
40 | - 'edit_item' => __( 'Edit Entity Type', 'wordlift' ), |
|
41 | - 'update_item' => __( 'Update Entity Type', 'wordlift' ), |
|
42 | - 'add_new_item' => __( 'Add New Entity Type', 'wordlift' ), |
|
43 | - 'new_item_name' => __( 'New Entity Type', 'wordlift' ), |
|
44 | - 'menu_name' => __( 'Entity Types', 'wordlift' ), |
|
34 | + 'name' => _x('Entity Types', 'taxonomy general name', 'wordlift'), |
|
35 | + 'singular_name' => _x('Entity Type', 'taxonomy singular name', 'wordlift'), |
|
36 | + 'search_items' => __('Search Entity Types', 'wordlift'), |
|
37 | + 'all_items' => __('All Entity Types', 'wordlift'), |
|
38 | + 'parent_item' => __('Parent Entity Type', 'wordlift'), |
|
39 | + 'parent_item_colon' => __('Parent Entity Type:', 'wordlift'), |
|
40 | + 'edit_item' => __('Edit Entity Type', 'wordlift'), |
|
41 | + 'update_item' => __('Update Entity Type', 'wordlift'), |
|
42 | + 'add_new_item' => __('Add New Entity Type', 'wordlift'), |
|
43 | + 'new_item_name' => __('New Entity Type', 'wordlift'), |
|
44 | + 'menu_name' => __('Entity Types', 'wordlift'), |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | // Take away GUI for taxonomy editing. |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | 'capabilities' => $capabilities, |
62 | 62 | 'hierarchical' => true, |
63 | 63 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
64 | - 'show_admin_column' => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ), |
|
64 | + 'show_admin_column' => apply_filters('wl_feature__enable__entity-types-taxonomy', true), |
|
65 | 65 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
66 | - 'show_in_rest' => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ), |
|
66 | + 'show_in_rest' => apply_filters('wl_feature__enable__entity-types-taxonomy', true), |
|
67 | 67 | 'show_in_quick_edit' => false, |
68 | 68 | 'publicly_queryable' => false, |
69 | 69 | ); |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | * @since 3.20.0 |
76 | 76 | */ |
77 | 77 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
78 | - if ( apply_filters( 'wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES ) ) { |
|
78 | + if (apply_filters('wl_feature__enable__all-entity-types', WL_ALL_ENTITY_TYPES)) { |
|
79 | 79 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
80 | - $args['meta_box_cb'] = apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ) ? array( |
|
80 | + $args['meta_box_cb'] = apply_filters('wl_feature__enable__entity-types-taxonomy', true) ? array( |
|
81 | 81 | 'Wordlift_Admin_Schemaorg_Taxonomy_Metabox', |
82 | 82 | 'render', |
83 | 83 | ) : false; |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | // query for synonyms in Block Editor. |
120 | 120 | add_filter( |
121 | 121 | 'register_post_type_args', |
122 | - function ( $args, $post_type ) { |
|
123 | - if ( in_array( $post_type, Wordlift_Entity_Service::valid_entity_post_types(), true ) ) { |
|
124 | - if ( ! isset( $args['supports'] ) ) { |
|
122 | + function($args, $post_type) { |
|
123 | + if (in_array($post_type, Wordlift_Entity_Service::valid_entity_post_types(), true)) { |
|
124 | + if ( ! isset($args['supports'])) { |
|
125 | 125 | $args['supports'] = array(); |
126 | 126 | } |
127 | 127 | $args['supports'][] = 'custom-fields'; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ); |
135 | 135 | |
136 | 136 | // Add filter to change the metabox CSS class. |
137 | - add_filter( 'postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class' ); |
|
137 | + add_filter('postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class'); |
|
138 | 138 | |
139 | 139 | // Add a filter to preset the object term if none is set. |
140 | 140 | // |
@@ -142,14 +142,14 @@ discard block |
||
142 | 142 | // |
143 | 143 | // @see https://github.com/insideout10/wordlift-plugin/issues/995 |
144 | 144 | // @since 3.23.6 |
145 | - add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 ); |
|
145 | + add_filter('get_object_terms', array($this, 'get_object_terms'), 10, 4); |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Exclude sitemap creation for wl_entity_type taxonomy in Yoast |
149 | 149 | * |
150 | 150 | * @since 3.30.1 |
151 | 151 | */ |
152 | - add_filter( 'wpseo_sitemap_exclude_taxonomy', array( $this, 'wpseo_sitemap_exclude_taxonomy' ), 10, 2 ); |
|
152 | + add_filter('wpseo_sitemap_exclude_taxonomy', array($this, 'wpseo_sitemap_exclude_taxonomy'), 10, 2); |
|
153 | 153 | |
154 | 154 | $this->hide_posts_count(); |
155 | 155 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | $name = self::TAXONOMY_NAME; |
159 | 159 | add_filter( |
160 | 160 | "manage_edit-{$name}_columns", |
161 | - function ( $columns ) { |
|
162 | - unset( $columns['posts'] ); |
|
161 | + function($columns) { |
|
162 | + unset($columns['posts']); |
|
163 | 163 | return $columns; |
164 | 164 | } |
165 | 165 | ); |
@@ -180,53 +180,53 @@ discard block |
||
180 | 180 | * @return array|WP_Error |
181 | 181 | * @since 3.23.6 |
182 | 182 | */ |
183 | - public function get_object_terms( $terms, $object_ids, $taxonomies, $args ) { |
|
183 | + public function get_object_terms($terms, $object_ids, $taxonomies, $args) { |
|
184 | 184 | // Get our entity type. |
185 | 185 | $entity_type = self::TAXONOMY_NAME; |
186 | 186 | |
187 | 187 | // Check if this is a query for our entity type, that no terms have been found and that we have an article |
188 | 188 | // term to preset in case. |
189 | - if ( ! taxonomy_exists( $entity_type ) |
|
190 | - || array( $entity_type ) !== (array) $taxonomies |
|
191 | - || ! empty( $terms ) |
|
192 | - || ! term_exists( 'article', $entity_type ) |
|
193 | - || ! term_exists( 'thing', $entity_type ) ) { |
|
189 | + if ( ! taxonomy_exists($entity_type) |
|
190 | + || array($entity_type) !== (array) $taxonomies |
|
191 | + || ! empty($terms) |
|
192 | + || ! term_exists('article', $entity_type) |
|
193 | + || ! term_exists('thing', $entity_type)) { |
|
194 | 194 | |
195 | 195 | // Return the input value. |
196 | 196 | return $terms; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Avoid nested calls in case of issues. |
200 | - remove_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10 ); |
|
200 | + remove_filter('get_object_terms', array($this, 'get_object_terms'), 10); |
|
201 | 201 | |
202 | 202 | // Set the default term for all the queried object. |
203 | - foreach ( (array) $object_ids as $object_id ) { |
|
204 | - $post_type = get_post_type( $object_id ); |
|
205 | - if ( Wordlift_Entity_Type_Service::is_valid_entity_post_type( $post_type ) ) { |
|
203 | + foreach ((array) $object_ids as $object_id) { |
|
204 | + $post_type = get_post_type($object_id); |
|
205 | + if (Wordlift_Entity_Type_Service::is_valid_entity_post_type($post_type)) { |
|
206 | 206 | // Set the term to article for posts and pages, or to thing for everything else. |
207 | - $uris = Wordlift_Entity_Type_Adapter::get_entity_types( $post_type ); |
|
208 | - foreach ( $uris as $uri ) { |
|
207 | + $uris = Wordlift_Entity_Type_Adapter::get_entity_types($post_type); |
|
208 | + foreach ($uris as $uri) { |
|
209 | 209 | // set the uri based on post type. |
210 | - if ( 'http://schema.org/Article' === $uri || 'http://schema.org/Thing' === $uri ) { |
|
210 | + if ('http://schema.org/Article' === $uri || 'http://schema.org/Thing' === $uri) { |
|
211 | 211 | $uri = Wordlift_Entity_Service::TYPE_NAME === $post_type ? |
212 | 212 | 'http://schema.org/Thing' : 'http://schema.org/Article'; |
213 | 213 | } |
214 | - Wordlift_Entity_Type_Service::get_instance()->set( $object_id, $uri ); |
|
214 | + Wordlift_Entity_Type_Service::get_instance()->set($object_id, $uri); |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Finally return the object terms. |
220 | - $terms = wp_get_object_terms( $object_ids, $taxonomies, $args ); |
|
220 | + $terms = wp_get_object_terms($object_ids, $taxonomies, $args); |
|
221 | 221 | |
222 | 222 | // Re-enable nested calls in case of issues. |
223 | - add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 ); |
|
223 | + add_filter('get_object_terms', array($this, 'get_object_terms'), 10, 4); |
|
224 | 224 | |
225 | 225 | return $terms; |
226 | 226 | } |
227 | 227 | |
228 | - public function wpseo_sitemap_exclude_taxonomy( $exclude, $tax ) { |
|
229 | - if ( self::TAXONOMY_NAME === $tax ) { |
|
228 | + public function wpseo_sitemap_exclude_taxonomy($exclude, $tax) { |
|
229 | + if (self::TAXONOMY_NAME === $tax) { |
|
230 | 230 | return true; |
231 | 231 | } |
232 | 232 |