/** * Checks if the given capability is a valid WordPress capability and if it is assigns it to $capability. * * @since 3.0.0 * * @param string $capability The capability required for this menu to be displayed to the user. * @return Page */ public function setCapability($capability) { if (Capability::isValid($capability)) { $this->capability = $capability; } else { wp_die(__("{$capability} is not a valid WordPress capability.", parent::$textDomain)); } return $this; }
/** * Sets $capabilities if all capabilities are valid. * * @since 3.0.0 * * @param string[] $capabilities An array of the capabilities for this post type. * * @return PostType */ public function setCapabilities($capabilities) { foreach ($capabilities as $capability) { if (!Capability::isValid($capability)) { wp_die(__("{$capability} is not a valid WordPress capability."), parent::$textDomain); } } $this->capabilities = $capabilities; return $this; }