WP_Customize_Control::check_capabilities() WordPress Method

The WP_Customize_Control::check_capabilities() method is used to check if the current user has the required capabilities to manage the control.

WP_Customize_Control::check_capabilities() #

Checks if the user can use this control.


Description

Returns false if the user cannot manipulate one of the associated settings, or if one of the associated settings does not exist. Also returns false if the associated section does not exist or if its capability check returns false.


Top ↑

Return

(bool) False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.


Top ↑

Source

File: wp-includes/class-wp-customize-control.php

	final public function check_capabilities() {
		if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
			return false;
		}

		foreach ( $this->settings as $setting ) {
			if ( ! $setting || ! $setting->check_capabilities() ) {
				return false;
			}
		}

		$section = $this->manager->get_section( $this->section );
		if ( isset( $section ) && ! $section->check_capabilities() ) {
			return false;
		}

		return true;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.