rebase on oct-10-2023

This commit is contained in:
Rachit Bhargava
2023-10-10 17:23:21 -04:00
parent d37566ffb6
commit d096058d7d
4789 changed files with 254611 additions and 307223 deletions

View File

@@ -75,7 +75,11 @@ function wpcf7_is_number( $text ) {
* @link https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date)
*/
function wpcf7_is_date( $text ) {
$result = preg_match( '/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/', $text, $matches );
$result = preg_match(
'/^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/',
$text,
$matches
);
if ( $result ) {
$result = checkdate( $matches[2], $matches[3], $matches[1] );
@@ -85,6 +89,32 @@ function wpcf7_is_date( $text ) {
}
/**
* Checks whether the given text is a valid time.
*
* @link https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time)
*/
function wpcf7_is_time( $text ) {
$result = preg_match(
'/^([0-9]{2})\:([0-9]{2})(?:\:([0-9]{2}))?$/',
$text,
$matches
);
if ( $result ) {
$hour = (int) $matches[1];
$minute = (int) $matches[2];
$second = empty( $matches[3] ) ? 0 : (int) $matches[3];
$result = 0 <= $hour && $hour <= 23 &&
0 <= $minute && $minute <= 59 &&
0 <= $second && $second <= 59;
}
return apply_filters( 'wpcf7_is_time', $result, $text );
}
/**
* Checks whether the given text is a well-formed mailbox list.
*
@@ -229,12 +259,23 @@ function wpcf7_is_file_path_in_content_dir( $path ) {
return false;
}
if ( 0 === strpos( $path, realpath( WP_CONTENT_DIR ) ) ) {
if (
str_starts_with( $path, trailingslashit( realpath( WP_CONTENT_DIR ) ) )
) {
return true;
}
if ( defined( 'UPLOADS' )
and 0 === strpos( $path, realpath( ABSPATH . UPLOADS ) ) ) {
if (
defined( 'UPLOADS' ) and
str_starts_with( $path, trailingslashit( realpath( ABSPATH . UPLOADS ) ) )
) {
return true;
}
if (
defined( 'WP_TEMP_DIR' ) and
str_starts_with( $path, trailingslashit( realpath( WP_TEMP_DIR ) ) )
) {
return true;
}