Code Duplication    Length = 27-28 lines in 2 locations

src/wordlift/vocabulary/api/class-tag-rest-endpoint.php 1 location

@@ 37-64 (lines=28) @@
34
	public function register_routes() {
35
		$that = $this;
36
		add_action( 'rest_api_init',
37
			function () use ( $that ) {
38
				register_rest_route(
39
					Api_Config::REST_NAMESPACE,
40
					'/tags',
41
					array(
42
						'methods'             => WP_REST_Server::CREATABLE,
43
						'callback'            => array( $that, 'get_tags' ),
44
						//@todo : review the permission level
45
						'permission_callback' => function () {
46
							return current_user_can( 'manage_options' );
47
						},
48
						'args'                => array(
49
							'limit'  => array(
50
								'validate_callback' => function ( $param, $request, $key ) {
51
									return is_numeric( $param ) && $param;
52
								},
53
								'required'          => true,
54
							),
55
							'offset' => array(
56
								'validate_callback' => function ( $param, $request, $key ) {
57
									return is_numeric( $param );
58
								},
59
								'required'          => true,
60
							),
61
						),
62
					)
63
				);
64
			} );
65
66
67
	}

src/wordlift/videoobject/api/class-rest-controller.php 1 location

@@ 89-115 (lines=27) @@
86
		);
87
	}
88
89
	private function register_save_all_videos_route() {
90
		register_rest_route(
91
			WL_REST_ROUTE_DEFAULT_NAMESPACE,
92
			'/videos/save',
93
			array(
94
				'methods'             => WP_REST_Server::CREATABLE,
95
				'callback'            => array( $this, 'save_all_videos' ),
96
				'permission_callback' => function () {
97
					return current_user_can( 'manage_options' );
98
				},
99
				'args'                => array(
100
					'post_id' => array(
101
						'validate_callback' => function ( $param, $request, $key ) {
102
							return is_numeric( $param ) && $param;
103
						},
104
						'required'          => true,
105
					),
106
					'videos'  => array(
107
						'validate_callback' => function ( $param, $request, $key ) {
108
							return is_array( $param ) && $param;
109
						},
110
						'required'          => true,
111
					),
112
				),
113
			)
114
		);
115
	}
116
117
118
	public function register_get_sync_state_endpoint() {