Code Duplication    Length = 19-19 lines in 2 locations

classes/PodsRESTHandlers.php 2 locations

@@ 279-297 (lines=19) @@
276
	 * @param string     $controller     Optional, controller class for route. If not set "WP_REST_Posts_Controller" is
277
	 *                                   used.
278
	 */
279
	public static function post_type_rest_support( $post_type_name, $rest_base = false, $controller = 'WP_REST_Posts_Controller' ) {
280
281
		global $wp_post_types;
282
283
		// Only add support for post types that exist
284
		if ( isset( $wp_post_types[ $post_type_name ] ) ) {
285
			// Only add support if REST base not already set
286
			if ( empty( $wp_post_types[ $post_type_name ]->rest_base ) ) {
287
				if ( ! $rest_base ) {
288
					$rest_base = $post_type_name;
289
				}
290
291
				$wp_post_types[ $post_type_name ]->show_in_rest          = true;
292
				$wp_post_types[ $post_type_name ]->rest_base             = $rest_base;
293
				$wp_post_types[ $post_type_name ]->rest_controller_class = $controller;
294
			}
295
		}
296
297
	}
298
299
	/**
300
	 * Add REST API support to an already registered taxonomy.
@@ 309-327 (lines=19) @@
306
	 * @param string     $controller    Optional, controller class for route. If not set "WP_REST_Terms_Controller" is
307
	 *                                  used.
308
	 */
309
	public static function taxonomy_rest_support( $taxonomy_name, $rest_base = false, $controller = 'WP_REST_Terms_Controller' ) {
310
311
		global $wp_taxonomies;
312
313
		// Only add support for taxonomies that exist
314
		if ( isset( $wp_taxonomies[ $taxonomy_name ] ) ) {
315
			// Only add support if REST base not already set
316
			if ( empty( $wp_taxonomies[ $taxonomy_name ]->rest_base ) ) {
317
				if ( ! $rest_base ) {
318
					$rest_base = $taxonomy_name;
319
				}
320
321
				$wp_taxonomies[ $taxonomy_name ]->show_in_rest          = true;
322
				$wp_taxonomies[ $taxonomy_name ]->rest_base             = $rest_base;
323
				$wp_taxonomies[ $taxonomy_name ]->rest_controller_class = $controller;
324
			}
325
326
		}
327
	}
328
329
	/**
330
	 * Check if a Pod supports extending core REST response.