Completed
Push — develop ( c44905...714dab )
by
unknown
04:15 queued 10s
created
src/includes/class-wordlift-entity-type-taxonomy-service.php 2 patches
Indentation   +187 added lines, -187 removed lines patch added patch discarded remove patch
@@ -14,197 +14,197 @@
 block discarded – undo
14 14
  */
15 15
 class Wordlift_Entity_Type_Taxonomy_Service {
16 16
 
17
-	/**
18
-	 * The WordPress taxonomy name.
19
-	 *
20
-	 * @since 1.0.0
21
-	 */
22
-	const TAXONOMY_NAME = 'wl_entity_type';
23
-
24
-	/**
25
-	 * Register the taxonomies.
26
-	 *
27
-	 * @since 3.23.6 we hook to `wp_get_object_terms` to ensure that a term is returned when a post is queries for the
28
-	 *               `wl_entity_type` taxonomy.
29
-	 * @since 3.18.0
30
-	 */
31
-	public function init() {
32
-
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' ),
45
-		);
46
-
47
-		// Take away GUI for taxonomy editing.
48
-		// TODO: read capabilities when editing of the WL <-> schema.org mapping is possible.
49
-		$capabilities = array(
50
-			// We enable editors to change the title/description of terms:
51
-			//
52
-			// @see https://github.com/insideout10/wordlift-plugin/issues/398.
53
-			'manage_terms' => 'manage_options',
54
-			'edit_terms'   => 'wl_entity_type_edit_term',
55
-			'delete_terms' => 'wl_entity_type_delete_term',
56
-			'assign_terms' => 'edit_posts',
57
-		);
58
-
59
-		$args = array(
60
-			'labels'             => $labels,
61
-			'capabilities'       => $capabilities,
62
-			'hierarchical'       => true,
63
-			'show_admin_column'  => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
64
-			'show_in_rest'       => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
65
-			'show_in_quick_edit' => false,
66
-			'publicly_queryable' => false
67
-		);
68
-
69
-		/*
17
+    /**
18
+     * The WordPress taxonomy name.
19
+     *
20
+     * @since 1.0.0
21
+     */
22
+    const TAXONOMY_NAME = 'wl_entity_type';
23
+
24
+    /**
25
+     * Register the taxonomies.
26
+     *
27
+     * @since 3.23.6 we hook to `wp_get_object_terms` to ensure that a term is returned when a post is queries for the
28
+     *               `wl_entity_type` taxonomy.
29
+     * @since 3.18.0
30
+     */
31
+    public function init() {
32
+
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' ),
45
+        );
46
+
47
+        // Take away GUI for taxonomy editing.
48
+        // TODO: read capabilities when editing of the WL <-> schema.org mapping is possible.
49
+        $capabilities = array(
50
+            // We enable editors to change the title/description of terms:
51
+            //
52
+            // @see https://github.com/insideout10/wordlift-plugin/issues/398.
53
+            'manage_terms' => 'manage_options',
54
+            'edit_terms'   => 'wl_entity_type_edit_term',
55
+            'delete_terms' => 'wl_entity_type_delete_term',
56
+            'assign_terms' => 'edit_posts',
57
+        );
58
+
59
+        $args = array(
60
+            'labels'             => $labels,
61
+            'capabilities'       => $capabilities,
62
+            'hierarchical'       => true,
63
+            'show_admin_column'  => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
64
+            'show_in_rest'       => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
65
+            'show_in_quick_edit' => false,
66
+            'publicly_queryable' => false
67
+        );
68
+
69
+        /*
70 70
 		 * If `All Entity Types` is enabled, use the new metabox.
71 71
 		 *
72 72
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
73 73
 		 * @since 3.20.0
74 74
 		 */
75
-		if ( WL_ALL_ENTITY_TYPES ) {
76
-			$args['meta_box_cb'] = apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ) ? array(
77
-				'Wordlift_Admin_Schemaorg_Taxonomy_Metabox',
78
-				'render'
79
-			) : false;
80
-		}
81
-
82
-		register_taxonomy(
83
-			self::TAXONOMY_NAME, // Taxonomy name.
84
-			Wordlift_Entity_Service::valid_entity_post_types(), // Taxonomy post types.
85
-			$args // Taxonomy args.
86
-		);
87
-
88
-		/**
89
-		 * Register meta wl_entities_gutenberg for use in Gutenberg
90
-		 */
91
-		register_meta( 'post', 'wl_entities_gutenberg', array(
92
-			'show_in_rest' => true,
93
-			'single'       => true,
94
-			'type'         => 'string',
95
-		) );
96
-
97
-		/**
98
-		 * Register meta _wl_alt_label for use in Gutenberg
99
-		 */
100
-		register_meta( 'post', Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, array(
101
-			'object_subtype' => '',
102
-			'show_in_rest'   => true,
103
-			'single'         => false,
104
-			'type'           => 'string',
105
-			'auth_callback'  => function () {
106
-				return current_user_can( 'edit_posts' );
107
-			}
108
-		) );
109
-
110
-		// see #1364: add custom fields support for CPTs that are valid entity post types in order to be able to
111
-		// query for synonyms in Block Editor.
112
-		add_filter( 'register_post_type_args', function ( $args, $post_type ) {
113
-			if ( in_array( $post_type, Wordlift_Entity_Service::valid_entity_post_types() ) ) {
114
-				if ( ! isset( $args['supports'] ) ) {
115
-					$args['supports'] = array();
116
-				}
117
-				$args['supports'][] = 'custom-fields';
118
-			}
119
-
120
-			return $args;
121
-		}, 10, 2 );
122
-
123
-		// Add filter to change the metabox CSS class.
124
-		add_filter( 'postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class' );
125
-
126
-		// Add a filter to preset the object term if none is set.
127
-		//
128
-		// DO NOT hook to `wp_get_object_terms`, because `wp_get_object_terms` returns imploded values for SQL queries.
129
-		//
130
-		// @see https://github.com/insideout10/wordlift-plugin/issues/995
131
-		// @since 3.23.6
132
-		add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
133
-
134
-		/**
135
-		 * Exclude sitemap creation for wl_entity_type taxonomy in Yoast
136
-		 * @since 3.30.1
137
-		 */
138
-		add_filter( 'wpseo_sitemap_exclude_taxonomy', array( $this, 'wpseo_sitemap_exclude_taxonomy' ), 10, 2 );
139
-
140
-	}
141
-
142
-	/**
143
-	 * Hook to the `get_object_terms` filter.
144
-	 *
145
-	 * We check if our taxonomy is requested and whether a term has been returned. If no term has been returned we
146
-	 * preset `Article` for posts/pages and 'Thing' for everything else and we query the terms again.
147
-	 *
148
-	 * @param array $terms Array of terms for the given object or objects.
149
-	 * @param int[] $object_ids Array of object IDs for which terms were retrieved.
150
-	 * @param string[] $taxonomies Array of taxonomy names from which terms were retrieved.
151
-	 * @param array $args Array of arguments for retrieving terms for the given
152
-	 *                             object(s). See get_object_terms() for details.
153
-	 *
154
-	 * @return array|WP_Error
155
-	 * @since 3.23.6
156
-	 */
157
-	public function get_object_terms( $terms, $object_ids, $taxonomies, $args ) {
158
-		// Get our entity type.
159
-		$entity_type = self::TAXONOMY_NAME;
160
-
161
-		// Check if this is a query for our entity type, that no terms have been found and that we have an article
162
-		// term to preset in case.
163
-		if ( ! taxonomy_exists( $entity_type )
164
-		     || array( $entity_type ) !== (array) $taxonomies
165
-		     || ! empty( $terms )
166
-		     || ! term_exists( 'article', $entity_type )
167
-		     || ! term_exists( 'thing', $entity_type ) ) {
168
-
169
-			// Return the input value.
170
-			return $terms;
171
-		}
172
-
173
-		// Avoid nested calls in case of issues.
174
-		remove_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10 );
175
-
176
-		// Set the default term for all the queried object.
177
-		foreach ( (array) $object_ids as $object_id ) {
178
-			$post_type = get_post_type( $object_id );
179
-			if ( Wordlift_Entity_Type_Service::is_valid_entity_post_type( $post_type ) ) {
180
-				// Set the term to article for posts and pages, or to thing for everything else.
181
-				$uris = Wordlift_Entity_Type_Adapter::get_entity_types( $post_type );
182
-				foreach ( $uris as $uri ) {
183
-					// set the uri based on post type.
184
-					if ( $uri === 'http://schema.org/Article' || $uri === 'http://schema.org/Thing' ) {
185
-						$uri = Wordlift_Entity_Service::TYPE_NAME === $post_type ?
186
-							'http://schema.org/Thing' : 'http://schema.org/Article';
187
-					}
188
-					Wordlift_Entity_Type_Service::get_instance()->set( $object_id, $uri );
189
-				}
190
-			}
191
-		}
192
-
193
-		// Finally return the object terms.
194
-		$terms = wp_get_object_terms( $object_ids, $taxonomies, $args );
195
-
196
-		// Re-enable nested calls in case of issues.
197
-		add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
198
-
199
-		return $terms;
200
-	}
201
-
202
-	public function wpseo_sitemap_exclude_taxonomy( $exclude, $tax ) {
203
-		if ( $tax === self::TAXONOMY_NAME ) {
204
-			return true;
205
-		}
206
-
207
-		return $exclude;
208
-	}
75
+        if ( WL_ALL_ENTITY_TYPES ) {
76
+            $args['meta_box_cb'] = apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ) ? array(
77
+                'Wordlift_Admin_Schemaorg_Taxonomy_Metabox',
78
+                'render'
79
+            ) : false;
80
+        }
81
+
82
+        register_taxonomy(
83
+            self::TAXONOMY_NAME, // Taxonomy name.
84
+            Wordlift_Entity_Service::valid_entity_post_types(), // Taxonomy post types.
85
+            $args // Taxonomy args.
86
+        );
87
+
88
+        /**
89
+         * Register meta wl_entities_gutenberg for use in Gutenberg
90
+         */
91
+        register_meta( 'post', 'wl_entities_gutenberg', array(
92
+            'show_in_rest' => true,
93
+            'single'       => true,
94
+            'type'         => 'string',
95
+        ) );
96
+
97
+        /**
98
+         * Register meta _wl_alt_label for use in Gutenberg
99
+         */
100
+        register_meta( 'post', Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, array(
101
+            'object_subtype' => '',
102
+            'show_in_rest'   => true,
103
+            'single'         => false,
104
+            'type'           => 'string',
105
+            'auth_callback'  => function () {
106
+                return current_user_can( 'edit_posts' );
107
+            }
108
+        ) );
109
+
110
+        // see #1364: add custom fields support for CPTs that are valid entity post types in order to be able to
111
+        // query for synonyms in Block Editor.
112
+        add_filter( 'register_post_type_args', function ( $args, $post_type ) {
113
+            if ( in_array( $post_type, Wordlift_Entity_Service::valid_entity_post_types() ) ) {
114
+                if ( ! isset( $args['supports'] ) ) {
115
+                    $args['supports'] = array();
116
+                }
117
+                $args['supports'][] = 'custom-fields';
118
+            }
119
+
120
+            return $args;
121
+        }, 10, 2 );
122
+
123
+        // Add filter to change the metabox CSS class.
124
+        add_filter( 'postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class' );
125
+
126
+        // Add a filter to preset the object term if none is set.
127
+        //
128
+        // DO NOT hook to `wp_get_object_terms`, because `wp_get_object_terms` returns imploded values for SQL queries.
129
+        //
130
+        // @see https://github.com/insideout10/wordlift-plugin/issues/995
131
+        // @since 3.23.6
132
+        add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
133
+
134
+        /**
135
+         * Exclude sitemap creation for wl_entity_type taxonomy in Yoast
136
+         * @since 3.30.1
137
+         */
138
+        add_filter( 'wpseo_sitemap_exclude_taxonomy', array( $this, 'wpseo_sitemap_exclude_taxonomy' ), 10, 2 );
139
+
140
+    }
141
+
142
+    /**
143
+     * Hook to the `get_object_terms` filter.
144
+     *
145
+     * We check if our taxonomy is requested and whether a term has been returned. If no term has been returned we
146
+     * preset `Article` for posts/pages and 'Thing' for everything else and we query the terms again.
147
+     *
148
+     * @param array $terms Array of terms for the given object or objects.
149
+     * @param int[] $object_ids Array of object IDs for which terms were retrieved.
150
+     * @param string[] $taxonomies Array of taxonomy names from which terms were retrieved.
151
+     * @param array $args Array of arguments for retrieving terms for the given
152
+     *                             object(s). See get_object_terms() for details.
153
+     *
154
+     * @return array|WP_Error
155
+     * @since 3.23.6
156
+     */
157
+    public function get_object_terms( $terms, $object_ids, $taxonomies, $args ) {
158
+        // Get our entity type.
159
+        $entity_type = self::TAXONOMY_NAME;
160
+
161
+        // Check if this is a query for our entity type, that no terms have been found and that we have an article
162
+        // term to preset in case.
163
+        if ( ! taxonomy_exists( $entity_type )
164
+             || array( $entity_type ) !== (array) $taxonomies
165
+             || ! empty( $terms )
166
+             || ! term_exists( 'article', $entity_type )
167
+             || ! term_exists( 'thing', $entity_type ) ) {
168
+
169
+            // Return the input value.
170
+            return $terms;
171
+        }
172
+
173
+        // Avoid nested calls in case of issues.
174
+        remove_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10 );
175
+
176
+        // Set the default term for all the queried object.
177
+        foreach ( (array) $object_ids as $object_id ) {
178
+            $post_type = get_post_type( $object_id );
179
+            if ( Wordlift_Entity_Type_Service::is_valid_entity_post_type( $post_type ) ) {
180
+                // Set the term to article for posts and pages, or to thing for everything else.
181
+                $uris = Wordlift_Entity_Type_Adapter::get_entity_types( $post_type );
182
+                foreach ( $uris as $uri ) {
183
+                    // set the uri based on post type.
184
+                    if ( $uri === 'http://schema.org/Article' || $uri === 'http://schema.org/Thing' ) {
185
+                        $uri = Wordlift_Entity_Service::TYPE_NAME === $post_type ?
186
+                            'http://schema.org/Thing' : 'http://schema.org/Article';
187
+                    }
188
+                    Wordlift_Entity_Type_Service::get_instance()->set( $object_id, $uri );
189
+                }
190
+            }
191
+        }
192
+
193
+        // Finally return the object terms.
194
+        $terms = wp_get_object_terms( $object_ids, $taxonomies, $args );
195
+
196
+        // Re-enable nested calls in case of issues.
197
+        add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
198
+
199
+        return $terms;
200
+    }
201
+
202
+    public function wpseo_sitemap_exclude_taxonomy( $exclude, $tax ) {
203
+        if ( $tax === self::TAXONOMY_NAME ) {
204
+            return true;
205
+        }
206
+
207
+        return $exclude;
208
+    }
209 209
 
210 210
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -31,17 +31,17 @@  discard block
 block discarded – undo
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.
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 			'labels'             => $labels,
61 61
 			'capabilities'       => $capabilities,
62 62
 			'hierarchical'       => true,
63
-			'show_admin_column'  => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
64
-			'show_in_rest'       => apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ),
63
+			'show_admin_column'  => apply_filters('wl_feature__enable__entity-types-taxonomy', true),
64
+			'show_in_rest'       => apply_filters('wl_feature__enable__entity-types-taxonomy', true),
65 65
 			'show_in_quick_edit' => false,
66 66
 			'publicly_queryable' => false
67 67
 		);
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/835
73 73
 		 * @since 3.20.0
74 74
 		 */
75
-		if ( WL_ALL_ENTITY_TYPES ) {
76
-			$args['meta_box_cb'] = apply_filters( 'wl_feature__enable__entity-types-taxonomy', true ) ? array(
75
+		if (WL_ALL_ENTITY_TYPES) {
76
+			$args['meta_box_cb'] = apply_filters('wl_feature__enable__entity-types-taxonomy', true) ? array(
77 77
 				'Wordlift_Admin_Schemaorg_Taxonomy_Metabox',
78 78
 				'render'
79 79
 			) : false;
@@ -88,40 +88,40 @@  discard block
 block discarded – undo
88 88
 		/**
89 89
 		 * Register meta wl_entities_gutenberg for use in Gutenberg
90 90
 		 */
91
-		register_meta( 'post', 'wl_entities_gutenberg', array(
91
+		register_meta('post', 'wl_entities_gutenberg', array(
92 92
 			'show_in_rest' => true,
93 93
 			'single'       => true,
94 94
 			'type'         => 'string',
95
-		) );
95
+		));
96 96
 
97 97
 		/**
98 98
 		 * Register meta _wl_alt_label for use in Gutenberg
99 99
 		 */
100
-		register_meta( 'post', Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, array(
100
+		register_meta('post', Wordlift_Entity_Service::ALTERNATIVE_LABEL_META_KEY, array(
101 101
 			'object_subtype' => '',
102 102
 			'show_in_rest'   => true,
103 103
 			'single'         => false,
104 104
 			'type'           => 'string',
105
-			'auth_callback'  => function () {
106
-				return current_user_can( 'edit_posts' );
105
+			'auth_callback'  => function() {
106
+				return current_user_can('edit_posts');
107 107
 			}
108
-		) );
108
+		));
109 109
 
110 110
 		// see #1364: add custom fields support for CPTs that are valid entity post types in order to be able to
111 111
 		// query for synonyms in Block Editor.
112
-		add_filter( 'register_post_type_args', function ( $args, $post_type ) {
113
-			if ( in_array( $post_type, Wordlift_Entity_Service::valid_entity_post_types() ) ) {
114
-				if ( ! isset( $args['supports'] ) ) {
112
+		add_filter('register_post_type_args', function($args, $post_type) {
113
+			if (in_array($post_type, Wordlift_Entity_Service::valid_entity_post_types())) {
114
+				if ( ! isset($args['supports'])) {
115 115
 					$args['supports'] = array();
116 116
 				}
117 117
 				$args['supports'][] = 'custom-fields';
118 118
 			}
119 119
 
120 120
 			return $args;
121
-		}, 10, 2 );
121
+		}, 10, 2);
122 122
 
123 123
 		// Add filter to change the metabox CSS class.
124
-		add_filter( 'postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class' );
124
+		add_filter('postbox_classes_entity_wl_entity_typediv', 'wl_admin_metaboxes_add_css_class');
125 125
 
126 126
 		// Add a filter to preset the object term if none is set.
127 127
 		//
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 		//
130 130
 		// @see https://github.com/insideout10/wordlift-plugin/issues/995
131 131
 		// @since 3.23.6
132
-		add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
132
+		add_filter('get_object_terms', array($this, 'get_object_terms'), 10, 4);
133 133
 
134 134
 		/**
135 135
 		 * Exclude sitemap creation for wl_entity_type taxonomy in Yoast
136 136
 		 * @since 3.30.1
137 137
 		 */
138
-		add_filter( 'wpseo_sitemap_exclude_taxonomy', array( $this, 'wpseo_sitemap_exclude_taxonomy' ), 10, 2 );
138
+		add_filter('wpseo_sitemap_exclude_taxonomy', array($this, 'wpseo_sitemap_exclude_taxonomy'), 10, 2);
139 139
 
140 140
 	}
141 141
 
@@ -154,53 +154,53 @@  discard block
 block discarded – undo
154 154
 	 * @return array|WP_Error
155 155
 	 * @since 3.23.6
156 156
 	 */
157
-	public function get_object_terms( $terms, $object_ids, $taxonomies, $args ) {
157
+	public function get_object_terms($terms, $object_ids, $taxonomies, $args) {
158 158
 		// Get our entity type.
159 159
 		$entity_type = self::TAXONOMY_NAME;
160 160
 
161 161
 		// Check if this is a query for our entity type, that no terms have been found and that we have an article
162 162
 		// term to preset in case.
163
-		if ( ! taxonomy_exists( $entity_type )
164
-		     || array( $entity_type ) !== (array) $taxonomies
165
-		     || ! empty( $terms )
166
-		     || ! term_exists( 'article', $entity_type )
167
-		     || ! term_exists( 'thing', $entity_type ) ) {
163
+		if ( ! taxonomy_exists($entity_type)
164
+		     || array($entity_type) !== (array) $taxonomies
165
+		     || ! empty($terms)
166
+		     || ! term_exists('article', $entity_type)
167
+		     || ! term_exists('thing', $entity_type)) {
168 168
 
169 169
 			// Return the input value.
170 170
 			return $terms;
171 171
 		}
172 172
 
173 173
 		// Avoid nested calls in case of issues.
174
-		remove_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10 );
174
+		remove_filter('get_object_terms', array($this, 'get_object_terms'), 10);
175 175
 
176 176
 		// Set the default term for all the queried object.
177
-		foreach ( (array) $object_ids as $object_id ) {
178
-			$post_type = get_post_type( $object_id );
179
-			if ( Wordlift_Entity_Type_Service::is_valid_entity_post_type( $post_type ) ) {
177
+		foreach ((array) $object_ids as $object_id) {
178
+			$post_type = get_post_type($object_id);
179
+			if (Wordlift_Entity_Type_Service::is_valid_entity_post_type($post_type)) {
180 180
 				// Set the term to article for posts and pages, or to thing for everything else.
181
-				$uris = Wordlift_Entity_Type_Adapter::get_entity_types( $post_type );
182
-				foreach ( $uris as $uri ) {
181
+				$uris = Wordlift_Entity_Type_Adapter::get_entity_types($post_type);
182
+				foreach ($uris as $uri) {
183 183
 					// set the uri based on post type.
184
-					if ( $uri === 'http://schema.org/Article' || $uri === 'http://schema.org/Thing' ) {
184
+					if ($uri === 'http://schema.org/Article' || $uri === 'http://schema.org/Thing') {
185 185
 						$uri = Wordlift_Entity_Service::TYPE_NAME === $post_type ?
186 186
 							'http://schema.org/Thing' : 'http://schema.org/Article';
187 187
 					}
188
-					Wordlift_Entity_Type_Service::get_instance()->set( $object_id, $uri );
188
+					Wordlift_Entity_Type_Service::get_instance()->set($object_id, $uri);
189 189
 				}
190 190
 			}
191 191
 		}
192 192
 
193 193
 		// Finally return the object terms.
194
-		$terms = wp_get_object_terms( $object_ids, $taxonomies, $args );
194
+		$terms = wp_get_object_terms($object_ids, $taxonomies, $args);
195 195
 
196 196
 		// Re-enable nested calls in case of issues.
197
-		add_filter( 'get_object_terms', array( $this, 'get_object_terms' ), 10, 4 );
197
+		add_filter('get_object_terms', array($this, 'get_object_terms'), 10, 4);
198 198
 
199 199
 		return $terms;
200 200
 	}
201 201
 
202
-	public function wpseo_sitemap_exclude_taxonomy( $exclude, $tax ) {
203
-		if ( $tax === self::TAXONOMY_NAME ) {
202
+	public function wpseo_sitemap_exclude_taxonomy($exclude, $tax) {
203
+		if ($tax === self::TAXONOMY_NAME) {
204 204
 			return true;
205 205
 		}
206 206
 
Please login to merge, or discard this patch.