Completed
Branch FET-9795-new-interfaces (ea072c)
by
unknown
51:56 queued 35:16
created
libraries/form_sections/inputs/EE_Select_Ajax_Model_Rest_Input.input.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 1 patch
Spacing   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -66,23 +66,23 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 1 patch
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_reminder_content.template.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -31,29 +31,29 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_reminder_content_admin.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Recipient_Details_Shortcodes.lib.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -64,14 +64,14 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +50 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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,58 +37,57 @@  discard block
 block discarded – undo
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_CODE]' => esc_html__( 'Parses to the registration code of the recipient for the message.', 'event_espresso' ),
47
-			'[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__( 'Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso' ),
48
-			'[RECIPIENT_PHONE_NUMBER]' => esc_html__( 'The Phone Number for the recipient of the message.', 'event_espresso' ),
49
-			'[RECIPIENT_ADDRESS]' => esc_html__( 'The Address for the recipient of the message.', 'event_espresso' ),
50
-			'[RECIPIENT_ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the recipient of the message.', 'event_espresso' ),
51
-			'[RECIPIENT_CITY]' => esc_html__( 'The city for the recipient of the message.', 'event_espresso' ),
52
-			'[RECIPIENT_ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso' ),
53
-			'[RECIPIENT_ADDRESS_STATE]' => esc_html__( 'The state/province for the recipient of the message.', 'event_espresso' ),
54
-			'[RECIPIENT_COUNTRY]' => esc_html__( 'The country for the recipient of the message.', 'event_espresso' ),
55
-			'[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' ),
56
-			'[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_CODE]' => esc_html__('Parses to the registration code of the recipient for the message.', 'event_espresso'),
47
+			'[RECIPIENT_EDIT_REGISTRATION_LINK]' => esc_html__('Parses to a link for frontend editing of the registration for the recipient.', 'event_espresso'),
48
+			'[RECIPIENT_PHONE_NUMBER]' => esc_html__('The Phone Number for the recipient of the message.', 'event_espresso'),
49
+			'[RECIPIENT_ADDRESS]' => esc_html__('The Address for the recipient of the message.', 'event_espresso'),
50
+			'[RECIPIENT_ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the recipient of the message.', 'event_espresso'),
51
+			'[RECIPIENT_CITY]' => esc_html__('The city for the recipient of the message.', 'event_espresso'),
52
+			'[RECIPIENT_ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the recipient of the message.', 'event_espresso'),
53
+			'[RECIPIENT_ADDRESS_STATE]' => esc_html__('The state/province for the recipient of the message.', 'event_espresso'),
54
+			'[RECIPIENT_COUNTRY]' => esc_html__('The country for the recipient of the message.', 'event_espresso'),
55
+			'[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'),
56
+			'[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')
57 57
 			);
58 58
 	}
59 59
 
60 60
 
61 61
 
62
-	protected function _parser( $shortcode ) {
62
+	protected function _parser($shortcode) {
63 63
 
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'] )
67
+		                    && is_array($this->_data)
68
+		                    && isset($this->_data['data'])
69 69
 		                    && $this->_data['data'] instanceof EE_Messages_Addressee
70
-			? $this->_data['data'] :
71
-			$this->_recipient;
70
+			? $this->_data['data'] : $this->_recipient;
72 71
 		$this->_recipient = ! $this->_recipient instanceof EE_Messages_Addressee
73
-		                    && ! empty( $this->_extra_data['data'] )
72
+		                    && ! empty($this->_extra_data['data'])
74 73
 		                    && $this->_extra_data['data'] instanceof EE_Messages_Addressee
75 74
 			? $this->_extra_data['data']
76 75
 			: $this->_recipient;
77 76
 
78
-		if ( ! $this->_recipient instanceof EE_Messages_Addressee ) {
77
+		if ( ! $this->_recipient instanceof EE_Messages_Addressee) {
79 78
 			return '';
80 79
 		}
81 80
 
82 81
 		$attendee = $this->_recipient->att_obj;
83
-		if ( ! $attendee instanceof EE_Attendee ) {
82
+		if ( ! $attendee instanceof EE_Attendee) {
84 83
 			return '';
85 84
 		}
86 85
 
87
-		$this->_registrations_for_recipient = isset( $this->_recipient->attendees[ $attendee->ID() ]['reg_objs'] )
88
-			? $this->_recipient->attendees[ $attendee->ID() ]['reg_objs']
86
+		$this->_registrations_for_recipient = isset($this->_recipient->attendees[$attendee->ID()]['reg_objs'])
87
+			? $this->_recipient->attendees[$attendee->ID()]['reg_objs']
89 88
 			: array();
90 89
 
91
-		switch ( $shortcode ) {
90
+		switch ($shortcode) {
92 91
 			case '[RECIPIENT_FNAME]' :
93 92
 				return $attendee->fname();
94 93
 				break;
@@ -102,14 +101,14 @@  discard block
 block discarded – undo
102 101
 				break;
103 102
 
104 103
 			case '[RECIPIENT_REGISTRATION_CODE]' :
105
-				if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) {
104
+				if ( ! $this->_recipient->reg_obj instanceof EE_Registration) {
106 105
 					return '';
107 106
 				}
108 107
 				return $this->_get_reg_code();
109 108
 				break;
110 109
 
111 110
 			case '[RECIPIENT_EDIT_REGISTRATION_LINK]' :
112
-				if ( ! $this->_recipient->reg_obj instanceof EE_Registration ) {
111
+				if ( ! $this->_recipient->reg_obj instanceof EE_Registration) {
113 112
 					return '';
114 113
 				}
115 114
 				return $this->_recipient->reg_obj->edit_attendee_information_url();
@@ -151,23 +150,23 @@  discard block
 block discarded – undo
151 150
 				break;
152 151
 		}
153 152
 
154
-		if ( strpos( $shortcode, '[RECIPIENT_ANSWER_*' ) !== false ) {
155
-			$shortcode = str_replace( '[RECIPIENT_ANSWER_*', '', $shortcode );
156
-			$shortcode = trim( str_replace( ']', '', $shortcode ) );
153
+		if (strpos($shortcode, '[RECIPIENT_ANSWER_*') !== false) {
154
+			$shortcode = str_replace('[RECIPIENT_ANSWER_*', '', $shortcode);
155
+			$shortcode = trim(str_replace(']', '', $shortcode));
157 156
 
158 157
 
159 158
 			//now let's figure out what question has this text
160
-			if ( empty( $this->_recipient->questions ) || ! $this->_recipient->reg_obj instanceof EE_Registration ) {
159
+			if (empty($this->_recipient->questions) || ! $this->_recipient->reg_obj instanceof EE_Registration) {
161 160
 				return '';
162 161
 			}
163 162
 
164
-			foreach ( $this->_recipient->questions as $ansid => $question ) {
163
+			foreach ($this->_recipient->questions as $ansid => $question) {
165 164
 				if (
166 165
 					$question instanceof EE_Question
167 166
 					&& $question->display_text() == $shortcode
168
-					&& isset( $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ] )
167
+					&& isset($this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid])
169 168
 				) {
170
-					return $this->_recipient->registrations[ $this->_recipient->reg_obj->ID() ]['ans_objs'][ $ansid ]->get_pretty( 'ANS_value', 'no_wpautop' );
169
+					return $this->_recipient->registrations[$this->_recipient->reg_obj->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', 'no_wpautop');
171 170
 				}
172 171
 			}
173 172
 		}
@@ -198,53 +197,53 @@  discard block
 block discarded – undo
198 197
 	protected function _get_reg_code() {
199 198
 
200 199
 		//if only one related registration for the recipient then just return that reg code.
201
-		if ( count( $this->_registrations_for_recipient ) <= 1 )  {
200
+		if (count($this->_registrations_for_recipient) <= 1) {
202 201
 			return $this->_recipient->reg_obj->reg_code();
203 202
 		}
204 203
 
205 204
 		//k more than one registration so let's see if we can get specific to context
206 205
 		//are we parsing event_list?
207
-		if ( $this->_data instanceof EE_Event ) {
206
+		if ($this->_data instanceof EE_Event) {
208 207
 			$reg_code = array();
209 208
 			//loop through registrations for recipient and see if there is a match for this event
210
-			foreach ( $this->_registrations_for_recipient as $reg ) {
211
-				if ( $reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID() ) {
209
+			foreach ($this->_registrations_for_recipient as $reg) {
210
+				if ($reg instanceof EE_Registration && $reg->event_ID() == $this->_data->ID()) {
212 211
 					$reg_code[] = $reg->reg_code();
213 212
 				}
214 213
 			}
215
-			return implode( ', ', $reg_code );
214
+			return implode(', ', $reg_code);
216 215
 		}
217 216
 
218 217
 		//are we parsing ticket list?
219
-		if ( $this->_data instanceof EE_Ticket ) {
218
+		if ($this->_data instanceof EE_Ticket) {
220 219
 			$reg_code = array();
221 220
 			//loop through each registration for recipient and see if there is a match for this ticket
222
-			foreach ( $this->_registrations_for_recipient as $reg ) {
223
-				if ( $reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID() ) {
221
+			foreach ($this->_registrations_for_recipient as $reg) {
222
+				if ($reg instanceof EE_Registration && $reg->ticket_ID() == $this->_data->ID()) {
224 223
 					$reg_code = $reg->reg_code();
225 224
 				}
226 225
 			}
227
-			return implode( ', ', $reg_code );
226
+			return implode(', ', $reg_code);
228 227
 		}
229 228
 
230 229
 		//do we have a specific reg_obj?  Let's use it
231
-		if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) {
230
+		if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) {
232 231
 			return $this->_data->reg_obj->reg_code();
233 232
 		}
234 233
 
235 234
 		//do we have a specific reg_obj?  Let's use it
236
-		if ( $this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration ) {
235
+		if ($this->_data instanceof EE_Messages_Addressee && $this->_data->reg_obj instanceof EE_Registration) {
237 236
 			return $this->_data->reg_obj->reg_code();
238 237
 		}
239 238
 
240 239
 		//not able to determine the single reg code so let's return a comma delimited list of reg codes.
241 240
 		$reg_code = array();
242
-		foreach ( $this->_registrations_for_recipient as $reg ) {
243
-			if ( $reg instanceof EE_Registration ) {
241
+		foreach ($this->_registrations_for_recipient as $reg) {
242
+			if ($reg instanceof EE_Registration) {
244 243
 				$reg_code[] = $reg->reg_code();
245 244
 			}
246 245
 		}
247
-		return implode( ', ', $reg_code );
246
+		return implode(', ', $reg_code);
248 247
 	}
249 248
 
250 249
 
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Attendee_Shortcodes.lib.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 
42 42
 	/**
43 43
 	 * EE_Attendee_Shortcodes constructor.
44
-	*/
44
+	 */
45 45
 	public function __construct() {
46 46
 		parent::__construct();
47 47
 	}
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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,25 +49,25 @@  discard block
 block discarded – undo
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_CODE]' => esc_html__( 'Unique Registration Code for the registration', 'event_espresso' ),
60
-			'[REGISTRATION_STATUS_ID]' => esc_html__( 'Parses to the registration status for the attendee', 'event_espresso' ),
61
-			'[REGISTRATION_STATUS_LABEL]' => esc_html__( 'Parses to the status label for the registrant', 'event_espresso' ),
62
-			'[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__( 'Parses to the total amount paid for this registration.', 'event_espresso' ),
63
-			'[FRONTEND_EDIT_REG_LINK]' => esc_html__( 'Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso' ),
64
-			'[PHONE_NUMBER]' => esc_html__( 'The Phone Number for the Registration.', 'event_espresso' ),
65
-			'[ADDRESS]' => esc_html__( 'The Address for the Registration', 'event_espresso' ),
66
-			'[ADDRESS2]' => esc_html__( 'Whatever was in the address 2 field for the registration.', 'event_espresso' ),
67
-			'[CITY]' => esc_html__( 'The city for the registration.', 'event_espresso' ),
68
-			'[ZIP_PC]' => esc_html__( 'The ZIP (or Postal) Code for the Registration.', 'event_espresso' ),
69
-			'[ADDRESS_STATE]' => esc_html__( 'The state/province for the registration.', 'event_espresso' ),
70
-			'[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_CODE]' => esc_html__('Unique Registration Code for the registration', 'event_espresso'),
60
+			'[REGISTRATION_STATUS_ID]' => esc_html__('Parses to the registration status for the attendee', 'event_espresso'),
61
+			'[REGISTRATION_STATUS_LABEL]' => esc_html__('Parses to the status label for the registrant', 'event_espresso'),
62
+			'[REGISTRATION_TOTAL_AMOUNT_PAID]' => esc_html__('Parses to the total amount paid for this registration.', 'event_espresso'),
63
+			'[FRONTEND_EDIT_REG_LINK]' => esc_html__('Generates a link for the given registration to edit this registration details on the frontend.', 'event_espresso'),
64
+			'[PHONE_NUMBER]' => esc_html__('The Phone Number for the Registration.', 'event_espresso'),
65
+			'[ADDRESS]' => esc_html__('The Address for the Registration', 'event_espresso'),
66
+			'[ADDRESS2]' => esc_html__('Whatever was in the address 2 field for the registration.', 'event_espresso'),
67
+			'[CITY]' => esc_html__('The city for the registration.', 'event_espresso'),
68
+			'[ZIP_PC]' => esc_html__('The ZIP (or Postal) Code for the Registration.', 'event_espresso'),
69
+			'[ADDRESS_STATE]' => esc_html__('The state/province for the registration.', 'event_espresso'),
70
+			'[COUNTRY]' => esc_html__('The country for the registration.', 'event_espresso')
71 71
 			);
72 72
 	}
73 73
 
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 	 * @return string
82 82
 	 * @throws \EE_Error
83 83
 	 */
84
-	protected function _parser( $shortcode ) {
84
+	protected function _parser($shortcode) {
85 85
 
86 86
 
87
-		$this->_xtra = ! empty( $this->_extra_data ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
87
+		$this->_xtra = ! empty($this->_extra_data) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
88 88
 			? $this->_extra_data['data']
89 89
 			: null;
90 90
 
@@ -93,34 +93,34 @@  discard block
 block discarded – undo
93 93
 			? null
94 94
 			: $this->_data;
95 95
 
96
-		if ( ! $registration instanceof EE_Registration ) {
96
+		if ( ! $registration instanceof EE_Registration) {
97 97
 			//let's attempt to get the txn_id for the error message.
98
-			$txn_id = isset( $this->_xtra->txn ) && $this->_xtra->txn instanceof EE_Transaction
98
+			$txn_id = isset($this->_xtra->txn) && $this->_xtra->txn instanceof EE_Transaction
99 99
 				? $this->_xtra->txn->ID()
100
-				: esc_html__( 'Unknown', 'event_espresso' );
101
-			$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' );
100
+				: esc_html__('Unknown', 'event_espresso');
101
+			$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');
102 102
 			$dev_msg = sprintf(
103
-				esc_html__( 'The transaction ID for this request is: %s', 'event_espresso' ),
103
+				esc_html__('The transaction ID for this request is: %s', 'event_espresso'),
104 104
 				$txn_id
105 105
 			);
106
-			throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" );
106
+			throw new EE_Error("{$msg}||{$msg} {$dev_msg}");
107 107
 		}
108 108
 
109 109
 		//attendee obj for this registration
110
-		$attendee = isset( $this->_xtra->registrations[ $registration->ID() ]['att_obj'] )
111
-			?  $this->_xtra->registrations[ $registration->ID() ]['att_obj']
112
-			: null ;
110
+		$attendee = isset($this->_xtra->registrations[$registration->ID()]['att_obj'])
111
+			? $this->_xtra->registrations[$registration->ID()]['att_obj']
112
+			: null;
113 113
 
114
-		if ( ! $attendee instanceof EE_Attendee ) {
115
-			$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' );
114
+		if ( ! $attendee instanceof EE_Attendee) {
115
+			$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');
116 116
 			$dev_msg = sprintf(
117
-				esc_html__( 'The registration ID for this request is: %s', 'event_espresso' ),
117
+				esc_html__('The registration ID for this request is: %s', 'event_espresso'),
118 118
 				$registration->ID()
119 119
 			);
120
-			throw new EE_Error( "{$msg}||{$msg} {$dev_msg}" );
120
+			throw new EE_Error("{$msg}||{$msg} {$dev_msg}");
121 121
 		}
122 122
 
123
-		switch ( $shortcode ) {
123
+		switch ($shortcode) {
124 124
 
125 125
 			case '[FNAME]' :
126 126
 				return $attendee->fname();
Please login to merge, or discard this patch.
core/libraries/rest_api/Model_Data_Translator.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
174 174
 			$original_value,
175 175
 			$requested_version
176 176
 		);
177
-    }
177
+	}
178 178
 
179 179
 
180 180
 
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Read.php 1 patch
Spacing   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\libraries\rest_api\Rest_Exception;
7 7
 use EventEspresso\core\libraries\rest_api\Model_Data_Translator;
8 8
 
9
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
10
-	exit( 'No direct script access allowed' );
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @param \WP_REST_Request $request
47 47
 	 * @return \WP_REST_Response|\WP_Error
48 48
 	 */
49
-	public static function handle_request_get_all( \WP_REST_Request $request) {
49
+	public static function handle_request_get_all(\WP_REST_Request $request) {
50 50
 		$controller = new Read();
51
-		try{
51
+		try {
52 52
 			$matches = $controller->parse_route(
53 53
 				$request->get_route(),
54
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~',
55
-				array( 'version', 'model' )
54
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~',
55
+				array('version', 'model')
56 56
 			);
57
-			$controller->set_requested_version( $matches[ 'version' ] );
58
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
59
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
57
+			$controller->set_requested_version($matches['version']);
58
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
59
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
60 60
 				return $controller->send_response(
61 61
 					new \WP_Error(
62 62
 						'endpoint_parsing_error',
63 63
 						sprintf(
64
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
64
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
65 65
 							$model_name_singular
66 66
 						)
67 67
 					)
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 			return $controller->send_response(
71 71
 					$controller->get_entities_from_model(
72
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
72
+							$controller->get_model_version_info()->load_model($model_name_singular),
73 73
 							$request
74 74
 					)
75 75
 			);
76
-		} catch( \Exception $e ) {
77
-			return $controller->send_response( $e );
76
+		} catch (\Exception $e) {
77
+			return $controller->send_response($e);
78 78
 		}
79 79
 	}
80 80
 
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
 	 * @param \WP_REST_Request $request
85 85
 	 * @return \WP_REST_Response|\WP_Error
86 86
 	 */
87
-	public static function handle_request_get_one( \WP_REST_Request $request ) {
87
+	public static function handle_request_get_one(\WP_REST_Request $request) {
88 88
 		$controller = new Read();
89
-		try{
89
+		try {
90 90
 			$matches = $controller->parse_route(
91 91
 				$request->get_route(),
92
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~',
93
-				array( 'version', 'model', 'id' ) );
94
-			$controller->set_requested_version( $matches[ 'version' ] );
95
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
96
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
92
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~',
93
+				array('version', 'model', 'id') );
94
+			$controller->set_requested_version($matches['version']);
95
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
96
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
97 97
 				return $controller->send_response(
98 98
 					new \WP_Error(
99 99
 						'endpoint_parsing_error',
100 100
 						sprintf(
101
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
101
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
102 102
 							$model_name_singular
103 103
 						)
104 104
 					)
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			return $controller->send_response(
108 108
 					$controller->get_entity_from_model(
109
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
109
+							$controller->get_model_version_info()->load_model($model_name_singular),
110 110
 							$request
111 111
 						)
112 112
 				);
113
-		} catch( \Exception $e ) {
114
-			return $controller->send_response( $e );
113
+		} catch (\Exception $e) {
114
+			return $controller->send_response($e);
115 115
 		}
116 116
 	}
117 117
 
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
 	 * @param \WP_REST_Request $request
124 124
 	 * @return \WP_REST_Response|\WP_Error
125 125
 	 */
126
-	public static function handle_request_get_related( \WP_REST_Request $request ) {
126
+	public static function handle_request_get_related(\WP_REST_Request $request) {
127 127
 		$controller = new Read();
128
-		try{
128
+		try {
129 129
 			$matches = $controller->parse_route(
130 130
 				$request->get_route(),
131
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~',
132
-				array( 'version', 'model', 'id', 'related_model' )
131
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~',
132
+				array('version', 'model', 'id', 'related_model')
133 133
 			);
134
-			$controller->set_requested_version( $matches[ 'version' ] );
135
-			$main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
136
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) {
134
+			$controller->set_requested_version($matches['version']);
135
+			$main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
136
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) {
137 137
 				return $controller->send_response(
138 138
 					new \WP_Error(
139 139
 						'endpoint_parsing_error',
140 140
 						sprintf(
141
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
141
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
142 142
 							$main_model_name_singular
143 143
 						)
144 144
 					)
145 145
 				);
146 146
 			}
147
-			$main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular );
147
+			$main_model = $controller->get_model_version_info()->load_model($main_model_name_singular);
148 148
 			//assume the related model name is plural and try to find the model's name
149
-			$related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] );
150
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
149
+			$related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']);
150
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
151 151
 				//so the word didn't singularize well. Maybe that's just because it's a singular word?
152
-				$related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] );
152
+				$related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']);
153 153
 			}
154
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
154
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
155 155
 				return $controller->send_response(
156 156
 					new \WP_Error(
157 157
 						'endpoint_parsing_error',
158 158
 						sprintf(
159
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
159
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
160 160
 							$related_model_name_singular
161 161
 						)
162 162
 					)
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 
166 166
 			return $controller->send_response(
167 167
 					$controller->get_entities_from_relation(
168
-						$request->get_param( 'id' ),
169
-						$main_model->related_settings_for( $related_model_name_singular ) ,
168
+						$request->get_param('id'),
169
+						$main_model->related_settings_for($related_model_name_singular),
170 170
 						$request
171 171
 					)
172 172
 				);
173
-		} catch( \Exception $e ) {
174
-			return $controller->send_response( $e );
173
+		} catch (\Exception $e) {
174
+			return $controller->send_response($e);
175 175
 		}
176 176
 	}
177 177
 
@@ -184,28 +184,28 @@  discard block
 block discarded – undo
184 184
 	 * @param \WP_REST_Request $request
185 185
 	 * @return array|\WP_Error
186 186
 	 */
187
-	public function get_entities_from_model( $model, $request) {
188
-		$query_params = $this->create_model_query_params( $model, $request->get_params() );
189
-		if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) {
190
-			$model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() );
187
+	public function get_entities_from_model($model, $request) {
188
+		$query_params = $this->create_model_query_params($model, $request->get_params());
189
+		if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) {
190
+			$model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
191 191
 			return new \WP_Error(
192
-				sprintf( 'rest_%s_cannot_list', $model_name_plural ),
192
+				sprintf('rest_%s_cannot_list', $model_name_plural),
193 193
 				sprintf(
194
-					__( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ),
194
+					__('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'),
195 195
 					$model_name_plural,
196
-					Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] )
196
+					Capabilities::get_missing_permissions_string($model, $query_params['caps'])
197 197
 				),
198
-				array( 'status' => 403 )
198
+				array('status' => 403)
199 199
 			);
200 200
 		}
201
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
202
-			$this->_set_headers_from_query_params( $model, $query_params );
201
+		if ( ! $request->get_header('no_rest_headers')) {
202
+			$this->_set_headers_from_query_params($model, $query_params);
203 203
 		}
204 204
 		/** @type array $results */
205
-		$results = $model->get_all_wpdb_results( $query_params );
205
+		$results = $model->get_all_wpdb_results($query_params);
206 206
 		$nice_results = array( );
207
-		foreach ( $results as $result ) {
208
-			$nice_results[ ] = $this->create_entity_from_wpdb_result(
207
+		foreach ($results as $result) {
208
+			$nice_results[] = $this->create_entity_from_wpdb_result(
209 209
 					$model,
210 210
 					$result,
211 211
 					$request
@@ -225,64 +225,64 @@  discard block
 block discarded – undo
225 225
 	 * @param \WP_REST_Request $request
226 226
 	 * @return array|\WP_Error
227 227
 	 */
228
-	public function get_entities_from_relation( $id,  $relation, $request ) {
229
-		$context = $this->validate_context( $request->get_param( 'caps' ));
228
+	public function get_entities_from_relation($id, $relation, $request) {
229
+		$context = $this->validate_context($request->get_param('caps'));
230 230
 		$model = $relation->get_this_model();
231 231
 		$related_model = $relation->get_other_model();
232 232
 		//check if they can access the 1st model object
233
-		$query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 );
234
-		if( $model instanceof \EEM_Soft_Delete_Base ){
233
+		$query_params = array(array($model->primary_key_name() => $id), 'limit' => 1);
234
+		if ($model instanceof \EEM_Soft_Delete_Base) {
235 235
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
236 236
 		}
237 237
 		$restricted_query_params = $query_params;
238
-		$restricted_query_params[ 'caps' ] = $context;
239
-		$this->_set_debug_info( 'main model query params', $restricted_query_params );
240
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) );
238
+		$restricted_query_params['caps'] = $context;
239
+		$this->_set_debug_info('main model query params', $restricted_query_params);
240
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context));
241 241
 
242
-		if(
242
+		if (
243 243
 			! (
244
-				Capabilities::current_user_has_partial_access_to( $related_model, $context )
245
-				&& $model->exists( $restricted_query_params )
244
+				Capabilities::current_user_has_partial_access_to($related_model, $context)
245
+				&& $model->exists($restricted_query_params)
246 246
 			)
247
-		){
248
-			if( $relation instanceof \EE_Belongs_To_Relation ) {
249
-				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
250
-			}else{
251
-				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
247
+		) {
248
+			if ($relation instanceof \EE_Belongs_To_Relation) {
249
+				$related_model_name_maybe_plural = strtolower($related_model->get_this_model_name());
250
+			} else {
251
+				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name());
252 252
 			}
253 253
 			return new \WP_Error(
254
-				sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ),
254
+				sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural),
255 255
 				sprintf(
256
-					__(	'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ),
256
+					__('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'),
257 257
 					$related_model_name_maybe_plural,
258 258
 					$relation->get_this_model()->get_this_model_name(),
259 259
 					implode(
260 260
 						',',
261 261
 						array_keys(
262
-							Capabilities::get_missing_permissions( $related_model, $context )
262
+							Capabilities::get_missing_permissions($related_model, $context)
263 263
 						)
264 264
 					)
265 265
 				),
266
-				array( 'status' => 403 )
266
+				array('status' => 403)
267 267
 			);
268 268
 		}
269
-		$query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() );
270
-		$query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id;
271
-		$query_params[ 'default_where_conditions' ] = 'none';
272
-		$query_params[ 'caps' ] = $context;
273
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
274
-			$this->_set_headers_from_query_params( $relation->get_other_model(), $query_params );
269
+		$query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params());
270
+		$query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id;
271
+		$query_params['default_where_conditions'] = 'none';
272
+		$query_params['caps'] = $context;
273
+		if ( ! $request->get_header('no_rest_headers')) {
274
+			$this->_set_headers_from_query_params($relation->get_other_model(), $query_params);
275 275
 		}
276 276
 		/** @type array $results */
277
-		$results = $relation->get_other_model()->get_all_wpdb_results( $query_params );
277
+		$results = $relation->get_other_model()->get_all_wpdb_results($query_params);
278 278
 		$nice_results = array();
279
-		foreach( $results as $result ) {
279
+		foreach ($results as $result) {
280 280
 			$nice_result = $this->create_entity_from_wpdb_result(
281 281
 				$relation->get_other_model(),
282 282
 				$result,
283 283
 				$request
284 284
 			);
285
-			if( $relation instanceof \EE_HABTM_Relation ) {
285
+			if ($relation instanceof \EE_HABTM_Relation) {
286 286
 				//put the unusual stuff (properties from the HABTM relation) first, and make sure
287 287
 				//if there are conflicts we prefer the properties from the main model
288 288
 				$join_model_result = $this->create_entity_from_wpdb_result(
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
 					$result,
291 291
 					$request
292 292
 				);
293
-				$joined_result = array_merge( $nice_result, $join_model_result );
293
+				$joined_result = array_merge($nice_result, $join_model_result);
294 294
 				//but keep the meta stuff from the main model
295
-				if( isset( $nice_result['meta'] ) ){
295
+				if (isset($nice_result['meta'])) {
296 296
 					$joined_result['meta'] = $nice_result['meta'];
297 297
 				}
298 298
 				$nice_result = $joined_result;
299 299
 			}
300 300
 			$nice_results[] = $nice_result;
301 301
 		}
302
-		if( $relation instanceof \EE_Belongs_To_Relation ){
303
-			return array_shift( $nice_results );
304
-		}else{
302
+		if ($relation instanceof \EE_Belongs_To_Relation) {
303
+			return array_shift($nice_results);
304
+		} else {
305 305
 			return $nice_results;
306 306
 		}
307 307
 	}
@@ -314,30 +314,30 @@  discard block
 block discarded – undo
314 314
 	 * @param array $query_params
315 315
 	 * @return void
316 316
 	 */
317
-	protected function _set_headers_from_query_params( $model, $query_params ) {
318
-		$this->_set_debug_info( 'model query params', $query_params );
319
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) );
317
+	protected function _set_headers_from_query_params($model, $query_params) {
318
+		$this->_set_debug_info('model query params', $query_params);
319
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps']));
320 320
 		//normally the limit to a 2-part array, where the 2nd item is the limit
321
-		if( ! isset( $query_params[ 'limit' ] ) ) {
322
-			$query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
321
+		if ( ! isset($query_params['limit'])) {
322
+			$query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
323 323
 		}
324
-		if( is_array( $query_params[ 'limit' ] )  ) {
325
-			$limit_parts = $query_params[ 'limit' ];
324
+		if (is_array($query_params['limit'])) {
325
+			$limit_parts = $query_params['limit'];
326 326
 		} else {
327
-			$limit_parts = explode(',', $query_params[ 'limit' ] );
328
-			if( count( $limit_parts ) == 1 ){
329
-				$limit_parts = array(0, $limit_parts[ 0 ] );
327
+			$limit_parts = explode(',', $query_params['limit']);
328
+			if (count($limit_parts) == 1) {
329
+				$limit_parts = array(0, $limit_parts[0]);
330 330
 			}
331 331
 		}
332 332
 		//remove the group by and having parts of the query, as those will
333 333
 		//make the sql query return an array of values, instead of just a single value
334
-		unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] );
335
-		$count = $model->count( $query_params, null, true );
334
+		unset($query_params['group_by'], $query_params['having'], $query_params['limit']);
335
+		$count = $model->count($query_params, null, true);
336 336
 
337
-		$pages = $count / $limit_parts[ 1 ];
338
-		$this->_set_response_header( 'Total', $count, false );
339
-		$this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false );
340
-		$this->_set_response_header( 'TotalPages', ceil( $pages ), false );
337
+		$pages = $count / $limit_parts[1];
338
+		$this->_set_response_header('Total', $count, false);
339
+		$this->_set_response_header('PageSize', $limit_parts[1], false);
340
+		$this->_set_response_header('TotalPages', ceil($pages), false);
341 341
 	}
342 342
 
343 343
 
@@ -350,47 +350,47 @@  discard block
 block discarded – undo
350 350
 	 * @param string $deprecated no longer used
351 351
 	 * @return array ready for being converted into json for sending to client
352 352
 	 */
353
-	public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) {
354
-		if( ! $rest_request instanceof \WP_REST_Request ) {
353
+	public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) {
354
+		if ( ! $rest_request instanceof \WP_REST_Request) {
355 355
 			//ok so this was called in the old style, where the 3rd arg was
356 356
 			//$include, and the 4th arg was $context
357 357
 			//now setup the request just to avoid fatal errors, although we won't be able
358 358
 			//to truly make use of it because it's kinda devoid of info
359 359
 			$rest_request = new \WP_REST_Request();
360
-			$rest_request->set_param( 'include', $rest_request );
361
-			$rest_request->set_param( 'caps', $deprecated );
360
+			$rest_request->set_param('include', $rest_request);
361
+			$rest_request->set_param('caps', $deprecated);
362 362
 		}
363
-		if( $rest_request->get_param( 'caps' ) == null ) {
364
-			$rest_request->set_param( 'caps', \EEM_Base::caps_read );
363
+		if ($rest_request->get_param('caps') == null) {
364
+			$rest_request->set_param('caps', \EEM_Base::caps_read);
365 365
 		}
366
-		$entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row );
367
-		$entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array );
368
-		$entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array );
369
-		$entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request );
370
-		$entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array );
366
+		$entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row);
367
+		$entity_array = $this->_add_extra_fields($model, $db_row, $entity_array);
368
+		$entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array);
369
+		$entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request);
370
+		$entity_array = $this->_include_requested_models($model, $rest_request, $entity_array);
371 371
 		$entity_array = apply_filters(
372 372
 			'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal',
373 373
 			$entity_array,
374 374
 			$model,
375
-			$rest_request->get_param( 'caps' ),
375
+			$rest_request->get_param('caps'),
376 376
 			$rest_request,
377 377
 			$this
378 378
 		);
379 379
 		$result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields(
380 380
 			$entity_array,
381 381
 			$model,
382
-			$rest_request->get_param( 'caps' ),
382
+			$rest_request->get_param('caps'),
383 383
 			$this->get_model_version_info()
384 384
 		);
385 385
 		$this->_set_debug_info(
386 386
 			'inaccessible fields',
387
-			array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) )
387
+			array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields))
388 388
 		);
389 389
 		return apply_filters(
390 390
 			'FHEE__Read__create_entity_from_wpdb_results__entity_return',
391 391
 			$result_without_inaccessible_fields,
392 392
 			$model,
393
-			$rest_request->get_param( 'caps' )
393
+			$rest_request->get_param('caps')
394 394
 		);
395 395
 	}
396 396
 
@@ -402,39 +402,39 @@  discard block
 block discarded – undo
402 402
 	 * @param array $db_row
403 403
 	 * @return array entity mostly ready for converting to JSON and sending in the response
404 404
 	 */
405
-	protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) {
406
-		$result = $model->deduce_fields_n_values_from_cols_n_values( $db_row );
407
-		$result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) );
408
-		foreach( $result as $field_name => $raw_field_value ) {
405
+	protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) {
406
+		$result = $model->deduce_fields_n_values_from_cols_n_values($db_row);
407
+		$result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model));
408
+		foreach ($result as $field_name => $raw_field_value) {
409 409
 			$field_obj = $model->field_settings_for($field_name);
410
-			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
411
-			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
412
-				unset( $result[ $field_name ] );
413
-			}elseif(
414
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
415
-			){
416
-				$result[ $field_name ] = array(
417
-					'raw' => $field_obj->prepare_for_get( $field_value ),
418
-					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
410
+			$field_value = $field_obj->prepare_for_set_from_db($raw_field_value);
411
+			if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) {
412
+				unset($result[$field_name]);
413
+			}elseif (
414
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format())
415
+			) {
416
+				$result[$field_name] = array(
417
+					'raw' => $field_obj->prepare_for_get($field_value),
418
+					'rendered' => $field_obj->prepare_for_pretty_echoing($field_value)
419 419
 				);
420
-			}elseif(
421
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
422
-			){
423
-				$result[ $field_name ] = array(
424
-					'raw' => $field_obj->prepare_for_get( $field_value ),
425
-					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
420
+			}elseif (
421
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format())
422
+			) {
423
+				$result[$field_name] = array(
424
+					'raw' => $field_obj->prepare_for_get($field_value),
425
+					'pretty' => $field_obj->prepare_for_pretty_echoing($field_value)
426 426
 				);
427
-			} elseif ( $field_obj instanceof \EE_Datetime_Field ) {
428
-				if( $field_value instanceof \DateTime ) {
427
+			} elseif ($field_obj instanceof \EE_Datetime_Field) {
428
+				if ($field_value instanceof \DateTime) {
429 429
 					$timezone = $field_value->getTimezone();
430
-					$field_value->setTimezone( new \DateTimeZone( 'UTC' ) );
431
-					$result[ $field_name . '_gmt' ] = Model_Data_Translator::prepare_field_value_for_json(
430
+					$field_value->setTimezone(new \DateTimeZone('UTC'));
431
+					$result[$field_name.'_gmt'] = Model_Data_Translator::prepare_field_value_for_json(
432 432
 						$field_obj,
433 433
 						$field_value,
434 434
 						$this->get_model_version_info()->requested_version()
435 435
 					);
436
-					$field_value->setTimezone( $timezone );
437
-					$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
436
+					$field_value->setTimezone($timezone);
437
+					$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
438 438
 						$field_obj,
439 439
 						$field_value,
440 440
 						$this->get_model_version_info()->requested_version()
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 				}
443 443
 
444 444
 			} else {
445
-				$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
445
+				$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
446 446
 					$field_obj,
447
-					$field_obj->prepare_for_get( $field_value ),
447
+					$field_obj->prepare_for_get($field_value),
448 448
 					$this->get_model_version_info()->requested_version()
449 449
 				);
450 450
 			}
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 * @param array $entity_array
460 460
 	 * @return array modified entity
461 461
 	 */
462
-	protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) {
463
-		if( $model instanceof \EEM_CPT_Base ) {
464
-			$entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] );
462
+	protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) {
463
+		if ($model instanceof \EEM_CPT_Base) {
464
+			$entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]);
465 465
 		}
466 466
 		return $entity_array;
467 467
 	}
@@ -475,20 +475,20 @@  discard block
 block discarded – undo
475 475
 	 * @param array $entity_array
476 476
 	 * @return array the _links item in the entity
477 477
 	 */
478
-	protected function _get_entity_links( $model, $db_row, $entity_array ) {
478
+	protected function _get_entity_links($model, $db_row, $entity_array) {
479 479
 		//add basic links
480 480
 		$links = array(
481 481
 			'self' => array(
482 482
 				array(
483 483
 					'href' => $this->get_versioned_link_to(
484
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ]
484
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()]
485 485
 					)
486 486
 				)
487 487
 			),
488 488
 			'collection' => array(
489 489
 				array(
490 490
 					'href' => $this->get_versioned_link_to(
491
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() )
491
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())
492 492
 					)
493 493
 				)
494 494
 			),
@@ -496,24 +496,24 @@  discard block
 block discarded – undo
496 496
 
497 497
 		//add link to the wp core endpoint, if wp api is active
498 498
 		global $wp_rest_server;
499
-		if( $model instanceof \EEM_CPT_Base &&
499
+		if ($model instanceof \EEM_CPT_Base &&
500 500
 			$wp_rest_server instanceof \WP_REST_Server &&
501
-			$wp_rest_server->get_route_options( '/wp/v2/posts' ) ) {
502
-			$links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array(
501
+			$wp_rest_server->get_route_options('/wp/v2/posts')) {
502
+			$links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array(
503 503
 				array(
504
-					'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
504
+					'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]),
505 505
 					'single' => true
506 506
 				)
507 507
 			);
508 508
 		}
509 509
 
510 510
 		//add links to related models
511
-		foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) {
512
-			$related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj );
513
-			$links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array(
511
+		foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) {
512
+			$related_model_part = Read::get_related_entity_name($relation_name, $relation_obj);
513
+			$links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array(
514 514
 				array(
515 515
 					'href' => $this->get_versioned_link_to(
516
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part
516
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part
517 517
 					),
518 518
 					'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false
519 519
 				)
@@ -529,51 +529,51 @@  discard block
 block discarded – undo
529 529
 	 * @param array $entity_array
530 530
 	 * @return array the modified entity
531 531
 	 */
532
-	protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) {
533
-		$includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' );
534
-		$includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model );
532
+	protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) {
533
+		$includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), '');
534
+		$includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model);
535 535
 		//if they passed in * or didn't specify any includes, return everything
536
-		if( ! in_array( '*', $includes_for_this_model )
537
-			&& ! empty( $includes_for_this_model ) ) {
538
-			if( $model->has_primary_key_field() ) {
536
+		if ( ! in_array('*', $includes_for_this_model)
537
+			&& ! empty($includes_for_this_model)) {
538
+			if ($model->has_primary_key_field()) {
539 539
 				//always include the primary key. ya just gotta know that at least
540 540
 				$includes_for_this_model[] = $model->primary_key_name();
541 541
 			}
542
-			if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) {
542
+			if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) {
543 543
 				$includes_for_this_model[] = '_calculated_fields';
544 544
 			}
545
-			$entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) );
545
+			$entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model));
546 546
 		}
547
-		$relation_settings = $this->get_model_version_info()->relation_settings( $model );
548
-		foreach( $relation_settings as $relation_name => $relation_obj ) {
547
+		$relation_settings = $this->get_model_version_info()->relation_settings($model);
548
+		foreach ($relation_settings as $relation_name => $relation_obj) {
549 549
 			$related_fields_to_include = $this->explode_and_get_items_prefixed_with(
550
-				$rest_request->get_param( 'include' ),
550
+				$rest_request->get_param('include'),
551 551
 				$relation_name
552 552
 			);
553 553
 			$related_fields_to_calculate = $this->explode_and_get_items_prefixed_with(
554
-				$rest_request->get_param( 'calculate' ),
554
+				$rest_request->get_param('calculate'),
555 555
 				$relation_name
556 556
 			);
557 557
 			//did they specify they wanted to include a related model, or
558 558
 			//specific fields from a related model?
559 559
 			//or did they specify to calculate a field from a related model?
560
-			if( $related_fields_to_include || $related_fields_to_calculate ) {
560
+			if ($related_fields_to_include || $related_fields_to_calculate) {
561 561
 				//if so, we should include at least some part of the related model
562 562
 				$pretend_related_request = new \WP_REST_Request();
563 563
 				$pretend_related_request->set_query_params(
564 564
 					array(
565
-						'caps' => $rest_request->get_param( 'caps' ),
565
+						'caps' => $rest_request->get_param('caps'),
566 566
 						'include' => $related_fields_to_include,
567 567
 						'calculate' => $related_fields_to_calculate,
568 568
 					)
569 569
 				);
570
-				$pretend_related_request->add_header( 'no_rest_headers', true );
570
+				$pretend_related_request->add_header('no_rest_headers', true);
571 571
 				$related_results = $this->get_entities_from_relation(
572
-					$entity_array[ $model->primary_key_name() ],
572
+					$entity_array[$model->primary_key_name()],
573 573
 					$relation_obj,
574 574
 					$pretend_related_request
575 575
 				);
576
-				$entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error
576
+				$entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error
577 577
 					? null
578 578
 					: $related_results;
579 579
 			}
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 	 * @param array $arr
588 588
 	 * @return array
589 589
 	 */
590
-	private function _remove_model_names_from_array( $arr ) {
591
-		return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) );
590
+	private function _remove_model_names_from_array($arr) {
591
+		return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models));
592 592
 	}
593 593
 	/**
594 594
 	 * Gets the calculated fields for the response
@@ -598,15 +598,15 @@  discard block
 block discarded – undo
598 598
 	 * @param \WP_REST_Request $rest_request
599 599
 	 * @return \stdClass the _calculations item in the entity
600 600
 	 */
601
-	protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) {
601
+	protected function _get_entity_calculations($model, $wpdb_row, $rest_request) {
602 602
 		$calculated_fields = $this->explode_and_get_items_prefixed_with(
603
-			$rest_request->get_param( 'calculate' ),
603
+			$rest_request->get_param('calculate'),
604 604
 			''
605 605
 		);
606 606
 		//note: setting calculate=* doesn't do anything
607 607
 		$calculated_fields_to_return = new \stdClass();
608
-		foreach( $calculated_fields as $field_to_calculate ) {
609
-			try{
608
+		foreach ($calculated_fields as $field_to_calculate) {
609
+			try {
610 610
 				$calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json(
611 611
 					null,
612 612
 					$this->_fields_calculator->retrieve_calculated_field_value(
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
 					),
619 619
 					$this->get_model_version_info()->requested_version()
620 620
 				);
621
-			} catch( Rest_Exception $e ) {
621
+			} catch (Rest_Exception $e) {
622 622
 				//if we don't have permission to read it, just leave it out. but let devs know about the problem
623 623
 				$this->_set_response_header(
624
-					'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']',
624
+					'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']',
625 625
 					$e->getMessage(),
626 626
 					true
627 627
 				);
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 	 * @param string $link_part_after_version_and_slash eg "events/10/datetimes"
636 636
 	 * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes"
637 637
 	 */
638
-	public function get_versioned_link_to( $link_part_after_version_and_slash ) {
638
+	public function get_versioned_link_to($link_part_after_version_and_slash) {
639 639
 		return rest_url(
640 640
 			\EED_Core_Rest_Api::ee_api_namespace
641 641
 			. $this->get_model_version_info()->requested_version()
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 	 * @param \EE_Model_Relation_Base $relation_obj
652 652
 	 * @return string
653 653
 	 */
654
-	public static function get_related_entity_name( $relation_name, $relation_obj ){
655
-		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
656
-			return strtolower( $relation_name );
657
-		}else{
658
-			return \EEH_Inflector::pluralize_and_lower( $relation_name );
654
+	public static function get_related_entity_name($relation_name, $relation_obj) {
655
+		if ($relation_obj instanceof \EE_Belongs_To_Relation) {
656
+			return strtolower($relation_name);
657
+		} else {
658
+			return \EEH_Inflector::pluralize_and_lower($relation_name);
659 659
 		}
660 660
 	}
661 661
 
@@ -668,43 +668,43 @@  discard block
 block discarded – undo
668 668
 	 * @param \WP_REST_Request $request
669 669
 	 * @return array|\WP_Error
670 670
 	 */
671
-	public function get_entity_from_model( $model, $request ) {
672
-		$query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1);
673
-		if( $model instanceof \EEM_Soft_Delete_Base ){
671
+	public function get_entity_from_model($model, $request) {
672
+		$query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
673
+		if ($model instanceof \EEM_Soft_Delete_Base) {
674 674
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
675 675
 		}
676 676
 		$restricted_query_params = $query_params;
677
-		$restricted_query_params[ 'caps' ] =  $this->validate_context(  $request->get_param( 'caps' ) );
678
-		$this->_set_debug_info( 'model query params', $restricted_query_params );
679
-		$model_rows = $model->get_all_wpdb_results( $restricted_query_params );
680
-		if ( ! empty ( $model_rows ) ) {
677
+		$restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
678
+		$this->_set_debug_info('model query params', $restricted_query_params);
679
+		$model_rows = $model->get_all_wpdb_results($restricted_query_params);
680
+		if ( ! empty ($model_rows)) {
681 681
 			return $this->create_entity_from_wpdb_result(
682 682
 				$model,
683
-				array_shift( $model_rows ),
683
+				array_shift($model_rows),
684 684
 				$request );
685 685
 		} else {
686 686
 			//ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
687
-			$lowercase_model_name = strtolower( $model->get_this_model_name() );
688
-			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params );
689
-			if( ! empty( $model_rows_found_sans_restrictions ) ) {
687
+			$lowercase_model_name = strtolower($model->get_this_model_name());
688
+			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
689
+			if ( ! empty($model_rows_found_sans_restrictions)) {
690 690
 				//you got shafted- it existed but we didn't want to tell you!
691 691
 				return new \WP_Error(
692 692
 					'rest_user_cannot_read',
693 693
 					sprintf(
694
-						__( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ),
695
-						strtolower( $model->get_this_model_name() ),
694
+						__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'),
695
+						strtolower($model->get_this_model_name()),
696 696
 						Capabilities::get_missing_permissions_string(
697 697
 							$model,
698
-							$this->validate_context( $request->get_param( 'caps' ) ) )
698
+							$this->validate_context($request->get_param('caps')) )
699 699
 					),
700
-					array( 'status' => 403 )
700
+					array('status' => 403)
701 701
 				);
702 702
 			} else {
703 703
 				//it's not you. It just doesn't exist
704 704
 				return new \WP_Error(
705
-					sprintf( 'rest_%s_invalid_id', $lowercase_model_name ),
706
-					sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ),
707
-					array( 'status' => 404 )
705
+					sprintf('rest_%s_invalid_id', $lowercase_model_name),
706
+					sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name),
707
+					array('status' => 404)
708 708
 				);
709 709
 			}
710 710
 		}
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 	 * @param string $context
718 718
 	 * @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
719 719
 	 */
720
-	public function validate_context( $context ) {
721
-		if( ! $context ) {
720
+	public function validate_context($context) {
721
+		if ( ! $context) {
722 722
 			$context = \EEM_Base::caps_read;
723 723
 		}
724 724
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
725
-		if( in_array( $context, $valid_contexts )  ){
725
+		if (in_array($context, $valid_contexts)) {
726 726
 			return $context;
727
-		}else{
727
+		} else {
728 728
 			return \EEM_Base::caps_read;
729 729
 		}
730 730
 	}
@@ -743,87 +743,87 @@  discard block
 block discarded – undo
743 743
 	 *                          that absolutely no results should be returned
744 744
 	 * @throws \EE_Error
745 745
 	 */
746
-	public function create_model_query_params( $model, $query_parameters ) {
746
+	public function create_model_query_params($model, $query_parameters) {
747 747
 		$model_query_params = array( );
748
-		if ( isset( $query_parameters[ 'where' ] ) ) {
749
-			$model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
750
-				$query_parameters[ 'where' ],
748
+		if (isset($query_parameters['where'])) {
749
+			$model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models(
750
+				$query_parameters['where'],
751 751
 				$model,
752 752
 				$this->get_model_version_info()->requested_version()
753 753
 			);
754 754
 		}
755
-		if ( isset( $query_parameters[ 'order_by' ] ) ) {
756
-			$order_by = $query_parameters[ 'order_by' ];
757
-		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
758
-			$order_by = $query_parameters[ 'orderby' ];
759
-		}else{
755
+		if (isset($query_parameters['order_by'])) {
756
+			$order_by = $query_parameters['order_by'];
757
+		} elseif (isset($query_parameters['orderby'])) {
758
+			$order_by = $query_parameters['orderby'];
759
+		} else {
760 760
 			$order_by = null;
761 761
 		}
762
-		if( $order_by !== null ){
763
-			if( is_array( $order_by ) ) {
764
-				$order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json( $order_by );
762
+		if ($order_by !== null) {
763
+			if (is_array($order_by)) {
764
+				$order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json($order_by);
765 765
 			} else {
766 766
 				//it's a single item
767
-				$order_by = Model_Data_Translator::prepare_field_name_from_json( $order_by );
767
+				$order_by = Model_Data_Translator::prepare_field_name_from_json($order_by);
768 768
 			}
769
-			$model_query_params[ 'order_by' ] =  $order_by;
769
+			$model_query_params['order_by'] = $order_by;
770 770
 		}
771
-		if ( isset( $query_parameters[ 'group_by' ] ) ) {
772
-			$group_by = $query_parameters[ 'group_by' ];
773
-		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
774
-			$group_by = $query_parameters[ 'groupby' ];
775
-		}else{
776
-			$group_by = array_keys( $model->get_combined_primary_key_fields() );
771
+		if (isset($query_parameters['group_by'])) {
772
+			$group_by = $query_parameters['group_by'];
773
+		} elseif (isset($query_parameters['groupby'])) {
774
+			$group_by = $query_parameters['groupby'];
775
+		} else {
776
+			$group_by = array_keys($model->get_combined_primary_key_fields());
777 777
 		}
778 778
 		//make sure they're all real names
779
-		if( is_array( $group_by ) ) {
780
-			$group_by = Model_Data_Translator::prepare_field_names_from_json( $group_by );
779
+		if (is_array($group_by)) {
780
+			$group_by = Model_Data_Translator::prepare_field_names_from_json($group_by);
781 781
 		}
782
-		if( $group_by !== null ){
783
-			$model_query_params[ 'group_by' ] = $group_by;
782
+		if ($group_by !== null) {
783
+			$model_query_params['group_by'] = $group_by;
784 784
 		}
785
-		if ( isset( $query_parameters[ 'having' ] ) ) {
786
-			$model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
787
-				$query_parameters[ 'having' ],
785
+		if (isset($query_parameters['having'])) {
786
+			$model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models(
787
+				$query_parameters['having'],
788 788
 				$model,
789 789
 				$this->get_model_version_info()->requested_version()
790 790
 			);
791 791
 		}
792
-		if ( isset( $query_parameters[ 'order' ] ) ) {
793
-			$model_query_params[ 'order' ] = $query_parameters[ 'order' ];
792
+		if (isset($query_parameters['order'])) {
793
+			$model_query_params['order'] = $query_parameters['order'];
794 794
 		}
795
-		if ( isset( $query_parameters[ 'mine' ] ) ){
796
-			$model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params );
795
+		if (isset($query_parameters['mine'])) {
796
+			$model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params);
797 797
 		}
798
-		if( isset( $query_parameters[ 'limit' ] ) ) {
798
+		if (isset($query_parameters['limit'])) {
799 799
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
800
-			if( ! is_array( $query_parameters[ 'limit' ] ) ) {
801
-				$limit_array = explode(',', (string)$query_parameters['limit']);
802
-			}else {
803
-				$limit_array = $query_parameters[ 'limit' ];
800
+			if ( ! is_array($query_parameters['limit'])) {
801
+				$limit_array = explode(',', (string) $query_parameters['limit']);
802
+			} else {
803
+				$limit_array = $query_parameters['limit'];
804 804
 			}
805 805
 			$sanitized_limit = array();
806
-			foreach( $limit_array as $key => $limit_part ) {
807
-				if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) {
806
+			foreach ($limit_array as $key => $limit_part) {
807
+				if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) {
808 808
 					throw new \EE_Error(
809 809
 						sprintf(
810
-							__( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ),
811
-							json_encode( $query_parameters[ 'limit' ] )
810
+							__('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'),
811
+							json_encode($query_parameters['limit'])
812 812
 						)
813 813
 					);
814 814
 				}
815
-				$sanitized_limit[] = (int)$limit_part;
815
+				$sanitized_limit[] = (int) $limit_part;
816 816
 			}
817
-			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
818
-		}else{
819
-			$model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
817
+			$model_query_params['limit'] = implode(',', $sanitized_limit);
818
+		} else {
819
+			$model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
820 820
 		}
821
-		if( isset( $query_parameters[ 'caps' ] ) ) {
822
-			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
823
-		}else{
824
-			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
821
+		if (isset($query_parameters['caps'])) {
822
+			$model_query_params['caps'] = $this->validate_context($query_parameters['caps']);
823
+		} else {
824
+			$model_query_params['caps'] = \EEM_Base::caps_read;
825 825
 		}
826
-		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
826
+		return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model);
827 827
 	}
828 828
 
829 829
 
@@ -835,13 +835,13 @@  discard block
 block discarded – undo
835 835
 	 * @param array     $query_params sub-array from @see EEM_Base::get_all()
836 836
 	 * @return array
837 837
 	 */
838
-	public function prepare_rest_query_params_key_for_models( $model,  $query_params ) {
838
+	public function prepare_rest_query_params_key_for_models($model, $query_params) {
839 839
 		$model_ready_query_params = array();
840
-		foreach( $query_params as $key => $value ) {
841
-			if( is_array( $value ) ) {
842
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
843
-			}else{
844
-				$model_ready_query_params[ $key ] = $value;
840
+		foreach ($query_params as $key => $value) {
841
+			if (is_array($value)) {
842
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value);
843
+			} else {
844
+				$model_ready_query_params[$key] = $value;
845 845
 			}
846 846
 		}
847 847
 		return $model_ready_query_params;
@@ -855,13 +855,13 @@  discard block
 block discarded – undo
855 855
 	 * @param $query_params
856 856
 	 * @return array
857 857
 	 */
858
-	public function prepare_rest_query_params_values_for_models( $model, $query_params ) {
858
+	public function prepare_rest_query_params_values_for_models($model, $query_params) {
859 859
 		$model_ready_query_params = array();
860
-		foreach( $query_params as $key => $value ) {
861
-			if( is_array( $value ) ) {
862
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value );
860
+		foreach ($query_params as $key => $value) {
861
+			if (is_array($value)) {
862
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value);
863 863
 			} else {
864
-				$model_ready_query_params[ $key ] = $value;
864
+				$model_ready_query_params[$key] = $value;
865 865
 			}
866 866
 		}
867 867
 		return $model_ready_query_params;
@@ -876,33 +876,33 @@  discard block
 block discarded – undo
876 876
 	 * we only return strings starting with that and a period; if no prefix was specified
877 877
 	 * we return all items containing NO periods
878 878
 	 */
879
-	public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) {
880
-		if( is_string( $string_to_explode ) ) {
881
-			$exploded_contents = explode( ',', $string_to_explode );
882
-		} else if( is_array( $string_to_explode ) ) {
879
+	public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) {
880
+		if (is_string($string_to_explode)) {
881
+			$exploded_contents = explode(',', $string_to_explode);
882
+		} else if (is_array($string_to_explode)) {
883 883
 			$exploded_contents = $string_to_explode;
884 884
 		} else {
885 885
 			$exploded_contents = array();
886 886
 		}
887 887
 		//if the string was empty, we want an empty array
888
-		$exploded_contents = array_filter( $exploded_contents );
888
+		$exploded_contents = array_filter($exploded_contents);
889 889
 		$contents_with_prefix = array();
890
-		foreach( $exploded_contents as $item ) {
891
-			$item = trim( $item );
890
+		foreach ($exploded_contents as $item) {
891
+			$item = trim($item);
892 892
 			//if no prefix was provided, so we look for items with no "." in them
893
-			if( ! $prefix ) {
893
+			if ( ! $prefix) {
894 894
 				//does this item have a period?
895
-				if( strpos( $item, '.' ) === false ) {
895
+				if (strpos($item, '.') === false) {
896 896
 					//if not, then its what we're looking for
897 897
 					$contents_with_prefix[] = $item;
898 898
 				}
899
-			} else if( strpos( $item, $prefix . '.' ) === 0 ) {
899
+			} else if (strpos($item, $prefix.'.') === 0) {
900 900
 				//this item has the prefix and a period, grab it
901 901
 				$contents_with_prefix[] = substr(
902 902
 					$item,
903
-					strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' )
903
+					strpos($item, $prefix.'.') + strlen($prefix.'.')
904 904
 					);
905
-			} else if( $item === $prefix ) {
905
+			} else if ($item === $prefix) {
906 906
 				//this item is JUST the prefix
907 907
 				//so let's grab everything after, which is a blank string
908 908
 				$contents_with_prefix[] = '';
@@ -925,33 +925,33 @@  discard block
 block discarded – undo
925 925
 	 * the fields for that model, with the model's name removed from each.
926 926
 	 * If $include_string was blank or '*' returns an empty array
927 927
 	 */
928
-	public function extract_includes_for_this_model( $include_string, $model_name = null ) {
929
-		if( is_array( $include_string ) ) {
930
-			$include_string = implode( ',', $include_string );
928
+	public function extract_includes_for_this_model($include_string, $model_name = null) {
929
+		if (is_array($include_string)) {
930
+			$include_string = implode(',', $include_string);
931 931
 		}
932
-		if( $include_string === '*' || $include_string === '' ) {
932
+		if ($include_string === '*' || $include_string === '') {
933 933
 			return array();
934 934
 		}
935
-		$includes = explode( ',', $include_string );
935
+		$includes = explode(',', $include_string);
936 936
 		$extracted_fields_to_include = array();
937
-		if( $model_name ){
938
-			foreach( $includes as $field_to_include ) {
939
-				$field_to_include = trim( $field_to_include );
940
-				if( strpos( $field_to_include, $model_name . '.' ) === 0 ) {
937
+		if ($model_name) {
938
+			foreach ($includes as $field_to_include) {
939
+				$field_to_include = trim($field_to_include);
940
+				if (strpos($field_to_include, $model_name.'.') === 0) {
941 941
 					//found the model name at the exact start
942
-					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
942
+					$field_sans_model_name = str_replace($model_name.'.', '', $field_to_include);
943 943
 					$extracted_fields_to_include[] = $field_sans_model_name;
944
-				}elseif( $field_to_include == $model_name ){
944
+				}elseif ($field_to_include == $model_name) {
945 945
 					$extracted_fields_to_include[] = '*';
946 946
 				}
947 947
 			}
948
-		}else{
948
+		} else {
949 949
 			//look for ones with no period
950
-			foreach( $includes as $field_to_include ) {
951
-				$field_to_include = trim( $field_to_include );
950
+			foreach ($includes as $field_to_include) {
951
+				$field_to_include = trim($field_to_include);
952 952
 				if (
953
-					strpos( $field_to_include, '.' ) === false
954
-					&& ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include )
953
+					strpos($field_to_include, '.') === false
954
+					&& ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include)
955 955
 				) {
956 956
 					$extracted_fields_to_include[] = $field_to_include;
957 957
 				}
Please login to merge, or discard this patch.