Completed
Branch BUG-7537 (42ca46)
by
unknown
1233:48 queued 1213:30
created
core/libraries/rest_api/controllers/Base.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
 	 *
130 130
 	 * @param string $route
131 131
 	 * @param string $regex
132
-	 * @param array  $match_keys EXCLUDING matching the entire regex
132
+	 * @param string[]  $match_keys EXCLUDING matching the entire regex
133 133
 	 * @return array where  $match_keys are the keys (the first value of $match_keys
134 134
 	 * becomes the first key of the return value, etc. Eg passing in $match_keys of
135 135
 	 * array( 'model', 'id' ), will, if the regex is successful, will return
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 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\controllers;
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
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	protected $_requested_version;
37 37
 
38 38
 	public function __construct() {
39
-		$this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false;
39
+		$this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false;
40 40
 	}
41 41
 
42 42
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * Sets the version the user requested
45 45
 	 * @param string $version eg '4.8'
46 46
 	 */
47
-	public function set_requested_version( $version ) {
47
+	public function set_requested_version($version) {
48 48
 		$this->_requested_version = $version;
49 49
 	}
50 50
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 * @param string $key
54 54
 	 * @param string|array $info
55 55
 	 */
56
-	protected function _set_debug_info( $key, $info ){
57
-		$this->_debug_info[ $key ] = $info;
56
+	protected function _set_debug_info($key, $info) {
57
+		$this->_debug_info[$key] = $info;
58 58
 	}
59 59
 
60 60
 
@@ -69,52 +69,52 @@  discard block
 block discarded – undo
69 69
 	 * @param array|\WP_Error|\Exception $response
70 70
 	 * @return \WP_REST_Response
71 71
 	 */
72
-	public function send_response( $response ) {
73
-		if( $response instanceof \Exception ) {
74
-			$response = new \WP_Error( $response->getCode(), $response->getMessage() );
72
+	public function send_response($response) {
73
+		if ($response instanceof \Exception) {
74
+			$response = new \WP_Error($response->getCode(), $response->getMessage());
75 75
 		}
76
-		if( $response instanceof \WP_Error ) {
76
+		if ($response instanceof \WP_Error) {
77 77
 			//we want to send a "normal"-looking WP error response, but we also
78 78
 			//want to add headers. It doesn't seem WP API 1.2 supports this.
79 79
 			//I'd like to use WP_JSON_Server::error_to_response() but its protected
80 80
 			//so here's most of it copy-and-pasted :P
81 81
 			$error_data = $response->get_error_data();
82
-			if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
82
+			if (is_array($error_data) && isset($error_data['status'])) {
83 83
 				$status = $error_data['status'];
84 84
 			} else {
85 85
 				$status = 500;
86 86
 			}
87 87
 
88 88
 			$errors = array();
89
-			foreach ( (array) $response->errors as $code => $messages ) {
90
-				foreach ( (array) $messages as $message ) {
89
+			foreach ((array) $response->errors as $code => $messages) {
90
+				foreach ((array) $messages as $message) {
91 91
 					$errors[] = array(
92 92
 						'code'    => $code,
93 93
 						'message' => $message,
94
-						'data'    => $response->get_error_data( $code )
94
+						'data'    => $response->get_error_data($code)
95 95
 					);
96 96
 				}
97 97
 			}
98
-			$data = isset( $errors[0] ) ? $errors[0] : array();
99
-			if ( count( $errors ) > 1 ) {
98
+			$data = isset($errors[0]) ? $errors[0] : array();
99
+			if (count($errors) > 1) {
100 100
 				// Remove the primary error.
101
-				array_shift( $errors );
101
+				array_shift($errors);
102 102
 				$data['additional_errors'] = $errors;
103 103
 			}
104
-			$rest_response = new \WP_REST_Response( $data, $status );
105
-		}else{
106
-			$rest_response = new \WP_REST_Response( $response, 200 );
104
+			$rest_response = new \WP_REST_Response($data, $status);
105
+		} else {
106
+			$rest_response = new \WP_REST_Response($response, 200);
107 107
 		}
108 108
 		$headers = array();
109
-		if( $this->_debug_mode && is_array( $this->_debug_info ) ) {
110
-			foreach( $this->_debug_info  as $debug_key => $debug_info ) {
111
-				if( is_array( $debug_info ) ) {
112
-					$debug_info = json_encode( $debug_info );
109
+		if ($this->_debug_mode && is_array($this->_debug_info)) {
110
+			foreach ($this->_debug_info  as $debug_key => $debug_info) {
111
+				if (is_array($debug_info)) {
112
+					$debug_info = json_encode($debug_info);
113 113
 				}
114
-				$headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info;
114
+				$headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info;
115 115
 			}
116 116
 		}
117
-		$rest_response->set_headers( $headers );
117
+		$rest_response->set_headers($headers);
118 118
 		return $rest_response;
119 119
 	}
120 120
 
@@ -136,23 +136,23 @@  discard block
 block discarded – undo
136 136
 	 * array( 'model' => 'foo', 'id' => 'bar' )
137 137
 	 * @throws \EE_Error if it couldn't be parsed
138 138
 	 */
139
-	public function parse_route( $route, $regex, $match_keys ) {
139
+	public function parse_route($route, $regex, $match_keys) {
140 140
 		$indexed_matches = array();
141
-		$success = preg_match( $regex, $route, $matches );
142
-		if(
143
-			is_array( $matches ) ) {
141
+		$success = preg_match($regex, $route, $matches);
142
+		if (
143
+			is_array($matches) ) {
144 144
 			//skip the overall regex match. Who cares
145
-			for( $i = 1; $i <= count( $match_keys ); $i++ ) {
146
-				if( ! isset( $matches[ $i ] ) ) {
145
+			for ($i = 1; $i <= count($match_keys); $i++) {
146
+				if ( ! isset($matches[$i])) {
147 147
 					$success = false;
148 148
 				} else {
149
-					$indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ];
149
+					$indexed_matches[$match_keys[$i - 1]] = $matches[$i];
150 150
 				}
151 151
 			}
152 152
 		}
153
-		if( ! $success ) {
153
+		if ( ! $success) {
154 154
 			throw new \EE_Error(
155
-				__( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ),
155
+				__('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'),
156 156
 				'endpoint_parsing_error'
157 157
 			);
158 158
 		}
Please login to merge, or discard this patch.
core/libraries/rest_api/Capabilities.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api;
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
 	 * @param string $model_context one of the return values from EEM_Base::valid_cap_contexts()
22 22
 	 * @return boolean
23 23
 	 */
24
-	public static function current_user_has_partial_access_to( $model, $model_context = \EEM_Base::caps_read ) {
25
-		if( apply_filters( 'FHEE__Capabilities__current_user_has_partial_access_to__override_begin', false, $model, $model ) ) {
24
+	public static function current_user_has_partial_access_to($model, $model_context = \EEM_Base::caps_read) {
25
+		if (apply_filters('FHEE__Capabilities__current_user_has_partial_access_to__override_begin', false, $model, $model)) {
26 26
 			return true;
27 27
 		}
28
-		foreach( $model->caps_missing( $model_context ) as $capability_name => $restriction_obj ) {
29
-			if( $restriction_obj instanceof \EE_Return_None_Where_Conditions ){
28
+		foreach ($model->caps_missing($model_context) as $capability_name => $restriction_obj) {
29
+			if ($restriction_obj instanceof \EE_Return_None_Where_Conditions) {
30 30
 				return false;
31 31
 			}
32 32
 		}
33
-		if( apply_filters( 'FHEE__Capabilities__current_user_has_partial_access_to__override_end', false, $model, $model ) ) {
33
+		if (apply_filters('FHEE__Capabilities__current_user_has_partial_access_to__override_end', false, $model, $model)) {
34 34
 			return false;
35 35
 		}
36 36
 		return true;
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @param string $request_type one of the constants on WP_JSON_Server
44 44
 	 * @return array
45 45
 	 */
46
-	public static function get_missing_permissions( $model, $request_type = \EEM_Base::caps_read ) {
47
-		return $model->caps_missing( $request_type );
46
+	public static function get_missing_permissions($model, $request_type = \EEM_Base::caps_read) {
47
+		return $model->caps_missing($request_type);
48 48
 	}
49 49
 	/**
50 50
 	 * Gets a string of all the capabilities the current user is missing that affected
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 * @param string $model_context one of the return values from EEM_Base::valid_cap_contexts()
55 55
 	 * @return string
56 56
 	 */
57
-	public static function get_missing_permissions_string( $model, $model_context = \EEM_Base::caps_read ) {
58
-		return implode(',', array_keys( self::get_missing_permissions( $model, $model_context ) ) );
57
+	public static function get_missing_permissions_string($model, $model_context = \EEM_Base::caps_read) {
58
+		return implode(',', array_keys(self::get_missing_permissions($model, $model_context)));
59 59
 	}
60 60
 
61 61
 	/**
@@ -66,25 +66,25 @@  discard block
 block discarded – undo
66 66
 	 * @param Model_Version_Info $model_version_info
67 67
 	 * @return array ready for converting into json
68 68
 	 */
69
-	public static function filter_out_inaccessible_entity_fields( $entity,  $model, $request_type, $model_version_info ) {
69
+	public static function filter_out_inaccessible_entity_fields($entity, $model, $request_type, $model_version_info) {
70 70
 		//we only care to do this for frontend reads and when the user can't edit the item
71
-		if(  $request_type !== \EEM_Base::caps_read ||
72
-				$model->exists( array(
73
-					array( $model->primary_key_name() => $entity[ $model->primary_key_name() ] ),
71
+		if ($request_type !== \EEM_Base::caps_read ||
72
+				$model->exists(array(
73
+					array($model->primary_key_name() => $entity[$model->primary_key_name()]),
74 74
 					'default_where_conditions' => 'none',
75
-					'caps' => \EEM_Base::caps_edit ) ) ) {
75
+					'caps' => \EEM_Base::caps_edit ))) {
76 76
 			return $entity;
77 77
 		}
78
-		foreach( $model->field_settings() as $field_name => $field_obj ){
79
-			if( $model_version_info->field_has_rendered_format( $field_obj )
80
-				&& isset( $entity[ $field_name ][ 'raw' ] )
78
+		foreach ($model->field_settings() as $field_name => $field_obj) {
79
+			if ($model_version_info->field_has_rendered_format($field_obj)
80
+				&& isset($entity[$field_name]['raw'])
81 81
 			) {
82
-				unset( $entity[ $field_name ][ 'raw' ] );
82
+				unset($entity[$field_name]['raw']);
83 83
 			}
84 84
 		}
85 85
 		//theoretically we may want to filter out specific fields for specific models
86 86
 
87
-		return apply_filters( 'FHEE__Capabilities__filter_out_inaccessible_entity_fields', $entity, $model, $request_type );
87
+		return apply_filters('FHEE__Capabilities__filter_out_inaccessible_entity_fields', $entity, $model, $request_type);
88 88
 	}
89 89
 }
90 90
 
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/config/Read.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers\config;
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
 	 * @param \WP_REST_Request $request
22 22
 	 * @return \EE_Config|\WP_Error
23 23
 	 */
24
-	public static function handle_request( \WP_REST_Request $request) {
24
+	public static function handle_request(\WP_REST_Request $request) {
25 25
 		$cap = \EE_Restriction_Generator_Base::get_default_restrictions_cap();
26
-		if( \EE_Capabilities::instance()->current_user_can( $cap, 'read_over_api' ) ){
26
+		if (\EE_Capabilities::instance()->current_user_can($cap, 'read_over_api')) {
27 27
 			return \EE_Config::instance();
28
-		}else{
28
+		} else {
29 29
 			return new \WP_Error(
30 30
 				'cannot_read_config',
31 31
 				sprintf(
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 					),
36 36
 					$cap
37 37
 				),
38
-				array( 'status' => 403 )
38
+				array('status' => 403)
39 39
 			);
40 40
 		}
41 41
 	}
Please login to merge, or discard this patch.
modules/core_rest_api/EED_Core_Rest_Api.module.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -293,7 +293,7 @@
 block discarded – undo
293 293
 			//if it's not above the current core version, and it's compatible with the current version of core
294 294
 			if( $possibly_served_version < EED_REST_API::core_version() && $possibly_served_version >= $lowest_compatible_version ) {
295 295
 				$versions_served[ $possibly_served_version ] = true;
296
-			}else {
296
+			} else {
297 297
 				$versions_served[ $possibly_served_version ] = false;
298 298
 			}
299 299
 		}
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @return EED_Core_Rest_Api
23 23
 	 */
24 24
 	public static function instance() {
25
-		return parent::get_instance( __CLASS__ );
25
+		return parent::get_instance(__CLASS__);
26 26
 	}
27 27
 
28 28
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
 	public static function set_hooks_both() {
55
-		add_action( 'rest_api_init', array( 'EED_Core_REST_API', 'register_routes' ) );
56
-		add_filter( 'rest_route_data', array( 'EED_Core_REST_API', 'hide_old_endpoints' ), 10, 2 );
57
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
55
+		add_action('rest_api_init', array('EED_Core_REST_API', 'register_routes'));
56
+		add_filter('rest_route_data', array('EED_Core_REST_API', 'hide_old_endpoints'), 10, 2);
57
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
58 58
 	}
59 59
 
60 60
 
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
64 64
 	 */
65 65
 	public static function register_routes() {
66
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
67
-			foreach( $relative_urls as $endpoint => $routes ) {
68
-				foreach( $routes as $route ) {
66
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
67
+			foreach ($relative_urls as $endpoint => $routes) {
68
+				foreach ($routes as $route) {
69 69
 					register_rest_route(
70 70
 						$namespace,
71 71
 						$endpoint,
72 72
 						array(
73
-							'callback' => $route[ 'callback' ],
74
-							'methods' => $route[ 'methods' ],
75
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
73
+							'callback' => $route['callback'],
74
+							'methods' => $route['methods'],
75
+							'args' => isset($route['args']) ? $route['args'] : array(),
76 76
 						)
77 77
 					);
78 78
 				}
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
 	 * }
90 90
 	 */
91 91
 	public static function get_ee_route_data() {
92
-		$ee_routes = get_option( self::saved_routes_option_names, null );
93
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
92
+		$ee_routes = get_option(self::saved_routes_option_names, null);
93
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
94 94
 			self::save_ee_routes();
95
-			$ee_routes = get_option( self::saved_routes_option_names, array() );
95
+			$ee_routes = get_option(self::saved_routes_option_names, array());
96 96
 		}
97 97
 		return $ee_routes;
98 98
 	}
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 * @return void
104 104
 	 */
105 105
 	public static function save_ee_routes() {
106
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
106
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
107 107
 			$instance = self::instance();
108 108
 			$routes = array_replace_recursive(
109 109
 				$instance->_register_config_routes(),
110 110
 				$instance->_register_meta_routes(),
111 111
 				$instance->_register_model_routes()
112 112
 			);
113
-			update_option( self::saved_routes_option_names, $routes, true );
113
+			update_option(self::saved_routes_option_names, $routes, true);
114 114
 		}
115 115
 	}
116 116
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return array @see get_ee_route_data
120 120
 	 */
121 121
 	protected function _register_model_routes() {
122
-		EE_Registry::instance()->load_helper( 'Inflector' );
122
+		EE_Registry::instance()->load_helper('Inflector');
123 123
 		$models_to_register = apply_filters(
124 124
 			'FHEE__EED_Core_REST_API___register_model_routes',
125 125
 			EE_Registry::instance()->non_abstract_db_models
@@ -128,23 +128,23 @@  discard block
 block discarded – undo
128 128
 		unset($models_to_register['Extra_Meta']);
129 129
 		unset($models_to_register['Extra_Join']);
130 130
 		$model_routes = array( );
131
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
131
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
132 132
 
133
-			foreach ( $models_to_register as $model_name => $model_classname ) {
133
+			foreach ($models_to_register as $model_name => $model_classname) {
134 134
 				//yes we could just register one route for ALL models, but then they wouldn't show up in the index
135
-				$ee_namespace = self::ee_api_namespace . $version;
136
-				$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
137
-				$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
138
-				$model_routes[ $ee_namespace ][ $plural_model_route ] = array(
135
+				$ee_namespace = self::ee_api_namespace.$version;
136
+				$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
137
+				$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
138
+				$model_routes[$ee_namespace][$plural_model_route] = array(
139 139
 						array(
140 140
 							'callback' => array(
141 141
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
142 142
 								'handle_request_get_all' ),
143 143
 							'methods' => WP_REST_Server::READABLE,
144 144
 							'hidden_endpoint' => $hidden_endpoint,
145
-							'args' => $this->_get_read_query_params( $model_name ),
145
+							'args' => $this->_get_read_query_params($model_name),
146 146
 							'_links' => array(
147
-								'self' => rest_url( $ee_namespace . $singular_model_route ),
147
+								'self' => rest_url($ee_namespace.$singular_model_route),
148 148
 							)
149 149
 						),
150 150
 //						array(
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 //							'hidden_endpoint' => $hidden_endpoint
156 156
 //						)
157 157
 					);
158
-				$model_routes[ $ee_namespace ][ $singular_model_route ] = array(
158
+				$model_routes[$ee_namespace][$singular_model_route] = array(
159 159
 						array(
160 160
 							'callback' => array(
161 161
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 								'include' => array(
167 167
 									'required' => false,
168 168
 									'default' => '*',
169
-									'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
169
+									'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
170 170
 								),
171 171
 							)
172 172
 						),
@@ -179,20 +179,20 @@  discard block
 block discarded – undo
179 179
 //							),
180 180
 				);
181 181
 				//@todo: also handle  DELETE for a single item
182
-				$model = EE_Registry::instance()->load_model( $model_classname );
183
-				foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
182
+				$model = EE_Registry::instance()->load_model($model_classname);
183
+				foreach ($model->relation_settings() as $relation_name => $relation_obj) {
184 184
 					$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
185 185
 						$relation_name,
186 186
 						$relation_obj
187 187
 					);
188
-					$model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
188
+					$model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
189 189
 							array(
190 190
 								'callback' => array(
191 191
 									'EventEspresso\core\libraries\rest_api\controllers\model\Read',
192 192
 									'handle_request_get_related' ),
193 193
 								'methods' => WP_REST_Server::READABLE,
194 194
 								'hidden_endpoint' => $hidden_endpoint,
195
-								'args' => $this->_get_read_query_params( $relation_name ),
195
+								'args' => $this->_get_read_query_params($relation_name),
196 196
 							),
197 197
 //							array(
198 198
 //								'callback' => array(
@@ -215,47 +215,47 @@  discard block
 block discarded – undo
215 215
 	 * @param string $model_name eg 'Event' or 'Venue'
216 216
 	 * @return array describing the args acceptable when querying this model
217 217
 	 */
218
-	protected function _get_read_query_params( $model_name ) {
219
-		$model = EE_Registry::instance()->load_model( $model_name );
218
+	protected function _get_read_query_params($model_name) {
219
+		$model = EE_Registry::instance()->load_model($model_name);
220 220
 		$default_orderby = array();
221
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
222
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
221
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
222
+			$default_orderby[$key_field->get_name()] = 'ASC';
223 223
 		}
224 224
 		return array(
225 225
 			'where' => array(
226 226
 				'required' => false,
227 227
 				'default' => array(),
228
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterwhere for documentation', 'event_espresso' ),
228
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterwhere for documentation', 'event_espresso'),
229 229
 				),
230 230
 			'limit' => array(
231 231
 				'required' => false,
232 232
 				'default' => 50,
233
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterlimit for documentation', 'event_espresso' )
233
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterlimit for documentation', 'event_espresso')
234 234
 			),
235 235
 			'order_by' => array(
236 236
 				'required' => false,
237 237
 				'default' => $default_orderby,
238
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterorder_by for documentation', 'event_espresso' )
238
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterorder_by for documentation', 'event_espresso')
239 239
 			),
240 240
 			'group_by' => array(
241 241
 				'required' => false,
242 242
 				'default' => null,
243
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtergroup_by for documentation', 'event_espresso' )
243
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtergroup_by for documentation', 'event_espresso')
244 244
 			),
245 245
 			'having' => array(
246 246
 				'required' => false,
247 247
 				'default' => null,
248
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterhaving for documentation', 'event_espresso' )
248
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filterhaving for documentation', 'event_espresso')
249 249
 			),
250 250
 			'caps' => array(
251 251
 				'required' => false,
252 252
 				'default' => EEM_Base::caps_read,
253
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtercaps for documentation', 'event_espresso' )
253
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#filtercaps for documentation', 'event_espresso')
254 254
 			),
255 255
 			'include' => array(
256 256
 				'required' => false,
257 257
 				'default' => '*',
258
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
258
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-json-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
259 259
 			),
260 260
 		);
261 261
 	}
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	protected function _register_config_routes() {
268 268
 		$config_routes = array();
269
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
270
-			$config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array(
269
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
270
+			$config_routes[self::ee_api_namespace.$version]['config'] = array(
271 271
 					array(
272 272
 						'callback' => array(
273 273
 							'EventEspresso\core\libraries\rest_api\controllers\config\Read',
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	protected function _register_meta_routes() {
288 288
 		$meta_routes = array();
289
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
290
-			$meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array(
289
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
290
+			$meta_routes[self::ee_api_namespace.$version]['/resources'] = array(
291 291
 				array(
292 292
 					'callback' => array(
293 293
 						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 	 * @param array $route_data
309 309
 	 * @return array
310 310
 	 */
311
-	public function hide_old_endpoints( $route_data ) {
312
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
313
-			foreach( $relative_urls as $endpoint => $routes ) {
314
-				foreach( $routes as $route ) {
315
-					if( $route[ 'hidden_endpoint' ] ) {
316
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
317
-						unset( $route_data[ $full_route ] );
311
+	public function hide_old_endpoints($route_data) {
312
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
313
+			foreach ($relative_urls as $endpoint => $routes) {
314
+				foreach ($routes as $route) {
315
+					if ($route['hidden_endpoint']) {
316
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
317
+						unset($route_data[$full_route]);
318 318
 					}
319 319
 				}
320 320
 			}
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @return array
335 335
 	 */
336 336
 	public static function version_compatibilities() {
337
-		return apply_filters( 'FHEE__EED_Core_REST_API__version_compatibilities', array( '4.8.29' => '4.8.29' ) );
337
+		return apply_filters('FHEE__EED_Core_REST_API__version_compatibilities', array('4.8.29' => '4.8.29'));
338 338
 	}
339 339
 
340 340
 	/**
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 	public static function versions_served() {
349 349
 		$version_compatibilities = EED_Core_Rest_Api::version_compatibilities();
350 350
 		$versions_served = array();
351
-		$lowest_compatible_version = $version_compatibilities[ EED_Core_Rest_Api::core_version() ];
351
+		$lowest_compatible_version = $version_compatibilities[EED_Core_Rest_Api::core_version()];
352 352
 		//for each version of core we have ever served:
353
-		foreach( array_keys( EED_Core_Rest_Api::version_compatibilities() ) as $possibly_served_version ) {
353
+		foreach (array_keys(EED_Core_Rest_Api::version_compatibilities()) as $possibly_served_version) {
354 354
 			//if it's not above the current core version, and it's compatible with the current version of core
355
-			if(
355
+			if (
356 356
 				$possibly_served_version < EED_Core_Rest_Api::core_version()
357 357
 				&& $possibly_served_version >= $lowest_compatible_version
358 358
 			) {
359
-				$versions_served[ $possibly_served_version ] = true;
360
-			}else {
361
-				$versions_served[ $possibly_served_version ] = false;
359
+				$versions_served[$possibly_served_version] = true;
360
+			} else {
361
+				$versions_served[$possibly_served_version] = false;
362 362
 			}
363 363
 		}
364 364
 		return $versions_served;
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 * @return string
372 372
 	 */
373 373
 	public static function core_version() {
374
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
374
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
375 375
 	}
376 376
 
377 377
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param  WP $WP
384 384
 	 * @return    void
385 385
 	 */
386
-	public function run( $WP ) {
386
+	public function run($WP) {
387 387
 
388 388
 	}
389 389
 
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Read.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -653,6 +653,10 @@
 block discarded – undo
653 653
 		}
654 654
 		return $model_ready_query_params;
655 655
 	}
656
+
657
+	/**
658
+	 * @param \EEM_Base $model
659
+	 */
656 660
 	public function prepare_rest_query_params_values_for_models( $model,  $query_params ) {
657 661
 		$model_ready_query_params = array();
658 662
 		foreach( $query_params as $key => $value ) {
Please login to merge, or discard this patch.
Braces   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		){
228 228
 			if( $relation instanceof \EE_Belongs_To_Relation ) {
229 229
 				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
230
-			}else{
230
+			} else{
231 231
 				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
232 232
 			}
233 233
 			return new \WP_Error(
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		}
281 281
 		if( $relation instanceof \EE_Belongs_To_Relation ){
282 282
 			return array_shift( $nice_results );
283
-		}else{
283
+		} else{
284 284
 			return $nice_results;
285 285
 		}
286 286
 	}
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
 			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
332 332
 			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
333 333
 				unset( $result[ $field_name ] );
334
-			}elseif(
334
+			} elseif(
335 335
 				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
336 336
 			){
337 337
 				$result[ $field_name ] = array(
338 338
 					'raw' => $field_obj->prepare_for_get( $field_value ),
339 339
 					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
340 340
 				);
341
-			}elseif(
341
+			} elseif(
342 342
 				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
343 343
 			){
344 344
 				$result[ $field_name ] = array(
345 345
 					'raw' => $field_obj->prepare_for_get( $field_value ),
346 346
 					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
347 347
 				);
348
-			}elseif( $field_obj instanceof \EE_Datetime_Field ){
348
+			} elseif( $field_obj instanceof \EE_Datetime_Field ){
349 349
 				if( $raw_field_value instanceof \DateTime ) {
350 350
 					$raw_field_value = $raw_field_value->format( 'c' );
351 351
 				}
352 352
 				$result[ $field_name ] = mysql_to_rfc3339( $raw_field_value );
353
-			}else{
353
+			} else{
354 354
 				$value_prepared = $field_obj->prepare_for_get( $field_value );
355 355
 
356 356
 				$result[ $field_name ] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	public static function get_related_entity_name( $relation_name, $relation_obj ){
480 480
 		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
481 481
 			return strtolower( $relation_name );
482
-		}else{
482
+		} else{
483 483
 			return \EEH_Inflector::pluralize_and_lower( $relation_name );
484 484
 		}
485 485
 	}
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
549 549
 		if( in_array( $context, $valid_contexts )  ){
550 550
 			return $context;
551
-		}else{
551
+		} else{
552 552
 			return \EEM_Base::caps_read;
553 553
 		}
554 554
 	}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			$order_by = $query_parameters[ 'order_by' ];
574 574
 		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
575 575
 			$order_by = $query_parameters[ 'orderby' ];
576
-		}else{
576
+		} else{
577 577
 			$order_by = null;
578 578
 		}
579 579
 		if( $order_by !== null ){
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 			$group_by = $query_parameters[ 'group_by' ];
584 584
 		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
585 585
 			$group_by = $query_parameters[ 'groupby' ];
586
-		}else{
586
+		} else{
587 587
 			$group_by = null;
588 588
 		}
589 589
 		if( $group_by !== null ){
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
607 607
 			if( is_string( $query_parameters[ 'limit' ] ) ) {
608 608
 				$limit_array = explode(',', $query_parameters['limit']);
609
-			}else {
609
+			} else {
610 610
 				$limit_array = $query_parameters[ 'limit' ];
611 611
 			}
612 612
 			$sanitized_limit = array();
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 				$sanitized_limit[] = intval( $limit_part );
623 623
 			}
624 624
 			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
625
-		}else{
625
+		} else{
626 626
 			$model_query_params[ 'limit' ] = 50;
627 627
 		}
628 628
 		if( isset( $query_parameters[ 'caps' ] ) ) {
629 629
 			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
630
-		}else{
630
+		} else{
631 631
 			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
632 632
 		}
633 633
 		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		foreach( $query_params as $key => $value ) {
648 648
 			if( is_array( $value ) ) {
649 649
 				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
650
-			}else{
650
+			} else{
651 651
 				$model_ready_query_params[ $key ] = $value;
652 652
 			}
653 653
 		}
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 					//found the model name at the exact start
690 690
 					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
691 691
 					$extracted_fields_to_include[] = $field_sans_model_name;
692
-				}elseif( $field_to_include == $model_name ){
692
+				} elseif( $field_to_include == $model_name ){
693 693
 					$extracted_fields_to_include[] = '*';
694 694
 				}
695 695
 			}
696
-		}else{
696
+		} else{
697 697
 			//look for ones with no period
698 698
 			foreach( $includes as $field_to_include ) {
699 699
 				$field_to_include = trim( $field_to_include );
Please login to merge, or discard this patch.
Spacing   +244 added lines, -244 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\controllers\model;
3 3
 use EventEspresso\core\libraries\rest_api\Capabilities;
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
 /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 	public function __construct() {
26 26
 		parent::__construct();
27
-		\EE_Registry::instance()->load_helper( 'Inflector' );
27
+		\EE_Registry::instance()->load_helper('Inflector');
28 28
 	}
29 29
 
30 30
 	/**
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
 	 * @param \WP_REST_Request $request
33 33
 	 * @return \WP_REST_Response|\WP_Error
34 34
 	 */
35
-	public static function handle_request_get_all( \WP_REST_Request $request) {
35
+	public static function handle_request_get_all(\WP_REST_Request $request) {
36 36
 		$controller = new Read();
37
-		try{
37
+		try {
38 38
 			$matches = $controller->parse_route(
39 39
 				$request->get_route(),
40
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~',
41
-				array( 'version', 'model' )
40
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~',
41
+				array('version', 'model')
42 42
 			);
43
-			$controller->set_requested_version( $matches[ 'version' ] );
44
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
45
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
43
+			$controller->set_requested_version($matches['version']);
44
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
45
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
46 46
 				return $controller->send_response(
47 47
 					new \WP_Error(
48 48
 						'endpoint_parsing_error',
49 49
 						sprintf(
50
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
50
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
51 51
 							$model_name_singular
52 52
 						)
53 53
 					)
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 			}
56 56
 			return $controller->send_response(
57 57
 					$controller->get_entities_from_model(
58
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
58
+							$controller->get_model_version_info()->load_model($model_name_singular),
59 59
 							$request
60 60
 					)
61 61
 			);
62
-		} catch( \Exception $e ) {
63
-			return $controller->send_response( $e );
62
+		} catch (\Exception $e) {
63
+			return $controller->send_response($e);
64 64
 		}
65 65
 	}
66 66
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	 * @param \WP_Rest_Request $request
71 71
 	 * @return \WP_REST_Response|\WP_Error
72 72
 	 */
73
-	public static function handle_request_get_one( \WP_Rest_Request $request ) {
73
+	public static function handle_request_get_one(\WP_Rest_Request $request) {
74 74
 		$controller = new Read();
75
-		try{
75
+		try {
76 76
 			$matches = $controller->parse_route(
77 77
 				$request->get_route(),
78
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~',
79
-				array( 'version', 'model', 'id' ) );
80
-			$controller->set_requested_version( $matches[ 'version' ] );
81
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
82
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
78
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~',
79
+				array('version', 'model', 'id') );
80
+			$controller->set_requested_version($matches['version']);
81
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
82
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
83 83
 				return $controller->send_response(
84 84
 					new \WP_Error(
85 85
 						'endpoint_parsing_error',
86 86
 						sprintf(
87
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
87
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
88 88
 							$model_name_singular
89 89
 						)
90 90
 					)
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 			}
93 93
 			return $controller->send_response(
94 94
 					$controller->get_entity_from_model(
95
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
95
+							$controller->get_model_version_info()->load_model($model_name_singular),
96 96
 							$request
97 97
 						)
98 98
 				);
99
-		} catch( \Exception $e ) {
100
-			return $controller->send_response( $e );
99
+		} catch (\Exception $e) {
100
+			return $controller->send_response($e);
101 101
 		}
102 102
 	}
103 103
 
@@ -109,35 +109,35 @@  discard block
 block discarded – undo
109 109
 	 * @param \WP_REST_Request $request
110 110
 	 * @return \WP_REST_Response|\WP_Error
111 111
 	 */
112
-	public static function handle_request_get_related( \WP_REST_Request $request ) {
112
+	public static function handle_request_get_related(\WP_REST_Request $request) {
113 113
 		$controller = new Read();
114
-		try{
114
+		try {
115 115
 			$matches = $controller->parse_route(
116 116
 				$request->get_route(),
117
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~',
118
-				array( 'version', 'model', 'id', 'related_model' )
117
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~',
118
+				array('version', 'model', 'id', 'related_model')
119 119
 			);
120
-			$controller->set_requested_version( $matches[ 'version' ] );
121
-			$main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
122
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) {
120
+			$controller->set_requested_version($matches['version']);
121
+			$main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
122
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) {
123 123
 				return $controller->send_response(
124 124
 					new \WP_Error(
125 125
 						'endpoint_parsing_error',
126 126
 						sprintf(
127
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
127
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
128 128
 							$main_model_name_singular
129 129
 						)
130 130
 					)
131 131
 				);
132 132
 			}
133
-			$main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular );
134
-			$related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] );
135
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
133
+			$main_model = $controller->get_model_version_info()->load_model($main_model_name_singular);
134
+			$related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']);
135
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
136 136
 				return $controller->send_response(
137 137
 					new \WP_Error(
138 138
 						'endpoint_parsing_error',
139 139
 						sprintf(
140
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
140
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
141 141
 							$related_model_name_singular
142 142
 						)
143 143
 					)
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 
147 147
 			return $controller->send_response(
148 148
 					$controller->get_entities_from_relation(
149
-						$request->get_param( 'id' ),
150
-						$main_model->related_settings_for( $related_model_name_singular ) ,
149
+						$request->get_param('id'),
150
+						$main_model->related_settings_for($related_model_name_singular),
151 151
 						$request
152 152
 					)
153 153
 				);
154
-		} catch( \Exception $e ) {
155
-			return $controller->send_response( $e );
154
+		} catch (\Exception $e) {
155
+			return $controller->send_response($e);
156 156
 		}
157 157
 	}
158 158
 
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
 	 * @param \WP_REST_Request $request
166 166
 	 * @return array
167 167
 	 */
168
-	public function get_entities_from_model( $model, $request) {
169
-		$query_params = $this->create_model_query_params( $model, $request->get_params() );
170
-		if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) {
171
-			$model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() );
168
+	public function get_entities_from_model($model, $request) {
169
+		$query_params = $this->create_model_query_params($model, $request->get_params());
170
+		if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) {
171
+			$model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
172 172
 			return new \WP_Error(
173
-				sprintf( 'rest_%s_cannot_list', $model_name_plural ),
173
+				sprintf('rest_%s_cannot_list', $model_name_plural),
174 174
 				sprintf(
175
-					__( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ),
175
+					__('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'),
176 176
 					$model_name_plural,
177
-					Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] )
177
+					Capabilities::get_missing_permissions_string($model, $query_params['caps'])
178 178
 				),
179
-				array( 'status' => 403 )
179
+				array('status' => 403)
180 180
 			);
181 181
 		}
182 182
 
183
-		$this->_set_debug_info( 'model query params', $query_params );
184
-		$results = $model->get_all_wpdb_results( $query_params );
183
+		$this->_set_debug_info('model query params', $query_params);
184
+		$results = $model->get_all_wpdb_results($query_params);
185 185
 		$nice_results = array( );
186
-		foreach ( $results as $result ) {
187
-			$nice_results[ ] = $this->create_entity_from_wpdb_result(
186
+		foreach ($results as $result) {
187
+			$nice_results[] = $this->create_entity_from_wpdb_result(
188 188
 					$model,
189 189
 					$result,
190
-					$request->get_param( 'include' ),
191
-					$query_params[ 'caps' ]
190
+					$request->get_param('include'),
191
+					$query_params['caps']
192 192
 				);
193 193
 		}
194 194
 		return $nice_results;
@@ -205,82 +205,82 @@  discard block
 block discarded – undo
205 205
 	 * @param \WP_REST_Request $request
206 206
 	 * @return array
207 207
 	 */
208
-	public function get_entities_from_relation( $id,  $relation, $request ) {
209
-		$context = $this->validate_context( $request->get_param( 'caps' ));
208
+	public function get_entities_from_relation($id, $relation, $request) {
209
+		$context = $this->validate_context($request->get_param('caps'));
210 210
 		$model = $relation->get_this_model();
211 211
 		$related_model = $relation->get_other_model();
212 212
 		//check if they can access the 1st model object
213
-		$query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 );
214
-		if( $model instanceof \EEM_Soft_Delete_Base ){
213
+		$query_params = array(array($model->primary_key_name() => $id), 'limit' => 1);
214
+		if ($model instanceof \EEM_Soft_Delete_Base) {
215 215
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
216 216
 		}
217 217
 		$restricted_query_params = $query_params;
218
-		$restricted_query_params[ 'caps' ] = $context;
219
-		$this->_set_debug_info( 'main model query params', $restricted_query_params );
220
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) );
218
+		$restricted_query_params['caps'] = $context;
219
+		$this->_set_debug_info('main model query params', $restricted_query_params);
220
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context));
221 221
 
222
-		if(
222
+		if (
223 223
 			! (
224
-				Capabilities::current_user_has_partial_access_to( $related_model, $context )
225
-				&& $model->exists( $restricted_query_params )
224
+				Capabilities::current_user_has_partial_access_to($related_model, $context)
225
+				&& $model->exists($restricted_query_params)
226 226
 			)
227
-		){
228
-			if( $relation instanceof \EE_Belongs_To_Relation ) {
229
-				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
230
-			}else{
231
-				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
227
+		) {
228
+			if ($relation instanceof \EE_Belongs_To_Relation) {
229
+				$related_model_name_maybe_plural = strtolower($related_model->get_this_model_name());
230
+			} else {
231
+				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name());
232 232
 			}
233 233
 			return new \WP_Error(
234
-				sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ),
234
+				sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural),
235 235
 				sprintf(
236
-					__(	'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ),
236
+					__('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'),
237 237
 					$related_model_name_maybe_plural,
238 238
 					$relation->get_this_model()->get_this_model_name(),
239 239
 					implode(
240 240
 						',',
241 241
 						array_keys(
242
-							Capabilities::get_missing_permissions( $related_model, $context )
242
+							Capabilities::get_missing_permissions($related_model, $context)
243 243
 						)
244 244
 					)
245 245
 				),
246
-				array( 'status' => 403 )
246
+				array('status' => 403)
247 247
 			);
248 248
 		}
249
-		$query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() );
250
-		$query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id;
251
-		$query_params[ 'default_where_conditions' ] = 'none';
252
-		$query_params[ 'caps' ] = $context;
253
-		$this->_set_debug_info( 'model query params', $query_params );
254
-		$results = $relation->get_other_model()->get_all_wpdb_results( $query_params );
249
+		$query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params());
250
+		$query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id;
251
+		$query_params['default_where_conditions'] = 'none';
252
+		$query_params['caps'] = $context;
253
+		$this->_set_debug_info('model query params', $query_params);
254
+		$results = $relation->get_other_model()->get_all_wpdb_results($query_params);
255 255
 		$nice_results = array();
256
-		foreach( $results as $result ) {
256
+		foreach ($results as $result) {
257 257
 			$nice_result = $this->create_entity_from_wpdb_result(
258 258
 				$relation->get_other_model(),
259 259
 				$result,
260
-				$request->get_param( 'include' ),
261
-				$query_params[ 'caps' ]
260
+				$request->get_param('include'),
261
+				$query_params['caps']
262 262
 			);
263
-			if( $relation instanceof \EE_HABTM_Relation ) {
263
+			if ($relation instanceof \EE_HABTM_Relation) {
264 264
 				//put the unusual stuff (properties from the HABTM relation) first, and make sure
265 265
 				//if there are conflicts we prefer the properties from the main model
266 266
 				$join_model_result = $this->create_entity_from_wpdb_result(
267 267
 					$relation->get_join_model(),
268 268
 					$result,
269
-					$request->get_param( 'include' ),
270
-					$query_params[ 'caps' ]
269
+					$request->get_param('include'),
270
+					$query_params['caps']
271 271
 				);
272
-				$joined_result = array_merge( $nice_result, $join_model_result );
272
+				$joined_result = array_merge($nice_result, $join_model_result);
273 273
 				//but keep the meta stuff from the main model
274
-				if( isset( $nice_result['meta'] ) ){
274
+				if (isset($nice_result['meta'])) {
275 275
 					$joined_result['meta'] = $nice_result['meta'];
276 276
 				}
277 277
 				$nice_result = $joined_result;
278 278
 			}
279 279
 			$nice_results[] = $nice_result;
280 280
 		}
281
-		if( $relation instanceof \EE_Belongs_To_Relation ){
282
-			return array_shift( $nice_results );
283
-		}else{
281
+		if ($relation instanceof \EE_Belongs_To_Relation) {
282
+			return array_shift($nice_results);
283
+		} else {
284 284
 			return $nice_results;
285 285
 		}
286 286
 	}
@@ -317,110 +317,110 @@  discard block
 block discarded – undo
317 317
 	 * @param string $context one of the return values from EEM_Base::valid_cap_contexts()
318 318
 	 * @return array ready for being converted into json for sending to client
319 319
 	 */
320
-	public function create_entity_from_wpdb_result( $model, $db_row, $include, $context ) {
321
-		if( $include == null ) {
320
+	public function create_entity_from_wpdb_result($model, $db_row, $include, $context) {
321
+		if ($include == null) {
322 322
 			$include = '*';
323 323
 		}
324
-		if( $context == null ) {
324
+		if ($context == null) {
325 325
 			$context = \EEM_Base::caps_read;
326 326
 		}
327
-		$result = $model->deduce_fields_n_values_from_cols_n_values( $db_row );
328
-		$result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) );
329
-		foreach( $result as $field_name => $raw_field_value ) {
327
+		$result = $model->deduce_fields_n_values_from_cols_n_values($db_row);
328
+		$result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model));
329
+		foreach ($result as $field_name => $raw_field_value) {
330 330
 			$field_obj = $model->field_settings_for($field_name);
331
-			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
332
-			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
333
-				unset( $result[ $field_name ] );
334
-			}elseif(
335
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
336
-			){
337
-				$result[ $field_name ] = array(
338
-					'raw' => $field_obj->prepare_for_get( $field_value ),
339
-					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
331
+			$field_value = $field_obj->prepare_for_set_from_db($raw_field_value);
332
+			if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) {
333
+				unset($result[$field_name]);
334
+			}elseif (
335
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format())
336
+			) {
337
+				$result[$field_name] = array(
338
+					'raw' => $field_obj->prepare_for_get($field_value),
339
+					'rendered' => $field_obj->prepare_for_pretty_echoing($field_value)
340 340
 				);
341
-			}elseif(
342
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
343
-			){
344
-				$result[ $field_name ] = array(
345
-					'raw' => $field_obj->prepare_for_get( $field_value ),
346
-					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
341
+			}elseif (
342
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format())
343
+			) {
344
+				$result[$field_name] = array(
345
+					'raw' => $field_obj->prepare_for_get($field_value),
346
+					'pretty' => $field_obj->prepare_for_pretty_echoing($field_value)
347 347
 				);
348
-			}elseif( $field_obj instanceof \EE_Datetime_Field ){
349
-				if( $raw_field_value instanceof \DateTime ) {
350
-					$raw_field_value = $raw_field_value->format( 'c' );
348
+			}elseif ($field_obj instanceof \EE_Datetime_Field) {
349
+				if ($raw_field_value instanceof \DateTime) {
350
+					$raw_field_value = $raw_field_value->format('c');
351 351
 				}
352
-				$result[ $field_name ] = mysql_to_rfc3339( $raw_field_value );
353
-			}else{
354
-				$value_prepared = $field_obj->prepare_for_get( $field_value );
352
+				$result[$field_name] = mysql_to_rfc3339($raw_field_value);
353
+			} else {
354
+				$value_prepared = $field_obj->prepare_for_get($field_value);
355 355
 
356
-				$result[ $field_name ] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
356
+				$result[$field_name] = $value_prepared === INF ? EE_INF_IN_DB : $value_prepared;
357 357
 			}
358 358
 		}
359
-		if( $model instanceof \EEM_CPT_Base ) {
359
+		if ($model instanceof \EEM_CPT_Base) {
360 360
 			$attachment = wp_get_attachment_image_src(
361
-				get_post_thumbnail_id( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
361
+				get_post_thumbnail_id($db_row[$model->get_primary_key_field()->get_qualified_column()]),
362 362
 				'full'
363 363
 			);
364
-			$result[ 'featured_image_url' ] = !empty( $attachment ) ? $attachment[ 0 ] : null;
365
-			$result[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] );
364
+			$result['featured_image_url'] = ! empty($attachment) ? $attachment[0] : null;
365
+			$result['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]);
366 366
 		}
367 367
 		//add links to related data
368 368
 		$result['_links'] = array(
369 369
 			'self' => array(
370 370
 				array(
371 371
 					'href' => $this->get_versioned_link_to(
372
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $result[ $model->primary_key_name() ]
372
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$result[$model->primary_key_name()]
373 373
 					)
374 374
 				)
375 375
 			),
376 376
 			'collection' => array(
377 377
 				array(
378 378
 					'href' => $this->get_versioned_link_to(
379
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() )
379
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())
380 380
 					)
381 381
 				)
382 382
 			),
383 383
 		);
384 384
 		global $wp_rest_server;
385
-		if( $model instanceof \EEM_CPT_Base &&
385
+		if ($model instanceof \EEM_CPT_Base &&
386 386
 			$wp_rest_server instanceof \WP_REST_Server &&
387
-			$wp_rest_server->get_route_options( '/wp/v2/posts' ) ) {
388
-			$result[ '_links' ][ 'https://api.eventespresso.com/self_wp_post' ] = array(
387
+			$wp_rest_server->get_route_options('/wp/v2/posts')) {
388
+			$result['_links']['https://api.eventespresso.com/self_wp_post'] = array(
389 389
 				array(
390
-					'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
390
+					'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]),
391 391
 					'single' => true
392 392
 				)
393 393
 			);
394 394
 		}
395 395
 
396 396
 		//filter fields if specified
397
-		$includes_for_this_model = $this->extract_includes_for_this_model( $include );
398
-		if( ! empty( $includes_for_this_model ) ) {
399
-			if( $model->has_primary_key_field() ) {
397
+		$includes_for_this_model = $this->extract_includes_for_this_model($include);
398
+		if ( ! empty($includes_for_this_model)) {
399
+			if ($model->has_primary_key_field()) {
400 400
 				//always include the primary key
401 401
 				$includes_for_this_model[] = $model->primary_key_name();
402 402
 			}
403
-			$result = array_intersect_key( $result, array_flip( $includes_for_this_model ) );
403
+			$result = array_intersect_key($result, array_flip($includes_for_this_model));
404 404
 		}
405 405
 		//add meta links and possibly include related models
406 406
 		$relation_settings = apply_filters(
407 407
 			'FHEE__Read__create_entity_from_wpdb_result__related_models_to_include',
408 408
 			$model->relation_settings()
409 409
 		);
410
-		foreach( $relation_settings as $relation_name => $relation_obj ) {
411
-			$related_model_part = $this->get_related_entity_name( $relation_name, $relation_obj );
412
-			if( empty( $includes_for_this_model ) || isset( $includes_for_this_model['meta'] ) ) {
413
-				$result['_links']['https://api.eventespresso.com/' . $related_model_part] = array(
410
+		foreach ($relation_settings as $relation_name => $relation_obj) {
411
+			$related_model_part = $this->get_related_entity_name($relation_name, $relation_obj);
412
+			if (empty($includes_for_this_model) || isset($includes_for_this_model['meta'])) {
413
+				$result['_links']['https://api.eventespresso.com/'.$related_model_part] = array(
414 414
 					array(
415 415
 						'href' => $this->get_versioned_link_to(
416
-							\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $result[ $model->primary_key_name() ] . '/' . $related_model_part
416
+							\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$result[$model->primary_key_name()].'/'.$related_model_part
417 417
 						),
418 418
 						'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false
419 419
 					)
420 420
 				);
421 421
 			}
422
-			$related_fields_to_include = $this->extract_includes_for_this_model( $include, $relation_name );
423
-			if( $related_fields_to_include ) {
422
+			$related_fields_to_include = $this->extract_includes_for_this_model($include, $relation_name);
423
+			if ($related_fields_to_include) {
424 424
 				$pretend_related_request = new \WP_REST_Request();
425 425
 				$pretend_related_request->set_query_params(
426 426
 					array(
@@ -432,11 +432,11 @@  discard block
 block discarded – undo
432 432
 					)
433 433
 				);
434 434
 				$related_results = $this->get_entities_from_relation(
435
-					$result[ $model->primary_key_name() ],
435
+					$result[$model->primary_key_name()],
436 436
 					$relation_obj,
437 437
 					$pretend_related_request
438 438
 				);
439
-				$result[ $related_model_part ] = $related_results instanceof \WP_Error ? null : $related_results;
439
+				$result[$related_model_part] = $related_results instanceof \WP_Error ? null : $related_results;
440 440
 			}
441 441
 		}
442 442
 		$result = apply_filters(
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		);
454 454
 		$this->_set_debug_info(
455 455
 			'inaccessible fields',
456
-			array_keys( array_diff_key( $result, $result_without_inaccessible_fields ) )
456
+			array_keys(array_diff_key($result, $result_without_inaccessible_fields))
457 457
 		);
458 458
 		return apply_filters(
459 459
 			'FHEE__Read__create_entity_from_wpdb_results__entity_return',
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 	 * @param string $link_part_after_version_and_slash eg "events/10/datetimes"
469 469
 	 * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes"
470 470
 	 */
471
-	public function get_versioned_link_to( $link_part_after_version_and_slash ) {
472
-		return rest_url( \EED_Core_Rest_Api::ee_api_namespace . $this->get_model_version_info()->requested_version() . '/' . $link_part_after_version_and_slash );
471
+	public function get_versioned_link_to($link_part_after_version_and_slash) {
472
+		return rest_url(\EED_Core_Rest_Api::ee_api_namespace.$this->get_model_version_info()->requested_version().'/'.$link_part_after_version_and_slash);
473 473
 	}
474 474
 
475 475
 	/**
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 	 * @param \EE_Model_Relation_Base $relation_obj
480 480
 	 * @return string
481 481
 	 */
482
-	public static function get_related_entity_name( $relation_name, $relation_obj ){
483
-		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
484
-			return strtolower( $relation_name );
485
-		}else{
486
-			return \EEH_Inflector::pluralize_and_lower( $relation_name );
482
+	public static function get_related_entity_name($relation_name, $relation_obj) {
483
+		if ($relation_obj instanceof \EE_Belongs_To_Relation) {
484
+			return strtolower($relation_name);
485
+		} else {
486
+			return \EEH_Inflector::pluralize_and_lower($relation_name);
487 487
 		}
488 488
 	}
489 489
 
@@ -496,44 +496,44 @@  discard block
 block discarded – undo
496 496
 	 * @param \WP_REST_Request $request
497 497
 	 * @return array
498 498
 	 */
499
-	public function get_entity_from_model( $model, $request ) {
500
-		$query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1);
501
-		if( $model instanceof \EEM_Soft_Delete_Base ){
499
+	public function get_entity_from_model($model, $request) {
500
+		$query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
501
+		if ($model instanceof \EEM_Soft_Delete_Base) {
502 502
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
503 503
 		}
504 504
 		$restricted_query_params = $query_params;
505
-		$restricted_query_params[ 'caps' ] =  $this->validate_context(  $request->get_param( 'caps' ) );
506
-		$this->_set_debug_info( 'model query params', $restricted_query_params );
507
-		$model_rows = $model->get_all_wpdb_results( $restricted_query_params );
508
-		if ( ! empty ( $model_rows ) ) {
505
+		$restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
506
+		$this->_set_debug_info('model query params', $restricted_query_params);
507
+		$model_rows = $model->get_all_wpdb_results($restricted_query_params);
508
+		if ( ! empty ($model_rows)) {
509 509
 			return $this->create_entity_from_wpdb_result(
510 510
 				$model,
511
-				array_shift( $model_rows ),
512
-				$request->get_param( 'include' ),
513
-				$this->validate_context( $request->get_param( 'caps' ) ) );
511
+				array_shift($model_rows),
512
+				$request->get_param('include'),
513
+				$this->validate_context($request->get_param('caps')) );
514 514
 		} else {
515 515
 			//ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
516
-			$lowercase_model_name = strtolower( $model->get_this_model_name() );
517
-			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params );
518
-			if( ! empty( $model_rows_found_sans_restrictions ) ) {
516
+			$lowercase_model_name = strtolower($model->get_this_model_name());
517
+			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
518
+			if ( ! empty($model_rows_found_sans_restrictions)) {
519 519
 				//you got shafted- it existed but we didn't want to tell you!
520 520
 				return new \WP_Error(
521 521
 					'rest_user_cannot_read',
522 522
 					sprintf(
523
-						__( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ),
524
-						strtolower( $model->get_this_model_name() ),
523
+						__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'),
524
+						strtolower($model->get_this_model_name()),
525 525
 						Capabilities::get_missing_permissions_string(
526 526
 							$model,
527
-							$this->validate_context( $request->get_param( 'caps' ) ) )
527
+							$this->validate_context($request->get_param('caps')) )
528 528
 					),
529
-					array( 'status' => 403 )
529
+					array('status' => 403)
530 530
 				);
531 531
 			} else {
532 532
 				//it's not you. It just doesn't exist
533 533
 				return new \WP_Error(
534
-					sprintf( 'rest_%s_invalid_id', $lowercase_model_name ),
535
-					sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ),
536
-					array( 'status' => 404 )
534
+					sprintf('rest_%s_invalid_id', $lowercase_model_name),
535
+					sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name),
536
+					array('status' => 404)
537 537
 				);
538 538
 			}
539 539
 		}
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
 	 * @param string $context
547 547
 	 * @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
548 548
 	 */
549
-	public function validate_context( $context ) {
550
-		if( ! $context ) {
549
+	public function validate_context($context) {
550
+		if ( ! $context) {
551 551
 			$context = \EEM_Base::caps_read;
552 552
 		}
553 553
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
554
-		if( in_array( $context, $valid_contexts )  ){
554
+		if (in_array($context, $valid_contexts)) {
555 555
 			return $context;
556
-		}else{
556
+		} else {
557 557
 			return \EEM_Base::caps_read;
558 558
 		}
559 559
 	}
@@ -569,73 +569,73 @@  discard block
 block discarded – undo
569 569
 	 *                          that absolutely no results should be returned
570 570
 	 * @throws \EE_Error
571 571
 	 */
572
-	public function create_model_query_params( $model, $query_parameters ) {
572
+	public function create_model_query_params($model, $query_parameters) {
573 573
 		$model_query_params = array( );
574
-		if ( isset( $query_parameters[ 'where' ] ) ) {
575
-			$model_query_params[ 0 ] = $this->prepare_rest_query_params_key_for_models( $model, $query_parameters[ 'where' ] );
576
-		}
577
-		if ( isset( $query_parameters[ 'order_by' ] ) ) {
578
-			$order_by = $query_parameters[ 'order_by' ];
579
-		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
580
-			$order_by = $query_parameters[ 'orderby' ];
581
-		}else{
574
+		if (isset($query_parameters['where'])) {
575
+			$model_query_params[0] = $this->prepare_rest_query_params_key_for_models($model, $query_parameters['where']);
576
+		}
577
+		if (isset($query_parameters['order_by'])) {
578
+			$order_by = $query_parameters['order_by'];
579
+		} elseif (isset($query_parameters['orderby'])) {
580
+			$order_by = $query_parameters['orderby'];
581
+		} else {
582 582
 			$order_by = null;
583 583
 		}
584
-		if( $order_by !== null ){
585
-			$model_query_params[ 'order_by' ] = $this->prepare_rest_query_params_key_for_models( $model, $order_by );
584
+		if ($order_by !== null) {
585
+			$model_query_params['order_by'] = $this->prepare_rest_query_params_key_for_models($model, $order_by);
586 586
 		}
587
-		if ( isset( $query_parameters[ 'group_by' ] ) ) {
588
-			$group_by = $query_parameters[ 'group_by' ];
589
-		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
590
-			$group_by = $query_parameters[ 'groupby' ];
591
-		}else{
587
+		if (isset($query_parameters['group_by'])) {
588
+			$group_by = $query_parameters['group_by'];
589
+		} elseif (isset($query_parameters['groupby'])) {
590
+			$group_by = $query_parameters['groupby'];
591
+		} else {
592 592
 			$group_by = null;
593 593
 		}
594
-		if( $group_by !== null ){
595
-			if( is_array( $group_by ) ) {
596
-				$group_by = $this->prepare_rest_query_params_values_for_models( $model, $group_by );
594
+		if ($group_by !== null) {
595
+			if (is_array($group_by)) {
596
+				$group_by = $this->prepare_rest_query_params_values_for_models($model, $group_by);
597 597
 			}
598
-			$model_query_params[ 'group_by' ] = $group_by;
598
+			$model_query_params['group_by'] = $group_by;
599 599
 		}
600
-		if ( isset( $query_parameters[ 'having' ] ) ) {
600
+		if (isset($query_parameters['having'])) {
601 601
 			//@todo: no good for permissions
602
-			$model_query_params[ 'having' ] = $this->prepare_rest_query_params_key_for_models( $model, $query_parameters[ 'having' ] );
602
+			$model_query_params['having'] = $this->prepare_rest_query_params_key_for_models($model, $query_parameters['having']);
603 603
 		}
604
-		if ( isset( $query_parameters[ 'order' ] ) ) {
605
-			$model_query_params[ 'order' ] = $query_parameters[ 'order' ];
604
+		if (isset($query_parameters['order'])) {
605
+			$model_query_params['order'] = $query_parameters['order'];
606 606
 		}
607
-		if ( isset( $query_parameters[ 'mine' ] ) ){
608
-			$model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params );
607
+		if (isset($query_parameters['mine'])) {
608
+			$model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params);
609 609
 		}
610
-		if( isset( $query_parameters[ 'limit' ] ) ) {
610
+		if (isset($query_parameters['limit'])) {
611 611
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
612
-			if( is_string( $query_parameters[ 'limit' ] ) ) {
612
+			if (is_string($query_parameters['limit'])) {
613 613
 				$limit_array = explode(',', $query_parameters['limit']);
614
-			}else {
615
-				$limit_array = $query_parameters[ 'limit' ];
614
+			} else {
615
+				$limit_array = $query_parameters['limit'];
616 616
 			}
617 617
 			$sanitized_limit = array();
618
-			foreach( $limit_array as $key => $limit_part ) {
619
-				if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) {
618
+			foreach ($limit_array as $key => $limit_part) {
619
+				if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) {
620 620
 					throw new \EE_Error(
621 621
 						sprintf(
622
-							__( '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' ),
623
-							json_encode( $query_parameters[ 'limit' ] )
622
+							__('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'),
623
+							json_encode($query_parameters['limit'])
624 624
 						)
625 625
 					);
626 626
 				}
627
-				$sanitized_limit[] = intval( $limit_part );
627
+				$sanitized_limit[] = intval($limit_part);
628 628
 			}
629
-			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
630
-		}else{
631
-			$model_query_params[ 'limit' ] = 50;
629
+			$model_query_params['limit'] = implode(',', $sanitized_limit);
630
+		} else {
631
+			$model_query_params['limit'] = 50;
632 632
 		}
633
-		if( isset( $query_parameters[ 'caps' ] ) ) {
634
-			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
635
-		}else{
636
-			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
633
+		if (isset($query_parameters['caps'])) {
634
+			$model_query_params['caps'] = $this->validate_context($query_parameters['caps']);
635
+		} else {
636
+			$model_query_params['caps'] = \EEM_Base::caps_read;
637 637
 		}
638
-		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
638
+		return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model);
639 639
 	}
640 640
 
641 641
 
@@ -647,24 +647,24 @@  discard block
 block discarded – undo
647 647
 	 * @param array     $query_params sub-array from @see EEM_Base::get_all()
648 648
 	 * @return array
649 649
 	 */
650
-	public function prepare_rest_query_params_key_for_models( $model,  $query_params ) {
650
+	public function prepare_rest_query_params_key_for_models($model, $query_params) {
651 651
 		$model_ready_query_params = array();
652
-		foreach( $query_params as $key => $value ) {
653
-			if( is_array( $value ) ) {
654
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
655
-			}else{
656
-				$model_ready_query_params[ $key ] = $value;
652
+		foreach ($query_params as $key => $value) {
653
+			if (is_array($value)) {
654
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value);
655
+			} else {
656
+				$model_ready_query_params[$key] = $value;
657 657
 			}
658 658
 		}
659 659
 		return $model_ready_query_params;
660 660
 	}
661
-	public function prepare_rest_query_params_values_for_models( $model,  $query_params ) {
661
+	public function prepare_rest_query_params_values_for_models($model, $query_params) {
662 662
 		$model_ready_query_params = array();
663
-		foreach( $query_params as $key => $value ) {
664
-			if( is_array( $value ) ) {
665
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value );
663
+		foreach ($query_params as $key => $value) {
664
+			if (is_array($value)) {
665
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value);
666 666
 			} else {
667
-				$model_ready_query_params[ $key ] = $value;
667
+				$model_ready_query_params[$key] = $value;
668 668
 			}
669 669
 		}
670 670
 		return $model_ready_query_params;
@@ -680,33 +680,33 @@  discard block
 block discarded – undo
680 680
 	 * @return array of fields for this model. If $model_name is provided, then
681 681
 	 * the fields for that model, with the model's name removed from each.
682 682
 	 */
683
-	public function extract_includes_for_this_model( $include_string, $model_name = null ) {
684
-		if( is_array( $include_string ) ) {
685
-			$include_string = implode( ',', $include_string );
683
+	public function extract_includes_for_this_model($include_string, $model_name = null) {
684
+		if (is_array($include_string)) {
685
+			$include_string = implode(',', $include_string);
686 686
 		}
687
-		if( $include_string === '*' ) {
687
+		if ($include_string === '*') {
688 688
 			return array();
689 689
 		}
690
-		$includes = explode( ',', $include_string );
690
+		$includes = explode(',', $include_string);
691 691
 		$extracted_fields_to_include = array();
692
-		if( $model_name ){
693
-			foreach( $includes as $field_to_include ) {
694
-				$field_to_include = trim( $field_to_include );
695
-				if( strpos( $field_to_include, $model_name . '.' ) === 0 ) {
692
+		if ($model_name) {
693
+			foreach ($includes as $field_to_include) {
694
+				$field_to_include = trim($field_to_include);
695
+				if (strpos($field_to_include, $model_name.'.') === 0) {
696 696
 					//found the model name at the exact start
697
-					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
697
+					$field_sans_model_name = str_replace($model_name.'.', '', $field_to_include);
698 698
 					$extracted_fields_to_include[] = $field_sans_model_name;
699
-				}elseif( $field_to_include == $model_name ){
699
+				}elseif ($field_to_include == $model_name) {
700 700
 					$extracted_fields_to_include[] = '*';
701 701
 				}
702 702
 			}
703
-		}else{
703
+		} else {
704 704
 			//look for ones with no period
705
-			foreach( $includes as $field_to_include ) {
706
-				$field_to_include = trim( $field_to_include );
705
+			foreach ($includes as $field_to_include) {
706
+				$field_to_include = trim($field_to_include);
707 707
 				if (
708
-					strpos( $field_to_include, '.' ) === false
709
-					&& ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include )
708
+					strpos($field_to_include, '.') === false
709
+					&& ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include)
710 710
 				) {
711 711
 					$extracted_fields_to_include[] = $field_to_include;
712 712
 				}
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 1 patch
Spacing   +405 added lines, -405 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			'espresso_events' => 'edit'
68 68
 			);
69 69
 
70
-		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) );
70
+		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit'));
71 71
 	}
72 72
 
73 73
 	protected function _ajax_hooks() {
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 				'edit' => __('Update Event', 'event_espresso'),
94 94
 				'add_category' => __('Save New Category', 'event_espresso'),
95 95
 				'edit_category' => __('Update Category', 'event_espresso'),
96
-				'template_settings' => __( 'Update Settings', 'event_espresso' )
96
+				'template_settings' => __('Update Settings', 'event_espresso')
97 97
 				)
98 98
 		);
99 99
 	}
100 100
 
101 101
 	protected function _set_page_routes() {
102 102
 		//load formatter helper
103
-		EE_Registry::instance()->load_helper( 'Formatter' );
103
+		EE_Registry::instance()->load_helper('Formatter');
104 104
 		//load field generator helper
105
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
105
+		EE_Registry::instance()->load_helper('Form_Fields');
106 106
 
107 107
 		//is there a evt_id in the request?
108
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
109
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
108
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
109
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
110 110
 
111 111
 
112 112
 		$this->_page_routes = array(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				'help_tour' => array(
321 321
 					'Event_Editor_Help_Tour'
322 322
 					),
323
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
323
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
324 324
 				'require_nonce' => FALSE
325 325
 			),
326 326
 			'edit' => array(
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 				'help_tour' => array(
377 377
 					'Event_Edit_Help_Tour'
378 378
 				),
379
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
379
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
380 380
 				'require_nonce' => FALSE
381 381
 			),
382 382
 			'default_event_settings' => array(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 						'filename' => 'events_default_settings_status'
399 399
 					)
400 400
 				),
401
-				'help_tour' => array( 'Event_Default_Settings_Help_Tour'),
401
+				'help_tour' => array('Event_Default_Settings_Help_Tour'),
402 402
 				'require_nonce' => FALSE
403 403
 			),
404 404
 			//template settings
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 						'filename' => 'general_settings_templates'
415 415
 					)
416 416
 				),
417
-				'help_tour' => array( 'Templates_Help_Tour' ),
417
+				'help_tour' => array('Templates_Help_Tour'),
418 418
 				'require_nonce' => FALSE
419 419
 			),
420 420
 			//event category stuff
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					'label' => __('Edit Category', 'event_espresso'),
439 439
 					'order' => 15,
440 440
 					'persistent' => FALSE,
441
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
441
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
442 442
 					),
443 443
 				'help_tabs' => array(
444 444
 					'edit_category_help_tab' => array(
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 
509 509
 	public function load_scripts_styles() {
510 510
 
511
-		wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
511
+		wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
513 513
 		wp_enqueue_style('events-admin-css');
514 514
 		wp_enqueue_style('ee-cat-admin');
515 515
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
516 516
 		//registers for all views
517 517
 		//scripts
518
-		wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
518
+		wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
519 519
 	}
520 520
 
521 521
 	/**
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function load_scripts_styles_edit() {
534 534
 		//styles
535 535
 		wp_enqueue_style('espresso-ui-theme');
536
-		wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
536
+		wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
537 537
 		wp_enqueue_style('event-editor-css');
538 538
 
539 539
 		//scripts
540
-		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION );
540
+		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION);
541 541
 		wp_enqueue_script('event-datetime-metabox');
542 542
 
543 543
 	}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
 	public function admin_init() {
575
-		EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' );
575
+		EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso');
576 576
 	}
577 577
 
578 578
 
@@ -593,45 +593,45 @@  discard block
 block discarded – undo
593 593
 	 */
594 594
 	public function verify_event_edit($event = NULL) {
595 595
 		// no event?
596
-		if ( empty( $event )) {
596
+		if (empty($event)) {
597 597
 			// set event
598 598
 			$event = $this->_cpt_model_obj;
599 599
 		}
600 600
 		// STILL no event?
601
-		if ( empty ( $event )) {
601
+		if (empty ($event)) {
602 602
 			return;
603 603
 		}
604 604
 		// first check if event is active.
605
-		if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) {
605
+		if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) {
606 606
 			return;
607 607
 		}
608 608
 		$orig_status = $event->status();
609 609
 		//made it here so it IS active... next check that any of the tickets are sold.
610
-		if ( $event->is_sold_out( true ) ) {
611
-			if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out  ) {
610
+		if ($event->is_sold_out(true)) {
611
+			if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) {
612 612
 				EE_Error::add_attention(
613 613
 					sprintf(
614
-						__( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso' ),
615
-						EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' )
614
+						__('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso'),
615
+						EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence')
616 616
 					)
617 617
 				);
618 618
 			}
619 619
 			return;
620
-		} else if ( $orig_status === EEM_Event::sold_out ) {
620
+		} else if ($orig_status === EEM_Event::sold_out) {
621 621
 			EE_Error::add_attention(
622 622
 				sprintf(
623
-					__( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
-						'event_espresso' ),
625
-					EEH_Template::pretty_status( $event->status(), false, 'sentence' )
623
+					__('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
+						'event_espresso'),
625
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
626 626
 				)
627 627
 			);
628 628
 		}
629 629
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
630
-		if ( ! $event->tickets_on_sale() ) {
630
+		if ( ! $event->tickets_on_sale()) {
631 631
 			return;
632 632
 		}
633 633
 		//made it here so show warning
634
-		EE_Error::add_attention( $this->_edit_event_warning() );
634
+		EE_Error::add_attention($this->_edit_event_warning());
635 635
 	}
636 636
 
637 637
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			),
672 672
 		);
673 673
 
674
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
674
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
675 675
 			$this->_views['trash'] = array(
676 676
 				'slug' => 'trash',
677 677
 				'label' => __('Trash', 'event_espresso'),
@@ -701,39 +701,39 @@  discard block
 block discarded – undo
701 701
 				'desc' => __('View Registrations for Event', 'event_espresso')
702 702
 			)
703 703
 		);
704
-		$items  = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
704
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
705 705
 		$statuses = array(
706 706
 			'sold_out_status' => array(
707
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
708
-				'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' )
707
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
708
+				'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence')
709 709
 			),
710 710
 			'active_status' => array(
711
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
712
-				'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' )
711
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
712
+				'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence')
713 713
 			),
714 714
 			'upcoming_status' => array(
715
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
716
-				'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' )
715
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
716
+				'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence')
717 717
 			),
718 718
 			'postponed_status' => array(
719
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
720
-				'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' )
719
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
720
+				'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence')
721 721
 			),
722 722
 			'cancelled_status' => array(
723
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
724
-				'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' )
723
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
724
+				'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence')
725 725
 			),
726 726
 			'expired_status' => array(
727
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
728
-				'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' )
727
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
728
+				'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence')
729 729
 			),
730 730
 			'inactive_status' => array(
731
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
732
-				'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' )
731
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
732
+				'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence')
733 733
 			)
734 734
 		);
735
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
736
-		return array_merge( $items, $statuses );
735
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
736
+		return array_merge($items, $statuses);
737 737
 	}
738 738
 
739 739
 
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 	 * @return EEM_Event
746 746
 	 */
747 747
 	private function _event_model() {
748
-		if ( ! $this->_event_model instanceof EEM_Event ) {
749
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
748
+		if ( ! $this->_event_model instanceof EEM_Event) {
749
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
750 750
 		}
751 751
 		return $this->_event_model;
752 752
 	}
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 	 * @param  string $new_slug  what the slug is
766 766
 	 * @return string            The new html string for the permalink area
767 767
 	 */
768
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
768
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
769 769
 		//make sure this is only when editing
770
-		if ( !empty( $id ) ) {
771
-			$post = get_post( $id );
772
-			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> ';
773
-			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">';
770
+		if ( ! empty($id)) {
771
+			$post = get_post($id);
772
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> ';
773
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">';
774 774
 		}
775 775
 		return $return;
776 776
 	}
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @return string html for generated table
787 787
 	 */
788 788
 	protected function _events_overview_list_table() {
789
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
790
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) .
789
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
790
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button').
791 791
 		$this->_display_legend($this->_event_legend_items());
792 792
 		$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
793 793
 		$this->display_admin_list_table_page_with_no_sidebar();
@@ -805,51 +805,51 @@  discard block
 block discarded – undo
805 805
 
806 806
 
807 807
 
808
-	protected function _insert_update_cpt_item( $post_id, $post ) {
808
+	protected function _insert_update_cpt_item($post_id, $post) {
809 809
 
810
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
810
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
811 811
 			//getout we're not processing an event save.
812 812
 			return;
813 813
 		}
814 814
 
815 815
 		$event_values = array(
816
-			'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0,
817
-			'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
816
+			'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,
817
+			'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
818 818
 			'EVT_additional_limit' => min(
819
-					apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
820
-					!empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ),
821
-			'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
-			'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0,
823
-			'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
824
-			'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL,
825
-			'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL,
826
-			'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL
819
+					apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
820
+					! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ),
821
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
+			'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,
823
+			'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
824
+			'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL,
825
+			'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL,
826
+			'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL
827 827
 			);
828 828
 
829 829
 		//update event
830
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
830
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
831 831
 
832 832
 
833 833
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
834
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
835
-		$event = $this->_event_model()->get_one( array($get_one_where) );
834
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
835
+		$event = $this->_event_model()->get_one(array($get_one_where));
836 836
 
837 837
 
838 838
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
839
-		$event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) );
839
+		$event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')));
840 840
 
841 841
 		$att_success = TRUE;
842 842
 
843
-		foreach ( $event_update_callbacks as $e_callback ) {
844
-			$_succ = call_user_func_array( $e_callback, array( $event,  $this->_req_data ) );
845
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
843
+		foreach ($event_update_callbacks as $e_callback) {
844
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
845
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
846 846
 		}
847 847
 
848 848
 		//any errors?
849
-		if ( $success && FALSE === $att_success ) {
850
-			EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
851
-		} else if ( $success === FALSE ) {
852
-			EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
849
+		if ($success && FALSE === $att_success) {
850
+			EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851
+		} else if ($success === FALSE) {
852
+			EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
853 853
 		}
854 854
 	}
855 855
 
@@ -859,14 +859,14 @@  discard block
 block discarded – undo
859 859
 	/**
860 860
 	 * @see parent::restore_item()
861 861
 	 */
862
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
862
+	protected function _restore_cpt_item($post_id, $revision_id) {
863 863
 		//copy existing event meta to new post
864 864
 		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
865
-		if ( $post_evt instanceof EE_Event ) {
865
+		if ($post_evt instanceof EE_Event) {
866 866
 			//meta revision restore
867
-			$post_evt->restore_revision( $revision_id );
867
+			$post_evt->restore_revision($revision_id);
868 868
 			//related objs restore
869
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
869
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
870 870
 		}
871 871
 	}
872 872
 
@@ -879,52 +879,52 @@  discard block
 block discarded – undo
879 879
 	 * @param  array  $data   The request data from the form
880 880
 	 * @return bool           Success or fail.
881 881
 	 */
882
-	protected function _default_venue_update( $evtobj, $data ) {
883
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
882
+	protected function _default_venue_update($evtobj, $data) {
883
+		require_once(EE_MODELS.'EEM_Venue.model.php');
884 884
 		$venue_model = EE_Registry::instance()->load_model('Venue');
885 885
 		$rows_affected = NULL;
886
-		$venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL;
886
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL;
887 887
 
888 888
 		// very important.  If we don't have a venue name...
889 889
 		// then we'll get out because not necessary to create empty venue
890
-		if ( empty( $data['venue_title'] ) ) {
890
+		if (empty($data['venue_title'])) {
891 891
 			return false;
892 892
 		}
893 893
 
894 894
 		$venue_array = array(
895 895
 				'VNU_wp_user' => $evtobj->get('EVT_wp_user'),
896
-				'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL,
897
-				'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL,
898
-				'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL,
899
-				'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL,
900
-				'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL,
901
-				'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL,
902
-				'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL,
903
-				'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL,
904
-				'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL,
905
-				'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL,
906
-				'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL,
907
-				'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL,
908
-				'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL,
909
-				'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
-				'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL,
911
-				'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
896
+				'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL,
897
+				'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL,
898
+				'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL,
899
+				'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL,
900
+				'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL,
901
+				'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL,
902
+				'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL,
903
+				'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL,
904
+				'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL,
905
+				'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL,
906
+				'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL,
907
+				'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL,
908
+				'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL,
909
+				'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
+				'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL,
911
+				'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
912 912
 				'status' => 'publish'
913 913
 			);
914 914
 
915 915
 
916 916
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
917
-		if ( !empty( $venue_id ) ) {
918
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
919
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
917
+		if ( ! empty($venue_id)) {
918
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
919
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
920 920
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
921
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
921
+			$evtobj->_add_relation_to($venue_id, 'Venue');
922 922
 			return $rows_affected > 0 ? TRUE : FALSE;
923 923
 		} else {
924 924
 			//we insert the venue
925
-			$venue_id = $venue_model->insert( $venue_array );
926
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
927
-			return !empty( $venue_id ) ? TRUE : FALSE;
925
+			$venue_id = $venue_model->insert($venue_array);
926
+			$evtobj->_add_relation_to($venue_id, 'Venue');
927
+			return ! empty($venue_id) ? TRUE : FALSE;
928 928
 		}
929 929
 		//when we have the ancestor come in it's already been handled by the revision save.
930 930
 	}
@@ -938,55 +938,55 @@  discard block
 block discarded – undo
938 938
 	 * @param  array    $data   The request data from the form
939 939
 	 * @return bool             success or fail
940 940
 	 */
941
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
941
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
942 942
 		$success = true;
943 943
 		$saved_dtt = null;
944 944
 		$saved_tickets = array();
945
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
945
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
946 946
 
947
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
947
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
948 948
 			//trim all values to ensure any excess whitespace is removed.
949
-			$dtt =  array_map( 'trim', $dtt );
950
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
949
+			$dtt = array_map('trim', $dtt);
950
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
951 951
 			$datetime_values = array(
952
-				'DTT_ID' 		=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
952
+				'DTT_ID' 		=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
953 953
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
954 954
 				'DTT_EVT_end' 	=> $dtt['DTT_EVT_end'],
955
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
955
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
956 956
 				'DTT_order' 	=> $row,
957 957
 			);
958 958
 
959 959
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
960 960
 
961
-			if ( !empty( $dtt['DTT_ID'] ) ) {
962
-				$DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] );
963
-				$DTM->set_date_format( $incoming_date_formats[0] );
964
-				$DTM->set_time_format( $incoming_date_formats[1] );
965
-				foreach ( $datetime_values as $field => $value ) {
966
-					$DTM->set( $field, $value );
961
+			if ( ! empty($dtt['DTT_ID'])) {
962
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']);
963
+				$DTM->set_date_format($incoming_date_formats[0]);
964
+				$DTM->set_time_format($incoming_date_formats[1]);
965
+				foreach ($datetime_values as $field => $value) {
966
+					$DTM->set($field, $value);
967 967
 				}
968 968
 
969 969
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
970 970
 				$saved_dtts[$DTM->ID()] = $DTM;
971 971
 			} else {
972
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE );
973
-				$DTM->set_date_format( $incoming_date_formats[0] );
974
-				$DTM->set_time_format( $incoming_date_formats[1] );
975
-				$DTM->set_timezone( $evtobj->get_timezone() );
976
-				foreach ( $datetime_values as $field => $value ) {
977
-					$DTM->set( $field, $value );
972
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE);
973
+				$DTM->set_date_format($incoming_date_formats[0]);
974
+				$DTM->set_time_format($incoming_date_formats[1]);
975
+				$DTM->set_timezone($evtobj->get_timezone());
976
+				foreach ($datetime_values as $field => $value) {
977
+					$DTM->set($field, $value);
978 978
 				}
979 979
 			}
980 980
 			$DTM->save();
981 981
 
982
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
982
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
983 983
 
984 984
 			//load DTT helper
985 985
 			EE_Registry::instance()->load_helper('DTT_Helper');
986 986
 
987 987
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
988
-			if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) {
989
-				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') );
988
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
989
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
990 990
 				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
991 991
 				$DTT->save();
992 992
 			}
@@ -994,45 +994,45 @@  discard block
 block discarded – undo
994 994
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
995 995
 			$saved_dtt = $DTT;
996 996
 
997
-			$success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
997
+			$success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
998 998
 		}
999 999
 
1000 1000
 		//no dtts get deleted so we don't do any of that logic here.
1001 1001
 		//update tickets next
1002
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
1003
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
1004
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
1002
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1003
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1004
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1005 1005
 			$update_prices = false;
1006
-			$ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1006
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1007 1007
 
1008 1008
 			// trim inputs to ensure any excess whitespace is removed.
1009
-			$tkt = array_map( 'trim', $tkt );
1009
+			$tkt = array_map('trim', $tkt);
1010 1010
 
1011
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1011
+			if (empty($tkt['TKT_start_date'])) {
1012 1012
 				//let's use now in the set timezone.
1013
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1014
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1013
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1014
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1015 1015
 			}
1016 1016
 
1017
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1017
+			if (empty($tkt['TKT_end_date'])) {
1018 1018
 				//use the start date of the first datetime
1019 1019
 				$dtt = $evtobj->first_datetime();
1020
-				$tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] );
1020
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]);
1021 1021
 			}
1022 1022
 
1023 1023
 			$TKT_values = array(
1024
-				'TKT_ID' 			=> !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
1025
-				'TTM_ID' 			=> !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1026
-				'TKT_name' 			=> !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1027
-				'TKT_description' 	=> !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1024
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
1025
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1026
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1027
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1028 1028
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
1029 1029
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
1030
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'],
1031
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ],
1032
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1033
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1030
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1031
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1032
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1033
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1034 1034
 				'TKT_row' 			=> $row,
1035
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1035
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1036 1036
 				'TKT_price' 		=> $ticket_price
1037 1037
 			);
1038 1038
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 
1042 1042
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1043
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1043
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1044 1044
 				$TKT_values['TKT_ID'] = 0;
1045 1045
 				$TKT_values['TKT_is_default'] = 0;
1046 1046
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1051,58 +1051,58 @@  discard block
 block discarded – undo
1051 1051
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1052 1052
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1053 1053
 
1054
-			if ( !empty( $tkt['TKT_ID'] ) ) {
1055
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] );
1056
-				if ( $TKT instanceof EE_Ticket ) {
1057
-					$ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false;
1054
+			if ( ! empty($tkt['TKT_ID'])) {
1055
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']);
1056
+				if ($TKT instanceof EE_Ticket) {
1057
+					$ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false;
1058 1058
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1059
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false;
1060
-					$TKT->set_date_format( $incoming_date_formats[ 0 ] );
1061
-					$TKT->set_time_format( $incoming_date_formats[ 1 ] );
1059
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false;
1060
+					$TKT->set_date_format($incoming_date_formats[0]);
1061
+					$TKT->set_time_format($incoming_date_formats[1]);
1062 1062
 					//set new values
1063
-					foreach ( $TKT_values as $field => $value ) {
1064
-						if ( $field == 'TKT_qty' ) {
1065
-							$TKT->set_qty( $value );
1063
+					foreach ($TKT_values as $field => $value) {
1064
+						if ($field == 'TKT_qty') {
1065
+							$TKT->set_qty($value);
1066 1066
 						} else {
1067
-							$TKT->set( $field, $value );
1067
+							$TKT->set($field, $value);
1068 1068
 						}
1069 1069
 					}
1070 1070
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1071
-					if ( $create_new_TKT ) {
1071
+					if ($create_new_TKT) {
1072 1072
 						//archive the old ticket first
1073
-						$TKT->set( 'TKT_deleted', 1 );
1073
+						$TKT->set('TKT_deleted', 1);
1074 1074
 						$TKT->save();
1075 1075
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1076
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1076
+						$saved_tickets[$TKT->ID()] = $TKT;
1077 1077
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1078 1078
 						$TKT = clone $TKT;
1079
-						$TKT->set( 'TKT_ID', 0 );
1080
-						$TKT->set( 'TKT_deleted', 0 );
1081
-						$TKT->set( 'TKT_price', $ticket_price );
1082
-						$TKT->set( 'TKT_sold', 0 );
1079
+						$TKT->set('TKT_ID', 0);
1080
+						$TKT->set('TKT_deleted', 0);
1081
+						$TKT->set('TKT_price', $ticket_price);
1082
+						$TKT->set('TKT_sold', 0);
1083 1083
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1084 1084
 						$update_prices = true;
1085 1085
 					}
1086 1086
 					//make sure price is set if it hasn't been already
1087
-					$TKT->set( 'TKT_price', $ticket_price );
1087
+					$TKT->set('TKT_price', $ticket_price);
1088 1088
 				}
1089 1089
 
1090 1090
 			} else {
1091 1091
 				//no TKT_id so a new TKT
1092 1092
 				$TKT_values['TKT_price'] = $ticket_price;
1093
-				$TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE );
1094
-				if ( $TKT instanceof EE_Ticket ) {
1093
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE);
1094
+				if ($TKT instanceof EE_Ticket) {
1095 1095
 					//need to reset values to properly account for the date formats
1096
-					$TKT->set_date_format( $incoming_date_formats[0] );
1097
-					$TKT->set_time_format( $incoming_date_formats[1] );
1098
-					$TKT->set_timezone( $evtobj->get_timezone() );
1096
+					$TKT->set_date_format($incoming_date_formats[0]);
1097
+					$TKT->set_time_format($incoming_date_formats[1]);
1098
+					$TKT->set_timezone($evtobj->get_timezone());
1099 1099
 
1100 1100
 					//set new values
1101
-					foreach ( $TKT_values as $field => $value ) {
1102
-						if ( $field == 'TKT_qty' ) {
1103
-							$TKT->set_qty( $value );
1101
+					foreach ($TKT_values as $field => $value) {
1102
+						if ($field == 'TKT_qty') {
1103
+							$TKT->set_qty($value);
1104 1104
 						} else {
1105
-							$TKT->set( $field, $value );
1105
+							$TKT->set($field, $value);
1106 1106
 						}
1107 1107
 					}
1108 1108
 
@@ -1110,32 +1110,32 @@  discard block
 block discarded – undo
1110 1110
 				}
1111 1111
 			}
1112 1112
 			// cap ticket qty by datetime reg limits
1113
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1113
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1114 1114
 			//update ticket.
1115 1115
 			$TKT->save();
1116 1116
 
1117 1117
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1118
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
1119
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
1118
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1119
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1120 1120
 				EE_Registry::instance()->load_helper('DTT_Helper');
1121 1121
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1122 1122
 				$TKT->save();
1123 1123
 			}
1124 1124
 
1125 1125
 			//initially let's add the ticket to the dtt
1126
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1126
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1127 1127
 
1128 1128
 			$saved_tickets[$TKT->ID()] = $TKT;
1129 1129
 
1130 1130
 			//add prices to ticket
1131
-			$this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices );
1131
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1132 1132
 		}
1133 1133
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1134
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1134
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1136 1136
 
1137
-		foreach ( $tickets_removed as $id ) {
1138
-			$id = absint( $id );
1137
+		foreach ($tickets_removed as $id) {
1138
+			$id = absint($id);
1139 1139
 
1140 1140
 			//get the ticket for this id
1141 1141
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1144 1144
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
1145 1145
 
1146
-			foreach( $dtts as $dtt ) {
1146
+			foreach ($dtts as $dtt) {
1147 1147
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1148 1148
 			}
1149 1149
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1155 1155
 			$tkt_to_remove->delete_permanently();
1156 1156
 		}
1157
-		return array( $saved_dtt, $saved_tickets );
1157
+		return array($saved_dtt, $saved_tickets);
1158 1158
 	}
1159 1159
 
1160 1160
 
@@ -1169,31 +1169,31 @@  discard block
 block discarded – undo
1169 1169
 	 * @param bool 		$new_prices Whether attach existing incoming prices or create new ones.
1170 1170
 	 * @return  void
1171 1171
 	 */
1172
-	private function  _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) {
1173
-		foreach ( $prices as $row => $prc ) {
1172
+	private function  _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) {
1173
+		foreach ($prices as $row => $prc) {
1174 1174
 			$PRC_values = array(
1175
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
1176
-				'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL,
1177
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1178
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1179
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1175
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
1176
+				'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL,
1177
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1178
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1179
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1180 1180
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1181 1181
 				'PRC_order' => $row
1182 1182
 			);
1183 1183
 
1184
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1184
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1185 1185
 				$PRC_values['PRC_ID'] = 0;
1186
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
1186
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
1187 1187
 			} else {
1188
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1188
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1189 1189
 				//update this price with new values
1190
-				foreach ( $PRC_values as $field => $newprc ) {
1191
-					$PRC->set( $field, $newprc );
1190
+				foreach ($PRC_values as $field => $newprc) {
1191
+					$PRC->set($field, $newprc);
1192 1192
 				}
1193 1193
 				$PRC->save();
1194 1194
 			}
1195 1195
 
1196
-			$ticket->_add_relation_to( $PRC, 'Price' );
1196
+			$ticket->_add_relation_to($PRC, 'Price');
1197 1197
 		}
1198 1198
 	}
1199 1199
 
@@ -1216,33 +1216,33 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1218 1218
 
1219
-		$postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL;
1219
+		$postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL;
1220 1220
 
1221 1221
 
1222 1222
 		//if no postid then get out cause we need it for stuff in here
1223
-		if ( empty( $postid ) ) return;
1223
+		if (empty($postid)) return;
1224 1224
 
1225 1225
 
1226 1226
 		//handle datetime saves
1227 1227
 		$items = array();
1228 1228
 
1229
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $postid );
1230
-		$event = $this->_event_model()->get_one( array($get_one_where) );
1229
+		$get_one_where = array($this->_event_model()->primary_key_name() => $postid);
1230
+		$event = $this->_event_model()->get_one(array($get_one_where));
1231 1231
 
1232 1232
 		//now let's get the attached datetimes from the most recent autosave
1233 1233
 		$dtts = $event->get_many_related('Datetime');
1234 1234
 
1235 1235
 		$dtt_ids = array();
1236
-		foreach( $dtts as $dtt ) {
1236
+		foreach ($dtts as $dtt) {
1237 1237
 			$dtt_ids[] = $dtt->ID();
1238 1238
 			$order = $dtt->order();
1239 1239
 			$this->_template_args['data']['items']['ID-'.$order] = $dtt->ID();
1240 1240
 		}
1241
-		$this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids );
1241
+		$this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids);
1242 1242
 
1243 1243
 		//handle DECAF venues
1244 1244
 		//we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event.
1245
-		if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) {
1245
+		if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) {
1246 1246
 			$venue = $event->get_first_related('Venue');
1247 1247
 			$this->_template_args['data']['items']['venue-id'] = $venue->ID();
1248 1248
 		}
@@ -1253,23 +1253,23 @@  discard block
 block discarded – undo
1253 1253
 
1254 1254
 		$ticket_ids = array();
1255 1255
 		$price_ids = array();
1256
-		foreach ( $tickets as $ticket ) {
1256
+		foreach ($tickets as $ticket) {
1257 1257
 			$ticket_ids[] = $price->ID();
1258 1258
 			$ticket_order = $price->get('TKT_order');
1259
-			$this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID();
1260
-			$this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID();
1259
+			$this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID();
1260
+			$this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID();
1261 1261
 
1262 1262
 			//now we have to make sure the prices are updated appropriately
1263 1263
 			$prices = $ticket->get_many_related('Prices');
1264 1264
 
1265
-			foreach ( $prices as $price ) {
1265
+			foreach ($prices as $price) {
1266 1266
 				$price_ids[] = $price->ID();
1267 1267
 				$price_order = $price->get('PRC_order');
1268
-				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID();
1269
-				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID();
1270
-				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default');
1268
+				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID();
1269
+				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID();
1270
+				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default');
1271 1271
 			}
1272
-			$this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids);
1272
+			$this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids);
1273 1273
 		}
1274 1274
 		$this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids);
1275 1275
 	}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 	private function _generate_publish_box_extra_content() {
1288 1288
 
1289 1289
 		//load formatter helper
1290
-  		EE_Registry::instance()->load_helper( 'Formatter' );
1290
+  		EE_Registry::instance()->load_helper('Formatter');
1291 1291
 
1292 1292
   		//args for getting related registrations
1293
-  		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1294
-  		$not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) );
1295
-  		$pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) );
1293
+  		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1294
+  		$not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved));
1295
+  		$pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment));
1296 1296
 
1297 1297
 
1298 1298
 		// publish box
@@ -1321,9 +1321,9 @@  discard block
 block discarded – undo
1321 1321
 				),
1322 1322
 				REG_ADMIN_URL
1323 1323
 			),
1324
-			'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ),
1325
-			'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ),
1326
-			'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ),
1324
+			'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args),
1325
+			'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args),
1326
+			'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args),
1327 1327
 			'misc_pub_section_class' => apply_filters(
1328 1328
 				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1329 1329
 				'misc-pub-section'
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1343 1343
 			$this->_cpt_model_obj
1344 1344
 		);
1345
-		$publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean();
1345
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1346 1346
 		// load template
1347
-		EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args );
1347
+		EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args);
1348 1348
 	}
1349 1349
 
1350 1350
 
@@ -1376,16 +1376,16 @@  discard block
 block discarded – undo
1376 1376
 		$this->verify_cpt_object();
1377 1377
 		add_meta_box(
1378 1378
 			'espresso_event_editor_tickets',
1379
-			__( 'Event Datetime & Ticket', 'event_espresso' ),
1380
-			array( $this, 'ticket_metabox' ),
1379
+			__('Event Datetime & Ticket', 'event_espresso'),
1380
+			array($this, 'ticket_metabox'),
1381 1381
 			$this->page_slug,
1382 1382
 			'normal',
1383 1383
 			'high'
1384 1384
 		);
1385 1385
 		add_meta_box(
1386 1386
 			'espresso_event_editor_event_options',
1387
-			__( 'Event Registration Options', 'event_espresso' ),
1388
-			array( $this, 'registration_options_meta_box' ),
1387
+			__('Event Registration Options', 'event_espresso'),
1388
+			array($this, 'registration_options_meta_box'),
1389 1389
 			$this->page_slug,
1390 1390
 			'side',
1391 1391
 			'default'
@@ -1415,38 +1415,38 @@  discard block
 block discarded – undo
1415 1415
 			'disabled' => ''
1416 1416
 			);
1417 1417
 
1418
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL;
1418
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL;
1419 1419
 
1420
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1420
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1421 1421
 
1422 1422
 		/**
1423 1423
 		 * 1. Start with retrieving Datetimes
1424 1424
 		 * 2. Fore each datetime get related tickets
1425 1425
 		 * 3. For each ticket get related prices
1426 1426
 		 */
1427
-		$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id );
1428
-		EE_Registry::instance()->load_helper('DTT_Helper' );
1427
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1428
+		EE_Registry::instance()->load_helper('DTT_Helper');
1429 1429
 		/** @type EE_Datetime $first_datetime */
1430
-		$first_datetime = array_slice( $times, 0, 1 );
1430
+		$first_datetime = array_slice($times, 0, 1);
1431 1431
 		//do we get related tickets?
1432
-		if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) {
1433
-			foreach ( $times as $time ) {
1434
-				if ( $time instanceof EE_Datetime ) {
1432
+		if ($first_datetime[0]->get('DTT_ID') !== 0) {
1433
+			foreach ($times as $time) {
1434
+				if ($time instanceof EE_Datetime) {
1435 1435
 					$existing_datetime_ids[] = $time->get('DTT_ID');
1436 1436
 					$template_args['time'] = $time;
1437 1437
 					$related_tickets = $time->tickets(
1438 1438
 						array(
1439
-							array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1439
+							array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1440 1440
 							'default_where_conditions' => 'none'
1441 1441
 						)
1442 1442
 					);
1443 1443
 
1444
-					if ( !empty($related_tickets) ) {
1444
+					if ( ! empty($related_tickets)) {
1445 1445
 						$template_args['total_ticket_rows'] = count($related_tickets);
1446 1446
 						$row = 0;
1447
-						foreach ( $related_tickets as $ticket ) {
1447
+						foreach ($related_tickets as $ticket) {
1448 1448
 							$existing_ticket_ids[] = $ticket->get('TKT_ID');
1449
-							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row );
1449
+							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row);
1450 1450
 
1451 1451
 							$row++;
1452 1452
 						}
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 						$template_args['total_ticket_rows'] = 1;
1455 1455
 						/** @type EE_Ticket $ticket */
1456 1456
 						$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1457
-						$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1457
+						$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1458 1458
 					}
1459 1459
 				}
1460 1460
 			}
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 			$template_args['time'] = $times[0];
1463 1463
 			/** @type EE_Ticket $ticket */
1464 1464
 			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1465
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1465
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1466 1466
 			// NOTE: we're just sending the first default row
1467 1467
 			// (decaf can't manage default tickets so this should be sufficient);
1468 1468
 		}
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1472 1472
 		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1473 1473
 		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1474
-		$template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE );
1475
-		$template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' );
1474
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE);
1475
+		$template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php');
1476 1476
 		EEH_Template::display_template($template, $template_args);
1477 1477
 	}
1478 1478
 
@@ -1487,21 +1487,21 @@  discard block
 block discarded – undo
1487 1487
 	 * @param int        $row
1488 1488
 	 * @return string generated html for the ticket row.
1489 1489
 	 */
1490
-	private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) {
1490
+	private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) {
1491 1491
 		$template_args = array(
1492
-			'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),
1493
-			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '',
1492
+			'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(),
1493
+			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '',
1494 1494
 			'ticketrow' => $skeleton ? 'TICKETNUM' : $row,
1495 1495
 			'TKT_ID' => $ticket->get('TKT_ID'),
1496 1496
 			'TKT_name' => $ticket->get('TKT_name'),
1497 1497
 			'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1498 1498
 			'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1499 1499
 			'TKT_is_default' => $ticket->get('TKT_is_default'),
1500
-			'TKT_qty' => $ticket->get_pretty('TKT_qty','input'),
1500
+			'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'),
1501 1501
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1502 1502
 			'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'),
1503
-			'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
-			'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled'
1503
+			'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
+			'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled'
1505 1505
 			);
1506 1506
 
1507 1507
 		$price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object();
@@ -1517,23 +1517,23 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 		//make sure we have default start and end dates if skeleton
1519 1519
 		//handle rows that should NOT be empty
1520
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1520
+		if (empty($template_args['TKT_start_date'])) {
1521 1521
 			//if empty then the start date will be now.
1522 1522
 			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1523 1523
 		}
1524 1524
 
1525
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1525
+		if (empty($template_args['TKT_end_date'])) {
1526 1526
 			//get the earliest datetime (if present);
1527
-			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1527
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1528 1528
 
1529
-			if ( !empty( $earliest_dtt ) )
1529
+			if ( ! empty($earliest_dtt))
1530 1530
 				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1531 1531
 			else
1532
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1532
+				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")));
1533 1533
 		}
1534 1534
 
1535
-		$template_args = array_merge( $template_args, $price_args );
1536
-		$template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket);
1535
+		$template_args = array_merge($template_args, $price_args);
1536
+		$template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket);
1537 1537
 		return EEH_Template::display_template($template, $template_args, TRUE);
1538 1538
 	}
1539 1539
 
@@ -1562,8 +1562,8 @@  discard block
 block discarded – undo
1562 1562
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
1563 1563
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
1564 1564
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
1565
-		$template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values );
1566
-		$templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php';
1565
+		$template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values);
1566
+		$templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php';
1567 1567
 		EEH_Template::display_template($templatepath, $template_args);
1568 1568
 	}
1569 1569
 
@@ -1591,21 +1591,21 @@  discard block
 block discarded – undo
1591 1591
 		$EEME = $this->_event_model();
1592 1592
 
1593 1593
 		$offset = ($current_page - 1) * $per_page;
1594
-		$limit = $count ? NULL : $offset . ',' . $per_page;
1594
+		$limit = $count ? NULL : $offset.','.$per_page;
1595 1595
 		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1596 1596
 		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1597 1597
 
1598 1598
 		if (isset($this->_req_data['month_range'])) {
1599 1599
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1600
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1600
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1602 1602
 		}
1603 1603
 
1604 1604
 		$where = array();
1605 1605
 
1606
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
1606
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
1607 1607
 		//determine what post_status our condition will have for the query.
1608
-		switch ( $status ) {
1608
+		switch ($status) {
1609 1609
 			case 'month' :
1610 1610
 			case 'today' :
1611 1611
 			case NULL :
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 				break;
1614 1614
 
1615 1615
 			case 'draft' :
1616
-				$where['status'] = array( 'IN', array('draft', 'auto-draft') );
1616
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1617 1617
 				break;
1618 1618
 
1619 1619
 			default :
@@ -1621,43 +1621,43 @@  discard block
 block discarded – undo
1621 1621
 		}
1622 1622
 
1623 1623
 		//categories?
1624
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1624
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1625 1625
 
1626
-		if ( !empty ( $category ) ) {
1626
+		if ( ! empty ($category)) {
1627 1627
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1628 1628
 			$where['Term_Taxonomy.term_id'] = $category;
1629 1629
 		}
1630 1630
 
1631 1631
 		//date where conditions
1632
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1632
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1633 1633
 		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1634
-			$DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) );
1635
-			$start = $DateTime->format( implode( ' ', $start_formats  ) );
1636
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) );
1637
-			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) );
1634
+			$DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone()));
1635
+			$start = $DateTime->format(implode(' ', $start_formats));
1636
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1637
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1638 1638
 		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1639
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1640
-			$start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) );
1641
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1642
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1643
-		} else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) {
1644
-			$now = date( 'Y-m-01' );
1645
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1646
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1647
-			$end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1648
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1639
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1640
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1641
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1642
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1643
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1644
+			$now = date('Y-m-01');
1645
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1646
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1647
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1648
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1649 1649
 		}
1650 1650
 
1651 1651
 
1652
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1653
-			$where['EVT_wp_user'] =  get_current_user_id();
1652
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1653
+			$where['EVT_wp_user'] = get_current_user_id();
1654 1654
 		} else {
1655
-			if ( ! isset( $where['status'] ) ) {
1656
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1655
+			if ( ! isset($where['status'])) {
1656
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1657 1657
 					$where['OR'] = array(
1658
-						'status*restrict_private' => array( '!=', 'private' ),
1658
+						'status*restrict_private' => array('!=', 'private'),
1659 1659
 						'AND' => array(
1660
-							'status*inclusive' => array( '=', 'private' ),
1660
+							'status*inclusive' => array('=', 'private'),
1661 1661
 							'EVT_wp_user' => get_current_user_id()
1662 1662
 						)
1663 1663
 					);
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
 			}
1666 1666
 		}
1667 1667
 
1668
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1669
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1668
+		if (isset($this->_req_data['EVT_wp_user'])) {
1669
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1670 1670
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1671 1671
 			}
1672 1672
 		}
1673 1673
 
1674 1674
 
1675 1675
 		//search query handling
1676
-		if ( isset( $this->_req_data['s'] ) ) {
1677
-			$search_string = '%' . $this->_req_data['s'] . '%';
1676
+		if (isset($this->_req_data['s'])) {
1677
+			$search_string = '%'.$this->_req_data['s'].'%';
1678 1678
 			$where['OR'] = array(
1679 1679
 				'EVT_name' => array('LIKE', $search_string),
1680 1680
 				'EVT_desc' => array('LIKE', $search_string),
@@ -1683,32 +1683,32 @@  discard block
 block discarded – undo
1683 1683
 		}
1684 1684
 
1685 1685
 
1686
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1687
-		$query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data );
1686
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1687
+		$query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data);
1688 1688
 
1689 1689
 
1690 1690
 		//let's first check if we have special requests coming in.
1691
-		if ( isset( $this->_req_data['active_status'] ) ) {
1692
-			switch ( $this->_req_data['active_status'] ) {
1691
+		if (isset($this->_req_data['active_status'])) {
1692
+			switch ($this->_req_data['active_status']) {
1693 1693
 				case 'upcoming' :
1694
-					return $EEME->get_upcoming_events( $query_params, $count );
1694
+					return $EEME->get_upcoming_events($query_params, $count);
1695 1695
 					break;
1696 1696
 
1697 1697
 				case 'expired' :
1698
-					return $EEME->get_expired_events( $query_params, $count );
1698
+					return $EEME->get_expired_events($query_params, $count);
1699 1699
 					break;
1700 1700
 
1701 1701
 				case 'active' :
1702
-					return $EEME->get_active_events( $query_params, $count );
1702
+					return $EEME->get_active_events($query_params, $count);
1703 1703
 					break;
1704 1704
 
1705 1705
 				case 'inactive' :
1706
-					return $EEME->get_inactive_events( $query_params, $count );
1706
+					return $EEME->get_inactive_events($query_params, $count);
1707 1707
 					break;
1708 1708
 			}
1709 1709
 		}
1710 1710
 
1711
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1711
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1712 1712
 
1713 1713
 		return $events;
1714 1714
 	}
@@ -1717,23 +1717,23 @@  discard block
 block discarded – undo
1717 1717
 
1718 1718
 
1719 1719
 	//handling for WordPress CPT actions (trash, restore, delete)
1720
-	public function trash_cpt_item( $post_id ) {
1720
+	public function trash_cpt_item($post_id) {
1721 1721
 		$this->_req_data['EVT_ID'] = $post_id;
1722
-		$this->_trash_or_restore_event( 'trash', FALSE );
1722
+		$this->_trash_or_restore_event('trash', FALSE);
1723 1723
 	}
1724 1724
 
1725 1725
 
1726 1726
 
1727 1727
 
1728
-	public function restore_cpt_item( $post_id ) {
1728
+	public function restore_cpt_item($post_id) {
1729 1729
 		$this->_req_data['EVT_ID'] = $post_id;
1730
-		$this->_trash_or_restore_event( 'draft', FALSE );
1730
+		$this->_trash_or_restore_event('draft', FALSE);
1731 1731
 	}
1732 1732
 
1733 1733
 
1734
-	public function delete_cpt_item( $post_id ) {
1734
+	public function delete_cpt_item($post_id) {
1735 1735
 		$this->_req_data['EVT_ID'] = $post_id;
1736
-		$this->_delete_event( FALSE );
1736
+		$this->_delete_event(FALSE);
1737 1737
 	}
1738 1738
 
1739 1739
 
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 	 * @param  string $event_status
1746 1746
 	 * @return void
1747 1747
 	 */
1748
-	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1748
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) {
1749 1749
 		//determine the event id and set to array.
1750 1750
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1751 1751
 		// loop thru events
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			// clean status
1754 1754
 			$event_status = sanitize_key($event_status);
1755 1755
 			// grab status
1756
-			if (!empty($event_status)) {
1756
+			if ( ! empty($event_status)) {
1757 1757
 				$success = $this->_change_event_status($EVT_ID, $event_status);
1758 1758
 			} else {
1759 1759
 				$success = FALSE;
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
 		}
1768 1768
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1769 1769
 
1770
-		if ( $redirect_after )
1770
+		if ($redirect_after)
1771 1771
 			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1772 1772
 	}
1773 1773
 
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 		// clean status
1783 1783
 		$event_status = sanitize_key($event_status);
1784 1784
 		// grab status
1785
-		if (!empty($event_status)) {
1785
+		if ( ! empty($event_status)) {
1786 1786
 			$success = TRUE;
1787 1787
 			//determine the event id and set to array.
1788 1788
 			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
 	 * @param  string $event_status
1818 1818
 	 * @return bool
1819 1819
 	 */
1820
-	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1820
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1821 1821
 		// grab event id
1822
-		if (!$EVT_ID) {
1822
+		if ( ! $EVT_ID) {
1823 1823
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1824 1824
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1825 1825
 			return FALSE;
1826 1826
 		}
1827 1827
 
1828
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1828
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1829 1829
 
1830 1830
 		// clean status
1831 1831
 		$event_status = sanitize_key($event_status);
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 				$hook = FALSE;
1852 1852
 		}
1853 1853
 		//use class to change status
1854
-		$this->_cpt_model_obj->set_status( $event_status );
1854
+		$this->_cpt_model_obj->set_status($event_status);
1855 1855
 		$success = $this->_cpt_model_obj->save();
1856 1856
 
1857 1857
 		if ($success === FALSE) {
@@ -1873,15 +1873,15 @@  discard block
 block discarded – undo
1873 1873
 	 * @access protected
1874 1874
 	 * @param bool $redirect_after
1875 1875
 	 */
1876
-	protected function _delete_event( $redirect_after = TRUE ) {
1876
+	protected function _delete_event($redirect_after = TRUE) {
1877 1877
 		//determine the event id and set to array.
1878 1878
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL;
1879
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1879
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1880 1880
 
1881 1881
 
1882 1882
 		// loop thru events
1883 1883
 		if ($EVT_ID) {
1884
-			$success = $this->_permanently_delete_event( $EVT_ID );
1884
+			$success = $this->_permanently_delete_event($EVT_ID);
1885 1885
 			// get list of events with no prices
1886 1886
 			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1887 1887
 			// remove this event from the list of events with no prices
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1896 1896
 		}
1897 1897
 
1898
-		if ( $redirect_after )
1898
+		if ($redirect_after)
1899 1899
 			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1900 1900
 	}
1901 1901
 
@@ -1913,12 +1913,12 @@  discard block
 block discarded – undo
1913 1913
 		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1914 1914
 		// loop thru events
1915 1915
 		foreach ($EVT_IDs as $EVT_ID) {
1916
-			$EVT_ID = absint( $EVT_ID );
1917
-			if ( $EVT_ID ) {
1918
-				$results = $this->_permanently_delete_event( $EVT_ID );
1916
+			$EVT_ID = absint($EVT_ID);
1917
+			if ($EVT_ID) {
1918
+				$results = $this->_permanently_delete_event($EVT_ID);
1919 1919
 				$success = $results !== FALSE ? $success : FALSE;
1920 1920
 				// remove this event from the list of events with no prices
1921
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1921
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1922 1922
 			} else {
1923 1923
 				$success = FALSE;
1924 1924
 				$msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso');
@@ -1938,21 +1938,21 @@  discard block
 block discarded – undo
1938 1938
 	 * @param  int $EVT_ID
1939 1939
 	 * @return bool
1940 1940
 	 */
1941
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
1941
+	private function _permanently_delete_event($EVT_ID = 0) {
1942 1942
 		// grab event id
1943
-		if ( ! $EVT_ID ) {
1943
+		if ( ! $EVT_ID) {
1944 1944
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1945 1945
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1946 1946
 			return FALSE;
1947 1947
 		}
1948
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1948
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1949 1949
 
1950 1950
 		//need to delete related tickets and prices first.
1951 1951
 		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
1952
-		foreach ( $datetimes as $datetime ) {
1952
+		foreach ($datetimes as $datetime) {
1953 1953
 			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
1954 1954
 			$tickets = $datetime->get_many_related('Ticket');
1955
-			foreach ( $tickets as $ticket ) {
1955
+			foreach ($tickets as $ticket) {
1956 1956
 				$ticket->_remove_relation_to($datetime, 'Datetime');
1957 1957
 				$ticket->delete_related_permanently('Price');
1958 1958
 				$ticket->delete_permanently();
@@ -1962,14 +1962,14 @@  discard block
 block discarded – undo
1962 1962
 
1963 1963
 		//what about related venues or terms?
1964 1964
 		$venues = $this->_cpt_model_obj->get_many_related('Venue');
1965
-		foreach ( $venues as $venue ) {
1965
+		foreach ($venues as $venue) {
1966 1966
 			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
1967 1967
 		}
1968 1968
 
1969 1969
 		//any attached question groups?
1970 1970
 		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
1971
-		if ( !empty( $question_groups ) ) {
1972
-			foreach ( $question_groups as $question_group ) {
1971
+		if ( ! empty($question_groups)) {
1972
+			foreach ($question_groups as $question_group) {
1973 1973
 				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
1974 1974
 			}
1975 1975
 		}
@@ -1978,12 +1978,12 @@  discard block
 block discarded – undo
1978 1978
 
1979 1979
 
1980 1980
 		//Message Template Groups
1981
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
1981
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
1982 1982
 
1983 1983
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
1984 1984
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
1985 1985
 
1986
-		foreach ( $term_taxonomies as $term_taxonomy ) {
1986
+		foreach ($term_taxonomies as $term_taxonomy) {
1987 1987
 			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
1988 1988
 		}
1989 1989
 
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1998 1998
 			return FALSE;
1999 1999
 		}
2000
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID );
2000
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2001 2001
 		return TRUE;
2002 2002
 	}
2003 2003
 
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 	 */
2015 2015
 	public function total_events() {
2016 2016
 
2017
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2017
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2018 2018
 		return $count;
2019 2019
 	}
2020 2020
 
@@ -2029,10 +2029,10 @@  discard block
 block discarded – undo
2029 2029
 	 */
2030 2030
 	public function total_events_draft() {
2031 2031
 		$where = array(
2032
-			'status' => array( 'IN', array('draft', 'auto-draft' ) )
2032
+			'status' => array('IN', array('draft', 'auto-draft'))
2033 2033
 			);
2034 2034
 
2035
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2035
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2036 2036
 		return $count;
2037 2037
 	}
2038 2038
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 			'status' => 'trash'
2052 2052
 			);
2053 2053
 
2054
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2054
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2055 2055
 		return $count;
2056 2056
 	}
2057 2057
 
@@ -2079,11 +2079,11 @@  discard block
 block discarded – undo
2079 2079
 			// translated
2080 2080
 			TRUE
2081 2081
 		);
2082
-		$this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment;
2082
+		$this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment;
2083 2083
 
2084 2084
 		$this->_set_add_edit_form_tags('update_default_event_settings');
2085 2085
 		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
2086
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE);
2086
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE);
2087 2087
 		$this->display_admin_page_with_sidebar();
2088 2088
 	}
2089 2089
 
@@ -2109,9 +2109,9 @@  discard block
 block discarded – undo
2109 2109
 
2110 2110
 	protected function _template_settings() {
2111 2111
 		$this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso');
2112
-		$this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />';
2113
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>';
2114
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2112
+		$this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />';
2113
+		$this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>';
2114
+		$this->display_admin_caf_preview_page('template_settings_tab');
2115 2115
 	}
2116 2116
 
2117 2117
 
@@ -2124,22 +2124,22 @@  discard block
 block discarded – undo
2124 2124
 	 * @return void
2125 2125
 	 */
2126 2126
 	private function _set_category_object() {
2127
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2127
+		if (isset($this->_category->id) && ! empty($this->_category->id))
2128 2128
 			return; //already have the category object so get out.
2129 2129
 
2130 2130
 		//set default category object
2131 2131
 		$this->_set_empty_category_object();
2132 2132
 
2133 2133
 		//only set if we've got an id
2134
-		if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) {
2134
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2135 2135
 			return;
2136 2136
 		}
2137 2137
 
2138 2138
 		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2139 2139
 
2140
-		$term = get_term( $category_id, 'espresso_event_categories' );
2140
+		$term = get_term($category_id, 'espresso_event_categories');
2141 2141
 
2142
-		if ( !empty( $term ) ) {
2142
+		if ( ! empty($term)) {
2143 2143
 			$this->_category->category_name = $term->name;
2144 2144
 			$this->_category->category_identifier = $term->slug;
2145 2145
 			$this->_category->category_desc = $term->description;
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
 
2154 2154
 	private function _set_empty_category_object() {
2155 2155
 		$this->_category = new stdClass();
2156
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
2156
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2157 2157
 		$this->_category->id = $this->_category->parent = 0;
2158 2158
 	}
2159 2159
 
2160 2160
 
2161 2161
 	protected function _category_list_table() {
2162
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2162
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2163 2163
 		$this->_search_btn_label = __('Categories', 'event_espresso');
2164 2164
 		$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2');
2165 2165
 		$this->display_admin_list_table_page_with_sidebar();
@@ -2169,22 +2169,22 @@  discard block
 block discarded – undo
2169 2169
 	protected function _category_details($view) {
2170 2170
 
2171 2171
 		//load formatter helper
2172
-		EE_Registry::instance()->load_helper( 'Formatter' );
2172
+		EE_Registry::instance()->load_helper('Formatter');
2173 2173
 		//load field generator helper
2174
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
2174
+		EE_Registry::instance()->load_helper('Form_Fields');
2175 2175
 
2176 2176
 		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2177 2177
 		$this->_set_add_edit_form_tags($route);
2178 2178
 
2179 2179
 		$this->_set_category_object();
2180
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
2180
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2181 2181
 
2182 2182
 		$delete_action = 'delete_category';
2183 2183
 
2184 2184
 		//custom redirect
2185
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url );
2185
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
2186 2186
 
2187
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2187
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2188 2188
 
2189 2189
 		//take care of contents
2190 2190
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -2198,25 +2198,25 @@  discard block
 block discarded – undo
2198 2198
 			'type' => 'wp_editor',
2199 2199
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
2200 2200
 			'class' => 'my_editor_custom',
2201
-			'wpeditor_args' => array('media_buttons' => FALSE )
2201
+			'wpeditor_args' => array('media_buttons' => FALSE)
2202 2202
 		);
2203
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2203
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2204 2204
 
2205
-		$all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
2205
+		$all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
2206 2206
 
2207 2207
 		//setup category select for term parents.
2208 2208
 		$category_select_values[] = array(
2209 2209
 			'text' => __('No Parent', 'event_espresso'),
2210 2210
 			'id' => 0
2211 2211
 			);
2212
-		foreach ( $all_terms as $term ) {
2212
+		foreach ($all_terms as $term) {
2213 2213
 			$category_select_values[] = array(
2214 2214
 				'text' => $term->name,
2215 2215
 				'id' => $term->term_id
2216 2216
 				);
2217 2217
 		}
2218 2218
 
2219
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
2219
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
2220 2220
 
2221 2221
 		$template_args = array(
2222 2222
 			'category' => $this->_category,
@@ -2226,15 +2226,15 @@  discard block
 block discarded – undo
2226 2226
 			'disable' => '',
2227 2227
 			'disabled_message' => FALSE
2228 2228
 			);
2229
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2230
-		return EEH_Template::display_template($template, $template_args, TRUE );
2229
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2230
+		return EEH_Template::display_template($template, $template_args, TRUE);
2231 2231
 	}
2232 2232
 
2233 2233
 
2234 2234
 	protected function _delete_categories() {
2235
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2235
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2236 2236
 
2237
-		foreach ( $cat_ids as $cat_id ) {
2237
+		foreach ($cat_ids as $cat_id) {
2238 2238
 			$this->_delete_category($cat_id);
2239 2239
 		}
2240 2240
 
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 		$query_args = array(
2243 2243
 			'action' => 'category_list'
2244 2244
 			);
2245
-		$this->_redirect_after_action(0,'','',$query_args);
2245
+		$this->_redirect_after_action(0, '', '', $query_args);
2246 2246
 
2247 2247
 	}
2248 2248
 
@@ -2252,61 +2252,61 @@  discard block
 block discarded – undo
2252 2252
 
2253 2253
 	protected function _delete_category($cat_id) {
2254 2254
 		global $wpdb;
2255
-		$cat_id = absint( $cat_id );
2256
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2255
+		$cat_id = absint($cat_id);
2256
+		wp_delete_term($cat_id, 'espresso_event_categories');
2257 2257
 	}
2258 2258
 
2259 2259
 
2260 2260
 
2261 2261
 	protected function _insert_or_update_category($new_category) {
2262 2262
 
2263
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
2263
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
2264 2264
 		$success = 0; //we already have a success message so lets not send another.
2265 2265
 
2266
-		if ( $cat_id ) {
2266
+		if ($cat_id) {
2267 2267
 			$query_args = array(
2268 2268
 				'action'     => 'edit_category',
2269 2269
 				'EVT_CAT_ID' => $cat_id
2270 2270
 			);
2271 2271
 		} else {
2272
-			$query_args = array( 'action' => 'add_category' );
2272
+			$query_args = array('action' => 'add_category');
2273 2273
 		}
2274
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
2274
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
2275 2275
 
2276 2276
 	}
2277 2277
 
2278 2278
 
2279 2279
 
2280
-	private function _insert_category( $update = FALSE ) {
2280
+	private function _insert_category($update = FALSE) {
2281 2281
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2282
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2283
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2284
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2282
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2283
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2284
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2285 2285
 
2286
-		if ( empty( $category_name ) ) {
2287
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
2288
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2286
+		if (empty($category_name)) {
2287
+			$msg = __('You must add a name for the category.', 'event_espresso');
2288
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2289 2289
 			return false;
2290 2290
 		}
2291 2291
 
2292
-		$term_args=array(
2292
+		$term_args = array(
2293 2293
 			'name'=>$category_name,
2294 2294
 			'description'=>$category_desc,
2295 2295
 			'parent'=>$category_parent
2296 2296
 		);
2297 2297
 		//was the category_identifier input disabled?
2298
-		if(isset($this->_req_data['category_identifier'])){
2298
+		if (isset($this->_req_data['category_identifier'])) {
2299 2299
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2300 2300
 		}
2301
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2301
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2302 2302
 
2303
-		if ( !is_array( $insert_ids ) ) {
2304
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
2305
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2303
+		if ( ! is_array($insert_ids)) {
2304
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
2305
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2306 2306
 		} else {
2307 2307
 			$cat_id = $insert_ids['term_id'];
2308
-			$msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name );
2309
-			EE_Error::add_success( $msg );
2308
+			$msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name);
2309
+			EE_Error::add_success($msg);
2310 2310
 		}
2311 2311
 
2312 2312
 		return $cat_id;
@@ -2315,32 +2315,32 @@  discard block
 block discarded – undo
2315 2315
 
2316 2316
 
2317 2317
 
2318
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
2318
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
2319 2319
 		global $wpdb;
2320 2320
 
2321 2321
 		//testing term stuff
2322
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2324
-		$limit = ($current_page-1)*$per_page;
2322
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2324
+		$limit = ($current_page - 1) * $per_page;
2325 2325
 
2326
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2326
+		$where = array('taxonomy' => 'espresso_event_categories');
2327 2327
 
2328
-		if ( isset( $this->_req_data['s'] ) ) {
2329
-			$sstr = '%' . $this->_req_data['s'] . '%';
2328
+		if (isset($this->_req_data['s'])) {
2329
+			$sstr = '%'.$this->_req_data['s'].'%';
2330 2330
 			$where['OR'] = array(
2331
-				'Term.name' => array( 'LIKE', $sstr),
2332
-				'description' => array( 'LIKE', $sstr )
2331
+				'Term.name' => array('LIKE', $sstr),
2332
+				'description' => array('LIKE', $sstr)
2333 2333
 				);
2334 2334
 		}
2335 2335
 
2336 2336
 		$query_params = array(
2337
-			$where ,
2338
-			'order_by' => array( $orderby => $order ),
2339
-			'limit' => $limit . ',' . $per_page,
2337
+			$where,
2338
+			'order_by' => array($orderby => $order),
2339
+			'limit' => $limit.','.$per_page,
2340 2340
 			'force_join' => array('Term')
2341 2341
 			);
2342 2342
 
2343
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
2343
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
2344 2344
 
2345 2345
 		return $categories;
2346 2346
 	}
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
45 45
 	 * @return \Payments_Admin_Page
46 46
 	 */
47
-	public function __construct( $routing = TRUE ) {
48
-		parent::__construct( $routing );
47
+	public function __construct($routing = TRUE) {
48
+		parent::__construct($routing);
49 49
 	}
50 50
 
51 51
 
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	protected function _set_page_config() {
131 131
 		$payment_method_list_config = array(
132 132
 			'nav'           => array(
133
-				'label' => __( 'Payment Methods', 'event_espresso' ),
133
+				'label' => __('Payment Methods', 'event_espresso'),
134 134
 				'order' => 10
135 135
 			),
136 136
 			'metaboxes'     => $this->_default_espresso_metaboxes,
137 137
 			'help_tabs'     => array_merge(
138 138
 				array(
139 139
 					'payment_methods_overview_help_tab' => array(
140
-						'title'    => __( 'Payment Methods Overview', 'event_espresso' ),
140
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
141 141
 						'filename' => 'payment_methods_overview'
142 142
 					)
143 143
 				),
144 144
 				$this->_add_payment_method_help_tabs() ),
145
-			'help_tour'     => array( 'Payment_Methods_Selection_Help_Tour' ),
145
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
146 146
 			'require_nonce' => false
147 147
 		);
148 148
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 					)
161 161
 				),
162 162
 				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
163
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
163
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164 164
 				'require_nonce' => FALSE
165 165
 			),
166 166
 			'payment_log'=>array(
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @return array
181 181
 	 */
182
-	protected function _add_payment_method_help_tabs(){
182
+	protected function _add_payment_method_help_tabs() {
183 183
 		EE_Registry::instance()->load_lib('Payment_Method_Manager');
184 184
 		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
185 185
 		$all_pmt_help_tabs_config = array();
186
-		foreach( $payment_method_types as $payment_method_type ){
187
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) {
186
+		foreach ($payment_method_types as $payment_method_type) {
187
+			if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) {
188 188
 				continue;
189 189
 			}
190
-			foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){
191
-				$template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array();
192
-				$template_args[ 'admin_page_obj' ] = $this;
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
192
+				$template_args['admin_page_obj'] = $this;
193 193
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
194 194
 					'title'=>$config['title'],
195 195
 					'content'=>EEH_Template::display_template( 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	public function load_scripts_styles() {
219
-		wp_enqueue_script( 'ee_admin_js' );
220
-		wp_enqueue_script( 'ee-text-links' );
221
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
219
+		wp_enqueue_script('ee_admin_js');
220
+		wp_enqueue_script('ee-text-links');
221
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
222 222
 	}
223 223
 
224 224
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 	public function load_scripts_styles_default() {
229 229
 		//styles
230
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
231
-		wp_enqueue_style( 'espresso_payments' );
232
-		wp_enqueue_style( 'ee-text-links' );
230
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
231
+		wp_enqueue_style('espresso_payments');
232
+		wp_enqueue_style('ee-text-links');
233 233
 		//scripts
234 234
 	}
235 235
 
@@ -243,46 +243,46 @@  discard block
 block discarded – undo
243 243
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
244 244
 		 * recheck here.
245 245
 		 */
246
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
246
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
247 247
 		EEM_Payment_Method::instance()->verify_button_urls();
248
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
249
-		EE_Registry::instance()->load_helper( 'HTML' );
248
+		EE_Registry::instance()->load_helper('Tabbed_Content');
249
+		EE_Registry::instance()->load_helper('HTML');
250 250
 		//setup tabs, one for each payment method type
251 251
 		$tabs = array();
252 252
 		$payment_methods = array();
253
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
253
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
254 254
 			// we don't want to show admin-only PMTs for now
255
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
255
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
256 256
 				continue;
257 257
 			}
258 258
 			//check access
259
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
259
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
260 260
 				continue;
261 261
 			}
262 262
 			//check for any active pms of that type
263
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
264
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
263
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
264
+			if ( ! $payment_method instanceof EE_Payment_Method) {
265 265
 				$payment_method = EE_Payment_Method::new_instance(
266 266
 					array(
267
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
267
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
268 268
 						'PMD_type'					=>$pmt_obj->system_name(),
269 269
 						'PMD_name'				=>$pmt_obj->pretty_name(),
270 270
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
271 271
 					)
272 272
 				);
273 273
 			}
274
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
274
+			$payment_methods[$payment_method->slug()] = $payment_method;
275 275
 		}
276
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
277
-		foreach( $payment_methods as $payment_method ) {
278
-			if ( $payment_method instanceof EE_Payment_Method ) {
276
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
277
+		foreach ($payment_methods as $payment_method) {
278
+			if ($payment_method instanceof EE_Payment_Method) {
279 279
 				add_meta_box(
280 280
 					//html id
281
-					'espresso_' . $payment_method->slug() . '_payment_settings',
281
+					'espresso_'.$payment_method->slug().'_payment_settings',
282 282
 					//title
283
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
283
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
284 284
 					//callback
285
-					array( $this, 'payment_method_settings_meta_box' ),
285
+					array($this, 'payment_method_settings_meta_box'),
286 286
 					//post type
287 287
 					null,
288 288
 					//context
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 					//priority
291 291
 					'default',
292 292
 					//callback args
293
-					array( 'payment_method' => $payment_method )
293
+					array('payment_method' => $payment_method)
294 294
 				);
295 295
 				//setup for tabbed content
296
-				$tabs[ $payment_method->slug() ] = array(
296
+				$tabs[$payment_method->slug()] = array(
297 297
 					'label' => $payment_method->admin_name(),
298 298
 					'class' => $payment_method->active() ? 'gateway-active' : '',
299
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
300
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
299
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
300
+					'title' => __('Modify this Payment Method', 'event_espresso'),
301 301
 					'slug'  => $payment_method->slug()
302 302
 				);
303 303
 			}
304 304
 		}
305
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
305
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
306 306
 		$this->display_admin_page_with_sidebar();
307 307
 
308 308
 	}
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 	 *   _get_active_payment_method_slug
314 314
 	 * 	@return string
315 315
 	 */
316
-	protected function _get_active_payment_method_slug(){
316
+	protected function _get_active_payment_method_slug() {
317 317
 		$payment_method_slug = FALSE;
318 318
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
319
-		if ( isset( $this->_req_data['payment_method'] )) {
319
+		if (isset($this->_req_data['payment_method'])) {
320 320
 			// if they provided the current payment method, use it
321
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
321
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
322 322
 		}
323
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
323
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
324 324
 		// if that didn't work or wasn't provided, find another way to select the current pm
325
-		if ( ! $this->_verify_payment_method( $payment_method )) {
325
+		if ( ! $this->_verify_payment_method($payment_method)) {
326 326
 			// like, looking for an active one
327
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
327
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
328 328
 			// test that one as well
329
-			if ( $this->_verify_payment_method( $payment_method )) {
329
+			if ($this->_verify_payment_method($payment_method)) {
330 330
 				$payment_method_slug = $payment_method->slug();
331 331
 			} else {
332 332
 				$payment_method_slug = 'paypal_standard';
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	 * @param \EE_Payment_Method $payment_method
345 345
 	 * @return boolean
346 346
 	 */
347
-	protected function _verify_payment_method( $payment_method ){
347
+	protected function _verify_payment_method($payment_method) {
348 348
 		if (
349 349
 			$payment_method instanceof EE_Payment_Method &&
350 350
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
351
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
351
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
352 352
 		) {
353 353
 			return TRUE;
354 354
 		}
@@ -365,21 +365,21 @@  discard block
 block discarded – undo
365 365
 	 * @return string
366 366
 	 * @throws EE_Error
367 367
 	 */
368
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
369
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
370
-		if ( ! $payment_method instanceof EE_Payment_Method ){
371
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
368
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
369
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
370
+		if ( ! $payment_method instanceof EE_Payment_Method) {
371
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
372 372
 		}
373 373
 		$payment_method_scopes = $payment_method->active();
374 374
 		// if the payment method really exists show its form, otherwise the activation template
375
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
376
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
377
-				if ( $form->form_data_present_in( $this->_req_data )) {
378
-					$form->receive_form_submission( $this->_req_data );
375
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
376
+				$form = $this->_generate_payment_method_settings_form($payment_method);
377
+				if ($form->form_data_present_in($this->_req_data)) {
378
+					$form->receive_form_submission($this->_req_data);
379 379
 				}
380
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
380
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
381 381
 		} else {
382
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
382
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
383 383
 		}
384 384
 	}
385 385
 
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param \EE_Payment_Method $payment_method
393 393
 	 * @return \EE_Form_Section_Proper
394 394
 	 */
395
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
396
-		if ( ! $payment_method instanceof EE_Payment_Method ){
395
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
396
+		if ( ! $payment_method instanceof EE_Payment_Method) {
397 397
 			return new EE_Form_Section_Proper();
398 398
 		}
399 399
 		return new EE_Form_Section_Proper(
400 400
 			array(
401
-				'name' 	=> $payment_method->slug() . '_settings_form',
402
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
401
+				'name' 	=> $payment_method->slug().'_settings_form',
402
+				'html_id' 	=> $payment_method->slug().'_settings_form',
403 403
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
404 404
 					array(
405 405
 						'action' 						=> 'update_payment_method',
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 				'subsections' 			=> apply_filters(
412 412
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
413 413
 					array(
414
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
415
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
416
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
417
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
418
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
419
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
414
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
415
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
416
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
417
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
418
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
419
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
420 420
 					),
421 421
 					$payment_method
422 422
 				)
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 	 * @param \EE_Payment_Method $payment_method
434 434
 	 * @return \EE_Form_Section_Proper
435 435
 	 */
436
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
437
-		if ( $payment_method->type_obj()->requires_https() ) {
436
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
437
+		if ($payment_method->type_obj()->requires_https()) {
438 438
 			return new EE_Form_Section_HTML(
439 439
 				EEH_HTML::tr(
440 440
 					EEH_HTML::th(
441 441
 						EEH_HTML::label(
442
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
442
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
443 443
 						)
444
-					) .
444
+					).
445 445
 					EEH_HTML::td(
446
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
447
-						EEH_HTML::br() .
448
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
446
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
447
+						EEH_HTML::br().
448
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
449 449
 					)
450 450
 				)
451 451
 			);
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 	 * @param \EE_Payment_Method $payment_method
464 464
 	 * @return \EE_Form_Section_Proper
465 465
 	 */
466
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
467
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
466
+	protected function _currency_support(EE_Payment_Method $payment_method) {
467
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
468 468
 			return new EE_Form_Section_HTML(
469 469
 				EEH_HTML::tr(
470 470
 					EEH_HTML::th(
471 471
 						EEH_HTML::label(
472
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
472
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
473 473
 						)
474
-					) .
474
+					).
475 475
 					EEH_HTML::td(
476 476
 						EEH_HTML::strong(
477 477
 							sprintf(
478
-								__( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
478
+								__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
479 479
 								EE_Config::instance()->currency->code
480 480
 							)
481 481
 						)
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
 	 * @param \EE_Payment_Method $payment_method
496 496
 	 * @return \EE_Form_Section_HTML
497 497
 	 */
498
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
498
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
499 499
 		//modify the form so we only have/show fields that will be implemented for this version
500
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
500
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
501 501
 	}
502 502
 
503 503
 
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
 	 * @return \EE_Payment_Method_Form
511 511
 	 * @throws \EE_Error
512 512
 	 */
513
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
514
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
513
+	protected function _simplify_form($form_section, $payment_method_name = '') {
514
+		if ($form_section instanceof EE_Payment_Method_Form) {
515 515
 			$form_section->exclude(
516 516
 				array(
517 517
 					'PMD_type', //dont want them changing the type
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			);
523 523
 			return $form_section;
524 524
 		} else {
525
-			throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name ));
525
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
526 526
 		}
527 527
 	}
528 528
 
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 	 * @param \EE_Payment_Method $payment_method
536 536
 	 * @return \EE_Form_Section_HTML
537 537
 	 */
538
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
538
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
539 539
 		$update_button = new EE_Submit_Input(
540 540
 			array(
541
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
542
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
541
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
542
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
543 543
 				'html_label' => EEH_HTML::nbsp()
544 544
 			)
545 545
 		);
546 546
 		return new EE_Form_Section_HTML(
547
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
547
+			EEH_HTML::no_row(EEH_HTML::br(2)).
548 548
 			EEH_HTML::tr(
549
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
549
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
550 550
 				EEH_HTML::td(
551 551
 					$update_button->get_html_for_input()
552 552
 				)
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
 	 * @param \EE_Payment_Method $payment_method
564 564
 	 * @return \EE_Form_Section_Proper
565 565
 	 */
566
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
567
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
566
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
567
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
568 568
 		return new EE_Form_Section_HTML(
569 569
 			EEH_HTML::tr(
570
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
570
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
571 571
 				EEH_HTML::td(
572 572
 					EEH_HTML::link(
573 573
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 						),
580 580
 						$link_text_and_title,
581 581
 						$link_text_and_title,
582
-						'deactivate_' . $payment_method->slug(),
582
+						'deactivate_'.$payment_method->slug(),
583 583
 						'espresso-button button-secondary'
584 584
 					)
585 585
 				)
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @param \EE_Payment_Method $payment_method
596 596
 	 * @return \EE_Form_Section_Proper
597 597
 	 */
598
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
599
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
598
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
599
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
600 600
 		return new EE_Form_Section_Proper(
601 601
 			array(
602
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
603
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
602
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
603
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
604 604
 				'action' 	=> '#',
605 605
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
606 606
 				'subsections' 			=> apply_filters(
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 						new EE_Form_Section_HTML(
610 610
 							EEH_HTML::tr(
611 611
 								EEH_HTML::th(
612
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
613
-								) .
612
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
613
+								).
614 614
 								EEH_HTML::td(
615 615
 									EEH_HTML::link(
616 616
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 										),
623 623
 										$link_text_and_title,
624 624
 										$link_text_and_title,
625
-										'activate_' . $payment_method->slug(),
625
+										'activate_'.$payment_method->slug(),
626 626
 										'espresso-button-green button-primary'
627 627
 									)
628 628
 								)
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	protected function _fine_print() {
645 645
 		return new EE_Form_Section_HTML(
646 646
 			EEH_HTML::tr(
647
-				EEH_HTML::th() .
647
+				EEH_HTML::th().
648 648
 				EEH_HTML::td(
649
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
649
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
650 650
 				)
651 651
 			)
652 652
 		);
@@ -658,15 +658,15 @@  discard block
 block discarded – undo
658 658
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
659 659
 	 * @global WP_User $current_user
660 660
 	 */
661
-	protected function _activate_payment_method(){
662
-		if(isset($this->_req_data['payment_method_type'])){
661
+	protected function _activate_payment_method() {
662
+		if (isset($this->_req_data['payment_method_type'])) {
663 663
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
664 664
 			//see if one exists
665
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
666
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
665
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
666
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
667 667
 
668
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
669
-		}else{
668
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
669
+		} else {
670 670
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
671 671
 		}
672 672
 	}
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 	/**
675 675
 	 * Deactivates the payment method with the specified slug, and redirects.
676 676
 	 */
677
-	protected function _deactivate_payment_method(){
678
-		if(isset($this->_req_data['payment_method'])){
677
+	protected function _deactivate_payment_method() {
678
+		if (isset($this->_req_data['payment_method'])) {
679 679
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
680 680
 			//deactivate it
681 681
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
682
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
683
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
684
-		}else{
682
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
683
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
684
+		} else {
685 685
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
686 686
 		}
687 687
 	}
@@ -695,39 +695,39 @@  discard block
 block discarded – undo
695 695
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
696 696
 	 * @return void
697 697
 	 */
698
-	protected function _update_payment_method(){
699
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
698
+	protected function _update_payment_method() {
699
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
700 700
 			//ok let's find which gateway form to use based on the form input
701 701
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
702 702
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
703 703
 			$correct_pmt_form_to_use = NULL;
704 704
 			$pmt_obj = NULL;
705
-			foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){
705
+			foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
706 706
 				/** @var $pmt_obj EE_PMT_Base */
707 707
 				//get the form and simplify it, like what we do when we display it
708 708
 				$pmt_form = $pmt_obj->settings_form();
709 709
 				$this->_simplify_form($pmt_form);
710
-				if($pmt_form->form_data_present_in($this->_req_data)){
710
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
711 711
 					$correct_pmt_form_to_use = $pmt_form;
712 712
 					break;
713 713
 				}
714 714
 			}
715 715
 			//if we couldn't find the correct payment method type...
716
-			if( ! $correct_pmt_form_to_use ){
716
+			if ( ! $correct_pmt_form_to_use) {
717 717
 				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
718 718
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
719 719
 			}
720 720
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
721
-			if($correct_pmt_form_to_use->is_valid()){
721
+			if ($correct_pmt_form_to_use->is_valid()) {
722 722
 				$correct_pmt_form_to_use->save();
723 723
 				$pm = $correct_pmt_form_to_use->get_model_object();
724 724
 				/** @var $pm EE_Payment_Method */
725
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug()));
726
-			}else{
725
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug()));
726
+			} else {
727 727
 				EE_Error::add_error(
728 728
 					sprintf(
729 729
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
730
-						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' )
730
+						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso')
731 731
 					),
732 732
 					__FILE__,
733 733
 					__FUNCTION__,
@@ -744,11 +744,11 @@  discard block
 block discarded – undo
744 744
 	protected function _payment_settings() {
745 745
 
746 746
 		$this->_template_args['values'] = $this->_yes_no_values;
747
-		$this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE;
747
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE;
748 748
 
749
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
750
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
751
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
749
+		$this->_set_add_edit_form_tags('update_payment_settings');
750
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
751
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
752 752
 		$this->display_admin_page_with_sidebar();
753 753
 
754 754
 	}
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 	*		@return array
763 763
 	*/
764 764
 	protected function _update_payment_settings() {
765
-		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
765
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
767 767
 
768 768
 
769
-		$what = __('Payment Settings','event_espresso');
770
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
771
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
769
+		$what = __('Payment Settings', 'event_espresso');
770
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
771
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
772 772
 
773 773
 	}
774 774
 	protected function _payment_log_overview_list_table() {
@@ -794,18 +794,18 @@  discard block
 block discarded – undo
794 794
 	 * @param bool $count
795 795
 	 * @return array
796 796
 	 */
797
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
798
-		EE_Registry::instance()->load_model( 'Change_Log' );
797
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
798
+		EE_Registry::instance()->load_model('Change_Log');
799 799
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
800
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
800
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
801 801
 		//check if they've selected a specific payment method
802
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
802
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
803 803
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
804 804
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
805 805
 		}
806 806
 		//take into account search
807
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
808
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
807
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
808
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
809 809
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
810 810
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
811 811
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -820,48 +820,48 @@  discard block
 block discarded – undo
820 820
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
821 821
 
822 822
 		}
823
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
823
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
824 824
 			//add date
825
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
826
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
825
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
826
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
827 827
 			//make sure our timestamps start and end right at the boundaries for each day
828
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
829
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
828
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
829
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
830 830
 
831 831
 			//convert to timestamps
832
-			$start_date = strtotime( $start_date );
833
-			$end_date = strtotime( $end_date );
832
+			$start_date = strtotime($start_date);
833
+			$end_date = strtotime($end_date);
834 834
 
835 835
 			//makes sure start date is the lowest value and vice versa
836
-			$start_date = min( $start_date, $end_date );
837
-			$end_date = max( $start_date, $end_date );
836
+			$start_date = min($start_date, $end_date);
837
+			$end_date = max($start_date, $end_date);
838 838
 
839 839
 			//convert for query
840
-			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
841
-			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
840
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
841
+			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
842 842
 
843
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
843
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
844 844
 
845 845
 		}
846
-		if($count){
846
+		if ($count) {
847 847
 			return EEM_Change_Log::instance()->count($query_params);
848 848
 		}
849
-		if(isset($this->_req_data['order'])){
850
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
849
+		if (isset($this->_req_data['order'])) {
850
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
851 851
 			$query_params['order_by'] = array('LOG_time' => $sort);
852
-		}else{
852
+		} else {
853 853
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
854 854
 		}
855
-		$offset = ($current_page-1)*$per_page;
855
+		$offset = ($current_page - 1) * $per_page;
856 856
 
857
-		if( ! isset($this->_req_data['download_results'])){
858
-			$query_params['limit'] = array( $offset, $per_page );
857
+		if ( ! isset($this->_req_data['download_results'])) {
858
+			$query_params['limit'] = array($offset, $per_page);
859 859
 		}
860 860
 
861 861
 
862 862
 
863 863
 		//now they've requested to instead just download the file instead of viewing it.
864
-		if(isset($this->_req_data['download_results'])){
864
+		if (isset($this->_req_data['download_results'])) {
865 865
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
866 866
 			header('Content-Disposition: attachment');
867 867
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
 	 * @param EE_Change_Log $logB
884 884
 	 * @return int
885 885
 	 */
886
-	protected function _sort_logs_again($logA,$logB){
886
+	protected function _sort_logs_again($logA, $logB) {
887 887
 		$timeA = $logA->get_raw('LOG_time');
888 888
 		$timeB = $logB->get_raw('LOG_time');
889
-		if($timeA == $timeB){
889
+		if ($timeA == $timeB) {
890 890
 			return 0;
891 891
 		}
892 892
 		$comparison = $timeA < $timeB ? -1 : 1;
893
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
893
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
894 894
 			return $comparison * -1;
895
-		}else{
895
+		} else {
896 896
 			return $comparison;
897 897
 		}
898 898
 	}
899 899
 
900 900
 	protected function _payment_log_details() {
901
-		EE_Registry::instance()->load_model( 'Change_Log' );
901
+		EE_Registry::instance()->load_model('Change_Log');
902 902
 		/** @var $payment_log EE_Change_Log */
903 903
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
904 904
 		$payment_method = NULL;
905 905
 		$transaction = NULL;
906
-		if( $payment_log instanceof EE_Change_Log ){
907
-			if( $payment_log->object() instanceof EE_Payment ){
906
+		if ($payment_log instanceof EE_Change_Log) {
907
+			if ($payment_log->object() instanceof EE_Payment) {
908 908
 				$payment_method = $payment_log->object()->payment_method();
909 909
 				$transaction = $payment_log->object()->transaction();
910
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
910
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
911 911
 				$payment_method = $payment_log->object();
912 912
 			}
913 913
 		}
914 914
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
915
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
915
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
916 916
 			array(
917 917
 				'payment_log'=>$payment_log,
918 918
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	protected $_job_step_response = null;
38 38
 
39 39
 
40
-	public function __construct( $routing = TRUE ) {
41
-		parent::__construct( $routing );
40
+	public function __construct($routing = TRUE) {
41
+		parent::__construct($routing);
42 42
 	}
43 43
 
44 44
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 
54 54
 
55 55
 	protected function _ajax_hooks() {
56
-		add_action('wp_ajax_espresso_batch_continue',array($this,'batch_continue'));
57
-		add_action('wp_ajax_espresso_batch_cleanup',array($this,'batch_cleanup'));
56
+		add_action('wp_ajax_espresso_batch_continue', array($this, 'batch_continue'));
57
+		add_action('wp_ajax_espresso_batch_cleanup', array($this, 'batch_cleanup'));
58 58
 		
59 59
 	}
60 60
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 				'nav' => array(
103 103
 					'label' => __('Shortcodes', 'event_espresso'),
104 104
 					'order' => 30),
105
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ),
105
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
106 106
 				'require_nonce' => FALSE
107 107
 				),
108 108
 			'contact_support' => array(
109 109
 				'nav' => array(
110 110
 					'label' => __('Support', 'event_espresso'),
111 111
 					'order' => 40),
112
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_support_boxes' ) ),
112
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
113 113
 				'require_nonce' => FALSE
114 114
 				),
115 115
 			'developers' => array(
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 
138 138
 
139 139
 	protected function _installation() {
140
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
141
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE);
140
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
141
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE);
142 142
 		$this->display_admin_page_with_sidebar();
143 143
 	}
144 144
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 			'other_resources' => __('Other Resources', 'event_espresso')
164 164
 			);
165 165
 
166
-		foreach ( $boxes as $box => $label ) {
167
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
166
+		foreach ($boxes as $box => $label) {
167
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
168 168
 			$callback_args = array('template_path' => $template_path);
169
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
169
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
170 170
 		}
171 171
 	}
172 172
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 			'shortcodes_event_listings' => __('Event Listings', 'event_espresso'),
188 188
 			'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'),
189 189
 			'shortcodes_category' => __('Event Categories', 'event_espresso'),
190
-			'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' )
190
+			'shortcodes_attendee' => __('Event Attendees', 'event_espresso')
191 191
 			/*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/
192 192
 			/*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/
193 193
 			);
194 194
 
195
-		foreach ( $boxes as $box => $label ) {
196
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
195
+		foreach ($boxes as $box => $label) {
196
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
197 197
 			$callback_args = array('template_path' => $template_path);
198
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
198
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
199 199
 		}
200 200
 	}
201 201
 
@@ -214,41 +214,41 @@  discard block
 block discarded – undo
214 214
 			'important_information' => __('Important Information', 'event_espresso')
215 215
 			);
216 216
 
217
-		foreach ( $boxes as $box => $label ) {
218
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
217
+		foreach ($boxes as $box => $label) {
218
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
219 219
 			$callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args);
220
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
220
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
221 221
 		}
222 222
 	}
223 223
 
224 224
 
225 225
 	protected function _developers() {
226
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php';
227
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true );
226
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php';
227
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true);
228 228
 		$this->display_admin_page_with_sidebar();
229 229
 	}
230 230
 	
231 231
 	public function load_scripts_styles_batch_create() {	
232 232
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
233
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
234
-		wp_localize_script( 'support_batch_runner', 'ee_job_response', $job_response->to_array() );
235
-		wp_localize_script( 'support_batch_runner', 'ee_job_i18n', 
233
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
234
+		wp_localize_script('support_batch_runner', 'ee_job_response', $job_response->to_array());
235
+		wp_localize_script('support_batch_runner', 'ee_job_i18n', 
236 236
 			array(
237
-				'redirect_url' => $this->_req_data['redirect_url' ],
237
+				'redirect_url' => $this->_req_data['redirect_url'],
238 238
 			));
239 239
 	}
240 240
 	public function load_scripts_styles_batch_file_create() {
241 241
 		//creates a job based on the request variable
242 242
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
243
-		wp_enqueue_script( 'support_batch_file_runner', EE_SUPPORT_ASSETS_URL . 'support_batch_file_runner.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION,true);
244
-		wp_localize_script( 'support_batch_file_runner', 'ee_job_response', $job_response->to_array() );
245
-		wp_localize_script( 'support_batch_file_runner', 'ee_job_i18n', 
243
+		wp_enqueue_script('support_batch_file_runner', EE_SUPPORT_ASSETS_URL.'support_batch_file_runner.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
244
+		wp_localize_script('support_batch_file_runner', 'ee_job_response', $job_response->to_array());
245
+		wp_localize_script('support_batch_file_runner', 'ee_job_i18n', 
246 246
 				array(
247 247
 					'download_and_redirecting' => sprintf( 
248 248
 							__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
249
-							'<a href="' . $this->_req_data['redirect_url' ] .'">',
249
+							'<a href="'.$this->_req_data['redirect_url'].'">',
250 250
 							'</a>' ),
251
-					'redirect_url' => $this->_req_data['redirect_url' ],
251
+					'redirect_url' => $this->_req_data['redirect_url'],
252 252
 				));
253 253
 	}
254 254
 	
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
260 260
 	 */
261 261
 	protected function _enqueue_batch_job_scripts_and_styles_and_start_job() {
262
-		wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) );
263
-		wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION );
264
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
265
-		$job_handler_classname = stripslashes( $this->_req_data[ 'job_handler' ] );
262
+		wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery'));
263
+		wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION);
264
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
265
+		$job_handler_classname = stripslashes($this->_req_data['job_handler']);
266 266
 		$request_data = array_diff_key( 
267 267
 				$this->_req_data, 
268
-				array_flip( array( 'action',  'page' ) ) );
268
+				array_flip(array('action', 'page')) );
269 269
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
270 270
 		//eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
271
-		$job_response = $batch_runner->create_job( $job_handler_classname, $request_data );
271
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
272 272
 		//remember the response for later. We need it to display the page body
273 273
 		$this->_job_step_response = $job_response;
274 274
 		return $job_response;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * Invokes the report-generating code
278 278
 	 */
279 279
 	protected function batch_create() {		
280
-		echo EEH_Template::locate_template( EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_runner.template.html' );
280
+		echo EEH_Template::locate_template(EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_runner.template.html');
281 281
 	}
282 282
 	
283 283
 	/**
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * and then sends the user back to wherever they were before
286 286
 	 */
287 287
 	protected function batch_file_create() {
288
-		if( $this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse ) {
289
-			$filename = EEH_File::get_filename_from_filepath( $this->_job_step_response->job_parameters()->extra_datum( 'filepath' ) );
288
+		if ($this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse) {
289
+			$filename = EEH_File::get_filename_from_filepath($this->_job_step_response->job_parameters()->extra_datum('filepath'));
290 290
 		} else {
291
-			$filename = __( 'Unknown', 'event_espresso' );
291
+			$filename = __('Unknown', 'event_espresso');
292 292
 		}
293 293
 		echo EEH_Template::locate_template( 
294
-				EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_file_runner.template.html', 
294
+				EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_file_runner.template.html', 
295 295
 				array( 
296 296
 					'filename' => $filename 
297 297
 				)
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 * Receives ajax calls for continuing a job
303 303
 	 */
304 304
 	public function batch_continue() {
305
-		$job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] );
305
+		$job_id = sanitize_text_field($this->_req_data['job_id']);
306 306
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
307
-		$responseobj = $batch_runner->continue_job( $job_id);
308
-		$this->_template_args[ 'data' ] = $responseobj->to_array();
307
+		$responseobj = $batch_runner->continue_job($job_id);
308
+		$this->_template_args['data'] = $responseobj->to_array();
309 309
 		$this->_return_json();
310 310
 	}
311 311
 	
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * @return type
315 315
 	 */
316 316
 	public function batch_cleanup() {
317
-		$job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] );
317
+		$job_id = sanitize_text_field($this->_req_data['job_id']);
318 318
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
319
-		$response_obj = $batch_runner->cleanup_job( $job_id );
320
-		$this->_template_args[ 'data' ] = $response_obj->to_array();
319
+		$response_obj = $batch_runner->cleanup_job($job_id);
320
+		$this->_template_args['data'] = $response_obj->to_array();
321 321
 		$this->_return_json();
322 322
 	}
323 323
 
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Spacing   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		$this->_name = 'pricing';
55 55
 
56 56
 		//capability check
57
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) {
57
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
61
+		EE_Registry::instance()->load_helper('DTT_Helper');
62 62
 
63 63
 		//if we were going to add our own metaboxes we'd use the below.
64 64
 		$this->_metaboxes = array(
65 65
 			0 => array(
66
-				'page_route' => array('edit','create_new'),
66
+				'page_route' => array('edit', 'create_new'),
67 67
 				'func' => 'pricing_metabox',
68 68
 				'label' => __('Event Tickets & Datetimes', 'event_espresso'),
69 69
 				'priority' => 'high',
70 70
 				'context' => 'normal'
71 71
 				),
72 72
 
73
-			);/**/
73
+			); /**/
74 74
 
75 75
 		$this->_remove_metaboxes = array(
76 76
 			0 => array(
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
 		 *
90 90
 		 * @var array  Expected an array returned with 'date' and 'time' keys.
91 91
 		 */
92
-		$this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
92
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
93 93
 				'date' => 'Y-m-d',
94 94
 				'time' => 'h:i a'
95 95
 			));
96 96
 
97 97
 		//validate
98
-		$this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null;
99
-		$this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null;
98
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
99
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
100 100
 
101 101
 		//validate format strings
102
-		$format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
103
-		if ( is_array( $format_validation ) ) {
104
-			$msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>';
105
-			foreach ( $format_validation as $error ) {
106
-				$msg .= '<li>' . $error . '</li>';
102
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
103
+		if (is_array($format_validation)) {
104
+			$msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>';
105
+			foreach ($format_validation as $error) {
106
+				$msg .= '<li>'.$error.'</li>';
107 107
 			}
108
-			$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
109
-			EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
108
+			$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
109
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
110 110
 			$this->_date_format_strings = array(
111 111
 				'date' => 'Y-m-d',
112 112
 				'time' => 'h:i a'
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 		$this->_scripts_styles = array(
118 118
 			'registers' => array(
119 119
 				'ee-tickets-datetimes-css' => array(
120
-					'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
120
+					'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
121 121
 					'type' => 'css'
122 122
 					),
123 123
 				'ee-dtt-ticket-metabox' => array(
124
-					'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
124
+					'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
125 125
 					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
126 126
 					)
127 127
 				),
128 128
 			'deregisters' => array(
129
-				'event-editor-css' => array('type' => 'css' ),
129
+				'event-editor-css' => array('type' => 'css'),
130 130
 				'event-datetime-metabox' => array('type' => 'js')
131 131
 				),
132 132
 			'enqueues' => array(
133
-				'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ),
134
-				'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' )
133
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
134
+				'ee-dtt-ticket-metabox' => array('edit', 'create_new')
135 135
 				),
136 136
 			'localize' => array(
137 137
 				'ee-dtt-ticket-metabox' => array(
138 138
 					'DTT_TRASH_BLOCK' => array(
139 139
 						'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'),
140 140
 						'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'),
141
-						'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>',
141
+						'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>',
142 142
 						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
143 143
 						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
144
-						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>'
144
+						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>'
145 145
 						),
146 146
 					'DTT_ERROR_MSG' => array(
147 147
 						'no_ticket_name' => __('General Admission', 'event_espresso'),
148
-						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>'
148
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>'
149 149
 						),
150 150
 					'DTT_OVERSELL_WARNING' => array(
151 151
 						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'),
152 152
 						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso')
153 153
 						),
154
-					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ),
155
-					'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) )
154
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']),
155
+					'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week'))
156 156
 					)
157 157
 				)
158 158
 			);
159 159
 
160 160
 
161
-		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 );
162
-		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 );
161
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10);
162
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10);
163 163
 	}
164 164
 
165 165
 
166 166
 
167
-	public function caf_updates( $update_callbacks ) {
168
-		foreach ( $update_callbacks as $key => $callback ) {
169
-			if ( $callback[1] == '_default_tickets_update' )
170
-				unset( $update_callbacks[$key] );
167
+	public function caf_updates($update_callbacks) {
168
+		foreach ($update_callbacks as $key => $callback) {
169
+			if ($callback[1] == '_default_tickets_update')
170
+				unset($update_callbacks[$key]);
171 171
 		}
172 172
 
173
-		$update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' );
173
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
174 174
 		return $update_callbacks;
175 175
 	}
176 176
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param  array    $data   The request data from the form
184 184
 	 * @return bool             success or fail
185 185
 	 */
186
-	public function dtt_and_tickets_caf_update( $evtobj, $data ) {
186
+	public function dtt_and_tickets_caf_update($evtobj, $data) {
187 187
 		//first we need to start with datetimes cause they are the "root" items attached to events.
188
-		$saved_dtts = $this->_update_dtts( $evtobj, $data );
188
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
189 189
 		//next tackle the tickets (and prices?)
190
-		$this->_update_tkts( $evtobj, $saved_dtts, $data );
190
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
191 191
 	}
192 192
 
193 193
 
@@ -198,41 +198,41 @@  discard block
 block discarded – undo
198 198
 	 * @param  array    	$data    the request data from the form
199 199
 	 * @return EE_Datetime[]
200 200
 	 */
201
-	protected function _update_dtts( $evt_obj, $data ) {
202
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
201
+	protected function _update_dtts($evt_obj, $data) {
202
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
203 203
 		$saved_dtt_ids = array();
204 204
 		$saved_dtt_objs = array();
205 205
 
206
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
206
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
207 207
 			//trim all values to ensure any excess whitespace is removed.
208 208
 			$dtt = array_map(
209
-				function( $datetime_data ) {
210
-					return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data );
209
+				function($datetime_data) {
210
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
211 211
 				},
212 212
 				$dtt
213 213
 			);
214
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
214
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
215 215
 			$datetime_values = array(
216
-				'DTT_ID' 			=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
217
-				'DTT_name' 			=> ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '',
218
-				'DTT_description' 	=> ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '',
216
+				'DTT_ID' 			=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
217
+				'DTT_name' 			=> ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
218
+				'DTT_description' 	=> ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
219 219
 				'DTT_EVT_start' 	=> $dtt['DTT_EVT_start'],
220 220
 				'DTT_EVT_end' 		=> $dtt['DTT_EVT_end'],
221
-				'DTT_reg_limit' 	=> empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ],
222
-				'DTT_order' 		=> ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'],
221
+				'DTT_reg_limit' 	=> empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
222
+				'DTT_order' 		=> ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
223 223
 			);
224 224
 
225 225
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
226 226
 
227
-			if ( !empty( $dtt['DTT_ID'] ) ) {
228
-				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] );
227
+			if ( ! empty($dtt['DTT_ID'])) {
228
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
229 229
 
230 230
 				//set date and time format according to what is set in this class.
231
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
232
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
231
+				$DTM->set_date_format($this->_date_format_strings['date']);
232
+				$DTM->set_time_format($this->_date_format_strings['time']);
233 233
 
234
-				foreach ( $datetime_values as $field => $value ) {
235
-					$DTM->set( $field, $value );
234
+				foreach ($datetime_values as $field => $value) {
235
+					$DTM->set($field, $value);
236 236
 				}
237 237
 
238 238
 				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
241 241
 
242 242
 			} else {
243
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE );
243
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE);
244 244
 
245 245
 				//reset date and times to match the format
246
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
247
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
248
-				foreach( $datetime_values as $field => $value ) {
249
-					$DTM->set( $field, $value );
246
+				$DTM->set_date_format($this->_date_format_strings['date']);
247
+				$DTM->set_time_format($this->_date_format_strings['time']);
248
+				foreach ($datetime_values as $field => $value) {
249
+					$DTM->set($field, $value);
250 250
 				}
251 251
 			}
252 252
 
253 253
 
254 254
 			$DTM->save();
255
-			$DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' );
255
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
256 256
 			$evt_obj->save();
257 257
 
258 258
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
259
-			if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) {
260
-				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') );
259
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
260
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
261 261
 				EE_Registry::instance()->load_helper('DTT_Helper');
262 262
 				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
263 263
 				$DTM->save();
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
276
-		$old_datetimes = explode(',', $data['datetime_IDs'] );
276
+		$old_datetimes = explode(',', $data['datetime_IDs']);
277 277
 		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
278 278
 
279
-		if ( is_array( $old_datetimes ) ) {
280
-			$dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids );
281
-			foreach ( $dtts_to_delete as $id ) {
282
-				$id = absint( $id );
283
-				if ( empty( $id ) )
279
+		if (is_array($old_datetimes)) {
280
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
281
+			foreach ($dtts_to_delete as $id) {
282
+				$id = absint($id);
283
+				if (empty($id))
284 284
 					continue;
285 285
 
286 286
 				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
287 287
 
288 288
 				//remove tkt relationships.
289 289
 				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
290
-				foreach ( $related_tickets as $tkt ) {
290
+				foreach ($related_tickets as $tkt) {
291 291
 					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
292 292
 				}
293 293
 
294
-				$evt_obj->_remove_relation_to( $id, 'Datetime' );
294
+				$evt_obj->_remove_relation_to($id, 'Datetime');
295 295
 				$dtt_to_remove->refresh_cache_of_related_objects();
296 296
 
297 297
 			}
@@ -312,86 +312,86 @@  discard block
 block discarded – undo
312 312
 	 * @param  array            $data       incoming request data
313 313
 	 * @return EE_Ticket[]
314 314
 	 */
315
-	protected function _update_tkts( $evtobj, $saved_dtts, $data ) {
315
+	protected function _update_tkts($evtobj, $saved_dtts, $data) {
316 316
 
317 317
 		$new_tkt = null;
318 318
 		$new_default = null;
319 319
 		//stripslashes because WP filtered the $_POST ($data) array to add slashes
320 320
 		$data = stripslashes_deep($data);
321
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
321
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
322 322
 		$saved_tickets = $dtts_on_existing = array();
323
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
323
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
324 324
 
325 325
 		//load money helper
326
-		EE_Registry::instance()->load_helper( 'Money' );
326
+		EE_Registry::instance()->load_helper('Money');
327 327
 
328
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
328
+		foreach ($data['edit_tickets'] as $row => $tkt) {
329 329
 
330 330
 			$update_prices = $create_new_TKT = FALSE;
331 331
 
332 332
 			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
333 333
 
334
-			$starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]);
335
-			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] );
334
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
335
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
336 336
 			$dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
337 337
 			$dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
338 338
 
339 339
 			// trim inputs to ensure any excess whitespace is removed.
340 340
 			$tkt = array_map(
341
-				function( $ticket_data ) {
342
-					return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data );
341
+				function($ticket_data) {
342
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
343 343
 				},
344 344
 				$tkt
345 345
 			);
346 346
 
347 347
 			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
348 348
 			//note incoming ['TKT_price'] value is already in standard notation (via js).
349
-			$ticket_price = isset( $tkt['TKT_price'] ) ?  round ( (float) $tkt['TKT_price'], 3 ) : 0;
349
+			$ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0;
350 350
 
351 351
 			//note incoming base price needs converted from localized value.
352
-			$base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0;
352
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
353 353
 			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
354 354
 			$ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
355
-			$base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0;
355
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
356 356
 
357 357
 			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
358 358
 
359 359
 			$now = null;
360
-			if ( empty( $tkt['TKT_start_date'] ) ) {
360
+			if (empty($tkt['TKT_start_date'])) {
361 361
 				//lets' use now in the set timezone.
362
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
363
-				$tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
362
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
363
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
364 364
 			}
365 365
 
366
-			if ( empty( $tkt['TKT_end_date'] ) ) {
366
+			if (empty($tkt['TKT_end_date'])) {
367 367
 				/**
368 368
 				 * set the TKT_end_date to the first datetime attached to the ticket.
369 369
 				 */
370
-				$first_dtt = $saved_dtts[reset( $tkt_dtt_rows )];
371
-				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] );
370
+				$first_dtt = $saved_dtts[reset($tkt_dtt_rows)];
371
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']);
372 372
 			}
373 373
 
374 374
 			$TKT_values = array(
375
-				'TKT_ID' 			=> ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
376
-				'TTM_ID' 			=> ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
377
-				'TKT_name' 			=> ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
378
-				'TKT_description' 	=> ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
375
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
376
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
377
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
378
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
379 379
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
380 380
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
381
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ],
382
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'],
383
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
384
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
381
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
382
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
383
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
384
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
385 385
 				'TKT_row' 			=> $row,
386
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0,
387
-				'TKT_taxable' 		=> ! empty( $tkt['TKT_taxable'] ) ? 1 : 0,
388
-				'TKT_required' 		=> ! empty( $tkt['TKT_required'] ) ? 1 : 0,
386
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
387
+				'TKT_taxable' 		=> ! empty($tkt['TKT_taxable']) ? 1 : 0,
388
+				'TKT_required' 		=> ! empty($tkt['TKT_required']) ? 1 : 0,
389 389
 				'TKT_price' 		=> $ticket_price
390 390
 			);
391 391
 
392 392
 
393 393
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
394
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
394
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
395 395
 				$TKT_values['TKT_ID'] = 0;
396 396
 				$TKT_values['TKT_is_default'] = 0;
397 397
 				$update_prices = TRUE;
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
 			// but DID have it's items modified.
404 404
 			// keep in mind that if the TKT has been sold (and we have changed pricing information),
405 405
 			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
406
-			if ( absint( $TKT_values['TKT_ID'] ) ) {
407
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] );
408
-				if ( $TKT instanceof EE_Ticket ) {
406
+			if (absint($TKT_values['TKT_ID'])) {
407
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
408
+				if ($TKT instanceof EE_Ticket) {
409 409
 
410
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
410
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
411 411
 					// are there any registrations using this ticket ?
412 412
 					$tickets_sold = $TKT->count_related(
413 413
 						'Registration',
414
-						array( array(
415
-								'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) )
416
-						) )
414
+						array(array(
415
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
416
+						))
417 417
 					);
418 418
 					//set ticket formats
419
-					$TKT->set_date_format( $this->_date_format_strings['date'] );
420
-					$TKT->set_time_format( $this->_date_format_strings['time'] );
419
+					$TKT->set_date_format($this->_date_format_strings['date']);
420
+					$TKT->set_time_format($this->_date_format_strings['time']);
421 421
 
422 422
 					// let's just check the total price for the existing ticket
423 423
 					// and determine if it matches the new total price.
@@ -427,17 +427,17 @@  discard block
 block discarded – undo
427 427
 							? TRUE : FALSE;
428 428
 
429 429
 					//set new values
430
-					foreach ( $TKT_values as $field => $value ) {
431
-						if ( $field === 'TKT_qty' ) {
432
-							$TKT->set_qty( $value );
430
+					foreach ($TKT_values as $field => $value) {
431
+						if ($field === 'TKT_qty') {
432
+							$TKT->set_qty($value);
433 433
 						} else {
434
-							$TKT->set( $field, $value );
434
+							$TKT->set($field, $value);
435 435
 						}
436 436
 					}
437 437
 
438 438
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
439
-					if ( $create_new_TKT ) {
440
-						$new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id );
439
+					if ($create_new_TKT) {
440
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id);
441 441
 					}
442 442
 				}
443 443
 
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 				$TKT = EE_Ticket::new_instance(
447 447
 					$TKT_values,
448 448
 					$timezone,
449
-					array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ]  )
449
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
450 450
 				);
451
-				if ( $TKT instanceof EE_Ticket ) {
451
+				if ($TKT instanceof EE_Ticket) {
452 452
 					// make sure ticket has an ID of setting relations won't work
453 453
 					$TKT->save();
454
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
454
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
455 455
 					$update_prices = TRUE;
456 456
 				}
457 457
 			}
@@ -459,38 +459,38 @@  discard block
 block discarded – undo
459 459
 			//$TKT->save();
460 460
 
461 461
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
462
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
463
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
462
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
463
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
464 464
 				EE_Registry::instance()->load_helper('DTT_Helper');
465 465
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
466 466
 			}
467 467
 
468 468
 			//let's make sure the base price is handled
469
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT;
469
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT;
470 470
 
471 471
 			//add/update price_modifiers
472
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT;
472
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
473 473
 
474 474
 			//need to make sue that the TKT_price is accurate after saving the prices.
475 475
 			$TKT->ensure_TKT_Price_correct();
476 476
 
477 477
 			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
478
-			if ( ! defined('DOING_AUTOSAVE' ) ) {
479
-				if ( !empty($tkt['TKT_is_default_selector'] ) ) {
478
+			if ( ! defined('DOING_AUTOSAVE')) {
479
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
480 480
 					$update_prices = TRUE;
481 481
 					$new_default = clone $TKT;
482
-					$new_default->set( 'TKT_ID', 0 );
483
-					$new_default->set( 'TKT_is_default', 1 );
484
-					$new_default->set( 'TKT_row', 1 );
485
-					$new_default->set( 'TKT_price', $ticket_price );
482
+					$new_default->set('TKT_ID', 0);
483
+					$new_default->set('TKT_is_default', 1);
484
+					$new_default->set('TKT_row', 1);
485
+					$new_default->set('TKT_price', $ticket_price);
486 486
 					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
487 487
 					$new_default->_remove_relations('Datetime');
488 488
 					//todo we need to add the current attached prices as new prices to the new default ticket.
489
-					$new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices );
489
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
490 490
 					//don't forget the base price!
491
-					$new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id );
491
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id);
492 492
 					$new_default->save();
493
-					do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data );
493
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data);
494 494
 				}
495 495
 			}
496 496
 
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
 			//let's assign any tickets that have been setup to the saved_tickets tracker
502 502
 			//save existing TKT
503 503
 			$TKT->save();
504
-			if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) {
504
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
505 505
 				//save new TKT
506 506
 				$new_tkt->save();
507 507
 				//add new ticket to array
508
-				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
508
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
509 509
 
510
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data );
510
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
511 511
 
512 512
 			} else {
513 513
 				//add tkt to saved tkts
514
-				$saved_tickets[ $TKT->ID() ] = $TKT;
514
+				$saved_tickets[$TKT->ID()] = $TKT;
515 515
 
516
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data );
516
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
517 517
 			}
518 518
 
519 519
 		}
@@ -523,22 +523,22 @@  discard block
 block discarded – undo
523 523
 		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
524 524
 		// Or a draft event was saved and in the process of editing a ticket is trashed.
525 525
 		// No sense in keeping all the related data in the db!
526
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
527
-		$tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) );
526
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
527
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
528 528
 
529
-		foreach ( $tickets_removed as $id ) {
530
-			$id = absint( $id );
529
+		foreach ($tickets_removed as $id) {
530
+			$id = absint($id);
531 531
 
532 532
 			//get the ticket for this id
533 533
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
534 534
 
535 535
 			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
536
-			if ( $tkt_to_remove->get('TKT_is_default') )
536
+			if ($tkt_to_remove->get('TKT_is_default'))
537 537
 				continue;
538 538
 
539 539
 			// if this tkt has any registrations attached so then we just ARCHIVE
540 540
 			// because we don't actually permanently delete these tickets.
541
-			if ( $tkt_to_remove->count_related('Registration') > 0 ) {
541
+			if ($tkt_to_remove->count_related('Registration') > 0) {
542 542
 				$tkt_to_remove->delete();
543 543
 				continue;
544 544
 			}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			// (remember this process can ONLY kick off if there are NO tkts_sold)
548 548
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
549 549
 
550
-			foreach( $dtts as $dtt ) {
550
+			foreach ($dtts as $dtt) {
551 551
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
552 552
 			}
553 553
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
556 556
 			$tkt_to_remove->delete_related_permanently('Price');
557 557
 
558
-			do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove );
558
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
559 559
 
560 560
 			// finally let's delete this ticket
561 561
 			// (which should not be blocked at this point b/c we've removed all our relationships)
@@ -587,39 +587,39 @@  discard block
 block discarded – undo
587 587
 		// and removing the ticket from datetimes it got removed from.
588 588
 
589 589
 		// first let's add datetimes
590
-		if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) {
591
-			foreach ( $added_datetimes as $row_id ) {
592
-				$row_id = (int)$row_id;
593
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
594
-					$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
590
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
591
+			foreach ($added_datetimes as $row_id) {
592
+				$row_id = (int) $row_id;
593
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
594
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
595 595
 					// Is this an existing ticket (has an ID) and does it have any sold?
596 596
 					// If so, then we need to add that to the DTT sold because this DTT is getting added.
597
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
598
-						$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() );
599
-						$saved_datetimes[ $row_id ]->save();
597
+					if ($ticket->ID() && $ticket->sold() > 0) {
598
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
599
+						$saved_datetimes[$row_id]->save();
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 		// then remove datetimes
605
-		if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) {
606
-			foreach ( $removed_datetimes as $row_id ) {
607
-				$row_id = (int)$row_id;
605
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
606
+			foreach ($removed_datetimes as $row_id) {
607
+				$row_id = (int) $row_id;
608 608
 				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
609 609
 				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
610
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
611
-					$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
610
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
611
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
612 612
 					// Is this an existing ticket (has an ID) and does it have any sold?
613 613
 					// If so, then we need to remove it's sold from the DTT_sold.
614
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
615
-						$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() );
616
-						$saved_datetimes[ $row_id ]->save();
614
+					if ($ticket->ID() && $ticket->sold() > 0) {
615
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
616
+						$saved_datetimes[$row_id]->save();
617 617
 					}
618 618
 				}
619 619
 			}
620 620
 		}
621 621
 		// cap ticket qty by datetime reg limits
622
-		$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) );
622
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
623 623
 		return $ticket;
624 624
 	}
625 625
 
@@ -640,39 +640,39 @@  discard block
 block discarded – undo
640 640
 		EE_Ticket $ticket,
641 641
 		$price_rows = array(),
642 642
 		$ticket_price = 0,
643
-		$base_price = 0 ,
643
+		$base_price = 0,
644 644
 		$base_price_id = 0
645 645
 	) {
646 646
 
647 647
 		// create new ticket that's a copy of the existing
648 648
 		// except a new id of course (and not archived)
649 649
 		// AND has the new TKT_price associated with it.
650
-		$new_ticket = clone( $ticket );
651
-		$new_ticket->set( 'TKT_ID', 0 );
652
-		$new_ticket->set( 'TKT_deleted', 0 );
653
-		$new_ticket->set( 'TKT_price', $ticket_price );
654
-		$new_ticket->set( 'TKT_sold', 0 );
650
+		$new_ticket = clone($ticket);
651
+		$new_ticket->set('TKT_ID', 0);
652
+		$new_ticket->set('TKT_deleted', 0);
653
+		$new_ticket->set('TKT_price', $ticket_price);
654
+		$new_ticket->set('TKT_sold', 0);
655 655
 		// let's get a new ID for this ticket
656 656
 		$new_ticket->save();
657 657
 		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
658
-		$datetimes_on_existing = $ticket->get_many_related( 'Datetime' );
658
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
659 659
 		$new_ticket = $this->_update_ticket_datetimes(
660 660
 			$new_ticket,
661 661
 			$datetimes_on_existing,
662
-			array_keys( $datetimes_on_existing )
662
+			array_keys($datetimes_on_existing)
663 663
 		);
664 664
 
665 665
 		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
666 666
 		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
667 667
 		// available.
668
-		if ( $ticket->sold() > 0 ) {
668
+		if ($ticket->sold() > 0) {
669 669
 			$new_qty = $ticket->qty() - $ticket->sold();
670
-			$new_ticket->set_qty( $new_qty );
670
+			$new_ticket->set_qty($new_qty);
671 671
 		}
672 672
 		//now we update the prices just for this ticket
673
-		$new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true );
673
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
674 674
 		//and we update the base price
675
-		$new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id );
675
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
676 676
 		return $new_ticket;
677 677
 	}
678 678
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @param int|bool 		$base_price_id  if present then this is the base_price_id being updated.
693 693
 	 * @return EE_Ticket
694 694
 	 */
695
-	protected function  _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) {
695
+	protected function  _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) {
696 696
 
697 697
 		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
698 698
 		$current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers();
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		$updated_prices = array();
701 701
 
702 702
 		// if $base_price ! FALSE then updating a base price.
703
-		if ( $base_price !== FALSE ) {
703
+		if ($base_price !== FALSE) {
704 704
 			$prices[1] = array(
705 705
 				'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id,
706 706
 				'PRT_ID' => 1,
@@ -711,47 +711,47 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		//possibly need to save tkt
714
-		if ( ! $ticket->ID() )
714
+		if ( ! $ticket->ID())
715 715
 			$ticket->save();
716 716
 
717
-		foreach ( $prices as $row => $prc ) {
718
-			$prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL;
719
-			if ( empty($prt_id) )
717
+		foreach ($prices as $row => $prc) {
718
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL;
719
+			if (empty($prt_id))
720 720
 				continue; //prices MUST have a price type id.
721 721
 			$PRC_values = array(
722
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
722
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
723 723
 				'PRT_ID' => $prt_id,
724
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
725
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
726
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
724
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
725
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
726
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
727 727
 				'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor
728 728
 				'PRC_order' => $row
729 729
 				);
730
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
730
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
731 731
 				$PRC_values['PRC_ID'] = 0;
732
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
732
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
733 733
 			} else {
734
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
734
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
735 735
 				//update this price with new values
736
-				foreach ( $PRC_values as $field => $newprc ) {
737
-					$PRC->set( $field, $newprc );
736
+				foreach ($PRC_values as $field => $newprc) {
737
+					$PRC->set($field, $newprc);
738 738
 				}
739 739
 			}
740 740
 			$PRC->save();
741 741
 			$prcid = $PRC->ID();
742 742
 			$updated_prices[$prcid] = $PRC;
743
-			$ticket->_add_relation_to( $PRC, 'Price' );
743
+			$ticket->_add_relation_to($PRC, 'Price');
744 744
 		}
745 745
 
746 746
 		//now let's remove any prices that got removed from the ticket
747
-		if ( !empty ( $current_prices_on_ticket ) ) {
747
+		if ( ! empty ($current_prices_on_ticket)) {
748 748
 			$current = array_keys($current_prices_on_ticket);
749 749
 			$updated = array_keys($updated_prices);
750 750
 			$prices_to_remove = array_diff($current, $updated);
751
-			if ( !empty( $prices_to_remove ) ) {
752
-				foreach ( $prices_to_remove as $prc_id ) {
751
+			if ( ! empty($prices_to_remove)) {
752
+				foreach ($prices_to_remove as $prc_id) {
753 753
 					$p = $current_prices_on_ticket[$prc_id];
754
-					$ticket->_remove_relation_to( $p, 'Price' );
754
+					$ticket->_remove_relation_to($p, 'Price');
755 755
 
756 756
 					//delete permanently the price
757 757
 					$p->delete_permanently();
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 
766 766
 
767
-	public function autosave_handling( $event_admin_obj ) {
767
+	public function autosave_handling($event_admin_obj) {
768 768
 		return $event_admin_obj; //doing nothing for the moment.
769 769
 		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
770 770
 
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
 
799 799
 		//default main template args
800 800
 		$main_template_args = array(
801
-			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
801
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
802 802
 			'existing_datetime_ids' => '',
803 803
 			'total_dtt_rows' => 1,
804
-			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
804
+			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
805 805
 			'datetime_rows' => '',
806
-			'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
806
+			'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
807 807
 			'ticket_rows' => '',
808 808
 			'existing_ticket_ids' => '',
809 809
 			'total_ticket_rows' => 1,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
 		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL;
815 815
 
816
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
816
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
817 817
 
818 818
 		/**
819 819
 		 * 1. Start with retrieving Datetimes
@@ -821,25 +821,25 @@  discard block
 block discarded – undo
821 821
 		 * 3. For each ticket get related prices
822 822
 		 */
823 823
 
824
-		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) );
825
-		$times = $DTM->get_all_event_dates( $evtID );
824
+		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone));
825
+		$times = $DTM->get_all_event_dates($evtID);
826 826
 
827 827
 
828 828
 
829 829
 		$main_template_args['total_dtt_rows'] = count($times);
830
-		foreach ( $times as $time ) {
830
+		foreach ($times as $time) {
831 831
 			$dttid = $time->get('DTT_ID');
832 832
 			$dttrow = $time->get('DTT_order');
833 833
 			$existing_datetime_ids[] = $dttid;
834 834
 
835 835
 			//tickets attached
836
-			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array();
836
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array();
837 837
 
838 838
 			//if there are no related tickets this is likely a new event OR autodraft
839 839
 			// event so we need to generate the default tickets because dtts
840 840
 			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
841 841
 			// datetime on the event.
842
-			if ( empty ( $related_tickets ) && count( $times ) < 2 ) {
842
+			if (empty ($related_tickets) && count($times) < 2) {
843 843
 				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
844 844
 			}
845 845
 
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 
849 849
 			//loop through and setup the ticket rows and make sure the order is set.
850 850
 			$order = 0;
851
-			foreach ( $related_tickets as $ticket ) {
851
+			foreach ($related_tickets as $ticket) {
852 852
 				$tktid = $ticket->get('TKT_ID');
853 853
 				$tktrow = $ticket->get('TKT_row');
854 854
 				//we only want unique tickets in our final display!!
855
-				if ( !in_array( $tktid, $existing_ticket_ids ) ) {
855
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
856 856
 					$existing_ticket_ids[] = $tktid;
857 857
 					$all_tickets[] = $ticket;
858 858
 				}
@@ -861,56 +861,56 @@  discard block
 block discarded – undo
861 861
 				$datetime_tickets[$dttid][] = $tktrow;
862 862
 
863 863
 				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
864
-				if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) )
864
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid]))
865 865
 					$ticket_datetimes[$tktid][] = $dttrow;
866 866
 			}
867 867
 		}
868 868
 
869
-		$main_template_args['total_ticket_rows'] = count( $existing_ticket_ids );
870
-		$main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
871
-		$main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
869
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
870
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
871
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
872 872
 
873 873
 		//sort $all_tickets by order
874
-		usort( $all_tickets, function( $a, $b ) {
874
+		usort($all_tickets, function($a, $b) {
875 875
 			$a_order = (int) $a->get('TKT_order');
876 876
 			$b_order = (int) $b->get('TKT_order');
877
-			if ( $a_order == $b_order ) {
877
+			if ($a_order == $b_order) {
878 878
 				return 0;
879 879
 			}
880
-			return ( $a_order < $b_order ) ? -1 : 1;
880
+			return ($a_order < $b_order) ? -1 : 1;
881 881
 		});
882 882
 
883 883
 		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
884 884
 		$dttrow = 1;
885
-		foreach ( $times as $time ) {
886
-			$main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times );
885
+		foreach ($times as $time) {
886
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times);
887 887
 			$dttrow++;
888 888
 		}
889 889
 
890 890
 		//then loop through all tickets for the ticket rows.
891 891
 		$tktrow = 1;
892
-		foreach ( $all_tickets as $ticket ) {
893
-			$main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets );
892
+		foreach ($all_tickets as $ticket) {
893
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets);
894 894
 			$tktrow++;
895 895
 		}
896 896
 
897 897
 		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
898
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
899
-		EEH_Template::display_template( $template, $main_template_args );
898
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php';
899
+		EEH_Template::display_template($template, $main_template_args);
900 900
 		return;
901 901
 	}
902 902
 
903 903
 
904 904
 
905
-	protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) {
905
+	protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) {
906 906
 
907 907
 		$dtt_display_template_args = array(
908
-			'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ),
909
-			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ),
908
+			'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
909
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default),
910 910
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow
911 911
 			);
912
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
913
-		return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE);
912
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php';
913
+		return EEH_Template::display_template($template, $dtt_display_template_args, TRUE);
914 914
 	}
915 915
 
916 916
 
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return string Generated edit row.
930 930
 	 */
931
-	protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) {
931
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) {
932 932
 
933 933
 		// if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true.
934 934
 		$default = ! $dtt instanceof EE_Datetime ? true : false;
@@ -936,30 +936,30 @@  discard block
 block discarded – undo
936 936
 		$template_args = array(
937 937
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
938 938
 			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
939
-			'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
939
+			'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
940 940
 			'DTT_ID' => $default ? '' : $dtt->ID(),
941 941
 			'DTT_name' => $default ? '' : $dtt->name(),
942 942
 			'DTT_description' => $default ? '' : $dtt->description(),
943
-			'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
944
-			'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
945
-			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'),
943
+			'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
944
+			'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
945
+			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
946 946
 			'DTT_order' => $default ? 'DTTNUM' : $dttrow,
947 947
 			'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'),
948
-			'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
949
-			'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0  ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
948
+			'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
949
+			'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
950 950
 			);
951 951
 
952
-		$template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
952
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
953 953
 
954 954
 		//allow filtering of template args at this point.
955
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event );
955
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
956 956
 
957
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
958
-		return EEH_Template::display_template( $template, $template_args, TRUE );
957
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php';
958
+		return EEH_Template::display_template($template, $template_args, TRUE);
959 959
 	}
960 960
 
961 961
 
962
-	protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) {
962
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) {
963 963
 
964 964
 		$template_args = array(
965 965
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
@@ -967,47 +967,47 @@  discard block
 block discarded – undo
967 967
 			'DTT_description' => $default ? '' : $dtt->description(),
968 968
 			'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '',
969 969
 			'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
970
-			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
970
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
971 971
 			'DTT_ID' => $default ? '' : $dtt->ID()
972 972
 			);
973 973
 
974 974
 		//need to setup the list items (but only if this isnt' a default skeleton setup)
975
-		if ( !$default ) {
975
+		if ( ! $default) {
976 976
 			$tktrow = 1;
977
-			foreach ( $all_tickets as $ticket ) {
978
-				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default );
977
+			foreach ($all_tickets as $ticket) {
978
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default);
979 979
 				$tktrow++;
980 980
 			}
981 981
 		}
982 982
 
983 983
 		//filter template args at this point
984
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event );
984
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
985 985
 
986
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
987
-		return EEH_Template::display_template( $template, $template_args, TRUE );
986
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php';
987
+		return EEH_Template::display_template($template, $template_args, TRUE);
988 988
 	}
989 989
 
990 990
 
991 991
 
992
-	protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) {
993
-		$tktid = !empty( $ticket ) ? $ticket->ID() : 0;
994
-		$dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array();
992
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) {
993
+		$tktid = ! empty($ticket) ? $ticket->ID() : 0;
994
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
995 995
 
996
-		$displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0;
996
+		$displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
997 997
 		$template_args = array(
998 998
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
999
-			'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow,
999
+			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1000 1000
 			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1001 1001
 			'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1002
-			'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'),
1003
-			'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1002
+			'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1003
+			'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(),
1004 1004
 			);
1005 1005
 
1006 1006
 		//filter template args
1007
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event );
1007
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1008 1008
 
1009
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1010
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1009
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php';
1010
+		return EEH_Template::display_template($template, $template_args, TRUE);
1011 1011
 	}
1012 1012
 
1013 1013
 
@@ -1029,32 +1029,32 @@  discard block
 block discarded – undo
1029 1029
 	 *
1030 1030
 	 * @return [type] [description]
1031 1031
 	 */
1032
-	protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) {
1032
+	protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) {
1033 1033
 
1034 1034
 		//if $ticket is not an instance of EE_Ticket then force default to true.
1035
-		$default =  ! $ticket instanceof EE_Ticket ? true : false;
1035
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1036 1036
 
1037 1037
 
1038
-		$prices = !empty($ticket) && !$default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array();
1038
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1039 1039
 
1040 1040
 		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1041
-		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE;
1041
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE;
1042 1042
 
1043
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1043
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1044 1044
 
1045 1045
 		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1046
-		$base_price = $default ? NULL :  $ticket->base_price();
1046
+		$base_price = $default ? NULL : $ticket->base_price();
1047 1047
 		$count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE);
1048 1048
 
1049 1049
 		//breaking out complicated condition for ticket_status
1050
-		if ( $default ) {
1051
-			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1050
+		if ($default) {
1051
+			$ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1052 1052
 		} else {
1053
-			$ticket_status_class =  $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1053
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status();
1054 1054
 		}
1055 1055
 
1056 1056
 		//breaking out complicated condition for TKT_taxable
1057
-		if ( $default ) {
1057
+		if ($default) {
1058 1058
 			$TKT_taxable = '';
1059 1059
 		} else {
1060 1060
 			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
@@ -1069,19 +1069,19 @@  discard block
 block discarded – undo
1069 1069
 			'edit_tkt_expanded' => '',
1070 1070
 			'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1071 1071
 			'TKT_name' => $default ? '' : $ticket->get('TKT_name'),
1072
-			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
1073
-			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']  ),
1074
-			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1072
+			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1073
+			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1074
+			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1075 1075
 			'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE),
1076 1076
 			'TKT_price_code' => EE_Registry::instance()->CFG->currency->code,
1077 1077
 			'TKT_price_amount' => $default ? 0 : $ticket_subtotal,
1078
-			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'),
1079
-			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'),
1080
-			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'),
1081
-			'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ),
1082
-			'TKT_max' => $default ? '' :  $ticket->get_pretty('TKT_max','input'),
1078
+			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1079
+			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1080
+			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1081
+			'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1082
+			'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1083 1083
 			'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'),
1084
-			'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ),
1084
+			'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))),
1085 1085
 			'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'),
1086 1086
 			'TKT_description' => $default ? '' : $ticket->get('TKT_description'),
1087 1087
 			'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'),
@@ -1090,99 +1090,99 @@  discard block
 block discarded – undo
1090 1090
 			'ticket_price_rows' => '',
1091 1091
 			'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'),
1092 1092
 			'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1093
-			'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"',
1094
-			'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '',
1093
+			'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1094
+			'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1095 1095
 			'total_price_rows' => count($prices) > 1 ? count($prices) : 1,
1096 1096
 			'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '',
1097 1097
 			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1098 1098
 			'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts),
1099
-			'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ),
1099
+			'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)),
1100 1100
 			'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'),
1101 1101
 			'TKT_taxable' => $TKT_taxable,
1102 1102
 			'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1103 1103
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1104
-			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ),
1104
+			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE),
1105 1105
 			'TKT_subtotal_amount' => $ticket_subtotal,
1106
-			'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ),
1107
-			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE,
1106
+			'tax_rows' => $this->_get_tax_rows($tktrow, $ticket),
1107
+			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE,
1108 1108
 			'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1109 1109
 			'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1110 1110
 			'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1111 1111
 			);
1112 1112
 
1113
-		$template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1113
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1114 1114
 
1115 1115
 		//handle rows that should NOT be empty
1116
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1116
+		if (empty($template_args['TKT_start_date'])) {
1117 1117
 			//if empty then the start date will be now.
1118
-			$template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp'));
1119
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1118
+			$template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp'));
1119
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1120 1120
 		}
1121 1121
 
1122
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1122
+		if (empty($template_args['TKT_end_date'])) {
1123 1123
 
1124 1124
 			//get the earliest datetime (if present);
1125
-			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1125
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1126 1126
 
1127
-			if ( !empty( $earliest_dtt ) ) {
1128
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
1127
+			if ( ! empty($earliest_dtt)) {
1128
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
1129 1129
 			} else {
1130 1130
 				//default so let's just use what's been set for the default date-time which is 30 days from now.
1131
-				$template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") )  );
1131
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1132 1132
 			}
1133
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1133
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1134 1134
 		}
1135 1135
 
1136 1136
 		//generate ticket_datetime items
1137
-		if ( ! $default ) {
1137
+		if ( ! $default) {
1138 1138
 			$dttrow = 1;
1139
-			foreach ( $all_dtts as $dtt ) {
1140
-				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default );
1139
+			foreach ($all_dtts as $dtt) {
1140
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default);
1141 1141
 				$dttrow++;
1142 1142
 			}
1143 1143
 		}
1144 1144
 
1145 1145
 		$prcrow = 1;
1146
-		foreach ( $prices as $price ) {
1147
-			if ( $price->is_base_price() ) {
1146
+		foreach ($prices as $price) {
1147
+			if ($price->is_base_price()) {
1148 1148
 				$prcrow++;
1149 1149
 				continue;
1150 1150
 			}
1151
-			$show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1  ? FALSE : TRUE;
1152
-			$show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE;
1153
-			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create );
1151
+			$show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE;
1152
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE;
1153
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create);
1154 1154
 			$prcrow++;
1155 1155
 		}
1156 1156
 
1157 1157
 		//filter $template_args
1158
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event );
1158
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event);
1159 1159
 
1160
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1161
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1160
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php';
1161
+		return EEH_Template::display_template($template, $template_args, TRUE);
1162 1162
 	}
1163 1163
 
1164 1164
 
1165 1165
 
1166 1166
 
1167 1167
 
1168
-	protected function _get_tax_rows( $tktrow, $ticket ) {
1168
+	protected function _get_tax_rows($tktrow, $ticket) {
1169 1169
 		$tax_rows = '';
1170
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1170
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php';
1171 1171
 		$template_args = array();
1172
-		$taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1173
-		foreach ( $taxes as $tax ) {
1174
-			$tax_added = $this->_get_tax_added( $tax, $ticket );
1172
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1173
+		foreach ($taxes as $tax) {
1174
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1175 1175
 			$template_args = array(
1176
-				'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1176
+				'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1177 1177
 				'tax_id' => $tax->ID(),
1178 1178
 				'tkt_row' => $tktrow,
1179 1179
 				'tax_label' => $tax->get('PRC_name'),
1180 1180
 				'tax_added' => $tax_added,
1181
-				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ),
1181
+				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE),
1182 1182
 				'tax_amount' => $tax->get('PRC_amount')
1183 1183
 				);
1184
-			$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event  );
1185
-			$tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE );
1184
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
1185
+			$tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
1186 1186
 		}
1187 1187
 
1188 1188
 
@@ -1190,81 +1190,81 @@  discard block
 block discarded – undo
1190 1190
 	}
1191 1191
 
1192 1192
 
1193
-	protected function _get_tax_added( EE_Price $tax, $ticket ) {
1194
-		$subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal();
1193
+	protected function _get_tax_added(EE_Price $tax, $ticket) {
1194
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1195 1195
 		return $subtotal * $tax->get('PRC_amount') / 100;
1196 1196
 	}
1197 1197
 
1198 1198
 
1199 1199
 
1200 1200
 
1201
-	protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) {
1202
-		$send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1201
+	protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) {
1202
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1203 1203
 		$template_args = array(
1204 1204
 			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1205 1205
 			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1206 1206
 			'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1207
-			'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ),
1207
+			'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1208 1208
 			'PRC_ID' => $default && empty($price) ? 0 : $price->ID(),
1209 1209
 			'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1210 1210
 			'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'),
1211 1211
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1212 1212
 			'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"',
1213
-			'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1214
-			'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1215
-			'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ),
1216
-			'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1217
-			'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ),
1213
+			'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1214
+			'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1215
+			'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1216
+			'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1217
+			'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1218 1218
 			'show_trash_icon' => $show_trash ? '' : ' style="display:none;"',
1219 1219
 			'show_create_button' => $show_create ? '' : ' style="display:none;"',
1220
-			'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'),
1221
-			'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1220
+			'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'),
1221
+			'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1222 1222
 			);
1223 1223
 
1224
-	$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event );
1224
+	$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event);
1225 1225
 
1226
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1227
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1226
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php';
1227
+		return EEH_Template::display_template($template, $template_args, TRUE);
1228 1228
 	}
1229 1229
 
1230 1230
 
1231
-	protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1232
-		if ( $price->is_base_price() ) {
1233
-			return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default );
1231
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1232
+		if ($price->is_base_price()) {
1233
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1234 1234
 		} else {
1235
-			return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled );
1235
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1236 1236
 		}
1237 1237
 
1238 1238
 	}
1239 1239
 
1240 1240
 
1241
-	protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) {
1241
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default) {
1242 1242
 		$template_args = array(
1243 1243
 				'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1244
-				'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1245
-				'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'),
1244
+				'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1245
+				'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1246 1246
 				'PRT_name' => __('Price', 'event_espresso'),
1247 1247
 				'price_selected_operator' => '+',
1248 1248
 				'price_selected_is_percent' => 0
1249 1249
 			);
1250
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1250
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php';
1251 1251
 
1252
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event );
1252
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1253 1253
 
1254
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1254
+		return EEH_Template::display_template($template, $template_args, TRUE);
1255 1255
 	}
1256 1256
 
1257 1257
 
1258 1258
 
1259
-	protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1260
-		$select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1261
-		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) );
1262
-		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1263
-		$all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array();
1264
-		$selected_price_type_id = $default && empty( $price ) ? 0 : $price->type();
1259
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1260
+		$select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]';
1261
+		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3'))));
1262
+		$price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php';
1263
+		$all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array();
1264
+		$selected_price_type_id = $default && empty($price) ? 0 : $price->type();
1265 1265
 		$price_option_spans = '';
1266 1266
 		//setup pricetypes for selector
1267
-		foreach ( $price_types as $price_type ) {
1267
+		foreach ($price_types as $price_type) {
1268 1268
 			$all_price_types[] = array(
1269 1269
 				'id' => $price_type->ID(),
1270 1270
 				'text' => $price_type->get('PRT_name'),
@@ -1276,50 +1276,50 @@  discard block
 block discarded – undo
1276 1276
 				'PRT_operator' => $price_type->is_discount() ? '-' : '+',
1277 1277
 				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1278 1278
 				);
1279
-			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE );
1279
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE);
1280 1280
 		}
1281 1281
 
1282
-		$select_params = $disabled ? 'style="width:auto;" disabled'  : 'style="width:auto;"';
1282
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1283 1283
 		$main_name = $select_name;
1284
-		$select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1284
+		$select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name;
1285 1285
 
1286 1286
 		$template_args = array(
1287 1287
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1288
-			'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1289
-			'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ),
1288
+			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1289
+			'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1290 1290
 			'main_name' => $main_name,
1291 1291
 			'selected_price_type_id' => $selected_price_type_id,
1292 1292
 			'price_option_spans' => $price_option_spans,
1293
-			'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ),
1294
-			'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ),
1293
+			'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1294
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1295 1295
 			'disabled' => $disabled
1296 1296
 			);
1297 1297
 
1298
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event );
1298
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1299 1299
 
1300
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1300
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php';
1301 1301
 
1302
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1302
+		return EEH_Template::display_template($template, $template_args, TRUE);
1303 1303
 	}
1304 1304
 
1305 1305
 
1306 1306
 
1307
-	protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) {
1308
-		$dttid = !empty($dtt) ? $dtt->ID() : 0;
1309
-		$displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0;
1310
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1307
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) {
1308
+		$dttid = ! empty($dtt) ? $dtt->ID() : 0;
1309
+		$displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0;
1310
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1311 1311
 		$template_args = array(
1312
-			'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow,
1312
+			'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow,
1313 1313
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1314
-			'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '',
1315
-			'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '',
1316
-			'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ),
1314
+			'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '',
1315
+			'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '',
1316
+			'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE),
1317 1317
 			'tkt_status_class' => '',
1318 1318
 			);
1319 1319
 
1320
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event );
1321
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1322
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1320
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1321
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1322
+		return EEH_Template::display_template($template, $template_args, TRUE);
1323 1323
 	}
1324 1324
 
1325 1325
 
@@ -1327,53 +1327,53 @@  discard block
 block discarded – undo
1327 1327
 	protected function _get_ticket_js_structure($all_dtts, $all_tickets) {
1328 1328
 		$template_args = array(
1329 1329
 			'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts),
1330
-			'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE),
1331
-			'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ),
1330
+			'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE),
1331
+			'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL),
1332 1332
 			'default_price_rows' => '',
1333 1333
 			'default_base_price_amount' => 0,
1334 1334
 			'default_base_price_name' => '',
1335 1335
 			'default_base_price_description' => '',
1336
-			'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ),
1337
-			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ),
1336
+			'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE),
1337
+			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE),
1338 1338
 			'existing_available_datetime_tickets_list' => '',
1339 1339
 			'existing_available_ticket_datetimes_list' => '',
1340
-			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ),
1341
-			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE )
1340
+			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE),
1341
+			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE)
1342 1342
 			);
1343 1343
 
1344 1344
 		$tktrow = 1;
1345
-		foreach ( $all_tickets as $ticket ) {
1346
-			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE );
1345
+		foreach ($all_tickets as $ticket) {
1346
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE);
1347 1347
 			$tktrow++;
1348 1348
 		}
1349 1349
 
1350 1350
 
1351 1351
 		$dttrow = 1;
1352
-		foreach ( $all_dtts as $dtt ) {
1353
-			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE );
1352
+		foreach ($all_dtts as $dtt) {
1353
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE);
1354 1354
 			$dttrow++;
1355 1355
 		}
1356 1356
 
1357 1357
 		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1358 1358
 		$prcrow = 1;
1359
-		foreach ( $default_prices as $price ) {
1360
-			if ( $price->is_base_price() ) {
1359
+		foreach ($default_prices as $price) {
1360
+			if ($price->is_base_price()) {
1361 1361
 				$template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float');
1362 1362
 				$template_args['default_base_price_name'] = $price->get('PRC_name');
1363 1363
 				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1364 1364
 				$prcrow++;
1365 1365
 				continue;
1366 1366
 			}
1367
-			$show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1  ? FALSE : TRUE;
1368
-			$show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE;
1369
-			$template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create );
1367
+			$show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE;
1368
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE;
1369
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create);
1370 1370
 			$prcrow++;
1371 1371
 		}
1372 1372
 
1373
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event );
1373
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1374 1374
 
1375
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1376
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1375
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php';
1376
+		return EEH_Template::display_template($template, $template_args, TRUE);
1377 1377
 	}
1378 1378
 
1379 1379
 
Please login to merge, or discard this patch.