@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Base { |
21 | - protected static function _verify_current_user_can( $required_permission, $attempted_calculation ) { |
|
22 | - if( ! current_user_can( $required_permission ) ) { |
|
21 | + protected static function _verify_current_user_can($required_permission, $attempted_calculation) { |
|
22 | + if ( ! current_user_can($required_permission)) { |
|
23 | 23 | throw new Rest_Exception( |
24 | 24 | 'permission_denied', |
25 | 25 | sprintf( |
26 | - __( 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso' ), |
|
26 | + __('Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso'), |
|
27 | 27 | $attempted_calculation, |
28 | - \EEH_Inflector::pluralize_and_lower( self::get_resource_name() ), |
|
28 | + \EEH_Inflector::pluralize_and_lower(self::get_resource_name()), |
|
29 | 29 | $required_permission |
30 | 30 | ) |
31 | 31 | ); |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function get_resource_name() { |
40 | 40 | $classname = get_called_class(); |
41 | - return substr( $classname, strrpos( $classname, '\\' ) + 1 ); |
|
41 | + return substr($classname, strrpos($classname, '\\') + 1); |
|
42 | 42 | } |
43 | 43 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since 4.8.35.rc.001 |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Calculated_Model_Fields { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * the WP_Request object, |
39 | 39 | * the controller object |
40 | 40 | */ |
41 | - public function mapping( $refresh = false ) { |
|
42 | - if( ! $this->_mapping || $refresh ) { |
|
41 | + public function mapping($refresh = false) { |
|
42 | + if ( ! $this->_mapping || $refresh) { |
|
43 | 43 | $this->_mapping = $this->_generate_new_mapping(); |
44 | 44 | } |
45 | 45 | return $this->_mapping; |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function _generate_new_mapping() { |
54 | 54 | $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
55 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
56 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
55 | + $event_calculations_class = $rest_api_calculations_namespace.'Event'; |
|
56 | + $datetime_calculations_class = $rest_api_calculations_namespace.'Datetime'; |
|
57 | 57 | return apply_filters( |
58 | 58 | 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
59 | 59 | array( |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @param \EEM_Base $model |
82 | 82 | * @return array allowable values for this field |
83 | 83 | */ |
84 | - public function retrieve_calculated_fields_for_model( \EEM_Base $model ) { |
|
84 | + public function retrieve_calculated_fields_for_model(\EEM_Base $model) { |
|
85 | 85 | $mapping = $this->mapping(); |
86 | - if( isset( $mapping[ $model->get_this_model_name() ] ) ) { |
|
87 | - return array_keys( $mapping[ $model->get_this_model_name() ] ); |
|
86 | + if (isset($mapping[$model->get_this_model_name()])) { |
|
87 | + return array_keys($mapping[$model->get_this_model_name()]); |
|
88 | 88 | } else { |
89 | 89 | return array(); |
90 | 90 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @return mixed|null |
104 | 104 | * @throws \EE_Error |
105 | 105 | */ |
106 | - public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) { |
|
106 | + public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) { |
|
107 | 107 | $mapping = $this->mapping(); |
108 | - if( isset( $mapping[ $model->get_this_model_name() ] ) |
|
109 | - && isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) { |
|
110 | - $classname = $mapping[ $model->get_this_model_name() ][ $field_name ]; |
|
111 | - return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller ); |
|
108 | + if (isset($mapping[$model->get_this_model_name()]) |
|
109 | + && isset($mapping[$model->get_this_model_name()][$field_name])) { |
|
110 | + $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
111 | + return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller); |
|
112 | 112 | } |
113 | 113 | throw new Rest_Exception( |
114 | 114 | 'calculated_field_does_not_exist', |
115 | 115 | sprintf( |
116 | - __( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), |
|
116 | + __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
117 | 117 | $field_name, |
118 | 118 | $model->get_this_model_name() |
119 | 119 | ) |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Rest_Exception extends \EE_Error { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $_wp_error_data = array(); |
26 | 26 | protected $_wp_error_code = ''; |
27 | - public function __construct( $string_code, $message, $wp_error_data = array(), $previous = null ) { |
|
27 | + public function __construct($string_code, $message, $wp_error_data = array(), $previous = null) { |
|
28 | 28 | parent::__construct( |
29 | 29 | $message, |
30 | 30 | 500, |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function __construct() { |
44 | 44 | // construct request stack and run middleware apps as soon as all WP plugins are loaded |
45 | - add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 ); |
|
45 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
46 | 46 | // set framework for the rest of EE to hook into when loading |
47 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 ); |
|
48 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 ); |
|
49 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 ); |
|
50 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
51 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 ); |
|
47 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
48 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
49 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
50 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
51 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | new EE_Load_Espresso_Core() |
66 | 66 | ); |
67 | 67 | $this->_request_stack->handle_request( |
68 | - new EE_Request( $_GET, $_POST, $_COOKIE ), |
|
68 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
69 | 69 | new EE_Response() |
70 | 70 | ); |
71 | 71 | $this->_request_stack->handle_response(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function load_autoloader() { |
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' ); |
|
81 | + espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php'); |
|
82 | 82 | EEH_Autoloader::instance(); |
83 | 83 | } |
84 | 84 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function set_autoloaders_for_required_files() { |
91 | 91 | // load interfaces |
92 | - espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' ); |
|
92 | + espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php'); |
|
93 | 93 | // load helpers |
94 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
94 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
95 | 95 | // load request stack |
96 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS ); |
|
96 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
97 | 97 | // load middleware |
98 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS ); |
|
98 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | // load middleware onto stack : FILO (First In Last Out) |
121 | - foreach ( (array)$stack_apps as $stack_app ) { |
|
121 | + foreach ((array) $stack_apps as $stack_app) { |
|
122 | 122 | //$request_stack_builder->push( $stack_app ); |
123 | - $request_stack_builder->unshift( $stack_app ); |
|
123 | + $request_stack_builder->unshift($stack_app); |
|
124 | 124 | } |
125 | 125 | return apply_filters( |
126 | 126 | 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * no other logic should be performed at this point |
138 | 138 | */ |
139 | 139 | public static function load_espresso_addons() { |
140 | - do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' ); |
|
140 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * we can determine if anything needs activating or upgrading |
150 | 150 | */ |
151 | 151 | public static function detect_activations_or_upgrades() { |
152 | - do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' ); |
|
152 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * we can load and set all of the system configurations |
162 | 162 | */ |
163 | 163 | public static function load_core_configuration() { |
164 | - do_action( 'AHEE__EE_Bootstrap__load_core_configuration' ); |
|
164 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * so that they are ready to be used throughout the system |
174 | 174 | */ |
175 | 175 | public static function register_shortcodes_modules_and_widgets() { |
176 | - do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' ); |
|
176 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * so let the fun begin... |
186 | 186 | */ |
187 | 187 | public static function brew_espresso() { |
188 | - do_action( 'AHEE__EE_Bootstrap__brew_espresso' ); |
|
188 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | * @param array $post |
61 | 61 | * @param array $cookie |
62 | 62 | */ |
63 | - public function __construct( $get, $post, $cookie ) { |
|
63 | + public function __construct($get, $post, $cookie) { |
|
64 | 64 | // grab request vars |
65 | 65 | $this->_get = $get; |
66 | 66 | $this->_post = $post; |
67 | 67 | $this->_cookie = $cookie; |
68 | - $this->_params = array_merge( $get, $post ); |
|
68 | + $this->_params = array_merge($get, $post); |
|
69 | 69 | // AJAX ??? |
70 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
71 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
70 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
71 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | * @param bool $override_ee |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function set( $key, $value, $override_ee = FALSE ) { |
|
122 | + public function set($key, $value, $override_ee = FALSE) { |
|
123 | 123 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
124 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
125 | - $this->_params[ $key ] = $value; |
|
124 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
125 | + $this->_params[$key] = $value; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param null $default |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get( $key, $default = NULL ) { |
|
140 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
139 | + public function get($key, $default = NULL) { |
|
140 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param $key |
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | - public function is_set( $key ) { |
|
153 | - return isset( $this->_params[ $key ] ) ? TRUE : FALSE; |
|
152 | + public function is_set($key) { |
|
153 | + return isset($this->_params[$key]) ? TRUE : FALSE; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @param $key |
163 | 163 | * @param bool $unset_from_global_too |
164 | 164 | */ |
165 | - public function un_set( $key, $unset_from_global_too = false ) { |
|
166 | - unset( $this->_params[ $key ] ); |
|
167 | - if ( $unset_from_global_too ) { |
|
168 | - unset( $_REQUEST[ $key ] ); |
|
165 | + public function un_set($key, $unset_from_global_too = false) { |
|
166 | + unset($this->_params[$key]); |
|
167 | + if ($unset_from_global_too) { |
|
168 | + unset($_REQUEST[$key]); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param WP $wp |
66 | 66 | * @return \EE_Request_Handler |
67 | 67 | */ |
68 | - public function __construct( $wp = null ) { |
|
68 | + public function __construct($wp = null) { |
|
69 | 69 | // grab request vars |
70 | 70 | // NOTE: WHEN MERGING TO 4.9 PLZ FAVOUR THE CHANGES IN 4.9 OVER THE FOLLOWING LINE |
71 | - $this->_params = array_merge( $_GET, $_POST ); |
|
71 | + $this->_params = array_merge($_GET, $_POST); |
|
72 | 72 | // AJAX ??? |
73 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
74 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
75 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
73 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
74 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
75 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,12 +84,12 @@ discard block |
||
84 | 84 | * @param WP $wp |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function parse_request( $wp = null ) { |
|
87 | + public function parse_request($wp = null) { |
|
88 | 88 | //if somebody forgot to provide us with WP, that's ok because its global |
89 | - if ( ! $wp instanceof WP ) { |
|
89 | + if ( ! $wp instanceof WP) { |
|
90 | 90 | global $wp; |
91 | 91 | } |
92 | - $this->set_request_vars( $wp ); |
|
92 | + $this->set_request_vars($wp); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | * @param WP $wp |
102 | 102 | * @return void |
103 | 103 | */ |
104 | - public function set_request_vars( $wp = null ) { |
|
105 | - if ( ! is_admin() ) { |
|
104 | + public function set_request_vars($wp = null) { |
|
105 | + if ( ! is_admin()) { |
|
106 | 106 | // set request post_id |
107 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
107 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
108 | 108 | // set request post name |
109 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
109 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
110 | 110 | // set request post_type |
111 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
111 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
112 | 112 | // true or false ? is this page being used by EE ? |
113 | 113 | $this->set_espresso_page(); |
114 | 114 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | * @param WP $wp |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function get_post_id_from_request( $wp = null ) { |
|
127 | - if ( ! $wp instanceof WP ){ |
|
126 | + public function get_post_id_from_request($wp = null) { |
|
127 | + if ( ! $wp instanceof WP) { |
|
128 | 128 | global $wp; |
129 | 129 | } |
130 | 130 | $post_id = null; |
131 | - if ( isset( $wp->query_vars['p'] )) { |
|
131 | + if (isset($wp->query_vars['p'])) { |
|
132 | 132 | $post_id = $wp->query_vars['p']; |
133 | 133 | } |
134 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
134 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
135 | 135 | $post_id = $wp->query_vars['page_id']; |
136 | 136 | } |
137 | - if ( ! $post_id && isset( $wp->request )) { |
|
138 | - if ( is_numeric( basename( $wp->request ))) { |
|
139 | - $post_id = basename( $wp->request ); |
|
137 | + if ( ! $post_id && isset($wp->request)) { |
|
138 | + if (is_numeric(basename($wp->request))) { |
|
139 | + $post_id = basename($wp->request); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | return $post_id; |
@@ -151,35 +151,35 @@ discard block |
||
151 | 151 | * @param WP $wp |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function get_post_name_from_request( $wp = null ) { |
|
155 | - if ( ! $wp instanceof WP ){ |
|
154 | + public function get_post_name_from_request($wp = null) { |
|
155 | + if ( ! $wp instanceof WP) { |
|
156 | 156 | global $wp; |
157 | 157 | } |
158 | 158 | $post_name = null; |
159 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
159 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
160 | 160 | $post_name = $wp->query_vars['name']; |
161 | 161 | } |
162 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
162 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
163 | 163 | $post_name = $wp->query_vars['pagename']; |
164 | 164 | } |
165 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
166 | - $possible_post_name = basename( $wp->request ); |
|
167 | - if ( ! is_numeric( $possible_post_name )) { |
|
165 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
166 | + $possible_post_name = basename($wp->request); |
|
167 | + if ( ! is_numeric($possible_post_name)) { |
|
168 | 168 | /** @type WPDB $wpdb */ |
169 | 169 | global $wpdb; |
170 | 170 | $SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s"; |
171 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
172 | - if ( $possible_post_name ) { |
|
171 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
172 | + if ($possible_post_name) { |
|
173 | 173 | $post_name = $possible_post_name; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
177 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
177 | + if ( ! $post_name && $this->get('post_id')) { |
|
178 | 178 | /** @type WPDB $wpdb */ |
179 | 179 | global $wpdb; |
180 | 180 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d"; |
181 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
182 | - if( $possible_post_name ) { |
|
181 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
182 | + if ($possible_post_name) { |
|
183 | 183 | $post_name = $possible_post_name; |
184 | 184 | } |
185 | 185 | } |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @param WP $wp |
196 | 196 | * @return mixed |
197 | 197 | */ |
198 | - public function get_post_type_from_request( $wp = null ) { |
|
199 | - if ( ! $wp instanceof WP ){ |
|
198 | + public function get_post_type_from_request($wp = null) { |
|
199 | + if ( ! $wp instanceof WP) { |
|
200 | 200 | global $wp; |
201 | 201 | } |
202 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
202 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | |
@@ -209,18 +209,18 @@ discard block |
||
209 | 209 | * @param WP $wp |
210 | 210 | * @return bool|string|void |
211 | 211 | */ |
212 | - public function get_current_page_permalink( $wp = null ) { |
|
213 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
214 | - if ( $post_id ) { |
|
215 | - $current_page_permalink = get_permalink( $post_id ); |
|
212 | + public function get_current_page_permalink($wp = null) { |
|
213 | + $post_id = $this->get_post_id_from_request($wp); |
|
214 | + if ($post_id) { |
|
215 | + $current_page_permalink = get_permalink($post_id); |
|
216 | 216 | } else { |
217 | - if ( ! $wp instanceof WP ) { |
|
217 | + if ( ! $wp instanceof WP) { |
|
218 | 218 | global $wp; |
219 | 219 | } |
220 | - if ( $wp->request ) { |
|
221 | - $current_page_permalink = site_url( $wp->request ); |
|
220 | + if ($wp->request) { |
|
221 | + $current_page_permalink = site_url($wp->request); |
|
222 | 222 | } else { |
223 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
223 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | return $current_page_permalink; |
@@ -237,41 +237,41 @@ discard block |
||
237 | 237 | public function test_for_espresso_page() { |
238 | 238 | global $wp; |
239 | 239 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
240 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
240 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
241 | 241 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
242 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
243 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
244 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
242 | + if (is_array($espresso_CPT_taxonomies)) { |
|
243 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
244 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | 249 | // load espresso CPT endpoints |
250 | 250 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
251 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
252 | - $post_types = (array)$this->get( 'post_type' ); |
|
253 | - foreach ( $post_types as $post_type ) { |
|
251 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
252 | + $post_types = (array) $this->get('post_type'); |
|
253 | + foreach ($post_types as $post_type) { |
|
254 | 254 | // was a post name passed ? |
255 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
255 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
256 | 256 | // kk we know this is an espresso page, but is it a specific post ? |
257 | - if ( ! $this->get( 'post_name' ) ) { |
|
257 | + if ( ! $this->get('post_name')) { |
|
258 | 258 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
259 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null; |
|
259 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null; |
|
260 | 260 | // if the post type matches on of our then set the endpoint |
261 | - if ( $post_name ) { |
|
262 | - $this->set( 'post_name', $post_name ); |
|
261 | + if ($post_name) { |
|
262 | + $this->set('post_name', $post_name); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | return true; |
266 | 266 | } |
267 | 267 | } |
268 | - if ( $this->get( 'post_name' )) { |
|
268 | + if ($this->get('post_name')) { |
|
269 | 269 | // load all pages using espresso shortcodes |
270 | - $post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
270 | + $post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array(); |
|
271 | 271 | // make sure core pages are included |
272 | - $espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes ); |
|
272 | + $espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes); |
|
273 | 273 | // was a post name passed ? |
274 | - if ( isset( $espresso_pages[ $this->get( 'post_name' ) ] )) { |
|
274 | + if (isset($espresso_pages[$this->get('post_name')])) { |
|
275 | 275 | return true; |
276 | 276 | } |
277 | 277 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param null $value |
288 | 288 | * @return mixed |
289 | 289 | */ |
290 | - public function set_espresso_page( $value = null ) { |
|
290 | + public function set_espresso_page($value = null) { |
|
291 | 291 | $value = $value ? $value : $this->test_for_espresso_page(); |
292 | 292 | $this->_params['is_espresso_page'] = $value; |
293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return mixed |
302 | 302 | */ |
303 | 303 | public function is_espresso_page() { |
304 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
304 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | * @param bool $override_ee |
326 | 326 | * @return void |
327 | 327 | */ |
328 | - public function set( $key, $value, $override_ee = false ) { |
|
328 | + public function set($key, $value, $override_ee = false) { |
|
329 | 329 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
330 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
331 | - $this->_params[ $key ] = $value; |
|
330 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
331 | + $this->_params[$key] = $value; |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | * @param null $default |
343 | 343 | * @return mixed |
344 | 344 | */ |
345 | - public function get( $key, $default = null ) { |
|
346 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
345 | + public function get($key, $default = null) { |
|
346 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param $key |
356 | 356 | * @return boolean |
357 | 357 | */ |
358 | - public function is_set( $key ) { |
|
359 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
358 | + public function is_set($key) { |
|
359 | + return isset($this->_params[$key]) ? true : false; |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,8 +368,8 @@ discard block |
||
368 | 368 | * @param $key |
369 | 369 | * @return void |
370 | 370 | */ |
371 | - public function un_set( $key ) { |
|
372 | - unset( $this->_params[ $key ] ); |
|
371 | + public function un_set($key) { |
|
372 | + unset($this->_params[$key]); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -382,8 +382,8 @@ discard block |
||
382 | 382 | * @param $value |
383 | 383 | * @return void |
384 | 384 | */ |
385 | - public function set_notice( $key, $value ) { |
|
386 | - $this->_notice[ $key ] = $value; |
|
385 | + public function set_notice($key, $value) { |
|
386 | + $this->_notice[$key] = $value; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * @param $key |
396 | 396 | * @return mixed |
397 | 397 | */ |
398 | - public function get_notice( $key ) { |
|
399 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
398 | + public function get_notice($key) { |
|
399 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param $string |
409 | 409 | * @return void |
410 | 410 | */ |
411 | - public function add_output( $string ) { |
|
411 | + public function add_output($string) { |
|
412 | 412 | $this->_output .= $string; |
413 | 413 | } |
414 | 414 | |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * @param $item |
431 | 431 | * @param $key |
432 | 432 | */ |
433 | - function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
434 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
433 | + function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
434 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @param $b |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public function __set($a,$b) { return false; } |
|
444 | + public function __set($a, $b) { return false; } |
|
445 | 445 | |
446 | 446 | |
447 | 447 |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since $VID:$ |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Datetime extends Calculations_Base { |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | * @return int |
33 | 33 | * @throws \EE_Error |
34 | 34 | */ |
35 | - public static function spaces_remaining_considering_tickets( $wpdb_row, $request, $controller ){ |
|
36 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) { |
|
37 | - $dtt_obj = \EEM_Datetime::instance()->get_one_by_ID( $wpdb_row[ 'Datetime.DTT_ID' ] ); |
|
35 | + public static function spaces_remaining_considering_tickets($wpdb_row, $request, $controller) { |
|
36 | + if (is_array($wpdb_row) && isset($wpdb_row['Datetime.DTT_ID'])) { |
|
37 | + $dtt_obj = \EEM_Datetime::instance()->get_one_by_ID($wpdb_row['Datetime.DTT_ID']); |
|
38 | 38 | } else { |
39 | 39 | $dtt_obj = null; |
40 | 40 | } |
41 | - if( $dtt_obj instanceof \EE_Datetime ) { |
|
42 | - return $dtt_obj->spaces_remaining( true ); |
|
41 | + if ($dtt_obj instanceof \EE_Datetime) { |
|
42 | + return $dtt_obj->spaces_remaining(true); |
|
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
47 | - $wpdb_row[ 'Datetime.DTT_ID' ], |
|
48 | - print_r( $wpdb_row, true ) |
|
46 | + __('Cannot calculate spaces_remaining_considering_tickets because the datetime with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
47 | + $wpdb_row['Datetime.DTT_ID'], |
|
48 | + print_r($wpdb_row, true) |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | } |
@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | * @throws \EE_Error |
64 | 64 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
65 | 65 | */ |
66 | - public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){ |
|
67 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) { |
|
66 | + public static function registrations_checked_in_count($wpdb_row, $request, $controller) { |
|
67 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
68 | 68 | throw new \EE_Error( |
69 | 69 | sprintf( |
70 | - __( 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso' ), |
|
71 | - print_r( $wpdb_row, true ) |
|
70 | + __('Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso'), |
|
71 | + print_r($wpdb_row, true) |
|
72 | 72 | ) |
73 | 73 | ); |
74 | 74 | } |
75 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_in_count' ); |
|
76 | - return \EEM_Registration::instance()->count_registrations_checked_into_datetime( $wpdb_row[ 'Datetime.DTT_ID' ], true ); |
|
75 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_in_count'); |
|
76 | + return \EEM_Registration::instance()->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], true); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
90 | 90 | */ |
91 | - public static function registrations_checked_out_count( $wpdb_row, $request, $controller ){ |
|
92 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) { |
|
91 | + public static function registrations_checked_out_count($wpdb_row, $request, $controller) { |
|
92 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
93 | 93 | throw new \EE_Error( |
94 | 94 | sprintf( |
95 | - __( 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso' ), |
|
96 | - print_r( $wpdb_row, true ) |
|
95 | + __('Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso'), |
|
96 | + print_r($wpdb_row, true) |
|
97 | 97 | ) |
98 | 98 | ); |
99 | 99 | } |
100 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_out_count' ); |
|
101 | - return \EEM_Registration::instance()->count_registrations_checked_into_datetime( $wpdb_row[ 'Datetime.DTT_ID' ], false ); |
|
100 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_out_count'); |
|
101 | + return \EEM_Registration::instance()->count_registrations_checked_into_datetime($wpdb_row['Datetime.DTT_ID'], false); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | * @throws \EE_Error |
115 | 115 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
116 | 116 | */ |
117 | - public static function spots_taken_pending_payment( $wpdb_row, $request, $controller ){ |
|
118 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Datetime.DTT_ID' ] ) ) { |
|
117 | + public static function spots_taken_pending_payment($wpdb_row, $request, $controller) { |
|
118 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Datetime.DTT_ID'])) { |
|
119 | 119 | throw new \EE_Error( |
120 | 120 | sprintf( |
121 | - __( 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso' ), |
|
122 | - print_r( $wpdb_row, true ) |
|
121 | + __('Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Datetime.DTT_ID"', 'event_espresso'), |
|
122 | + print_r($wpdb_row, true) |
|
123 | 123 | ) |
124 | 124 | ); |
125 | 125 | } |
126 | - self::_verify_current_user_can( 'ee_read_registrations', 'spots_taken_pending_payment' ); |
|
126 | + self::_verify_current_user_can('ee_read_registrations', 'spots_taken_pending_payment'); |
|
127 | 127 | return \EEM_Registration::instance()->count( |
128 | 128 | array( |
129 | 129 | array( |
130 | - 'Ticket.Datetime.DTT_ID' => $wpdb_row[ 'Datetime.DTT_ID' ], |
|
130 | + 'Ticket.Datetime.DTT_ID' => $wpdb_row['Datetime.DTT_ID'], |
|
131 | 131 | 'STS_ID' => \EEM_Registration::status_id_pending_payment |
132 | 132 | ) |
133 | 133 | ), |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
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 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function instance() { |
36 | 36 | self::$_field_calculator = new Calculated_Model_Fields(); |
37 | - return parent::get_instance( __CLASS__ ); |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | public static function set_hooks_both() { |
67 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
69 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
70 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
67 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
69 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
70 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
71 | 71 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
72 | 72 | } |
73 | 73 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * Loads all the hooks which make requests to old versions of the API |
86 | 86 | * appear the same as they always did |
87 | 87 | */ |
88 | - public static function set_hooks_for_changes(){ |
|
88 | + public static function set_hooks_for_changes() { |
|
89 | 89 | self::_set_hooks_for_changes(); |
90 | 90 | } |
91 | 91 | /** |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | * appear the same as they always did |
94 | 94 | */ |
95 | 95 | protected static function _set_hooks_for_changes() { |
96 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
97 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
96 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
97 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
98 | 98 | //ignore the base parent class |
99 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
99 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
103 | - if ( class_exists( $full_classname )) { |
|
102 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
103 | + if (class_exists($full_classname)) { |
|
104 | 104 | $instance_of_class = new $full_classname; |
105 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
105 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
106 | 106 | $instance_of_class->set_hooks(); |
107 | 107 | } |
108 | 108 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
116 | 116 | */ |
117 | 117 | public static function register_routes() { |
118 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
119 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
120 | - foreach( $routes as $route ) { |
|
118 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
119 | + foreach ($relative_urls as $endpoint => $routes) { |
|
120 | + foreach ($routes as $route) { |
|
121 | 121 | register_rest_route( |
122 | 122 | $namespace, |
123 | 123 | $endpoint, |
124 | 124 | array( |
125 | - 'callback' => $route[ 'callback' ], |
|
126 | - 'methods' => $route[ 'methods' ], |
|
127 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
125 | + 'callback' => $route['callback'], |
|
126 | + 'methods' => $route['methods'], |
|
127 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
128 | 128 | ) |
129 | 129 | ); |
130 | 130 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | * next time the WP API is used |
139 | 139 | */ |
140 | 140 | public static function invalidate_cached_route_data_on_version_change() { |
141 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
141 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
142 | 142 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
143 | 143 | } |
144 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
145 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
144 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
145 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
146 | 146 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
147 | 147 | } |
148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public static function invalidate_cached_route_data() { |
155 | 155 | //delete the saved EE REST API routes |
156 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
156 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | * } |
166 | 166 | */ |
167 | 167 | public static function get_ee_route_data() { |
168 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
169 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
168 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
169 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
170 | 170 | self::save_ee_routes(); |
171 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
171 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
172 | 172 | } |
173 | 173 | return $ee_routes; |
174 | 174 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | */ |
181 | 181 | public static function save_ee_routes() { |
182 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
182 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
183 | 183 | $instance = self::instance(); |
184 | 184 | $routes = apply_filters( |
185 | 185 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $instance->_register_rpc_routes() |
191 | 191 | ) |
192 | 192 | ); |
193 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
193 | + update_option(self::saved_routes_option_names, $routes, true); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return array @see get_ee_route_data |
200 | 200 | */ |
201 | 201 | protected function _register_model_routes() { |
202 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
202 | + EE_Registry::instance()->load_helper('Inflector'); |
|
203 | 203 | $models_to_register = apply_filters( |
204 | 204 | 'FHEE__EED_Core_REST_API___register_model_routes', |
205 | 205 | EE_Registry::instance()->non_abstract_db_models |
@@ -208,24 +208,24 @@ discard block |
||
208 | 208 | unset($models_to_register['Extra_Meta']); |
209 | 209 | unset($models_to_register['Extra_Join']); |
210 | 210 | $model_routes = array( ); |
211 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
211 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
212 | 212 | |
213 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
214 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
213 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
214 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
215 | 215 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
216 | - $ee_namespace = self::ee_api_namespace . $version; |
|
217 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
218 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
219 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
216 | + $ee_namespace = self::ee_api_namespace.$version; |
|
217 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
218 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
219 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
220 | 220 | array( |
221 | 221 | 'callback' => array( |
222 | 222 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
223 | 223 | 'handle_request_get_all' ), |
224 | 224 | 'methods' => WP_REST_Server::READABLE, |
225 | 225 | 'hidden_endpoint' => $hidden_endpoint, |
226 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
226 | + 'args' => $this->_get_read_query_params($model, $version), |
|
227 | 227 | '_links' => array( |
228 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
228 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
229 | 229 | ) |
230 | 230 | ), |
231 | 231 | // array( |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | // 'hidden_endpoint' => $hidden_endpoint |
237 | 237 | // ) |
238 | 238 | ); |
239 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
239 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
240 | 240 | array( |
241 | 241 | 'callback' => array( |
242 | 242 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
243 | 243 | 'handle_request_get_one' ), |
244 | 244 | 'methods' => WP_REST_Server::READABLE, |
245 | 245 | 'hidden_endpoint' => $hidden_endpoint, |
246 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
246 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
247 | 247 | ), |
248 | 248 | // array( |
249 | 249 | // 'callback' => array( |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | // ), |
255 | 255 | ); |
256 | 256 | //@todo: also handle DELETE for a single item |
257 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
257 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
258 | 258 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
259 | 259 | $relation_name, |
260 | 260 | $relation_obj |
261 | 261 | ); |
262 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
262 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
263 | 263 | array( |
264 | 264 | 'callback' => array( |
265 | 265 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
266 | 266 | 'handle_request_get_related' ), |
267 | 267 | 'methods' => WP_REST_Server::READABLE, |
268 | 268 | 'hidden_endpoint' => $hidden_endpoint, |
269 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
269 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
270 | 270 | ), |
271 | 271 | // array( |
272 | 272 | // 'callback' => array( |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | */ |
291 | 291 | protected function _register_rpc_routes() { |
292 | 292 | $routes = array(); |
293 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
294 | - $ee_namespace = self::ee_api_namespace . $version; |
|
293 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
294 | + $ee_namespace = self::ee_api_namespace.$version; |
|
295 | 295 | $this_versions_routes = array(); |
296 | 296 | //checkin endpoint |
297 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
297 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
298 | 298 | array( |
299 | 299 | 'callback' => array( |
300 | 300 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | 'force' => array( |
306 | 306 | 'required' => false, |
307 | 307 | 'default' => false, |
308 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
308 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
309 | 309 | ) |
310 | 310 | ) |
311 | 311 | ) |
312 | 312 | ); |
313 | - $routes[ $ee_namespace ] = apply_filters( |
|
313 | + $routes[$ee_namespace] = apply_filters( |
|
314 | 314 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
315 | 315 | $this_versions_routes, |
316 | 316 | $version, |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | * @param string $version |
327 | 327 | * @return array |
328 | 328 | */ |
329 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
329 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
330 | 330 | return apply_filters( |
331 | 331 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
332 | 332 | array( |
333 | 333 | 'include' => array( |
334 | 334 | 'required' => false, |
335 | 335 | 'default' => '*', |
336 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
336 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
337 | 337 | ), |
338 | 338 | 'calculate' => array( |
339 | 339 | 'required' => false, |
340 | 340 | 'default' => '', |
341 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
341 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
342 | 342 | ) |
343 | 343 | ), |
344 | 344 | $model, |
@@ -356,43 +356,43 @@ discard block |
||
356 | 356 | * @return array describing the args acceptable when querying this model |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
359 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
360 | 360 | $default_orderby = array(); |
361 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
362 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
361 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
362 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
363 | 363 | } |
364 | 364 | return array_merge( |
365 | - $this->_get_response_selection_query_params( $model, $version ), |
|
365 | + $this->_get_response_selection_query_params($model, $version), |
|
366 | 366 | array( |
367 | 367 | 'where' => array( |
368 | 368 | 'required' => false, |
369 | 369 | 'default' => array(), |
370 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
370 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
371 | 371 | ), |
372 | 372 | 'limit' => array( |
373 | 373 | 'required' => false, |
374 | 374 | 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
375 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
375 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
376 | 376 | ), |
377 | 377 | 'order_by' => array( |
378 | 378 | 'required' => false, |
379 | 379 | 'default' => $default_orderby, |
380 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
380 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
381 | 381 | ), |
382 | 382 | 'group_by' => array( |
383 | 383 | 'required' => false, |
384 | 384 | 'default' => null, |
385 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
385 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
386 | 386 | ), |
387 | 387 | 'having' => array( |
388 | 388 | 'required' => false, |
389 | 389 | 'default' => null, |
390 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
390 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
391 | 391 | ), |
392 | 392 | 'caps' => array( |
393 | 393 | 'required' => false, |
394 | 394 | 'default' => EEM_Base::caps_read, |
395 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
395 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
396 | 396 | ), |
397 | 397 | ) |
398 | 398 | ); |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | */ |
405 | 405 | protected function _register_config_routes() { |
406 | 406 | $config_routes = array(); |
407 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
408 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
407 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
408 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
409 | 409 | array( |
410 | 410 | 'callback' => array( |
411 | 411 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | */ |
425 | 425 | protected function _register_meta_routes() { |
426 | 426 | $meta_routes = array(); |
427 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
428 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
427 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
428 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
429 | 429 | array( |
430 | 430 | 'callback' => array( |
431 | 431 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | * @param array $route_data |
447 | 447 | * @return array |
448 | 448 | */ |
449 | - public static function hide_old_endpoints( $route_data ) { |
|
450 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
451 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
452 | - foreach( $routes as $route ) { |
|
453 | - if( $route[ 'hidden_endpoint' ] ) { |
|
454 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
455 | - unset( $route_data[ $full_route ] ); |
|
449 | + public static function hide_old_endpoints($route_data) { |
|
450 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
451 | + foreach ($relative_urls as $endpoint => $routes) { |
|
452 | + foreach ($routes as $route) { |
|
453 | + if ($route['hidden_endpoint']) { |
|
454 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
455 | + unset($route_data[$full_route]); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public static function latest_rest_api_version() { |
493 | 493 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
494 | - return end( array_keys( $versions_served ) ); |
|
494 | + return end(array_keys($versions_served)); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -505,32 +505,32 @@ discard block |
||
505 | 505 | public static function versions_served() { |
506 | 506 | $versions_served = array(); |
507 | 507 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
508 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
509 | - reset( $possibly_served_versions ); |
|
510 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
511 | - $latest_version = end( $versions_served_historically ); |
|
512 | - reset( $versions_served_historically ); |
|
508 | + $lowest_compatible_version = end($possibly_served_versions); |
|
509 | + reset($possibly_served_versions); |
|
510 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
511 | + $latest_version = end($versions_served_historically); |
|
512 | + reset($versions_served_historically); |
|
513 | 513 | //for each version of core we have ever served: |
514 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
514 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
515 | 515 | //if it's not above the current core version, and it's compatible with the current version of core |
516 | - if( $key_versioned_endpoint == $latest_version ) { |
|
516 | + if ($key_versioned_endpoint == $latest_version) { |
|
517 | 517 | //don't hide the latest version in the index |
518 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
519 | - } else if( |
|
518 | + $versions_served[$key_versioned_endpoint] = false; |
|
519 | + } else if ( |
|
520 | 520 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
521 | 521 | && $key_versioned_endpoint >= $lowest_compatible_version |
522 | 522 | ) { |
523 | 523 | //include, but hide, previous versions which are still supported |
524 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
525 | - } elseif( |
|
524 | + $versions_served[$key_versioned_endpoint] = true; |
|
525 | + } elseif ( |
|
526 | 526 | apply_filters( |
527 | 527 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
528 | 528 | false, |
529 | 529 | $possibly_served_versions |
530 | 530 | ) |
531 | - ){ |
|
531 | + ) { |
|
532 | 532 | //if a version is no longer supported, don't include it in index or list of versions served |
533 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
533 | + $versions_served[$key_versioned_endpoint] = true; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | return $versions_served; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | * @return string |
544 | 544 | */ |
545 | 545 | public static function core_version() { |
546 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
546 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param WP $WP |
569 | 569 | * @return void |
570 | 570 | */ |
571 | - public function run( $WP ) { |
|
571 | + public function run($WP) { |
|
572 | 572 | |
573 | 573 | } |
574 | 574 |
@@ -15,28 +15,28 @@ discard block |
||
15 | 15 | //set a hook to remove the "calculate" query param |
16 | 16 | add_filter( |
17 | 17 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
18 | - array( $this, 'remove_calculate_query_param' ), |
|
18 | + array($this, 'remove_calculate_query_param'), |
|
19 | 19 | 10, |
20 | 20 | 3 |
21 | 21 | ); |
22 | 22 | //don't add the _calculated_fields either |
23 | 23 | add_filter( |
24 | 24 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
25 | - array( $this, 'remove_calculated_fields_from_response' ), |
|
25 | + array($this, 'remove_calculated_fields_from_response'), |
|
26 | 26 | 10, |
27 | 27 | 5 |
28 | 28 | ); |
29 | 29 | //and also don't add the count headers |
30 | 30 | add_filter( |
31 | 31 | 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
32 | - array( $this, 'remove_headers_new_in_this_version' ), |
|
32 | + array($this, 'remove_headers_new_in_this_version'), |
|
33 | 33 | 10, |
34 | 34 | 3 |
35 | 35 | ); |
36 | 36 | //remove the old featured_image part of the response... |
37 | 37 | add_filter( |
38 | 38 | 'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal', |
39 | - array( $this, 'remove_old_featured_image_part_of_cpt_entities' ), |
|
39 | + array($this, 'remove_old_featured_image_part_of_cpt_entities'), |
|
40 | 40 | 10, |
41 | 41 | 5 |
42 | 42 | ); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | //before this, infinity was -1, now it's null |
47 | 47 | add_filter( |
48 | 48 | 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
49 | - array( $this, 'use_negative_one_for_infinity_before_this_version' ), |
|
49 | + array($this, 'use_negative_one_for_infinity_before_this_version'), |
|
50 | 50 | 10, |
51 | 51 | 4 |
52 | 52 | ); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @param string $version |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function remove_calculate_query_param( $query_params, \EEM_Base $model, $version ) { |
|
63 | - if( $this->applies_to_version( $version ) ) { |
|
64 | - unset( $query_params[ 'calculate' ] ); |
|
62 | + public function remove_calculate_query_param($query_params, \EEM_Base $model, $version) { |
|
63 | + if ($this->applies_to_version($version)) { |
|
64 | + unset($query_params['calculate']); |
|
65 | 65 | } |
66 | 66 | return $query_params; |
67 | 67 | } |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | \WP_REST_Request $request, |
83 | 83 | Read $controller |
84 | 84 | ) { |
85 | - if( $this->applies_to_version( $controller->get_model_version_info()->requested_version() ) ) { |
|
86 | - unset( $entity_response_array[ '_calculated_fields' ] ); |
|
85 | + if ($this->applies_to_version($controller->get_model_version_info()->requested_version())) { |
|
86 | + unset($entity_response_array['_calculated_fields']); |
|
87 | 87 | } |
88 | 88 | return $entity_response_array; |
89 | 89 | } |
@@ -101,14 +101,14 @@ discard block |
||
101 | 101 | Base $controller, |
102 | 102 | $version |
103 | 103 | ) { |
104 | - if( $this->applies_to_version( $version ) ) { |
|
104 | + if ($this->applies_to_version($version)) { |
|
105 | 105 | $headers = array_diff_key( |
106 | 106 | $headers, |
107 | 107 | array_flip( |
108 | 108 | array( |
109 | - Base::header_prefix_for_wp . 'Total', |
|
110 | - Base::header_prefix_for_wp . 'TotalPages', |
|
111 | - Base::header_prefix_for_wp . 'PageSize' |
|
109 | + Base::header_prefix_for_wp.'Total', |
|
110 | + Base::header_prefix_for_wp.'TotalPages', |
|
111 | + Base::header_prefix_for_wp.'PageSize' |
|
112 | 112 | ))); |
113 | 113 | } |
114 | 114 | return $headers; |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | \WP_REST_Request $request, |
131 | 131 | Read $controller |
132 | 132 | ) { |
133 | - if( $this->applies_to_version( $controller->get_model_version_info()->requested_version() ) |
|
133 | + if ($this->applies_to_version($controller->get_model_version_info()->requested_version()) |
|
134 | 134 | && $model instanceof \EEM_CPT_Base |
135 | 135 | ) { |
136 | 136 | $attachment = wp_get_attachment_image_src( |
137 | - get_post_thumbnail_id( $entity_response_array[ $model->primary_key_name() ] ), |
|
137 | + get_post_thumbnail_id($entity_response_array[$model->primary_key_name()]), |
|
138 | 138 | 'full' |
139 | 139 | ); |
140 | - $entity_response_array[ 'featured_image_url' ] = !empty( $attachment ) ? $attachment[ 0 ] : null; |
|
140 | + $entity_response_array['featured_image_url'] = ! empty($attachment) ? $attachment[0] : null; |
|
141 | 141 | } |
142 | 142 | return $entity_response_array; |
143 | 143 | } |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | * @param string $requested_value |
153 | 153 | * @return mixed |
154 | 154 | */ |
155 | - public function use_negative_one_for_infinity_before_this_version( $new_value, $field_obj, $original_value, $requested_value ) { |
|
156 | - if( $this->applies_to_version( $requested_value ) |
|
157 | - && $original_value === EE_INF ) { |
|
155 | + public function use_negative_one_for_infinity_before_this_version($new_value, $field_obj, $original_value, $requested_value) { |
|
156 | + if ($this->applies_to_version($requested_value) |
|
157 | + && $original_value === EE_INF) { |
|
158 | 158 | //return the old representation of infinity in the JSON |
159 | 159 | return -1; |
160 | 160 | } |