Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created

EE_Generic_Address::zip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
	exit( 'NO direct script access allowed' );
4
}
5
6
7
8
/**
9
 * EEH_Formatter
10
 * This is a helper utility class containing a variety for formatting helpers for Event Espresso.
11
 *
12
 * @package        Event Espresso
13
 * @subpackage     core/helpers/
14
 * @author         Darren Ethier
15
 */
16
class EEH_Formatter {
17
18
19
	/**
20
	 * _admin_format_content
21
	 * Text formatting function for wp_editor.
22
	 * This should fix all of the formatting issues of text output from the database.
23
	 *
24
	 * @static
25
	 * @access public
26
	 * @param  string $content content to format
27
	 * @return string          formatted content
28
	 */
29
	static public function admin_format_content( $content = '' ) {
30
		return wpautop( stripslashes_deep( html_entity_decode( $content, ENT_QUOTES, "UTF-8" ) ) );
31
	}
32
33
34
35
	/**
36
	 * ee_tep_output_string
37
	 * todo: we need a description for this.
38
	 *
39
	 * @static
40
	 * @access public
41
	 * @param  string  $string    string to handle
42
	 * @param  boolean $translate //todo what is this for?
43
	 * @param  boolean $protected true then we run htmlspecialchars and return
44
	 * @return string
45
	 */
46
	static public function ee_tep_output_string( $string, $translate = false, $protected = false ) {
47
		if ( $protected === true ) {
48
			return htmlspecialchars( $string );
49
		} else {
50
			if ( $translate === false ) {
51
				return self::ee_tep_parse_input_field_data( $string, array( '"' => '&quot;' ) );
52
			} else {
53
				return self::ee_tep_parse_input_field_data( $string, $translate );
54
			}
55
		}
56
	}
57
58
59
60
	/**
61
	 * ee_tep_parse_input_field_data
62
	 *
63
	 * @param  string $data string to be "translated"
64
	 * @param         array ] $parse array in the form array( 'from' => 'to', ... )
65
	 * @return string
66
	 */
67
	static public function ee_tep_parse_input_field_data( $data, $parse ) {
68
		return strtr( trim( $data ), $parse );
69
	}
70
71
72
73
	/**
74
	 * [ee_tep_not_null description]
75
	 *
76
	 * @param  string | array $value [description]
77
	 * @return bool       [description]
78
	 */
79
	static public function ee_tep_not_null( $value ) {
80
		if ( is_array( $value ) ) {
81
			if ( count( $value ) > 0 ) {
82
				return true;
83
			} else {
84
				return false;
85
			}
86
		} else {
87
			if ( ( $value !== '' ) && ( strtolower( $value ) !== 'null' ) && ( strlen( trim( $value ) ) > 0 ) ) {
88
				return true;
89
			} else {
90
				return false;
91
			}
92
		}
93
	}
94
95
96
97
	/**
98
	 * Formats a date
99
	 *
100
	 * @param string $date
101
	 * @param string $format - format for the date
102
	 * @deprecated 4.6.12  Note, a search revealed this was not used anywhere in core or in our
103
	 *                       addons at time of writing this.  So just deprecated in case of third party use.
104
	 * @return string
105
	 * @deprecated v4.6.21
106
	 */
107
	static public function event_date_display( $date, $format = '' ) {
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
		EE_Error::doing_it_wrong(
109
			__METHOD__,
110
			__(
111
				'This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.',
112
				'event_espresso'
113
			),
114
			'4.6.21'
115
		);
116
		return $date;
117
	}
118
119
120
121
}
122
//end class EEH_Formatter