@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage |
12 | 12 | * @author Mike Nelson |
13 | 13 | */ |
14 | -class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base{ |
|
14 | +class EE_Select_Ajax_Model_Rest_Input extends EE_Form_Input_With_Options_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @var string $_model_name |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * And the arguments accepted by EE_Form_Input_With_Options_Base |
51 | 51 | * @throws \EE_Error |
52 | 52 | */ |
53 | - public function __construct( $input_settings = array() ) { |
|
53 | + public function __construct($input_settings = array()) { |
|
54 | 54 | //needed input settings: |
55 | 55 | //select2_args |
56 | 56 | $this->_model_name = EEH_Array::is_set( |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | // make sure limit and caps are always set |
68 | 68 | $query_params = array_merge( |
69 | - array( 'limit' => 10, 'caps' => EEM_Base::caps_read_admin ), |
|
69 | + array('limit' => 10, 'caps' => EEM_Base::caps_read_admin), |
|
70 | 70 | $query_params |
71 | 71 | ); |
72 | 72 | $this->_value_field_name = EEH_Array::is_set( |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->_display_field_name = EEH_Array::is_set( |
78 | 78 | $input_settings, |
79 | 79 | 'display_field_name', |
80 | - $model->get_a_field_of_type( 'EE_Text_Field_Base' )->get_name() |
|
80 | + $model->get_a_field_of_type('EE_Text_Field_Base')->get_name() |
|
81 | 81 | ); |
82 | 82 | $this->_extra_select_columns = EEH_Array::is_set( |
83 | 83 | $input_settings, |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | ); |
95 | 95 | //get resource endpoint |
96 | 96 | $rest_controller = new EventEspresso\core\libraries\rest_api\controllers\model\Read(); |
97 | - $rest_controller->set_requested_version( EED_Core_Rest_Api::latest_rest_api_version() ); |
|
97 | + $rest_controller->set_requested_version(EED_Core_Rest_Api::latest_rest_api_version()); |
|
98 | 98 | $default_select2_args = array( |
99 | 99 | 'ajax' => array( |
100 | 100 | 'url' => $rest_controller->get_versioned_link_to( |
101 | - EEH_Inflector::pluralize_and_lower( $this->_model_name ) |
|
101 | + EEH_Inflector::pluralize_and_lower($this->_model_name) |
|
102 | 102 | ), |
103 | 103 | 'dataType' => 'json', |
104 | 104 | 'delay' => '250', |
105 | 105 | 'data_interface' => 'EE_Select2_REST_API_Interface', |
106 | 106 | 'data_interface_args' => array( |
107 | - 'default_query_params' => (object)Model_Data_Translator::prepare_query_params_for_rest_api( |
|
107 | + 'default_query_params' => (object) Model_Data_Translator::prepare_query_params_for_rest_api( |
|
108 | 108 | $query_params, |
109 | 109 | $model |
110 | 110 | ), |
111 | 111 | 'display_field' => $this->_display_field_name, |
112 | 112 | 'value_field' => $this->_value_field_name, |
113 | - 'nonce' => wp_create_nonce( 'wp_rest' ), |
|
114 | - 'locale' => str_replace( '_', '-', strtolower( get_locale() ) ) |
|
113 | + 'nonce' => wp_create_nonce('wp_rest'), |
|
114 | + 'locale' => str_replace('_', '-', strtolower(get_locale())) |
|
115 | 115 | ), |
116 | 116 | ), |
117 | 117 | 'cache' => true, |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | ); |
120 | 120 | $select2_args = array_replace_recursive( |
121 | 121 | $default_select2_args, |
122 | - (array)EEH_Array::is_set( $input_settings, 'select2_args', array() ) |
|
122 | + (array) EEH_Array::is_set($input_settings, 'select2_args', array()) |
|
123 | 123 | ); |
124 | - $this->set_display_strategy( new EE_Select2_Display_Strategy( $select2_args ) ); |
|
125 | - parent::__construct( array(), $input_settings ); |
|
124 | + $this->set_display_strategy(new EE_Select2_Display_Strategy($select2_args)); |
|
125 | + parent::__construct(array(), $input_settings); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -140,34 +140,34 @@ discard block |
||
140 | 140 | * @return void |
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | - public function _set_raw_value( $value ) { |
|
144 | - $values_for_options = (array)$value; |
|
145 | - $value_field = $this->_get_model()->field_settings_for( $this->_value_field_name ); |
|
146 | - $display_field = $this->_get_model()->field_settings_for( $this->_display_field_name ); |
|
147 | - $this->_extra_select_columns[] = $value_field->get_qualified_column() . ' AS ' . $this->_value_field_name; |
|
148 | - $this->_extra_select_columns[] = $display_field->get_qualified_column() . ' AS ' . $this->_display_field_name; |
|
143 | + public function _set_raw_value($value) { |
|
144 | + $values_for_options = (array) $value; |
|
145 | + $value_field = $this->_get_model()->field_settings_for($this->_value_field_name); |
|
146 | + $display_field = $this->_get_model()->field_settings_for($this->_display_field_name); |
|
147 | + $this->_extra_select_columns[] = $value_field->get_qualified_column().' AS '.$this->_value_field_name; |
|
148 | + $this->_extra_select_columns[] = $display_field->get_qualified_column().' AS '.$this->_display_field_name; |
|
149 | 149 | $display_values = $this->_get_model()->get_all_wpdb_results( |
150 | 150 | array( |
151 | 151 | array( |
152 | - $this->_value_field_name => array( 'IN', $values_for_options ) |
|
152 | + $this->_value_field_name => array('IN', $values_for_options) |
|
153 | 153 | ) |
154 | 154 | ), |
155 | 155 | ARRAY_A, |
156 | - implode( ',', $this->_extra_select_columns ) |
|
156 | + implode(',', $this->_extra_select_columns) |
|
157 | 157 | ); |
158 | 158 | $select_options = array(); |
159 | - if( is_array( $select_options ) ) { |
|
160 | - foreach( $display_values as $db_rows ) { |
|
161 | - $db_rows = (array)$db_rows; |
|
162 | - $select_options[ $db_rows[ $this->_value_field_name ] ] = apply_filters( |
|
159 | + if (is_array($select_options)) { |
|
160 | + foreach ($display_values as $db_rows) { |
|
161 | + $db_rows = (array) $db_rows; |
|
162 | + $select_options[$db_rows[$this->_value_field_name]] = apply_filters( |
|
163 | 163 | 'FHEE__EE_Select_Ajax_Model_Rest_Input___set_raw_value__select_option_value', |
164 | - $db_rows[ $this->_display_field_name ], |
|
164 | + $db_rows[$this->_display_field_name], |
|
165 | 165 | $db_rows |
166 | 166 | ); |
167 | 167 | } |
168 | 168 | } |
169 | - $this->set_select_options( $select_options ); |
|
170 | - parent::_set_raw_value( $value ); |
|
169 | + $this->set_select_options($select_options); |
|
170 | + parent::_set_raw_value($value); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @throws EE_Error |
177 | 177 | */ |
178 | 178 | protected function _get_model() { |
179 | - if( ! EE_Registry::instance()->is_model_name( $this->_model_name ) ) { |
|
179 | + if ( ! EE_Registry::instance()->is_model_name($this->_model_name)) { |
|
180 | 180 | throw new EE_Error( |
181 | 181 | sprintf( |
182 | 182 | __( |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ) |
188 | 188 | ); |
189 | 189 | } else { |
190 | - return EE_Registry::instance()->load_model( $this->_model_name ); |
|
190 | + return EE_Registry::instance()->load_model($this->_model_name); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 |
@@ -66,23 +66,23 @@ discard block |
||
66 | 66 | * @param string $min_core_version |
67 | 67 | * @return string always like '4.3.0.rc.000' |
68 | 68 | */ |
69 | - protected static function _effective_version( $min_core_version ) { |
|
69 | + protected static function _effective_version($min_core_version) { |
|
70 | 70 | // versions: 4 . 3 . 1 . p . 123 |
71 | 71 | // offsets: 0 . 1 . 2 . 3 . 4 |
72 | - $version_parts = explode( '.', $min_core_version ); |
|
72 | + $version_parts = explode('.', $min_core_version); |
|
73 | 73 | //check they specified the micro version (after 2nd period) |
74 | - if( ! isset( $version_parts[ 2 ] ) ) { |
|
75 | - $version_parts[ 2] = '0'; |
|
74 | + if ( ! isset($version_parts[2])) { |
|
75 | + $version_parts[2] = '0'; |
|
76 | 76 | } |
77 | 77 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
78 | 78 | //soon we can assume that's 'rc', but this current version is 'alpha' |
79 | - if( ! isset( $version_parts[ 3 ] ) ) { |
|
80 | - $version_parts[ 3 ] = 'dev'; |
|
79 | + if ( ! isset($version_parts[3])) { |
|
80 | + $version_parts[3] = 'dev'; |
|
81 | 81 | } |
82 | - if( ! isset( $version_parts[ 4 ] ) ) { |
|
83 | - $version_parts[ 4 ] = '000'; |
|
82 | + if ( ! isset($version_parts[4])) { |
|
83 | + $version_parts[4] = '000'; |
|
84 | 84 | } |
85 | - return implode( '.', $version_parts ); |
|
85 | + return implode('.', $version_parts); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $actual_core_version the actual core version, optional |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public static function _meets_min_core_version_requirement( $min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION ) { |
|
96 | - return version_compare( self::_effective_version( $actual_core_version ), self::_effective_version( $min_core_version ), '>=' ); |
|
95 | + public static function _meets_min_core_version_requirement($min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION) { |
|
96 | + return version_compare(self::_effective_version($actual_core_version), self::_effective_version($min_core_version), '>='); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -155,112 +155,112 @@ discard block |
||
155 | 155 | * @throws EE_Error |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public static function register( $addon_name = '', $setup_args = array() ) { |
|
158 | + public static function register($addon_name = '', $setup_args = array()) { |
|
159 | 159 | // required fields MUST be present, so let's make sure they are. |
160 | - if ( empty( $addon_name ) || ! is_array( $setup_args )) { |
|
161 | - throw new EE_Error( __( 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso' )); |
|
160 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
161 | + throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso')); |
|
162 | 162 | } |
163 | - if ( ! isset($setup_args[ 'main_file_path' ]) || empty( $setup_args[ 'main_file_path' ] ) ){ |
|
164 | - throw new EE_Error( sprintf( __( 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso' ), implode(",", array_keys( $setup_args ) ) ) ); |
|
163 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
164 | + throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args)))); |
|
165 | 165 | } |
166 | 166 | // check that addon has not already been registered with that name |
167 | - if ( isset( self::$_settings[ $addon_name ] ) && ! did_action( 'activate_plugin' ) ) { |
|
168 | - throw new EE_Error( sprintf( __( 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso' ), $addon_name )); |
|
167 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
168 | + throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | 172 | // no class name for addon? |
173 | - if ( empty( $setup_args['class_name'] )) { |
|
173 | + if (empty($setup_args['class_name'])) { |
|
174 | 174 | // generate one by first separating name with spaces |
175 | - $class_name = str_replace( array( '-', '_' ), ' ', trim( $addon_name )); |
|
175 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
176 | 176 | //capitalize, then replace spaces with underscores |
177 | - $class_name = str_replace( ' ', '_', ucwords( $class_name )); |
|
177 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
178 | 178 | } else { |
179 | 179 | $class_name = $setup_args['class_name']; |
180 | 180 | } |
181 | - $class_name = strpos( $class_name, 'EE_' ) === 0 ? $class_name : 'EE_' . $class_name; |
|
181 | + $class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
182 | 182 | //setup $_settings array from incoming values. |
183 | 183 | $addon_settings = array( |
184 | 184 | // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
185 | 185 | 'class_name' => $class_name, |
186 | 186 | // the addon slug for use in URLs, etc |
187 | - 'plugin_slug' => isset( $setup_args['plugin_slug'] ) ? (string)$setup_args['plugin_slug'] : '', |
|
187 | + 'plugin_slug' => isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '', |
|
188 | 188 | // page slug to be used when generating the "Settings" link on the WP plugin page |
189 | - 'plugin_action_slug' => isset( $setup_args[ 'plugin_action_slug' ] ) ? (string)$setup_args[ 'plugin_action_slug' ] : '', |
|
189 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '', |
|
190 | 190 | // the "software" version for the addon |
191 | - 'version' => isset( $setup_args['version'] ) ? (string)$setup_args['version'] : '', |
|
191 | + 'version' => isset($setup_args['version']) ? (string) $setup_args['version'] : '', |
|
192 | 192 | // the minimum version of EE Core that the addon will work with |
193 | - 'min_core_version' => isset( $setup_args['min_core_version'] ) ? (string)$setup_args['min_core_version'] : '', |
|
193 | + 'min_core_version' => isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '', |
|
194 | 194 | // the minimum version of WordPress that the addon will work with |
195 | - 'min_wp_version' => isset( $setup_args['min_wp_version'] ) ? (string)$setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
195 | + 'min_wp_version' => isset($setup_args['min_wp_version']) ? (string) $setup_args['min_wp_version'] : EE_MIN_WP_VER_REQUIRED, |
|
196 | 196 | // full server path to main file (file loaded directly by WP) |
197 | - 'main_file_path' => isset( $setup_args['main_file_path'] ) ? (string)$setup_args['main_file_path'] : '', |
|
197 | + 'main_file_path' => isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '', |
|
198 | 198 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
199 | - 'admin_path' => isset( $setup_args['admin_path'] ) ? (string)$setup_args['admin_path'] : '', |
|
199 | + 'admin_path' => isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '', |
|
200 | 200 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
201 | - 'admin_callback' => isset( $setup_args['admin_callback'] ) ? (string)$setup_args['admin_callback'] : '', |
|
201 | + 'admin_callback' => isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '', |
|
202 | 202 | // the section name for this addon's configuration settings section (defaults to "addons") |
203 | - 'config_section' => isset( $setup_args['config_section'] ) ? (string)$setup_args['config_section'] : 'addons', |
|
203 | + 'config_section' => isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons', |
|
204 | 204 | // the class name for this addon's configuration settings object |
205 | - 'config_class' => isset( $setup_args['config_class'] ) ? (string)$setup_args['config_class'] : '', |
|
205 | + 'config_class' => isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '', |
|
206 | 206 | //the name given to the config for this addons' configuration settings object (optional) |
207 | - 'config_name' => isset( $setup_args['config_name'] ) ? (string) $setup_args['config_name']: '', |
|
207 | + 'config_name' => isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '', |
|
208 | 208 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
209 | - 'autoloader_paths' => isset( $setup_args['autoloader_paths'] ) ? (array)$setup_args['autoloader_paths'] : array(), |
|
209 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(), |
|
210 | 210 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
211 | - 'autoloader_folders' => isset( $setup_args['autoloader_folders'] ) ? (array)$setup_args['autoloader_folders'] : array(), |
|
211 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(), |
|
212 | 212 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
213 | - 'dms_paths' => isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array(), |
|
213 | + 'dms_paths' => isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(), |
|
214 | 214 | // array of full server paths to any EED_Modules used by the addon |
215 | - 'module_paths' => isset( $setup_args['module_paths'] ) ? (array)$setup_args['module_paths'] : array(), |
|
215 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(), |
|
216 | 216 | // array of full server paths to any EES_Shortcodes used by the addon |
217 | - 'shortcode_paths' => isset( $setup_args['shortcode_paths'] ) ? (array)$setup_args['shortcode_paths'] : array(), |
|
217 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(), |
|
218 | 218 | // array of full server paths to any WP_Widgets used by the addon |
219 | - 'widget_paths' => isset( $setup_args['widget_paths'] ) ? (array)$setup_args['widget_paths'] : array(), |
|
219 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(), |
|
220 | 220 | // array of PUE options used by the addon |
221 | - 'pue_options' => isset( $setup_args['pue_options'] ) ? (array)$setup_args['pue_options'] : array(), |
|
222 | - 'message_types' => isset( $setup_args['message_types'] ) ? (array) $setup_args['message_types'] : array(), |
|
223 | - 'capabilities' => isset( $setup_args['capabilities'] ) ? (array) $setup_args['capabilities'] : array(), |
|
224 | - 'capability_maps' => isset( $setup_args['capability_maps'] ) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | - 'model_paths' => isset( $setup_args['model_paths'] ) ? (array) $setup_args['model_paths'] : array(), |
|
226 | - 'class_paths' => isset( $setup_args['class_paths'] ) ? (array) $setup_args['class_paths'] : array(), |
|
227 | - 'model_extension_paths' => isset( $setup_args['model_extension_paths'] ) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | - 'class_extension_paths' => isset( $setup_args['class_extension_paths'] ) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | - 'custom_post_types' => isset( $setup_args['custom_post_types'] ) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | - 'custom_taxonomies' => isset( $setup_args['custom_taxonomies'] ) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | - 'payment_method_paths' => isset( $setup_args[ 'payment_method_paths' ] ) ? (array) $setup_args[ 'payment_method_paths' ] : array(), |
|
232 | - 'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array(), |
|
221 | + 'pue_options' => isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(), |
|
222 | + 'message_types' => isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(), |
|
223 | + 'capabilities' => isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(), |
|
224 | + 'capability_maps' => isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(), |
|
225 | + 'model_paths' => isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(), |
|
226 | + 'class_paths' => isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(), |
|
227 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(), |
|
228 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(), |
|
229 | + 'custom_post_types' => isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(), |
|
230 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(), |
|
231 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(), |
|
232 | + 'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(), |
|
233 | 233 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page that can be used for adding upgrading/marketing info |
234 | - 'plugins_page_row' => isset( $setup_args['plugins_page_row'] ) ? $setup_args['plugins_page_row'] : '', |
|
234 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '', |
|
235 | 235 | ); |
236 | 236 | |
237 | 237 | // if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page |
238 | - $addon_settings[ 'plugin_action_slug' ] = empty( $addon_settings[ 'plugin_action_slug' ] ) && ! empty( $addon_settings[ 'admin_path' ] ) ? $addon_settings[ 'plugin_slug' ] : $addon_settings[ 'plugin_action_slug' ]; |
|
238 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && ! empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug']; |
|
239 | 239 | // full server path to main file (file loaded directly by WP) |
240 | - $addon_settings['plugin_basename'] = plugin_basename( $addon_settings[ 'main_file_path' ] ); |
|
240 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
241 | 241 | |
242 | 242 | global $wp_version; |
243 | 243 | //check whether this addon version is compatible with EE core |
244 | - if ( isset( EE_Register_Addon::$_incompatible_addons[ $addon_name ] ) && |
|
245 | - ! self::_meets_min_core_version_requirement( EE_Register_Addon::$_incompatible_addons[ $addon_name ], $addon_settings[ 'version' ] ) ) { |
|
244 | + if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) && |
|
245 | + ! self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) { |
|
246 | 246 | $incompatibility_message = sprintf( |
247 | - __( 'The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso' ), |
|
247 | + __('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'), |
|
248 | 248 | $addon_name, |
249 | 249 | '<br />', |
250 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ] |
|
250 | + EE_Register_Addon::$_incompatible_addons[$addon_name] |
|
251 | 251 | ); |
252 | - } else if ( ! self::_meets_min_core_version_requirement( $addon_settings[ 'min_core_version' ], espresso_version() ) ) { |
|
252 | + } else if ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())) { |
|
253 | 253 | $incompatibility_message = sprintf( |
254 | 254 | __( |
255 | 255 | 'The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', |
256 | 256 | 'event_espresso' |
257 | 257 | ), |
258 | 258 | $addon_name, |
259 | - self::_effective_version( $addon_settings[ 'min_core_version' ] ), |
|
260 | - self::_effective_version( espresso_version() ), |
|
259 | + self::_effective_version($addon_settings['min_core_version']), |
|
260 | + self::_effective_version(espresso_version()), |
|
261 | 261 | '<br />' |
262 | 262 | ); |
263 | - } else if (version_compare( $wp_version, $addon_settings['min_wp_version'], '<' )) { |
|
263 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
264 | 264 | $incompatibility_message = sprintf( |
265 | 265 | __( |
266 | 266 | 'The Event Espresso "%1$s" addon could not be activated because it requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
@@ -269,137 +269,137 @@ discard block |
||
269 | 269 | $addon_name, |
270 | 270 | $addon_settings['min_wp_version'], |
271 | 271 | '<br />' |
272 | - );; |
|
272 | + ); ; |
|
273 | 273 | } else { |
274 | 274 | $incompatibility_message = ''; |
275 | 275 | } |
276 | - if ( ! empty( $incompatibility_message ) ) { |
|
276 | + if ( ! empty($incompatibility_message)) { |
|
277 | 277 | //remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the |
278 | 278 | //plugin activated fine when it didn't |
279 | - if( isset( $_GET[ 'activate' ]) ) { |
|
280 | - unset( $_GET[ 'activate' ] ); |
|
279 | + if (isset($_GET['activate'])) { |
|
280 | + unset($_GET['activate']); |
|
281 | 281 | } |
282 | - if( isset( $_REQUEST[ 'activate' ] ) ){ |
|
283 | - unset( $_REQUEST[ 'activate' ] ); |
|
282 | + if (isset($_REQUEST['activate'])) { |
|
283 | + unset($_REQUEST['activate']); |
|
284 | 284 | } |
285 | 285 | //and show an error message indicating the plugin didn't activate properly |
286 | - EE_Error::add_error( $incompatibility_message, __FILE__, __FUNCTION__, __LINE__ ); |
|
287 | - if ( current_user_can( 'activate_plugins' )) { |
|
288 | - require_once( ABSPATH.'wp-admin/includes/plugin.php' ); |
|
289 | - deactivate_plugins( plugin_basename( $addon_settings[ 'main_file_path' ] ), TRUE ); |
|
286 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
287 | + if (current_user_can('activate_plugins')) { |
|
288 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
289 | + deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE); |
|
290 | 290 | } |
291 | 291 | return; |
292 | 292 | } |
293 | 293 | //this is an activation request |
294 | - if( did_action( 'activate_plugin' ) ){ |
|
294 | + if (did_action('activate_plugin')) { |
|
295 | 295 | //to find if THIS is the addon that was activated, |
296 | 296 | //just check if we have already registered it or not |
297 | 297 | //(as the newly-activated addon wasn't around the first time addons were registered) |
298 | - if( ! isset( self::$_settings[ $addon_name ] ) ){ |
|
299 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
298 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
299 | + self::$_settings[$addon_name] = $addon_settings; |
|
300 | 300 | $addon = self::_load_and_init_addon_class($addon_name); |
301 | 301 | $addon->set_activation_indicator_option(); |
302 | 302 | //dont bother setting up the rest of the addon. |
303 | 303 | //we know it was just activated and the request will end soon |
304 | 304 | } |
305 | 305 | return; |
306 | - }else{ |
|
306 | + } else { |
|
307 | 307 | // make sure this was called in the right place! |
308 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) { |
|
308 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
309 | 309 | EE_Error::doing_it_wrong( |
310 | 310 | __METHOD__, |
311 | 311 | sprintf( |
312 | - __( 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.','event_espresso'), |
|
312 | + __('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'), |
|
313 | 313 | $addon_name |
314 | 314 | ), |
315 | 315 | '4.3.0' |
316 | 316 | ); |
317 | 317 | } |
318 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
318 | + self::$_settings[$addon_name] = $addon_settings; |
|
319 | 319 | } |
320 | 320 | // we need cars |
321 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_paths'] )) { |
|
321 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
322 | 322 | // setup autoloader for single file |
323 | - EEH_Autoloader::instance()->register_autoloader( self::$_settings[ $addon_name ]['autoloader_paths'] ); |
|
323 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
324 | 324 | } |
325 | 325 | // setup autoloaders for folders |
326 | - if ( ! empty( self::$_settings[ $addon_name ]['autoloader_folders'] )) { |
|
327 | - foreach ( self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder ) { |
|
328 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $autoloader_folder ); |
|
326 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
327 | + foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
328 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | // register new models |
332 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
333 | - EE_Register_Model::register( $addon_name, array( 'model_paths' => self::$_settings[ $addon_name ]['model_paths'] , 'class_paths' => self::$_settings[ $addon_name ]['class_paths'])); |
|
332 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
333 | + EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths'])); |
|
334 | 334 | } |
335 | 335 | // register model extensions |
336 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
337 | - EE_Register_Model_Extensions::register( $addon_name, array( 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'] , 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'])); |
|
336 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
337 | + EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'])); |
|
338 | 338 | } |
339 | 339 | // setup DMS |
340 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
341 | - EE_Register_Data_Migration_Scripts::register( $addon_name, array( 'dms_paths' => self::$_settings[ $addon_name ]['dms_paths'] )); |
|
340 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
341 | + EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])); |
|
342 | 342 | } |
343 | 343 | // if config_class is present let's register config. |
344 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
344 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
345 | 345 | EE_Register_Config::register( |
346 | - self::$_settings[ $addon_name ]['config_class'], |
|
346 | + self::$_settings[$addon_name]['config_class'], |
|
347 | 347 | array( |
348 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
349 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'] |
|
348 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
349 | + 'config_name' => self::$_settings[$addon_name]['config_name'] |
|
350 | 350 | ) |
351 | 351 | ); |
352 | 352 | } |
353 | 353 | // register admin page |
354 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
355 | - EE_Register_Admin_Page::register( $addon_name, array( 'page_path' => self::$_settings[ $addon_name ]['admin_path'] )); |
|
354 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
355 | + EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path'])); |
|
356 | 356 | |
357 | 357 | } |
358 | 358 | // add to list of modules to be registered |
359 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
360 | - EE_Register_Module::register( $addon_name, array( 'module_paths' => self::$_settings[ $addon_name ]['module_paths'] )); |
|
359 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
360 | + EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths'])); |
|
361 | 361 | } |
362 | 362 | // add to list of shortcodes to be registered |
363 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
364 | - EE_Register_Shortcode::register( $addon_name, array( 'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] )); |
|
363 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
364 | + EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])); |
|
365 | 365 | } |
366 | 366 | // add to list of widgets to be registered |
367 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
368 | - EE_Register_Widget::register( $addon_name, array( 'widget_paths' => self::$_settings[ $addon_name ]['widget_paths'] )); |
|
367 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
368 | + EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | //register capability related stuff. |
372 | - if ( ! empty( self::$_settings[ $addon_name ]['capabilities'] ) ) { |
|
373 | - EE_Register_Capabilities::register( $addon_name , array( 'capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'] ) ); |
|
372 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
373 | + EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'])); |
|
374 | 374 | } |
375 | 375 | //any message type to register? |
376 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
377 | - add_action( 'EE_Brewing_Regular___messages_caf', array( 'EE_Register_Addon', 'register_message_types' ) ); |
|
376 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
377 | + add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types')); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | // if plugin update engine is being used for auto-updates (not needed if PUE is not being used) |
381 | - if ( ! empty( $setup_args['pue_options'] )) { |
|
382 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
383 | - 'pue_plugin_slug' => isset( $setup_args['pue_options']['pue_plugin_slug'] ) ? (string)$setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower( $class_name ), |
|
384 | - 'plugin_basename' => isset( $setup_args['pue_options']['plugin_basename'] ) ? (string)$setup_args['pue_options']['plugin_basename'] : plugin_basename( self::$_settings[ $addon_name ]['main_file_path'] ), |
|
385 | - 'checkPeriod' => isset( $setup_args['pue_options']['checkPeriod'] ) ? (string)$setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | - 'use_wp_update' => isset( $setup_args['pue_options']['use_wp_update'] ) ? (string)$setup_args['pue_options']['use_wp_update'] : FALSE |
|
381 | + if ( ! empty($setup_args['pue_options'])) { |
|
382 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
383 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_'.strtolower($class_name), |
|
384 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']), |
|
385 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24', |
|
386 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE |
|
387 | 387 | ); |
388 | - add_action( 'AHEE__EE_System__brew_espresso__after_pue_init', array( 'EE_Register_Addon', 'load_pue_update' )); |
|
388 | + add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update')); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | //any custom post type/ custom capabilities or default terms to register |
392 | - if ( !empty( self::$_settings[$addon_name]['custom_post_types'] ) || !empty( self::$_settings[$addon_name]['custom_taxonomies'] ) ) { |
|
393 | - EE_Register_CPT::register( $addon_name, array( 'cpts' => self::$_settings[$addon_name]['custom_post_types'] , 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'] ) ); |
|
392 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])) { |
|
393 | + EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'])); |
|
394 | 394 | } |
395 | - if( ! empty( self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ){ |
|
396 | - EE_Register_Payment_Method::register($addon_name, array( 'payment_method_paths' => self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ); |
|
395 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
396 | + EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])); |
|
397 | 397 | } |
398 | 398 | // load and instantiate main addon class |
399 | 399 | $addon = self::_load_and_init_addon_class($addon_name); |
400 | 400 | // call any additional admin_callback functions during load_admin_controller hook |
401 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_callback'] )) { |
|
402 | - add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $addon, self::$_settings[ $addon_name ]['admin_callback'] )); |
|
401 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
402 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback'])); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -410,22 +410,22 @@ discard block |
||
410 | 410 | * @param string $addon_name |
411 | 411 | * @return EE_Addon |
412 | 412 | */ |
413 | - private static function _load_and_init_addon_class($addon_name){ |
|
414 | - $addon = EE_Registry::instance()->load_addon( dirname( self::$_settings[ $addon_name ]['main_file_path'] ), self::$_settings[ $addon_name ]['class_name'] ); |
|
415 | - $addon->set_name( $addon_name ); |
|
416 | - $addon->set_plugin_slug( self::$_settings[ $addon_name ][ 'plugin_slug' ] ); |
|
417 | - $addon->set_plugin_basename( self::$_settings[ $addon_name ][ 'plugin_basename' ] ); |
|
418 | - $addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] ); |
|
419 | - $addon->set_plugin_action_slug( self::$_settings[ $addon_name ][ 'plugin_action_slug' ] ); |
|
420 | - $addon->set_plugins_page_row( self::$_settings[ $addon_name ][ 'plugins_page_row' ] ); |
|
421 | - $addon->set_version( self::$_settings[ $addon_name ]['version'] ); |
|
422 | - $addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) ); |
|
423 | - $addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] ); |
|
424 | - $addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] ); |
|
425 | - $addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] ); |
|
413 | + private static function _load_and_init_addon_class($addon_name) { |
|
414 | + $addon = EE_Registry::instance()->load_addon(dirname(self::$_settings[$addon_name]['main_file_path']), self::$_settings[$addon_name]['class_name']); |
|
415 | + $addon->set_name($addon_name); |
|
416 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
417 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
418 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
419 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
420 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
421 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
422 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
423 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
424 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
425 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
426 | 426 | //unfortunately this can't be hooked in upon construction, because we don't have |
427 | 427 | //the plugin mainfile's path upon construction. |
428 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon,'deactivation')); |
|
428 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
429 | 429 | return $addon; |
430 | 430 | } |
431 | 431 | |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public static function load_pue_update() { |
440 | 440 | // load PUE client |
441 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
441 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
442 | 442 | // cycle thru settings |
443 | - foreach ( self::$_settings as $settings ) { |
|
444 | - if ( ! empty( $settings['pue_options'] )) { |
|
443 | + foreach (self::$_settings as $settings) { |
|
444 | + if ( ! empty($settings['pue_options'])) { |
|
445 | 445 | // initiate the class and start the plugin update engine! |
446 | 446 | new PluginUpdateEngineChecker( |
447 | 447 | // host file URL |
448 | 448 | 'https://eventespresso.com', |
449 | 449 | // plugin slug(s) |
450 | 450 | array( |
451 | - 'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ), |
|
452 | - 'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' ) |
|
451 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
452 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr') |
|
453 | 453 | ), |
454 | 454 | // options |
455 | 455 | array( |
@@ -477,9 +477,9 @@ discard block |
||
477 | 477 | * @return void |
478 | 478 | */ |
479 | 479 | public static function register_message_types() { |
480 | - foreach ( self::$_settings as $settings ) { |
|
481 | - foreach( $settings['message_types'] as $message_type => $message_type_settings ) { |
|
482 | - EE_Register_Message_Type::register( $message_type, $message_type_settings ); |
|
480 | + foreach (self::$_settings as $settings) { |
|
481 | + foreach ($settings['message_types'] as $message_type => $message_type_settings) { |
|
482 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | } |
@@ -495,60 +495,60 @@ discard block |
||
495 | 495 | * @throws EE_Error |
496 | 496 | * @return void |
497 | 497 | */ |
498 | - public static function deregister( $addon_name = NULL ) { |
|
499 | - if ( isset( self::$_settings[ $addon_name ] )) { |
|
500 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
501 | - if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) { |
|
498 | + public static function deregister($addon_name = NULL) { |
|
499 | + if (isset(self::$_settings[$addon_name])) { |
|
500 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
501 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
502 | 502 | // setup DMS |
503 | - EE_Register_Data_Migration_Scripts::deregister( $addon_name ); |
|
503 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
504 | 504 | } |
505 | - if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) { |
|
505 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
506 | 506 | // register admin page |
507 | - EE_Register_Admin_Page::deregister( $addon_name ); |
|
507 | + EE_Register_Admin_Page::deregister($addon_name); |
|
508 | 508 | } |
509 | - if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) { |
|
509 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
510 | 510 | // add to list of modules to be registered |
511 | - EE_Register_Module::deregister( $addon_name ); |
|
511 | + EE_Register_Module::deregister($addon_name); |
|
512 | 512 | } |
513 | - if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) { |
|
513 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
514 | 514 | // add to list of shortcodes to be registered |
515 | - EE_Register_Shortcode::deregister( $addon_name ); |
|
515 | + EE_Register_Shortcode::deregister($addon_name); |
|
516 | 516 | } |
517 | - if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) { |
|
517 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
518 | 518 | // if config_class present let's register config. |
519 | - EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class']); |
|
519 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
520 | 520 | } |
521 | - if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) { |
|
521 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
522 | 522 | // add to list of widgets to be registered |
523 | - EE_Register_Widget::deregister( $addon_name ); |
|
523 | + EE_Register_Widget::deregister($addon_name); |
|
524 | 524 | } |
525 | - if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || |
|
526 | - ! empty( self::$_settings[ $addon_name ]['class_paths'] )) { |
|
525 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) || |
|
526 | + ! empty(self::$_settings[$addon_name]['class_paths'])) { |
|
527 | 527 | // add to list of shortcodes to be registered |
528 | - EE_Register_Model::deregister( $addon_name ); |
|
528 | + EE_Register_Model::deregister($addon_name); |
|
529 | 529 | } |
530 | - if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || |
|
531 | - ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) { |
|
530 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || |
|
531 | + ! empty(self::$_settings[$addon_name]['class_extension_paths'])) { |
|
532 | 532 | // add to list of shortcodes to be registered |
533 | - EE_Register_Model_Extensions::deregister( $addon_name ); |
|
533 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
534 | 534 | } |
535 | - if ( !empty( self::$_settings[$addon_name]['message_types'] ) ) { |
|
536 | - foreach( self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings ) { |
|
537 | - EE_Register_Message_Type::deregister( $message_type ); |
|
535 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
536 | + foreach (self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
537 | + EE_Register_Message_Type::deregister($message_type); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | //deregister capabilities for addon |
541 | - if ( ! empty( self::$_settings[$addon_name]['capabilities'] ) || ! empty( self::$_settings[$addon_name]['capability_maps']) ) { |
|
542 | - EE_Register_Capabilities::deregister( $addon_name ); |
|
541 | + if ( ! empty(self::$_settings[$addon_name]['capabilities']) || ! empty(self::$_settings[$addon_name]['capability_maps'])) { |
|
542 | + EE_Register_Capabilities::deregister($addon_name); |
|
543 | 543 | } |
544 | 544 | //deregister custom_post_types for addon |
545 | - if ( ! empty( self::$_settings[$addon_name]['custom_post_types'] ) ) { |
|
546 | - EE_Register_CPT::deregister( $addon_name ); |
|
545 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
546 | + EE_Register_CPT::deregister($addon_name); |
|
547 | 547 | } |
548 | - remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) ); |
|
549 | - remove_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) ); |
|
548 | + remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')); |
|
549 | + remove_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')); |
|
550 | 550 | unset(EE_Registry::instance()->addons->{$class_name}); |
551 | - unset( self::$_settings[ $addon_name ] ); |
|
551 | + unset(self::$_settings[$addon_name]); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param \Transactions_Admin_Page $admin_page |
33 | 33 | */ |
34 | - public function __construct( \Transactions_Admin_Page $admin_page ){ |
|
35 | - parent::__construct( $admin_page ); |
|
34 | + public function __construct(\Transactions_Admin_Page $admin_page) { |
|
35 | + parent::__construct($admin_page); |
|
36 | 36 | $this->_status = $this->_admin_page->get_transaction_status_array(); |
37 | 37 | } |
38 | 38 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | *_setup_data |
43 | 43 | */ |
44 | 44 | protected function _setup_data() { |
45 | - $this->_data = $this->_admin_page->get_transactions( $this->_per_page ); |
|
46 | - $status = ! empty( $this->_req_data['status'] )? $this->_req_data['status'] : 'all'; |
|
47 | - $this->_all_data_count = $this->_admin_page->get_transactions( $this->_per_page, TRUE, $status ); |
|
45 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
46 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
47 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, TRUE, $status); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | 'ajax' => TRUE, |
60 | 60 | 'screen' => $this->_admin_page->get_current_screen()->id |
61 | 61 | ); |
62 | - $ID_column_name = __( 'ID', 'event_espresso' ); |
|
62 | + $ID_column_name = __('ID', 'event_espresso'); |
|
63 | 63 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
64 | - $ID_column_name .= __( 'Transaction Date', 'event_espresso' ); |
|
64 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
65 | 65 | $ID_column_name .= '</span> '; |
66 | 66 | $this->_columns = array( |
67 | 67 | 'TXN_ID' => $ID_column_name, |
68 | - 'TXN_timestamp' => __( 'Transaction Date', 'event_espresso' ), |
|
69 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
70 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
71 | - 'ATT_fname' => __( 'Primary Registrant', 'event_espresso' ), |
|
72 | - 'event_name' => __( 'Event', 'event_espresso' ), |
|
73 | - 'actions' => __( 'Actions', 'event_espresso' ) |
|
68 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
69 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
70 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
71 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
72 | + 'event_name' => __('Event', 'event_espresso'), |
|
73 | + 'actions' => __('Actions', 'event_espresso') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $this->_sortable_columns = array( |
77 | - 'TXN_ID' => array( 'TXN_ID' => FALSE ), |
|
78 | - 'event_name' => array( 'event_name'=> FALSE ), |
|
79 | - 'ATT_fname' => array( 'ATT_fname'=> FALSE ), |
|
80 | - 'TXN_timestamp' => array( 'TXN_timestamp'=> TRUE ) //true means its already sorted |
|
77 | + 'TXN_ID' => array('TXN_ID' => FALSE), |
|
78 | + 'event_name' => array('event_name'=> FALSE), |
|
79 | + 'ATT_fname' => array('ATT_fname'=> FALSE), |
|
80 | + 'TXN_timestamp' => array('TXN_timestamp'=> TRUE) //true means its already sorted |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | $this->_primary_column = 'TXN_ID'; |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return string |
96 | 96 | * @throws \EE_Error |
97 | 97 | */ |
98 | - protected function _get_row_class( $item ) { |
|
99 | - $class = parent::_get_row_class( $item ); |
|
98 | + protected function _get_row_class($item) { |
|
99 | + $class = parent::_get_row_class($item); |
|
100 | 100 | //add status class |
101 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
102 | - if ( $this->_has_checkbox_column ) { |
|
101 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
102 | + if ($this->_has_checkbox_column) { |
|
103 | 103 | $class .= ' has-checkbox-column'; |
104 | 104 | } |
105 | 105 | return $class; |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | protected function _get_table_filters() { |
118 | 118 | $filters = array(); |
119 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
120 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y', current_time('timestamp') ); |
|
119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
120 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', current_time('timestamp')); |
|
121 | 121 | ob_start(); |
122 | 122 | ?> |
123 | 123 | <label for="txn-filter-start-date">Display Transactions from </label> |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | *_add_view_counts |
137 | 137 | */ |
138 | 138 | protected function _add_view_counts() { |
139 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'all' ); |
|
140 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'abandoned' ); |
|
141 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions( $this->_per_page, TRUE, 'failed' ); |
|
139 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'all'); |
|
140 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'abandoned'); |
|
141 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, TRUE, 'failed'); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @return string |
151 | 151 | * @throws \EE_Error |
152 | 152 | */ |
153 | - public function column_TXN_ID( EE_Transaction $item ){ |
|
154 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
155 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__( 'Go to Transaction Details', 'event_espresso' ) . '">' . $item->ID() . '</a>'; |
|
153 | + public function column_TXN_ID(EE_Transaction $item) { |
|
154 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
155 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'.$item->ID().'</a>'; |
|
156 | 156 | |
157 | 157 | //txn timestamp |
158 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp( $item ) . '</span>'; |
|
158 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
159 | 159 | return $content; |
160 | 160 | } |
161 | 161 | |
@@ -166,18 +166,18 @@ discard block |
||
166 | 166 | * @return mixed|string|void |
167 | 167 | * @throws \EE_Error |
168 | 168 | */ |
169 | - protected function _get_txn_timestamp( EE_Transaction $item ) { |
|
169 | + protected function _get_txn_timestamp(EE_Transaction $item) { |
|
170 | 170 | //txn timestamp |
171 | 171 | // is TXN less than 2 hours old ? |
172 | 172 | if ( |
173 | - ( $item->failed() || $item->is_abandoned() ) |
|
173 | + ($item->failed() || $item->is_abandoned()) |
|
174 | 174 | && ( |
175 | - ( time() - EE_Registry::instance()->SSN->lifespan() ) < $item->datetime( false, true ) |
|
175 | + (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
176 | 176 | ) |
177 | 177 | ) { |
178 | - $timestamp = __( 'TXN in progress...', 'event_espresso' ); |
|
178 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
179 | 179 | } else { |
180 | - $timestamp = $item->get_i18n_datetime( 'TXN_timestamp' ); |
|
180 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
181 | 181 | } |
182 | 182 | return $timestamp; |
183 | 183 | } |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @return string |
192 | 192 | * @throws \EE_Error |
193 | 193 | */ |
194 | - public function column_cb($item ){ |
|
195 | - return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
194 | + public function column_cb($item) { |
|
195 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], $item->ID()); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | * @return string |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public function column_TXN_timestamp( EE_Transaction $item ){ |
|
208 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
209 | - $txn_date = '<a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details for TXN #', 'event_espresso' ) . $item->ID() . '">' . $this->_get_txn_timestamp( $item ) . '</a>'; |
|
207 | + public function column_TXN_timestamp(EE_Transaction $item) { |
|
208 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
209 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
210 | 210 | //status |
211 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ) . '</span>'; |
|
211 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, 'sentence').'</span>'; |
|
212 | 212 | return $txn_date; |
213 | 213 | } |
214 | 214 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @return string |
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | - public function column_TXN_total( EE_Transaction $item ){ |
|
225 | - if ( $item->get('TXN_total') > 0 ) { |
|
226 | - return '<span class="txn-pad-rght">' . apply_filters( 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item ) . '</span>'; |
|
224 | + public function column_TXN_total(EE_Transaction $item) { |
|
225 | + if ($item->get('TXN_total') > 0) { |
|
226 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', $item->get_pretty('TXN_total'), $item).'</span>'; |
|
227 | 227 | } else { |
228 | - return '<span class="txn-overview-free-event-spn">' . __( 'free', 'event_espresso' ) . '</span>'; |
|
228 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @return mixed|string |
239 | 239 | * @throws \EE_Error |
240 | 240 | */ |
241 | - public function column_TXN_paid( EE_Transaction $item ){ |
|
241 | + public function column_TXN_paid(EE_Transaction $item) { |
|
242 | 242 | $transaction_total = $item->get('TXN_total'); |
243 | 243 | $transaction_paid = $item->get('TXN_paid'); |
244 | 244 | |
245 | - if ( \EEH_Money::compare_floats( $transaction_total, 0,'>' ) ) { |
|
245 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
246 | 246 | // monies owing |
247 | 247 | $span_class = 'txn-overview-part-payment-spn'; |
248 | - if ( \EEH_Money::compare_floats( $transaction_paid, $transaction_total, '>=' ) ) { |
|
248 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
249 | 249 | // paid in full |
250 | 250 | $span_class = 'txn-overview-full-payment-spn'; |
251 | - } elseif ( \EEH_Money::compare_floats( $transaction_paid, 0, '==' ) ) { |
|
251 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
252 | 252 | // no payments made |
253 | 253 | $span_class = 'txn-overview-no-payment-spn'; |
254 | 254 | } |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | $payment_method = $item->payment_method(); |
261 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' ); |
|
261 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso'); |
|
262 | 262 | |
263 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
264 | - if ( $transaction_paid > 0 ) { |
|
265 | - $content .= '<br><span class="ee-status-text-small">' . sprintf( __( '...via %s', 'event_espresso' ), $payment_method_name ) . '</span>'; |
|
263 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
264 | + if ($transaction_paid > 0) { |
|
265 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), $payment_method_name).'</span>'; |
|
266 | 266 | } |
267 | 267 | return $content; |
268 | 268 | } |
@@ -276,13 +276,13 @@ discard block |
||
276 | 276 | * @return string|void |
277 | 277 | * @throws \EE_Error |
278 | 278 | */ |
279 | - public function column_ATT_fname( EE_Transaction $item ){ |
|
279 | + public function column_ATT_fname(EE_Transaction $item) { |
|
280 | 280 | $primary_reg = $item->primary_registration(); |
281 | 281 | $attendee = $primary_reg->get_first_related('Attendee'); |
282 | - if ( $attendee instanceof EE_Attendee ) { |
|
283 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$primary_reg->ID() ), REG_ADMIN_URL ); |
|
284 | - $content = EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
285 | - $content .= '<br>' . $attendee->email(); |
|
282 | + if ($attendee instanceof EE_Attendee) { |
|
283 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$primary_reg->ID()), REG_ADMIN_URL); |
|
284 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
285 | + $content .= '<br>'.$attendee->email(); |
|
286 | 286 | return $content; |
287 | 287 | } |
288 | 288 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', 'event_espresso'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @return string|void |
298 | 298 | * @throws \EE_Error |
299 | 299 | */ |
300 | - public function column_ATT_email( EE_Transaction $item ){ |
|
300 | + public function column_ATT_email(EE_Transaction $item) { |
|
301 | 301 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
302 | - if ( ! empty( $attendee ) ) { |
|
303 | - return '<a href="mailto:' . $attendee->get( 'ATT_email' ) . '">' . $attendee->get( 'ATT_email' ) . '</a>'; |
|
302 | + if ( ! empty($attendee)) { |
|
303 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
304 | 304 | } else { |
305 | 305 | return $item->failed() || $item->is_abandoned() |
306 | - ? __( 'no contact record.', 'event_espresso' ) |
|
306 | + ? __('no contact record.', 'event_espresso') |
|
307 | 307 | : __( |
308 | 308 | 'No contact record, because the transaction was abandoned or the registration process failed.', |
309 | 309 | 'event_espresso' |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @return string|void |
321 | 321 | * @throws \EE_Error |
322 | 322 | */ |
323 | - public function column_event_name( EE_Transaction $item ){ |
|
323 | + public function column_event_name(EE_Transaction $item) { |
|
324 | 324 | $actions = array(); |
325 | 325 | $event = $item->primary_registration()->get_first_related('Event'); |
326 | - if ( !empty( $event ) ) { |
|
327 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$event->ID() ), EVENTS_ADMIN_URL ); |
|
326 | + if ( ! empty($event)) { |
|
327 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$event->ID()), EVENTS_ADMIN_URL); |
|
328 | 328 | $event_name = $event->get('EVT_name'); |
329 | 329 | |
330 | 330 | //filter this view by transactions for this event |
331 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event->ID() ) ); |
|
332 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ) { |
|
333 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
331 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event->ID())); |
|
332 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
333 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
334 | 334 | } |
335 | 335 | |
336 | - return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $event->ID() ) ? '<a href="' . $edit_event_url . '" title="' . sprintf( esc_attr__( 'Edit Event: %s', 'event_espresso' ), $event->get('EVT_name') ) .'">' . wp_trim_words( $event_name, 30, '...' ) . '</a>' : wp_trim_words( $event_name, 30, '...' ), $this->row_actions($actions) ); |
|
336 | + return sprintf('%1$s %2$s', EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
337 | 337 | } else { |
338 | 338 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', 'event_espresso'); |
339 | 339 | } |
@@ -348,35 +348,35 @@ discard block |
||
348 | 348 | * @return string |
349 | 349 | * @throws \EE_Error |
350 | 350 | */ |
351 | - public function column_actions( EE_Transaction $item ){ |
|
351 | + public function column_actions(EE_Transaction $item) { |
|
352 | 352 | |
353 | 353 | $registration = $item->primary_registration(); |
354 | 354 | $attendee = $registration->attendee(); |
355 | 355 | |
356 | 356 | //Build row actions |
357 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
357 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
358 | 358 | $dl_invoice_lnk_url = $registration->invoice_url(); |
359 | 359 | $dl_receipt_lnk_url = $registration->receipt_url(); |
360 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration->ID() ), REG_ADMIN_URL ); |
|
361 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID() ), TXN_ADMIN_URL ); |
|
362 | - $related_messages_link = EEH_MSG_Template::get_message_action_link( 'see_notifications_for', null, array( |
|
360 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration->ID()), REG_ADMIN_URL); |
|
361 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$item->ID()), TXN_ADMIN_URL); |
|
362 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
363 | 363 | 'TXN_ID' => $item->ID() |
364 | 364 | )); |
365 | 365 | |
366 | 366 | //Build row actions |
367 | 367 | $view_lnk = ' |
368 | 368 | <li> |
369 | - <a href="'.$view_lnk_url.'" title="' . esc_attr__( 'View Transaction Details', 'event_espresso' ) . '" class="tiny-text"> |
|
369 | + <a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
370 | 370 | <span class="dashicons dashicons-cart"></span> |
371 | 371 | </a> |
372 | 372 | </li>'; |
373 | 373 | |
374 | 374 | $dl_invoice_lnk = ''; |
375 | 375 | //only show invoice link if message type is active. |
376 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'invoice' ) ) { |
|
376 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
377 | 377 | $dl_invoice_lnk = ' |
378 | 378 | <li> |
379 | - <a title="' . esc_attr__( 'View Transaction Invoice', 'event_espresso' ) . '" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
379 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
380 | 380 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
381 | 381 | </a> |
382 | 382 | </li>'; |
@@ -384,17 +384,17 @@ discard block |
||
384 | 384 | |
385 | 385 | $dl_receipt_lnk = ''; |
386 | 386 | //only show receipt link if message type is active. |
387 | - if ( $attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active( 'receipt' ) ) { |
|
387 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
388 | 388 | $dl_receipt_lnk = ' |
389 | 389 | <li> |
390 | - <a title="' . esc_attr__( 'View Transaction Receipt', 'event_espresso' ) . '" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
390 | + <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
391 | 391 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
392 | 392 | </a> |
393 | 393 | </li>'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | //only show payment reminder link if the message type is active. |
397 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
397 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
398 | 398 | $send_pay_lnk = $attendee instanceof EE_Attendee |
399 | 399 | && EE_Registry::instance()->CAP->current_user_can( |
400 | 400 | 'ee_send_message', |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | ) |
403 | 403 | ? ' |
404 | 404 | <li> |
405 | - <a href="'.$send_pay_lnk_url.'" title="' . esc_attr__( 'Send Payment Reminder', 'event_espresso' ) . '" class="tiny-text"> |
|
405 | + <a href="'.$send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text"> |
|
406 | 406 | <span class="dashicons dashicons-email-alt"></span> |
407 | 407 | </a> |
408 | 408 | </li>' |
@@ -422,18 +422,18 @@ discard block |
||
422 | 422 | ) |
423 | 423 | ? ' |
424 | 424 | <li> |
425 | - <a href="'.$view_reg_lnk_url.'" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '" class="tiny-text"> |
|
425 | + <a href="'.$view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
426 | 426 | <span class="dashicons dashicons-clipboard"></span> |
427 | 427 | </a> |
428 | 428 | </li>' |
429 | 429 | : ''; |
430 | 430 | |
431 | 431 | $view_related_messages_lnk = ''; |
432 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
433 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
432 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
433 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
434 | 434 | } |
435 | 435 | |
436 | - return $this->_action_string( $view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul' ); |
|
436 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, $item, 'ul', 'txn-overview-actions-ul'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 |
@@ -31,29 +31,29 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php esc_html_e( "We'd like to remind you that you still owe money for the following transaction:", 'event_espresso' ); ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php esc_html_e("We'd like to remind you that you still owe money for the following transaction:", 'event_espresso'); ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
48 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
49 | 49 | </li> |
50 | 50 | </ul> |
51 | 51 | <p class="callout"> |
52 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
52 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
53 | 53 | </p> |
54 | 54 | [EVENT_LIST] |
55 | 55 | <p class="callout"> |
56 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
56 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
57 | 57 | </p> |
58 | 58 | </td> |
59 | 59 | </tr> |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | <tbody> |
79 | 79 | <tr> |
80 | 80 | <td> |
81 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
82 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
83 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
84 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
81 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
82 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
83 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
84 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
85 | 85 | </td> |
86 | 86 | </tr> |
87 | 87 | </tbody> |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | <tbody> |
92 | 92 | <tr> |
93 | 93 | <td> |
94 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
95 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
96 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> |
|
94 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
95 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
96 | + <?php esc_html_e('Email:', 'event_espresso'); ?> |
|
97 | 97 | <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
98 | 98 | </td> |
99 | 99 | </tr> |
@@ -31,23 +31,23 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h1><?php esc_html_e( 'Payment Reminder Notification', 'event_espresso' ); ?></h1> |
|
35 | - <?php esc_html_e( 'The following message was sent to the Primary Registrant of this transaction:', 'event_espresso' ); ?> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h1><?php esc_html_e('Payment Reminder Notification', 'event_espresso'); ?></h1> |
|
35 | + <?php esc_html_e('The following message was sent to the Primary Registrant of this transaction:', 'event_espresso'); ?> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | - <li><strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> |
|
41 | + <li><strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> |
|
42 | 42 | <a href="[TRANSACTION_ADMIN_URL]">[TXN_ID]</a></li> |
43 | 43 | <li> |
44 | - <strong><?php esc_html_e( 'Payment Gateway:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
44 | + <strong><?php esc_html_e('Payment Gateway:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
45 | 45 | </li> |
46 | 46 | <li> |
47 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
47 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
48 | 48 | </li> |
49 | 49 | <li> |
50 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
50 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
51 | 51 | </li> |
52 | 52 | </ul> |
53 | 53 | </td> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | </table> |
57 | 57 | </div> |
58 | 58 | <div class="content"> |
59 | - <h2><?php esc_html_e( 'Registrant Details:', 'event_espresso' ); ?></h2> |
|
59 | + <h2><?php esc_html_e('Registrant Details:', 'event_espresso'); ?></h2> |
|
60 | 60 | <p class="callout"><strong>[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]:</strong> |
61 | 61 | <a href="mailto:[PRIMARY_REGISTRANT_EMAIL]">[PRIMARY_REGISTRANT_EMAIL]</a></p> |
62 | 62 | </div> |
@@ -64,14 +64,14 @@ |
||
64 | 64 | //make sure we end up with a copy of the EE_Messages_Addressee object |
65 | 65 | $this->_recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
66 | 66 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
67 | - && is_array( $this->_data ) |
|
68 | - && isset( $this->_data['data'] ) |
|
69 | - && $this->_data['data'] instanceof EE_Messages_Addressee |
|
67 | + && is_array( $this->_data ) |
|
68 | + && isset( $this->_data['data'] ) |
|
69 | + && $this->_data['data'] instanceof EE_Messages_Addressee |
|
70 | 70 | ? $this->_data['data'] : |
71 | 71 | $this->_recipient; |
72 | 72 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
73 | - && ! empty( $this->_extra_data['data'] ) |
|
74 | - && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
73 | + && ! empty( $this->_extra_data['data'] ) |
|
74 | + && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
75 | 75 | ? $this->_extra_data['data'] |
76 | 76 | : $this->_recipient; |
77 | 77 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -37,24 +37,24 @@ discard block |
||
37 | 37 | |
38 | 38 | |
39 | 39 | protected function _init_props() { |
40 | - $this->label = esc_html__( 'Recipient Details Shortcodes', 'event_espresso' ); |
|
41 | - $this->description = esc_html__( 'All shortcodes specific to recipient registration data', 'event_espresso' ); |
|
40 | + $this->label = esc_html__('Recipient Details Shortcodes', 'event_espresso'); |
|
41 | + $this->description = esc_html__('All shortcodes specific to recipient registration data', 'event_espresso'); |
|
42 | 42 | $this->_shortcodes = array( |
43 | - '[RECIPIENT_FNAME]' => esc_html__( 'Parses to the first name of the recipient for the message.', 'event_espresso' ), |
|
44 | - '[RECIPIENT_LNAME]' => esc_html__( 'Parses to the last name of the recipient for the message.', 'event_espresso' ), |
|
45 | - '[RECIPIENT_EMAIL]' => esc_html__( 'Parses to the email address of the recipient for the message.', 'event_espresso' ), |
|
46 | - '[RECIPIENT_REGISTRATION_ID]' => esc_html__( 'Parses to the registration ID of the recipient for the message.', 'event_espresso' ), |
|
47 | - '[RECIPIENT_REGISTRATION_CODE]' => esc_html__( 'Parses to the registration code of the recipient for the message.', 'event_espresso' ), |
|
48 | - '[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__( 'Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso' ), |
|
49 | - '[RECIPIENT_PHONE_NUMBER]' => esc_html__( 'The Phone Number for the recipient of the message.', 'event_espresso' ), |
|
50 | - '[RECIPIENT_ADDRESS]' => esc_html__( 'The Address for the recipient of the message.', 'event_espresso' ), |
|
51 | - '[RECIPIENT_ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the recipient of the message.', 'event_espresso' ), |
|
52 | - '[RECIPIENT_CITY]' => esc_html__( 'The city for the recipient of the message.', 'event_espresso' ), |
|
53 | - '[RECIPIENT_ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso' ), |
|
54 | - '[RECIPIENT_ADDRESS_STATE]' => esc_html__( 'The state/province for the recipient of the message.', 'event_espresso' ), |
|
55 | - '[RECIPIENT_COUNTRY]' => esc_html__( 'The country for the recipient of the message.', 'event_espresso' ), |
|
56 | - '[RECIPIENT_ANSWER_*]' => esc_html__( 'This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso' ), |
|
57 | - '[RECIPIENT_TOTAL_AMOUNT_PAID]' => esc_html__( 'If a single registration related to the recipient is available, that is used to retrieve the total amount that has been paid for this recipient. Otherwise the value of 0 is printed.', 'event_espresso' ) |
|
43 | + '[RECIPIENT_FNAME]' => esc_html__('Parses to the first name of the recipient for the message.', 'event_espresso'), |
|
44 | + '[RECIPIENT_LNAME]' => esc_html__('Parses to the last name of the recipient for the message.', 'event_espresso'), |
|
45 | + '[RECIPIENT_EMAIL]' => esc_html__('Parses to the email address of the recipient for the message.', 'event_espresso'), |
|
46 | + '[RECIPIENT_REGISTRATION_ID]' => esc_html__('Parses to the registration ID of the recipient for the message.', 'event_espresso'), |
|
47 | + '[RECIPIENT_REGISTRATION_CODE]' => esc_html__('Parses to the registration code of the recipient for the message.', 'event_espresso'), |
|
48 | + '[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__('Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso'), |
|
49 | + '[RECIPIENT_PHONE_NUMBER]' => esc_html__('The Phone Number for the recipient of the message.', 'event_espresso'), |
|
50 | + '[RECIPIENT_ADDRESS]' => esc_html__('The Address for the recipient of the message.', 'event_espresso'), |
|
51 | + '[RECIPIENT_ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the recipient of the message.', 'event_espresso'), |
|
52 | + '[RECIPIENT_CITY]' => esc_html__('The city for the recipient of the message.', 'event_espresso'), |
|
53 | + '[RECIPIENT_ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso'), |
|
54 | + '[RECIPIENT_ADDRESS_STATE]' => esc_html__('The state/province for the recipient of the message.', 'event_espresso'), |
|
55 | + '[RECIPIENT_COUNTRY]' => esc_html__('The country for the recipient of the message.', 'event_espresso'), |
|
56 | + '[RECIPIENT_ANSWER_*]' => esc_html__('This is a special dynamic shortcode. After the "*", add the exact text of an existing question, and if there is an answer for that question for this recipient, then it will be output in place of this shortcode.', 'event_espresso'), |
|
57 | + '[RECIPIENT_TOTAL_AMOUNT_PAID]' => esc_html__('If a single registration related to the recipient is available, that is used to retrieve the total amount that has been paid for this recipient. Otherwise the value of 0 is printed.', 'event_espresso') |
|
58 | 58 | ); |
59 | 59 | } |
60 | 60 | |
@@ -65,36 +65,35 @@ discard block |
||
65 | 65 | * @param string $shortcode the shortcode to be parsed. |
66 | 66 | * @return string parsed shortcode |
67 | 67 | */ |
68 | - protected function _parser( $shortcode ) { |
|
68 | + protected function _parser($shortcode) { |
|
69 | 69 | |
70 | 70 | //make sure we end up with a copy of the EE_Messages_Addressee object |
71 | 71 | $this->_recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
72 | 72 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
73 | - && is_array( $this->_data ) |
|
74 | - && isset( $this->_data['data'] ) |
|
73 | + && is_array($this->_data) |
|
74 | + && isset($this->_data['data']) |
|
75 | 75 | && $this->_data['data'] instanceof EE_Messages_Addressee |
76 | - ? $this->_data['data'] : |
|
77 | - $this->_recipient; |
|
76 | + ? $this->_data['data'] : $this->_recipient; |
|
78 | 77 | $this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee |
79 | - && ! empty( $this->_extra_data['data'] ) |
|
78 | + && ! empty($this->_extra_data['data']) |
|
80 | 79 | && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
81 | 80 | ? $this->_extra_data['data'] |
82 | 81 | : $this->_recipient; |
83 | 82 | |
84 | - if ( ! $this->_recipient instanceof EE_Messages_Addressee ) { |
|
83 | + if ( ! $this->_recipient instanceof EE_Messages_Addressee) { |
|
85 | 84 | return ''; |
86 | 85 | } |
87 | 86 | |
88 | 87 | $attendee = $this->_recipient->att_obj; |
89 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
88 | + if ( ! $attendee instanceof EE_Attendee) { |
|
90 | 89 | return ''; |
91 | 90 | } |
92 | 91 | |
93 | - $this->_registrations_for_recipient = isset( $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] ) |
|
94 | - ? $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] |
|
92 | + $this->_registrations_for_recipient = isset($this->_recipient->attendees[$attendee->ID()]['reg_objs']) |
|
93 | + ? $this->_recipient->attendees[$attendee->ID()]['reg_objs'] |
|
95 | 94 | : array(); |
96 | 95 | |
97 | - switch ( $shortcode ) { |
|
96 | + switch ($shortcode) { |
|
98 | 97 | case '[RECIPIENT_FNAME]' : |
99 | 98 | return $attendee->fname(); |
100 | 99 | break; |
@@ -108,21 +107,21 @@ discard block |
||
108 | 107 | break; |
109 | 108 | |
110 | 109 | case '[RECIPIENT_REGISTRATION_ID]' : |
111 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
110 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
112 | 111 | return ''; |
113 | 112 | } |
114 | 113 | return $this->_get_reg_id(); |
115 | 114 | break; |
116 | 115 | |
117 | 116 | case '[RECIPIENT_REGISTRATION_CODE]' : |
118 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
117 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
119 | 118 | return ''; |
120 | 119 | } |
121 | 120 | return $this->_get_reg_code(); |
122 | 121 | break; |
123 | 122 | |
124 | 123 | case '[RECIPIENT_EDIT_REGISTRATION_LINK]' : |
125 | - if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
124 | + if ( ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
126 | 125 | return ''; |
127 | 126 | } |
128 | 127 | return $this->_recipient->reg_obj->edit_attendee_information_url(); |
@@ -164,23 +163,23 @@ discard block |
||
164 | 163 | break; |
165 | 164 | } |
166 | 165 | |
167 | - if ( strpos( $shortcode, '[RECIPIENT_ANSWER_*' ) !== false ) { |
|
168 | - $shortcode = str_replace( '[RECIPIENT_ANSWER_*', '', $shortcode ); |
|
169 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
166 | + if (strpos($shortcode, '[RECIPIENT_ANSWER_*') !== false) { |
|
167 | + $shortcode = str_replace('[RECIPIENT_ANSWER_*', '', $shortcode); |
|
168 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
170 | 169 | |
171 | 170 | |
172 | 171 | //now let's figure out what question has this text |
173 | - if ( empty( $this->_recipient->questions ) || ! $this->_recipient->reg_obj instanceof EE_Registration ) { |
|
172 | + if (empty($this->_recipient->questions) || ! $this->_recipient->reg_obj instanceof EE_Registration) { |
|
174 | 173 | return ''; |
175 | 174 | } |
176 | 175 | |
177 | - foreach ( $this->_recipient->questions as $ansid => $question ) { |
|
176 | + foreach ($this->_recipient->questions as $ansid => $question) { |
|
178 | 177 | if ( |
179 | 178 | $question instanceof EE_Question |
180 | 179 | && $question->display_text() == $shortcode |
181 | - && isset( $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ] ) |
|
180 | + && isset($this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]) |
|
182 | 181 | ) { |
183 | - return $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ]->get_pretty( 'ANS_value', 'no_wpautop' ); |
|
182 | + return $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop'); |
|
184 | 183 | } |
185 | 184 | } |
186 | 185 | } |
@@ -211,53 +210,53 @@ discard block |
||
211 | 210 | protected function _get_reg_code() { |
212 | 211 | |
213 | 212 | //if only one related registration for the recipient then just return that reg code. |
214 | - if ( count( $this->_registrations_for_recipient ) <= 1 ) { |
|
213 | + if (count($this->_registrations_for_recipient) <= 1) { |
|
215 | 214 | return $this->_recipient->reg_obj->reg_code(); |
216 | 215 | } |
217 | 216 | |
218 | 217 | //k more than one registration so let's see if we can get specific to context |
219 | 218 | //are we parsing event_list? |
220 | - if ( $this->_data instanceof EE_Event ) { |
|
219 | + if ($this->_data instanceof EE_Event) { |
|
221 | 220 | $reg_code = array(); |
222 | 221 | //loop through registrations for recipient and see if there is a match for this event |
223 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
224 | - if ( $reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID() ) { |
|
222 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
223 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID()) { |
|
225 | 224 | $reg_code[] = $reg->reg_code(); |
226 | 225 | } |
227 | 226 | } |
228 | - return implode( ', ', $reg_code ); |
|
227 | + return implode(', ', $reg_code); |
|
229 | 228 | } |
230 | 229 | |
231 | 230 | //are we parsing ticket list? |
232 | - if ( $this->_data instanceof EE_Ticket ) { |
|
231 | + if ($this->_data instanceof EE_Ticket) { |
|
233 | 232 | $reg_code = array(); |
234 | 233 | //loop through each registration for recipient and see if there is a match for this ticket |
235 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
236 | - if ( $reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID() ) { |
|
234 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
235 | + if ($reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID()) { |
|
237 | 236 | $reg_code = $reg->reg_code(); |
238 | 237 | } |
239 | 238 | } |
240 | - return implode( ', ', $reg_code ); |
|
239 | + return implode(', ', $reg_code); |
|
241 | 240 | } |
242 | 241 | |
243 | 242 | //do we have a specific reg_obj? Let's use it |
244 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
243 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
245 | 244 | return $this->_data->reg_obj->reg_code(); |
246 | 245 | } |
247 | 246 | |
248 | 247 | //do we have a specific reg_obj? Let's use it |
249 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
248 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
250 | 249 | return $this->_data->reg_obj->reg_code(); |
251 | 250 | } |
252 | 251 | |
253 | 252 | //not able to determine the single reg code so let's return a comma delimited list of reg codes. |
254 | 253 | $reg_code = array(); |
255 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
256 | - if ( $reg instanceof EE_Registration ) { |
|
254 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
255 | + if ($reg instanceof EE_Registration) { |
|
257 | 256 | $reg_code[] = $reg->reg_code(); |
258 | 257 | } |
259 | 258 | } |
260 | - return implode( ', ', $reg_code ); |
|
259 | + return implode(', ', $reg_code); |
|
261 | 260 | } |
262 | 261 | |
263 | 262 | |
@@ -270,48 +269,48 @@ discard block |
||
270 | 269 | protected function _get_reg_id() { |
271 | 270 | |
272 | 271 | //if only one related registration for the recipient then just return that reg code. |
273 | - if ( count( $this->_registrations_for_recipient ) <= 1 ) { |
|
272 | + if (count($this->_registrations_for_recipient) <= 1) { |
|
274 | 273 | return $this->_recipient->reg_obj->ID(); |
275 | 274 | } |
276 | 275 | |
277 | 276 | //k more than one registration so let's see if we can get specific to context |
278 | 277 | //are we parsing event_list? |
279 | - if ( $this->_data instanceof EE_Event ) { |
|
278 | + if ($this->_data instanceof EE_Event) { |
|
280 | 279 | $registration_ids = array(); |
281 | 280 | //loop through registrations for recipient and see if there is a match for this event |
282 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
283 | - if ( $reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID() ) { |
|
281 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
282 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID()) { |
|
284 | 283 | $registration_ids[] = $reg->ID(); |
285 | 284 | } |
286 | 285 | } |
287 | - return implode( ', ', $registration_ids ); |
|
286 | + return implode(', ', $registration_ids); |
|
288 | 287 | } |
289 | 288 | |
290 | 289 | //are we parsing ticket list? |
291 | - if ( $this->_data instanceof EE_Ticket ) { |
|
290 | + if ($this->_data instanceof EE_Ticket) { |
|
292 | 291 | $registration_ids = array(); |
293 | 292 | //loop through each registration for recipient and see if there is a match for this ticket |
294 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
295 | - if ( $reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID() ) { |
|
293 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
294 | + if ($reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID()) { |
|
296 | 295 | $registration_ids = $reg->ID(); |
297 | 296 | } |
298 | 297 | } |
299 | - return implode( ', ', $registration_ids ); |
|
298 | + return implode(', ', $registration_ids); |
|
300 | 299 | } |
301 | 300 | |
302 | 301 | //do we have a specific reg_obj? Let's use it |
303 | - if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) { |
|
302 | + if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) { |
|
304 | 303 | return $this->_data->reg_obj->ID(); |
305 | 304 | } |
306 | 305 | |
307 | 306 | //not able to determine the single reg code so let's return a comma delimited list of reg codes. |
308 | 307 | $registration_ids = array(); |
309 | - foreach ( $this->_registrations_for_recipient as $reg ) { |
|
310 | - if ( $reg instanceof EE_Registration ) { |
|
308 | + foreach ($this->_registrations_for_recipient as $reg) { |
|
309 | + if ($reg instanceof EE_Registration) { |
|
311 | 310 | $registration_ids[] = $reg->ID(); |
312 | 311 | } |
313 | 312 | } |
314 | - return implode( ', ', $registration_ids ); |
|
313 | + return implode(', ', $registration_ids); |
|
315 | 314 | } |
316 | 315 | |
317 | 316 |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | /** |
43 | 43 | * EE_Attendee_Shortcodes constructor. |
44 | - */ |
|
44 | + */ |
|
45 | 45 | public function __construct() { |
46 | 46 | parent::__construct(); |
47 | 47 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -49,26 +49,26 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | protected function _init_props() { |
52 | - $this->label = esc_html__( 'Attendee Shortcodes', 'event_espresso' ); |
|
53 | - $this->description = esc_html__( 'All shortcodes specific to attendee related data', 'event_espresso' ); |
|
52 | + $this->label = esc_html__('Attendee Shortcodes', 'event_espresso'); |
|
53 | + $this->description = esc_html__('All shortcodes specific to attendee related data', 'event_espresso'); |
|
54 | 54 | $this->_shortcodes = array( |
55 | - '[FNAME]' => esc_html__( 'First Name of an attendee.', 'event_espresso' ), |
|
56 | - '[LNAME]' => esc_html__( 'Last Name of an attendee.', 'event_espresso' ), |
|
57 | - '[ATTENDEE_EMAIL]' => esc_html__( 'Email address for the attendee.', 'event_espresso' ), |
|
58 | - '[EDIT_ATTENDEE_LINK]' => esc_html__( 'Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso' ), |
|
59 | - '[REGISTRATION_ID]' => esc_html__( 'Unique Registration ID for the registration', 'event_espresso' ), |
|
60 | - '[REGISTRATION_CODE]' => esc_html__( 'Unique Registration Code for the registration', 'event_espresso' ), |
|
61 | - '[REGISTRATION_STATUS_ID]' => esc_html__( 'Parses to the registration status for the attendee', 'event_espresso' ), |
|
62 | - '[REGISTRATION_STATUS_LABEL]' => esc_html__( 'Parses to the status label for the registrant', 'event_espresso' ), |
|
63 | - '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( 'Parses to the total amount paid for this registration.', 'event_espresso' ), |
|
64 | - '[FRONTEND_EDIT_REG_LINK]' => esc_html__( 'Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso' ), |
|
65 | - '[PHONE_NUMBER]' => esc_html__( 'The Phone Number for the Registration.', 'event_espresso' ), |
|
66 | - '[ADDRESS]' => esc_html__( 'The Address for the Registration', 'event_espresso' ), |
|
67 | - '[ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the registration.', 'event_espresso' ), |
|
68 | - '[CITY]' => esc_html__( 'The city for the registration.', 'event_espresso' ), |
|
69 | - '[ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the Registration.', 'event_espresso' ), |
|
70 | - '[ADDRESS_STATE]' => esc_html__( 'The state/province for the registration.', 'event_espresso' ), |
|
71 | - '[COUNTRY]' => esc_html__( 'The country for the registration.', 'event_espresso' ) |
|
55 | + '[FNAME]' => esc_html__('First Name of an attendee.', 'event_espresso'), |
|
56 | + '[LNAME]' => esc_html__('Last Name of an attendee.', 'event_espresso'), |
|
57 | + '[ATTENDEE_EMAIL]' => esc_html__('Email address for the attendee.', 'event_espresso'), |
|
58 | + '[EDIT_ATTENDEE_LINK]' => esc_html__('Edit Registration Link (typically you\'d only use this for messages going to event administrators)', 'event_espresso'), |
|
59 | + '[REGISTRATION_ID]' => esc_html__('Unique Registration ID for the registration', 'event_espresso'), |
|
60 | + '[REGISTRATION_CODE]' => esc_html__('Unique Registration Code for the registration', 'event_espresso'), |
|
61 | + '[REGISTRATION_STATUS_ID]' => esc_html__('Parses to the registration status for the attendee', 'event_espresso'), |
|
62 | + '[REGISTRATION_STATUS_LABEL]' => esc_html__('Parses to the status label for the registrant', 'event_espresso'), |
|
63 | + '[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__('Parses to the total amount paid for this registration.', 'event_espresso'), |
|
64 | + '[FRONTEND_EDIT_REG_LINK]' => esc_html__('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'), |
|
65 | + '[PHONE_NUMBER]' => esc_html__('The Phone Number for the Registration.', 'event_espresso'), |
|
66 | + '[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'), |
|
67 | + '[ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the registration.', 'event_espresso'), |
|
68 | + '[CITY]' => esc_html__('The city for the registration.', 'event_espresso'), |
|
69 | + '[ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the Registration.', 'event_espresso'), |
|
70 | + '[ADDRESS_STATE]' => esc_html__('The state/province for the registration.', 'event_espresso'), |
|
71 | + '[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso') |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @return string |
83 | 83 | * @throws \EE_Error |
84 | 84 | */ |
85 | - protected function _parser( $shortcode ) { |
|
85 | + protected function _parser($shortcode) { |
|
86 | 86 | |
87 | 87 | |
88 | - $this->_xtra = ! empty( $this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
88 | + $this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee |
|
89 | 89 | ? $this->_extra_data['data'] |
90 | 90 | : null; |
91 | 91 | |
@@ -94,34 +94,34 @@ discard block |
||
94 | 94 | ? null |
95 | 95 | : $this->_data; |
96 | 96 | |
97 | - if ( ! $registration instanceof EE_Registration ) { |
|
97 | + if ( ! $registration instanceof EE_Registration) { |
|
98 | 98 | //let's attempt to get the txn_id for the error message. |
99 | - $txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction |
|
99 | + $txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction |
|
100 | 100 | ? $this->_xtra->txn->ID() |
101 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
102 | - $msg = esc_html__( 'There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso' ); |
|
101 | + : esc_html__('Unknown', 'event_espresso'); |
|
102 | + $msg = esc_html__('There is no EE_Registration object in the data sent to the EE_Attendee Shortcode Parser for the messages system.', 'event_espresso'); |
|
103 | 103 | $dev_msg = sprintf( |
104 | - esc_html__( 'The transaction ID for this request is: %s', 'event_espresso' ), |
|
104 | + esc_html__('The transaction ID for this request is: %s', 'event_espresso'), |
|
105 | 105 | $txn_id |
106 | 106 | ); |
107 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
107 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | //attendee obj for this registration |
111 | - $attendee = isset( $this->_xtra->registrations[ $registration->ID() ]['att_obj'] ) |
|
112 | - ? $this->_xtra->registrations[ $registration->ID() ]['att_obj'] |
|
113 | - : null ; |
|
111 | + $attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj']) |
|
112 | + ? $this->_xtra->registrations[$registration->ID()]['att_obj'] |
|
113 | + : null; |
|
114 | 114 | |
115 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
116 | - $msg = esc_html__( 'There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso' ); |
|
115 | + if ( ! $attendee instanceof EE_Attendee) { |
|
116 | + $msg = esc_html__('There is no EE_Attendee object in the data sent to the EE_Attendee_Shortcode parser for the messages system.', 'event_espresso'); |
|
117 | 117 | $dev_msg = sprintf( |
118 | - esc_html__( 'The registration ID for this request is: %s', 'event_espresso' ), |
|
118 | + esc_html__('The registration ID for this request is: %s', 'event_espresso'), |
|
119 | 119 | $registration->ID() |
120 | 120 | ); |
121 | - throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" ); |
|
121 | + throw new EE_Error("{$msg}||{$msg} {$dev_msg}"); |
|
122 | 122 | } |
123 | 123 | |
124 | - switch ( $shortcode ) { |
|
124 | + switch ($shortcode) { |
|
125 | 125 | |
126 | 126 | case '[FNAME]' : |
127 | 127 | return $attendee->fname(); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | 116 | if ( $field_obj instanceof \EE_Infinite_Integer_Field |
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
117 | + && in_array( $original_value, array( null, '' ), true ) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | 120 | } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $original_value, |
175 | 175 | $requested_version |
176 | 176 | ); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | 180 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | $requested_version, |
49 | 49 | $timezone_string = 'UTC' |
50 | 50 | ) { |
51 | - if ( is_array( $original_value_maybe_array ) ) { |
|
51 | + if (is_array($original_value_maybe_array)) { |
|
52 | 52 | $new_value_maybe_array = array(); |
53 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
54 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_from_json( |
|
53 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
54 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_from_json( |
|
55 | 55 | $field_obj, |
56 | 56 | $array_item, |
57 | 57 | $requested_version, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param string $request_version (eg 4.8.36) |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - public static function prepare_field_values_for_json( $field_obj, $original_value_maybe_array, $request_version ) { |
|
81 | - if ( is_array( $original_value_maybe_array ) ) { |
|
80 | + public static function prepare_field_values_for_json($field_obj, $original_value_maybe_array, $request_version) { |
|
81 | + if (is_array($original_value_maybe_array)) { |
|
82 | 82 | $new_value_maybe_array = array(); |
83 | - foreach ( $original_value_maybe_array as $array_key => $array_item ) { |
|
84 | - $new_value_maybe_array[ $array_key ] = Model_Data_Translator::prepare_field_value_for_json( |
|
83 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
84 | + $new_value_maybe_array[$array_key] = Model_Data_Translator::prepare_field_value_for_json( |
|
85 | 85 | $field_obj, |
86 | 86 | $array_item, |
87 | 87 | $request_version |
@@ -113,30 +113,30 @@ discard block |
||
113 | 113 | $timezone_string = 'UTC' |
114 | 114 | ) { |
115 | 115 | $new_value = null; |
116 | - if ( $field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | - && in_array( $original_value, array( null, '' ), true ) |
|
116 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
117 | + && in_array($original_value, array(null, ''), true) |
|
118 | 118 | ) { |
119 | 119 | $new_value = EE_INF; |
120 | - } elseif ( $field_obj instanceof \EE_Datetime_Field ) { |
|
120 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
121 | 121 | //treat the provided value as being in this timezone |
122 | - $offset_secs_string = $field_obj->get_timezone_offset( new \DateTimeZone( $timezone_string ) ); |
|
123 | - $offset_secs = (int) substr( $offset_secs_string, 1 ); |
|
124 | - $offset_sign = substr( $offset_secs_string, 0, 1 ) ? substr( $offset_secs_string, 0, 1 ) : '+'; |
|
122 | + $offset_secs_string = $field_obj->get_timezone_offset(new \DateTimeZone($timezone_string)); |
|
123 | + $offset_secs = (int) substr($offset_secs_string, 1); |
|
124 | + $offset_sign = substr($offset_secs_string, 0, 1) ? substr($offset_secs_string, 0, 1) : '+'; |
|
125 | 125 | $offset_string = |
126 | 126 | str_pad( |
127 | - floor( $offset_secs / HOUR_IN_SECONDS ), |
|
127 | + floor($offset_secs / HOUR_IN_SECONDS), |
|
128 | 128 | 2, |
129 | 129 | '0', |
130 | 130 | STR_PAD_LEFT |
131 | 131 | ) |
132 | 132 | . ':' |
133 | 133 | . str_pad( |
134 | - ( $offset_secs % HOUR_IN_SECONDS ) / MINUTE_IN_SECONDS, |
|
134 | + ($offset_secs % HOUR_IN_SECONDS) / MINUTE_IN_SECONDS, |
|
135 | 135 | 2, |
136 | 136 | '0', |
137 | 137 | STR_PAD_LEFT |
138 | 138 | ); |
139 | - $new_value = rest_parse_date( $original_value . $offset_sign . $offset_string ); |
|
139 | + $new_value = rest_parse_date($original_value.$offset_sign.$offset_string); |
|
140 | 140 | } else { |
141 | 141 | $new_value = $original_value; |
142 | 142 | } |
@@ -157,22 +157,22 @@ discard block |
||
157 | 157 | >>>>>>> master |
158 | 158 | * @return mixed |
159 | 159 | */ |
160 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
161 | - if( $original_value === EE_INF ) { |
|
160 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
161 | + if ($original_value === EE_INF) { |
|
162 | 162 | $new_value = Model_Data_Translator::ee_inf_in_rest; |
163 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
164 | - if( $original_value instanceof \DateTime ) { |
|
165 | - $new_value = $original_value->format( 'Y-m-d H:i:s' ); |
|
166 | - } elseif( is_int( $original_value ) ) { |
|
167 | - $new_value = date( 'Y-m-d H:i:s', $original_value ); |
|
163 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
164 | + if ($original_value instanceof \DateTime) { |
|
165 | + $new_value = $original_value->format('Y-m-d H:i:s'); |
|
166 | + } elseif (is_int($original_value)) { |
|
167 | + $new_value = date('Y-m-d H:i:s', $original_value); |
|
168 | 168 | } else { |
169 | 169 | $new_value = $original_value; |
170 | 170 | } |
171 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
171 | + $new_value = mysql_to_rfc3339($new_value); |
|
172 | 172 | } else { |
173 | 173 | $new_value = $original_value; |
174 | 174 | } |
175 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
175 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
176 | 176 | $new_value, |
177 | 177 | $field_obj, |
178 | 178 | $original_value, |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @return array |
193 | 193 | * @throws \EE_Error |
194 | 194 | */ |
195 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
195 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
196 | 196 | $query_param_for_models = array(); |
197 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
198 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ); |
|
197 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
198 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key); |
|
199 | 199 | $field = Model_Data_Translator::deduce_field_from_query_param( |
200 | 200 | $query_param_sans_stars, |
201 | 201 | $model |
202 | 202 | ); |
203 | 203 | //double-check is it a *_gmt field? |
204 | - if( ! $field instanceof \EE_Model_Field_Base |
|
205 | - && Model_Data_Translator::is_gmt_date_field_name( $query_param_sans_stars ) ) { |
|
204 | + if ( ! $field instanceof \EE_Model_Field_Base |
|
205 | + && Model_Data_Translator::is_gmt_date_field_name($query_param_sans_stars)) { |
|
206 | 206 | //yep, take off '_gmt', and find the field |
207 | - $query_param_key = Model_Data_Translator::remove_gmt_from_field_name( $query_param_sans_stars ); |
|
207 | + $query_param_key = Model_Data_Translator::remove_gmt_from_field_name($query_param_sans_stars); |
|
208 | 208 | $field = Model_Data_Translator::deduce_field_from_query_param( |
209 | 209 | $query_param_key, |
210 | 210 | $model |
@@ -214,22 +214,22 @@ discard block |
||
214 | 214 | //so it's not a GMT field. Set the timezone on the model to the default |
215 | 215 | $timezone = \EEH_DTT_Helper::get_valid_timezone_string(); |
216 | 216 | } |
217 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
217 | + if ($field instanceof \EE_Model_Field_Base) { |
|
218 | 218 | //did they specify an operator? |
219 | - if( is_array( $query_param_value ) ) { |
|
220 | - $op = $query_param_value[ 0 ]; |
|
221 | - $translated_value = array( $op ); |
|
222 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
223 | - $value = $query_param_value[ 1 ]; |
|
224 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json( $field, $value, $requested_version, $timezone ); |
|
219 | + if (is_array($query_param_value)) { |
|
220 | + $op = $query_param_value[0]; |
|
221 | + $translated_value = array($op); |
|
222 | + if (isset($query_param_value[1])) { |
|
223 | + $value = $query_param_value[1]; |
|
224 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_from_json($field, $value, $requested_version, $timezone); |
|
225 | 225 | } |
226 | 226 | } else { |
227 | - $translated_value = Model_Data_Translator::prepare_field_value_from_json( $field, $query_param_value, $requested_version, $timezone ); |
|
227 | + $translated_value = Model_Data_Translator::prepare_field_value_from_json($field, $query_param_value, $requested_version, $timezone); |
|
228 | 228 | } |
229 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
229 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
230 | 230 | } else { |
231 | 231 | //so it's not for a field, assume it's a logic query param key |
232 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
232 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | return $query_param_for_models; |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | * @param string $field_name |
242 | 242 | * @return boolean |
243 | 243 | */ |
244 | - public static function is_gmt_date_field_name( $field_name ) { |
|
244 | + public static function is_gmt_date_field_name($field_name) { |
|
245 | 245 | return substr( |
246 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ), |
|
246 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name), |
|
247 | 247 | -4, |
248 | 248 | 4 |
249 | 249 | ) === '_gmt'; |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | * @param string $field_name |
255 | 255 | * @return string |
256 | 256 | */ |
257 | - public static function remove_gmt_from_field_name( $field_name ) { |
|
258 | - if( ! Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
257 | + public static function remove_gmt_from_field_name($field_name) { |
|
258 | + if ( ! Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
259 | 259 | return $field_name; |
260 | 260 | } |
261 | - $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $field_name ); |
|
261 | + $query_param_sans_stars = Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($field_name); |
|
262 | 262 | $query_param_sans_gmt_and_sans_stars = substr( |
263 | 263 | $query_param_sans_stars, |
264 | 264 | 0, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | '_gmt' |
268 | 268 | ) |
269 | 269 | ); |
270 | - return str_replace( $query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name ); |
|
270 | + return str_replace($query_param_sans_stars, $query_param_sans_gmt_and_sans_stars, $field_name); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * @param string $field_name |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - public static function prepare_field_name_from_json( $field_name ) { |
|
279 | - if( Model_Data_Translator::is_gmt_date_field_name( $field_name ) ) { |
|
280 | - return Model_Data_Translator::remove_gmt_from_field_name( $field_name ); |
|
278 | + public static function prepare_field_name_from_json($field_name) { |
|
279 | + if (Model_Data_Translator::is_gmt_date_field_name($field_name)) { |
|
280 | + return Model_Data_Translator::remove_gmt_from_field_name($field_name); |
|
281 | 281 | } |
282 | 282 | return $field_name; |
283 | 283 | } |
@@ -287,10 +287,10 @@ discard block |
||
287 | 287 | * @param array $field_names |
288 | 288 | * @return array of field names (possibly include model prefixes) |
289 | 289 | */ |
290 | - public static function prepare_field_names_from_json( array $field_names ) { |
|
290 | + public static function prepare_field_names_from_json(array $field_names) { |
|
291 | 291 | $new_array = array(); |
292 | - foreach( $field_names as $key => $field_name ) { |
|
293 | - $new_array[ $key ] = Model_Data_Translator::prepare_field_name_from_json( $field_name ); |
|
292 | + foreach ($field_names as $key => $field_name) { |
|
293 | + $new_array[$key] = Model_Data_Translator::prepare_field_name_from_json($field_name); |
|
294 | 294 | } |
295 | 295 | return $new_array; |
296 | 296 | } |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * @param array $field_names_as_keys |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public static function prepare_field_names_in_array_keys_from_json( array $field_names_as_keys ) { |
|
304 | + public static function prepare_field_names_in_array_keys_from_json(array $field_names_as_keys) { |
|
305 | 305 | $new_array = array(); |
306 | - foreach( $field_names_as_keys as $field_name => $value ) { |
|
307 | - $new_array[ Model_Data_Translator::prepare_field_name_from_json( $field_name ) ] = $value; |
|
306 | + foreach ($field_names_as_keys as $field_name => $value) { |
|
307 | + $new_array[Model_Data_Translator::prepare_field_name_from_json($field_name)] = $value; |
|
308 | 308 | } |
309 | 309 | return $new_array; |
310 | 310 | } |
@@ -317,27 +317,27 @@ discard block |
||
317 | 317 | * @param string $requested_version eg "4.8.36". If null is provided, defaults to the latest release of the EE4 REST API |
318 | 318 | * @return array which can be passed into the EE4 REST API when querying a model resource |
319 | 319 | */ |
320 | - public static function prepare_query_params_for_rest_api( array $model_query_params, \EEM_Base $model, $requested_version = null ) { |
|
321 | - if( $requested_version === null ) { |
|
322 | - $requested_version = \EED_Core_Rest_Api::latest_rest_api_version() ; |
|
320 | + public static function prepare_query_params_for_rest_api(array $model_query_params, \EEM_Base $model, $requested_version = null) { |
|
321 | + if ($requested_version === null) { |
|
322 | + $requested_version = \EED_Core_Rest_Api::latest_rest_api_version(); |
|
323 | 323 | } |
324 | 324 | $rest_query_params = $model_query_params; |
325 | - if ( isset( $model_query_params[0] ) ) { |
|
326 | - $rest_query_params[ 'where' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | - $model_query_params[ 0 ], |
|
325 | + if (isset($model_query_params[0])) { |
|
326 | + $rest_query_params['where'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
327 | + $model_query_params[0], |
|
328 | 328 | $model, |
329 | 329 | $requested_version |
330 | 330 | ); |
331 | - unset( $rest_query_params[0] ); |
|
331 | + unset($rest_query_params[0]); |
|
332 | 332 | } |
333 | - if ( isset( $model_query_params[ 'having' ] ) ) { |
|
334 | - $rest_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | - $model_query_params[ 'having' ], |
|
333 | + if (isset($model_query_params['having'])) { |
|
334 | + $rest_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( |
|
335 | + $model_query_params['having'], |
|
336 | 336 | $model, |
337 | 337 | $requested_version |
338 | 338 | ); |
339 | 339 | } |
340 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version ); |
|
340 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_query_params_for_rest_api', $rest_query_params, $model_query_params, $model, $requested_version); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -347,29 +347,29 @@ discard block |
||
347 | 347 | * @param string $requested_version eg "4.8.36" |
348 | 348 | * @return array ready for use in the rest api query params |
349 | 349 | */ |
350 | - public static function prepare_conditions_query_params_for_rest_api( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
350 | + public static function prepare_conditions_query_params_for_rest_api($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
351 | 351 | $query_param_for_models = array(); |
352 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
352 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
353 | 353 | $field = Model_Data_Translator::deduce_field_from_query_param( |
354 | - Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
354 | + Model_Data_Translator::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
355 | 355 | $model |
356 | 356 | ); |
357 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
357 | + if ($field instanceof \EE_Model_Field_Base) { |
|
358 | 358 | //did they specify an operator? |
359 | - if( is_array( $query_param_value ) ) { |
|
360 | - $op = $query_param_value[ 0 ]; |
|
361 | - $translated_value = array( $op ); |
|
362 | - if( isset( $query_param_value[ 1 ] ) ) { |
|
363 | - $value = $query_param_value[ 1 ]; |
|
364 | - $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json( $field, $value, $requested_version ); |
|
359 | + if (is_array($query_param_value)) { |
|
360 | + $op = $query_param_value[0]; |
|
361 | + $translated_value = array($op); |
|
362 | + if (isset($query_param_value[1])) { |
|
363 | + $value = $query_param_value[1]; |
|
364 | + $translated_value[1] = Model_Data_Translator::prepare_field_values_for_json($field, $value, $requested_version); |
|
365 | 365 | } |
366 | 366 | } else { |
367 | - $translated_value = Model_Data_Translator::prepare_field_value_for_json( $field, $query_param_value, $requested_version ); |
|
367 | + $translated_value = Model_Data_Translator::prepare_field_value_for_json($field, $query_param_value, $requested_version); |
|
368 | 368 | } |
369 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
369 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
370 | 370 | } else { |
371 | 371 | //so it's not for a field, assume it's a logic query param key |
372 | - $query_param_for_models[ $query_param_key ] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api( $query_param_value, $model, $requested_version ); |
|
372 | + $query_param_for_models[$query_param_key] = Model_Data_Translator::prepare_conditions_query_params_for_rest_api($query_param_value, $model, $requested_version); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 | return $query_param_for_models; |
@@ -381,11 +381,11 @@ discard block |
||
381 | 381 | * @param $condition_query_param_key |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
384 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
385 | 385 | $pos_of_star = strpos($condition_query_param_key, '*'); |
386 | - if($pos_of_star === FALSE){ |
|
386 | + if ($pos_of_star === FALSE) { |
|
387 | 387 | return $condition_query_param_key; |
388 | - }else{ |
|
388 | + } else { |
|
389 | 389 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
390 | 390 | return $condition_query_param_sans_star; |
391 | 391 | } |
@@ -401,26 +401,26 @@ discard block |
||
401 | 401 | * @return \EE_Model_Field_Base |
402 | 402 | * @throws \EE_Error |
403 | 403 | */ |
404 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
404 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
405 | 405 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
406 | 406 | //which will help us find the database table and column |
407 | 407 | |
408 | - $query_param_parts = explode(".",$query_param_name); |
|
409 | - if(empty($query_param_parts)){ |
|
410 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
408 | + $query_param_parts = explode(".", $query_param_name); |
|
409 | + if (empty($query_param_parts)) { |
|
410 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
411 | 411 | } |
412 | 412 | $number_of_parts = count($query_param_parts); |
413 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
414 | - if($number_of_parts == 1){ |
|
413 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
414 | + if ($number_of_parts == 1) { |
|
415 | 415 | $field_name = $last_query_param_part; |
416 | - }else{// $number_of_parts >= 2 |
|
416 | + } else {// $number_of_parts >= 2 |
|
417 | 417 | //the last part is the column name, and there are only 2parts. therefore... |
418 | 418 | $field_name = $last_query_param_part; |
419 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
419 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
420 | 420 | } |
421 | - try{ |
|
421 | + try { |
|
422 | 422 | return $model->field_settings_for($field_name); |
423 | - }catch(\EE_Error $e){ |
|
423 | + } catch (\EE_Error $e) { |
|
424 | 424 | return null; |
425 | 425 | } |
426 | 426 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( |
|
100 | + if ( |
|
101 | 101 | apply_filters( |
102 | 102 | 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
103 | - ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
104 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) |
|
103 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
104 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
105 | 105 | ) |
106 | 106 | ) { |
107 | 107 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | //ok they're using the WP API with Basic Auth |
111 | 111 | $message = sprintf( |
112 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
112 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
113 | 113 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
114 | 114 | '</a>', |
115 | 115 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
116 | 116 | '<br/>' |
117 | 117 | ); |
118 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
119 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
120 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
118 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
119 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
120 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
121 | 121 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
122 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
122 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
123 | 123 | //and send the message to the site admin too |
124 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
125 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
124 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
125 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * appear the same as they always did |
131 | 131 | */ |
132 | 132 | protected static function _set_hooks_for_changes() { |
133 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
134 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
133 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
134 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
135 | 135 | //ignore the base parent class |
136 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
136 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
140 | - if ( class_exists( $full_classname )) { |
|
139 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
140 | + if (class_exists($full_classname)) { |
|
141 | 141 | $instance_of_class = new $full_classname; |
142 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
142 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
143 | 143 | $instance_of_class->set_hooks(); |
144 | 144 | } |
145 | 145 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
153 | 153 | */ |
154 | 154 | public static function register_routes() { |
155 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
156 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
157 | - foreach( $routes as $route ) { |
|
155 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
156 | + foreach ($relative_urls as $endpoint => $routes) { |
|
157 | + foreach ($routes as $route) { |
|
158 | 158 | register_rest_route( |
159 | 159 | $namespace, |
160 | 160 | $endpoint, |
161 | 161 | array( |
162 | - 'callback' => $route[ 'callback' ], |
|
163 | - 'methods' => $route[ 'methods' ], |
|
164 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
162 | + 'callback' => $route['callback'], |
|
163 | + 'methods' => $route['methods'], |
|
164 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
165 | 165 | ) |
166 | 166 | ); |
167 | 167 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * next time the WP API is used |
176 | 176 | */ |
177 | 177 | public static function invalidate_cached_route_data_on_version_change() { |
178 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
178 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
179 | 179 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
180 | 180 | } |
181 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
182 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
181 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
182 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
183 | 183 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
184 | 184 | } |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function invalidate_cached_route_data() { |
192 | 192 | //delete the saved EE REST API routes |
193 | - foreach( EED_Core_Rest_Api::versions_served() as $version => $hidden ){ |
|
194 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names . $version ); |
|
193 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
194 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function get_ee_route_data() { |
207 | 207 | $ee_routes = array(); |
208 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
209 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
208 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
209 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
210 | 210 | } |
211 | 211 | return $ee_routes; |
212 | 212 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @param boolean $hidden_endpoints |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
222 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
223 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
224 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
221 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
222 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
223 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
224 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
225 | 225 | } |
226 | 226 | return $ee_routes; |
227 | 227 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param boolean $hidden_endpoints |
236 | 236 | * @return mixed|null|void |
237 | 237 | */ |
238 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
238 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
239 | 239 | $instance = self::instance(); |
240 | 240 | $routes = apply_filters( |
241 | 241 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
242 | 242 | array_replace_recursive( |
243 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
244 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
245 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
246 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
243 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
244 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
245 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
246 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
247 | 247 | ) |
248 | 248 | ); |
249 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
249 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
250 | 250 | return $routes; |
251 | 251 | } |
252 | 252 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | public static function save_ee_routes() { |
260 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
260 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
261 | 261 | $instance = self::instance(); |
262 | 262 | $routes = apply_filters( |
263 | 263 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $instance->_register_rpc_routes() |
269 | 269 | ) |
270 | 270 | ); |
271 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
271 | + update_option(self::saved_routes_option_names, $routes, true); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | */ |
280 | 280 | protected function _register_model_routes() { |
281 | 281 | $model_routes = array( ); |
282 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
283 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
282 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
283 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
284 | 284 | } |
285 | 285 | return $model_routes; |
286 | 286 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param boolean $hidden_endpoint |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
295 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
294 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
295 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
296 | 296 | $models_to_register = apply_filters( |
297 | 297 | 'FHEE__EED_Core_REST_API___register_model_routes', |
298 | 298 | $model_version_info->models_for_requested_version() |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | unset($models_to_register['Extra_Meta']); |
302 | 302 | unset($models_to_register['Extra_Join']); |
303 | 303 | $model_routes = array(); |
304 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
305 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
304 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
305 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
306 | 306 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
307 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
308 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
309 | - $model_routes[ $plural_model_route ] = array( |
|
307 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
308 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
309 | + $model_routes[$plural_model_route] = array( |
|
310 | 310 | array( |
311 | 311 | 'callback' => array( |
312 | 312 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
313 | 313 | 'handle_request_get_all' ), |
314 | 314 | 'methods' => WP_REST_Server::READABLE, |
315 | 315 | 'hidden_endpoint' => $hidden_endpoint, |
316 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
316 | + 'args' => $this->_get_read_query_params($model, $version), |
|
317 | 317 | '_links' => array( |
318 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
318 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
319 | 319 | ) |
320 | 320 | ), |
321 | 321 | // array( |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | // 'hidden_endpoint' => $hidden_endpoint |
327 | 327 | // ) |
328 | 328 | ); |
329 | - $model_routes[ $singular_model_route ] = array( |
|
329 | + $model_routes[$singular_model_route] = array( |
|
330 | 330 | array( |
331 | 331 | 'callback' => array( |
332 | 332 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
333 | 333 | 'handle_request_get_one' ), |
334 | 334 | 'methods' => WP_REST_Server::READABLE, |
335 | 335 | 'hidden_endpoint' => $hidden_endpoint, |
336 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
336 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
337 | 337 | ), |
338 | 338 | // array( |
339 | 339 | // 'callback' => array( |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | // ), |
345 | 345 | ); |
346 | 346 | //@todo: also handle DELETE for a single item |
347 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
347 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
348 | 348 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
349 | 349 | $relation_name, |
350 | 350 | $relation_obj |
351 | 351 | ); |
352 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
352 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
353 | 353 | array( |
354 | 354 | 'callback' => array( |
355 | 355 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
356 | 356 | 'handle_request_get_related' ), |
357 | 357 | 'methods' => WP_REST_Server::READABLE, |
358 | 358 | 'hidden_endpoint' => $hidden_endpoint, |
359 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
359 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
360 | 360 | ), |
361 | 361 | // array( |
362 | 362 | // 'callback' => array( |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function _register_rpc_routes() { |
381 | 381 | $routes = array(); |
382 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
383 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
382 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
383 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
384 | 384 | } |
385 | 385 | return $routes; |
386 | 386 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param boolean $hidden_endpoint |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
394 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
395 | 395 | $this_versions_routes = array(); |
396 | 396 | //checkin endpoint |
397 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
397 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
398 | 398 | array( |
399 | 399 | 'callback' => array( |
400 | 400 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'force' => array( |
406 | 406 | 'required' => false, |
407 | 407 | 'default' => false, |
408 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
408 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ) |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $version |
425 | 425 | * @return array |
426 | 426 | */ |
427 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
427 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
428 | 428 | return apply_filters( |
429 | 429 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
430 | 430 | array( |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'calculate' => array( |
436 | 436 | 'required' => false, |
437 | 437 | 'default' => '', |
438 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
438 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | $model, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * @return array describing the args acceptable when querying this model |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
456 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
457 | 457 | $default_orderby = array(); |
458 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
459 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
458 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
459 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
460 | 460 | } |
461 | 461 | return array_merge( |
462 | - $this->_get_response_selection_query_params( $model, $version ), |
|
462 | + $this->_get_response_selection_query_params($model, $version), |
|
463 | 463 | array( |
464 | 464 | 'where' => array( |
465 | 465 | 'required' => false, |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function _register_config_routes() { |
498 | 498 | $config_routes = array(); |
499 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
500 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
499 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
500 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
501 | 501 | } |
502 | 502 | return $config_routes; |
503 | 503 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param boolean $hidden_endpoint |
509 | 509 | * @return array |
510 | 510 | */ |
511 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
511 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
512 | 512 | return array( |
513 | 513 | 'config' => array( |
514 | 514 | array( |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function _register_meta_routes() { |
540 | 540 | $meta_routes = array(); |
541 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
542 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
541 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
542 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
543 | 543 | } |
544 | 544 | return $meta_routes; |
545 | 545 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param boolean $hidden_endpoint |
551 | 551 | * @return array |
552 | 552 | */ |
553 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
553 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
554 | 554 | return array( |
555 | 555 | 'resources' => array( |
556 | 556 | array( |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | * @param array $route_data |
573 | 573 | * @return array |
574 | 574 | */ |
575 | - public static function hide_old_endpoints( $route_data ) { |
|
576 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
577 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
578 | - foreach( $routes as $route ) { |
|
579 | - if( $route[ 'hidden_endpoint' ] ) { |
|
580 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
581 | - unset( $route_data[ $full_route ] ); |
|
575 | + public static function hide_old_endpoints($route_data) { |
|
576 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
577 | + foreach ($relative_urls as $endpoint => $routes) { |
|
578 | + foreach ($routes as $route) { |
|
579 | + if ($route['hidden_endpoint']) { |
|
580 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
581 | + unset($route_data[$full_route]); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | */ |
618 | 618 | public static function latest_rest_api_version() { |
619 | 619 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
620 | - $versions_served_keys = array_keys( $versions_served ); |
|
621 | - return end( $versions_served_keys ); |
|
620 | + $versions_served_keys = array_keys($versions_served); |
|
621 | + return end($versions_served_keys); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -632,32 +632,32 @@ discard block |
||
632 | 632 | public static function versions_served() { |
633 | 633 | $versions_served = array(); |
634 | 634 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
635 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
636 | - reset( $possibly_served_versions ); |
|
637 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
638 | - $latest_version = end( $versions_served_historically ); |
|
639 | - reset( $versions_served_historically ); |
|
635 | + $lowest_compatible_version = end($possibly_served_versions); |
|
636 | + reset($possibly_served_versions); |
|
637 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
638 | + $latest_version = end($versions_served_historically); |
|
639 | + reset($versions_served_historically); |
|
640 | 640 | //for each version of core we have ever served: |
641 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
641 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
642 | 642 | //if it's not above the current core version, and it's compatible with the current version of core |
643 | - if( $key_versioned_endpoint == $latest_version ) { |
|
643 | + if ($key_versioned_endpoint == $latest_version) { |
|
644 | 644 | //don't hide the latest version in the index |
645 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
646 | - } else if( |
|
645 | + $versions_served[$key_versioned_endpoint] = false; |
|
646 | + } else if ( |
|
647 | 647 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
648 | 648 | && $key_versioned_endpoint >= $lowest_compatible_version |
649 | 649 | ) { |
650 | 650 | //include, but hide, previous versions which are still supported |
651 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
652 | - } elseif( |
|
651 | + $versions_served[$key_versioned_endpoint] = true; |
|
652 | + } elseif ( |
|
653 | 653 | apply_filters( |
654 | 654 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
655 | 655 | false, |
656 | 656 | $possibly_served_versions |
657 | 657 | ) |
658 | - ){ |
|
658 | + ) { |
|
659 | 659 | //if a version is no longer supported, don't include it in index or list of versions served |
660 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
660 | + $versions_served[$key_versioned_endpoint] = true; |
|
661 | 661 | } |
662 | 662 | } |
663 | 663 | return $versions_served; |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @return string |
671 | 671 | */ |
672 | 672 | public static function core_version() { |
673 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
673 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * @param WP $WP |
696 | 696 | * @return void |
697 | 697 | */ |
698 | - public function run( $WP ) { |
|
698 | + public function run($WP) { |
|
699 | 699 | |
700 | 700 | } |
701 | 701 |