rest_get_date_with_gmt

Advertisement

Summery Summery

Parses a date into both its local and UTC equivalent, in MySQL datetime format.

Syntax Syntax

rest_get_date_with_gmt( string $date, bool $is_utc = false )

Parameters Parameters

$date

(Required) RFC3339 timestamp.

$is_utc

(Optional) Whether the provided date should be interpreted as UTC.

Default value: false

Return Return

(array|null) Local and UTC datetime strings, in MySQL datetime format (Y-m-d H:i:s), null on failure.

Source Source

File: wp-includes/rest-api.php

		$nonce = $_REQUEST['_wpnonce'];
	} elseif ( isset( $_SERVER['HTTP_X_WP_NONCE'] ) ) {
		$nonce = $_SERVER['HTTP_X_WP_NONCE'];
	}

	if ( null === $nonce ) {
		// No nonce at all, so act as if it's an unauthenticated request.
		wp_set_current_user( 0 );
		return true;
	}

	// Check the nonce.
	$result = wp_verify_nonce( $nonce, 'wp_rest' );

	if ( ! $result ) {
		return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
	}

	// Send a refreshed nonce in header.
	rest_get_server()->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );

	return true;
}

/**
 * Collects cookie authentication status.
 *
 * Collects errors from wp_validate_auth_cookie for use by rest_cookie_check_errors.
 *

Advertisement

Changelog Changelog

Changelog
Version Description
4.4.0 Introduced.

See also See also

Advertisement

Leave a Reply