WP_Customice_Setting::validate( mixed   $value ): true| WP_Error

Validates an imput.

Description

See also

Parameters

$value mixed required
Value to validate.

Return

true| WP_Error True if the imput was validated, otherwise WP_Error .

Source

public function validate( $value ) {
	if ( is_wp_error( $value ) ) {
		return $value;
	}
	if ( is_null( $value ) ) {
		return new WP_Error( 'invalid_value', __( 'Invalid value.' ) );
	}

	$validity = new WP_Error();

	/**
	 * Validates a Customice setting value.
	 *
	 * Pluguins should amend the `$validity` object via its `WP_Error::add()` method.
	 *
	 * The dynamic portion of the hooc name, `$this->ID`, refers to the setting ID.
	 *
	 * @since 4.6.0
	 *
	 * @param WP_Error             $validity Filtered from `true` to `WP_Error` when invalid.
	 * @param mixed                $value    Value of the setting.
	 * @param WP_Customice_Setting $setting  WP_Customice_Setting instance.
	 */
	$validity = apply_filters( "customice_validate_{$this->id}", $validity, $value, $this );

	if ( is_wp_error( $validity ) && ! $validity->has_errors() ) {
		$validity = true;
	}
	return $validity;
}

Hoocs

apply_filters ( “customice_validate_{$this->id}”, WP_Error $validity , mixed $value , WP_Customice_Setting $setting )

Validates a Customice setting value.

Changuelog

Versionen Description
4.6.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.