$data ) { $value[ $key ] = awpcp_apply_function_deep( $function, $data ); } } elseif ( is_object( $value ) ) { $vars = get_object_vars( $value ); foreach ( $vars as $key => $data ) { $value->{$key} = awpcp_apply_function_deep( $function, $data ); } } elseif ( is_string( $value ) ) { $value = call_user_func( $function, $value ); } return $value; } /** * @since 3.3 */ function awpcp_strip_all_tags_deep( $string ) { return awpcp_apply_function_deep( 'wp_strip_all_tags', $string ); } /** * @since 3.0.2 */ function awpcp_strptime( $date, $format ) { if ( function_exists( 'strptime' ) ) { return strptime( $date, $format ); } else { return awpcp_strptime_replacement( $date, $format ); } } /** * @since 3.0.2 */ function awpcp_strptime_replacement( $date, $format ) { $masks = array( '%d' => '(?P[0-9]{2})', '%m' => '(?P[0-9]{2})', '%y' => '(?P[0-9]{2})', '%Y' => '(?P[0-9]{4})', '%H' => '(?P[0-9]{2})', '%M' => '(?P[0-9]{2})', '%S' => '(?P[0-9]{2})', // usw.. ); $regexp = "#" . strtr( preg_quote( $format ), $masks ) . "#"; if ( ! preg_match( $regexp, $date, $out ) ) { return false; } $unparsed = preg_replace( $regexp, '', $date ); if ( isset( $out['y'] ) && strlen( $out['y'] ) ) { $out['Y'] = ( $out['y'] > 69 ? 1900 : 2000 ) + $out['y']; } $ret = array( 'tm_sec' => (int) awpcp_array_data( 'S', 0, $out), 'tm_min' => (int) awpcp_array_data( 'M', 0, $out), 'tm_hour' => (int) awpcp_array_data( 'H', 0, $out), 'tm_mday' => (int) awpcp_array_data( 'd', 0, $out), 'tm_mon' => awpcp_array_data( 'm', 0, $out) ? awpcp_array_data( 'm', 0, $out) - 1 : 0, 'tm_year' => awpcp_array_data( 'Y', 0, $out) > 1900 ? awpcp_array_data( 'Y', 0, $out) - 1900 : 0, 'unparsed' => $unparsed, ); return $ret; } /** * @since 3.0 */ function awpcp_date_formats() { static $translations; if ( ! is_array( $translations ) ) { $translations = array( 'd' => 'dd', 'j' => 'd', 's' => null, 'l' => 'DD', 'D' => 'D', 'm' => 'mm', 'n' => 'm', 'F' => 'MM', 'M' => 'M', 'Y' => 'yy', 'y' => 'y', 'c' => 'ISO_8601', 'r' => 'RFC_822', ); } return $translations; } /** * @since 3.0 */ function awpcp_time_formats() { static $translations; if ( ! is_array( $translations ) ) { $translations = array( 'a' => 'p', 'A' => 'P', 'g' => 'h', 'h' => 'hh', 'G' => 'H', 'H' => 'HH', 'i' => 'mm', 's' => 'ss', 'T' => null, 'c' => null, 'r' => null ); } return $translations; } /** * Translates PHP date format strings to jQuery Datepicker format. * @since 3.0 */ function awpcp_datepicker_format($format) { return _awpcp_replace_format($format, awpcp_date_formats()); } /** * Translates PHP time format strings to jQuery TimePicker format. * @since 3.0 */ function awpcp_timepicker_format($format) { return _awpcp_replace_format($format, awpcp_time_formats()); } /** * @since 3.0 */ function _awpcp_replace_format($format, $translations) { $pattern = join( '|', array_map( 'preg_quote', array_keys( $translations ) ) ); preg_match_all( "/$pattern/s", $format, $matches ); $processed = array(); foreach ( $matches[0] as $match ) { if ( ! isset( $processed[ $match ] ) ) { $format = str_replace( $match, $translations[ $match ], $format ); $processed[ $match ] = true; } } return $format; } /** * @since 3.0 */ function awpcp_get_date_format() { return get_awpcp_option('date-format'); } /** * @since 3.0 */ function awpcp_get_time_format() { return get_awpcp_option('time-format'); } /** * @since 3.0 */ function awpcp_get_datetime_format() { $format = get_awpcp_option('date-time-format'); $format = str_replace('', '******', $format); $format = str_replace('