Code Duplication    Length = 19-19 lines in 3 locations

includes/class-wp-fields-api-screen.php 1 location

@@ 262-280 (lines=19) @@
259
	 *
260
	 * @return bool False if theme doesn't support the screen or user can't change screen, otherwise true.
261
	 */
262
	public function check_capabilities() {
263
264
		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
265
			return false;
266
		}
267
268
		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
269
			return false;
270
		}
271
272
		$access = true;
273
274
		if ( is_callable( $this->capabilities_callback ) ) {
275
			$access = call_user_func( $this->capabilities_callback, $this );
276
		}
277
278
		return $access;
279
280
	}
281
282
	/**
283
	 * Get the screen's content template for insertion into the Fields API screen.

includes/class-wp-fields-api-section.php 1 location

@@ 283-301 (lines=19) @@
280
	 *
281
	 * @return bool False if theme doesn't support the section or user can't change section, otherwise true.
282
	 */
283
	public function check_capabilities() {
284
285
		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
286
			return false;
287
		}
288
289
		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
290
			return false;
291
		}
292
293
		$access = true;
294
295
		if ( is_callable( $this->capabilities_callback ) ) {
296
			$access = call_user_func( $this->capabilities_callback, $this );
297
		}
298
299
		return $access;
300
301
	}
302
303
	/**
304
	 * Get the section's content template for insertion into the Fields UI.

includes/class-wp-fields-api-field.php 1 location

@@ 549-567 (lines=19) @@
546
	 *
547
	 * @return bool False if theme doesn't support the section or user can't change section, otherwise true.
548
	 */
549
	public function check_capabilities() {
550
551
		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
552
			return false;
553
		}
554
555
		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
556
			return false;
557
		}
558
559
		$access = true;
560
561
		if ( is_callable( $this->capabilities_callback ) ) {
562
			$access = call_user_func( $this->capabilities_callback, $this );
563
		}
564
565
		return $access;
566
567
	}
568
569
	/**
570
	 * Multidimensional helper function.