@@ -121,7 +121,7 @@ |
||
121 | 121 | |
122 | 122 | /** |
123 | 123 | * resolve_route |
124 | - * |
|
124 | + * |
|
125 | 125 | * this method simply takes a valid route, and resolves what module class method the route points to |
126 | 126 | * |
127 | 127 | * @access public |
@@ -61,31 +61,31 @@ discard block |
||
61 | 61 | * @param WP_Query $WP_Query |
62 | 62 | * @return string | NULL |
63 | 63 | */ |
64 | - public function get_route( WP_Query $WP_Query ) { |
|
64 | + public function get_route(WP_Query $WP_Query) { |
|
65 | 65 | $this->WP_Query = $WP_Query; |
66 | 66 | // assume this if first route being called |
67 | 67 | $previous_route = FALSE; |
68 | 68 | // but is it really ??? |
69 | - if ( ! empty( self::$_previous_routes )) { |
|
69 | + if ( ! empty(self::$_previous_routes)) { |
|
70 | 70 | // get last run route |
71 | - $previous_routes = array_values( self::$_previous_routes ); |
|
72 | - $previous_route = array_pop( $previous_routes ); |
|
71 | + $previous_routes = array_values(self::$_previous_routes); |
|
72 | + $previous_route = array_pop($previous_routes); |
|
73 | 73 | } |
74 | 74 | // has another route already been run ? |
75 | - if ( $previous_route ) { |
|
75 | + if ($previous_route) { |
|
76 | 76 | // check if forwarding has been set |
77 | - $current_route = $this->get_forward( $previous_route ); |
|
77 | + $current_route = $this->get_forward($previous_route); |
|
78 | 78 | try { |
79 | 79 | //check for recursive forwarding |
80 | - if ( isset( self::$_previous_routes[ $current_route ] )) { |
|
80 | + if (isset(self::$_previous_routes[$current_route])) { |
|
81 | 81 | throw new EE_Error( |
82 | 82 | sprintf( |
83 | - __('An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.','event_espresso'), |
|
83 | + __('An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', 'event_espresso'), |
|
84 | 84 | $current_route |
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
88 | - } catch ( EE_Error $e ) { |
|
88 | + } catch (EE_Error $e) { |
|
89 | 89 | $e->get_error(); |
90 | 90 | return NULL; |
91 | 91 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | // grab all routes |
96 | 96 | $routes = EE_Registry::instance()->CFG->get_routes(); |
97 | 97 | //d( $routes ); |
98 | - foreach( $routes as $key => $route ) { |
|
98 | + foreach ($routes as $key => $route) { |
|
99 | 99 | // check request for module route |
100 | - if ( EE_Registry::instance()->REQ->is_set( $key )) { |
|
100 | + if (EE_Registry::instance()->REQ->is_set($key)) { |
|
101 | 101 | //echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />'; |
102 | - $current_route = sanitize_text_field( EE_Registry::instance()->REQ->get( $key )); |
|
103 | - if ( $current_route ) { |
|
104 | - $current_route = array( $key, $current_route ); |
|
102 | + $current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key)); |
|
103 | + if ($current_route) { |
|
104 | + $current_route = array($key, $current_route); |
|
105 | 105 | //echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />'; |
106 | 106 | break; |
107 | 107 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | // sorry, but I can't read what you route ! |
112 | - if ( empty( $current_route )) { |
|
112 | + if (empty($current_route)) { |
|
113 | 113 | return NULL; |
114 | 114 | } |
115 | 115 | //add route to previous routes array |
@@ -129,46 +129,46 @@ discard block |
||
129 | 129 | * @param string $current_route |
130 | 130 | * @return mixed EED_Module | boolean |
131 | 131 | */ |
132 | - public function resolve_route( $key, $current_route ) { |
|
132 | + public function resolve_route($key, $current_route) { |
|
133 | 133 | // get module method that route has been mapped to |
134 | - $module_method = EE_Config::get_route( $current_route, $key ); |
|
134 | + $module_method = EE_Config::get_route($current_route, $key); |
|
135 | 135 | //EEH_Debug_Tools::printr( $module_method, '$module_method <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
136 | 136 | // verify result was returned |
137 | - if ( empty( $module_method )) { |
|
138 | - $msg = sprintf( __( 'The requested route %s could not be mapped to any registered modules.', 'event_espresso' ), $current_route ); |
|
139 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
137 | + if (empty($module_method)) { |
|
138 | + $msg = sprintf(__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), $current_route); |
|
139 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
140 | 140 | return FALSE; |
141 | 141 | } |
142 | 142 | // verify that result is an array |
143 | - if ( ! is_array( $module_method )) { |
|
144 | - $msg = sprintf( __( 'The %s route has not been properly registered.', 'event_espresso' ), $current_route ); |
|
145 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
143 | + if ( ! is_array($module_method)) { |
|
144 | + $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
145 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
146 | 146 | return FALSE; |
147 | 147 | } |
148 | 148 | // grab module name |
149 | 149 | $module_name = $module_method[0]; |
150 | 150 | // verify that a class method was registered properly |
151 | - if ( ! isset( $module_method[1] )) { |
|
152 | - $msg = sprintf( __( 'A class method for the %s route has not been properly registered.', 'event_espresso' ), $current_route ); |
|
153 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
151 | + if ( ! isset($module_method[1])) { |
|
152 | + $msg = sprintf(__('A class method for the %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
153 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
154 | 154 | return FALSE; |
155 | 155 | } |
156 | 156 | // grab method |
157 | 157 | $method = $module_method[1]; |
158 | 158 | // verify that class exists |
159 | - if ( ! class_exists( $module_name )) { |
|
160 | - $msg = sprintf( __( 'The requested %s class could not be found.', 'event_espresso' ), $module_name ); |
|
161 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
159 | + if ( ! class_exists($module_name)) { |
|
160 | + $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
161 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
162 | 162 | return FALSE; |
163 | 163 | } |
164 | 164 | // verify that method exists |
165 | - if ( ! method_exists( $module_name, $method )) { |
|
166 | - $msg = sprintf( __( 'The class method %s for the %s route is in invalid.', 'event_espresso' ), $method, $current_route ); |
|
167 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
165 | + if ( ! method_exists($module_name, $method)) { |
|
166 | + $msg = sprintf(__('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route); |
|
167 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
168 | 168 | return FALSE; |
169 | 169 | } |
170 | 170 | // instantiate module and call route method |
171 | - return $this->_module_router( $module_name, $method ); |
|
171 | + return $this->_module_router($module_name, $method); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | * @param string $module_name |
183 | 183 | * @return EED_Module | NULL |
184 | 184 | */ |
185 | - public static function module_factory( $module_name ) { |
|
186 | - if ( $module_name == 'EED_Module' ) { |
|
187 | - EE_Error::add_error( sprintf( __( 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', 'event_espresso' ), $module_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
185 | + public static function module_factory($module_name) { |
|
186 | + if ($module_name == 'EED_Module') { |
|
187 | + EE_Error::add_error(sprintf(__('EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', 'event_espresso'), $module_name), __FILE__, __FUNCTION__, __LINE__); |
|
188 | 188 | return NULL; |
189 | 189 | } |
190 | 190 | // let's pause to reflect on this... |
191 | - $mod_reflector = new ReflectionClass( $module_name ); |
|
191 | + $mod_reflector = new ReflectionClass($module_name); |
|
192 | 192 | // ensure that class is actually a module |
193 | - if ( ! $mod_reflector->isSubclassOf( 'EED_Module' )) { |
|
194 | - EE_Error::add_error( sprintf( __( 'The requested %s module is not of the class EED_Module.', 'event_espresso' ), $module_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
193 | + if ( ! $mod_reflector->isSubclassOf('EED_Module')) { |
|
194 | + EE_Error::add_error(sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), __FILE__, __FUNCTION__, __LINE__); |
|
195 | 195 | return NULL; |
196 | 196 | } |
197 | 197 | // instantiate and return module class |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | * @param string $method |
210 | 210 | * @return EED_Module | NULL |
211 | 211 | */ |
212 | - private function _module_router( $module_name, $method ) { |
|
212 | + private function _module_router($module_name, $method) { |
|
213 | 213 | // instantiate module class |
214 | - $module = EE_Module_Request_Router::module_factory( $module_name ); |
|
215 | - if ( $module instanceof EED_Module ) { |
|
214 | + $module = EE_Module_Request_Router::module_factory($module_name); |
|
215 | + if ($module instanceof EED_Module) { |
|
216 | 216 | // and call whatever action the route was for |
217 | 217 | try { |
218 | - call_user_func( array( $module, $method ), $this->WP_Query ); |
|
219 | - } catch ( EE_Error $e ) { |
|
218 | + call_user_func(array($module, $method), $this->WP_Query); |
|
219 | + } catch (EE_Error $e) { |
|
220 | 220 | $e->get_error(); |
221 | 221 | return NULL; |
222 | 222 | } |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param $current_route |
234 | 234 | * @return string |
235 | 235 | */ |
236 | - public function get_forward( $current_route ) { |
|
237 | - return EE_Config::get_forward( $current_route ); |
|
236 | + public function get_forward($current_route) { |
|
237 | + return EE_Config::get_forward($current_route); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | * @param $current_route |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - public function get_view( $current_route ) { |
|
250 | - return EE_Config::get_view( $current_route ); |
|
249 | + public function get_view($current_route) { |
|
250 | + return EE_Config::get_view($current_route); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param $b |
258 | 258 | * @return bool |
259 | 259 | */ |
260 | - public function __set($a,$b) { return FALSE; } |
|
260 | + public function __set($a, $b) { return FALSE; } |
|
261 | 261 | |
262 | 262 | |
263 | 263 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -243,7 +243,7 @@ |
||
243 | 243 | * get_view |
244 | 244 | * |
245 | 245 | * @access public |
246 | - * @param $current_route |
|
246 | + * @param string $current_route |
|
247 | 247 | * @return string |
248 | 248 | */ |
249 | 249 | public function get_view( $current_route ) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated, and instantiated properly |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @return void |
75 | 75 | */ |
76 | 76 | private function __construct() { |
77 | - do_action( 'AHEE__EE_Network_Config__construct__begin',$this ); |
|
77 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
78 | 78 | //set defaults |
79 | - $this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() ); |
|
79 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
80 | 80 | $this->addons = array(); |
81 | 81 | |
82 | 82 | $this->_load_config(); |
83 | 83 | |
84 | 84 | // construct__end hook |
85 | - do_action( 'AHEE__EE_Network_Config__construct__end',$this ); |
|
85 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | private function _load_config() { |
97 | 97 | $config = $this->get_config(); |
98 | - foreach ( $config as $prop => $settings ) { |
|
99 | - $prop_class = is_object( $settings ) ? get_class( $this->$prop ) : FALSE; |
|
100 | - if ( ! empty( $settings ) && ( ! $prop_class || ( $settings instanceof $prop_class ))) { |
|
98 | + foreach ($config as $prop => $settings) { |
|
99 | + $prop_class = is_object($settings) ? get_class($this->$prop) : FALSE; |
|
100 | + if ( ! empty($settings) && ( ! $prop_class || ($settings instanceof $prop_class))) { |
|
101 | 101 | $this->$prop = $settings; |
102 | 102 | } |
103 | 103 | } |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function get_config() { |
116 | 116 | // grab network configuration |
117 | - $CFG = get_site_option( 'ee_network_config', array() ); |
|
118 | - $CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG ); |
|
117 | + $CFG = get_site_option('ee_network_config', array()); |
|
118 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
119 | 119 | return $CFG; |
120 | 120 | } |
121 | 121 | |
@@ -127,24 +127,24 @@ discard block |
||
127 | 127 | * @access public |
128 | 128 | * @return boolean success |
129 | 129 | */ |
130 | - public function update_config( $add_success = FALSE, $add_error = TRUE ) { |
|
131 | - do_action( 'AHEE__EE_Network_Config__update_config__begin',$this ); |
|
130 | + public function update_config($add_success = FALSE, $add_error = TRUE) { |
|
131 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
132 | 132 | // compare existing settings with what's already saved' |
133 | 133 | $saved_config = $this->get_config(); |
134 | 134 | // update |
135 | - $saved = $saved_config == $this ? TRUE : update_site_option( 'ee_network_config', $this ); |
|
136 | - do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved ); |
|
135 | + $saved = $saved_config == $this ? TRUE : update_site_option('ee_network_config', $this); |
|
136 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
137 | 137 | // if config remains the same or was updated successfully |
138 | - if ( $saved ) { |
|
139 | - if ( $add_success ) { |
|
140 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' ); |
|
141 | - EE_Error::add_success( $msg ); |
|
138 | + if ($saved) { |
|
139 | + if ($add_success) { |
|
140 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
141 | + EE_Error::add_success($msg); |
|
142 | 142 | } |
143 | 143 | return TRUE; |
144 | 144 | } else { |
145 | - if ( $add_error ) { |
|
146 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' ); |
|
147 | - EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ ); |
|
145 | + if ($add_error) { |
|
146 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
147 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
148 | 148 | } |
149 | 149 | return FALSE; |
150 | 150 | } |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | * @return array |
159 | 159 | */ |
160 | 160 | public function __sleep() { |
161 | - return apply_filters( 'FHEE__EE_Network_Config__sleep',array( |
|
161 | + return apply_filters('FHEE__EE_Network_Config__sleep', array( |
|
162 | 162 | 'core', |
163 | - ) ); |
|
163 | + )); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } //end EE_Network_Config. |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -2,18 +2,18 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Class EE_Object_Collection |
|
6 | - * |
|
7 | - * abstract storage entity for unique objects |
|
8 | - * extends SplObjectStorage so therefore implements the |
|
9 | - * Countable, Iterator, Serializable, and ArrayAccess interfaces |
|
10 | - * |
|
11 | - * @package Event Espresso |
|
12 | - * @subpackage core |
|
13 | - * @author Brent Christensen |
|
14 | - * @since 4.6.31 |
|
15 | - * |
|
16 | - */ |
|
5 | + * Class EE_Object_Collection |
|
6 | + * |
|
7 | + * abstract storage entity for unique objects |
|
8 | + * extends SplObjectStorage so therefore implements the |
|
9 | + * Countable, Iterator, Serializable, and ArrayAccess interfaces |
|
10 | + * |
|
11 | + * @package Event Espresso |
|
12 | + * @subpackage core |
|
13 | + * @author Brent Christensen |
|
14 | + * @since 4.6.31 |
|
15 | + * |
|
16 | + */ |
|
17 | 17 | abstract class EE_Object_Collection extends SplObjectStorage implements EEI_Collection { |
18 | 18 | |
19 | 19 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Class EE_Object_Collection |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @param mixed $info |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public function add( $object, $info = null ) { |
|
40 | + public function add($object, $info = null) { |
|
41 | 41 | $class = $this->interface; |
42 | - if ( ! $object instanceof $class ) { |
|
42 | + if ( ! $object instanceof $class) { |
|
43 | 43 | return false; |
44 | 44 | } |
45 | - $this->attach( $object ); |
|
46 | - $this->set_info( $object, $info ); |
|
47 | - return $this->contains( $object ); |
|
45 | + $this->attach($object); |
|
46 | + $this->set_info($object, $info); |
|
47 | + return $this->contains($object); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param mixed $info |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function set_info( $object, $info = null ) { |
|
64 | - $info = ! empty( $info ) ? $info : spl_object_hash( $object ); |
|
63 | + public function set_info($object, $info = null) { |
|
64 | + $info = ! empty($info) ? $info : spl_object_hash($object); |
|
65 | 65 | $this->rewind(); |
66 | - while ( $this->valid() ) { |
|
67 | - if ( $object == $this->current() ) { |
|
68 | - $this->setInfo( $info ); |
|
66 | + while ($this->valid()) { |
|
67 | + if ($object == $this->current()) { |
|
68 | + $this->setInfo($info); |
|
69 | 69 | $this->rewind(); |
70 | 70 | return true; |
71 | 71 | } |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | * @param mixed |
87 | 87 | * @return null | object |
88 | 88 | */ |
89 | - public function get_by_info( $info ) { |
|
89 | + public function get_by_info($info) { |
|
90 | 90 | $this->rewind(); |
91 | - while ( $this->valid() ) { |
|
92 | - if ( $info === $this->getInfo() ) { |
|
91 | + while ($this->valid()) { |
|
92 | + if ($info === $this->getInfo()) { |
|
93 | 93 | $object = $this->current(); |
94 | 94 | $this->rewind(); |
95 | 95 | return $object; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param object $object |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public function has( $object ) { |
|
114 | - return $this->contains( $object ); |
|
113 | + public function has($object) { |
|
114 | + return $this->contains($object); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param $object |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - public function remove( $object ) { |
|
129 | - $this->detach( $object ); |
|
128 | + public function remove($object) { |
|
129 | + $this->detach($object); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @param $object |
141 | 141 | * @return void |
142 | 142 | */ |
143 | - public function set_current( $object ) { |
|
143 | + public function set_current($object) { |
|
144 | 144 | $this->rewind(); |
145 | - while ( $this->valid() ) { |
|
146 | - if ( $this->current() === $object ) { |
|
145 | + while ($this->valid()) { |
|
146 | + if ($this->current() === $object) { |
|
147 | 147 | break; |
148 | 148 | } |
149 | 149 | $this->next(); |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | * @param $info |
162 | 162 | * @return void |
163 | 163 | */ |
164 | - public function set_current_by_info( $info ) { |
|
164 | + public function set_current_by_info($info) { |
|
165 | 165 | $this->rewind(); |
166 | - while ( $this->valid() ) { |
|
167 | - if ( $info === $this->getInfo() ) { |
|
166 | + while ($this->valid()) { |
|
167 | + if ($info === $this->getInfo()) { |
|
168 | 168 | break; |
169 | 169 | } |
170 | 170 | $this->next(); |
@@ -2,19 +2,19 @@ |
||
2 | 2 | exit( 'No direct script access allowed' ); |
3 | 3 | } |
4 | 4 | /** |
5 | - * Class EE_Object_Repository |
|
6 | - * |
|
7 | - * abstract storage entity for unique objects with persistence |
|
8 | - * extends EE_Object_Collection... |
|
9 | - * which extends SplObjectStorage, so therefore implements the |
|
10 | - * Countable, Iterator, Serializable, and ArrayAccess interfaces |
|
11 | - * |
|
12 | - * @package Event Espresso |
|
13 | - * @subpackage core |
|
14 | - * @author Brent Christensen |
|
15 | - * @since 4.6.31 |
|
16 | - * |
|
17 | - */ |
|
5 | + * Class EE_Object_Repository |
|
6 | + * |
|
7 | + * abstract storage entity for unique objects with persistence |
|
8 | + * extends EE_Object_Collection... |
|
9 | + * which extends SplObjectStorage, so therefore implements the |
|
10 | + * Countable, Iterator, Serializable, and ArrayAccess interfaces |
|
11 | + * |
|
12 | + * @package Event Espresso |
|
13 | + * @subpackage core |
|
14 | + * @author Brent Christensen |
|
15 | + * @since 4.6.31 |
|
16 | + * |
|
17 | + */ |
|
18 | 18 | abstract class EE_Object_Repository extends EE_Object_Collection implements EEI_Repository { |
19 | 19 | |
20 | 20 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Class EE_Object_Repository |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * @param array $arguments arrays of arguments that will be passed to the object's callback method |
39 | 39 | * @return bool | int |
40 | 40 | */ |
41 | - protected function _call_user_func_array_on_current( $callback = '', $arguments = array() ) { |
|
42 | - if ( $callback !== '' && method_exists( $this->current(), $callback ) ) { |
|
43 | - return call_user_func_array( array( $this->current(), $callback ), $arguments ); |
|
41 | + protected function _call_user_func_array_on_current($callback = '', $arguments = array()) { |
|
42 | + if ($callback !== '' && method_exists($this->current(), $callback)) { |
|
43 | + return call_user_func_array(array($this->current(), $callback), $arguments); |
|
44 | 44 | } |
45 | 45 | return false; |
46 | 46 | } |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param string $callback name of method found on repository objects to be called |
57 | 57 | * @return bool | int |
58 | 58 | */ |
59 | - protected function _call_user_func_on_all( $callback = '' ) { |
|
59 | + protected function _call_user_func_on_all($callback = '') { |
|
60 | 60 | $success = true; |
61 | - if ( $this->valid() ) { |
|
61 | + if ($this->valid()) { |
|
62 | 62 | $this->rewind(); |
63 | - while ( $this->valid() ) { |
|
63 | + while ($this->valid()) { |
|
64 | 64 | // any negative result will toggle success to false |
65 | - $success = $this->_call_user_func_array_on_current( $callback ) ? $success : false; |
|
65 | + $success = $this->_call_user_func_array_on_current($callback) ? $success : false; |
|
66 | 66 | $this->next(); |
67 | 67 | } |
68 | 68 | $this->rewind(); |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param array $persistence_arguments arrays of arguments that will be passed to the object's persistence method |
87 | 87 | * @return bool | int |
88 | 88 | */ |
89 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ) { |
|
90 | - $persistence_callback = ! empty( $persistence_callback ) ? $persistence_callback : $this->persist_method; |
|
91 | - return $this->_call_user_func_array_on_current( $persistence_callback, $persistence_arguments ); |
|
89 | + public function persist($persistence_callback = '', $persistence_arguments = array()) { |
|
90 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
91 | + return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param string $persistence_callback name of method found on object that can be used for persisting the object |
103 | 103 | * @return bool | int |
104 | 104 | */ |
105 | - public function persist_all( $persistence_callback = '' ) { |
|
106 | - $persistence_callback = ! empty( $persistence_callback ) ? $persistence_callback : $this->persist_method; |
|
107 | - return $this->_call_user_func_on_all( $persistence_callback ); |
|
105 | + public function persist_all($persistence_callback = '') { |
|
106 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
107 | + return $this->_call_user_func_on_all($persistence_callback); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | /** |
34 | 34 | * This property is used to hold an array of EE_default_term objects assigned to a custom post type when the post for that post type is published with no terms set for the taxonomy. |
35 | - * |
|
35 | + * |
|
36 | 36 | * @var array of EE_Default_Term objects |
37 | 37 | */ |
38 | 38 | protected $_default_terms = array(); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -53,8 +55,9 @@ discard block |
||
53 | 55 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
54 | 56 | |
55 | 57 | //wp have no MONTH_IN_SECONDS constant. So we approximate our own assuming all months are 4 weeks long. |
56 | - if ( !defined('MONTH_IN_SECONDS' ) ) |
|
57 | - define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
58 | + if ( !defined('MONTH_IN_SECONDS' ) ) { |
|
59 | + define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
60 | + } |
|
58 | 61 | |
59 | 62 | if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){ |
60 | 63 | $this->_uxip_hooks(); |
@@ -101,42 +104,51 @@ discard block |
||
101 | 104 | |
102 | 105 | //what is the current active theme? |
103 | 106 | $active_theme = get_option('uxip_ee_active_theme'); |
104 | - if ( !empty( $active_theme ) ) |
|
105 | - $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
107 | + if ( !empty( $active_theme ) ) { |
|
108 | + $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
109 | + } |
|
106 | 110 | |
107 | 111 | //event info regarding an all event count and all "active" event count |
108 | 112 | $all_events_count = get_option('uxip_ee4_all_events_count'); |
109 | - if ( !empty( $all_events_count ) ) |
|
110 | - $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
113 | + if ( !empty( $all_events_count ) ) { |
|
114 | + $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
115 | + } |
|
111 | 116 | $active_events_count = get_option('uxip_ee4_active_events_count'); |
112 | - if ( !empty( $active_events_count ) ) |
|
113 | - $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
117 | + if ( !empty( $active_events_count ) ) { |
|
118 | + $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
119 | + } |
|
114 | 120 | |
115 | 121 | //datetime stuff |
116 | 122 | $dtt_count = get_option('uxip_ee_all_dtts_count'); |
117 | - if ( !empty( $dtt_count ) ) |
|
118 | - $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
123 | + if ( !empty( $dtt_count ) ) { |
|
124 | + $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
125 | + } |
|
119 | 126 | |
120 | 127 | $dtt_sold = get_option('uxip_ee_dtt_sold'); |
121 | - if ( !empty( $dtt_sold ) ) |
|
122 | - $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
128 | + if ( !empty( $dtt_sold ) ) { |
|
129 | + $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
130 | + } |
|
123 | 131 | |
124 | 132 | //ticket stuff |
125 | 133 | $all_tkt_count = get_option('uxip_ee_all_tkt_count'); |
126 | - if ( !empty( $all_tkt_count ) ) |
|
127 | - $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
134 | + if ( !empty( $all_tkt_count ) ) { |
|
135 | + $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
136 | + } |
|
128 | 137 | |
129 | 138 | $free_tkt_count = get_option('uxip_ee_free_tkt_count'); |
130 | - if ( !empty( $free_tkt_count ) ) |
|
131 | - $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
139 | + if ( !empty( $free_tkt_count ) ) { |
|
140 | + $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
141 | + } |
|
132 | 142 | |
133 | 143 | $paid_tkt_count = get_option('uxip_ee_paid_tkt_count'); |
134 | - if ( !empty( $paid_tkt_count ) ) |
|
135 | - $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
144 | + if ( !empty( $paid_tkt_count ) ) { |
|
145 | + $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
146 | + } |
|
136 | 147 | |
137 | 148 | $tkt_sold = get_option('uxip_ee_tkt_sold' ); |
138 | - if ( !empty($tkt_sold) ) |
|
139 | - $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
149 | + if ( !empty($tkt_sold) ) { |
|
150 | + $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
151 | + } |
|
140 | 152 | |
141 | 153 | //phpversion checking |
142 | 154 | $extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown'; |
@@ -209,7 +221,9 @@ discard block |
||
209 | 221 | |
210 | 222 | function espresso_data_collection_optin_notice() { |
211 | 223 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
212 | - if ( $ueip_has_notified ) return; |
|
224 | + if ( $ueip_has_notified ) { |
|
225 | + return; |
|
226 | + } |
|
213 | 227 | $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
214 | 228 | $settings_url = $settings_url . '#UXIP_settings'; |
215 | 229 | ?> |
@@ -249,7 +263,9 @@ discard block |
||
249 | 263 | function espresso_data_optin_ajax_handler() { |
250 | 264 | |
251 | 265 | //verify nonce |
252 | - if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit(); |
|
266 | + if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) { |
|
267 | + exit(); |
|
268 | + } |
|
253 | 269 | |
254 | 270 | //made it here so let's save the selection |
255 | 271 | $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no'; |
@@ -279,13 +295,15 @@ discard block |
||
279 | 295 | $current = get_site_transient( 'update_plugins' ); |
280 | 296 | |
281 | 297 | foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
282 | - if ( isset( $current->response['plugin_file'] ) ) |
|
283 | - $update = true; |
|
298 | + if ( isset( $current->response['plugin_file'] ) ) { |
|
299 | + $update = true; |
|
300 | + } |
|
284 | 301 | } |
285 | 302 | |
286 | 303 | //it's possible that there is an update but an invalid site-license-key is in use |
287 | - if ( get_site_option('pue_json_error_' . $basename ) ) |
|
288 | - $update = true; |
|
304 | + if ( get_site_option('pue_json_error_' . $basename ) ) { |
|
305 | + $update = true; |
|
306 | + } |
|
289 | 307 | |
290 | 308 | return $update; |
291 | 309 | } |
@@ -329,46 +347,54 @@ discard block |
||
329 | 347 | $DTT = EE_Registry::instance()->load_model('Datetime'); |
330 | 348 | $TKT = EE_Registry::instance()->load_model('Ticket'); |
331 | 349 | $count = $EVT->count(); |
332 | - if ( $count > 0 ) |
|
333 | - update_option('uxip_ee4_all_events_count', $count); |
|
350 | + if ( $count > 0 ) { |
|
351 | + update_option('uxip_ee4_all_events_count', $count); |
|
352 | + } |
|
334 | 353 | |
335 | 354 | //next let's just get the number of ACTIVE events |
336 | 355 | $count_active = $EVT->get_active_events(array(), TRUE); |
337 | - if ( $count_active > 0 ) |
|
338 | - update_option('uxip_ee4_active_events_count', $count_active); |
|
356 | + if ( $count_active > 0 ) { |
|
357 | + update_option('uxip_ee4_active_events_count', $count_active); |
|
358 | + } |
|
339 | 359 | |
340 | 360 | //datetimes! |
341 | 361 | $dtt_count = $DTT->count(); |
342 | - if ( $dtt_count > 0 ) |
|
343 | - update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
362 | + if ( $dtt_count > 0 ) { |
|
363 | + update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
364 | + } |
|
344 | 365 | |
345 | 366 | |
346 | 367 | //dttsold |
347 | 368 | $dtt_sold = $DTT->sum(array(), 'DTT_sold'); |
348 | - if ( $dtt_sold > 0 ) |
|
349 | - update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
369 | + if ( $dtt_sold > 0 ) { |
|
370 | + update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
371 | + } |
|
350 | 372 | |
351 | 373 | //allticketcount |
352 | 374 | $all_tkt_count = $TKT->count(); |
353 | - if ( $all_tkt_count > 0 ) |
|
354 | - update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
375 | + if ( $all_tkt_count > 0 ) { |
|
376 | + update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
377 | + } |
|
355 | 378 | |
356 | 379 | //freetktcount |
357 | 380 | $_where = array( 'TKT_price' => 0 ); |
358 | 381 | $free_tkt_count = $TKT->count(array($_where)); |
359 | - if ( $free_tkt_count > 0 ) |
|
360 | - update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
382 | + if ( $free_tkt_count > 0 ) { |
|
383 | + update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
384 | + } |
|
361 | 385 | |
362 | 386 | //paidtktcount |
363 | 387 | $_where = array( 'TKT_price' => array('>', 0) ); |
364 | 388 | $paid_tkt_count = $TKT->count( array( $_where ) ); |
365 | - if ( $paid_tkt_count > 0 ) |
|
366 | - update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
389 | + if ( $paid_tkt_count > 0 ) { |
|
390 | + update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
391 | + } |
|
367 | 392 | |
368 | 393 | //tktsold |
369 | 394 | $tkt_sold = $TKT->sum( array(), 'TKT_sold' ); |
370 | - if( $tkt_sold > 0 ) |
|
371 | - update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
395 | + if( $tkt_sold > 0 ) { |
|
396 | + update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
397 | + } |
|
372 | 398 | |
373 | 399 | |
374 | 400 | set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 ); |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | public function __construct() { |
50 | 50 | // throw new EE_Error('error'); |
51 | 51 | |
52 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
|
52 | + do_action('AHEE_log', __CLASS__, __FUNCTION__); |
|
53 | 53 | |
54 | 54 | //wp have no MONTH_IN_SECONDS constant. So we approximate our own assuming all months are 4 weeks long. |
55 | - if ( !defined('MONTH_IN_SECONDS' ) ) |
|
56 | - define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
55 | + if ( ! defined('MONTH_IN_SECONDS')) |
|
56 | + define('MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4); |
|
57 | 57 | |
58 | - if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){ |
|
58 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
59 | 59 | $this->_uxip_hooks(); |
60 | 60 | } |
61 | 61 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
65 | 65 | |
66 | 66 | //has optin been selected for data collection? |
67 | - $espresso_data_optin = !empty($ueip_optin) ? $ueip_optin : NULL; |
|
67 | + $espresso_data_optin = ! empty($ueip_optin) ? $ueip_optin : NULL; |
|
68 | 68 | |
69 | - if ( empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_mode::level_2_complete_maintenance ) { |
|
70 | - add_action('admin_notices', array( $this, 'espresso_data_collection_optin_notice' ), 10 ); |
|
71 | - add_action('admin_enqueue_scripts', array( $this, 'espresso_data_collection_enqueue_scripts' ), 10 ); |
|
72 | - add_action('wp_ajax_espresso_data_optin', array( $this, 'espresso_data_optin_ajax_handler' ), 10 ); |
|
69 | + if (empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_mode::level_2_complete_maintenance) { |
|
70 | + add_action('admin_notices', array($this, 'espresso_data_collection_optin_notice'), 10); |
|
71 | + add_action('admin_enqueue_scripts', array($this, 'espresso_data_collection_enqueue_scripts'), 10); |
|
72 | + add_action('wp_ajax_espresso_data_optin', array($this, 'espresso_data_optin_ajax_handler'), 10); |
|
73 | 73 | update_option('ee_ueip_optin', 'yes'); |
74 | 74 | $espresso_data_optin = 'yes'; |
75 | 75 | } |
@@ -78,80 +78,80 @@ discard block |
||
78 | 78 | $extra_stats = array(); |
79 | 79 | |
80 | 80 | //only collect extra stats if the plugin user has opted in. |
81 | - if ( !empty($espresso_data_optin) && $espresso_data_optin == 'yes' ) { |
|
81 | + if ( ! empty($espresso_data_optin) && $espresso_data_optin == 'yes') { |
|
82 | 82 | //let's only setup extra data if transient has expired |
83 | - if ( false === ( $transient = get_transient('ee_extra_data') ) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
83 | + if (false === ($transient = get_transient('ee_extra_data')) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
84 | 84 | |
85 | 85 | $current_site = is_multisite() ? get_current_site() : NULL; |
86 | - $site_pre = ! is_main_site() && ! empty($current_site) ? trim( preg_replace('/\b\w\S\w\b/', '', $current_site->domain ), '.' ) . '_' : ''; |
|
86 | + $site_pre = ! is_main_site() && ! empty($current_site) ? trim(preg_replace('/\b\w\S\w\b/', '', $current_site->domain), '.').'_' : ''; |
|
87 | 87 | |
88 | 88 | |
89 | 89 | //active gateways |
90 | 90 | $active_gateways = get_option('event_espresso_active_gateways'); |
91 | - if ( !empty($active_gateways ) ) { |
|
92 | - foreach ( (array) $active_gateways as $gateway => $ignore ) { |
|
93 | - $extra_stats[$site_pre . $gateway . '_gateway_active'] = 1; |
|
91 | + if ( ! empty($active_gateways)) { |
|
92 | + foreach ((array) $active_gateways as $gateway => $ignore) { |
|
93 | + $extra_stats[$site_pre.$gateway.'_gateway_active'] = 1; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - if ( is_multisite() && is_main_site() ) { |
|
97 | + if (is_multisite() && is_main_site()) { |
|
98 | 98 | $extra_stats['is_multisite'] = true; |
99 | 99 | } |
100 | 100 | |
101 | 101 | //what is the current active theme? |
102 | 102 | $active_theme = get_option('uxip_ee_active_theme'); |
103 | - if ( !empty( $active_theme ) ) |
|
104 | - $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
103 | + if ( ! empty($active_theme)) |
|
104 | + $extra_stats[$site_pre.'active_theme'] = $active_theme; |
|
105 | 105 | |
106 | 106 | //event info regarding an all event count and all "active" event count |
107 | 107 | $all_events_count = get_option('uxip_ee4_all_events_count'); |
108 | - if ( !empty( $all_events_count ) ) |
|
109 | - $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
108 | + if ( ! empty($all_events_count)) |
|
109 | + $extra_stats[$site_pre.'ee4_all_events_count'] = $all_events_count; |
|
110 | 110 | $active_events_count = get_option('uxip_ee4_active_events_count'); |
111 | - if ( !empty( $active_events_count ) ) |
|
112 | - $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
111 | + if ( ! empty($active_events_count)) |
|
112 | + $extra_stats[$site_pre.'ee4_active_events_count'] = $active_events_count; |
|
113 | 113 | |
114 | 114 | //datetime stuff |
115 | 115 | $dtt_count = get_option('uxip_ee_all_dtts_count'); |
116 | - if ( !empty( $dtt_count ) ) |
|
117 | - $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
116 | + if ( ! empty($dtt_count)) |
|
117 | + $extra_stats[$site_pre.'all_dtts_count'] = $dtt_count; |
|
118 | 118 | |
119 | 119 | $dtt_sold = get_option('uxip_ee_dtt_sold'); |
120 | - if ( !empty( $dtt_sold ) ) |
|
121 | - $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
120 | + if ( ! empty($dtt_sold)) |
|
121 | + $extra_stats[$site_pre.'dtt_sold'] = $dtt_sold; |
|
122 | 122 | |
123 | 123 | //ticket stuff |
124 | 124 | $all_tkt_count = get_option('uxip_ee_all_tkt_count'); |
125 | - if ( !empty( $all_tkt_count ) ) |
|
126 | - $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
125 | + if ( ! empty($all_tkt_count)) |
|
126 | + $extra_stats[$site_pre.'all_tkt_count'] = $all_tkt_count; |
|
127 | 127 | |
128 | 128 | $free_tkt_count = get_option('uxip_ee_free_tkt_count'); |
129 | - if ( !empty( $free_tkt_count ) ) |
|
130 | - $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
129 | + if ( ! empty($free_tkt_count)) |
|
130 | + $extra_stats[$site_pre.'free_tkt_count'] = $free_tkt_count; |
|
131 | 131 | |
132 | 132 | $paid_tkt_count = get_option('uxip_ee_paid_tkt_count'); |
133 | - if ( !empty( $paid_tkt_count ) ) |
|
134 | - $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
133 | + if ( ! empty($paid_tkt_count)) |
|
134 | + $extra_stats[$site_pre.'paid_tkt_count'] = $paid_tkt_count; |
|
135 | 135 | |
136 | - $tkt_sold = get_option('uxip_ee_tkt_sold' ); |
|
137 | - if ( !empty($tkt_sold) ) |
|
138 | - $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
136 | + $tkt_sold = get_option('uxip_ee_tkt_sold'); |
|
137 | + if ( ! empty($tkt_sold)) |
|
138 | + $extra_stats[$site_pre.'tkt_sold'] = $tkt_sold; |
|
139 | 139 | |
140 | 140 | //phpversion checking |
141 | 141 | $extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown'; |
142 | 142 | |
143 | 143 | //set transient |
144 | - set_transient( 'ee_extra_data', $extra_stats, WEEK_IN_SECONDS ); |
|
144 | + set_transient('ee_extra_data', $extra_stats, WEEK_IN_SECONDS); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | |
149 | 149 | |
150 | 150 | // PUE Auto Upgrades stuff |
151 | - if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file |
|
152 | - require_once(EE_THIRD_PARTY . 'pue/pue-client.php' ); |
|
151 | + if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { //include the file |
|
152 | + require_once(EE_THIRD_PARTY.'pue/pue-client.php'); |
|
153 | 153 | |
154 | - $api_key = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->site_license_key : ''; |
|
154 | + $api_key = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->site_license_key : ''; |
|
155 | 155 | $host_server_url = 'http://eventespresso.com'; //this needs to be the host server where plugin update engine is installed. Note, if you leave this blank then it is assumed the WordPress repo will be used and we'll just check there. |
156 | 156 | |
157 | 157 | //Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. So it's important that you use a key for the version type that is unique and not found in another key. |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | //$plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
164 | 164 | //..WOULD work! |
165 | 165 | $plugin_slug = array( |
166 | - 'free' => array( 'decaf' => 'event-espresso-core-decaf' ), |
|
167 | - 'premium' => array( 'p' => 'event-espresso-core-reg' ), |
|
168 | - 'prerelease' => array( 'beta' => 'event-espresso-core-pr' ) |
|
166 | + 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
167 | + 'premium' => array('p' => 'event-espresso-core-reg'), |
|
168 | + 'prerelease' => array('beta' => 'event-espresso-core-pr') |
|
169 | 169 | ); |
170 | 170 | |
171 | 171 | |
@@ -192,14 +192,14 @@ discard block |
||
192 | 192 | * The purpose of this function is to display information about Event Espresso data collection and a optin selection for extra data collecting by users. |
193 | 193 | * @return string html. |
194 | 194 | */ |
195 | - public static function espresso_data_collection_optin_text( $extra = TRUE ) { |
|
196 | - if ( ! $extra ) { |
|
197 | - echo '<h2 class="ee-admin-settings-hdr" '. (!$extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>'; |
|
198 | - echo sprintf( __('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>','<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">','</a>','<br><br>','<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">','</a>' ); |
|
195 | + public static function espresso_data_collection_optin_text($extra = TRUE) { |
|
196 | + if ( ! $extra) { |
|
197 | + echo '<h2 class="ee-admin-settings-hdr" '.( ! $extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>'; |
|
198 | + echo sprintf(__('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>', '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<br><br>', '<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">', '</a>'); |
|
199 | 199 | } else { |
200 | - $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
|
200 | + $settings_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), admin_url('admin.php?page=espresso_general_settings')); |
|
201 | 201 | $settings_url .= '#UXIP_settings'; |
202 | - echo sprintf( __( 'The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso' ), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" traget="_blank">', '</a>', '<a href="' . $settings_url . '" target="_blank">', '</a>' ); |
|
202 | + echo sprintf(__('The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso'), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" traget="_blank">', '</a>', '<a href="'.$settings_url.'" target="_blank">', '</a>'); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | |
209 | 209 | function espresso_data_collection_optin_notice() { |
210 | 210 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
211 | - if ( $ueip_has_notified ) return; |
|
212 | - $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
|
213 | - $settings_url = $settings_url . '#UXIP_settings'; |
|
211 | + if ($ueip_has_notified) return; |
|
212 | + $settings_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), admin_url('admin.php?page=espresso_general_settings')); |
|
213 | + $settings_url = $settings_url.'#UXIP_settings'; |
|
214 | 214 | ?> |
215 | 215 | <div class="updated data-collect-optin" id="espresso-data-collect-optin-container"> |
216 | 216 | <div id="data-collect-optin-options-container"> |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @return void |
233 | 233 | */ |
234 | 234 | function espresso_data_collection_enqueue_scripts() { |
235 | - wp_register_script( 'ee-data-optin-js', EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
236 | - wp_register_style( 'ee-data-optin-css', EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
235 | + wp_register_script('ee-data-optin-js', EE_GLOBAL_ASSETS_URL.'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
236 | + wp_register_style('ee-data-optin-css', EE_GLOBAL_ASSETS_URL.'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION); |
|
237 | 237 | |
238 | 238 | wp_enqueue_script('ee-data-optin-js'); |
239 | 239 | wp_enqueue_style('ee-data-optin-css'); |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | function espresso_data_optin_ajax_handler() { |
249 | 249 | |
250 | 250 | //verify nonce |
251 | - if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit(); |
|
251 | + if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) exit(); |
|
252 | 252 | |
253 | 253 | //made it here so let's save the selection |
254 | - $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no'; |
|
254 | + $ueip_optin = isset($_POST['selection']) ? $_POST['selection'] : 'no'; |
|
255 | 255 | |
256 | 256 | //update_option('ee_ueip_optin', $ueip_optin); |
257 | 257 | EE_Registry::instance()->CFG->core->ee_ueip_has_notified = 1; |
258 | - EE_Registry::instance()->CFG->update_espresso_config( FALSE, FALSE ); |
|
258 | + EE_Registry::instance()->CFG->update_espresso_config(FALSE, FALSE); |
|
259 | 259 | exit(); |
260 | 260 | } |
261 | 261 | |
@@ -268,22 +268,22 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public static function is_update_available($basename = '') { |
270 | 270 | |
271 | - $basename = ! empty( $basename ) ? $basename : EE_PLUGIN_BASENAME; |
|
271 | + $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME; |
|
272 | 272 | |
273 | 273 | $update = false; |
274 | 274 | |
275 | - $folder = DS . dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
275 | + $folder = DS.dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core" |
|
276 | 276 | |
277 | 277 | $plugins = get_plugins($folder); |
278 | - $current = get_site_transient( 'update_plugins' ); |
|
278 | + $current = get_site_transient('update_plugins'); |
|
279 | 279 | |
280 | - foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
|
281 | - if ( isset( $current->response['plugin_file'] ) ) |
|
280 | + foreach ((array) $plugins as $plugin_file => $plugin_data) { |
|
281 | + if (isset($current->response['plugin_file'])) |
|
282 | 282 | $update = true; |
283 | 283 | } |
284 | 284 | |
285 | 285 | //it's possible that there is an update but an invalid site-license-key is in use |
286 | - if ( get_site_option('pue_json_error_' . $basename ) ) |
|
286 | + if (get_site_option('pue_json_error_'.$basename)) |
|
287 | 287 | $update = true; |
288 | 288 | |
289 | 289 | return $update; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * @return void |
302 | 302 | */ |
303 | 303 | public function _uxip_hooks() { |
304 | - if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
305 | - add_action('admin_init', array( $this, 'track_active_theme' ) ); |
|
306 | - add_action('admin_init', array( $this, 'track_event_info' ) ); |
|
304 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
305 | + add_action('admin_init', array($this, 'track_active_theme')); |
|
306 | + add_action('admin_init', array($this, 'track_event_info')); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
@@ -312,65 +312,65 @@ discard block |
||
312 | 312 | |
313 | 313 | public function track_active_theme() { |
314 | 314 | //we only check this once a month. |
315 | - if ( false === ( $transient = get_transient( 'ee_active_theme_check' ) ) ) { |
|
315 | + if (false === ($transient = get_transient('ee_active_theme_check'))) { |
|
316 | 316 | $theme = wp_get_theme(); |
317 | - update_option('uxip_ee_active_theme', $theme->get('Name') ); |
|
318 | - set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS ); |
|
317 | + update_option('uxip_ee_active_theme', $theme->get('Name')); |
|
318 | + set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
322 | 322 | |
323 | 323 | public function track_event_info() { |
324 | 324 | //we only check this once every couple weeks. |
325 | - if ( false === ( $transient = get_transient( 'ee4_event_info_check') ) ) { |
|
325 | + if (false === ($transient = get_transient('ee4_event_info_check'))) { |
|
326 | 326 | //first let's get the number for ALL events |
327 | 327 | $EVT = EE_Registry::instance()->load_model('Event'); |
328 | 328 | $DTT = EE_Registry::instance()->load_model('Datetime'); |
329 | 329 | $TKT = EE_Registry::instance()->load_model('Ticket'); |
330 | 330 | $count = $EVT->count(); |
331 | - if ( $count > 0 ) |
|
331 | + if ($count > 0) |
|
332 | 332 | update_option('uxip_ee4_all_events_count', $count); |
333 | 333 | |
334 | 334 | //next let's just get the number of ACTIVE events |
335 | 335 | $count_active = $EVT->get_active_events(array(), TRUE); |
336 | - if ( $count_active > 0 ) |
|
336 | + if ($count_active > 0) |
|
337 | 337 | update_option('uxip_ee4_active_events_count', $count_active); |
338 | 338 | |
339 | 339 | //datetimes! |
340 | 340 | $dtt_count = $DTT->count(); |
341 | - if ( $dtt_count > 0 ) |
|
342 | - update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
341 | + if ($dtt_count > 0) |
|
342 | + update_option('uxip_ee_all_dtts_count', $dtt_count); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | //dttsold |
346 | 346 | $dtt_sold = $DTT->sum(array(), 'DTT_sold'); |
347 | - if ( $dtt_sold > 0 ) |
|
348 | - update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
347 | + if ($dtt_sold > 0) |
|
348 | + update_option('uxip_ee_dtt_sold', $dtt_sold); |
|
349 | 349 | |
350 | 350 | //allticketcount |
351 | 351 | $all_tkt_count = $TKT->count(); |
352 | - if ( $all_tkt_count > 0 ) |
|
353 | - update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
352 | + if ($all_tkt_count > 0) |
|
353 | + update_option('uxip_ee_all_tkt_count', $all_tkt_count); |
|
354 | 354 | |
355 | 355 | //freetktcount |
356 | - $_where = array( 'TKT_price' => 0 ); |
|
356 | + $_where = array('TKT_price' => 0); |
|
357 | 357 | $free_tkt_count = $TKT->count(array($_where)); |
358 | - if ( $free_tkt_count > 0 ) |
|
359 | - update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
358 | + if ($free_tkt_count > 0) |
|
359 | + update_option('uxip_ee_free_tkt_count', $free_tkt_count); |
|
360 | 360 | |
361 | 361 | //paidtktcount |
362 | - $_where = array( 'TKT_price' => array('>', 0) ); |
|
363 | - $paid_tkt_count = $TKT->count( array( $_where ) ); |
|
364 | - if ( $paid_tkt_count > 0 ) |
|
365 | - update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
362 | + $_where = array('TKT_price' => array('>', 0)); |
|
363 | + $paid_tkt_count = $TKT->count(array($_where)); |
|
364 | + if ($paid_tkt_count > 0) |
|
365 | + update_option('uxip_ee_paid_tkt_count', $paid_tkt_count); |
|
366 | 366 | |
367 | 367 | //tktsold |
368 | - $tkt_sold = $TKT->sum( array(), 'TKT_sold' ); |
|
369 | - if( $tkt_sold > 0 ) |
|
370 | - update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
368 | + $tkt_sold = $TKT->sum(array(), 'TKT_sold'); |
|
369 | + if ($tkt_sold > 0) |
|
370 | + update_option('uxip_ee_tkt_sold', $tkt_sold); |
|
371 | 371 | |
372 | 372 | |
373 | - set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 ); |
|
373 | + set_transient('ee4_event_info_check', 1, WEEK_IN_SECONDS * 2); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | */ |
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance = NULL; |
20 | 20 | |
21 | 21 | |
@@ -48,9 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | - |
|
52 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
53 | - * Saves the payment that is generated |
|
52 | + * Saves the payment that is generated |
|
54 | 53 | * |
55 | 54 | * @param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | EE_Processor_Base::set_IPN( $separate_IPN_request ); |
149 | 149 | if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){ |
150 | 150 | $obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) ); |
151 | - }elseif( $payment_method instanceof EE_Payment ){ |
|
151 | + } elseif( $payment_method instanceof EE_Payment ){ |
|
152 | 152 | $obj_for_log = $payment_method; |
153 | - }elseif( $transaction instanceof EE_Transaction ){ |
|
153 | + } elseif( $transaction instanceof EE_Transaction ){ |
|
154 | 154 | $obj_for_log = $transaction; |
155 | - }else{ |
|
155 | + } else{ |
|
156 | 156 | $obj_for_log = null; |
157 | 157 | } |
158 | 158 | $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | __FILE__, __FUNCTION__, __LINE__ |
181 | 181 | ); |
182 | 182 | } |
183 | - }else{ |
|
183 | + } else{ |
|
184 | 184 | //that's actually pretty ok. The IPN just wasn't able |
185 | 185 | //to identify which transaction or payment method this was for |
186 | 186 | // give all active payment methods a chance to claim it |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | $payment->save(); |
202 | 202 | // update the TXN |
203 | 203 | $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
204 | - }else{ |
|
204 | + } else{ |
|
205 | 205 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
206 | 206 | if($payment_method){ |
207 | 207 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
208 | - }elseif($transaction){ |
|
208 | + } elseif($transaction){ |
|
209 | 209 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
210 | 210 | } |
211 | 211 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | foreach( $request_data as $key => $value ) { |
237 | 237 | $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
238 | 238 | } |
239 | - }else{ |
|
239 | + } else{ |
|
240 | 240 | $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
241 | 241 | } |
242 | 242 | return $return_data; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,42 +64,42 @@ discard block |
||
64 | 64 | * @param string $cancel_url URL to return to if off-site payments are cancelled |
65 | 65 | * @return EE_Payment |
66 | 66 | */ |
67 | - public function process_payment( EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '' ) { |
|
68 | - if( $amount < 0 ) { |
|
67 | + public function process_payment(EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '') { |
|
68 | + if ($amount < 0) { |
|
69 | 69 | throw new EE_Error( |
70 | 70 | sprintf( |
71 | - __( 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso' ), |
|
71 | + __('Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso'), |
|
72 | 72 | $amount, |
73 | 73 | $transaction->ID() ) ); |
74 | 74 | } |
75 | 75 | // verify payment method |
76 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
76 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
77 | 77 | // verify transaction |
78 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
79 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
78 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
79 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
80 | 80 | // verify payment method type |
81 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ){ |
|
81 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
82 | 82 | $payment = $payment_method->type_obj()->process_payment( |
83 | 83 | $transaction, |
84 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
84 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
85 | 85 | $billing_form, |
86 | 86 | $return_url, |
87 | - add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
87 | + add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
88 | 88 | $method, |
89 | 89 | $by_admin |
90 | 90 | ); |
91 | 91 | // check if payment method uses an off-site gateway |
92 | - if ( $payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite ) { |
|
92 | + if ($payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite) { |
|
93 | 93 | // don't process payments for off-site gateways yet because no payment has occurred yet |
94 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
94 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
95 | 95 | } |
96 | 96 | return $payment; |
97 | 97 | } else { |
98 | 98 | EE_Error::add_error( |
99 | 99 | sprintf( |
100 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
100 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
101 | 101 | '<br/>', |
102 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
102 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
103 | 103 | ), __FILE__, __FUNCTION__, __LINE__ |
104 | 104 | ); |
105 | 105 | return NULL; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @throws EE_Error |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
118 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
119 | 119 | /** @type EE_Transaction $transaction */ |
120 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
120 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
121 | 121 | $primary_reg = $transaction->primary_registration(); |
122 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
123 | - throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"),$transaction->ID())); |
|
122 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
123 | + throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"), $transaction->ID())); |
|
124 | 124 | } |
125 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
125 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
126 | 126 | $url = add_query_arg( |
127 | 127 | array( |
128 | 128 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -149,81 +149,81 @@ discard block |
||
149 | 149 | * @throws Exception |
150 | 150 | * @return EE_Payment |
151 | 151 | */ |
152 | - public function process_ipn( $_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true ){ |
|
153 | - $_req_data = $this->_remove_unusable_characters( $_req_data ); |
|
154 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
155 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
156 | - if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){ |
|
157 | - $obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) ); |
|
158 | - }elseif( $payment_method instanceof EE_Payment ){ |
|
152 | + public function process_ipn($_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true) { |
|
153 | + $_req_data = $this->_remove_unusable_characters($_req_data); |
|
154 | + EE_Registry::instance()->load_model('Change_Log'); |
|
155 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
156 | + if ($transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method) { |
|
157 | + $obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc'))); |
|
158 | + }elseif ($payment_method instanceof EE_Payment) { |
|
159 | 159 | $obj_for_log = $payment_method; |
160 | - }elseif( $transaction instanceof EE_Transaction ){ |
|
160 | + }elseif ($transaction instanceof EE_Transaction) { |
|
161 | 161 | $obj_for_log = $transaction; |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $obj_for_log = null; |
164 | 164 | } |
165 | 165 | $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log); |
166 | - try{ |
|
166 | + try { |
|
167 | 167 | /** |
168 | 168 | * @var EE_Payment $payment |
169 | 169 | */ |
170 | 170 | $payment = NULL; |
171 | - if($transaction && $payment_method){ |
|
171 | + if ($transaction && $payment_method) { |
|
172 | 172 | /** @type EE_Transaction $transaction */ |
173 | 173 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
174 | 174 | /** @type EE_Payment_Method $payment_method */ |
175 | 175 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
176 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
177 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
176 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
177 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
178 | 178 | $log->set_object($payment); |
179 | 179 | } else { |
180 | 180 | // not a payment |
181 | 181 | EE_Error::add_error( |
182 | 182 | sprintf( |
183 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
183 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
184 | 184 | '<br/>', |
185 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
185 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
186 | 186 | ), |
187 | 187 | __FILE__, __FUNCTION__, __LINE__ |
188 | 188 | ); |
189 | 189 | } |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | //that's actually pretty ok. The IPN just wasn't able |
192 | 192 | //to identify which transaction or payment method this was for |
193 | 193 | // give all active payment methods a chance to claim it |
194 | 194 | $active_pms = EEM_Payment_Method::instance()->get_all_active(); |
195 | - foreach( $active_pms as $payment_method ){ |
|
196 | - try{ |
|
197 | - $payment = $payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
195 | + foreach ($active_pms as $payment_method) { |
|
196 | + try { |
|
197 | + $payment = $payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
198 | 198 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment); |
199 | 199 | break; |
200 | - } catch( EE_Error $e ) { |
|
200 | + } catch (EE_Error $e) { |
|
201 | 201 | //that's fine- it apparently couldn't handle the IPN |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
206 | 206 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
207 | - if( $payment instanceof EE_Payment){ |
|
207 | + if ($payment instanceof EE_Payment) { |
|
208 | 208 | $payment->save(); |
209 | 209 | // update the TXN |
210 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
211 | - }else{ |
|
210 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
211 | + } else { |
|
212 | 212 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
213 | - if($payment_method){ |
|
213 | + if ($payment_method) { |
|
214 | 214 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
215 | - }elseif($transaction){ |
|
215 | + }elseif ($transaction) { |
|
216 | 216 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | return $payment; |
220 | 220 | |
221 | - } catch( EE_Error $e ) { |
|
221 | + } catch (EE_Error $e) { |
|
222 | 222 | do_action( |
223 | 223 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
224 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
225 | - print_r( $transaction, TRUE ), |
|
226 | - print_r( $_req_data, TRUE ), |
|
224 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
225 | + print_r($transaction, TRUE), |
|
226 | + print_r($_req_data, TRUE), |
|
227 | 227 | $e->getMessage() |
228 | 228 | ) |
229 | 229 | ); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * @param array $request_data |
238 | 238 | * @return array|string |
239 | 239 | */ |
240 | - protected function _remove_unusable_characters( $request_data ) { |
|
241 | - if( is_array( $request_data ) ) { |
|
240 | + protected function _remove_unusable_characters($request_data) { |
|
241 | + if (is_array($request_data)) { |
|
242 | 242 | $return_data = array(); |
243 | - foreach( $request_data as $key => $value ) { |
|
244 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
243 | + foreach ($request_data as $key => $value) { |
|
244 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
245 | 245 | } |
246 | - }else{ |
|
247 | - $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
246 | + } else { |
|
247 | + $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
248 | 248 | } |
249 | 249 | return $return_data; |
250 | 250 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | * @return EE_Payment |
267 | 267 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, to call handle_ipn() for offsite gateways that don't receive separate IPNs |
268 | 268 | */ |
269 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
269 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
270 | 270 | /** @var $transaction EE_Transaction */ |
271 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
271 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
272 | 272 | $last_payment_method = $transaction->payment_method(); |
273 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
274 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
275 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
273 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
274 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
275 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
276 | 276 | return $payment; |
277 | 277 | } else { |
278 | 278 | return NULL; |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @internal param float $amount |
290 | 290 | * @return EE_Payment |
291 | 291 | */ |
292 | - public function process_refund( EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array() ){ |
|
293 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
294 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
295 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
292 | + public function process_refund(EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array()) { |
|
293 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
294 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
295 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
296 | 296 | } |
297 | 297 | return $payment_to_refund; |
298 | 298 | } |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | * TXN is locked before updating |
335 | 335 | * @throws \EE_Error |
336 | 336 | */ |
337 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
337 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
338 | 338 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
339 | 339 | /** @type EE_Transaction $transaction */ |
340 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
340 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
341 | 341 | // can we freely update the TXN at this moment? |
342 | - if ( $IPN && $transaction->is_locked() ) { |
|
342 | + if ($IPN && $transaction->is_locked()) { |
|
343 | 343 | // don't update the transaction at this exact moment |
344 | 344 | // because the TXN is active in another request |
345 | 345 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -349,40 +349,40 @@ discard block |
||
349 | 349 | ); |
350 | 350 | } else { |
351 | 351 | // verify payment and that it has been saved |
352 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
353 | - if( $payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base ){ |
|
354 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
352 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
353 | + if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base) { |
|
354 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
355 | 355 | // update TXN registrations with payment info |
356 | - $this->process_registration_payments( $transaction, $payment ); |
|
356 | + $this->process_registration_payments($transaction, $payment); |
|
357 | 357 | } |
358 | 358 | $do_action = $payment->just_approved() ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' : $do_action; |
359 | 359 | } else { |
360 | 360 | // send out notifications |
361 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
361 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
362 | 362 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
363 | 363 | } |
364 | 364 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
365 | 365 | // so that we know whether the status has changed and notifications should be triggered |
366 | - if ( $IPN ) { |
|
366 | + if ($IPN) { |
|
367 | 367 | /** @type EE_Transaction_Processor $transaction_processor */ |
368 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
369 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
368 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
369 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
370 | 370 | } |
371 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
371 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
372 | 372 | /** @type EE_Transaction_Payments $transaction_payments */ |
373 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
373 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
374 | 374 | // set new value for total paid |
375 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
375 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
376 | 376 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
377 | - if ( $update_txn ) { |
|
378 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
377 | + if ($update_txn) { |
|
378 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | // granular hook for others to use. |
382 | - do_action( $do_action, $transaction, $payment ); |
|
383 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
382 | + do_action($do_action, $transaction, $payment); |
|
383 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
384 | 384 | //global hook for others to use. |
385 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
385 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
386 | 386 | } |
387 | 387 | } |
388 | 388 | |
@@ -396,25 +396,25 @@ discard block |
||
396 | 396 | * @param EE_Registration[] $registrations |
397 | 397 | * @throws \EE_Error |
398 | 398 | */ |
399 | - public function process_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $registrations = array() ) { |
|
399 | + public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array()) { |
|
400 | 400 | // only process if payment was successful |
401 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
401 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
402 | 402 | return; |
403 | 403 | } |
404 | 404 | //EEM_Registration::instance()->show_next_x_db_queries(); |
405 | - if ( empty( $registrations )) { |
|
405 | + if (empty($registrations)) { |
|
406 | 406 | // find registrations with monies owing that can receive a payment |
407 | - $registrations = $transaction->registrations( array( |
|
407 | + $registrations = $transaction->registrations(array( |
|
408 | 408 | array( |
409 | 409 | // only these reg statuses can receive payments |
410 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
411 | - 'REG_final_price' => array( '!=', 0 ), |
|
412 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
410 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
411 | + 'REG_final_price' => array('!=', 0), |
|
412 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
413 | 413 | ) |
414 | - ) ); |
|
414 | + )); |
|
415 | 415 | } |
416 | 416 | // still nothing ??!?? |
417 | - if ( empty( $registrations )) { |
|
417 | + if (empty($registrations)) { |
|
418 | 418 | return; |
419 | 419 | } |
420 | 420 | // todo: break out the following logic into a separate strategy class |
@@ -426,28 +426,28 @@ discard block |
||
426 | 426 | |
427 | 427 | $refund = $payment->is_a_refund(); |
428 | 428 | // how much is available to apply to registrations? |
429 | - $available_payment_amount = abs( $payment->amount() ); |
|
430 | - foreach ( $registrations as $registration ) { |
|
431 | - if ( $registration instanceof EE_Registration ) { |
|
429 | + $available_payment_amount = abs($payment->amount()); |
|
430 | + foreach ($registrations as $registration) { |
|
431 | + if ($registration instanceof EE_Registration) { |
|
432 | 432 | // nothing left? |
433 | - if ( $available_payment_amount <= 0 ) { |
|
433 | + if ($available_payment_amount <= 0) { |
|
434 | 434 | break; |
435 | 435 | } |
436 | - if ( $refund ) { |
|
437 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
436 | + if ($refund) { |
|
437 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
438 | 438 | } else { |
439 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
439 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | } |
443 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
443 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
444 | 444 | EE_Error::add_attention( |
445 | 445 | sprintf( |
446 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
447 | - EEH_Template::format_currency( $available_payment_amount ), |
|
448 | - implode( ', ', array_keys( $registrations ) ), |
|
446 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
447 | + EEH_Template::format_currency($available_payment_amount), |
|
448 | + implode(', ', array_keys($registrations)), |
|
449 | 449 | '<br/>', |
450 | - EEH_Template::format_currency( $payment->amount() ) |
|
450 | + EEH_Template::format_currency($payment->amount()) |
|
451 | 451 | ), |
452 | 452 | __FILE__, __FUNCTION__, __LINE__ |
453 | 453 | ); |
@@ -464,17 +464,17 @@ discard block |
||
464 | 464 | * @param float $available_payment_amount |
465 | 465 | * @return float |
466 | 466 | */ |
467 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
467 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
468 | 468 | $owing = $registration->final_price() - $registration->paid(); |
469 | - if ( $owing > 0 ) { |
|
469 | + if ($owing > 0) { |
|
470 | 470 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
471 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
471 | + $payment_amount = min($available_payment_amount, $owing); |
|
472 | 472 | // update $available_payment_amount |
473 | 473 | $available_payment_amount = $available_payment_amount - $payment_amount; |
474 | 474 | //calculate and set new REG_paid |
475 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
475 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
476 | 476 | // now save it |
477 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
477 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
478 | 478 | } |
479 | 479 | return $available_payment_amount; |
480 | 480 | } |
@@ -489,19 +489,19 @@ discard block |
||
489 | 489 | * @param float $payment_amount |
490 | 490 | * @return float |
491 | 491 | */ |
492 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
492 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
493 | 493 | // find any existing reg payment records for this registration and payment |
494 | 494 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
495 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
495 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
496 | 496 | ); |
497 | 497 | // if existing registration payment exists |
498 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
498 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
499 | 499 | // then update that record |
500 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
500 | + $existing_reg_payment->set_amount($payment_amount); |
|
501 | 501 | $existing_reg_payment->save(); |
502 | 502 | } else { |
503 | 503 | // or add new relation between registration and payment and set amount |
504 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
504 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
505 | 505 | // make it stick |
506 | 506 | $registration->save(); |
507 | 507 | } |
@@ -517,21 +517,21 @@ discard block |
||
517 | 517 | * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
518 | 518 | * @return float |
519 | 519 | */ |
520 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
520 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
521 | 521 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
522 | - if ( $registration->paid() > 0 ) { |
|
522 | + if ($registration->paid() > 0) { |
|
523 | 523 | // ensure $available_refund_amount is NOT negative |
524 | - $available_refund_amount = abs( $available_refund_amount ); |
|
524 | + $available_refund_amount = abs($available_refund_amount); |
|
525 | 525 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
526 | - $refund_amount = min( $available_refund_amount, $registration->paid() ); |
|
526 | + $refund_amount = min($available_refund_amount, $registration->paid()); |
|
527 | 527 | // update $available_payment_amount |
528 | 528 | $available_refund_amount = $available_refund_amount - $refund_amount; |
529 | 529 | //calculate and set new REG_paid |
530 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
530 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
531 | 531 | // convert payment amount back to a negative value for storage in the db |
532 | - $refund_amount = abs( $refund_amount ) * -1; |
|
532 | + $refund_amount = abs($refund_amount) * -1; |
|
533 | 533 | // now save it |
534 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
534 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
535 | 535 | } |
536 | 536 | return $available_refund_amount; |
537 | 537 | } |
@@ -549,12 +549,12 @@ discard block |
||
549 | 549 | * @param EE_Payment $payment |
550 | 550 | * @param bool $IPN |
551 | 551 | */ |
552 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
552 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
553 | 553 | |
554 | 554 | /** @type EE_Transaction_Processor $transaction_processor */ |
555 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
555 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
556 | 556 | // is the Payment Options Reg Step completed ? |
557 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
557 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
558 | 558 | // DEBUG LOG |
559 | 559 | //$this->log( |
560 | 560 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | // if the Payment Options Reg Step is completed... |
568 | 568 | $revisit = $payment_options_step_completed === true ? true : false; |
569 | 569 | // then this is kinda sorta a revisit with regards to payments at least |
570 | - $transaction_processor->set_revisit( $revisit ); |
|
570 | + $transaction_processor->set_revisit($revisit); |
|
571 | 571 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
572 | 572 | if ( |
573 | 573 | $IPN && |
574 | 574 | $payment_options_step_completed !== true && |
575 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
575 | + ($payment->is_approved() || $payment->is_pending()) |
|
576 | 576 | ) { |
577 | - $payment_options_step_completed = $transaction_processor->set_reg_step_completed( $transaction, 'payment_options' ); |
|
577 | + $payment_options_step_completed = $transaction_processor->set_reg_step_completed($transaction, 'payment_options'); |
|
578 | 578 | } |
579 | 579 | // DEBUG LOG |
580 | 580 | //$this->log( |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | // ) |
587 | 587 | //); |
588 | 588 | /** @type EE_Transaction_Payments $transaction_payments */ |
589 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
589 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
590 | 590 | // maybe update status, but don't save transaction just yet |
591 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
591 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
592 | 592 | // check if 'finalize_registration' step has been completed... |
593 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
593 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
594 | 594 | // DEBUG LOG |
595 | 595 | //$this->log( |
596 | 596 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | // ) |
602 | 602 | //); |
603 | 603 | // if this is an IPN and the final step has not been initiated |
604 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
604 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
605 | 605 | // and if it hasn't already been set as being started... |
606 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
606 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
607 | 607 | // DEBUG LOG |
608 | 608 | //$this->log( |
609 | 609 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -616,13 +616,13 @@ discard block |
||
616 | 616 | } |
617 | 617 | $transaction->save(); |
618 | 618 | // because the above will return false if the final step was not fully completed, we need to check again... |
619 | - if ( $IPN && $finalized !== false ) { |
|
619 | + if ($IPN && $finalized !== false) { |
|
620 | 620 | // and if we are all good to go, then send out notifications |
621 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
621 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
622 | 622 | // DEBUG LOG |
623 | 623 | //$this->log( __CLASS__, __FUNCTION__, __LINE__, $transaction ); |
624 | 624 | //ok, now process the transaction according to the payment |
625 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
625 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
626 | 626 | } |
627 | 627 | // DEBUG LOG |
628 | 628 | //$this->log( |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -578,7 +580,7 @@ discard block |
||
578 | 580 | $espresso_db_update = array( $espresso_db_update=>array() ); |
579 | 581 | update_option( 'espresso_db_update', $espresso_db_update ); |
580 | 582 | } |
581 | - }else{ |
|
583 | + } else{ |
|
582 | 584 | $corrected_db_update = array(); |
583 | 585 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
584 | 586 | foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
@@ -588,7 +590,7 @@ discard block |
||
588 | 590 | //fix it! |
589 | 591 | $version_string = $should_be_array; |
590 | 592 | $corrected_db_update[$version_string] = array('unknown-date'); |
591 | - }else{ |
|
593 | + } else{ |
|
592 | 594 | //ok it checks out |
593 | 595 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
594 | 596 | } |
@@ -633,7 +635,7 @@ discard block |
||
633 | 635 | $addon->initialize_db_if_no_migrations_required(); |
634 | 636 | } |
635 | 637 | } |
636 | - }else{ |
|
638 | + } else{ |
|
637 | 639 | EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
638 | 640 | } |
639 | 641 | if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
@@ -703,7 +705,7 @@ discard block |
||
703 | 705 | //it a version we haven't seen before |
704 | 706 | if( $version_is_higher === 1 ){ |
705 | 707 | $req_type = EE_System::req_type_upgrade; |
706 | - }else{ |
|
708 | + } else{ |
|
707 | 709 | $req_type = EE_System::req_type_downgrade; |
708 | 710 | } |
709 | 711 | delete_option( $activation_indicator_option_name ); |
@@ -712,10 +714,10 @@ discard block |
||
712 | 714 | if( get_option( $activation_indicator_option_name, FALSE ) ){ |
713 | 715 | if ( $version_is_higher === -1 ){ |
714 | 716 | $req_type = EE_System::req_type_downgrade; |
715 | - }elseif( $version_is_higher === 0 ){ |
|
717 | + } elseif( $version_is_higher === 0 ){ |
|
716 | 718 | //we've seen this version before, but it's an activation. must be a reactivation |
717 | 719 | $req_type = EE_System::req_type_reactivation; |
718 | - }else{//$version_is_higher === 1 |
|
720 | + } else{//$version_is_higher === 1 |
|
719 | 721 | $req_type = EE_System::req_type_upgrade; |
720 | 722 | } |
721 | 723 | delete_option( $activation_indicator_option_name ); |
@@ -723,10 +725,10 @@ discard block |
||
723 | 725 | //we've seen this version before and the activation indicate doesn't show it was just activated |
724 | 726 | if ( $version_is_higher === -1 ){ |
725 | 727 | $req_type = EE_System::req_type_downgrade; |
726 | - }elseif( $version_is_higher === 0 ){ |
|
728 | + } elseif( $version_is_higher === 0 ){ |
|
727 | 729 | //we've seen this version before and it's not an activation. its normal request |
728 | 730 | $req_type = EE_System::req_type_normal; |
729 | - }else{//$version_is_higher === 1 |
|
731 | + } else{//$version_is_higher === 1 |
|
730 | 732 | $req_type = EE_System::req_type_upgrade; |
731 | 733 | } |
732 | 734 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @param \EE_Registry $Registry |
89 | 89 | * @return \EE_System |
90 | 90 | */ |
91 | - public static function instance( EE_Registry $Registry = null ) { |
|
91 | + public static function instance(EE_Registry $Registry = null) { |
|
92 | 92 | // check if class object is instantiated |
93 | - if ( ! self::$_instance instanceof EE_System ) { |
|
94 | - self::$_instance = new self( $Registry ); |
|
93 | + if ( ! self::$_instance instanceof EE_System) { |
|
94 | + self::$_instance = new self($Registry); |
|
95 | 95 | } |
96 | 96 | return self::$_instance; |
97 | 97 | } |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * resets the instance and returns it |
102 | 102 | * @return EE_System |
103 | 103 | */ |
104 | - public static function reset(){ |
|
104 | + public static function reset() { |
|
105 | 105 | self::$_instance->_req_type = NULL; |
106 | 106 | //we need to reset the migration manager in order for it to detect DMSs properly |
107 | 107 | EE_Data_Migration_Manager::reset(); |
108 | 108 | //make sure none of the old hooks are left hanging around |
109 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
109 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
110 | 110 | self::instance()->detect_activations_or_upgrades(); |
111 | 111 | self::instance()->perform_activations_upgrades_and_migrations(); |
112 | 112 | return self::instance(); |
@@ -122,28 +122,28 @@ discard block |
||
122 | 122 | * @access private |
123 | 123 | * @param \EE_Registry $Registry |
124 | 124 | */ |
125 | - private function __construct( EE_Registry $Registry ) { |
|
125 | + private function __construct(EE_Registry $Registry) { |
|
126 | 126 | $this->registry = $Registry; |
127 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
127 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
128 | 128 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
129 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) ); |
|
129 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
130 | 130 | // when an ee addon is activated, we want to call the core hook(s) again |
131 | 131 | // because the newly-activated addon didn't get a chance to run at all |
132 | - add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 ); |
|
132 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
133 | 133 | // detect whether install or upgrade |
134 | - add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 ); |
|
134 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3); |
|
135 | 135 | // load EE_Config, EE_Textdomain, etc |
136 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 ); |
|
136 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
137 | 137 | // load EE_Config, EE_Textdomain, etc |
138 | - add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
138 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
139 | 139 | // you wanna get going? I wanna get going... let's get going! |
140 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 ); |
|
140 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
141 | 141 | //other housekeeping |
142 | 142 | //exclude EE critical pages from wp_list_pages |
143 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
143 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
144 | 144 | // ALL EE Addons should use the following hook point to attach their initial setup too |
145 | 145 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
146 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
146 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | public function load_espresso_addons() { |
164 | 164 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
165 | 165 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
166 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
166 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
167 | 167 | //load and setup EE_Capabilities |
168 | - $this->registry->load_core( 'Capabilities' ); |
|
168 | + $this->registry->load_core('Capabilities'); |
|
169 | 169 | //caps need to be initialized on every request so that capability maps are set. |
170 | 170 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
171 | 171 | $this->registry->CAP->init_caps(); |
172 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
172 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @access public |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function detect_activations_or_upgrades(){ |
|
187 | + public function detect_activations_or_upgrades() { |
|
188 | 188 | //first off: let's make sure to handle core |
189 | 189 | $this->detect_if_activation_or_upgrade(); |
190 | - foreach($this->registry->addons as $addon){ |
|
190 | + foreach ($this->registry->addons as $addon) { |
|
191 | 191 | //detect teh request type for that addon |
192 | 192 | $addon->detect_activation_or_upgrade(); |
193 | 193 | } |
@@ -208,44 +208,44 @@ discard block |
||
208 | 208 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
209 | 209 | |
210 | 210 | // load M-Mode class |
211 | - $this->registry->load_core( 'Maintenance_Mode' ); |
|
211 | + $this->registry->load_core('Maintenance_Mode'); |
|
212 | 212 | // check if db has been updated, or if its a brand-new installation |
213 | 213 | |
214 | 214 | $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
215 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
215 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
216 | 216 | //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
217 | - if( $request_type != EE_System::req_type_normal){ |
|
217 | + if ($request_type != EE_System::req_type_normal) { |
|
218 | 218 | $this->registry->load_helper('Activation'); |
219 | 219 | } |
220 | 220 | |
221 | - switch($request_type){ |
|
221 | + switch ($request_type) { |
|
222 | 222 | case EE_System::req_type_new_activation: |
223 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' ); |
|
224 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
223 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
224 | + $this->_handle_core_version_change($espresso_db_update); |
|
225 | 225 | break; |
226 | 226 | case EE_System::req_type_reactivation: |
227 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' ); |
|
228 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
227 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
228 | + $this->_handle_core_version_change($espresso_db_update); |
|
229 | 229 | break; |
230 | 230 | case EE_System::req_type_upgrade: |
231 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' ); |
|
231 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
232 | 232 | //migrations may be required now that we've upgraded |
233 | 233 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
234 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
234 | + $this->_handle_core_version_change($espresso_db_update); |
|
235 | 235 | // echo "done upgrade";die; |
236 | 236 | break; |
237 | 237 | case EE_System::req_type_downgrade: |
238 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' ); |
|
238 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
239 | 239 | //its possible migrations are no longer required |
240 | 240 | EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
241 | - $this->_handle_core_version_change( $espresso_db_update ); |
|
241 | + $this->_handle_core_version_change($espresso_db_update); |
|
242 | 242 | break; |
243 | 243 | case EE_System::req_type_normal: |
244 | 244 | default: |
245 | 245 | // $this->_maybe_redirect_to_ee_about(); |
246 | 246 | break; |
247 | 247 | } |
248 | - do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' ); |
|
248 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * initializing the database later during the request |
254 | 254 | * @param array $espresso_db_update |
255 | 255 | */ |
256 | - protected function _handle_core_version_change( $espresso_db_update ){ |
|
257 | - $this->update_list_of_installed_versions( $espresso_db_update ); |
|
256 | + protected function _handle_core_version_change($espresso_db_update) { |
|
257 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
258 | 258 | //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
259 | - add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )); |
|
259 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | |
@@ -271,44 +271,44 @@ discard block |
||
271 | 271 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
272 | 272 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
273 | 273 | */ |
274 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
|
275 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update ); |
|
276 | - if( ! $espresso_db_update){ |
|
277 | - $espresso_db_update = get_option( 'espresso_db_update' ); |
|
274 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) { |
|
275 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
276 | + if ( ! $espresso_db_update) { |
|
277 | + $espresso_db_update = get_option('espresso_db_update'); |
|
278 | 278 | } |
279 | 279 | // check that option is an array |
280 | - if( ! is_array( $espresso_db_update )) { |
|
280 | + if ( ! is_array($espresso_db_update)) { |
|
281 | 281 | // if option is FALSE, then it never existed |
282 | - if ( $espresso_db_update === FALSE ) { |
|
282 | + if ($espresso_db_update === FALSE) { |
|
283 | 283 | // make $espresso_db_update an array and save option with autoload OFF |
284 | - $espresso_db_update = array(); |
|
285 | - add_option( 'espresso_db_update', $espresso_db_update, '', 'no' ); |
|
284 | + $espresso_db_update = array(); |
|
285 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
286 | 286 | } else { |
287 | 287 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
288 | - $espresso_db_update = array( $espresso_db_update=>array() ); |
|
289 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
288 | + $espresso_db_update = array($espresso_db_update=>array()); |
|
289 | + update_option('espresso_db_update', $espresso_db_update); |
|
290 | 290 | } |
291 | - }else{ |
|
291 | + } else { |
|
292 | 292 | $corrected_db_update = array(); |
293 | 293 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
294 | - foreach($espresso_db_update as $should_be_version_string => $should_be_array){ |
|
295 | - if(is_int($should_be_version_string) && ! is_array($should_be_array)){ |
|
294 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
295 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
296 | 296 | //the key is an int, and the value IS NOT an array |
297 | 297 | //so it must be numerically-indexed, where values are versions installed... |
298 | 298 | //fix it! |
299 | 299 | $version_string = $should_be_array; |
300 | 300 | $corrected_db_update[$version_string] = array('unknown-date'); |
301 | - }else{ |
|
301 | + } else { |
|
302 | 302 | //ok it checks out |
303 | 303 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | $espresso_db_update = $corrected_db_update; |
307 | - update_option( 'espresso_db_update', $espresso_db_update ); |
|
307 | + update_option('espresso_db_update', $espresso_db_update); |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | |
311 | - do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update ); |
|
311 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
312 | 312 | return $espresso_db_update; |
313 | 313 | } |
314 | 314 | |
@@ -328,33 +328,33 @@ discard block |
||
328 | 328 | * so we prefer to only do it when necessary |
329 | 329 | * @return void |
330 | 330 | */ |
331 | - public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
|
331 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) { |
|
332 | 332 | $request_type = $this->detect_req_type(); |
333 | 333 | //only initialize system if we're not in maintenance mode. |
334 | - if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){ |
|
335 | - update_option( 'ee_flush_rewrite_rules', TRUE ); |
|
334 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
335 | + update_option('ee_flush_rewrite_rules', TRUE); |
|
336 | 336 | EEH_Activation::system_initialization(); |
337 | - if( $verify_schema ) { |
|
337 | + if ($verify_schema) { |
|
338 | 338 | EEH_Activation::initialize_db_and_folders(); |
339 | 339 | } |
340 | 340 | EEH_Activation::initialize_db_content(); |
341 | - if( $initialize_addons_too ) { |
|
341 | + if ($initialize_addons_too) { |
|
342 | 342 | $this->initialize_addons(); |
343 | 343 | } |
344 | - }else{ |
|
345 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' ); |
|
344 | + } else { |
|
345 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
346 | 346 | } |
347 | - if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) { |
|
348 | - add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 ); |
|
347 | + if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) { |
|
348 | + add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9); |
|
349 | 349 | } |
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Initializes the db for all registered addons |
354 | 354 | */ |
355 | - public function initialize_addons(){ |
|
355 | + public function initialize_addons() { |
|
356 | 356 | //foreach registered addon, make sure its db is up-to-date too |
357 | - foreach($this->registry->addons as $addon){ |
|
357 | + foreach ($this->registry->addons as $addon) { |
|
358 | 358 | $addon->initialize_db_if_no_migrations_required(); |
359 | 359 | } |
360 | 360 | } |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | * @param string $current_version_to_add version to be added to the version history |
367 | 367 | * @return boolean success as to whether or not this option was changed |
368 | 368 | */ |
369 | - public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
|
370 | - if( ! $version_history ) { |
|
369 | + public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) { |
|
370 | + if ( ! $version_history) { |
|
371 | 371 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
372 | 372 | } |
373 | - if( $current_version_to_add == NULL){ |
|
373 | + if ($current_version_to_add == NULL) { |
|
374 | 374 | $current_version_to_add = espresso_version(); |
375 | 375 | } |
376 | - $version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() ); |
|
376 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
377 | 377 | // re-save |
378 | - return update_option( 'espresso_db_update', $version_history ); |
|
378 | + return update_option('espresso_db_update', $version_history); |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -392,10 +392,10 @@ discard block |
||
392 | 392 | * but still know if this is a new install or not |
393 | 393 | * @return int one of the constants on EE_System::req_type_ |
394 | 394 | */ |
395 | - public function detect_req_type( $espresso_db_update = NULL ){ |
|
396 | - if ( $this->_req_type === NULL ){ |
|
397 | - $espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
398 | - $this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() ); |
|
395 | + public function detect_req_type($espresso_db_update = NULL) { |
|
396 | + if ($this->_req_type === NULL) { |
|
397 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option(); |
|
398 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version()); |
|
399 | 399 | } |
400 | 400 | return $this->_req_type; |
401 | 401 | } |
@@ -411,39 +411,39 @@ discard block |
||
411 | 411 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
412 | 412 | * @return int one of the constants on EE_System::req_type_* |
413 | 413 | */ |
414 | - public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
|
415 | - $version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ); |
|
416 | - if( $activation_history_for_addon ){ |
|
414 | + public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) { |
|
415 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
416 | + if ($activation_history_for_addon) { |
|
417 | 417 | //it exists, so this isn't a completely new install |
418 | 418 | //check if this version already in that list of previously installed versions |
419 | - if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) { |
|
419 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
420 | 420 | //it a version we haven't seen before |
421 | - if( $version_is_higher === 1 ){ |
|
421 | + if ($version_is_higher === 1) { |
|
422 | 422 | $req_type = EE_System::req_type_upgrade; |
423 | - }else{ |
|
423 | + } else { |
|
424 | 424 | $req_type = EE_System::req_type_downgrade; |
425 | 425 | } |
426 | - delete_option( $activation_indicator_option_name ); |
|
426 | + delete_option($activation_indicator_option_name); |
|
427 | 427 | } else { |
428 | 428 | // its not an update. maybe a reactivation? |
429 | - if( get_option( $activation_indicator_option_name, FALSE ) ){ |
|
430 | - if ( $version_is_higher === -1 ){ |
|
429 | + if (get_option($activation_indicator_option_name, FALSE)) { |
|
430 | + if ($version_is_higher === -1) { |
|
431 | 431 | $req_type = EE_System::req_type_downgrade; |
432 | - }elseif( $version_is_higher === 0 ){ |
|
432 | + }elseif ($version_is_higher === 0) { |
|
433 | 433 | //we've seen this version before, but it's an activation. must be a reactivation |
434 | 434 | $req_type = EE_System::req_type_reactivation; |
435 | - }else{//$version_is_higher === 1 |
|
435 | + } else {//$version_is_higher === 1 |
|
436 | 436 | $req_type = EE_System::req_type_upgrade; |
437 | 437 | } |
438 | - delete_option( $activation_indicator_option_name ); |
|
438 | + delete_option($activation_indicator_option_name); |
|
439 | 439 | } else { |
440 | 440 | //we've seen this version before and the activation indicate doesn't show it was just activated |
441 | - if ( $version_is_higher === -1 ){ |
|
441 | + if ($version_is_higher === -1) { |
|
442 | 442 | $req_type = EE_System::req_type_downgrade; |
443 | - }elseif( $version_is_higher === 0 ){ |
|
443 | + }elseif ($version_is_higher === 0) { |
|
444 | 444 | //we've seen this version before and it's not an activation. its normal request |
445 | 445 | $req_type = EE_System::req_type_normal; |
446 | - }else{//$version_is_higher === 1 |
|
446 | + } else {//$version_is_higher === 1 |
|
447 | 447 | $req_type = EE_System::req_type_upgrade; |
448 | 448 | } |
449 | 449 | } |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | } else { |
452 | 452 | //brand new install |
453 | 453 | $req_type = EE_System::req_type_new_activation; |
454 | - delete_option( $activation_indicator_option_name ); |
|
454 | + delete_option($activation_indicator_option_name); |
|
455 | 455 | } |
456 | 456 | return $req_type; |
457 | 457 | } |
@@ -469,30 +469,30 @@ discard block |
||
469 | 469 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
470 | 470 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
471 | 471 | */ |
472 | - protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
|
472 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) { |
|
473 | 473 | //find the most recently-activated version |
474 | 474 | $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
475 | 475 | $most_recently_active_version = '0.0.0.dev.000'; |
476 | - if( is_array( $activation_history_for_addon ) ){ |
|
477 | - foreach( $activation_history_for_addon as $version => $times_activated ){ |
|
476 | + if (is_array($activation_history_for_addon)) { |
|
477 | + foreach ($activation_history_for_addon as $version => $times_activated) { |
|
478 | 478 | //check there is a record of when this version was activated. Otherwise, |
479 | 479 | //mark it as unknown |
480 | - if( ! $times_activated ){ |
|
481 | - $times_activated = array( 'unknown-date'); |
|
480 | + if ( ! $times_activated) { |
|
481 | + $times_activated = array('unknown-date'); |
|
482 | 482 | } |
483 | - if( is_string( $times_activated ) ){ |
|
484 | - $times_activated = array( $times_activated ); |
|
483 | + if (is_string($times_activated)) { |
|
484 | + $times_activated = array($times_activated); |
|
485 | 485 | } |
486 | - foreach( $times_activated as $an_activation ){ |
|
487 | - if( $an_activation != 'unknown-date' && |
|
488 | - $an_activation > $most_recently_active_version_activation ){ |
|
486 | + foreach ($times_activated as $an_activation) { |
|
487 | + if ($an_activation != 'unknown-date' && |
|
488 | + $an_activation > $most_recently_active_version_activation) { |
|
489 | 489 | $most_recently_active_version = $version; |
490 | 490 | $most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation; |
491 | 491 | } |
492 | 492 | } |
493 | 493 | } |
494 | 494 | } |
495 | - return version_compare( $version_to_upgrade_to, $most_recently_active_version ); |
|
495 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
@@ -502,24 +502,24 @@ discard block |
||
502 | 502 | * @return void |
503 | 503 | */ |
504 | 504 | public function redirect_to_about_ee() { |
505 | - $notices = EE_Error::get_notices( FALSE ); |
|
505 | + $notices = EE_Error::get_notices(FALSE); |
|
506 | 506 | //if current user is an admin and it's not an ajax request |
507 | 507 | if ( |
508 | - $this->registry->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) |
|
509 | - && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
510 | - && ! isset( $notices[ 'errors' ] ) |
|
508 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
509 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
510 | + && ! isset($notices['errors']) |
|
511 | 511 | ) { |
512 | - $query_params = array( 'page' => 'espresso_about' ); |
|
512 | + $query_params = array('page' => 'espresso_about'); |
|
513 | 513 | |
514 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
|
514 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
515 | 515 | $query_params['new_activation'] = TRUE; |
516 | 516 | } |
517 | 517 | |
518 | - if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
|
518 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
519 | 519 | $query_params['reactivation'] = TRUE; |
520 | 520 | } |
521 | - $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
|
522 | - wp_safe_redirect( $url ); |
|
521 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
522 | + wp_safe_redirect($url); |
|
523 | 523 | exit(); |
524 | 524 | } |
525 | 525 | } |
@@ -533,31 +533,31 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return void |
535 | 535 | */ |
536 | - public function load_core_configuration(){ |
|
537 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
538 | - $this->registry->load_core( 'EE_Load_Textdomain' ); |
|
536 | + public function load_core_configuration() { |
|
537 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
538 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
539 | 539 | //load textdomain |
540 | 540 | EE_Load_Textdomain::load_textdomain(); |
541 | 541 | // load and setup EE_Config and EE_Network_Config |
542 | - $this->registry->load_core( 'Config' ); |
|
543 | - $this->registry->load_core( 'Network_Config' ); |
|
542 | + $this->registry->load_core('Config'); |
|
543 | + $this->registry->load_core('Network_Config'); |
|
544 | 544 | // setup autoloaders |
545 | 545 | // enable logging? |
546 | - if ( $this->registry->CFG->admin->use_full_logging ) { |
|
547 | - $this->registry->load_core( 'Log' ); |
|
546 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
547 | + $this->registry->load_core('Log'); |
|
548 | 548 | } |
549 | 549 | // check for activation errors |
550 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
551 | - if ( $activation_errors ) { |
|
552 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
553 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
550 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
551 | + if ($activation_errors) { |
|
552 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
553 | + update_option('ee_plugin_activation_errors', FALSE); |
|
554 | 554 | } |
555 | 555 | // get model names |
556 | 556 | $this->_parse_model_names(); |
557 | 557 | |
558 | 558 | //load caf stuff a chance to play during the activation process too. |
559 | 559 | $this->_maybe_brew_regular(); |
560 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
560 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -566,23 +566,23 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @return void |
568 | 568 | */ |
569 | - private function _parse_model_names(){ |
|
569 | + private function _parse_model_names() { |
|
570 | 570 | //get all the files in the EE_MODELS folder that end in .model.php |
571 | - $models = glob( EE_MODELS.'*.model.php'); |
|
571 | + $models = glob(EE_MODELS.'*.model.php'); |
|
572 | 572 | $model_names = array(); |
573 | 573 | $non_abstract_db_models = array(); |
574 | - foreach( $models as $model ){ |
|
574 | + foreach ($models as $model) { |
|
575 | 575 | // get model classname |
576 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
577 | - $short_name = str_replace( 'EEM_', '', $classname ); |
|
576 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
577 | + $short_name = str_replace('EEM_', '', $classname); |
|
578 | 578 | $reflectionClass = new ReflectionClass($classname); |
579 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
580 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
579 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
580 | + $non_abstract_db_models[$short_name] = $classname; |
|
581 | 581 | } |
582 | - $model_names[ $short_name ] = $classname; |
|
582 | + $model_names[$short_name] = $classname; |
|
583 | 583 | } |
584 | - $this->registry->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
585 | - $this->registry->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models ); |
|
584 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
585 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | |
@@ -592,8 +592,8 @@ discard block |
||
592 | 592 | * @return void |
593 | 593 | */ |
594 | 594 | private function _maybe_brew_regular() { |
595 | - if (( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) { |
|
596 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
595 | + if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
596 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -610,9 +610,9 @@ discard block |
||
610 | 610 | * @return void |
611 | 611 | */ |
612 | 612 | public function register_shortcodes_modules_and_widgets() { |
613 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
613 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
614 | 614 | // check for addons using old hookpoint |
615 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
615 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
616 | 616 | $this->_incompatible_addon_error(); |
617 | 617 | } |
618 | 618 | } |
@@ -626,19 +626,19 @@ discard block |
||
626 | 626 | */ |
627 | 627 | private function _incompatible_addon_error() { |
628 | 628 | // get array of classes hooking into here |
629 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
|
630 | - if ( ! empty( $class_names )) { |
|
631 | - $msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' ); |
|
629 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
630 | + if ( ! empty($class_names)) { |
|
631 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso'); |
|
632 | 632 | $msg .= '<ul>'; |
633 | - foreach ( $class_names as $class_name ) { |
|
634 | - $msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>'; |
|
633 | + foreach ($class_names as $class_name) { |
|
634 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>'; |
|
635 | 635 | } |
636 | 636 | $msg .= '</ul>'; |
637 | - $msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' ); |
|
637 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso'); |
|
638 | 638 | // save list of incompatible addons to wp-options for later use |
639 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
640 | - if ( is_admin() ) { |
|
641 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
639 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
640 | + if (is_admin()) { |
|
641 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } |
@@ -655,25 +655,25 @@ discard block |
||
655 | 655 | * |
656 | 656 | * @return void |
657 | 657 | */ |
658 | - public function brew_espresso(){ |
|
659 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
658 | + public function brew_espresso() { |
|
659 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
660 | 660 | // load some final core systems |
661 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
662 | - add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 ); |
|
663 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
664 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
665 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
666 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
667 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
668 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
669 | - add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 ); |
|
670 | - |
|
671 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE ) ) { |
|
661 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
662 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
663 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
664 | + add_action('init', array($this, 'load_controllers'), 7); |
|
665 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
666 | + add_action('init', array($this, 'initialize'), 10); |
|
667 | + add_action('init', array($this, 'initialize_last'), 100); |
|
668 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
669 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
670 | + |
|
671 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) { |
|
672 | 672 | // pew pew pew |
673 | - $this->registry->load_core( 'PUE' ); |
|
674 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
673 | + $this->registry->load_core('PUE'); |
|
674 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
675 | 675 | } |
676 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
676 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | |
@@ -687,7 +687,7 @@ discard block |
||
687 | 687 | */ |
688 | 688 | public function set_hooks_for_core() { |
689 | 689 | $this->_deactivate_incompatible_addons(); |
690 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
690 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | |
@@ -696,15 +696,15 @@ discard block |
||
696 | 696 | * Using the information gathered in EE_System::_incompatible_addon_error, |
697 | 697 | * deactivates any addons considered incompatible with the current version of EE |
698 | 698 | */ |
699 | - private function _deactivate_incompatible_addons(){ |
|
700 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
701 | - if ( ! empty( $incompatible_addons )) { |
|
702 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
703 | - foreach ( $active_plugins as $active_plugin ) { |
|
704 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
705 | - if ( strpos( $active_plugin, $incompatible_addon ) !== FALSE ) { |
|
706 | - unset( $_GET['activate'] ); |
|
707 | - espresso_deactivate_plugin( $active_plugin ); |
|
699 | + private function _deactivate_incompatible_addons() { |
|
700 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
701 | + if ( ! empty($incompatible_addons)) { |
|
702 | + $active_plugins = get_option('active_plugins', array()); |
|
703 | + foreach ($active_plugins as $active_plugin) { |
|
704 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
705 | + if (strpos($active_plugin, $incompatible_addon) !== FALSE) { |
|
706 | + unset($_GET['activate']); |
|
707 | + espresso_deactivate_plugin($active_plugin); |
|
708 | 708 | } |
709 | 709 | } |
710 | 710 | } |
@@ -721,10 +721,10 @@ discard block |
||
721 | 721 | */ |
722 | 722 | public function perform_activations_upgrades_and_migrations() { |
723 | 723 | //first check if we had previously attempted to setup EE's directories but failed |
724 | - if( EEH_Activation::upload_directories_incomplete() ) { |
|
724 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
725 | 725 | EEH_Activation::create_upload_directories(); |
726 | 726 | } |
727 | - do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
727 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | * @return void |
737 | 737 | */ |
738 | 738 | public function load_CPTs_and_session() { |
739 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
739 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
740 | 740 | // register Custom Post Types |
741 | - $this->registry->load_core( 'Register_CPTs' ); |
|
742 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
741 | + $this->registry->load_core('Register_CPTs'); |
|
742 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | |
@@ -754,16 +754,16 @@ discard block |
||
754 | 754 | * @return void |
755 | 755 | */ |
756 | 756 | public function load_controllers() { |
757 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
757 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
758 | 758 | // let's get it started |
759 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
760 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
761 | - $this->registry->load_core( 'Front_Controller', array(), false, true ); |
|
762 | - } else if ( ! EE_FRONT_AJAX ) { |
|
763 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
764 | - $this->registry->load_core( 'Admin' ); |
|
759 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
760 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
761 | + $this->registry->load_core('Front_Controller', array(), false, true); |
|
762 | + } else if ( ! EE_FRONT_AJAX) { |
|
763 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
764 | + $this->registry->load_core('Admin'); |
|
765 | 765 | } |
766 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
766 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
@@ -777,9 +777,9 @@ discard block |
||
777 | 777 | * @return void |
778 | 778 | */ |
779 | 779 | public function core_loaded_and_ready() { |
780 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
781 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
782 | - $this->registry->load_core( 'Session' ); |
|
780 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
781 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
782 | + $this->registry->load_core('Session'); |
|
783 | 783 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
784 | 784 | } |
785 | 785 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * @return void |
795 | 795 | */ |
796 | 796 | public function initialize() { |
797 | - do_action( 'AHEE__EE_System__initialize' ); |
|
797 | + do_action('AHEE__EE_System__initialize'); |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @return void |
809 | 809 | */ |
810 | 810 | public function initialize_last() { |
811 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
811 | + do_action('AHEE__EE_System__initialize_last'); |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | |
@@ -840,21 +840,21 @@ discard block |
||
840 | 840 | */ |
841 | 841 | public static function do_not_cache() { |
842 | 842 | // set no cache constants |
843 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
844 | - define( 'DONOTCACHEPAGE', true ); |
|
843 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
844 | + define('DONOTCACHEPAGE', true); |
|
845 | 845 | } |
846 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
847 | - define( 'DONOTCACHCEOBJECT', true ); |
|
846 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
847 | + define('DONOTCACHCEOBJECT', true); |
|
848 | 848 | } |
849 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
850 | - define( 'DONOTCACHEDB', true ); |
|
849 | + if ( ! defined('DONOTCACHEDB')) { |
|
850 | + define('DONOTCACHEDB', true); |
|
851 | 851 | } |
852 | 852 | // add no cache headers |
853 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
853 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
854 | 854 | // plus a little extra for nginx |
855 | - add_filter( 'nocache_headers', array( 'EE_System', 'nocache_headers_nginx' ), 10, 1 ); |
|
855 | + add_filter('nocache_headers', array('EE_System', 'nocache_headers_nginx'), 10, 1); |
|
856 | 856 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
857 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
857 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | * @param $headers |
867 | 867 | * @return array |
868 | 868 | */ |
869 | - public static function nocache_headers_nginx ( $headers ) { |
|
869 | + public static function nocache_headers_nginx($headers) { |
|
870 | 870 | $headers['X-Accel-Expires'] = 0; |
871 | 871 | return $headers; |
872 | 872 | } |
@@ -892,15 +892,15 @@ discard block |
||
892 | 892 | * @param WP_Admin_Bar $admin_bar |
893 | 893 | * @return void |
894 | 894 | */ |
895 | - public function espresso_toolbar_items( WP_Admin_Bar $admin_bar ) { |
|
895 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) { |
|
896 | 896 | |
897 | 897 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
898 | - if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
|
898 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) { |
|
899 | 899 | return; |
900 | 900 | } |
901 | 901 | |
902 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
903 | - $this->registry->load_helper( 'URL' ); |
|
902 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
903 | + $this->registry->load_helper('URL'); |
|
904 | 904 | $menu_class = 'espresso_menu_item_class'; |
905 | 905 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
906 | 906 | //because they're only defined in each of their respective constructors |
@@ -912,20 +912,20 @@ discard block |
||
912 | 912 | //Top Level |
913 | 913 | $admin_bar->add_menu(array( |
914 | 914 | 'id' => 'espresso-toolbar', |
915 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
|
915 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>', |
|
916 | 916 | 'href' => $events_admin_url, |
917 | 917 | 'meta' => array( |
918 | 918 | 'title' => __('Event Espresso', 'event_espresso'), |
919 | - 'class' => $menu_class . 'first' |
|
919 | + 'class' => $menu_class.'first' |
|
920 | 920 | ), |
921 | 921 | )); |
922 | 922 | |
923 | 923 | //Events |
924 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
924 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
925 | 925 | $admin_bar->add_menu(array( |
926 | 926 | 'id' => 'espresso-toolbar-events', |
927 | 927 | 'parent' => 'espresso-toolbar', |
928 | - 'title' => __( 'Events', 'event_espresso' ), |
|
928 | + 'title' => __('Events', 'event_espresso'), |
|
929 | 929 | 'href' => $events_admin_url, |
930 | 930 | 'meta' => array( |
931 | 931 | 'title' => __('Events', 'event_espresso'), |
@@ -936,13 +936,13 @@ discard block |
||
936 | 936 | } |
937 | 937 | |
938 | 938 | |
939 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
939 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
940 | 940 | //Events Add New |
941 | 941 | $admin_bar->add_menu(array( |
942 | 942 | 'id' => 'espresso-toolbar-events-new', |
943 | 943 | 'parent' => 'espresso-toolbar-events', |
944 | 944 | 'title' => __('Add New', 'event_espresso'), |
945 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
|
945 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url), |
|
946 | 946 | 'meta' => array( |
947 | 947 | 'title' => __('Add New', 'event_espresso'), |
948 | 948 | 'target' => '', |
@@ -951,18 +951,18 @@ discard block |
||
951 | 951 | )); |
952 | 952 | } |
953 | 953 | |
954 | - if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
|
954 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
955 | 955 | |
956 | 956 | //Current post |
957 | 957 | global $post; |
958 | 958 | |
959 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
959 | + if ($this->registry->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) { |
|
960 | 960 | //Events Edit Current Event |
961 | 961 | $admin_bar->add_menu(array( |
962 | 962 | 'id' => 'espresso-toolbar-events-edit', |
963 | 963 | 'parent' => 'espresso-toolbar-events', |
964 | 964 | 'title' => __('Edit Event', 'event_espresso'), |
965 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
|
965 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url), |
|
966 | 966 | 'meta' => array( |
967 | 967 | 'title' => __('Edit Event', 'event_espresso'), |
968 | 968 | 'target' => '', |
@@ -974,11 +974,11 @@ discard block |
||
974 | 974 | } |
975 | 975 | |
976 | 976 | //Events View |
977 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
977 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) { |
|
978 | 978 | $admin_bar->add_menu(array( |
979 | 979 | 'id' => 'espresso-toolbar-events-view', |
980 | 980 | 'parent' => 'espresso-toolbar-events', |
981 | - 'title' => __( 'View', 'event_espresso' ), |
|
981 | + 'title' => __('View', 'event_espresso'), |
|
982 | 982 | 'href' => $events_admin_url, |
983 | 983 | 'meta' => array( |
984 | 984 | 'title' => __('View', 'event_espresso'), |
@@ -988,12 +988,12 @@ discard block |
||
988 | 988 | )); |
989 | 989 | } |
990 | 990 | |
991 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
991 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
992 | 992 | //Events View All |
993 | 993 | $admin_bar->add_menu(array( |
994 | 994 | 'id' => 'espresso-toolbar-events-all', |
995 | 995 | 'parent' => 'espresso-toolbar-events-view', |
996 | - 'title' => __( 'All', 'event_espresso' ), |
|
996 | + 'title' => __('All', 'event_espresso'), |
|
997 | 997 | 'href' => $events_admin_url, |
998 | 998 | 'meta' => array( |
999 | 999 | 'title' => __('All', 'event_espresso'), |
@@ -1004,13 +1004,13 @@ discard block |
||
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
1007 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1007 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) { |
|
1008 | 1008 | //Events View Today |
1009 | 1009 | $admin_bar->add_menu(array( |
1010 | 1010 | 'id' => 'espresso-toolbar-events-today', |
1011 | 1011 | 'parent' => 'espresso-toolbar-events-view', |
1012 | 1012 | 'title' => __('Today', 'event_espresso'), |
1013 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
|
1013 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url), |
|
1014 | 1014 | 'meta' => array( |
1015 | 1015 | 'title' => __('Today', 'event_espresso'), |
1016 | 1016 | 'target' => '', |
@@ -1020,13 +1020,13 @@ discard block |
||
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | |
1023 | - if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1023 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) { |
|
1024 | 1024 | //Events View This Month |
1025 | 1025 | $admin_bar->add_menu(array( |
1026 | 1026 | 'id' => 'espresso-toolbar-events-month', |
1027 | 1027 | 'parent' => 'espresso-toolbar-events-view', |
1028 | - 'title' => __( 'This Month', 'event_espresso'), |
|
1029 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
|
1028 | + 'title' => __('This Month', 'event_espresso'), |
|
1029 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url), |
|
1030 | 1030 | 'meta' => array( |
1031 | 1031 | 'title' => __('This Month', 'event_espresso'), |
1032 | 1032 | 'target' => '', |
@@ -1036,11 +1036,11 @@ discard block |
||
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | //Registration Overview |
1039 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1039 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) { |
|
1040 | 1040 | $admin_bar->add_menu(array( |
1041 | 1041 | 'id' => 'espresso-toolbar-registrations', |
1042 | 1042 | 'parent' => 'espresso-toolbar', |
1043 | - 'title' => __( 'Registrations', 'event_espresso' ), |
|
1043 | + 'title' => __('Registrations', 'event_espresso'), |
|
1044 | 1044 | 'href' => $reg_admin_url, |
1045 | 1045 | 'meta' => array( |
1046 | 1046 | 'title' => __('Registrations', 'event_espresso'), |
@@ -1051,12 +1051,12 @@ discard block |
||
1051 | 1051 | } |
1052 | 1052 | |
1053 | 1053 | //Registration Overview Today |
1054 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1054 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) { |
|
1055 | 1055 | $admin_bar->add_menu(array( |
1056 | 1056 | 'id' => 'espresso-toolbar-registrations-today', |
1057 | 1057 | 'parent' => 'espresso-toolbar-registrations', |
1058 | - 'title' => __( 'Today', 'event_espresso'), |
|
1059 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
|
1058 | + 'title' => __('Today', 'event_espresso'), |
|
1059 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url), |
|
1060 | 1060 | 'meta' => array( |
1061 | 1061 | 'title' => __('Today', 'event_espresso'), |
1062 | 1062 | 'target' => '', |
@@ -1066,14 +1066,14 @@ discard block |
||
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | //Registration Overview Today Completed |
1069 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1069 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) { |
|
1070 | 1070 | $admin_bar->add_menu(array( |
1071 | 1071 | 'id' => 'espresso-toolbar-registrations-today-approved', |
1072 | 1072 | 'parent' => 'espresso-toolbar-registrations-today', |
1073 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1074 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1073 | + 'title' => __('Approved', 'event_espresso'), |
|
1074 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1075 | 1075 | 'meta' => array( |
1076 | - 'title' => __('Approved', 'event_espresso' ), |
|
1076 | + 'title' => __('Approved', 'event_espresso'), |
|
1077 | 1077 | 'target' => '', |
1078 | 1078 | 'class' => $menu_class |
1079 | 1079 | ), |
@@ -1081,14 +1081,14 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | //Registration Overview Today Pending\ |
1084 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1084 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) { |
|
1085 | 1085 | $admin_bar->add_menu(array( |
1086 | 1086 | 'id' => 'espresso-toolbar-registrations-today-pending', |
1087 | 1087 | 'parent' => 'espresso-toolbar-registrations-today', |
1088 | - 'title' => __( 'Pending', 'event_espresso' ), |
|
1089 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1088 | + 'title' => __('Pending', 'event_espresso'), |
|
1089 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1090 | 1090 | 'meta' => array( |
1091 | - 'title' => __('Pending Payment', 'event_espresso' ), |
|
1091 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1092 | 1092 | 'target' => '', |
1093 | 1093 | 'class' => $menu_class |
1094 | 1094 | ), |
@@ -1096,14 +1096,14 @@ discard block |
||
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | //Registration Overview Today Incomplete |
1099 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1099 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) { |
|
1100 | 1100 | $admin_bar->add_menu(array( |
1101 | 1101 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
1102 | 1102 | 'parent' => 'espresso-toolbar-registrations-today', |
1103 | - 'title' => __( 'Not Approved', 'event_espresso' ), |
|
1104 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1103 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1104 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1105 | 1105 | 'meta' => array( |
1106 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1106 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1107 | 1107 | 'target' => '', |
1108 | 1108 | 'class' => $menu_class |
1109 | 1109 | ), |
@@ -1111,12 +1111,12 @@ discard block |
||
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | //Registration Overview Today Incomplete |
1114 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1114 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) { |
|
1115 | 1115 | $admin_bar->add_menu(array( |
1116 | 1116 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
1117 | 1117 | 'parent' => 'espresso-toolbar-registrations-today', |
1118 | - 'title' => __( 'Cancelled', 'event_espresso'), |
|
1119 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1118 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1119 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1120 | 1120 | 'meta' => array( |
1121 | 1121 | 'title' => __('Cancelled', 'event_espresso'), |
1122 | 1122 | 'target' => '', |
@@ -1126,12 +1126,12 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | //Registration Overview This Month |
1129 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1129 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) { |
|
1130 | 1130 | $admin_bar->add_menu(array( |
1131 | 1131 | 'id' => 'espresso-toolbar-registrations-month', |
1132 | 1132 | 'parent' => 'espresso-toolbar-registrations', |
1133 | - 'title' => __( 'This Month', 'event_espresso' ), |
|
1134 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
|
1133 | + 'title' => __('This Month', 'event_espresso'), |
|
1134 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url), |
|
1135 | 1135 | 'meta' => array( |
1136 | 1136 | 'title' => __('This Month', 'event_espresso'), |
1137 | 1137 | 'target' => '', |
@@ -1141,12 +1141,12 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | //Registration Overview This Month Approved |
1144 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1144 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) { |
|
1145 | 1145 | $admin_bar->add_menu(array( |
1146 | 1146 | 'id' => 'espresso-toolbar-registrations-month-approved', |
1147 | 1147 | 'parent' => 'espresso-toolbar-registrations-month', |
1148 | - 'title' => __( 'Approved', 'event_espresso' ), |
|
1149 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
|
1148 | + 'title' => __('Approved', 'event_espresso'), |
|
1149 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url), |
|
1150 | 1150 | 'meta' => array( |
1151 | 1151 | 'title' => __('Approved', 'event_espresso'), |
1152 | 1152 | 'target' => '', |
@@ -1156,12 +1156,12 @@ discard block |
||
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | //Registration Overview This Month Pending |
1159 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1159 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) { |
|
1160 | 1160 | $admin_bar->add_menu(array( |
1161 | 1161 | 'id' => 'espresso-toolbar-registrations-month-pending', |
1162 | 1162 | 'parent' => 'espresso-toolbar-registrations-month', |
1163 | - 'title' => __( 'Pending', 'event_espresso'), |
|
1164 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
|
1163 | + 'title' => __('Pending', 'event_espresso'), |
|
1164 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url), |
|
1165 | 1165 | 'meta' => array( |
1166 | 1166 | 'title' => __('Pending', 'event_espresso'), |
1167 | 1167 | 'target' => '', |
@@ -1171,14 +1171,14 @@ discard block |
||
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | //Registration Overview This Month Not Approved |
1174 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1174 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) { |
|
1175 | 1175 | $admin_bar->add_menu(array( |
1176 | 1176 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
1177 | 1177 | 'parent' => 'espresso-toolbar-registrations-month', |
1178 | - 'title' => __( 'Not Approved', 'event_espresso'), |
|
1179 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
|
1178 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1179 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url), |
|
1180 | 1180 | 'meta' => array( |
1181 | - 'title' => __('Not Approved', 'event_espresso' ), |
|
1181 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1182 | 1182 | 'target' => '', |
1183 | 1183 | 'class' => $menu_class |
1184 | 1184 | ), |
@@ -1187,12 +1187,12 @@ discard block |
||
1187 | 1187 | |
1188 | 1188 | |
1189 | 1189 | //Registration Overview This Month Cancelled |
1190 | - if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1190 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) { |
|
1191 | 1191 | $admin_bar->add_menu(array( |
1192 | 1192 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
1193 | 1193 | 'parent' => 'espresso-toolbar-registrations-month', |
1194 | 1194 | 'title' => __('Cancelled', 'event_espresso'), |
1195 | - 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
|
1195 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url), |
|
1196 | 1196 | 'meta' => array( |
1197 | 1197 | 'title' => __('Cancelled', 'event_espresso'), |
1198 | 1198 | 'target' => '', |
@@ -1202,11 +1202,11 @@ discard block |
||
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | //Extensions & Services |
1205 | - if ( $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1205 | + if ($this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) { |
|
1206 | 1206 | $admin_bar->add_menu(array( |
1207 | 1207 | 'id' => 'espresso-toolbar-extensions-and-services', |
1208 | 1208 | 'parent' => 'espresso-toolbar', |
1209 | - 'title' => __( 'Extensions & Services', 'event_espresso' ), |
|
1209 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1210 | 1210 | 'href' => $extensions_admin_url, |
1211 | 1211 | 'meta' => array( |
1212 | 1212 | 'title' => __('Extensions & Services', 'event_espresso'), |
@@ -1228,8 +1228,8 @@ discard block |
||
1228 | 1228 | * @param array $exclude_array any existing pages being excluded are in this array. |
1229 | 1229 | * @return array |
1230 | 1230 | */ |
1231 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
1232 | - return array_merge( $exclude_array, $this->registry->CFG->core->get_critical_pages_array() ); |
|
1231 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
1232 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | |
@@ -1249,11 +1249,11 @@ discard block |
||
1249 | 1249 | */ |
1250 | 1250 | public function wp_enqueue_scripts() { |
1251 | 1251 | // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
1252 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
1252 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
1253 | 1253 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1254 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
1254 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
1255 | 1255 | // register jQuery Validate |
1256 | - wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE ); |
|
1256 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE); |
|
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * |
|
4 | - * EE_System |
|
5 | - * |
|
6 | - * @package Event Espresso |
|
7 | - * @subpackage core/ |
|
8 | - * @author Brent Christensen, Michael Nelson |
|
9 | - * |
|
10 | - * ------------------------------------------------------------------------ |
|
11 | - */ |
|
3 | + * |
|
4 | + * EE_System |
|
5 | + * |
|
6 | + * @package Event Espresso |
|
7 | + * @subpackage core/ |
|
8 | + * @author Brent Christensen, Michael Nelson |
|
9 | + * |
|
10 | + * ------------------------------------------------------------------------ |
|
11 | + */ |
|
12 | 12 | final class EE_System { |
13 | 13 | |
14 | 14 | |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | |
197 | 197 | |
198 | 198 | /** |
199 | - * detect_if_activation_or_upgrade |
|
200 | - * |
|
201 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | - * and either setting up the DB or setting up maintenance mode etc. |
|
203 | - * |
|
204 | - * @access public |
|
205 | - * @return void |
|
206 | - */ |
|
199 | + * detect_if_activation_or_upgrade |
|
200 | + * |
|
201 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
202 | + * and either setting up the DB or setting up maintenance mode etc. |
|
203 | + * |
|
204 | + * @access public |
|
205 | + * @return void |
|
206 | + */ |
|
207 | 207 | public function detect_if_activation_or_upgrade() { |
208 | 208 | do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
209 | 209 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | $query_params = array( 'page' => 'espresso_about' ); |
513 | 513 | |
514 | 514 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) { |
515 | - $query_params['new_activation'] = TRUE; |
|
515 | + $query_params['new_activation'] = TRUE; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) { |
519 | - $query_params['reactivation'] = TRUE; |
|
519 | + $query_params['reactivation'] = TRUE; |
|
520 | 520 | } |
521 | 521 | $url = add_query_arg( $query_params, admin_url( 'admin.php' ) ); |
522 | 522 | wp_safe_redirect( $url ); |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | |
620 | 620 | |
621 | 621 | /** |
622 | - * _incompatible_addon_error |
|
623 | - * |
|
624 | - * @access public |
|
625 | - * @return void |
|
626 | - */ |
|
622 | + * _incompatible_addon_error |
|
623 | + * |
|
624 | + * @access public |
|
625 | + * @return void |
|
626 | + */ |
|
627 | 627 | private function _incompatible_addon_error() { |
628 | 628 | // get array of classes hooking into here |
629 | 629 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' ); |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | |
746 | 746 | |
747 | 747 | /** |
748 | - * load_controllers |
|
749 | - * |
|
750 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | - * |
|
753 | - * @access public |
|
754 | - * @return void |
|
755 | - */ |
|
748 | + * load_controllers |
|
749 | + * |
|
750 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
751 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
|
752 | + * |
|
753 | + * @access public |
|
754 | + * @return void |
|
755 | + */ |
|
756 | 756 | public function load_controllers() { |
757 | 757 | do_action( 'AHEE__EE_System__load_controllers__start' ); |
758 | 758 | // let's get it started |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | |
770 | 770 | |
771 | 771 | /** |
772 | - * core_loaded_and_ready |
|
773 | - * |
|
774 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | - * |
|
776 | - * @access public |
|
777 | - * @return void |
|
778 | - */ |
|
772 | + * core_loaded_and_ready |
|
773 | + * |
|
774 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
775 | + * |
|
776 | + * @access public |
|
777 | + * @return void |
|
778 | + */ |
|
779 | 779 | public function core_loaded_and_ready() { |
780 | 780 | do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
781 | 781 | do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | |
787 | 787 | |
788 | 788 | /** |
789 | - * initialize |
|
790 | - * |
|
791 | - * this is the best place to begin initializing client code |
|
792 | - * |
|
793 | - * @access public |
|
794 | - * @return void |
|
795 | - */ |
|
789 | + * initialize |
|
790 | + * |
|
791 | + * this is the best place to begin initializing client code |
|
792 | + * |
|
793 | + * @access public |
|
794 | + * @return void |
|
795 | + */ |
|
796 | 796 | public function initialize() { |
797 | 797 | do_action( 'AHEE__EE_System__initialize' ); |
798 | 798 | } |
@@ -800,13 +800,13 @@ discard block |
||
800 | 800 | |
801 | 801 | |
802 | 802 | /** |
803 | - * initialize_last |
|
804 | - * |
|
805 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | - * |
|
807 | - * @access public |
|
808 | - * @return void |
|
809 | - */ |
|
803 | + * initialize_last |
|
804 | + * |
|
805 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
|
806 | + * |
|
807 | + * @access public |
|
808 | + * @return void |
|
809 | + */ |
|
810 | 810 | public function initialize_last() { |
811 | 811 | do_action( 'AHEE__EE_System__initialize_last' ); |
812 | 812 | } |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | |
816 | 816 | |
817 | 817 | /** |
818 | - * set_hooks_for_shortcodes_modules_and_addons |
|
819 | - * |
|
820 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
818 | + * set_hooks_for_shortcodes_modules_and_addons |
|
819 | + * |
|
820 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
821 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | 826 | public function set_hooks_for_shortcodes_modules_and_addons() { |
827 | 827 | // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
828 | 828 | } |
@@ -831,13 +831,13 @@ discard block |
||
831 | 831 | |
832 | 832 | |
833 | 833 | /** |
834 | - * do_not_cache |
|
835 | - * |
|
836 | - * sets no cache headers and defines no cache constants for WP plugins |
|
837 | - * |
|
838 | - * @access public |
|
839 | - * @return void |
|
840 | - */ |
|
834 | + * do_not_cache |
|
835 | + * |
|
836 | + * sets no cache headers and defines no cache constants for WP plugins |
|
837 | + * |
|
838 | + * @access public |
|
839 | + * @return void |
|
840 | + */ |
|
841 | 841 | public static function do_not_cache() { |
842 | 842 | // set no cache constants |
843 | 843 | if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | //Current post |
957 | 957 | global $post; |
958 | 958 | |
959 | - if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
959 | + if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
960 | 960 | //Events Edit Current Event |
961 | 961 | $admin_bar->add_menu(array( |
962 | 962 | 'id' => 'espresso-toolbar-events-edit', |
@@ -32,7 +32,7 @@ |
||
32 | 32 | */ |
33 | 33 | |
34 | 34 | if ( ! class_exists( 'WP_List_Table' )) { |
35 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
35 | + require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | abstract class EE_Admin_List_Table extends WP_List_Table { |
@@ -1,6 +1,7 @@ discard block |
||
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 | 6 | |
6 | 7 | /** |
@@ -362,8 +363,9 @@ discard block |
||
362 | 363 | |
363 | 364 | $sortable = array(); |
364 | 365 | foreach ( $_sortable as $id => $data ) { |
365 | - if ( empty( $data ) ) |
|
366 | - continue; |
|
366 | + if ( empty( $data ) ) { |
|
367 | + continue; |
|
368 | + } |
|
367 | 369 | |
368 | 370 | //fix for offset errors with WP_List_Table default get_columninfo() |
369 | 371 | if ( is_array($data) ) { |
@@ -375,8 +377,9 @@ discard block |
||
375 | 377 | |
376 | 378 | $data = (array) $data; |
377 | 379 | |
378 | - if ( !isset( $data[1] ) ) |
|
379 | - $_data[1] = false; |
|
380 | + if ( !isset( $data[1] ) ) { |
|
381 | + $_data[1] = false; |
|
382 | + } |
|
380 | 383 | |
381 | 384 | |
382 | 385 | $sortable[$id] = $_data; |
@@ -399,11 +402,12 @@ discard block |
||
399 | 402 | $actions = array(); |
400 | 403 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
401 | 404 | foreach ( $this->_views as $view => $args) { |
402 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
403 | - //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
405 | + if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) { |
|
406 | + //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
|
404 | 407 | foreach ( $args['bulk_action'] as $route =>$label ) { |
405 | 408 | if ( $this->_admin_page->check_user_access( $route, true ) ) { |
406 | 409 | $actions[$route] = $label; |
410 | + } |
|
407 | 411 | } |
408 | 412 | } |
409 | 413 | } |
@@ -633,14 +637,12 @@ discard block |
||
633 | 637 | echo '<th scope="row" class="check-column">'; |
634 | 638 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
635 | 639 | echo '</th>'; |
636 | - } |
|
637 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
640 | + } elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
638 | 641 | echo "<td $attributes>"; |
639 | 642 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
640 | 643 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
641 | 644 | echo "</td>"; |
642 | - } |
|
643 | - else { |
|
645 | + } else { |
|
644 | 646 | echo "<td $attributes>"; |
645 | 647 | echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
646 | 648 | echo $this->handle_row_actions( $item, $column_name, $primary ); |
@@ -656,7 +658,7 @@ discard block |
||
656 | 658 | $this->_filters(); |
657 | 659 | echo $this->_get_hidden_fields(); |
658 | 660 | echo '<br class="clear">'; |
659 | - }else{ |
|
661 | + } else{ |
|
660 | 662 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
661 | 663 | foreach($this->_bottom_buttons as $type => $action){ |
662 | 664 | $route = isset( $action['route'] ) ? $action['route'] : ''; |
@@ -1,5 +1,5 @@ discard block |
||
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 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * ------------------------------------------------------------------------ |
32 | 32 | */ |
33 | 33 | |
34 | -if ( ! class_exists( 'WP_List_Table' )) { |
|
35 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
34 | +if ( ! class_exists('WP_List_Table')) { |
|
35 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | abstract class EE_Admin_List_Table extends WP_List_Table { |
@@ -234,16 +234,16 @@ discard block |
||
234 | 234 | * constructor |
235 | 235 | * @param EE_Admin_Page object $admin_page we use this for obtaining everything we need in the list table. |
236 | 236 | */ |
237 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
237 | + public function __construct(EE_Admin_Page $admin_page) { |
|
238 | 238 | $this->_admin_page = $admin_page; |
239 | 239 | $this->_req_data = $this->_admin_page->get_request_data(); |
240 | 240 | $this->_view = $this->_admin_page->get_view(); |
241 | - $this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
241 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
242 | 242 | $this->_current_page = $this->get_pagenum(); |
243 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
244 | - $this->_yes_no = array( __('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
243 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
244 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
245 | 245 | |
246 | - $this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 ); |
|
246 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
247 | 247 | |
248 | 248 | $this->_setup_data(); |
249 | 249 | $this->_add_view_counts(); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $this->_set_properties(); |
254 | 254 | |
255 | 255 | //set primary column |
256 | - add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) ); |
|
256 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
257 | 257 | |
258 | 258 | //set parent defaults |
259 | 259 | parent::__construct($this->_wp_list_args); |
@@ -329,17 +329,17 @@ discard block |
||
329 | 329 | * @return html string |
330 | 330 | */ |
331 | 331 | protected function _get_hidden_fields() { |
332 | - $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
|
333 | - $action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action; |
|
332 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
333 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
334 | 334 | //if action is STILL empty, then we set it to default |
335 | - $action = empty( $action ) ? 'default' : $action; |
|
336 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
337 | - $field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/ |
|
338 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
335 | + $action = empty($action) ? 'default' : $action; |
|
336 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
337 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
338 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
339 | 339 | |
340 | 340 | $bulk_actions = $this->_get_bulk_actions(); |
341 | - foreach ( $bulk_actions as $bulk_action => $label ) { |
|
342 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce ( $bulk_action . '_nonce' ) . '" />' . "\n"; |
|
341 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
342 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $field; |
@@ -369,15 +369,15 @@ discard block |
||
369 | 369 | * |
370 | 370 | * @var array |
371 | 371 | */ |
372 | - $_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen ); |
|
372 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
373 | 373 | |
374 | 374 | $sortable = array(); |
375 | - foreach ( $_sortable as $id => $data ) { |
|
376 | - if ( empty( $data ) ) |
|
375 | + foreach ($_sortable as $id => $data) { |
|
376 | + if (empty($data)) |
|
377 | 377 | continue; |
378 | 378 | |
379 | 379 | //fix for offset errors with WP_List_Table default get_columninfo() |
380 | - if ( is_array($data) ) { |
|
380 | + if (is_array($data)) { |
|
381 | 381 | $_data[0] = key($data); |
382 | 382 | $_data[1] = isset($data[1]) ? $data[1] : false; |
383 | 383 | } else { |
@@ -386,14 +386,14 @@ discard block |
||
386 | 386 | |
387 | 387 | $data = (array) $data; |
388 | 388 | |
389 | - if ( !isset( $data[1] ) ) |
|
389 | + if ( ! isset($data[1])) |
|
390 | 390 | $_data[1] = false; |
391 | 391 | |
392 | 392 | |
393 | 393 | $sortable[$id] = $_data; |
394 | 394 | } |
395 | 395 | $primary = $this->get_primary_column_name(); |
396 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
396 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | * @return string |
403 | 403 | */ |
404 | 404 | protected function get_primary_column_name() { |
405 | - foreach( class_parents( $this ) as $parent ) { |
|
406 | - if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) { |
|
405 | + foreach (class_parents($this) as $parent) { |
|
406 | + if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') { |
|
407 | 407 | return parent::get_primary_column_name(); |
408 | 408 | } |
409 | 409 | } |
@@ -415,10 +415,10 @@ discard block |
||
415 | 415 | * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814) |
416 | 416 | * @return string |
417 | 417 | */ |
418 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
419 | - foreach( class_parents( $this ) as $parent ) { |
|
420 | - if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) { |
|
421 | - return parent::handle_row_actions( $item, $column_name, $primary ); |
|
418 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
419 | + foreach (class_parents($this) as $parent) { |
|
420 | + if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') { |
|
421 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | ''; |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | protected function _get_bulk_actions() { |
437 | 437 | $actions = array(); |
438 | 438 | //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table(); |
439 | - foreach ( $this->_views as $view => $args) { |
|
440 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
439 | + foreach ($this->_views as $view => $args) { |
|
440 | + if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view) |
|
441 | 441 | //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user. |
442 | - foreach ( $args['bulk_action'] as $route =>$label ) { |
|
443 | - if ( $this->_admin_page->check_user_access( $route, true ) ) { |
|
442 | + foreach ($args['bulk_action'] as $route =>$label) { |
|
443 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
444 | 444 | $actions[$route] = $label; |
445 | 445 | } |
446 | 446 | } |
@@ -458,18 +458,18 @@ discard block |
||
458 | 458 | */ |
459 | 459 | private function _filters() { |
460 | 460 | $classname = get_class($this); |
461 | - $filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen ); |
|
461 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen); |
|
462 | 462 | |
463 | - if ( empty( $filters )) { |
|
463 | + if (empty($filters)) { |
|
464 | 464 | return; |
465 | 465 | } |
466 | - foreach ( $filters as $filter ) { |
|
466 | + foreach ($filters as $filter) { |
|
467 | 467 | echo $filter; |
468 | 468 | } |
469 | 469 | //add filter button at end |
470 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />'; |
|
470 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />'; |
|
471 | 471 | //add reset filters button at end |
472 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>'; |
|
472 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>'; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | |
@@ -483,8 +483,8 @@ discard block |
||
483 | 483 | * @param string $column_name |
484 | 484 | * @return string |
485 | 485 | */ |
486 | - public function set_primary_column( $column_name ) { |
|
487 | - return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name; |
|
486 | + public function set_primary_column($column_name) { |
|
487 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | array( |
504 | 504 | 'total_items' => $total_items, |
505 | 505 | 'per_page' => $this->_per_page, |
506 | - 'total_pages' => ceil($total_items / $this->_per_page ) |
|
506 | + 'total_pages' => ceil($total_items / $this->_per_page) |
|
507 | 507 | ) |
508 | 508 | ); |
509 | 509 | } |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string html content for the column |
521 | 521 | */ |
522 | - public function column_default( $item, $column_name ) { |
|
522 | + public function column_default($item, $column_name) { |
|
523 | 523 | /** |
524 | 524 | * Dynamic hook allowing for adding additional column content in this list table. |
525 | 525 | * Note that $this->screen->id is in the format |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * hook prefix ("event-espresso") will be different. |
530 | 530 | * |
531 | 531 | */ |
532 | - do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen ); |
|
532 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * |
546 | 546 | * @var array |
547 | 547 | */ |
548 | - $columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen ); |
|
548 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
549 | 549 | return $columns; |
550 | 550 | } |
551 | 551 | |
@@ -557,18 +557,18 @@ discard block |
||
557 | 557 | $views = $this->get_views(); |
558 | 558 | $assembled_views = ''; |
559 | 559 | |
560 | - if ( empty( $views )) { |
|
560 | + if (empty($views)) { |
|
561 | 561 | return; |
562 | 562 | } |
563 | 563 | echo "<ul class='subsubsub'>\n"; |
564 | - foreach ( $views as $view ) { |
|
565 | - $count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] ) : 0; |
|
566 | - if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) { |
|
567 | - $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
564 | + foreach ($views as $view) { |
|
565 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
566 | + if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) { |
|
567 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | |
571 | - echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : ''; |
|
571 | + echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
572 | 572 | echo "</ul>"; |
573 | 573 | } |
574 | 574 | |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @param object $item The current item |
583 | 583 | */ |
584 | - public function single_row( $item ) { |
|
585 | - $row_class = $this->_get_row_class( $item ); |
|
586 | - echo '<tr class="' . esc_attr( $row_class ) . '">'; |
|
587 | - $this->single_row_columns( $item ); |
|
584 | + public function single_row($item) { |
|
585 | + $row_class = $this->_get_row_class($item); |
|
586 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
587 | + $this->single_row_columns($item); |
|
588 | 588 | echo '</tr>'; |
589 | 589 | } |
590 | 590 | |
@@ -595,13 +595,13 @@ discard block |
||
595 | 595 | * @param object $item the current item |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - protected function _get_row_class( $item ) { |
|
598 | + protected function _get_row_class($item) { |
|
599 | 599 | static $row_class = ''; |
600 | - $row_class = ( $row_class == '' ? 'alternate' : '' ); |
|
600 | + $row_class = ($row_class == '' ? 'alternate' : ''); |
|
601 | 601 | |
602 | 602 | $new_row_class = $row_class; |
603 | 603 | |
604 | - if ( !empty($this->_ajax_sorting_callback) ) { |
|
604 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
605 | 605 | $new_row_class .= ' rowsortable'; |
606 | 606 | } |
607 | 607 | |
@@ -620,13 +620,13 @@ discard block |
||
620 | 620 | |
621 | 621 | public function get_hidden_columns() { |
622 | 622 | $user_id = get_current_user_id(); |
623 | - $has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id); |
|
624 | - if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) { |
|
625 | - update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE); |
|
626 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE ); |
|
623 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
624 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
625 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE); |
|
626 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE); |
|
627 | 627 | } |
628 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
629 | - $saved_columns = (array) get_user_option( $ref, $user_id ); |
|
628 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
629 | + $saved_columns = (array) get_user_option($ref, $user_id); |
|
630 | 630 | return $saved_columns; |
631 | 631 | } |
632 | 632 | |
@@ -641,47 +641,47 @@ discard block |
||
641 | 641 | * |
642 | 642 | * @param object $item The current item |
643 | 643 | */ |
644 | - public function single_row_columns( $item ) { |
|
645 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
644 | + public function single_row_columns($item) { |
|
645 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
646 | 646 | |
647 | 647 | global $wp_version; |
648 | - $use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' ); |
|
648 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
649 | 649 | |
650 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
650 | + foreach ($columns as $column_name => $column_display_name) { |
|
651 | 651 | |
652 | 652 | /** |
653 | 653 | * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
654 | 654 | * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
655 | 655 | */ |
656 | - $hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : ''; |
|
657 | - $style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : ''; |
|
656 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
657 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
658 | 658 | |
659 | - $classes = $column_name . ' column-' . $column_name.$hidden_class; |
|
660 | - if ( $primary == $column_name ) { |
|
659 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
660 | + if ($primary == $column_name) { |
|
661 | 661 | $classes .= ' has-row-actions column-primary'; |
662 | 662 | } |
663 | 663 | |
664 | - $data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
664 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
665 | 665 | |
666 | 666 | $class = "class='$classes'"; |
667 | 667 | |
668 | 668 | $attributes = "$class$style$data"; |
669 | 669 | |
670 | - if ( 'cb' === $column_name ) { |
|
670 | + if ('cb' === $column_name) { |
|
671 | 671 | echo '<th scope="row" class="check-column">'; |
672 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
|
672 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this); |
|
673 | 673 | echo '</th>'; |
674 | 674 | } |
675 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
675 | + elseif (method_exists($this, 'column_'.$column_name)) { |
|
676 | 676 | echo "<td $attributes>"; |
677 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this ); |
|
678 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
677 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this); |
|
678 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
679 | 679 | echo "</td>"; |
680 | 680 | } |
681 | 681 | else { |
682 | 682 | echo "<td $attributes>"; |
683 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this ); |
|
684 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
683 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this); |
|
684 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
685 | 685 | echo "</td>"; |
686 | 686 | } |
687 | 687 | } |
@@ -689,19 +689,19 @@ discard block |
||
689 | 689 | |
690 | 690 | |
691 | 691 | |
692 | - public function extra_tablenav( $which ) { |
|
693 | - if ( $which == 'top' ) { |
|
692 | + public function extra_tablenav($which) { |
|
693 | + if ($which == 'top') { |
|
694 | 694 | $this->_filters(); |
695 | 695 | echo $this->_get_hidden_fields(); |
696 | 696 | echo '<br class="clear">'; |
697 | - }else{ |
|
697 | + } else { |
|
698 | 698 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
699 | - foreach($this->_bottom_buttons as $type => $action){ |
|
700 | - $route = isset( $action['route'] ) ? $action['route'] : ''; |
|
701 | - $extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : ''; |
|
699 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
700 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
701 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
702 | 702 | echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request); |
703 | 703 | } |
704 | - do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen ); |
|
704 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
705 | 705 | echo '</div>'; |
706 | 706 | } |
707 | 707 | //echo $this->_entries_per_page_dropdown; |
@@ -751,13 +751,13 @@ discard block |
||
751 | 751 | * |
752 | 752 | * @return string The assembled action elements container. |
753 | 753 | */ |
754 | - protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) { |
|
754 | + protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') { |
|
755 | 755 | $content = ''; |
756 | - $action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : ''; |
|
757 | - $action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : ''; |
|
758 | - $content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
759 | - $content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this ); |
|
760 | - $content .= ! empty( $container ) ? '</' . $container . '>' : ''; |
|
756 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
757 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
758 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
759 | + $content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this); |
|
760 | + $content .= ! empty($container) ? '</'.$container.'>' : ''; |
|
761 | 761 | return $content; |
762 | 762 | } |
763 | 763 | } |
@@ -594,7 +594,7 @@ |
||
594 | 594 | * @since 4.1 |
595 | 595 | * @access public |
596 | 596 | * |
597 | - * @param object $item The current item |
|
597 | + * @param EE_Message_Template_Group $item The current item |
|
598 | 598 | */ |
599 | 599 | public function single_row( $item ) { |
600 | 600 | $row_class = $this->_get_row_class( $item ); |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EE_Admin_Page_CPT class |
4 | 6 | * |
@@ -231,8 +233,9 @@ discard block |
||
231 | 233 | |
232 | 234 | $containers = array(); |
233 | 235 | |
234 | - if ( empty( $wp_meta_boxes ) ) |
|
235 | - return; |
|
236 | + if ( empty( $wp_meta_boxes ) ) { |
|
237 | + return; |
|
238 | + } |
|
236 | 239 | |
237 | 240 | $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
238 | 241 | |
@@ -336,8 +339,9 @@ discard block |
||
336 | 339 | |
337 | 340 | |
338 | 341 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
339 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
340 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
342 | + if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) { |
|
343 | + add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344 | + } |
|
341 | 345 | |
342 | 346 | //add preview button |
343 | 347 | add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
@@ -347,12 +351,14 @@ discard block |
||
347 | 351 | add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
348 | 352 | |
349 | 353 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
350 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
351 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
354 | + if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) { |
|
355 | + add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
356 | + } |
|
352 | 357 | |
353 | 358 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
354 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
355 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359 | + if ( method_exists( $this, 'edit_form_after_title' ) ) { |
|
360 | + add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
361 | + } |
|
356 | 362 | |
357 | 363 | |
358 | 364 | /** |
@@ -543,7 +549,9 @@ discard block |
||
543 | 549 | |
544 | 550 | |
545 | 551 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
546 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
552 | + if ( !defined('DOING_AUTOSAVE') ) { |
|
553 | + define('DOING_AUTOSAVE', true); |
|
554 | + } |
|
547 | 555 | |
548 | 556 | //if we made it here then the nonce checked out. Let's run our methods and actions |
549 | 557 | if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
@@ -573,8 +581,9 @@ discard block |
||
573 | 581 | protected function _extend_page_config_for_cpt() { |
574 | 582 | |
575 | 583 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
576 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
577 | - return; |
|
584 | + if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) { |
|
585 | + return; |
|
586 | + } |
|
578 | 587 | |
579 | 588 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
580 | 589 | if ( !empty( $this->_cpt_object ) ) { |
@@ -606,8 +615,9 @@ discard block |
||
606 | 615 | } |
607 | 616 | |
608 | 617 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
609 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
610 | - return; |
|
618 | + if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) { |
|
619 | + return; |
|
620 | + } |
|
611 | 621 | |
612 | 622 | |
613 | 623 | $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
@@ -803,8 +813,9 @@ discard block |
||
803 | 813 | public function insert_update( $post_id, $post ) { |
804 | 814 | |
805 | 815 | //make sure that if this is a revision OR trash action that we don't do any updates! |
806 | - if ( isset( $this->_req_data['action'] ) && ( $this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash' ) ) |
|
807 | - return; |
|
816 | + if ( isset( $this->_req_data['action'] ) && ( $this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash' ) ) { |
|
817 | + return; |
|
818 | + } |
|
808 | 819 | |
809 | 820 | //check for autosave and update our req_data property accordingly. |
810 | 821 | /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) { |
@@ -828,8 +839,10 @@ discard block |
||
828 | 839 | } |
829 | 840 | } |
830 | 841 | |
831 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
832 | - return; //TODO we'll remove this after reimplementing autosave in 4.2 |
|
842 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
843 | + return; |
|
844 | + } |
|
845 | + //TODO we'll remove this after reimplementing autosave in 4.2 |
|
833 | 846 | $this->_insert_update_cpt_item( $post_id, $post ); |
834 | 847 | } |
835 | 848 | |
@@ -900,7 +913,9 @@ discard block |
||
900 | 913 | */ |
901 | 914 | public function modify_current_screen() { |
902 | 915 | //ONLY do this if the current page_route IS a cpt route |
903 | - if ( !$this->_cpt_route ) return; |
|
916 | + if ( !$this->_cpt_route ) { |
|
917 | + return; |
|
918 | + } |
|
904 | 919 | //routing things REALLY early b/c this is a cpt admin page |
905 | 920 | set_current_screen( $this->_cpt_routes[$this->_req_action]); |
906 | 921 | $this->_current_screen = get_current_screen(); |
@@ -940,8 +955,9 @@ discard block |
||
940 | 955 | public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
941 | 956 | if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
942 | 957 | $post = get_post( $id ); |
943 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
944 | - $shortlink = home_url('?p=' . $post->ID); |
|
958 | + if ( isset($post->post_type) && $this->page_slug == $post->post_type ) { |
|
959 | + $shortlink = home_url('?p=' . $post->ID); |
|
960 | + } |
|
945 | 961 | } |
946 | 962 | return $shortlink; |
947 | 963 | } |
@@ -954,7 +970,9 @@ discard block |
||
954 | 970 | * @return void |
955 | 971 | */ |
956 | 972 | public function route_admin_request() { |
957 | - if ( $this->_cpt_route ) return; |
|
973 | + if ( $this->_cpt_route ) { |
|
974 | + return; |
|
975 | + } |
|
958 | 976 | try { |
959 | 977 | $this->_route_admin_request(); |
960 | 978 | } catch ( EE_Error $e ) { |
@@ -993,8 +1011,9 @@ discard block |
||
993 | 1011 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
994 | 1012 | |
995 | 1013 | //can't do anything without revision so let's get out if not present |
996 | - if ( empty( $rev_id ) ) |
|
997 | - return $location; |
|
1014 | + if ( empty( $rev_id ) ) { |
|
1015 | + return $location; |
|
1016 | + } |
|
998 | 1017 | |
999 | 1018 | //get rev_post_data |
1000 | 1019 | $rev = get_post($rev_id); |
@@ -1023,8 +1042,9 @@ discard block |
||
1023 | 1042 | */ |
1024 | 1043 | public function modify_edit_post_link( $link, $id, $context ) { |
1025 | 1044 | $post = get_post( $id ); |
1026 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1027 | - return $link; |
|
1045 | + if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) { |
|
1046 | + return $link; |
|
1047 | + } |
|
1028 | 1048 | $query_args = array( |
1029 | 1049 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1030 | 1050 | 'post' => $id |
@@ -1044,8 +1064,9 @@ discard block |
||
1044 | 1064 | */ |
1045 | 1065 | public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
1046 | 1066 | $post = get_post($post_id); |
1047 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1048 | - return $delete_link; |
|
1067 | + if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) { |
|
1068 | + return $delete_link; |
|
1069 | + } |
|
1049 | 1070 | |
1050 | 1071 | return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
1051 | 1072 | } |
@@ -1059,8 +1080,9 @@ discard block |
||
1059 | 1080 | * @return string url to redirect to |
1060 | 1081 | */ |
1061 | 1082 | public function cpt_trash_post_location_redirect( $location, $status ) { |
1062 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1063 | - return $location; |
|
1083 | + if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) { |
|
1084 | + return $location; |
|
1085 | + } |
|
1064 | 1086 | |
1065 | 1087 | $post = get_post( $this->_req_data['post'] ); |
1066 | 1088 | $query_args = array( 'action' => 'default' ); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param object $post The post object of the cpt that was saved. |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - abstract protected function _insert_update_cpt_item( $post_id, $post ); |
|
116 | + abstract protected function _insert_update_cpt_item($post_id, $post); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $post_id The ID of the cpt that was trashed |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - abstract public function trash_cpt_item( $post_id ); |
|
129 | + abstract public function trash_cpt_item($post_id); |
|
130 | 130 | |
131 | 131 | |
132 | 132 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $post_id theID of the cpt that was untrashed |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - abstract public function restore_cpt_item( $post_id ); |
|
140 | + abstract public function restore_cpt_item($post_id); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $post_id the ID of the cpt that was deleted |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - abstract public function delete_cpt_item( $post_id ); |
|
151 | + abstract public function delete_cpt_item($post_id); |
|
152 | 152 | |
153 | 153 | |
154 | 154 | |
@@ -161,32 +161,32 @@ discard block |
||
161 | 161 | */ |
162 | 162 | protected function _before_page_setup() { |
163 | 163 | |
164 | - $page = isset( $this->_req_data['page'] ) ? $this->_req_data['page'] : $this->page_slug; |
|
164 | + $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
165 | 165 | |
166 | - $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes ); |
|
166 | + $this->_cpt_routes = array_merge(array('create_new'=>$this->page_slug, 'edit' => $this->page_slug, 'trash' => $this->page_slug), $this->_cpt_routes); |
|
167 | 167 | |
168 | 168 | //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
169 | - $this->_cpt_object = isset($this->_req_data['action']) && isset( $this->_cpt_routes[$this->_req_data['action']] ) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object( $page ); |
|
169 | + $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) : get_post_type_object($page); |
|
170 | 170 | |
171 | 171 | //tweak pagenow for page loading. |
172 | - if( ! $this->_pagenow_map ) { |
|
172 | + if ( ! $this->_pagenow_map) { |
|
173 | 173 | $this->_pagenow_map = array( |
174 | 174 | 'create_new' => 'post-new.php', |
175 | 175 | 'edit' => 'post.php', |
176 | 176 | 'trash' => 'post.php' |
177 | 177 | ); |
178 | 178 | } |
179 | - add_action( 'current_screen', array( $this, 'modify_pagenow') ); |
|
179 | + add_action('current_screen', array($this, 'modify_pagenow')); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
183 | 183 | //get current page from autosave |
184 | - $current_page = isset( $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] ) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | - $this->_current_page = isset( $this->_req_data['current_page'] ) ? $this->_req_data['current_page'] : $current_page; |
|
184 | + $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] : NULL; |
|
185 | + $this->_current_page = isset($this->_req_data['current_page']) ? $this->_req_data['current_page'] : $current_page; |
|
186 | 186 | |
187 | 187 | |
188 | 188 | //autosave... make sure its only for the correct page |
189 | - if ( !empty($this->_current_page ) && $this->_current_page == $this->page_slug ) { |
|
189 | + if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
190 | 190 | //setup autosave ajax hook |
191 | 191 | //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
192 | 192 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return void |
204 | 204 | */ |
205 | - public function modify_pagenow( $current_screen ) { |
|
205 | + public function modify_pagenow($current_screen) { |
|
206 | 206 | global $pagenow; |
207 | 207 | //possibly reset pagenow. |
208 | - if ( ! empty( $this->_req_data['page'] ) && $this->_req_data['page'] == $this->page_slug && !empty( $this->_req_data['action'] ) && isset( $this->_pagenow_map[$this->_req_data['action'] ] ) ) { |
|
208 | + if ( ! empty($this->_req_data['page']) && $this->_req_data['page'] == $this->page_slug && ! empty($this->_req_data['action']) && isset($this->_pagenow_map[$this->_req_data['action']])) { |
|
209 | 209 | $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
210 | 210 | } |
211 | 211 | } |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically you would send along the id of a metabox container. |
221 | 221 | * @return void |
222 | 222 | */ |
223 | - protected function _register_autosave_containers( $ids ) { |
|
224 | - $this->_autosave_containers = array_merge( $this->_autosave_fields, (array) $ids ); |
|
223 | + protected function _register_autosave_containers($ids) { |
|
224 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | |
237 | 237 | $containers = array(); |
238 | 238 | |
239 | - if ( empty( $wp_meta_boxes ) ) |
|
239 | + if (empty($wp_meta_boxes)) |
|
240 | 240 | return; |
241 | 241 | |
242 | - $current_metaboxes = isset( $wp_meta_boxes[$this->page_slug] ) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
242 | + $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
243 | 243 | |
244 | - foreach ( $current_metaboxes as $box_context ) { |
|
245 | - foreach ( $box_context as $box_details ) { |
|
246 | - foreach ( $box_details as $box ) { |
|
247 | - if ( is_array( $box['callback'] ) && ( $box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks ) ){ |
|
244 | + foreach ($current_metaboxes as $box_context) { |
|
245 | + foreach ($box_context as $box_details) { |
|
246 | + foreach ($box_details as $box) { |
|
247 | + if (is_array($box['callback']) && ($box['callback'][0] instanceof EE_Admin_Page || $box['callback'][0] instanceof EE_Admin_Hooks)) { |
|
248 | 248 | $containers[] = $box['id']; |
249 | 249 | } |
250 | 250 | } |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | - $this->_autosave_containers = array_merge( $this->_autosave_containers, $containers ); |
|
254 | + $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
255 | 255 | |
256 | 256 | //add hidden inputs container |
257 | 257 | $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
@@ -268,13 +268,13 @@ discard block |
||
268 | 268 | wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
269 | 269 | |
270 | 270 | //filter _autosave_containers |
271 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this ); |
|
272 | - $containers = apply_filters( 'FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', $containers, $this ); |
|
271 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', $this->_autosave_containers, $this); |
|
272 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', $containers, $this); |
|
273 | 273 | |
274 | - wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers ); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
274 | + wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
275 | 275 | |
276 | 276 | $unsaved_data_msg = array( |
277 | - 'eventmsg' => sprintf( __("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
277 | + 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
278 | 278 | 'inputChanged' => 0 |
279 | 279 | ); |
280 | 280 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public function load_page_dependencies() { |
287 | 287 | try { |
288 | 288 | $this->_load_page_dependencies(); |
289 | - } catch ( EE_Error $e ) { |
|
289 | + } catch (EE_Error $e) { |
|
290 | 290 | $e->get_error(); |
291 | 291 | } |
292 | 292 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | protected function _load_page_dependencies() { |
303 | 303 | |
304 | 304 | //we only add stuff if this is a cpt_route! |
305 | - if ( !$this->_cpt_route ) { |
|
305 | + if ( ! $this->_cpt_route) { |
|
306 | 306 | parent::_load_page_dependencies(); |
307 | 307 | return; |
308 | 308 | } |
@@ -312,72 +312,72 @@ discard block |
||
312 | 312 | |
313 | 313 | //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
314 | 314 | //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
315 | - add_action('edit_form_after_title', array( $this, 'cpt_post_form_hidden_input') ); |
|
315 | + add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
316 | 316 | |
317 | 317 | //inject our Admin page nav tabs... |
318 | 318 | //let's make sure the nav tabs are set if they aren't already |
319 | 319 | //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
320 | - add_action('post_edit_form_tag', array( $this, 'inject_nav_tabs' ) ); |
|
320 | + add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
321 | 321 | |
322 | 322 | //modify the post_updated messages array |
323 | - add_action('post_updated_messages', array( $this, 'post_update_messages' ), 10 ); |
|
323 | + add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
324 | 324 | |
325 | 325 | //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
326 | - add_filter( 'pre_get_shortlink', array( $this, 'add_shortlink_button_to_editor' ), 10, 4 ); |
|
326 | + add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
327 | 327 | |
328 | 328 | //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
329 | - if ( !empty($this->_labels['publishbox'] ) ) { |
|
329 | + if ( ! empty($this->_labels['publishbox'])) { |
|
330 | 330 | |
331 | - $box_label = is_array( $this->_labels['publishbox'] ) && isset( $this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
331 | + $box_label = is_array($this->_labels['publishbox']) && isset($this->_labels['publishbox'][$this->_req_action]) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
332 | 332 | |
333 | - remove_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
334 | - add_meta_box( 'submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
333 | + remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
334 | + add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | //let's add page_templates metabox if this cpt added support for it. |
338 | - if ( $this->_supports_page_templates($this->_cpt_object->name) ) { |
|
339 | - add_meta_box( 'page_templates', __('Page Template', 'event_espresso' ), array( $this, 'page_template_meta_box' ), $this->_cpt_routes[$this->_req_action], 'side', 'default' ); |
|
338 | + if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
339 | + add_meta_box('page_templates', __('Page Template', 'event_espresso'), array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
340 | 340 | }/**/ |
341 | 341 | |
342 | 342 | |
343 | 343 | //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
344 | - if ( method_exists( $this, 'extra_permalink_field_buttons' ) ) |
|
345 | - add_filter('get_sample_permalink_html', array( $this, 'extra_permalink_field_buttons' ), 10, 4 ); |
|
344 | + if (method_exists($this, 'extra_permalink_field_buttons')) |
|
345 | + add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
346 | 346 | |
347 | 347 | //add preview button |
348 | - add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4 ); |
|
348 | + add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
349 | 349 | |
350 | 350 | |
351 | 351 | //insert our own post_stati dropdown |
352 | - add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown' ), 10 ); |
|
352 | + add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
353 | 353 | |
354 | 354 | //This allows adding additional information to the publish post submitbox on the wp post edit form |
355 | - if ( method_exists( $this, 'extra_misc_actions_publish_box' ) ) |
|
356 | - add_action('post_submitbox_misc_actions', array( $this, 'extra_misc_actions_publish_box' ), 10 ); |
|
355 | + if (method_exists($this, 'extra_misc_actions_publish_box')) |
|
356 | + add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
357 | 357 | |
358 | 358 | //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
359 | - if ( method_exists( $this, 'edit_form_after_title' ) ) |
|
360 | - add_action('edit_form_after_title', array( $this, 'edit_form_after_title' ), 10 ); |
|
359 | + if (method_exists($this, 'edit_form_after_title')) |
|
360 | + add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
365 | 365 | */ |
366 | - add_filter( 'clean_url', array( $this, 'switch_core_wp_urls_with_ours' ), 10, 3 ); |
|
366 | + add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | parent::_load_page_dependencies(); |
370 | 370 | |
371 | 371 | //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
372 | 372 | global $pagenow; |
373 | - do_action( 'load-' . $pagenow ); |
|
373 | + do_action('load-'.$pagenow); |
|
374 | 374 | |
375 | 375 | $this->modify_current_screen(); |
376 | - add_action( 'admin_enqueue_scripts', array( $this, 'setup_autosave_hooks'), 30 ); |
|
376 | + add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
377 | 377 | //we route REALLY early. |
378 | 378 | try { |
379 | 379 | $this->_route_admin_request(); |
380 | - } catch ( EE_Error $e ) { |
|
380 | + } catch (EE_Error $e) { |
|
381 | 381 | $e->get_error(); |
382 | 382 | } |
383 | 383 | } |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * |
397 | 397 | * @return string possibly a new url for our route. |
398 | 398 | */ |
399 | - public function switch_core_wp_urls_with_ours( $good_protocol_url, $original_url, $_context ) { |
|
399 | + public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) { |
|
400 | 400 | $routes_to_match = array( |
401 | 401 | 0 => array( |
402 | 402 | 'edit.php?post_type=espresso_attendees', |
403 | 403 | 'admin.php?page=espresso_registrations&action=contact_list' |
404 | 404 | ), |
405 | 405 | 1 => array( |
406 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
407 | - 'admin.php?page=' . $this->_cpt_object->name |
|
406 | + 'edit.php?post_type='.$this->_cpt_object->name, |
|
407 | + 'admin.php?page='.$this->_cpt_object->name |
|
408 | 408 | ) |
409 | 409 | ); |
410 | 410 | |
411 | - foreach( $routes_to_match as $route_matches ) { |
|
412 | - if ( strpos( $good_protocol_url, $route_matches[0] ) !== false ) { |
|
413 | - return str_replace( $route_matches[0], $route_matches[1], $good_protocol_url ); |
|
411 | + foreach ($routes_to_match as $route_matches) { |
|
412 | + if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
413 | + return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
414 | 414 | |
415 | 415 | } |
416 | 416 | } |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * @param string $cpt_name The cpt slug we're checking on. |
427 | 427 | * @return bool True supported, false not. |
428 | 428 | */ |
429 | - private function _supports_page_templates( $cpt_name ) { |
|
429 | + private function _supports_page_templates($cpt_name) { |
|
430 | 430 | $cpt_args = EE_Register_CPTs::get_CPTs(); |
431 | - $cpt_args = isset( $cpt_args[$cpt_name] ) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | - return ! empty( $cpt_args['page_templates'] ) ? TRUE : FALSE; |
|
431 | + $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
432 | + return ! empty($cpt_args['page_templates']) ? TRUE : FALSE; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -444,9 +444,9 @@ discard block |
||
444 | 444 | public function page_template_meta_box() { |
445 | 445 | global $post; |
446 | 446 | $template = ''; |
447 | - if ( count( get_page_templates( $post ) ) != 0 ) { |
|
448 | - $page_template = get_post_meta( $post->ID, '_wp_page_template', TRUE ); |
|
449 | - $template = !empty( $page_template ) ? $page_template : ''; |
|
447 | + if (count(get_page_templates($post)) != 0) { |
|
448 | + $page_template = get_post_meta($post->ID, '_wp_page_template', TRUE); |
|
449 | + $template = ! empty($page_template) ? $page_template : ''; |
|
450 | 450 | } |
451 | 451 | ?> |
452 | 452 | <p><strong><?php _e('Template') ?></strong></p> |
@@ -470,10 +470,10 @@ discard block |
||
470 | 470 | * @param string $new_slug what the slug is |
471 | 471 | * @return string The new html string for the permalink area |
472 | 472 | */ |
473 | - public function preview_button_html( $return, $id, $new_title, $new_slug ) { |
|
474 | - $post = get_post( $id ); |
|
475 | - if ( 'publish' != get_post_status( $post ) ) { |
|
476 | - $return .= '<span_id="view-post-btn"><a href="' . wp_get_shortlink($id, 'post') . '" class="button button-small">' . __('Preview', 'event_espresso') . '</a></span>' . "\n"; |
|
473 | + public function preview_button_html($return, $id, $new_title, $new_slug) { |
|
474 | + $post = get_post($id); |
|
475 | + if ('publish' != get_post_status($post)) { |
|
476 | + $return .= '<span_id="view-post-btn"><a href="'.wp_get_shortlink($id, 'post').'" class="button button-small">'.__('Preview', 'event_espresso').'</a></span>'."\n"; |
|
477 | 477 | } |
478 | 478 | return $return; |
479 | 479 | } |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | 'cur_status' => $this->_cpt_model_obj->status(), |
494 | 494 | 'statuses' => $statuses, |
495 | 495 | 'cur_status_label' => $cur_status_label, |
496 | - 'localized_status_save' => sprintf( __('Save %s', 'event_espresso'), $cur_status_label ) |
|
496 | + 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label) |
|
497 | 497 | ); |
498 | 498 | |
499 | 499 | //we'll add a trash post status (WP doesn't add one for some reason) |
500 | - if ( $this->_cpt_model_obj->status() == 'trash' ) { |
|
500 | + if ($this->_cpt_model_obj->status() == 'trash') { |
|
501 | 501 | $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
502 | 502 | $statuses['trash'] = __('Trashed', 'event_espresso'); |
503 | 503 | $template_args['statuses'] = $statuses; |
504 | 504 | } |
505 | 505 | |
506 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
507 | - EEH_Template::display_template( $template, $template_args ); |
|
506 | + $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
507 | + EEH_Template::display_template($template, $template_args); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -543,22 +543,22 @@ discard block |
||
543 | 543 | public function do_extra_autosave_stuff() { |
544 | 544 | |
545 | 545 | //next let's check for the autosave nonce (we'll use _verify_nonce ) |
546 | - $nonce = isset( $this->_req_data['autosavenonce'] ) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | - $this->_verify_nonce( $nonce, 'autosave' ); |
|
546 | + $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : NULL; |
|
547 | + $this->_verify_nonce($nonce, 'autosave'); |
|
548 | 548 | |
549 | 549 | |
550 | 550 | //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
551 | - if ( !defined('DOING_AUTOSAVE') ) define('DOING_AUTOSAVE', true); |
|
551 | + if ( ! defined('DOING_AUTOSAVE')) define('DOING_AUTOSAVE', true); |
|
552 | 552 | |
553 | 553 | //if we made it here then the nonce checked out. Let's run our methods and actions |
554 | - if ( method_exists( $this, '_ee_autosave_' . $this->_current_view ) ) { |
|
555 | - call_user_func( array( $this, '_ee_autosave_' . $this->_current_view ) ); |
|
554 | + if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
555 | + call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
|
556 | 556 | } else { |
557 | 557 | $this->_template_args['success'] = TRUE; |
558 | 558 | } |
559 | 559 | |
560 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this ); |
|
561 | - do_action( 'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class( $this ), $this ); |
|
560 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
561 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
|
562 | 562 | |
563 | 563 | //now let's return json |
564 | 564 | $this->_return_json(); |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | protected function _extend_page_config_for_cpt() { |
579 | 579 | |
580 | 580 | //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
581 | - if ( ( isset( $this->_req_data['page'] ) && $this->_req_data['page'] != $this->page_slug ) ) |
|
581 | + if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) |
|
582 | 582 | return; |
583 | 583 | |
584 | 584 | //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
585 | - if ( !empty( $this->_cpt_object ) ) { |
|
586 | - $this->_page_routes = array_merge( array( |
|
585 | + if ( ! empty($this->_cpt_object)) { |
|
586 | + $this->_page_routes = array_merge(array( |
|
587 | 587 | 'create_new' => '_create_new_cpt_item', |
588 | 588 | 'edit' => '_edit_cpt_item' |
589 | - ), $this->_page_routes ); |
|
589 | + ), $this->_page_routes); |
|
590 | 590 | |
591 | 591 | |
592 | - $this->_page_config = array_merge( array( |
|
592 | + $this->_page_config = array_merge(array( |
|
593 | 593 | 'create_new' => array( |
594 | 594 | 'nav' => array( |
595 | 595 | 'label' => $this->_cpt_object->labels->add_new_item, |
@@ -611,23 +611,23 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | //load the next section only if this is a matching cpt route as set in the cpt routes array. |
614 | - if ( !isset( $this->_cpt_routes[$this->_req_action] ) ) |
|
614 | + if ( ! isset($this->_cpt_routes[$this->_req_action])) |
|
615 | 615 | return; |
616 | 616 | |
617 | 617 | |
618 | - $this->_cpt_route = isset( $this->_cpt_routes[$this->_req_action] ) ? TRUE : FALSE; |
|
618 | + $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? TRUE : FALSE; |
|
619 | 619 | //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
620 | 620 | |
621 | 621 | |
622 | - if ( empty( $this->_cpt_object ) ) { |
|
623 | - $msg = sprintf( __('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this) ); |
|
624 | - throw new EE_Error( $msg ); |
|
622 | + if (empty($this->_cpt_object)) { |
|
623 | + $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), $this->page_slug, $this->_req_action, get_class($this)); |
|
624 | + throw new EE_Error($msg); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | |
628 | - if ( $this->_cpt_route ) { |
|
629 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
630 | - $this->_set_model_object( $id ); |
|
628 | + if ($this->_cpt_route) { |
|
629 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
630 | + $this->_set_model_object($id); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | } |
@@ -643,17 +643,17 @@ discard block |
||
643 | 643 | * @param int $id The id to retrieve the model object for. If empty we set a default object. |
644 | 644 | * @return void |
645 | 645 | */ |
646 | - protected function _set_model_object( $id = NULL ) { |
|
646 | + protected function _set_model_object($id = NULL) { |
|
647 | 647 | |
648 | - if ( empty( $this->_cpt_model_names ) || ! isset( $this->_cpt_routes[ $this->_req_action ] ) || ( is_object( $this->_cpt_model_obj ) && $this->_cpt_model_obj->ID() == $id )) { |
|
648 | + if (empty($this->_cpt_model_names) || ! isset($this->_cpt_routes[$this->_req_action]) || (is_object($this->_cpt_model_obj) && $this->_cpt_model_obj->ID() == $id)) { |
|
649 | 649 | //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent. |
650 | 650 | return; |
651 | 651 | } |
652 | 652 | // load CPT object model |
653 | - $model = EE_Registry::instance()->load_model( $this->_cpt_model_names[$this->_req_action] ); |
|
654 | - $this->_cpt_model_obj = ! empty( $id ) ? $model->get_one_by_ID( $id ) : $model->create_default_object(); |
|
653 | + $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
654 | + $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
655 | 655 | //d( $this->_cpt_model_obj ); |
656 | - do_action( 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object' ); |
|
656 | + do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | |
@@ -667,47 +667,47 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function admin_init_global() { |
669 | 669 | |
670 | - $post = isset( $this->_req_data['post'] ) ? get_post( $this->_req_data['post'] ) : NULL; |
|
670 | + $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : NULL; |
|
671 | 671 | |
672 | 672 | //its possible this is a new save so let's catch that instead |
673 | - $post = isset( $this->_req_data['post_ID'] ) ? get_post( $this->_req_data['post_ID'] ) : $post; |
|
673 | + $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
674 | 674 | $post_type = $post ? $post->post_type : false; |
675 | 675 | |
676 | 676 | $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
677 | 677 | |
678 | - $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
678 | + $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : ''; |
|
679 | 679 | |
680 | - add_filter( 'get_delete_post_link', array( $this, 'modify_delete_post_link'), 10, 3 ); |
|
681 | - add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link'), 10, 3 ); |
|
680 | + add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
681 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
682 | 682 | |
683 | 683 | |
684 | - if ( $post_type === $route_to_check ) { |
|
685 | - add_filter('redirect_post_location', array( $this, 'cpt_post_location_redirect'), 10, 2 ); |
|
684 | + if ($post_type === $route_to_check) { |
|
685 | + add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
686 | 686 | //catch trashed wp redirect |
687 | - add_filter('wp_redirect', array( $this, 'cpt_trash_post_location_redirect' ), 10, 2 ); |
|
687 | + add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
691 | - $revision = isset( $this->_req_data['revision'] ) ? $this->_req_data['revision'] : NULL; |
|
691 | + $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
|
692 | 692 | |
693 | 693 | /**var_dump($this->_req_data); |
694 | 694 | exit();/**/ |
695 | 695 | |
696 | - if ( !empty( $revision ) ) { |
|
697 | - $action = isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : NULL; |
|
696 | + if ( ! empty($revision)) { |
|
697 | + $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : NULL; |
|
698 | 698 | |
699 | 699 | //doing a restore? |
700 | - if ( !empty( $action ) && $action == 'restore' ) { |
|
700 | + if ( ! empty($action) && $action == 'restore') { |
|
701 | 701 | |
702 | 702 | //get post for revision |
703 | - $rev_post = get_post( $revision ); |
|
704 | - $rev_parent = get_post( $rev_post->post_parent ); |
|
703 | + $rev_post = get_post($revision); |
|
704 | + $rev_parent = get_post($rev_post->post_parent); |
|
705 | 705 | |
706 | 706 | //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
707 | - if ( $rev_parent && $rev_parent->post_type == $this->page_slug ) { |
|
708 | - add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2 ); |
|
707 | + if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
708 | + add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
709 | 709 | //restores of revisions |
710 | - add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2 ); |
|
710 | + add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
@@ -716,15 +716,15 @@ discard block |
||
716 | 716 | //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
717 | 717 | |
718 | 718 | |
719 | - if ( $post_type && $post_type === $route_to_check ) { |
|
719 | + if ($post_type && $post_type === $route_to_check) { |
|
720 | 720 | //$post_id, $post |
721 | - add_action('save_post', array( $this, 'insert_update'), 10, 2 ); |
|
721 | + add_action('save_post', array($this, 'insert_update'), 10, 2); |
|
722 | 722 | |
723 | 723 | //$post_id |
724 | - add_action('trashed_post', array( $this, 'trash_cpt_item' ), 10 ); |
|
725 | - add_action('trashed_post', array( $this, 'dont_permanently_delete_ee_cpts'), 10 ); |
|
726 | - add_action('untrashed_post', array( $this, 'restore_cpt_item'), 10 ); |
|
727 | - add_action('after_delete_post', array( $this, 'delete_cpt_item'), 10 ); |
|
724 | + add_action('trashed_post', array($this, 'trash_cpt_item'), 10); |
|
725 | + add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
726 | + add_action('untrashed_post', array($this, 'restore_cpt_item'), 10); |
|
727 | + add_action('after_delete_post', array($this, 'delete_cpt_item'), 10); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | } |
@@ -739,15 +739,15 @@ discard block |
||
739 | 739 | * @return void |
740 | 740 | */ |
741 | 741 | public function verify_cpt_object() { |
742 | - $label = !empty( $this->_cpt_object ) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
742 | + $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
743 | 743 | // verify event object |
744 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
745 | - throw new EE_Error( sprintf( __('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso' ), $label ) ); |
|
744 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
745 | + throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', 'event_espresso'), $label)); |
|
746 | 746 | } |
747 | 747 | //if auto-draft then throw an error |
748 | - if ( $this->_cpt_model_obj->get('status') == 'auto-draft' ) { |
|
748 | + if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
749 | 749 | EE_Error::overwrite_errors(); |
750 | - EE_Error::add_error( sprintf( __('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label ), __FILE__, __FUNCTION__, __LINE__ ); |
|
750 | + EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), $label), __FILE__, __FUNCTION__, __LINE__); |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
@@ -776,22 +776,22 @@ discard block |
||
776 | 776 | public function load_global_scripts_styles() { |
777 | 777 | parent::load_global_scripts_styles(); |
778 | 778 | |
779 | - if ( $this->_cpt_model_obj instanceof EE_CPT_Base ) { |
|
779 | + if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
780 | 780 | //setup custom post status object for localize script but only if we've got a cpt object |
781 | 781 | $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
782 | 782 | |
783 | - if ( !empty($statuses) ) { |
|
783 | + if ( ! empty($statuses)) { |
|
784 | 784 | //get ALL statuses! |
785 | 785 | $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
786 | 786 | //setup object |
787 | 787 | $ee_cpt_statuses = array(); |
788 | - foreach ( $statuses as $status => $label ) { |
|
788 | + foreach ($statuses as $status => $label) { |
|
789 | 789 | $ee_cpt_statuses[$status] = array( |
790 | 790 | 'label' => $label, |
791 | - 'save_label' => sprintf( __('Save as %s', 'event_espresso'), $label ) |
|
791 | + 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label) |
|
792 | 792 | ); |
793 | 793 | } |
794 | - wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses ); |
|
794 | + wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | } |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | * @param WP_Post $post Post object from WP |
806 | 806 | * @return void |
807 | 807 | */ |
808 | - public function insert_update( $post_id, $post ) { |
|
808 | + public function insert_update($post_id, $post) { |
|
809 | 809 | |
810 | 810 | //make sure that if this is a revision OR trash action that we don't do any updates! |
811 | - if ( isset( $this->_req_data['action'] ) && ( $this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash' ) ) |
|
811 | + if (isset($this->_req_data['action']) && ($this->_req_data['action'] == 'restore' || $this->_req_data['action'] == 'trash')) |
|
812 | 812 | return; |
813 | 813 | |
814 | 814 | //check for autosave and update our req_data property accordingly. |
@@ -823,19 +823,19 @@ discard block |
||
823 | 823 | }/**/ //TODO reactivate after autosave is implemented in 4.2 |
824 | 824 | |
825 | 825 | //take care of updating any selected page_template IF this cpt supports it. |
826 | - if ( $this->_supports_page_templates($post->post_type ) && !empty( $this->_req_data['page_template'] ) ) { |
|
826 | + if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
827 | 827 | $post->page_template = $this->_req_data['page_template']; |
828 | - $page_templates = wp_get_theme()->get_page_templates( $post ); |
|
829 | - if ( 'default' != $this->_req_data['page_template'] && ! isset( $page_templates[ $this->_req_data['page_template'] ] ) ) { |
|
830 | - EE_Error::add_error( __('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
828 | + $page_templates = wp_get_theme()->get_page_templates($post); |
|
829 | + if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
830 | + EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
831 | 831 | } else { |
832 | - update_post_meta( $post_id, '_wp_page_template', $this->_req_data['page_template'] ); |
|
832 | + update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | |
836 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
836 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
837 | 837 | return; //TODO we'll remove this after reimplementing autosave in 4.2 |
838 | - $this->_insert_update_cpt_item( $post_id, $post ); |
|
838 | + $this->_insert_update_cpt_item($post_id, $post); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | * @param int $post_id ID of the post |
849 | 849 | * @return void |
850 | 850 | */ |
851 | - public function dont_permanently_delete_ee_cpts( $post_id ) { |
|
852 | - delete_post_meta( $post_id, '_wp_trash_meta_status' ); |
|
851 | + public function dont_permanently_delete_ee_cpts($post_id) { |
|
852 | + delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
853 | 853 | delete_post_meta($post_id, '_wp_trash_meta_time'); |
854 | 854 | |
855 | 855 | //our cpts may have comments so let's take care of that too |
@@ -868,14 +868,14 @@ discard block |
||
868 | 868 | * @param int $revision_id ID of revision being restored |
869 | 869 | * @return void |
870 | 870 | */ |
871 | - public function restore_revision( $post_id, $revision_id ) { |
|
872 | - $this->_restore_cpt_item( $post_id, $revision_id ); |
|
871 | + public function restore_revision($post_id, $revision_id) { |
|
872 | + $this->_restore_cpt_item($post_id, $revision_id); |
|
873 | 873 | |
874 | 874 | //global action |
875 | - do_action( 'AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
875 | + do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
876 | 876 | |
877 | 877 | //class specific action so you can limit hooking into a specific page. |
878 | - do_action( 'AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id ); |
|
878 | + do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * @param int $revision_id ID of revision for item |
887 | 887 | * @return void |
888 | 888 | */ |
889 | - abstract protected function _restore_cpt_item( $post_id, $revision_id ); |
|
889 | + abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
890 | 890 | |
891 | 891 | |
892 | 892 | |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | */ |
906 | 906 | public function modify_current_screen() { |
907 | 907 | //ONLY do this if the current page_route IS a cpt route |
908 | - if ( !$this->_cpt_route ) return; |
|
908 | + if ( ! $this->_cpt_route) return; |
|
909 | 909 | //routing things REALLY early b/c this is a cpt admin page |
910 | - set_current_screen( $this->_cpt_routes[$this->_req_action]); |
|
910 | + set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
911 | 911 | $this->_current_screen = get_current_screen(); |
912 | 912 | $this->_current_screen->base = 'event-espresso'; |
913 | 913 | $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $title The new title (or existing if there is no editor_title defined) |
929 | 929 | * @return string |
930 | 930 | */ |
931 | - public function add_custom_editor_default_title( $title ) { |
|
932 | - return isset( $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] ) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
931 | + public function add_custom_editor_default_title($title) { |
|
932 | + return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] : $title; |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | |
@@ -942,11 +942,11 @@ discard block |
||
942 | 942 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
943 | 943 | * @return string |
944 | 944 | */ |
945 | - public function add_shortlink_button_to_editor( $shortlink, $id, $context, $allow_slugs ) { |
|
946 | - if ( !empty( $id ) && '' != get_option('permalink_structure') ) { |
|
947 | - $post = get_post( $id ); |
|
948 | - if ( isset($post->post_type) && $this->page_slug == $post->post_type ) |
|
949 | - $shortlink = home_url('?p=' . $post->ID); |
|
945 | + public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) { |
|
946 | + if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
947 | + $post = get_post($id); |
|
948 | + if (isset($post->post_type) && $this->page_slug == $post->post_type) |
|
949 | + $shortlink = home_url('?p='.$post->ID); |
|
950 | 950 | } |
951 | 951 | return $shortlink; |
952 | 952 | } |
@@ -959,10 +959,10 @@ discard block |
||
959 | 959 | * @return void |
960 | 960 | */ |
961 | 961 | public function route_admin_request() { |
962 | - if ( $this->_cpt_route ) return; |
|
962 | + if ($this->_cpt_route) return; |
|
963 | 963 | try { |
964 | 964 | $this->_route_admin_request(); |
965 | - } catch ( EE_Error $e ) { |
|
965 | + } catch (EE_Error $e) { |
|
966 | 966 | $e->get_error(); |
967 | 967 | } |
968 | 968 | } |
@@ -975,12 +975,12 @@ discard block |
||
975 | 975 | * @return string html |
976 | 976 | */ |
977 | 977 | public function cpt_post_form_hidden_input() { |
978 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
978 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
|
979 | 979 | |
980 | 980 | //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
981 | 981 | echo '<div id="ee-cpt-hidden-inputs">'; |
982 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
983 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
982 | + echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
983 | + echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
|
984 | 984 | echo '</div>'; |
985 | 985 | } |
986 | 986 | |
@@ -993,12 +993,12 @@ discard block |
||
993 | 993 | * @param int $status Status for http header |
994 | 994 | * @return string new (or original) url to redirect to. |
995 | 995 | */ |
996 | - public function revision_redirect( $location, $status ) { |
|
996 | + public function revision_redirect($location, $status) { |
|
997 | 997 | //get revision |
998 | 998 | $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : NULL; |
999 | 999 | |
1000 | 1000 | //can't do anything without revision so let's get out if not present |
1001 | - if ( empty( $rev_id ) ) |
|
1001 | + if (empty($rev_id)) |
|
1002 | 1002 | return $location; |
1003 | 1003 | |
1004 | 1004 | //get rev_post_data |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | 'message' => 5 |
1013 | 1013 | ); |
1014 | 1014 | |
1015 | - $this->_process_notices( $query_args, TRUE ); |
|
1016 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1015 | + $this->_process_notices($query_args, TRUE); |
|
1016 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | |
@@ -1026,16 +1026,16 @@ discard block |
||
1026 | 1026 | * @param string $context optional, defaults to display. How to write the '&' |
1027 | 1027 | * @return string the link |
1028 | 1028 | */ |
1029 | - public function modify_edit_post_link( $link, $id, $context ) { |
|
1030 | - $post = get_post( $id ); |
|
1031 | - if ( !isset( $this->_req_data['action'] ) || !isset( $this->_cpt_routes[$this->_req_data['action']] ) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) |
|
1029 | + public function modify_edit_post_link($link, $id, $context) { |
|
1030 | + $post = get_post($id); |
|
1031 | + if ( ! isset($this->_req_data['action']) || ! isset($this->_cpt_routes[$this->_req_data['action']]) || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
1032 | 1032 | return $link; |
1033 | 1033 | $query_args = array( |
1034 | 1034 | 'action' => isset($this->_cpt_edit_routes[$post->post_type]) ? $this->_cpt_edit_routes[$post->post_type] : 'edit', |
1035 | 1035 | 'post' => $id |
1036 | 1036 | ); |
1037 | 1037 | |
1038 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1038 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | |
@@ -1047,12 +1047,12 @@ discard block |
||
1047 | 1047 | * @param bool $force_delete whether this is forcing a hard delete instead of trash |
1048 | 1048 | * @return string new delete link |
1049 | 1049 | */ |
1050 | - public function modify_delete_post_link( $delete_link, $post_id, $force_delete ) { |
|
1050 | + public function modify_delete_post_link($delete_link, $post_id, $force_delete) { |
|
1051 | 1051 | $post = get_post($post_id); |
1052 | - if ( !isset( $this->_req_data['action'] ) || ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] ) ) |
|
1052 | + if ( ! isset($this->_req_data['action']) || (isset($this->_cpt_routes[$this->_req_data['action']]) && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])) |
|
1053 | 1053 | return $delete_link; |
1054 | 1054 | |
1055 | - return add_query_arg( array('current_route' => 'trash' ), $delete_link ); |
|
1055 | + return add_query_arg(array('current_route' => 'trash'), $delete_link); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | |
@@ -1063,16 +1063,16 @@ discard block |
||
1063 | 1063 | * @param string $status status |
1064 | 1064 | * @return string url to redirect to |
1065 | 1065 | */ |
1066 | - public function cpt_trash_post_location_redirect( $location, $status ) { |
|
1067 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] !== 'trash' && empty( $this->_req_data['post'] ) ) |
|
1066 | + public function cpt_trash_post_location_redirect($location, $status) { |
|
1067 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) |
|
1068 | 1068 | return $location; |
1069 | 1069 | |
1070 | - $post = get_post( $this->_req_data['post'] ); |
|
1071 | - $query_args = array( 'action' => 'default' ); |
|
1070 | + $post = get_post($this->_req_data['post']); |
|
1071 | + $query_args = array('action' => 'default'); |
|
1072 | 1072 | $this->_cpt_object = get_post_type_object($post->post_type); |
1073 | - EE_Error::add_success( sprintf( __('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name) ); |
|
1074 | - $this->_process_notices( $query_args, TRUE ); |
|
1075 | - return self::add_query_args_and_nonce( $query_args, $this->_admin_base_url ); |
|
1073 | + EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name)); |
|
1074 | + $this->_process_notices($query_args, TRUE); |
|
1075 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1076 | 1076 | } |
1077 | 1077 | |
1078 | 1078 | |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * @param string $post_id This is the 'ID' value of the wp_posts table |
1088 | 1088 | * @return string the new location to redirect to |
1089 | 1089 | */ |
1090 | - public function cpt_post_location_redirect( $location, $post_id ) { |
|
1090 | + public function cpt_post_location_redirect($location, $post_id) { |
|
1091 | 1091 | //we DO have a match so let's setup the url |
1092 | 1092 | |
1093 | 1093 | //we have to get the post to determine our route |
@@ -1095,14 +1095,14 @@ discard block |
||
1095 | 1095 | $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
1096 | 1096 | |
1097 | 1097 | //shared query_args |
1098 | - $query_args = array( 'action' => $edit_route, 'post' => $post_id ); |
|
1098 | + $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
1099 | 1099 | $admin_url = $this->_admin_base_url; |
1100 | 1100 | // $append = ''; |
1101 | 1101 | |
1102 | - if ( isset( $this->_req_data['save'] ) || isset( $this->_req_data['publish'] ) ) { |
|
1103 | - $status = get_post_status( $post_id ); |
|
1104 | - if ( isset( $this->_req_data['publish'] ) ) { |
|
1105 | - switch ( $status ) { |
|
1102 | + if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
1103 | + $status = get_post_status($post_id); |
|
1104 | + if (isset($this->_req_data['publish'])) { |
|
1105 | + switch ($status) { |
|
1106 | 1106 | case 'pending': |
1107 | 1107 | $message = 8; |
1108 | 1108 | break; |
@@ -1115,13 +1115,13 @@ discard block |
||
1115 | 1115 | } else { |
1116 | 1116 | $message = 'draft' == $status ? 10 : 1; |
1117 | 1117 | } |
1118 | - } else if ( isset( $this->_req_data['addmeta']) && $this->_req_data['addmeta'] ) { |
|
1118 | + } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
1119 | 1119 | $message = 2; |
1120 | 1120 | // $append = '#postcustom'; |
1121 | - } else if ( isset( $this->_req_data['deletemeta']) && $this->_req_data['deletemeta'] ) { |
|
1121 | + } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
1122 | 1122 | $message = 3; |
1123 | 1123 | // $append = '#postcustom'; |
1124 | - } elseif ( $this->_req_data['action'] == 'post-quickpress-save-cont' ) { |
|
1124 | + } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
1125 | 1125 | $message = 7; |
1126 | 1126 | } else { |
1127 | 1127 | $message = 4; |
@@ -1129,12 +1129,12 @@ discard block |
||
1129 | 1129 | |
1130 | 1130 | //change the message if the post type is not viewable on the frontend |
1131 | 1131 | $this->_cpt_object = get_post_type_object($post->post_type); |
1132 | - $message = $message === 1 && !$this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1132 | + $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
1133 | 1133 | |
1134 | - $query_args = array_merge( array( 'message' => $message ), $query_args ); |
|
1134 | + $query_args = array_merge(array('message' => $message), $query_args); |
|
1135 | 1135 | |
1136 | - $this->_process_notices( $query_args, TRUE ); |
|
1137 | - return self::add_query_args_and_nonce( $query_args, $admin_url ); |
|
1136 | + $this->_process_notices($query_args, TRUE); |
|
1137 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
1138 | 1138 | } |
1139 | 1139 | |
1140 | 1140 | |
@@ -1166,10 +1166,10 @@ discard block |
||
1166 | 1166 | * @param array $messages the original messages array |
1167 | 1167 | * @return array the new messages array |
1168 | 1168 | */ |
1169 | - public function post_update_messages( $messages ) { |
|
1169 | + public function post_update_messages($messages) { |
|
1170 | 1170 | global $post; |
1171 | - $id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1172 | - $id = empty( $id ) && is_object( $post ) ? $post->ID : NULL; |
|
1171 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1172 | + $id = empty($id) && is_object($post) ? $post->ID : NULL; |
|
1173 | 1173 | |
1174 | 1174 | // $post_type = $post ? $post->post_type : false; |
1175 | 1175 | |
@@ -1182,9 +1182,9 @@ discard block |
||
1182 | 1182 | 0 => '', //Unused. Messages start at index 1. |
1183 | 1183 | |
1184 | 1184 | 1 => sprintf( |
1185 | - __( '%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1185 | + __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
1186 | 1186 | $this->_cpt_object->labels->singular_name, |
1187 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1187 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1188 | 1188 | '</a>' |
1189 | 1189 | ), |
1190 | 1190 | |
@@ -1192,38 +1192,38 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | 3 => __('Custom field deleted.'), |
1194 | 1194 | |
1195 | - 4 => sprintf( __( '%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1195 | + 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1196 | 1196 | |
1197 | - 5 => isset( $_GET['revision'] ) ? sprintf( __('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title( (int) $_GET['revision'], FALSE ) ) : FALSE, |
|
1197 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], FALSE)) : FALSE, |
|
1198 | 1198 | |
1199 | 1199 | 6 => sprintf( |
1200 | - __( '%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1200 | + __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
1201 | 1201 | $this->_cpt_object->labels->singular_name, |
1202 | - '<a href="' . esc_url( get_permalink( $id )) . '">', |
|
1202 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
1203 | 1203 | '</a>' |
1204 | 1204 | ), |
1205 | 1205 | |
1206 | - 7 => sprintf( __( '%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name ), |
|
1206 | + 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
1207 | 1207 | |
1208 | 1208 | 8 => sprintf( |
1209 | 1209 | __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
1210 | 1210 | $this->_cpt_object->labels->singular_name, |
1211 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) . '">', |
|
1211 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
|
1212 | 1212 | '</a>' |
1213 | 1213 | ), |
1214 | 1214 | |
1215 | 1215 | 9 => sprintf( |
1216 | - __( '%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1216 | + __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
1217 | 1217 | $this->_cpt_object->labels->singular_name, |
1218 | - '<strong>' . date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date )) . '</strong>', |
|
1219 | - '<a target="_blank" href="' . esc_url( get_permalink( $id )), |
|
1218 | + '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
1219 | + '<a target="_blank" href="'.esc_url(get_permalink($id)), |
|
1220 | 1220 | '</a>' |
1221 | 1221 | ), |
1222 | 1222 | |
1223 | 1223 | 10 => sprintf( |
1224 | 1224 | __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
1225 | 1225 | $this->_cpt_object->labels->singular_name, |
1226 | - '<a target="_blank" href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $id ))) , |
|
1226 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
1227 | 1227 | '</a>' |
1228 | 1228 | ) |
1229 | 1229 | ); |
@@ -1250,24 +1250,24 @@ discard block |
||
1250 | 1250 | $post_type_object = $this->_cpt_object; |
1251 | 1251 | $title = $post_type_object->labels->add_new_item; |
1252 | 1252 | $editing = TRUE; |
1253 | - wp_enqueue_script( 'autosave' ); |
|
1254 | - $post = $post = get_default_post_to_edit( $this->_cpt_routes[$this->_req_action], TRUE ); |
|
1253 | + wp_enqueue_script('autosave'); |
|
1254 | + $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], TRUE); |
|
1255 | 1255 | $post_ID = $post->ID; |
1256 | 1256 | $is_IE = $is_IE; |
1257 | 1257 | |
1258 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1258 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1259 | 1259 | |
1260 | 1260 | //modify the default editor title field with default title. |
1261 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1261 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1262 | 1262 | |
1263 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1263 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | |
1267 | 1267 | |
1268 | 1268 | |
1269 | 1269 | public function add_new_admin_page_global() { |
1270 | - $admin_page = !empty( $this->_req_data['post'] ) ? 'post-php' : 'post-new-php'; |
|
1270 | + $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
1271 | 1271 | ?> |
1272 | 1272 | <script type="text/javascript"> |
1273 | 1273 | adminpage = '<?php echo $admin_page; ?>'; |
@@ -1289,16 +1289,16 @@ discard block |
||
1289 | 1289 | */ |
1290 | 1290 | protected function _edit_cpt_item() { |
1291 | 1291 | global $post, $title, $is_IE, $post_type, $post_type_object; |
1292 | - $post_id = isset( $this->_req_data['post'] ) ? $this->_req_data['post'] : NULL; |
|
1293 | - $post = !empty( $post_id ) ? get_post( $post_id, OBJECT, 'edit' ) : NULL; |
|
1292 | + $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : NULL; |
|
1293 | + $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : NULL; |
|
1294 | 1294 | |
1295 | - if ( empty ( $post ) ) { |
|
1296 | - wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') ); |
|
1295 | + if (empty ($post)) { |
|
1296 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | - if ( ! empty( $_GET['get-post-lock'] ) ) { |
|
1300 | - wp_set_post_lock( $post_id ); |
|
1301 | - wp_redirect( get_edit_post_link( $post_id, 'url' ) ); |
|
1299 | + if ( ! empty($_GET['get-post-lock'])) { |
|
1300 | + wp_set_post_lock($post_id); |
|
1301 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
1302 | 1302 | exit(); |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1310,32 +1310,32 @@ discard block |
||
1310 | 1310 | $post_type_object = $this->_cpt_object; |
1311 | 1311 | $is_IE = $is_IE; |
1312 | 1312 | |
1313 | - if ( ! wp_check_post_lock( $post->ID ) ) { |
|
1314 | - $active_post_lock = wp_set_post_lock( $post->ID ); |
|
1313 | + if ( ! wp_check_post_lock($post->ID)) { |
|
1314 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
1315 | 1315 | //wp_enqueue_script('autosave'); |
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | $title = $this->_cpt_object->labels->edit_item; |
1319 | 1319 | |
1320 | - add_action('admin_footer', '_admin_notice_post_locked' ); |
|
1320 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
1321 | 1321 | |
1322 | - if ( isset( $this->_cpt_routes[$this->_req_data['action']] ) && !isset( $this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']] ) ) { |
|
1323 | - $create_new_action = apply_filters( 'FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this ); |
|
1322 | + if (isset($this->_cpt_routes[$this->_req_data['action']]) && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])) { |
|
1323 | + $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', 'create_new', $this); |
|
1324 | 1324 | |
1325 | - $post_new_file = EE_Admin_Page::add_query_args_and_nonce( array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php' ); |
|
1325 | + $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array('action' => $create_new_action, 'page' => $this->page_slug), 'admin.php'); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | - if ( post_type_supports($this->_cpt_routes[$this->_req_action], 'comments') ) { |
|
1328 | + if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
1329 | 1329 | wp_enqueue_script('admin-comments'); |
1330 | 1330 | enqueue_comment_hotkeys_js(); |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - add_action( 'admin_print_styles', array( $this, 'add_new_admin_page_global' ) ); |
|
1333 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
1334 | 1334 | |
1335 | 1335 | //modify the default editor title field with default title. |
1336 | - add_filter('enter_title_here', array( $this, 'add_custom_editor_default_title' ), 10 ); |
|
1336 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
1337 | 1337 | |
1338 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
1338 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
1339 | 1339 | |
1340 | 1340 | } |
1341 | 1341 |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * EE_Admin_Page_CPT class |
|
4 | - * |
|
5 | - * This class is for child classes that utilize core WP CPT views for add/edit pages. All you have to do is extend this class instead of the usual EE_Admin_Page class for your child. |
|
6 | - * |
|
7 | - * Please not the following caveats: |
|
8 | - * |
|
9 | - * 1. When using add_meta_box() - it must use $this->wp_page_slug as the screen_id for the page NOT $this->_current_screen->id. This is b/c there is a bug with how WP renders its custom post type pages that doesn't accept the default current_screen for metaboxes. |
|
10 | - * |
|
11 | - * 2. the same is true for any help_tabs or screen_options you want to add to custom post type views. |
|
12 | - * |
|
13 | - * 3. it is EXPECTED that $this->page_slug will be IDENTICAL to what slug/id was used when doing register_post_type(). So for instance, if you registered a "books" post type then $this->page_slug = 'espresso_books' would NOT be valid. So the correct id for the new post type would be "espresso_books". Remember, you can still use something totally different for front-end rewrite slugs in your configuration array for the register post type. |
|
14 | - * |
|
15 | - * @package Event Espresso |
|
16 | - * @subpackage includes/core/admin/EE_Admin_Page.core.php |
|
17 | - * @abstract |
|
18 | - * @author Darren Ethier |
|
19 | - * |
|
20 | - */ |
|
3 | + * EE_Admin_Page_CPT class |
|
4 | + * |
|
5 | + * This class is for child classes that utilize core WP CPT views for add/edit pages. All you have to do is extend this class instead of the usual EE_Admin_Page class for your child. |
|
6 | + * |
|
7 | + * Please not the following caveats: |
|
8 | + * |
|
9 | + * 1. When using add_meta_box() - it must use $this->wp_page_slug as the screen_id for the page NOT $this->_current_screen->id. This is b/c there is a bug with how WP renders its custom post type pages that doesn't accept the default current_screen for metaboxes. |
|
10 | + * |
|
11 | + * 2. the same is true for any help_tabs or screen_options you want to add to custom post type views. |
|
12 | + * |
|
13 | + * 3. it is EXPECTED that $this->page_slug will be IDENTICAL to what slug/id was used when doing register_post_type(). So for instance, if you registered a "books" post type then $this->page_slug = 'espresso_books' would NOT be valid. So the correct id for the new post type would be "espresso_books". Remember, you can still use something totally different for front-end rewrite slugs in your configuration array for the register post type. |
|
14 | + * |
|
15 | + * @package Event Espresso |
|
16 | + * @subpackage includes/core/admin/EE_Admin_Page.core.php |
|
17 | + * @abstract |
|
18 | + * @author Darren Ethier |
|
19 | + * |
|
20 | + */ |
|
21 | 21 | abstract class EE_Admin_Page_CPT extends EE_Admin_Page { |
22 | 22 | |
23 | 23 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | /** |
81 | - * @var EE_CPT_Base |
|
82 | - */ |
|
81 | + * @var EE_CPT_Base |
|
82 | + */ |
|
83 | 83 | protected $_cpt_model_obj = FALSE; |
84 | 84 | |
85 | 85 |