Code Duplication    Length = 10-13 lines in 3 locations

_inc/lib/core-api/wpcom-endpoints/business-hours.php 1 location

@@ 16-25 (lines=10) @@
13
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
14
	}
15
16
	public function register_routes() {
17
		// GET /sites/<blog_id>/business-hours/localized-week - Return the localized
18
		register_rest_route( $this->namespace, '/' . $this->rest_base . '/localized-week', array(
19
			array(
20
				'methods'             => WP_REST_Server::READABLE,
21
				'callback'            => array( $this, 'get_localized_week' ),
22
				'permission_callback' => '__return_true',
23
			)
24
		) );
25
	}
26
27
	/**
28
	 * Retreives localized business hours

_inc/lib/core-api/wpcom-endpoints/subscribers.php 1 location

@@ 19-28 (lines=10) @@
16
		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
17
	}
18
19
	public function register_routes() {
20
		// GET /sites/<blog_id>/subscribers/count - Return number of subscribers for this site.
21
		register_rest_route( $this->namespace, '/' . $this->rest_base  . '/count', array(
22
			array(
23
				'methods'             => WP_REST_Server::READABLE,
24
				'callback'            => array( $this, 'get_subscriber_count' ),
25
				'permission_callback' => array( $this, 'readable_permission_check' ),
26
			)
27
		) );
28
	}
29
30
	public function readable_permission_check() {
31
		if ( ! current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) ) {

_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-search.php 1 location

@@ 30-42 (lines=13) @@
27
	/**
28
	 * Called automatically on `rest_api_init()`.
29
	 */
30
	public function register_routes() {
31
		register_rest_route(
32
			$this->namespace,
33
			$this->rest_base,
34
			array(
35
				array(
36
					'methods'             => WP_REST_Server::READABLE,
37
					'callback'            => array( $this, 'get_search_results' ),
38
					'permission_callback' => 'is_user_logged_in',
39
				),
40
			)
41
		);
42
	}
43
44
	/**
45
	 * Returns search results for the current blog.