Code Duplication    Length = 18-18 lines in 2 locations

includes/wp-api-menus-v1.php 1 location

@@ 190-207 (lines=18) @@
187
			$json_url_base    = get_json_url();
188
			$json_menus       = array();
189
190
			if ( $locations && $registered_menus ) :
191
192
				foreach ( $registered_menus as $slug => $label ) :
193
194
					// Sanity check
195
					if ( ! isset( $locations[ $slug ] ) ) {
196
						continue;
197
					}
198
199
					$json_menus[ $slug ]['ID']                          = $locations[ $slug ];
200
					$json_menus[ $slug ]['label']                       = $label;
201
					$json_menus[ $slug ]['meta']['links']['collection'] = $json_url;
202
					$json_menus[ $slug ]['meta']['links']['self']       = $json_url . $slug;
203
					$json_menus[ $slug ]['meta']['links']['html']       = $json_url_base . '/menu-html-location/' . $slug;
204
205
				endforeach;
206
207
			endif;
208
209
			return $json_menus;
210
		}

includes/wp-api-menus-v2.php 1 location

@@ 294-311 (lines=18) @@
291
	        $rest_url_base    = get_rest_url() . self::get_plugin_namespace();
292
            $rest_menus       = array();
293
294
            if ( $locations && $registered_menus ) :
295
296
                foreach ( $registered_menus as $slug => $label ) :
297
298
	                // Sanity check
299
	                if ( ! isset( $locations[ $slug ] ) ) {
300
		                continue;
301
	                }
302
303
	                $rest_menus[ $slug ]['ID']                          = $locations[ $slug ];
304
                    $rest_menus[ $slug ]['label']                       = $label;
305
                    $rest_menus[ $slug ]['meta']['links']['collection'] = $rest_url;
306
                    $rest_menus[ $slug ]['meta']['links']['self']       = $rest_url . $slug;
307
                    $rest_menus[ $slug ]['meta']['links']['html']       = $rest_url_base . '/menu-html-location/' . $slug;
308
309
                endforeach;
310
311
            endif;
312
313
            return $rest_menus;
314
        }