@@ -13,25 +13,25 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @deprecated 4.9.53 |
|
18 | - * @param EEI_Request_Decorator $application |
|
19 | - * @param array $middlewares |
|
20 | - */ |
|
21 | - public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | - { |
|
23 | - EE_Error::doing_it_wrong( |
|
24 | - __METHOD__, |
|
25 | - sprintf( |
|
26 | - esc_html__( |
|
27 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - 'EventEspresso\core\services\request\RequestStack', |
|
31 | - '\core\services\request', |
|
32 | - 'EventEspresso\core\services\request' |
|
33 | - ), |
|
34 | - '4.9.53' |
|
35 | - ); |
|
36 | - } |
|
16 | + /** |
|
17 | + * @deprecated 4.9.53 |
|
18 | + * @param EEI_Request_Decorator $application |
|
19 | + * @param array $middlewares |
|
20 | + */ |
|
21 | + public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | + { |
|
23 | + EE_Error::doing_it_wrong( |
|
24 | + __METHOD__, |
|
25 | + sprintf( |
|
26 | + esc_html__( |
|
27 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + 'EventEspresso\core\services\request\RequestStack', |
|
31 | + '\core\services\request', |
|
32 | + 'EventEspresso\core\services\request' |
|
33 | + ), |
|
34 | + '4.9.53' |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | } |
@@ -12,184 +12,184 @@ |
||
12 | 12 | abstract class EES_Shortcode extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @protected public |
|
17 | - * @var array $_attributes |
|
18 | - */ |
|
19 | - protected $_attributes = array(); |
|
20 | - |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | - */ |
|
26 | - final public function __construct() |
|
27 | - { |
|
28 | - $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | - // make sure system knows this is an EE page |
|
32 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * run - initial shortcode module setup called during "parse_request" hook by |
|
39 | - * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
40 | - * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
41 | - * by a theme or plugin in a non-standard way. |
|
42 | - * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
43 | - * that will be required by the shortcode when it is actually processed. |
|
44 | - * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @param WP $WP |
|
48 | - * @return void |
|
49 | - */ |
|
50 | - abstract public function run(WP $WP); |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * process_shortcode |
|
56 | - * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
57 | - * |
|
58 | - * @access public |
|
59 | - * @param array $attributes |
|
60 | - * @return mixed |
|
61 | - */ |
|
62 | - abstract public function process_shortcode($attributes = array()); |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * instance - returns instance of child class object |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @param string $shortcode_class |
|
71 | - * @return \EES_Shortcode |
|
72 | - */ |
|
73 | - final public static function instance($shortcode_class = null) |
|
74 | - { |
|
75 | - $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
76 | - if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
77 | - return null; |
|
78 | - } |
|
79 | - $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
80 | - $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
81 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
82 | - : null; |
|
83 | - return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
84 | - ? $shortcode_obj |
|
85 | - : new $shortcode_class(); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * fallback_shortcode_processor - create instance and call process_shortcode |
|
93 | - * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @param $attributes |
|
97 | - * @return mixed |
|
98 | - */ |
|
99 | - final public static function fallback_shortcode_processor($attributes) |
|
100 | - { |
|
101 | - if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
102 | - return null; |
|
103 | - } |
|
104 | - // what shortcode was actually parsed ? |
|
105 | - $shortcode_class = get_called_class(); |
|
106 | - // notify rest of system that fallback processor was triggered |
|
107 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
108 | - // get instance of actual shortcode |
|
109 | - $shortcode_obj = self::instance($shortcode_class); |
|
110 | - // verify class |
|
111 | - if ($shortcode_obj instanceof EES_Shortcode) { |
|
112 | - global $wp; |
|
113 | - $shortcode_obj->run($wp); |
|
114 | - // set attributes and run the shortcode |
|
115 | - $shortcode_obj->_attributes = (array) $attributes; |
|
116 | - return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
117 | - } else { |
|
118 | - return null; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param $attributes |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - final public static function invalid_shortcode_processor($attributes) |
|
133 | - { |
|
134 | - return ''; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Performs basic sanitization on shortcode attributes |
|
143 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
144 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
145 | - * This can be overridden by supplying an array for the $custom_sanitization param, |
|
146 | - * where keys match keys in your attributes array, |
|
147 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
148 | - * So for example, if you had an integer attribute named "event_id" |
|
149 | - * that you wanted to be sanitized using absint(), |
|
150 | - * then you would pass the following for your $custom_sanitization array: |
|
151 | - * array('event_id' => 'absint') |
|
152 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
153 | - * |
|
154 | - * @param array $attributes |
|
155 | - * @param array $custom_sanitization |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
159 | - { |
|
160 | - foreach ($attributes as $key => $value) { |
|
161 | - // is a custom sanitization callback specified ? |
|
162 | - if (isset($custom_sanitization[ $key ])) { |
|
163 | - $callback = $custom_sanitization[ $key ]; |
|
164 | - if ($callback === 'skip_sanitization') { |
|
165 | - $attributes[ $key ] = $value; |
|
166 | - continue; |
|
167 | - } elseif (function_exists($callback)) { |
|
168 | - $attributes[ $key ] = $callback($value); |
|
169 | - continue; |
|
170 | - } |
|
171 | - } |
|
172 | - switch (true) { |
|
173 | - case $value === null: |
|
174 | - case is_int($value): |
|
175 | - case is_float($value): |
|
176 | - // typical booleans |
|
177 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
178 | - $attributes[ $key ] = $value; |
|
179 | - break; |
|
180 | - case is_string($value): |
|
181 | - $attributes[ $key ] = sanitize_text_field($value); |
|
182 | - break; |
|
183 | - case is_array($value): |
|
184 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | - break; |
|
186 | - default: |
|
187 | - // only remaining data types are Object and Resource |
|
188 | - // which are not allowed as shortcode attributes |
|
189 | - $attributes[ $key ] = null; |
|
190 | - break; |
|
191 | - } |
|
192 | - } |
|
193 | - return $attributes; |
|
194 | - } |
|
15 | + /** |
|
16 | + * @protected public |
|
17 | + * @var array $_attributes |
|
18 | + */ |
|
19 | + protected $_attributes = array(); |
|
20 | + |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
25 | + */ |
|
26 | + final public function __construct() |
|
27 | + { |
|
28 | + $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
29 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
30 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
31 | + // make sure system knows this is an EE page |
|
32 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * run - initial shortcode module setup called during "parse_request" hook by |
|
39 | + * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
40 | + * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
41 | + * by a theme or plugin in a non-standard way. |
|
42 | + * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
43 | + * that will be required by the shortcode when it is actually processed. |
|
44 | + * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @param WP $WP |
|
48 | + * @return void |
|
49 | + */ |
|
50 | + abstract public function run(WP $WP); |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * process_shortcode |
|
56 | + * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
57 | + * |
|
58 | + * @access public |
|
59 | + * @param array $attributes |
|
60 | + * @return mixed |
|
61 | + */ |
|
62 | + abstract public function process_shortcode($attributes = array()); |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * instance - returns instance of child class object |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @param string $shortcode_class |
|
71 | + * @return \EES_Shortcode |
|
72 | + */ |
|
73 | + final public static function instance($shortcode_class = null) |
|
74 | + { |
|
75 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
76 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
77 | + return null; |
|
78 | + } |
|
79 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
80 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
81 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
82 | + : null; |
|
83 | + return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
84 | + ? $shortcode_obj |
|
85 | + : new $shortcode_class(); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * fallback_shortcode_processor - create instance and call process_shortcode |
|
93 | + * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @param $attributes |
|
97 | + * @return mixed |
|
98 | + */ |
|
99 | + final public static function fallback_shortcode_processor($attributes) |
|
100 | + { |
|
101 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
102 | + return null; |
|
103 | + } |
|
104 | + // what shortcode was actually parsed ? |
|
105 | + $shortcode_class = get_called_class(); |
|
106 | + // notify rest of system that fallback processor was triggered |
|
107 | + add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
108 | + // get instance of actual shortcode |
|
109 | + $shortcode_obj = self::instance($shortcode_class); |
|
110 | + // verify class |
|
111 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
112 | + global $wp; |
|
113 | + $shortcode_obj->run($wp); |
|
114 | + // set attributes and run the shortcode |
|
115 | + $shortcode_obj->_attributes = (array) $attributes; |
|
116 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
117 | + } else { |
|
118 | + return null; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param $attributes |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + final public static function invalid_shortcode_processor($attributes) |
|
133 | + { |
|
134 | + return ''; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Performs basic sanitization on shortcode attributes |
|
143 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
144 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
145 | + * This can be overridden by supplying an array for the $custom_sanitization param, |
|
146 | + * where keys match keys in your attributes array, |
|
147 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
148 | + * So for example, if you had an integer attribute named "event_id" |
|
149 | + * that you wanted to be sanitized using absint(), |
|
150 | + * then you would pass the following for your $custom_sanitization array: |
|
151 | + * array('event_id' => 'absint') |
|
152 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
153 | + * |
|
154 | + * @param array $attributes |
|
155 | + * @param array $custom_sanitization |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
159 | + { |
|
160 | + foreach ($attributes as $key => $value) { |
|
161 | + // is a custom sanitization callback specified ? |
|
162 | + if (isset($custom_sanitization[ $key ])) { |
|
163 | + $callback = $custom_sanitization[ $key ]; |
|
164 | + if ($callback === 'skip_sanitization') { |
|
165 | + $attributes[ $key ] = $value; |
|
166 | + continue; |
|
167 | + } elseif (function_exists($callback)) { |
|
168 | + $attributes[ $key ] = $callback($value); |
|
169 | + continue; |
|
170 | + } |
|
171 | + } |
|
172 | + switch (true) { |
|
173 | + case $value === null: |
|
174 | + case is_int($value): |
|
175 | + case is_float($value): |
|
176 | + // typical booleans |
|
177 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
178 | + $attributes[ $key ] = $value; |
|
179 | + break; |
|
180 | + case is_string($value): |
|
181 | + $attributes[ $key ] = sanitize_text_field($value); |
|
182 | + break; |
|
183 | + case is_array($value): |
|
184 | + $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | + break; |
|
186 | + default: |
|
187 | + // only remaining data types are Object and Resource |
|
188 | + // which are not allowed as shortcode attributes |
|
189 | + $attributes[ $key ] = null; |
|
190 | + break; |
|
191 | + } |
|
192 | + } |
|
193 | + return $attributes; |
|
194 | + } |
|
195 | 195 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // what shortcode was actually parsed ? |
105 | 105 | $shortcode_class = get_called_class(); |
106 | 106 | // notify rest of system that fallback processor was triggered |
107 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
107 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
108 | 108 | // get instance of actual shortcode |
109 | 109 | $shortcode_obj = self::instance($shortcode_class); |
110 | 110 | // verify class |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | { |
160 | 160 | foreach ($attributes as $key => $value) { |
161 | 161 | // is a custom sanitization callback specified ? |
162 | - if (isset($custom_sanitization[ $key ])) { |
|
163 | - $callback = $custom_sanitization[ $key ]; |
|
162 | + if (isset($custom_sanitization[$key])) { |
|
163 | + $callback = $custom_sanitization[$key]; |
|
164 | 164 | if ($callback === 'skip_sanitization') { |
165 | - $attributes[ $key ] = $value; |
|
165 | + $attributes[$key] = $value; |
|
166 | 166 | continue; |
167 | 167 | } elseif (function_exists($callback)) { |
168 | - $attributes[ $key ] = $callback($value); |
|
168 | + $attributes[$key] = $callback($value); |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | } |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | case is_float($value): |
176 | 176 | // typical booleans |
177 | 177 | case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
178 | - $attributes[ $key ] = $value; |
|
178 | + $attributes[$key] = $value; |
|
179 | 179 | break; |
180 | 180 | case is_string($value): |
181 | - $attributes[ $key ] = sanitize_text_field($value); |
|
181 | + $attributes[$key] = sanitize_text_field($value); |
|
182 | 182 | break; |
183 | 183 | case is_array($value): |
184 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
184 | + $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | 185 | break; |
186 | 186 | default: |
187 | 187 | // only remaining data types are Object and Resource |
188 | 188 | // which are not allowed as shortcode attributes |
189 | - $attributes[ $key ] = null; |
|
189 | + $attributes[$key] = null; |
|
190 | 190 | break; |
191 | 191 | } |
192 | 192 | } |
@@ -16,108 +16,108 @@ |
||
16 | 16 | abstract class EE_Base_Class_Repository extends EE_Object_Repository implements EEI_Deletable |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * EE_Base_Class_Repository constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->persist_method = 'save'; |
|
25 | - } |
|
19 | + /** |
|
20 | + * EE_Base_Class_Repository constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->persist_method = 'save'; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * save |
|
30 | - * |
|
31 | - * calls EE_Base_Class::save() on the current object |
|
32 | - * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | - * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | - * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | - * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | - * @return bool | int |
|
40 | - */ |
|
41 | - public function save($arguments = array()) |
|
42 | - { |
|
43 | - return $this->persist('save', $arguments); |
|
44 | - } |
|
28 | + /** |
|
29 | + * save |
|
30 | + * |
|
31 | + * calls EE_Base_Class::save() on the current object |
|
32 | + * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | + * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | + * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | + * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | + * @return bool | int |
|
40 | + */ |
|
41 | + public function save($arguments = array()) |
|
42 | + { |
|
43 | + return $this->persist('save', $arguments); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * save_all |
|
49 | - * |
|
50 | - * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return bool | int |
|
54 | - */ |
|
55 | - public function save_all() |
|
56 | - { |
|
57 | - return $this->persist_all('save'); |
|
58 | - } |
|
47 | + /** |
|
48 | + * save_all |
|
49 | + * |
|
50 | + * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return bool | int |
|
54 | + */ |
|
55 | + public function save_all() |
|
56 | + { |
|
57 | + return $this->persist_all('save'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Calls EE_Base_Class::delete() on the current object |
|
63 | - * Keep in mind that this always detaches the object from the collection |
|
64 | - * regardless of whether the delete was successful for the db. This is because |
|
65 | - * its possible that the object ONLY existed in the collection. |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function delete() |
|
71 | - { |
|
72 | - $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | - $this->remove($this->current()); |
|
74 | - return $success; |
|
75 | - } |
|
61 | + /** |
|
62 | + * Calls EE_Base_Class::delete() on the current object |
|
63 | + * Keep in mind that this always detaches the object from the collection |
|
64 | + * regardless of whether the delete was successful for the db. This is because |
|
65 | + * its possible that the object ONLY existed in the collection. |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function delete() |
|
71 | + { |
|
72 | + $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | + $this->remove($this->current()); |
|
74 | + return $success; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * delete_all |
|
80 | - * |
|
81 | - * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function delete_all() |
|
87 | - { |
|
88 | - $success = true; |
|
89 | - $this->rewind(); |
|
90 | - while ($this->valid()) { |
|
91 | - // any db error will result in false being returned |
|
92 | - $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | - // can't remove current object because valid() requires it |
|
94 | - // so just capture current object temporarily |
|
95 | - $object = $this->current(); |
|
96 | - // advance the pointer |
|
97 | - $this->next(); |
|
98 | - // THEN remove the object from the repository |
|
99 | - $this->remove($object); |
|
100 | - } |
|
101 | - return $success; |
|
102 | - } |
|
78 | + /** |
|
79 | + * delete_all |
|
80 | + * |
|
81 | + * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function delete_all() |
|
87 | + { |
|
88 | + $success = true; |
|
89 | + $this->rewind(); |
|
90 | + while ($this->valid()) { |
|
91 | + // any db error will result in false being returned |
|
92 | + $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | + // can't remove current object because valid() requires it |
|
94 | + // so just capture current object temporarily |
|
95 | + $object = $this->current(); |
|
96 | + // advance the pointer |
|
97 | + $this->next(); |
|
98 | + // THEN remove the object from the repository |
|
99 | + $this->remove($object); |
|
100 | + } |
|
101 | + return $success; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * update_extra_meta |
|
107 | - * |
|
108 | - * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param string $meta_key |
|
112 | - * @param string $meta_value |
|
113 | - * @param string $previous_value |
|
114 | - * @return bool | int |
|
115 | - */ |
|
116 | - public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | - { |
|
118 | - return $this->_call_user_func_array_on_current( |
|
119 | - 'update_extra_meta', |
|
120 | - array($meta_key, $meta_value, $previous_value) |
|
121 | - ); |
|
122 | - } |
|
105 | + /** |
|
106 | + * update_extra_meta |
|
107 | + * |
|
108 | + * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param string $meta_key |
|
112 | + * @param string $meta_value |
|
113 | + * @param string $previous_value |
|
114 | + * @return bool | int |
|
115 | + */ |
|
116 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | + { |
|
118 | + return $this->_call_user_func_array_on_current( |
|
119 | + 'update_extra_meta', |
|
120 | + array($meta_key, $meta_value, $previous_value) |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | } |
@@ -10,143 +10,143 @@ |
||
10 | 10 | abstract class EE_Configurable extends EE_Base |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @var $_config |
|
15 | - * @type EE_Config_Base |
|
16 | - */ |
|
17 | - protected $_config; |
|
18 | - |
|
19 | - /** |
|
20 | - * @var $_config_section |
|
21 | - * @type string |
|
22 | - */ |
|
23 | - protected $_config_section = ''; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var $_config_class |
|
27 | - * @type string |
|
28 | - */ |
|
29 | - protected $_config_class = ''; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var $_config_name |
|
33 | - * @type string |
|
34 | - */ |
|
35 | - protected $_config_name = ''; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $config_section |
|
40 | - */ |
|
41 | - public function set_config_section($config_section = '') |
|
42 | - { |
|
43 | - $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return mixed |
|
49 | - */ |
|
50 | - public function config_section() |
|
51 | - { |
|
52 | - return $this->_config_section; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param string $config_class |
|
58 | - */ |
|
59 | - public function set_config_class($config_class = '') |
|
60 | - { |
|
61 | - $this->_config_class = $config_class; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return mixed |
|
67 | - */ |
|
68 | - public function config_class() |
|
69 | - { |
|
70 | - return $this->_config_class; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param mixed $config_name |
|
76 | - */ |
|
77 | - public function set_config_name($config_name) |
|
78 | - { |
|
79 | - $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return mixed |
|
85 | - */ |
|
86 | - public function config_name() |
|
87 | - { |
|
88 | - return $this->_config_name; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * set_config |
|
94 | - * this method integrates directly with EE_Config to set up the config object for this class |
|
95 | - * |
|
96 | - * @access protected |
|
97 | - * @param EE_Config_Base $config_obj |
|
98 | - * @return mixed EE_Config_Base | NULL |
|
99 | - */ |
|
100 | - protected function _set_config(EE_Config_Base $config_obj = null) |
|
101 | - { |
|
102 | - return EE_Config::instance()->set_config( |
|
103 | - $this->config_section(), |
|
104 | - $this->config_name(), |
|
105 | - $this->config_class(), |
|
106 | - $config_obj |
|
107 | - ); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * _update_config |
|
113 | - * this method integrates directly with EE_Config to update an existing config object for this class |
|
114 | - * |
|
115 | - * @access protected |
|
116 | - * @param EE_Config_Base $config_obj |
|
117 | - * @throws \EE_Error |
|
118 | - * @return mixed EE_Config_Base | NULL |
|
119 | - */ |
|
120 | - public function _update_config(EE_Config_Base $config_obj = null) |
|
121 | - { |
|
122 | - $config_class = $this->config_class(); |
|
123 | - if (! $config_obj instanceof $config_class) { |
|
124 | - throw new EE_Error( |
|
125 | - sprintf( |
|
126 | - __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
127 | - print_r($config_obj, true), |
|
128 | - $config_class |
|
129 | - ) |
|
130 | - ); |
|
131 | - } |
|
132 | - return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * gets the class's config object |
|
138 | - * |
|
139 | - * @return EE_Config_Base |
|
140 | - */ |
|
141 | - public function config() |
|
142 | - { |
|
143 | - if (empty($this->_config)) { |
|
144 | - $this->_config = EE_Config::instance()->get_config( |
|
145 | - $this->config_section(), |
|
146 | - $this->config_name(), |
|
147 | - $this->config_class() |
|
148 | - ); |
|
149 | - } |
|
150 | - return $this->_config; |
|
151 | - } |
|
13 | + /** |
|
14 | + * @var $_config |
|
15 | + * @type EE_Config_Base |
|
16 | + */ |
|
17 | + protected $_config; |
|
18 | + |
|
19 | + /** |
|
20 | + * @var $_config_section |
|
21 | + * @type string |
|
22 | + */ |
|
23 | + protected $_config_section = ''; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var $_config_class |
|
27 | + * @type string |
|
28 | + */ |
|
29 | + protected $_config_class = ''; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var $_config_name |
|
33 | + * @type string |
|
34 | + */ |
|
35 | + protected $_config_name = ''; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $config_section |
|
40 | + */ |
|
41 | + public function set_config_section($config_section = '') |
|
42 | + { |
|
43 | + $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return mixed |
|
49 | + */ |
|
50 | + public function config_section() |
|
51 | + { |
|
52 | + return $this->_config_section; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param string $config_class |
|
58 | + */ |
|
59 | + public function set_config_class($config_class = '') |
|
60 | + { |
|
61 | + $this->_config_class = $config_class; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return mixed |
|
67 | + */ |
|
68 | + public function config_class() |
|
69 | + { |
|
70 | + return $this->_config_class; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param mixed $config_name |
|
76 | + */ |
|
77 | + public function set_config_name($config_name) |
|
78 | + { |
|
79 | + $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return mixed |
|
85 | + */ |
|
86 | + public function config_name() |
|
87 | + { |
|
88 | + return $this->_config_name; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * set_config |
|
94 | + * this method integrates directly with EE_Config to set up the config object for this class |
|
95 | + * |
|
96 | + * @access protected |
|
97 | + * @param EE_Config_Base $config_obj |
|
98 | + * @return mixed EE_Config_Base | NULL |
|
99 | + */ |
|
100 | + protected function _set_config(EE_Config_Base $config_obj = null) |
|
101 | + { |
|
102 | + return EE_Config::instance()->set_config( |
|
103 | + $this->config_section(), |
|
104 | + $this->config_name(), |
|
105 | + $this->config_class(), |
|
106 | + $config_obj |
|
107 | + ); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * _update_config |
|
113 | + * this method integrates directly with EE_Config to update an existing config object for this class |
|
114 | + * |
|
115 | + * @access protected |
|
116 | + * @param EE_Config_Base $config_obj |
|
117 | + * @throws \EE_Error |
|
118 | + * @return mixed EE_Config_Base | NULL |
|
119 | + */ |
|
120 | + public function _update_config(EE_Config_Base $config_obj = null) |
|
121 | + { |
|
122 | + $config_class = $this->config_class(); |
|
123 | + if (! $config_obj instanceof $config_class) { |
|
124 | + throw new EE_Error( |
|
125 | + sprintf( |
|
126 | + __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
127 | + print_r($config_obj, true), |
|
128 | + $config_class |
|
129 | + ) |
|
130 | + ); |
|
131 | + } |
|
132 | + return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * gets the class's config object |
|
138 | + * |
|
139 | + * @return EE_Config_Base |
|
140 | + */ |
|
141 | + public function config() |
|
142 | + { |
|
143 | + if (empty($this->_config)) { |
|
144 | + $this->_config = EE_Config::instance()->get_config( |
|
145 | + $this->config_section(), |
|
146 | + $this->config_name(), |
|
147 | + $this->config_class() |
|
148 | + ); |
|
149 | + } |
|
150 | + return $this->_config; |
|
151 | + } |
|
152 | 152 | } |
@@ -120,7 +120,7 @@ |
||
120 | 120 | public function _update_config(EE_Config_Base $config_obj = null) |
121 | 121 | { |
122 | 122 | $config_class = $this->config_class(); |
123 | - if (! $config_obj instanceof $config_class) { |
|
123 | + if ( ! $config_obj instanceof $config_class) { |
|
124 | 124 | throw new EE_Error( |
125 | 125 | sprintf( |
126 | 126 | __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
@@ -59,11 +59,11 @@ |
||
59 | 59 | ); |
60 | 60 | $this->_model_relations = array(); |
61 | 61 | foreach ($models_this_can_attach_to as $model) { |
62 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
62 | + $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
|
63 | 63 | } |
64 | 64 | $this->_wp_core_model = true; |
65 | 65 | foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
66 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
66 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta( |
|
67 | 67 | 'meta_key', |
68 | 68 | 'meta_value' |
69 | 69 | ); |
@@ -18,56 +18,56 @@ |
||
18 | 18 | class EEM_Post_Meta extends EEM_Base |
19 | 19 | { |
20 | 20 | |
21 | - // private instance of the EE_Post_Meta object |
|
22 | - protected static $_instance; |
|
21 | + // private instance of the EE_Post_Meta object |
|
22 | + protected static $_instance; |
|
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - protected function __construct(string $timezone = '') |
|
27 | - { |
|
28 | - $this->singular_item = esc_html__('Post Meta', 'event_espresso'); |
|
29 | - $this->plural_item = esc_html__('Post Metas', 'event_espresso'); |
|
30 | - $this->_tables = array( |
|
31 | - 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
32 | - ); |
|
33 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
34 | - $this->_fields = array( |
|
35 | - 'Post_Meta' => array( |
|
36 | - 'meta_id' => new EE_Primary_Key_Int_Field( |
|
37 | - 'meta_id', |
|
38 | - esc_html__("Meta ID", "event_espresso") |
|
39 | - ), |
|
40 | - 'post_id' => new EE_Foreign_Key_Int_Field( |
|
41 | - 'post_id', |
|
42 | - esc_html__("Primary Key of Post", "event_espresso"), |
|
43 | - false, |
|
44 | - 0, |
|
45 | - $models_this_can_attach_to |
|
46 | - ), |
|
47 | - 'meta_key' => new EE_Plain_Text_Field( |
|
48 | - 'meta_key', |
|
49 | - esc_html__("Meta Key", "event_espresso"), |
|
50 | - false, |
|
51 | - '' |
|
52 | - ), |
|
53 | - 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
54 | - 'meta_value', |
|
55 | - esc_html__("Meta Value", "event_espresso"), |
|
56 | - true |
|
57 | - ), |
|
58 | - ), |
|
59 | - ); |
|
60 | - $this->_model_relations = array(); |
|
61 | - foreach ($models_this_can_attach_to as $model) { |
|
62 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
63 | - } |
|
64 | - $this->_wp_core_model = true; |
|
65 | - foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
66 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
67 | - 'meta_key', |
|
68 | - 'meta_value' |
|
69 | - ); |
|
70 | - } |
|
71 | - parent::__construct($timezone); |
|
72 | - } |
|
26 | + protected function __construct(string $timezone = '') |
|
27 | + { |
|
28 | + $this->singular_item = esc_html__('Post Meta', 'event_espresso'); |
|
29 | + $this->plural_item = esc_html__('Post Metas', 'event_espresso'); |
|
30 | + $this->_tables = array( |
|
31 | + 'Post_Meta' => new EE_Primary_Table('postmeta', 'meta_id'), |
|
32 | + ); |
|
33 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
34 | + $this->_fields = array( |
|
35 | + 'Post_Meta' => array( |
|
36 | + 'meta_id' => new EE_Primary_Key_Int_Field( |
|
37 | + 'meta_id', |
|
38 | + esc_html__("Meta ID", "event_espresso") |
|
39 | + ), |
|
40 | + 'post_id' => new EE_Foreign_Key_Int_Field( |
|
41 | + 'post_id', |
|
42 | + esc_html__("Primary Key of Post", "event_espresso"), |
|
43 | + false, |
|
44 | + 0, |
|
45 | + $models_this_can_attach_to |
|
46 | + ), |
|
47 | + 'meta_key' => new EE_Plain_Text_Field( |
|
48 | + 'meta_key', |
|
49 | + esc_html__("Meta Key", "event_espresso"), |
|
50 | + false, |
|
51 | + '' |
|
52 | + ), |
|
53 | + 'meta_value' => new EE_Maybe_Serialized_Text_Field( |
|
54 | + 'meta_value', |
|
55 | + esc_html__("Meta Value", "event_espresso"), |
|
56 | + true |
|
57 | + ), |
|
58 | + ), |
|
59 | + ); |
|
60 | + $this->_model_relations = array(); |
|
61 | + foreach ($models_this_can_attach_to as $model) { |
|
62 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Relation(); |
|
63 | + } |
|
64 | + $this->_wp_core_model = true; |
|
65 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
66 | + $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( |
|
67 | + 'meta_key', |
|
68 | + 'meta_value' |
|
69 | + ); |
|
70 | + } |
|
71 | + parent::__construct($timezone); |
|
72 | + } |
|
73 | 73 | } |
@@ -7,77 +7,77 @@ |
||
7 | 7 | class EE_Float_Field extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @param string $table_column |
|
12 | - * @param string $nicename |
|
13 | - * @param bool $nullable |
|
14 | - * @param null $default_value |
|
15 | - */ |
|
16 | - public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | - { |
|
18 | - parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | - $this->setSchemaType('number'); |
|
20 | - } |
|
10 | + /** |
|
11 | + * @param string $table_column |
|
12 | + * @param string $nicename |
|
13 | + * @param bool $nullable |
|
14 | + * @param null $default_value |
|
15 | + */ |
|
16 | + public function __construct($table_column, $nicename, $nullable, $default_value = null) |
|
17 | + { |
|
18 | + parent::__construct($table_column, $nicename, $nullable, $default_value); |
|
19 | + $this->setSchemaType('number'); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | - * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | - * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | - * Returns a float |
|
28 | - * |
|
29 | - * @param type $value_inputted_for_field_on_model_object |
|
30 | - * @return float |
|
31 | - */ |
|
32 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | - { |
|
23 | + /** |
|
24 | + * If provided a string, strips out number-related formatting, like commas, periods, spaces, other junk, etc. |
|
25 | + * However, treats commas and periods as thousand-separators ro decimal marks, as indicate by the config's currency. |
|
26 | + * So if you want to pass in a string that NEEDS to interpret periods as decimal marks, call floatval() on it first. |
|
27 | + * Returns a float |
|
28 | + * |
|
29 | + * @param type $value_inputted_for_field_on_model_object |
|
30 | + * @return float |
|
31 | + */ |
|
32 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
33 | + { |
|
34 | 34 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
35 | - // remove whitespaces and thousands separators |
|
36 | - if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | - $value_inputted_for_field_on_model_object = str_replace( |
|
38 | - array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | - "", |
|
40 | - $value_inputted_for_field_on_model_object |
|
41 | - ); |
|
35 | + // remove whitespaces and thousands separators |
|
36 | + if (is_string($value_inputted_for_field_on_model_object)) { |
|
37 | + $value_inputted_for_field_on_model_object = str_replace( |
|
38 | + array(" ", EE_Config::instance()->currency->thsnds), |
|
39 | + "", |
|
40 | + $value_inputted_for_field_on_model_object |
|
41 | + ); |
|
42 | 42 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
43 | 43 | // normalize it so periods are decimal marks (we don't care where you're from: we're talking PHP now) |
44 | - $value_inputted_for_field_on_model_object = str_replace( |
|
45 | - EE_Config::instance()->currency->dec_mrk, |
|
46 | - ".", |
|
47 | - $value_inputted_for_field_on_model_object |
|
48 | - ); |
|
44 | + $value_inputted_for_field_on_model_object = str_replace( |
|
45 | + EE_Config::instance()->currency->dec_mrk, |
|
46 | + ".", |
|
47 | + $value_inputted_for_field_on_model_object |
|
48 | + ); |
|
49 | 49 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
50 | 50 | // double-check there's absolutely nothing left on this string besides numbers |
51 | - $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | - "/[^0-9,.]/", |
|
53 | - "", |
|
54 | - $value_inputted_for_field_on_model_object |
|
55 | - ); |
|
56 | - } |
|
51 | + $value_inputted_for_field_on_model_object = preg_replace( |
|
52 | + "/[^0-9,.]/", |
|
53 | + "", |
|
54 | + $value_inputted_for_field_on_model_object |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | // echo __LINE__."$value_inputted_for_field_on_model_object<br>"; |
58 | - return floatval($value_inputted_for_field_on_model_object); |
|
59 | - } |
|
58 | + return floatval($value_inputted_for_field_on_model_object); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | - * |
|
64 | - * @param float $value_on_field_to_be_outputted |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | - { |
|
69 | - $EE = EE_Registry::instance(); |
|
70 | - return number_format( |
|
71 | - $value_on_field_to_be_outputted, |
|
72 | - $EE->CFG->currency->dec_plc, |
|
73 | - $EE->CFG->currency->dec_mrk, |
|
74 | - $EE->CFG->currency->thsnds |
|
75 | - ); |
|
76 | - } |
|
61 | + /** |
|
62 | + * Returns the number formatted according to local custom (set by the country of the blog). |
|
63 | + * |
|
64 | + * @param float $value_on_field_to_be_outputted |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
68 | + { |
|
69 | + $EE = EE_Registry::instance(); |
|
70 | + return number_format( |
|
71 | + $value_on_field_to_be_outputted, |
|
72 | + $EE->CFG->currency->dec_plc, |
|
73 | + $EE->CFG->currency->dec_mrk, |
|
74 | + $EE->CFG->currency->thsnds |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | - { |
|
78 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
79 | + { |
|
80 | 80 | // echo "prepare for set from db of ";d($value_found_in_db_for_model_object); |
81 | - return floatval($value_found_in_db_for_model_object); |
|
82 | - } |
|
81 | + return floatval($value_found_in_db_for_model_object); |
|
82 | + } |
|
83 | 83 | } |
@@ -7,49 +7,49 @@ |
||
7 | 7 | abstract class EE_Text_Field_Base extends EE_Model_Field_Base |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Gets the value in the format expected when being set. |
|
12 | - * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | - * @param mixed $value_of_field_on_model_object |
|
14 | - * @return mixed|string |
|
15 | - */ |
|
16 | - public function prepare_for_get($value_of_field_on_model_object) |
|
17 | - { |
|
18 | - return $value_of_field_on_model_object; |
|
19 | - } |
|
10 | + /** |
|
11 | + * Gets the value in the format expected when being set. |
|
12 | + * For display on the front-end, usually you would use prepare_for_pretty_echoing() instead. |
|
13 | + * @param mixed $value_of_field_on_model_object |
|
14 | + * @return mixed|string |
|
15 | + */ |
|
16 | + public function prepare_for_get($value_of_field_on_model_object) |
|
17 | + { |
|
18 | + return $value_of_field_on_model_object; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | - * |
|
24 | - * @param string $value_on_field_to_be_outputted |
|
25 | - * @param string $schema |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | - { |
|
30 | - if ($schema === 'form_input') { |
|
31 | - $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | - $value_on_field_to_be_outputted, |
|
33 | - ENT_QUOTES, |
|
34 | - 'UTF-8' |
|
35 | - ); |
|
36 | - } |
|
37 | - return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | - } |
|
21 | + /** |
|
22 | + * Accepts schema of 'form_input' which formats the string for echoing in form input's value. |
|
23 | + * |
|
24 | + * @param string $value_on_field_to_be_outputted |
|
25 | + * @param string $schema |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) |
|
29 | + { |
|
30 | + if ($schema === 'form_input') { |
|
31 | + $value_on_field_to_be_outputted = (string) htmlentities( |
|
32 | + $value_on_field_to_be_outputted, |
|
33 | + ENT_QUOTES, |
|
34 | + 'UTF-8' |
|
35 | + ); |
|
36 | + } |
|
37 | + return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | - * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | - * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | - * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | - * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | - * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | - * |
|
48 | - * @param string $value_inputted_for_field_on_model_object |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | - { |
|
53 | - return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | - } |
|
40 | + /** |
|
41 | + * Data received from the user should be exactly as they hope to save it in the DB, with the exception that |
|
42 | + * quotes need to have slashes added to it. This method takes care of removing the slashes added by WP |
|
43 | + * in magic-quotes fashion. We used to call html_entity_decode on the value here, |
|
44 | + * because we called htmlentities when in EE_Text_Field_Base::prepare_for_pretty_echoing, but that's not necessary |
|
45 | + * because web browsers always decode HTML entities in element attributes, like a form element's value attribute. |
|
46 | + * So if we do it again here, we'll be removing HTML entities the user intended to have.) |
|
47 | + * |
|
48 | + * @param string $value_inputted_for_field_on_model_object |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
52 | + { |
|
53 | + return stripslashes(parent::prepare_for_set($value_inputted_for_field_on_model_object)); |
|
54 | + } |
|
55 | 55 | } |
@@ -2,15 +2,15 @@ |
||
2 | 2 | |
3 | 3 | class EE_Slug_Field extends EE_Text_Field_Base |
4 | 4 | { |
5 | - /** |
|
6 | - * ensures string is usable in URLs |
|
7 | - * |
|
8 | - * @param string $value_inputted_for_field_on_model_object |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | - { |
|
13 | - // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | - return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | - } |
|
5 | + /** |
|
6 | + * ensures string is usable in URLs |
|
7 | + * |
|
8 | + * @param string $value_inputted_for_field_on_model_object |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
12 | + { |
|
13 | + // reminder: function prepares for use in URLs, not making human-readable. |
|
14 | + return sanitize_title($value_inputted_for_field_on_model_object); |
|
15 | + } |
|
16 | 16 | } |
@@ -3,27 +3,27 @@ |
||
3 | 3 | class EE_Primary_Key_Int_Field extends EE_Primary_Key_Field_Base |
4 | 4 | { |
5 | 5 | |
6 | - public function __construct($table_column, $nicename) |
|
7 | - { |
|
8 | - parent::__construct($table_column, $nicename, 0); |
|
9 | - $this->setSchemaType('integer'); |
|
10 | - } |
|
6 | + public function __construct($table_column, $nicename) |
|
7 | + { |
|
8 | + parent::__construct($table_column, $nicename, 0); |
|
9 | + $this->setSchemaType('integer'); |
|
10 | + } |
|
11 | 11 | |
12 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | - { |
|
14 | - if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | - $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | - } |
|
17 | - return absint($value_inputted_for_field_on_model_object); |
|
18 | - } |
|
12 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
13 | + { |
|
14 | + if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) { |
|
15 | + $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID(); |
|
16 | + } |
|
17 | + return absint($value_inputted_for_field_on_model_object); |
|
18 | + } |
|
19 | 19 | |
20 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | - { |
|
22 | - return intval($value_found_in_db_for_model_object); |
|
23 | - } |
|
20 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
21 | + { |
|
22 | + return intval($value_found_in_db_for_model_object); |
|
23 | + } |
|
24 | 24 | |
25 | - public function is_auto_increment() |
|
26 | - { |
|
27 | - return true; |
|
28 | - } |
|
25 | + public function is_auto_increment() |
|
26 | + { |
|
27 | + return true; |
|
28 | + } |
|
29 | 29 | } |