<?php /** * Must match given date. * * @param bool $match Current matching status. Default false. * @param string $operator Store owner selected operator. * @param mixed $value Store owner given value. * @param array $package Shipping package. * @return bool If the current user/environment matches this condition. */ function was_match_condition_date( $match, $operator, $value, $package ) { // Check if its a date, when false subtract the number of days if ( date( 'Y-m-d', strtotime( $value ) ) > 1970 ) : if ( $operator == '==' ) : $match = ( current_time( 'Y-m-d' ) == date_i18n( 'Y-m-d', strtotime( $value ) ) ); elseif ( $operator == '!=' ) : $match = ( current_time( 'Y-m-d' ) != date_i18n( 'Y-m-d', strtotime( $value ) ) ); elseif ( $operator == '>=' ) : $match = ( current_time( 'Y-m-d' ) >= date_i18n( 'Y-m-d', strtotime( $value ) ) ); elseif ( $operator == '<=' ) : $match = ( current_time( 'Y-m-d' ) <= date_i18n( 'Y-m-d', strtotime( $value ) ) ); endif; endif; return $match; } add_action( 'was_match_condition_date', 'was_match_condition_date', 10, 4 );