$value) { if (is_array($input[$key])) { array_walk_recursive($input[$key], $funcname, $userdata); } else { $saved_value = $value; if (!empty($userdata)) { $funcname($value, $key, $userdata); } else { $funcname($value, $key); } if ($value != $saved_value) { $input[$key] = $value; } } } return true; } } if (!function_exists('wp_strip_all_tags')) { /** * Properly strip all HTML tags including script and style * * @since 2.9.0 * * @param string $string String containing HTML tags * @param bool $remove_breaks optional Whether to remove left over line breaks and white space chars * @return string The processed string. */ function wp_strip_all_tags($string, $remove_breaks = false) { $string = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $string ); $string = strip_tags($string); if ( $remove_breaks ) $string = preg_replace('/[\r\n\t ]+/', ' ', $string); return trim($string); } } if (!function_exists('esc_textarea')) { /** * Escaping for textarea values. * * @since 3.1 * * @param string $text * @return string */ function esc_textarea( $text ) { $safe_text = htmlspecialchars( $text, ENT_QUOTES ); return apply_filters( 'esc_textarea', $safe_text, $text ); } } if (!function_exists('wp_trim_words')) { /** * Trims text to a certain number of words. * * @since 3.3.0 * * @param string $text Text to trim. * @param int $num_words Number of words. Default 55. * @param string $more What to append if $text needs to be trimmed. Default '…'. * @return string Trimmed text. */ function wp_trim_words( $text, $num_words = 55, $more = null ) { if ( null === $more ) $more = __( '…' ); $original_text = $text; $text = wp_strip_all_tags( $text ); $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); if ( count( $words_array ) > $num_words ) { array_pop( $words_array ); $text = implode( ' ', $words_array ); $text = $text . $more; } else { $text = implode( ' ', $words_array ); } return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); } } function awpcp_esc_attr($text) { // WP adds slashes to all request variables $text = stripslashes($text); // AWPCP adds more slashes $text = stripslashes($text); $text = esc_attr($text); return $text; } function awpcp_esc_textarea($text) { $text = stripslashes($text); $text = stripslashes($text); $text = esc_textarea($text); return $text; } /** * @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('