@@ -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 | * |
4 | 6 | * Class EE_Log |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Log |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return EE_Log |
63 | 63 | */ |
64 | 64 | public static function instance() { |
65 | - if ( ! self::$_instance instanceof EE_Log ) { |
|
65 | + if ( ! self::$_instance instanceof EE_Log) { |
|
66 | 66 | self::$_instance = new self(); |
67 | 67 | } |
68 | 68 | return self::$_instance; |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | 76 | |
77 | - if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
77 | + if ( ! EE_Registry::instance()->CFG->admin->use_full_logging && ! EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
78 | 78 | return; |
79 | 79 | } |
80 | 80 | |
81 | - $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS; |
|
81 | + $this->_logs_folder = EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS; |
|
82 | 82 | $this->_log_file = EE_Registry::instance()->CFG->admin->log_file_name(); |
83 | 83 | $this->_log = ''; |
84 | 84 | $this->_debug_file = EE_Registry::instance()->CFG->admin->debug_file_name(); |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | $this->_remote_logging_url = EE_Registry::instance()->CFG->admin->remote_logging_url; |
87 | 87 | $this->_remote_log = ''; |
88 | 88 | |
89 | - add_action( 'admin_init', array( $this, 'verify_filesystem' ), -10 ); |
|
90 | - add_action( 'AHEE_log', array( $this, 'log' ), 10, 4 ); |
|
91 | - if ( EE_Registry::instance()->CFG->admin->use_full_logging ) { |
|
92 | - add_action( 'shutdown', array( $this, 'write_log' ), 9999 ); |
|
89 | + add_action('admin_init', array($this, 'verify_filesystem'), -10); |
|
90 | + add_action('AHEE_log', array($this, 'log'), 10, 4); |
|
91 | + if (EE_Registry::instance()->CFG->admin->use_full_logging) { |
|
92 | + add_action('shutdown', array($this, 'write_log'), 9999); |
|
93 | 93 | // if WP_DEBUG |
94 | - add_action( 'shutdown', array( $this, 'write_debug' ), 9999 ); |
|
94 | + add_action('shutdown', array($this, 'write_debug'), 9999); |
|
95 | 95 | } |
96 | - if ( EE_Registry::instance()->CFG->admin->use_remote_logging ) { |
|
97 | - add_action( 'shutdown', array( $this, 'send_log' ), 9999 ); |
|
96 | + if (EE_Registry::instance()->CFG->admin->use_remote_logging) { |
|
97 | + add_action('shutdown', array($this, 'send_log'), 9999); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function verify_filesystem() { |
110 | 110 | try { |
111 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_log_file ); |
|
112 | - EEH_File::ensure_file_exists_and_is_writable( $this->_logs_folder . $this->_debug_file ); |
|
113 | - EEH_File::add_htaccess_deny_from_all( $this->_logs_folder ); |
|
114 | - } catch( EE_Error $e ){ |
|
115 | - EE_Error::add_error( sprintf( __( 'Event Espresso logging could not be setup because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_log_file); |
|
112 | + EEH_File::ensure_file_exists_and_is_writable($this->_logs_folder.$this->_debug_file); |
|
113 | + EEH_File::add_htaccess_deny_from_all($this->_logs_folder); |
|
114 | + } catch (EE_Error $e) { |
|
115 | + EE_Error::add_error(sprintf(__('Event Espresso logging could not be setup because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
116 | 116 | return; |
117 | 117 | } |
118 | 118 | } |
@@ -129,15 +129,15 @@ discard block |
||
129 | 129 | * @param string $type |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - private function _format_message( $file = '', $function = '', $message = '', $type = '' ) { |
|
133 | - $msg = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
134 | - $msg .= '[' . current_time( 'mysql' ) . '] '; |
|
135 | - $msg .= ! empty( $file ) ? basename( $file ) : ''; |
|
136 | - $msg .= ! empty( $file ) && ! empty( $function ) ? ' -> ' : ''; |
|
137 | - $msg .= ! empty( $function ) ? $function . '()' : ''; |
|
132 | + private function _format_message($file = '', $function = '', $message = '', $type = '') { |
|
133 | + $msg = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
134 | + $msg .= '['.current_time('mysql').'] '; |
|
135 | + $msg .= ! empty($file) ? basename($file) : ''; |
|
136 | + $msg .= ! empty($file) && ! empty($function) ? ' -> ' : ''; |
|
137 | + $msg .= ! empty($function) ? $function.'()' : ''; |
|
138 | 138 | $msg .= PHP_EOL; |
139 | - $type = ! empty( $type ) ? $type : 'log message'; |
|
140 | - $msg .= ! empty( $message ) ? "\t" . '[' . $type . '] ' . $message . PHP_EOL : ''; |
|
139 | + $type = ! empty($type) ? $type : 'log message'; |
|
140 | + $msg .= ! empty($message) ? "\t".'['.$type.'] '.$message.PHP_EOL : ''; |
|
141 | 141 | return $msg; |
142 | 142 | } |
143 | 143 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param string $message |
153 | 153 | * @param string $type |
154 | 154 | */ |
155 | - public function log( $file = '', $function = '', $message = '', $type = '' ) { |
|
156 | - $this->_log .= $this->_format_message( $file, $function, $message, $type ); |
|
155 | + public function log($file = '', $function = '', $message = '', $type = '') { |
|
156 | + $this->_log .= $this->_format_message($file, $function, $message, $type); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | public function write_log() { |
166 | 166 | try { |
167 | 167 | //get existing log file and append new log info |
168 | - $this->_log = EEH_File::get_file_contents( $this->_logs_folder . $this->_log_file ) . $this->_log; |
|
169 | - EEH_File::write_to_file( $this->_logs_folder . $this->_log_file, $this->_log, 'Event Espresso Log' ); |
|
170 | - } catch( EE_Error $e ){ |
|
171 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
168 | + $this->_log = EEH_File::get_file_contents($this->_logs_folder.$this->_log_file).$this->_log; |
|
169 | + EEH_File::write_to_file($this->_logs_folder.$this->_log_file, $this->_log, 'Event Espresso Log'); |
|
170 | + } catch (EE_Error $e) { |
|
171 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
172 | 172 | return; |
173 | 173 | } |
174 | 174 | } |
@@ -181,31 +181,31 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function send_log() { |
183 | 183 | |
184 | - if ( empty( $this->_remote_logging_url )) { |
|
184 | + if (empty($this->_remote_logging_url)) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
188 | - $data = 'domain=' . $_SERVER['HTTP_HOST']; |
|
189 | - $data .= '&ip=' . $_SERVER['SERVER_ADDR']; |
|
190 | - $data .= '&server_type=' . $_SERVER['SERVER_SOFTWARE']; |
|
191 | - $data .= '&time=' . time(); |
|
192 | - $data .= '&remote_log=' . $this->_log; |
|
193 | - $data .= '&request_array=' . json_encode( $_REQUEST ); |
|
188 | + $data = 'domain='.$_SERVER['HTTP_HOST']; |
|
189 | + $data .= '&ip='.$_SERVER['SERVER_ADDR']; |
|
190 | + $data .= '&server_type='.$_SERVER['SERVER_SOFTWARE']; |
|
191 | + $data .= '&time='.time(); |
|
192 | + $data .= '&remote_log='.$this->_log; |
|
193 | + $data .= '&request_array='.json_encode($_REQUEST); |
|
194 | 194 | $data .= '&action=save'; |
195 | 195 | |
196 | - if ( defined( 'EELOGGING_PASS' )) { |
|
197 | - $data .= '&pass=' . EELOGGING_PASS; |
|
196 | + if (defined('EELOGGING_PASS')) { |
|
197 | + $data .= '&pass='.EELOGGING_PASS; |
|
198 | 198 | } |
199 | - if ( defined( 'EELOGGING_KEY' )) { |
|
200 | - $data .= '&key=' . EELOGGING_KEY; |
|
199 | + if (defined('EELOGGING_KEY')) { |
|
200 | + $data .= '&key='.EELOGGING_KEY; |
|
201 | 201 | } |
202 | 202 | |
203 | - $c = curl_init( $this->_remote_logging_url ); |
|
204 | - curl_setopt( $c, CURLOPT_POST, TRUE ); |
|
205 | - curl_setopt( $c, CURLOPT_POSTFIELDS, $data ); |
|
206 | - curl_setopt( $c, CURLOPT_RETURNTRANSFER, TRUE ); |
|
207 | - curl_exec( $c ); |
|
208 | - curl_close( $c ); |
|
203 | + $c = curl_init($this->_remote_logging_url); |
|
204 | + curl_setopt($c, CURLOPT_POST, TRUE); |
|
205 | + curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
|
206 | + curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
|
207 | + curl_exec($c); |
|
208 | + curl_close($c); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | * previous entries are overwritten |
217 | 217 | */ |
218 | 218 | public function write_debug() { |
219 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
219 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
220 | 220 | $this->_debug_log = ''; |
221 | - foreach ( $_GET as $key => $value ) { |
|
222 | - $this->_debug_log .= '$_GET["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
221 | + foreach ($_GET as $key => $value) { |
|
222 | + $this->_debug_log .= '$_GET["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
223 | 223 | } |
224 | - foreach ( $_POST as $key => $value ) { |
|
225 | - $this->_debug_log .= '$_POST["' . $key . '"] = "' . serialize($value) . '"' . PHP_EOL; |
|
224 | + foreach ($_POST as $key => $value) { |
|
225 | + $this->_debug_log .= '$_POST["'.$key.'"] = "'.serialize($value).'"'.PHP_EOL; |
|
226 | 226 | } |
227 | 227 | try { |
228 | - EEH_File::write_to_file( $this->_logs_folder . $this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log' ); |
|
229 | - } catch( EE_Error $e ){ |
|
230 | - EE_Error::add_error( sprintf( __( 'Could not write to the Event Espresso debug log file because: %s', 'event_espresso' ), ' ' . $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
228 | + EEH_File::write_to_file($this->_logs_folder.$this->_debug_file, $this->_debug_log, 'Event Espresso Debug Log'); |
|
229 | + } catch (EE_Error $e) { |
|
230 | + EE_Error::add_error(sprintf(__('Could not write to the Event Espresso debug log file because: %s', 'event_espresso'), ' '.$e->getMessage()), __FILE__, __FUNCTION__, __LINE__); |
|
231 | 231 | return; |
232 | 232 | } |
233 | 233 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * __clone |
240 | 240 | */ |
241 | 241 | public function __clone() { |
242 | - trigger_error( __( 'Clone is not allowed.', 'event_espresso' ), E_USER_ERROR ); |
|
242 | + trigger_error(__('Clone is not allowed.', 'event_espresso'), E_USER_ERROR); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 |
@@ -48,10 +48,10 @@ |
||
48 | 48 | */ |
49 | 49 | const option_name_maintenance_mode = 'ee_maintenance_mode'; |
50 | 50 | /** |
51 | - * EE_Maintenance_Mode Object |
|
52 | - * @var EE_Maintenance_Mode $_instance |
|
53 | - * @access private |
|
54 | - */ |
|
51 | + * EE_Maintenance_Mode Object |
|
52 | + * @var EE_Maintenance_Mode $_instance |
|
53 | + * @access private |
|
54 | + */ |
|
55 | 55 | private static $_instance = NULL; |
56 | 56 | |
57 | 57 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | 142 | $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else{ |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + } elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | 162 | update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else{ |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public static function instance() { |
75 | 75 | // check if class object is instantiated |
76 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Maintenance_Mode )) { |
|
76 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Maintenance_Mode)) { |
|
77 | 77 | self::$_instance = new self(); |
78 | 78 | } |
79 | 79 | return self::$_instance; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Resets maintenance mode (mostly just re-checks whether or not we should be in maintenance mode) |
84 | 84 | * @return EE_Maintenance_Mode |
85 | 85 | */ |
86 | - public static function reset(){ |
|
86 | + public static function reset() { |
|
87 | 87 | self::instance()->set_maintenance_mode_if_db_old(); |
88 | 88 | return self::instance(); |
89 | 89 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private function __construct() { |
100 | 100 | // if M-Mode level 2 is engaged, we still need basic assets loaded |
101 | - add_action( 'wp_enqueue_scripts', array( $this, 'load_assets_required_for_m_mode' )); |
|
101 | + add_action('wp_enqueue_scripts', array($this, 'load_assets_required_for_m_mode')); |
|
102 | 102 | // shut 'er down down for maintenance ? |
103 | - add_filter( 'the_content', array( $this, 'the_content' ), 2 ); |
|
103 | + add_filter('the_content', array($this, 'the_content'), 2); |
|
104 | 104 | // add powered by EE msg |
105 | - add_action( 'shutdown', array( $this, 'display_maintenance_mode_notice' ), 10 ); |
|
105 | + add_action('shutdown', array($this, 'display_maintenance_mode_notice'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * retrieves the maintenance mode option value from the db |
113 | 113 | * @return int |
114 | 114 | */ |
115 | - public function real_level(){ |
|
116 | - return get_option( self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
115 | + public function real_level() { |
|
116 | + return get_option(self::option_name_maintenance_mode, EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * thinks their tables are present and up-to-date). |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function models_can_query(){ |
|
124 | + public function models_can_query() { |
|
125 | 125 | return $this->real_level() != EE_Maintenance_Mode::level_2_complete_maintenance; |
126 | 126 | } |
127 | 127 | |
@@ -134,14 +134,14 @@ discard block |
||
134 | 134 | * EE_Maintenance_Mode::level_2_complete_maintenance => frontend and backend maintenance mode |
135 | 135 | * @return int |
136 | 136 | */ |
137 | - public function level(){ |
|
137 | + public function level() { |
|
138 | 138 | $real_maintenance_mode_level = $this->real_level(); |
139 | 139 | //if this is an admin request, we'll be honest... except if it's ajax, because that might be from the frontend |
140 | - if( ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
140 | + if (( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) && //only on frontend or ajax requests |
|
141 | 141 | current_user_can('administrator') && //when the user is an admin |
142 | - $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance){//and we're in level 1 |
|
142 | + $real_maintenance_mode_level == EE_Maintenance_Mode::level_1_frontend_only_maintenance) {//and we're in level 1 |
|
143 | 143 | $maintenance_mode_level = EE_Maintenance_Mode::level_0_not_in_maintenance; |
144 | - }else{ |
|
144 | + } else { |
|
145 | 145 | $maintenance_mode_level = $real_maintenance_mode_level; |
146 | 146 | } |
147 | 147 | return $maintenance_mode_level; |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | * Determines if we need to put EE in maintenance mode because the database needs updating |
152 | 152 | * @return boolean true if DB is old and maintenance mode was triggered; false otherwise |
153 | 153 | */ |
154 | - public function set_maintenance_mode_if_db_old(){ |
|
155 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
156 | - if( EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){ |
|
154 | + public function set_maintenance_mode_if_db_old() { |
|
155 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
156 | + if (EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
157 | 157 | update_option(self::option_name_maintenance_mode, self::level_2_complete_maintenance); |
158 | 158 | return true; |
159 | - }elseif( $this->level() == self::level_2_complete_maintenance ){ |
|
159 | + }elseif ($this->level() == self::level_2_complete_maintenance) { |
|
160 | 160 | //we also want to handle the opposite: if the site is mm2, but there aren't any migrations to run |
161 | 161 | //then we shouldn't be in mm2. (Maybe an addon got deactivated?) |
162 | - update_option( self::option_name_maintenance_mode, self::level_0_not_in_maintenance ); |
|
162 | + update_option(self::option_name_maintenance_mode, self::level_0_not_in_maintenance); |
|
163 | 163 | return false; |
164 | - }else{ |
|
164 | + } else { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | } |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param int $level |
172 | 172 | * @return void |
173 | 173 | */ |
174 | - public function set_maintenance_level($level){ |
|
175 | - do_action( 'AHEE__EE_Maintenance_Mode__set_maintenance_level', $level ); |
|
174 | + public function set_maintenance_level($level) { |
|
175 | + do_action('AHEE__EE_Maintenance_Mode__set_maintenance_level', $level); |
|
176 | 176 | update_option(self::option_name_maintenance_mode, intval($level)); |
177 | 177 | } |
178 | 178 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @return string |
200 | 200 | */ |
201 | 201 | public function load_assets_required_for_m_mode() { |
202 | - if ( $this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is( 'espresso_core', 'enqueued' )) { |
|
203 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
202 | + if ($this->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance && ! wp_script_is('espresso_core', 'enqueued')) { |
|
203 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
204 | 204 | wp_enqueue_style('espresso_default'); |
205 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
206 | - wp_enqueue_script( 'espresso_core' ); |
|
205 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
206 | + wp_enqueue_script('espresso_core'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | */ |
222 | 222 | public static function template_include() { |
223 | 223 | // shut 'er down down for maintenance ? then don't use any of our templates for our endpoints |
224 | - return get_template_directory() . '/index.php'; |
|
224 | + return get_template_directory().'/index.php'; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * @param string $the_content |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - public function the_content( $the_content ) { |
|
238 | + public function the_content($the_content) { |
|
239 | 239 | // check if M-mode is engaged and for EE shortcode |
240 | - if ( $this->level() && strpos( $the_content, '[ESPRESSO_' ) !== false ) { |
|
240 | + if ($this->level() && strpos($the_content, '[ESPRESSO_') !== false) { |
|
241 | 241 | // this can eventually be moved to a template, or edited via admin. But for now... |
242 | 242 | $the_content = sprintf( |
243 | - __( '%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso' ), |
|
243 | + __('%sMaintenance Mode%sEvent Registration has been temporarily closed while system maintenance is being performed. We\'re sorry for any inconveniences this may have caused. Please try back again later.%s', 'event_espresso'), |
|
244 | 244 | '<h3>', |
245 | 245 | '</h3><p>', |
246 | 246 | '</p>' |
@@ -264,16 +264,16 @@ discard block |
||
264 | 264 | // check if M-mode is engaged and for EE shortcode |
265 | 265 | if ( |
266 | 266 | $this->real_level() && |
267 | - current_user_can( 'administrator' ) && |
|
267 | + current_user_can('administrator') && |
|
268 | 268 | ! is_admin() && |
269 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
269 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
270 | 270 | && EE_Registry::instance()->REQ->is_espresso_page() |
271 | 271 | ) { |
272 | 272 | printf( |
273 | - __( '%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso' ), |
|
273 | + __('%sclose%sEvent Registration is currently disabled because Event Espresso has been placed into Maintenance Mode. To change Maintenance Mode settings, click here %sEE Maintenance Mode Admin Page%s', 'event_espresso'), |
|
274 | 274 | '<div id="ee-m-mode-admin-notice-dv" class="ee-really-important-notice-dv"><a class="close-espresso-notice" title="', |
275 | 275 | '">×</a><p>', |
276 | - ' » <a href="' . add_query_arg( array( 'page' => 'espresso_maintenance_settings' ), admin_url( 'admin.php' )) . '">', |
|
276 | + ' » <a href="'.add_query_arg(array('page' => 'espresso_maintenance_settings'), admin_url('admin.php')).'">', |
|
277 | 277 | '</a></p></div>' |
278 | 278 | ); |
279 | 279 | } |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @ return void |
292 | 292 | */ |
293 | 293 | final function __destruct() {} |
294 | - final function __call($a,$b) {} |
|
294 | + final function __call($a, $b) {} |
|
295 | 295 | final function __get($a) {} |
296 | - final function __set($a,$b) {} |
|
296 | + final function __set($a, $b) {} |
|
297 | 297 | final function __isset($a) {} |
298 | 298 | final function __unset($a) {} |
299 | 299 | final function __sleep() { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | final function __invoke() {} |
305 | 305 | final function __set_state() {} |
306 | 306 | final function __clone() {} |
307 | - final static function __callStatic($a,$b) {} |
|
307 | + final static function __callStatic($a, $b) {} |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | // End of file EE_Maintenance_Mode.core.php |
@@ -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 | * |
@@ -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(); |
@@ -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 = 'https://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 |
@@ -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 | * |
@@ -52,8 +54,9 @@ discard block |
||
52 | 54 | do_action( 'AHEE_log', __CLASS__, __FUNCTION__ ); |
53 | 55 | |
54 | 56 | //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 ); |
|
57 | + if ( !defined('MONTH_IN_SECONDS' ) ) { |
|
58 | + define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 ); |
|
59 | + } |
|
57 | 60 | |
58 | 61 | if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){ |
59 | 62 | $this->_uxip_hooks(); |
@@ -100,42 +103,51 @@ discard block |
||
100 | 103 | |
101 | 104 | //what is the current active theme? |
102 | 105 | $active_theme = get_option('uxip_ee_active_theme'); |
103 | - if ( !empty( $active_theme ) ) |
|
104 | - $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
106 | + if ( !empty( $active_theme ) ) { |
|
107 | + $extra_stats[$site_pre . 'active_theme'] = $active_theme; |
|
108 | + } |
|
105 | 109 | |
106 | 110 | //event info regarding an all event count and all "active" event count |
107 | 111 | $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; |
|
112 | + if ( !empty( $all_events_count ) ) { |
|
113 | + $extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count; |
|
114 | + } |
|
110 | 115 | $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; |
|
116 | + if ( !empty( $active_events_count ) ) { |
|
117 | + $extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count; |
|
118 | + } |
|
113 | 119 | |
114 | 120 | //datetime stuff |
115 | 121 | $dtt_count = get_option('uxip_ee_all_dtts_count'); |
116 | - if ( !empty( $dtt_count ) ) |
|
117 | - $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
122 | + if ( !empty( $dtt_count ) ) { |
|
123 | + $extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count; |
|
124 | + } |
|
118 | 125 | |
119 | 126 | $dtt_sold = get_option('uxip_ee_dtt_sold'); |
120 | - if ( !empty( $dtt_sold ) ) |
|
121 | - $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
127 | + if ( !empty( $dtt_sold ) ) { |
|
128 | + $extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold; |
|
129 | + } |
|
122 | 130 | |
123 | 131 | //ticket stuff |
124 | 132 | $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; |
|
133 | + if ( !empty( $all_tkt_count ) ) { |
|
134 | + $extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count; |
|
135 | + } |
|
127 | 136 | |
128 | 137 | $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; |
|
138 | + if ( !empty( $free_tkt_count ) ) { |
|
139 | + $extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count; |
|
140 | + } |
|
131 | 141 | |
132 | 142 | $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; |
|
143 | + if ( !empty( $paid_tkt_count ) ) { |
|
144 | + $extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count; |
|
145 | + } |
|
135 | 146 | |
136 | 147 | $tkt_sold = get_option('uxip_ee_tkt_sold' ); |
137 | - if ( !empty($tkt_sold) ) |
|
138 | - $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
148 | + if ( !empty($tkt_sold) ) { |
|
149 | + $extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold; |
|
150 | + } |
|
139 | 151 | |
140 | 152 | //phpversion checking |
141 | 153 | $extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown'; |
@@ -208,7 +220,9 @@ discard block |
||
208 | 220 | |
209 | 221 | function espresso_data_collection_optin_notice() { |
210 | 222 | $ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified; |
211 | - if ( $ueip_has_notified ) return; |
|
223 | + if ( $ueip_has_notified ) { |
|
224 | + return; |
|
225 | + } |
|
212 | 226 | $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') ); |
213 | 227 | $settings_url = $settings_url . '#UXIP_settings'; |
214 | 228 | ?> |
@@ -248,7 +262,9 @@ discard block |
||
248 | 262 | function espresso_data_optin_ajax_handler() { |
249 | 263 | |
250 | 264 | //verify nonce |
251 | - if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit(); |
|
265 | + if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) { |
|
266 | + exit(); |
|
267 | + } |
|
252 | 268 | |
253 | 269 | //made it here so let's save the selection |
254 | 270 | $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no'; |
@@ -278,13 +294,15 @@ discard block |
||
278 | 294 | $current = get_site_transient( 'update_plugins' ); |
279 | 295 | |
280 | 296 | foreach ( (array) $plugins as $plugin_file => $plugin_data ) { |
281 | - if ( isset( $current->response['plugin_file'] ) ) |
|
282 | - $update = true; |
|
297 | + if ( isset( $current->response['plugin_file'] ) ) { |
|
298 | + $update = true; |
|
299 | + } |
|
283 | 300 | } |
284 | 301 | |
285 | 302 | //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 ) ) |
|
287 | - $update = true; |
|
303 | + if ( get_site_option('pue_json_error_' . $basename ) ) { |
|
304 | + $update = true; |
|
305 | + } |
|
288 | 306 | |
289 | 307 | return $update; |
290 | 308 | } |
@@ -328,46 +346,54 @@ discard block |
||
328 | 346 | $DTT = EE_Registry::instance()->load_model('Datetime'); |
329 | 347 | $TKT = EE_Registry::instance()->load_model('Ticket'); |
330 | 348 | $count = $EVT->count(); |
331 | - if ( $count > 0 ) |
|
332 | - update_option('uxip_ee4_all_events_count', $count); |
|
349 | + if ( $count > 0 ) { |
|
350 | + update_option('uxip_ee4_all_events_count', $count); |
|
351 | + } |
|
333 | 352 | |
334 | 353 | //next let's just get the number of ACTIVE events |
335 | 354 | $count_active = $EVT->get_active_events(array(), TRUE); |
336 | - if ( $count_active > 0 ) |
|
337 | - update_option('uxip_ee4_active_events_count', $count_active); |
|
355 | + if ( $count_active > 0 ) { |
|
356 | + update_option('uxip_ee4_active_events_count', $count_active); |
|
357 | + } |
|
338 | 358 | |
339 | 359 | //datetimes! |
340 | 360 | $dtt_count = $DTT->count(); |
341 | - if ( $dtt_count > 0 ) |
|
342 | - update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
361 | + if ( $dtt_count > 0 ) { |
|
362 | + update_option( 'uxip_ee_all_dtts_count', $dtt_count ); |
|
363 | + } |
|
343 | 364 | |
344 | 365 | |
345 | 366 | //dttsold |
346 | 367 | $dtt_sold = $DTT->sum(array(), 'DTT_sold'); |
347 | - if ( $dtt_sold > 0 ) |
|
348 | - update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
368 | + if ( $dtt_sold > 0 ) { |
|
369 | + update_option( 'uxip_ee_dtt_sold', $dtt_sold ); |
|
370 | + } |
|
349 | 371 | |
350 | 372 | //allticketcount |
351 | 373 | $all_tkt_count = $TKT->count(); |
352 | - if ( $all_tkt_count > 0 ) |
|
353 | - update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
374 | + if ( $all_tkt_count > 0 ) { |
|
375 | + update_option( 'uxip_ee_all_tkt_count', $all_tkt_count ); |
|
376 | + } |
|
354 | 377 | |
355 | 378 | //freetktcount |
356 | 379 | $_where = array( 'TKT_price' => 0 ); |
357 | 380 | $free_tkt_count = $TKT->count(array($_where)); |
358 | - if ( $free_tkt_count > 0 ) |
|
359 | - update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
381 | + if ( $free_tkt_count > 0 ) { |
|
382 | + update_option( 'uxip_ee_free_tkt_count', $free_tkt_count ); |
|
383 | + } |
|
360 | 384 | |
361 | 385 | //paidtktcount |
362 | 386 | $_where = array( 'TKT_price' => array('>', 0) ); |
363 | 387 | $paid_tkt_count = $TKT->count( array( $_where ) ); |
364 | - if ( $paid_tkt_count > 0 ) |
|
365 | - update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
388 | + if ( $paid_tkt_count > 0 ) { |
|
389 | + update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count ); |
|
390 | + } |
|
366 | 391 | |
367 | 392 | //tktsold |
368 | 393 | $tkt_sold = $TKT->sum( array(), 'TKT_sold' ); |
369 | - if( $tkt_sold > 0 ) |
|
370 | - update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
394 | + if( $tkt_sold > 0 ) { |
|
395 | + update_option( 'uxip_ee_tkt_sold', $tkt_sold ); |
|
396 | + } |
|
371 | 397 | |
372 | 398 | |
373 | 399 | set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 ); |
@@ -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 | * Event Espresso |
@@ -217,12 +218,15 @@ discard block |
||
217 | 218 | $this->_set_hooks_properties(); |
218 | 219 | |
219 | 220 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
221 | - return; //get out nothing more to be done here. |
|
221 | + if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) { |
|
222 | + return; |
|
223 | + } |
|
224 | + //get out nothing more to be done here. |
|
222 | 225 | |
223 | 226 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
225 | - $this->_extend_properties(); |
|
227 | + if ( method_exists( $this, '_extend_properties' ) ) { |
|
228 | + $this->_extend_properties(); |
|
229 | + } |
|
226 | 230 | |
227 | 231 | $this->_set_page_object(); |
228 | 232 | $this->_init_hooks(); |
@@ -305,8 +309,10 @@ discard block |
||
305 | 309 | } |
306 | 310 | |
307 | 311 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
312 | + if( !isset( $this->_scripts_styles['enqueues'] ) ) { |
|
313 | + return; |
|
314 | + } |
|
315 | + //not sure if we should throw an error here or not. |
|
310 | 316 | foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
311 | 317 | //make sure $routes is an array |
312 | 318 | $routes = (array) $routes; |
@@ -323,8 +329,9 @@ discard block |
||
323 | 329 | } |
324 | 330 | |
325 | 331 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
327 | - return; |
|
332 | + if ( !isset( $this->_scripts_styles['deregisters'] ) ) { |
|
333 | + return; |
|
334 | + } |
|
328 | 335 | foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
329 | 336 | $defaults = array( |
330 | 337 | 'type' => 'js' |
@@ -376,8 +383,9 @@ discard block |
||
376 | 383 | |
377 | 384 | //first default file (if exists) |
378 | 385 | $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
379 | - if ( is_readable( $decaf_file ) ) |
|
380 | - require_once( $decaf_file ); |
|
386 | + if ( is_readable( $decaf_file ) ) { |
|
387 | + require_once( $decaf_file ); |
|
388 | + } |
|
381 | 389 | |
382 | 390 | //now we have to do require for extended file (if needed) |
383 | 391 | if ( $this->_extend ) { |
@@ -486,12 +494,14 @@ discard block |
||
486 | 494 | |
487 | 495 | foreach ( $hook_filter_array as $hook => $args ) { |
488 | 496 | if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
489 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
490 | - $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
491 | - if ( $args['type'] == 'action' ) |
|
492 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | - else |
|
494 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
497 | + if ( isset( $this->_wp_action_filters_priority[$hook] ) ) { |
|
498 | + $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
499 | + } |
|
500 | + if ( $args['type'] == 'action' ) { |
|
501 | + add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
502 | + } else { |
|
503 | + add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
504 | + } |
|
495 | 505 | } |
496 | 506 | } |
497 | 507 | |
@@ -504,8 +514,10 @@ discard block |
||
504 | 514 | */ |
505 | 515 | private function _ajax_hooks() { |
506 | 516 | |
507 | - if ( empty( $this->_ajax_func) ) |
|
508 | - return; //get out there's nothing to take care of. |
|
517 | + if ( empty( $this->_ajax_func) ) { |
|
518 | + return; |
|
519 | + } |
|
520 | + //get out there's nothing to take care of. |
|
509 | 521 | |
510 | 522 | foreach ( $this->_ajax_func as $action => $method ) { |
511 | 523 | //make sure method exists |
@@ -528,8 +540,10 @@ discard block |
||
528 | 540 | * @return void |
529 | 541 | */ |
530 | 542 | protected function _init_hooks() { |
531 | - if ( empty( $this->_init_func) ) |
|
532 | - return; //get out there's nothing to take care of. |
|
543 | + if ( empty( $this->_init_func) ) { |
|
544 | + return; |
|
545 | + } |
|
546 | + //get out there's nothing to take care of. |
|
533 | 547 | |
534 | 548 | //We need to determine what page_route we are on! |
535 | 549 | $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
@@ -541,8 +555,9 @@ discard block |
||
541 | 555 | $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
542 | 556 | throw new EE_Error( implode('||', $msg ) ); |
543 | 557 | } |
544 | - if ( $route == $this->_current_route ) |
|
545 | - add_action('admin_init', array( $this, $method ) ); |
|
558 | + if ( $route == $this->_current_route ) { |
|
559 | + add_action('admin_init', array( $this, $method ) ); |
|
560 | + } |
|
546 | 561 | } |
547 | 562 | |
548 | 563 | } |
@@ -557,8 +572,10 @@ discard block |
||
557 | 572 | * @return void |
558 | 573 | */ |
559 | 574 | public function add_metaboxes() { |
560 | - if ( empty( $this->_metaboxes ) ) |
|
561 | - return; //get out we don't have any metaboxes to set for this connection |
|
575 | + if ( empty( $this->_metaboxes ) ) { |
|
576 | + return; |
|
577 | + } |
|
578 | + //get out we don't have any metaboxes to set for this connection |
|
562 | 579 | |
563 | 580 | $this->_handle_metabox_array( $this->_metaboxes ); |
564 | 581 | |
@@ -569,19 +586,24 @@ discard block |
||
569 | 586 | private function _handle_metabox_array( $boxes, $add = TRUE ) { |
570 | 587 | |
571 | 588 | foreach ( $boxes as $box ) { |
572 | - if ( !isset($box['page_route']) ) |
|
573 | - continue; //we dont' have a valid array |
|
589 | + if ( !isset($box['page_route']) ) { |
|
590 | + continue; |
|
591 | + } |
|
592 | + //we dont' have a valid array |
|
574 | 593 | |
575 | 594 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
576 | 595 | $box['page_route'] = (array) $box['page_route']; |
577 | 596 | |
578 | 597 | foreach ( $box['page_route'] as $route ) { |
579 | - if ( $route != $this->_current_route ) |
|
580 | - continue; //get out we only add metaboxes for set route. |
|
581 | - if ( $add ) |
|
582 | - $this->_add_metabox($box); |
|
583 | - else |
|
584 | - $this->_remove_metabox($box); |
|
598 | + if ( $route != $this->_current_route ) { |
|
599 | + continue; |
|
600 | + } |
|
601 | + //get out we only add metaboxes for set route. |
|
602 | + if ( $add ) { |
|
603 | + $this->_add_metabox($box); |
|
604 | + } else { |
|
605 | + $this->_remove_metabox($box); |
|
606 | + } |
|
585 | 607 | } |
586 | 608 | } |
587 | 609 | } |
@@ -596,8 +618,10 @@ discard block |
||
596 | 618 | */ |
597 | 619 | public function remove_metaboxes() { |
598 | 620 | |
599 | - if ( empty( $this->_remove_metaboxes ) ) |
|
600 | - return; //get out there are no metaboxes to remove |
|
621 | + if ( empty( $this->_remove_metaboxes ) ) { |
|
622 | + return; |
|
623 | + } |
|
624 | + //get out there are no metaboxes to remove |
|
601 | 625 | |
602 | 626 | $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
603 | 627 | } |
@@ -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 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * constructor |
210 | 210 | * @param EE_Admin_Page $admin_page the calling admin_page_object |
211 | 211 | */ |
212 | - public function __construct( EE_Admin_Page $adminpage ) { |
|
212 | + public function __construct(EE_Admin_Page $adminpage) { |
|
213 | 213 | |
214 | 214 | $this->_adminpage_obj = $adminpage; |
215 | 215 | $this->_req_data = array_merge($_GET, $_POST); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | $this->_set_hooks_properties(); |
218 | 218 | |
219 | 219 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
220 | + if ( ! isset($this->_req_data['page']) || (isset($this->_req_data['page']) && $this->_adminpage_obj->page_slug != $this->_req_data['page'])) |
|
221 | 221 | return; //get out nothing more to be done here. |
222 | 222 | |
223 | 223 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
224 | + if (method_exists($this, '_extend_properties')) |
|
225 | 225 | $this->_extend_properties(); |
226 | 226 | |
227 | 227 | $this->_set_page_object(); |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | $this->_load_custom_methods(); |
230 | 230 | $this->_load_routed_hooks(); |
231 | 231 | |
232 | - add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_styles' ) ); |
|
233 | - add_action( 'admin_enqueue_scripts', array($this, 'add_metaboxes'), 20 ); |
|
234 | - add_action( 'admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15 ); |
|
232 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
233 | + add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20); |
|
234 | + add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15); |
|
235 | 235 | |
236 | 236 | $this->_ajax_hooks(); |
237 | 237 | |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function enqueue_scripts_styles() { |
274 | 274 | |
275 | - if ( !empty( $this->_scripts_styles ) ) { |
|
275 | + if ( ! empty($this->_scripts_styles)) { |
|
276 | 276 | //first let's do all the registrations |
277 | - if ( !isset($this->_scripts_styles['registers'] ) ) { |
|
277 | + if ( ! isset($this->_scripts_styles['registers'])) { |
|
278 | 278 | $msg[] = __('There is no "registers" index in the <code>$this->_scripts_styles</code> property.', 'event_espresso'); |
279 | - $msg[] = sprintf ( __('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>' . $this->caller . '</strong>' ); |
|
280 | - throw new EE_Error( implode( '||', $msg ) ); |
|
279 | + $msg[] = sprintf(__('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>'.$this->caller.'</strong>'); |
|
280 | + throw new EE_Error(implode('||', $msg)); |
|
281 | 281 | } |
282 | 282 | |
283 | - foreach( $this->_scripts_styles['registers'] as $ref => $details ) { |
|
283 | + foreach ($this->_scripts_styles['registers'] as $ref => $details) { |
|
284 | 284 | $defaults = array( |
285 | 285 | 'type' => 'js', |
286 | 286 | 'url' => '', |
@@ -289,48 +289,48 @@ discard block |
||
289 | 289 | 'footer' => TRUE |
290 | 290 | ); |
291 | 291 | $details = wp_parse_args($details, $defaults); |
292 | - extract( $details ); |
|
292 | + extract($details); |
|
293 | 293 | |
294 | 294 | //let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
295 | 295 | $this->_scripts_styles['registers'][$ref]['type'] = $type; |
296 | 296 | |
297 | 297 | //let's make sure we're not missing any REQUIRED parameters |
298 | - if ( empty($url) ) { |
|
299 | - $msg[] = sprintf( __('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet' ); |
|
300 | - $msg[] = sprintf( __('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>' . $this->caller . '</strong>', $ref ); |
|
301 | - throw new EE_Error( implode( '||', $msg ) ); |
|
298 | + if (empty($url)) { |
|
299 | + $msg[] = sprintf(__('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet'); |
|
300 | + $msg[] = sprintf(__('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>'.$this->caller.'</strong>', $ref); |
|
301 | + throw new EE_Error(implode('||', $msg)); |
|
302 | 302 | } |
303 | 303 | //made it here so let's do the appropriate registration |
304 | - $type == 'js' ? wp_register_script( $ref, $url, $depends, $version, $footer ) : wp_register_style( $ref, $url, $depends, $version ); |
|
304 | + $type == 'js' ? wp_register_script($ref, $url, $depends, $version, $footer) : wp_register_style($ref, $url, $depends, $version); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
310 | - foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
|
308 | + if ( ! isset($this->_scripts_styles['enqueues'])) |
|
309 | + return; //not sure if we should throw an error here or not. |
|
310 | + foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) { |
|
311 | 311 | //make sure $routes is an array |
312 | 312 | $routes = (array) $routes; |
313 | 313 | |
314 | - if ( in_array($this->_current_route, $routes ) ) { |
|
314 | + if (in_array($this->_current_route, $routes)) { |
|
315 | 315 | $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) : wp_enqueue_style($ref); |
316 | 316 | //if we have a localization for the script let's do that too. |
317 | - if ( isset( $this->_scripts_styles['localize'][$ref] ) ) { |
|
318 | - foreach ( $this->_scripts_styles['localize'][$ref] as $object_name => $indexes ) { |
|
319 | - wp_localize_script($ref, $object_name , $this->_scripts_styles['localize'][$ref][$object_name] ); |
|
317 | + if (isset($this->_scripts_styles['localize'][$ref])) { |
|
318 | + foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) { |
|
319 | + wp_localize_script($ref, $object_name, $this->_scripts_styles['localize'][$ref][$object_name]); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
326 | + if ( ! isset($this->_scripts_styles['deregisters'])) |
|
327 | 327 | return; |
328 | - foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
|
328 | + foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
|
329 | 329 | $defaults = array( |
330 | 330 | 'type' => 'js' |
331 | 331 | ); |
332 | - $details = wp_parse_args( $details, $defaults ); |
|
333 | - extract( $details ); |
|
332 | + $details = wp_parse_args($details, $defaults); |
|
333 | + extract($details); |
|
334 | 334 | |
335 | 335 | $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref); |
336 | 336 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | private function _set_defaults() { |
351 | 351 | $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array(); |
352 | - $this->_current_route = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
352 | + $this->_current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
353 | 353 | $this->caller = get_class($this); |
354 | 354 | $this->_extend = stripos($this->caller, 'Extend') ? TRUE : FALSE; |
355 | 355 | } |
@@ -364,34 +364,34 @@ discard block |
||
364 | 364 | */ |
365 | 365 | protected function _set_page_object() { |
366 | 366 | //first make sure $this->_name is set |
367 | - if ( empty( $this->_name ) ) { |
|
367 | + if (empty($this->_name)) { |
|
368 | 368 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
369 | - $msg[] = sprintf( __("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller ); |
|
370 | - throw new EE_Error( implode( '||', $msg ) ); |
|
369 | + $msg[] = sprintf(__("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller); |
|
370 | + throw new EE_Error(implode('||', $msg)); |
|
371 | 371 | } |
372 | 372 | |
373 | - $ref = str_replace('_' , ' ', $this->_name); //take the_message -> the message |
|
374 | - $ref = str_replace(' ', '_', ucwords($ref) ) . '_Admin_Page'; //take the message -> The_Message |
|
373 | + $ref = str_replace('_', ' ', $this->_name); //take the_message -> the message |
|
374 | + $ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; //take the message -> The_Message |
|
375 | 375 | |
376 | 376 | //first default file (if exists) |
377 | - $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
|
378 | - if ( is_readable( $decaf_file ) ) |
|
379 | - require_once( $decaf_file ); |
|
377 | + $decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php'; |
|
378 | + if (is_readable($decaf_file)) |
|
379 | + require_once($decaf_file); |
|
380 | 380 | |
381 | 381 | //now we have to do require for extended file (if needed) |
382 | - if ( $this->_extend ) { |
|
383 | - require_once( EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php' ); |
|
382 | + if ($this->_extend) { |
|
383 | + require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | //if we've got an extended class we use that! |
388 | - $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
388 | + $ref = $this->_extend ? 'Extend_'.$ref : $ref; |
|
389 | 389 | |
390 | 390 | //let's make sure the class exists |
391 | - if ( !class_exists( $ref ) ) { |
|
391 | + if ( ! class_exists($ref)) { |
|
392 | 392 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
393 | - $msg[] = sprintf( __('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref ); |
|
394 | - throw new EE_Error( implode( '||', $msg ) ); |
|
393 | + $msg[] = sprintf(__('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref); |
|
394 | + throw new EE_Error(implode('||', $msg)); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $a = new ReflectionClass($ref); |
@@ -416,27 +416,27 @@ discard block |
||
416 | 416 | $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route; |
417 | 417 | |
418 | 418 | //these run before the Admin_Page route executes. |
419 | - if ( method_exists( $this, $method_callback ) ) { |
|
420 | - call_user_func( array( $this, $method_callback) ); |
|
419 | + if (method_exists($this, $method_callback)) { |
|
420 | + call_user_func(array($this, $method_callback)); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
424 | 424 | //these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes. There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens. |
425 | 425 | //first the actions |
426 | 426 | //note that these action hooks will have the $query_args value available. |
427 | - $admin_class_name = get_class( $this->_adminpage_obj ); |
|
427 | + $admin_class_name = get_class($this->_adminpage_obj); |
|
428 | 428 | |
429 | - if ( method_exists( $this, '_redirect_action_early_' . $this->_current_route ) ) { |
|
430 | - add_action( 'AHEE__' . $admin_class_name . '___redirect_after_action__before_redirect_modification_' . $this->_current_route, array( $this, '_redirect_action_early_' . $this->_current_route ), 10 ); |
|
429 | + if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) { |
|
430 | + add_action('AHEE__'.$admin_class_name.'___redirect_after_action__before_redirect_modification_'.$this->_current_route, array($this, '_redirect_action_early_'.$this->_current_route), 10); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( method_exists( $this, '_redirect_action_' . $this->_current_route ) ) { |
|
434 | - add_action( 'AHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_action_' . $this->_current_route ), 10 ); |
|
433 | + if (method_exists($this, '_redirect_action_'.$this->_current_route)) { |
|
434 | + add_action('AHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_action_'.$this->_current_route), 10); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | //let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
438 | - if ( method_exists( $this, '_redirect_filter_' . $this->_current_route ) ) { |
|
439 | - add_filter( 'FHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_filter_' . $this->_current_route ), 10, 2 ); |
|
438 | + if (method_exists($this, '_redirect_filter_'.$this->_current_route)) { |
|
439 | + add_filter('FHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_filter_'.$this->_current_route), 10, 2); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | } |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | 'argnum' => 1, |
460 | 460 | 'priority' => 10 |
461 | 461 | ), |
462 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
462 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array( |
|
463 | 463 | 'type' => 'filter', |
464 | 464 | 'argnum' => 1, |
465 | 465 | 'priority' => 10 |
466 | 466 | ), |
467 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
467 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array( |
|
468 | 468 | 'type' => 'filter', |
469 | 469 | 'argnum' => 1, |
470 | 470 | 'priority' => 10 |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | |
484 | 484 | |
485 | 485 | |
486 | - foreach ( $hook_filter_array as $hook => $args ) { |
|
487 | - if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
|
488 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
486 | + foreach ($hook_filter_array as $hook => $args) { |
|
487 | + if (method_exists($this, $this->_current_route.'_'.$hook)) { |
|
488 | + if (isset($this->_wp_action_filters_priority[$hook])) |
|
489 | 489 | $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
490 | - if ( $args['type'] == 'action' ) |
|
491 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
490 | + if ($args['type'] == 'action') |
|
491 | + add_action($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
492 | 492 | else |
493 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | + add_filter($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function _ajax_hooks() { |
505 | 505 | |
506 | - if ( empty( $this->_ajax_func) ) |
|
506 | + if (empty($this->_ajax_func)) |
|
507 | 507 | return; //get out there's nothing to take care of. |
508 | 508 | |
509 | - foreach ( $this->_ajax_func as $action => $method ) { |
|
509 | + foreach ($this->_ajax_func as $action => $method) { |
|
510 | 510 | //make sure method exists |
511 | - if ( !method_exists($this, $method) ) { |
|
512 | - $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso') . '<br />'; |
|
513 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
514 | - throw new EE_Error( implode('||', $msg ) ); |
|
511 | + if ( ! method_exists($this, $method)) { |
|
512 | + $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso').'<br />'; |
|
513 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
514 | + throw new EE_Error(implode('||', $msg)); |
|
515 | 515 | } |
516 | 516 | |
517 | - add_action('wp_ajax_' . $action, array( $this, $method ) ); |
|
517 | + add_action('wp_ajax_'.$action, array($this, $method)); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | } |
@@ -527,21 +527,21 @@ discard block |
||
527 | 527 | * @return void |
528 | 528 | */ |
529 | 529 | protected function _init_hooks() { |
530 | - if ( empty( $this->_init_func) ) |
|
530 | + if (empty($this->_init_func)) |
|
531 | 531 | return; //get out there's nothing to take care of. |
532 | 532 | |
533 | 533 | //We need to determine what page_route we are on! |
534 | - $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
534 | + $current_route = isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
535 | 535 | |
536 | - foreach ( $this->_init_func as $route => $method ) { |
|
536 | + foreach ($this->_init_func as $route => $method) { |
|
537 | 537 | //make sure method exists |
538 | - if ( !method_exists($this, $method) ) { |
|
539 | - $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso') . '<br />'; |
|
540 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
541 | - throw new EE_Error( implode('||', $msg ) ); |
|
538 | + if ( ! method_exists($this, $method)) { |
|
539 | + $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso').'<br />'; |
|
540 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
541 | + throw new EE_Error(implode('||', $msg)); |
|
542 | 542 | } |
543 | - if ( $route == $this->_current_route ) |
|
544 | - add_action('admin_init', array( $this, $method ) ); |
|
543 | + if ($route == $this->_current_route) |
|
544 | + add_action('admin_init', array($this, $method)); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | } |
@@ -556,28 +556,28 @@ discard block |
||
556 | 556 | * @return void |
557 | 557 | */ |
558 | 558 | public function add_metaboxes() { |
559 | - if ( empty( $this->_metaboxes ) ) |
|
559 | + if (empty($this->_metaboxes)) |
|
560 | 560 | return; //get out we don't have any metaboxes to set for this connection |
561 | 561 | |
562 | - $this->_handle_metabox_array( $this->_metaboxes ); |
|
562 | + $this->_handle_metabox_array($this->_metaboxes); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
566 | 566 | |
567 | 567 | |
568 | - private function _handle_metabox_array( $boxes, $add = TRUE ) { |
|
568 | + private function _handle_metabox_array($boxes, $add = TRUE) { |
|
569 | 569 | |
570 | - foreach ( $boxes as $box ) { |
|
571 | - if ( !isset($box['page_route']) ) |
|
570 | + foreach ($boxes as $box) { |
|
571 | + if ( ! isset($box['page_route'])) |
|
572 | 572 | continue; //we dont' have a valid array |
573 | 573 | |
574 | 574 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
575 | 575 | $box['page_route'] = (array) $box['page_route']; |
576 | 576 | |
577 | - foreach ( $box['page_route'] as $route ) { |
|
578 | - if ( $route != $this->_current_route ) |
|
577 | + foreach ($box['page_route'] as $route) { |
|
578 | + if ($route != $this->_current_route) |
|
579 | 579 | continue; //get out we only add metaboxes for set route. |
580 | - if ( $add ) |
|
580 | + if ($add) |
|
581 | 581 | $this->_add_metabox($box); |
582 | 582 | else |
583 | 583 | $this->_remove_metabox($box); |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function remove_metaboxes() { |
597 | 597 | |
598 | - if ( empty( $this->_remove_metaboxes ) ) |
|
598 | + if (empty($this->_remove_metaboxes)) |
|
599 | 599 | return; //get out there are no metaboxes to remove |
600 | 600 | |
601 | - $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
|
601 | + $this->_handle_metabox_array($this->_remove_metaboxes, FALSE); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -608,53 +608,53 @@ discard block |
||
608 | 608 | * @access private |
609 | 609 | * @param array $args an array of args that have been set for this metabox by the child class |
610 | 610 | */ |
611 | - private function _add_metabox( $args ) { |
|
611 | + private function _add_metabox($args) { |
|
612 | 612 | $current_screen = get_current_screen(); |
613 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
614 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
613 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
614 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
615 | 615 | |
616 | 616 | //set defaults |
617 | 617 | $defaults = array( |
618 | 618 | 'func' => $func, |
619 | - 'id' => $this->caller . '_' . $func . '_metabox', |
|
619 | + 'id' => $this->caller.'_'.$func.'_metabox', |
|
620 | 620 | 'priority' => 'default', |
621 | 621 | 'label' => $this->caller, |
622 | 622 | 'context' => 'advanced', |
623 | 623 | 'callback_args' => array(), |
624 | - 'page' => isset( $args['page'] ) ? $args['page'] : $screen_id |
|
624 | + 'page' => isset($args['page']) ? $args['page'] : $screen_id |
|
625 | 625 | ); |
626 | 626 | |
627 | - $args = wp_parse_args( $args, $defaults ); |
|
627 | + $args = wp_parse_args($args, $defaults); |
|
628 | 628 | extract($args); |
629 | 629 | |
630 | 630 | |
631 | 631 | //make sure method exists |
632 | - if ( !method_exists($this, $func) ) { |
|
633 | - $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
634 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $func, $this->caller ); |
|
635 | - throw new EE_Error( implode('||', $msg ) ); |
|
632 | + if ( ! method_exists($this, $func)) { |
|
633 | + $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />'; |
|
634 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $func, $this->caller); |
|
635 | + throw new EE_Error(implode('||', $msg)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | //everything checks out so lets add the metabox |
639 | - add_meta_box( $id, $label, array( $this, $func ), $page, $context, $priority, $callback_args); |
|
639 | + add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | |
643 | 643 | |
644 | - private function _remove_metabox( $args ) { |
|
644 | + private function _remove_metabox($args) { |
|
645 | 645 | $current_screen = get_current_screen(); |
646 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
647 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
646 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
647 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
648 | 648 | |
649 | 649 | //set defaults |
650 | 650 | $defaults = array( |
651 | - 'id' => isset( $args['id'] ) ? $args['id'] : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox', |
|
651 | + 'id' => isset($args['id']) ? $args['id'] : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox', |
|
652 | 652 | 'context' => 'default', |
653 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : $screen_id |
|
653 | + 'screen' => isset($args['screen']) ? $args['screen'] : $screen_id |
|
654 | 654 | ); |
655 | 655 | |
656 | - $args = wp_parse_args( $args, $defaults ); |
|
657 | - extract( $args ); |
|
656 | + $args = wp_parse_args($args, $defaults); |
|
657 | + extract($args); |
|
658 | 658 | |
659 | 659 | //everything checks out so lets remove the box! |
660 | 660 | remove_meta_box($id, $screen, $context); |
@@ -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 { |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | * constructor |
245 | 245 | * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table. |
246 | 246 | */ |
247 | - public function __construct( EE_Admin_Page $admin_page ) { |
|
247 | + public function __construct(EE_Admin_Page $admin_page) { |
|
248 | 248 | $this->_admin_page = $admin_page; |
249 | 249 | $this->_req_data = $this->_admin_page->get_request_data(); |
250 | 250 | $this->_view = $this->_admin_page->get_view(); |
251 | - $this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
251 | + $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views; |
|
252 | 252 | $this->_current_page = $this->get_pagenum(); |
253 | - $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view(); |
|
254 | - $this->_yes_no = array( __('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
253 | + $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view(); |
|
254 | + $this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso')); |
|
255 | 255 | |
256 | - $this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 ); |
|
256 | + $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10); |
|
257 | 257 | |
258 | 258 | $this->_setup_data(); |
259 | 259 | $this->_add_view_counts(); |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $this->_set_properties(); |
264 | 264 | |
265 | 265 | //set primary column |
266 | - add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) ); |
|
266 | + add_filter('list_table_primary_column', array($this, 'set_primary_column')); |
|
267 | 267 | |
268 | 268 | //set parent defaults |
269 | 269 | parent::__construct($this->_wp_list_args); |
@@ -339,17 +339,17 @@ discard block |
||
339 | 339 | * @return string |
340 | 340 | */ |
341 | 341 | protected function _get_hidden_fields() { |
342 | - $action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : ''; |
|
343 | - $action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action; |
|
342 | + $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : ''; |
|
343 | + $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action; |
|
344 | 344 | //if action is STILL empty, then we set it to default |
345 | - $action = empty( $action ) ? 'default' : $action; |
|
346 | - $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n"; |
|
347 | - $field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/ |
|
348 | - $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n"; |
|
345 | + $action = empty($action) ? 'default' : $action; |
|
346 | + $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n"; |
|
347 | + $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/ |
|
348 | + $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n"; |
|
349 | 349 | |
350 | 350 | $bulk_actions = $this->_get_bulk_actions(); |
351 | - foreach ( $bulk_actions as $bulk_action => $label ) { |
|
352 | - $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce ( $bulk_action . '_nonce' ) . '" />' . "\n"; |
|
351 | + foreach ($bulk_actions as $bulk_action => $label) { |
|
352 | + $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n"; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | return $field; |
@@ -379,15 +379,15 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @var array |
381 | 381 | */ |
382 | - $_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen ); |
|
382 | + $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen); |
|
383 | 383 | |
384 | 384 | $sortable = array(); |
385 | - foreach ( $_sortable as $id => $data ) { |
|
386 | - if ( empty( $data ) ) |
|
385 | + foreach ($_sortable as $id => $data) { |
|
386 | + if (empty($data)) |
|
387 | 387 | continue; |
388 | 388 | |
389 | 389 | //fix for offset errors with WP_List_Table default get_columninfo() |
390 | - if ( is_array($data) ) { |
|
390 | + if (is_array($data)) { |
|
391 | 391 | $_data[0] = key($data); |
392 | 392 | $_data[1] = isset($data[1]) ? $data[1] : false; |
393 | 393 | } else { |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | |
397 | 397 | $data = (array) $data; |
398 | 398 | |
399 | - if ( !isset( $data[1] ) ) |
|
399 | + if ( ! isset($data[1])) |
|
400 | 400 | $_data[1] = false; |
401 | 401 | |
402 | 402 | |
403 | 403 | $sortable[$id] = $_data; |
404 | 404 | } |
405 | 405 | $primary = $this->get_primary_column_name(); |
406 | - $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); |
|
406 | + $this->_column_headers = array($columns, $hidden, $sortable, $primary); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -412,8 +412,8 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | protected function get_primary_column_name() { |
415 | - foreach( class_parents( $this ) as $parent ) { |
|
416 | - if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) { |
|
415 | + foreach (class_parents($this) as $parent) { |
|
416 | + if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') { |
|
417 | 417 | return parent::get_primary_column_name(); |
418 | 418 | } |
419 | 419 | } |
@@ -430,10 +430,10 @@ discard block |
||
430 | 430 | * @param string $primary |
431 | 431 | * @return string |
432 | 432 | */ |
433 | - protected function handle_row_actions( $item, $column_name, $primary ) { |
|
434 | - foreach( class_parents( $this ) as $parent ) { |
|
435 | - if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) { |
|
436 | - return parent::handle_row_actions( $item, $column_name, $primary ); |
|
433 | + protected function handle_row_actions($item, $column_name, $primary) { |
|
434 | + foreach (class_parents($this) as $parent) { |
|
435 | + if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') { |
|
436 | + return parent::handle_row_actions($item, $column_name, $primary); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | return ''; |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | protected function _get_bulk_actions() { |
452 | 452 | $actions = array(); |
453 | 453 | //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(); |
454 | - foreach ( $this->_views as $view => $args) { |
|
455 | - if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view ) |
|
454 | + foreach ($this->_views as $view => $args) { |
|
455 | + if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view) |
|
456 | 456 | //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. |
457 | - foreach ( $args['bulk_action'] as $route =>$label ) { |
|
458 | - if ( $this->_admin_page->check_user_access( $route, true ) ) { |
|
457 | + foreach ($args['bulk_action'] as $route =>$label) { |
|
458 | + if ($this->_admin_page->check_user_access($route, true)) { |
|
459 | 459 | $actions[$route] = $label; |
460 | 460 | } |
461 | 461 | } |
@@ -473,18 +473,18 @@ discard block |
||
473 | 473 | */ |
474 | 474 | private function _filters() { |
475 | 475 | $classname = get_class($this); |
476 | - $filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen ); |
|
476 | + $filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen); |
|
477 | 477 | |
478 | - if ( empty( $filters )) { |
|
478 | + if (empty($filters)) { |
|
479 | 479 | return; |
480 | 480 | } |
481 | - foreach ( $filters as $filter ) { |
|
481 | + foreach ($filters as $filter) { |
|
482 | 482 | echo $filter; |
483 | 483 | } |
484 | 484 | //add filter button at end |
485 | - echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />'; |
|
485 | + echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />'; |
|
486 | 486 | //add reset filters button at end |
487 | - echo '<a class="button button-secondary" href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>'; |
|
487 | + echo '<a class="button button-secondary" href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>'; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $column_name |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public function set_primary_column( $column_name ) { |
|
502 | - return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name; |
|
501 | + public function set_primary_column($column_name) { |
|
502 | + return ! empty($this->_primary_column) ? $this->_primary_column : $column_name; |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | array( |
519 | 519 | 'total_items' => $total_items, |
520 | 520 | 'per_page' => $this->_per_page, |
521 | - 'total_pages' => ceil($total_items / $this->_per_page ) |
|
521 | + 'total_pages' => ceil($total_items / $this->_per_page) |
|
522 | 522 | ) |
523 | 523 | ); |
524 | 524 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return string html content for the column |
536 | 536 | */ |
537 | - public function column_default( $item, $column_name ) { |
|
537 | + public function column_default($item, $column_name) { |
|
538 | 538 | /** |
539 | 539 | * Dynamic hook allowing for adding additional column content in this list table. |
540 | 540 | * Note that $this->screen->id is in the format |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | * hook prefix ("event-espresso") will be different. |
545 | 545 | * |
546 | 546 | */ |
547 | - do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen ); |
|
547 | + do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @var array |
562 | 562 | */ |
563 | - $columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen ); |
|
563 | + $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen); |
|
564 | 564 | return $columns; |
565 | 565 | } |
566 | 566 | |
@@ -572,18 +572,18 @@ discard block |
||
572 | 572 | $views = $this->get_views(); |
573 | 573 | $assembled_views = ''; |
574 | 574 | |
575 | - if ( empty( $views )) { |
|
575 | + if (empty($views)) { |
|
576 | 576 | return; |
577 | 577 | } |
578 | 578 | echo "<ul class='subsubsub'>\n"; |
579 | - foreach ( $views as $view ) { |
|
580 | - $count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] ) : 0; |
|
581 | - if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) { |
|
582 | - $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>'; |
|
579 | + foreach ($views as $view) { |
|
580 | + $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0; |
|
581 | + if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) { |
|
582 | + $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>'; |
|
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | - echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : ''; |
|
586 | + echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : ''; |
|
587 | 587 | echo "</ul>"; |
588 | 588 | } |
589 | 589 | |
@@ -596,10 +596,10 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @param object $item The current item |
598 | 598 | */ |
599 | - public function single_row( $item ) { |
|
600 | - $row_class = $this->_get_row_class( $item ); |
|
601 | - echo '<tr class="' . esc_attr( $row_class ) . '">'; |
|
602 | - $this->single_row_columns( $item ); |
|
599 | + public function single_row($item) { |
|
600 | + $row_class = $this->_get_row_class($item); |
|
601 | + echo '<tr class="'.esc_attr($row_class).'">'; |
|
602 | + $this->single_row_columns($item); |
|
603 | 603 | echo '</tr>'; |
604 | 604 | } |
605 | 605 | |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | * @param object $item the current item |
611 | 611 | * @return string |
612 | 612 | */ |
613 | - protected function _get_row_class( $item ) { |
|
613 | + protected function _get_row_class($item) { |
|
614 | 614 | static $row_class = ''; |
615 | - $row_class = ( $row_class == '' ? 'alternate' : '' ); |
|
615 | + $row_class = ($row_class == '' ? 'alternate' : ''); |
|
616 | 616 | |
617 | 617 | $new_row_class = $row_class; |
618 | 618 | |
619 | - if ( !empty($this->_ajax_sorting_callback) ) { |
|
619 | + if ( ! empty($this->_ajax_sorting_callback)) { |
|
620 | 620 | $new_row_class .= ' rowsortable'; |
621 | 621 | } |
622 | 622 | |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | |
636 | 636 | public function get_hidden_columns() { |
637 | 637 | $user_id = get_current_user_id(); |
638 | - $has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id); |
|
639 | - if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) { |
|
640 | - update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE); |
|
641 | - update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE ); |
|
638 | + $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id); |
|
639 | + if (empty($has_default) && ! empty($this->_hidden_columns)) { |
|
640 | + update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE); |
|
641 | + update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE); |
|
642 | 642 | } |
643 | - $ref = 'manage' . $this->screen->id . 'columnshidden'; |
|
644 | - $saved_columns = (array) get_user_option( $ref, $user_id ); |
|
643 | + $ref = 'manage'.$this->screen->id.'columnshidden'; |
|
644 | + $saved_columns = (array) get_user_option($ref, $user_id); |
|
645 | 645 | return $saved_columns; |
646 | 646 | } |
647 | 647 | |
@@ -656,47 +656,47 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @param object $item The current item |
658 | 658 | */ |
659 | - public function single_row_columns( $item ) { |
|
660 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
659 | + public function single_row_columns($item) { |
|
660 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
661 | 661 | |
662 | 662 | global $wp_version; |
663 | - $use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' ); |
|
663 | + $use_hidden_class = version_compare($wp_version, '4.3-RC', '>='); |
|
664 | 664 | |
665 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
665 | + foreach ($columns as $column_name => $column_display_name) { |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are |
669 | 669 | * hidden or not instead of using "display:none;". This bit of code provides backward compat. |
670 | 670 | */ |
671 | - $hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : ''; |
|
672 | - $style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : ''; |
|
671 | + $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : ''; |
|
672 | + $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : ''; |
|
673 | 673 | |
674 | - $classes = $column_name . ' column-' . $column_name.$hidden_class; |
|
675 | - if ( $primary == $column_name ) { |
|
674 | + $classes = $column_name.' column-'.$column_name.$hidden_class; |
|
675 | + if ($primary == $column_name) { |
|
676 | 676 | $classes .= ' has-row-actions column-primary'; |
677 | 677 | } |
678 | 678 | |
679 | - $data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"'; |
|
679 | + $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"'; |
|
680 | 680 | |
681 | 681 | $class = "class='$classes'"; |
682 | 682 | |
683 | 683 | $attributes = "$class$style$data"; |
684 | 684 | |
685 | - if ( 'cb' === $column_name ) { |
|
685 | + if ('cb' === $column_name) { |
|
686 | 686 | echo '<th scope="row" class="check-column">'; |
687 | - echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this ); |
|
687 | + echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this); |
|
688 | 688 | echo '</th>'; |
689 | 689 | } |
690 | - elseif ( method_exists( $this, 'column_' . $column_name ) ) { |
|
690 | + elseif (method_exists($this, 'column_'.$column_name)) { |
|
691 | 691 | echo "<td $attributes>"; |
692 | - 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 ); |
|
693 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
692 | + 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); |
|
693 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
694 | 694 | echo "</td>"; |
695 | 695 | } |
696 | 696 | else { |
697 | 697 | echo "<td $attributes>"; |
698 | - 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 ); |
|
699 | - echo $this->handle_row_actions( $item, $column_name, $primary ); |
|
698 | + 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); |
|
699 | + echo $this->handle_row_actions($item, $column_name, $primary); |
|
700 | 700 | echo "</td>"; |
701 | 701 | } |
702 | 702 | } |
@@ -704,19 +704,19 @@ discard block |
||
704 | 704 | |
705 | 705 | |
706 | 706 | |
707 | - public function extra_tablenav( $which ) { |
|
708 | - if ( $which == 'top' ) { |
|
707 | + public function extra_tablenav($which) { |
|
708 | + if ($which == 'top') { |
|
709 | 709 | $this->_filters(); |
710 | 710 | echo $this->_get_hidden_fields(); |
711 | 711 | echo '<br class="clear">'; |
712 | - }else{ |
|
712 | + } else { |
|
713 | 713 | echo '<div class="list-table-bottom-buttons alignleft actions">'; |
714 | - foreach($this->_bottom_buttons as $type => $action){ |
|
715 | - $route = isset( $action['route'] ) ? $action['route'] : ''; |
|
716 | - $extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : ''; |
|
714 | + foreach ($this->_bottom_buttons as $type => $action) { |
|
715 | + $route = isset($action['route']) ? $action['route'] : ''; |
|
716 | + $extra_request = isset($action['extra_request']) ? $action['extra_request'] : ''; |
|
717 | 717 | echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request); |
718 | 718 | } |
719 | - do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen ); |
|
719 | + do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen); |
|
720 | 720 | echo '</div>'; |
721 | 721 | } |
722 | 722 | //echo $this->_entries_per_page_dropdown; |
@@ -766,13 +766,13 @@ discard block |
||
766 | 766 | * |
767 | 767 | * @return string The assembled action elements container. |
768 | 768 | */ |
769 | - protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) { |
|
769 | + protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') { |
|
770 | 770 | $content = ''; |
771 | - $action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : ''; |
|
772 | - $action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : ''; |
|
773 | - $content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : ''; |
|
774 | - $content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this ); |
|
775 | - $content .= ! empty( $container ) ? '</' . $container . '>' : ''; |
|
771 | + $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : ''; |
|
772 | + $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : ''; |
|
773 | + $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : ''; |
|
774 | + $content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this); |
|
775 | + $content .= ! empty($container) ? '</'.$container.'>' : ''; |
|
776 | 776 | return $content; |
777 | 777 | } |
778 | 778 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function do_initial_loads() { |
33 | 33 | //we want to use the corresponding admin page object (but not route it!). To do this we just set _routing to false. That way this page object is being loaded on all pages to make sure we hook into admin properly. But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;) |
34 | 34 | //This is important because we have hooks that help redirect custom post type saves |
35 | - if ( !isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] != $this->_menu_map->menu_slug ) ) { |
|
35 | + if ( ! isset($_REQUEST['page']) || (isset($_REQUEST['page']) && $_REQUEST['page'] != $this->_menu_map->menu_slug)) { |
|
36 | 36 | $this->_routing = FALSE; |
37 | 37 | $this->_initialize_admin_page(); |
38 | 38 | } else { |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | $this->_initialize_admin_page(); |
41 | 41 | //added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality |
42 | 42 | remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
43 | - add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100 ); |
|
43 | + add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100); |
|
44 | 44 | //end removal of autosave functionality. |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | public function wp_just_in_time_script_localization() { |
49 | - wp_localize_script( 'autosave', 'autosaveL10n', array( |
|
49 | + wp_localize_script('autosave', 'autosaveL10n', array( |
|
50 | 50 | 'autosaveInterval' => 172800, |
51 | 51 | 'savingText' => __('Saving Draft…'), |
52 | 52 | 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 |
@@ -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 | * |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | $this->_set_init_properties(); |
89 | 89 | |
90 | 90 | //global styles/scripts across all wp admin pages |
91 | - add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5 ); |
|
91 | + add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5); |
|
92 | 92 | |
93 | 93 | //load initial stuff. |
94 | 94 | $this->_set_file_and_folder_name(); |
95 | 95 | |
96 | 96 | $this->_set_menu_map(); |
97 | 97 | |
98 | - if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) ) |
|
98 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) |
|
99 | 99 | { |
100 | - EE_Error::doing_it_wrong( get_class( $this ) . '::$_menu_map', sprintf( __('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso' ), get_class( $this ) ), '4.4.0' ); |
|
100 | + EE_Error::doing_it_wrong(get_class($this).'::$_menu_map', sprintf(__('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso'), get_class($this)), '4.4.0'); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function load_wp_global_scripts_styles() { |
160 | 160 | /** STYLES **/ |
161 | 161 | //register |
162 | - wp_register_style('espresso_menu', EE_ADMIN_URL . 'assets/admin-menu-styles.css'); |
|
162 | + wp_register_style('espresso_menu', EE_ADMIN_URL.'assets/admin-menu-styles.css'); |
|
163 | 163 | |
164 | 164 | |
165 | 165 | |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | |
202 | 202 | |
203 | 203 | protected function _set_capability() { |
204 | - $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
205 | - $this->capability = apply_filters( 'FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability ); |
|
204 | + $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
205 | + $this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function initialize_admin_page() { |
221 | 221 | //let's check user access first |
222 | 222 | $this->_check_user_access(); |
223 | - if ( !is_object( $this->_loaded_page_object) ) return; |
|
223 | + if ( ! is_object($this->_loaded_page_object)) return; |
|
224 | 224 | $this->_loaded_page_object->route_admin_request(); |
225 | 225 | return; |
226 | 226 | } |
@@ -232,25 +232,25 @@ discard block |
||
232 | 232 | |
233 | 233 | |
234 | 234 | public function set_page_dependencies($wp_page_slug) { |
235 | - if ( !$this->_load_page ) return; |
|
235 | + if ( ! $this->_load_page) return; |
|
236 | 236 | |
237 | - if ( !is_object($this->_loaded_page_object) ) { |
|
237 | + if ( ! is_object($this->_loaded_page_object)) { |
|
238 | 238 | $msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso'); |
239 | - $msg[] = $msg[0] . "\r\n" . sprintf( |
|
239 | + $msg[] = $msg[0]."\r\n".sprintf( |
|
240 | 240 | __('The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', 'event_espresso'), |
241 | 241 | $this->_file_name, |
242 | 242 | $this->_file_name, |
243 | - $this->_folder_path . $this->_file_name, |
|
243 | + $this->_folder_path.$this->_file_name, |
|
244 | 244 | $this->_menu_map->menu_slug |
245 | 245 | ); |
246 | - throw new EE_Error( implode( '||', $msg) ); |
|
246 | + throw new EE_Error(implode('||', $msg)); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
250 | - $page_hook = 'load-' . $wp_page_slug; |
|
250 | + $page_hook = 'load-'.$wp_page_slug; |
|
251 | 251 | //hook into page load hook so all page specific stuff get's loaded. |
252 | - if ( !empty($wp_page_slug) ) |
|
253 | - add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
252 | + if ( ! empty($wp_page_slug)) |
|
253 | + add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies')); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function do_initial_loads() { |
263 | 263 | //no loading or initializing if menu map is setup incorrectly. |
264 | - if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) ) { |
|
264 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | $this->_initialize_admin_page(); |
@@ -278,19 +278,19 @@ discard block |
||
278 | 278 | $bt = debug_backtrace(); |
279 | 279 | //for more reliable determination of folder name |
280 | 280 | //we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
281 | - $class = get_class( $this ); |
|
282 | - foreach ( $bt as $index => $values ) { |
|
283 | - if ( isset( $values['class'] ) && $values['class'] == $class ) { |
|
281 | + $class = get_class($this); |
|
282 | + foreach ($bt as $index => $values) { |
|
283 | + if (isset($values['class']) && $values['class'] == $class) { |
|
284 | 284 | $file_index = $index - 1; |
285 | - $this->_folder_name = basename(dirname($bt[$file_index]['file']) ); |
|
286 | - if ( !empty( $this->_folder_name ) ) break; |
|
285 | + $this->_folder_name = basename(dirname($bt[$file_index]['file'])); |
|
286 | + if ( ! empty($this->_folder_name)) break; |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . DS; |
|
290 | + $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.DS; |
|
291 | 291 | |
292 | - $this->_file_name = preg_replace( '/^ee/' , 'EE', $this->_folder_name ); |
|
293 | - $this->_file_name = ucwords( str_replace('_', ' ', $this->_file_name) ); |
|
292 | + $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
293 | + $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
294 | 294 | $this->_file_name = str_replace(' ', '_', $this->_file_name); |
295 | 295 | } |
296 | 296 | |
@@ -302,19 +302,19 @@ discard block |
||
302 | 302 | * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks files/classes |
303 | 303 | * @return array |
304 | 304 | */ |
305 | - public function register_hooks( $extend = FALSE ) { |
|
305 | + public function register_hooks($extend = FALSE) { |
|
306 | 306 | |
307 | 307 | //get a list of files in the directory that have the "Hook" in their name an |
308 | 308 | |
309 | 309 | //if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
310 | - if ( $extend ) { |
|
311 | - $hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS . '*' . $this->_file_name . '_Hooks_Extend.class.php' ); |
|
312 | - $this->_hook_paths = $this->_register_hook_files( $hook_files_glob_path, $extend ); |
|
310 | + if ($extend) { |
|
311 | + $hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS.'*'.$this->_file_name.'_Hooks_Extend.class.php'); |
|
312 | + $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | //loop through decaf folders |
316 | - $hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' ); |
|
317 | - $this->_hook_paths = array_merge( $this->_register_hook_files( $hook_files_glob_path ), $this->_hook_paths ); //making sure any extended hook paths are later in the array than the core hook paths! |
|
316 | + $hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php'); |
|
317 | + $this->_hook_paths = array_merge($this->_register_hook_files($hook_files_glob_path), $this->_hook_paths); //making sure any extended hook paths are later in the array than the core hook paths! |
|
318 | 318 | |
319 | 319 | return $this->_hook_paths; |
320 | 320 | |
@@ -322,27 +322,27 @@ discard block |
||
322 | 322 | |
323 | 323 | |
324 | 324 | |
325 | - protected function _register_hook_files( $hook_files_glob_path, $extend = FALSE ) { |
|
325 | + protected function _register_hook_files($hook_files_glob_path, $extend = FALSE) { |
|
326 | 326 | $hook_paths = array(); |
327 | - if ( $hook_files = glob( $hook_files_glob_path ) ) { |
|
328 | - if ( empty( $hook_files ) ) { |
|
327 | + if ($hook_files = glob($hook_files_glob_path)) { |
|
328 | + if (empty($hook_files)) { |
|
329 | 329 | return array(); |
330 | 330 | } |
331 | - foreach ( $hook_files as $file ) { |
|
331 | + foreach ($hook_files as $file) { |
|
332 | 332 | //lets get the linked admin. |
333 | - $hook_file = $extend ? str_replace( EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS, '', $file ) : str_replace($this->_folder_path, '', $file ); |
|
334 | - $replace = $extend ? '_' . $this->_file_name . '_Hooks_Extend.class.php' : '_' . $this->_file_name . '_Hooks.class.php'; |
|
335 | - $rel_admin = str_replace( $replace, '', $hook_file); |
|
333 | + $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS, '', $file) : str_replace($this->_folder_path, '', $file); |
|
334 | + $replace = $extend ? '_'.$this->_file_name.'_Hooks_Extend.class.php' : '_'.$this->_file_name.'_Hooks.class.php'; |
|
335 | + $rel_admin = str_replace($replace, '', $hook_file); |
|
336 | 336 | $rel_admin = strtolower($rel_admin); |
337 | 337 | $hook_paths[] = $file; |
338 | 338 | |
339 | 339 | //make sure we haven't already got a hook setup for this page path |
340 | - if ( in_array( $rel_admin, $this->_files_hooked ) ) |
|
340 | + if (in_array($rel_admin, $this->_files_hooked)) |
|
341 | 341 | continue; |
342 | 342 | |
343 | 343 | $this->hook_file = $hook_file; |
344 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
345 | - $filter = add_filter( $rel_admin_hook, array($this, 'load_admin_hook') ); |
|
344 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin; |
|
345 | + $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook')); |
|
346 | 346 | $this->_files_hooked[] = $rel_admin; |
347 | 347 | } |
348 | 348 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | protected function _initialize_admin_page() { |
368 | 368 | |
369 | 369 | //JUST CHECK WE'RE ON RIGHT PAGE. |
370 | - if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) |
|
370 | + if (( ! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) |
|
371 | 371 | return; //not on the right page so let's get out. |
372 | 372 | $this->_load_page = TRUE; |
373 | 373 | |
@@ -375,30 +375,30 @@ discard block |
||
375 | 375 | // spl_autoload_register(array( $this, 'set_autoloaders') ); |
376 | 376 | |
377 | 377 | //we don't need to do a page_request check here because it's only called via WP menu system. |
378 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
379 | - $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page; |
|
378 | + $admin_page = $this->_file_name.'_Admin_Page'; |
|
379 | + $hook_suffix = $this->_menu_map->menu_slug.'_'.$admin_page; |
|
380 | 380 | $admin_page = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", $admin_page); |
381 | 381 | |
382 | 382 | // define requested admin page class name then load the file and instantiate |
383 | - $path_to_file = str_replace( array( '\\', '/' ), DS, $this->_folder_path . $admin_page . '.core.php' ); |
|
384 | - $path_to_file=apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",$path_to_file );//so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
383 | + $path_to_file = str_replace(array('\\', '/'), DS, $this->_folder_path.$admin_page.'.core.php'); |
|
384 | + $path_to_file = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", $path_to_file); //so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
385 | 385 | |
386 | - if ( is_readable( $path_to_file )) { |
|
386 | + if (is_readable($path_to_file)) { |
|
387 | 387 | // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
388 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization' ); |
|
389 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug ); |
|
390 | - require_once( $path_to_file ); |
|
391 | - $a = new ReflectionClass( $admin_page ); |
|
392 | - $this->_loaded_page_object = $a->newInstance( $this->_routing ); |
|
388 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
389 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_'.$this->_menu_map->menu_slug); |
|
390 | + require_once($path_to_file); |
|
391 | + $a = new ReflectionClass($admin_page); |
|
392 | + $this->_loaded_page_object = $a->newInstance($this->_routing); |
|
393 | 393 | } |
394 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization' ); |
|
395 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug ); |
|
394 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
395 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_'.$this->_menu_map->menu_slug); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
399 | 399 | |
400 | 400 | public function get_admin_page_name() { |
401 | - return $this->_file_name . '_Admin_Page'; |
|
401 | + return $this->_file_name.'_Admin_Page'; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @return bool|die true if pass (or admin) wp_die if fail |
432 | 432 | */ |
433 | 433 | private function _check_user_access() { |
434 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $this->_menu_map->capability, $this->_menu_map->menu_slug ) ) { |
|
435 | - wp_die( __('You don\'t have access to this page.'), '', array( 'back_link' => true ) ); |
|
434 | + if ( ! EE_Registry::instance()->CAP->current_user_can($this->_menu_map->capability, $this->_menu_map->menu_slug)) { |
|
435 | + wp_die(__('You don\'t have access to this page.'), '', array('back_link' => true)); |
|
436 | 436 | } |
437 | 437 | return true; |
438 | 438 | } |
@@ -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 | * |
@@ -220,7 +222,9 @@ discard block |
||
220 | 222 | public function initialize_admin_page() { |
221 | 223 | //let's check user access first |
222 | 224 | $this->_check_user_access(); |
223 | - if ( !is_object( $this->_loaded_page_object) ) return; |
|
225 | + if ( !is_object( $this->_loaded_page_object) ) { |
|
226 | + return; |
|
227 | + } |
|
224 | 228 | $this->_loaded_page_object->route_admin_request(); |
225 | 229 | return; |
226 | 230 | } |
@@ -232,7 +236,9 @@ discard block |
||
232 | 236 | |
233 | 237 | |
234 | 238 | public function set_page_dependencies($wp_page_slug) { |
235 | - if ( !$this->_load_page ) return; |
|
239 | + if ( !$this->_load_page ) { |
|
240 | + return; |
|
241 | + } |
|
236 | 242 | |
237 | 243 | if ( !is_object($this->_loaded_page_object) ) { |
238 | 244 | $msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso'); |
@@ -249,8 +255,9 @@ discard block |
||
249 | 255 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
250 | 256 | $page_hook = 'load-' . $wp_page_slug; |
251 | 257 | //hook into page load hook so all page specific stuff get's loaded. |
252 | - if ( !empty($wp_page_slug) ) |
|
253 | - add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
258 | + if ( !empty($wp_page_slug) ) { |
|
259 | + add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
260 | + } |
|
254 | 261 | } |
255 | 262 | |
256 | 263 | |
@@ -283,7 +290,9 @@ discard block |
||
283 | 290 | if ( isset( $values['class'] ) && $values['class'] == $class ) { |
284 | 291 | $file_index = $index - 1; |
285 | 292 | $this->_folder_name = basename(dirname($bt[$file_index]['file']) ); |
286 | - if ( !empty( $this->_folder_name ) ) break; |
|
293 | + if ( !empty( $this->_folder_name ) ) { |
|
294 | + break; |
|
295 | + } |
|
287 | 296 | } |
288 | 297 | } |
289 | 298 | |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | $hook_paths[] = $file; |
338 | 347 | |
339 | 348 | //make sure we haven't already got a hook setup for this page path |
340 | - if ( in_array( $rel_admin, $this->_files_hooked ) ) |
|
341 | - continue; |
|
349 | + if ( in_array( $rel_admin, $this->_files_hooked ) ) { |
|
350 | + continue; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | $this->hook_file = $hook_file; |
344 | 354 | $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
@@ -367,8 +377,10 @@ discard block |
||
367 | 377 | protected function _initialize_admin_page() { |
368 | 378 | |
369 | 379 | //JUST CHECK WE'RE ON RIGHT PAGE. |
370 | - if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) |
|
371 | - return; //not on the right page so let's get out. |
|
380 | + if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) { |
|
381 | + return; |
|
382 | + } |
|
383 | + //not on the right page so let's get out. |
|
372 | 384 | $this->_load_page = TRUE; |
373 | 385 | |
374 | 386 | //let's set page specific autoloaders. Note that this just sets autoloaders for THIS set of admin pages. |