@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | <tbody> |
| 22 | 22 | <tr> |
| 23 | 23 | <th> |
| 24 | - <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?> |
|
| 24 | + <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?> |
|
| 25 | 25 | </th> |
| 26 | 26 | <td> |
| 27 | 27 | <input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/> |
@@ -31,23 +31,23 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | <tr> |
| 33 | 33 | <th> |
| 34 | - <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?> |
|
| 34 | + <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?> |
|
| 35 | 35 | </th> |
| 36 | 36 | <td> |
| 37 | 37 | <?php |
| 38 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
| 39 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
| 38 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
| 39 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
| 40 | 40 | ?> |
| 41 | 41 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled?>/> |
| 42 | 42 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" /> |
| 43 | - <?php if ( ! empty( $QST_system )) { ?> |
|
| 43 | + <?php if ( ! empty($QST_system)) { ?> |
|
| 44 | 44 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/> |
| 45 | 45 | <?php } ?> |
| 46 | 46 | <br/> |
| 47 | 47 | <p class="description"> |
| 48 | - <?php if ( ! empty( $QST_system )) { ?> |
|
| 48 | + <?php if ( ! empty($QST_system)) { ?> |
|
| 49 | 49 | <span class="description" style="color:#D54E21;"> |
| 50 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
| 50 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
| 51 | 51 | </span> |
| 52 | 52 | <?php } ?> |
| 53 | 53 | |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | <tr> |
| 59 | 59 | <th> |
| 60 | - <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?> |
|
| 60 | + <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?> |
|
| 61 | 61 | </th> |
| 62 | 62 | <td> |
| 63 | 63 | <?php |
| 64 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
| 65 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
| 64 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
| 65 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
| 66 | 66 | $admin_only = $question->get('QST_admin_only'); |
| 67 | - $checked = !empty( $admin_only ) ? ' checked="checked"' : ''; |
|
| 67 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
| 68 | 68 | ?> |
| 69 | 69 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled; echo $checked; ?>/> |
| 70 | 70 | <br/> |
| 71 | 71 | <p class="description"> |
| 72 | - <?php if ( ! empty( $QST_system )) { ?> |
|
| 72 | + <?php if ( ! empty($QST_system)) { ?> |
|
| 73 | 73 | <span class="description" style="color:#D54E21;"> |
| 74 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
| 74 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
| 75 | 75 | </span> |
| 76 | 76 | <?php } ?> |
| 77 | 77 | |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | <tr> |
| 83 | 83 | <th> |
| 84 | - <label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?> |
|
| 84 | + <label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?> |
|
| 85 | 85 | </th> |
| 86 | 86 | <td> |
| 87 | 87 | <?php |
| 88 | - $disabled = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
| 89 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
| 90 | - echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled ); |
|
| 91 | - if( ! empty( $QST_system ) ) { ?> |
|
| 88 | + $disabled = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
| 89 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
| 90 | + echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled); |
|
| 91 | + if ( ! empty($QST_system)) { ?> |
|
| 92 | 92 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
| 93 | 93 | <?php |
| 94 | - $explanatory_text = __('System question! This field cannot be changed.','event_espresso'); |
|
| 95 | - }else{ |
|
| 96 | - $explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
|
| 94 | + $explanatory_text = __('System question! This field cannot be changed.', 'event_espresso'); |
|
| 95 | + } else { |
|
| 96 | + $explanatory_text = __('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso'); |
|
| 97 | 97 | } |
| 98 | - if ( ! empty( $QST_system ) || $has_answers ) { ?> |
|
| 98 | + if ( ! empty($QST_system) || $has_answers) { ?> |
|
| 99 | 99 | <p><span class="description" style="color:#D54E21;"> |
| 100 | 100 | <?php echo $explanatory_text; ?> |
| 101 | 101 | </span></p> |
@@ -108,22 +108,22 @@ discard block |
||
| 108 | 108 | <tr id="text_input_question_options"> |
| 109 | 109 | <th> |
| 110 | 110 | <label> |
| 111 | - <?php _e( 'Maximum Allowed Response Size', 'event_espresso' );?> |
|
| 111 | + <?php _e('Maximum Allowed Response Size', 'event_espresso'); ?> |
|
| 112 | 112 | </label> |
| 113 | 113 | </th> |
| 114 | 114 | <td> |
| 115 | - <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1"> |
|
| 115 | + <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
| 116 | 116 | <p> |
| 117 | 117 | <span class="description"> |
| 118 | - <?php _e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?> |
|
| 118 | + <?php _e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?> |
|
| 119 | 119 | </span> |
| 120 | 120 | </p> |
| 121 | - <?php if ( $QST_system ) { ?> |
|
| 121 | + <?php if ($QST_system) { ?> |
|
| 122 | 122 | <p> |
| 123 | 123 | <span class="description" style="color:#D54E21;"> |
| 124 | 124 | <?php printf( |
| 125 | - __( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ), |
|
| 126 | - $max_max );?> |
|
| 125 | + __('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'), |
|
| 126 | + $max_max ); ?> |
|
| 127 | 127 | </span> |
| 128 | 128 | </p> |
| 129 | 129 | <?php } ?> |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | <tr id="question_options"> |
| 133 | 133 | <th> |
| 134 | 134 | <label> |
| 135 | - <?php _e('Answer Options','event_espresso')?> |
|
| 135 | + <?php _e('Answer Options', 'event_espresso')?> |
|
| 136 | 136 | </label> |
| 137 | 137 | </th> |
| 138 | 138 | <td> |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | <thead> |
| 142 | 142 | <tr> |
| 143 | 143 | <th class="option-value-header"> |
| 144 | - <?php _e('Value','event_espresso')?> |
|
| 144 | + <?php _e('Value', 'event_espresso')?> |
|
| 145 | 145 | </th> |
| 146 | 146 | <th class="option-desc-header"> |
| 147 | - <?php _e('Description (optional, only shown on registration form)','event_espresso')?> |
|
| 147 | + <?php _e('Description (optional, only shown on registration form)', 'event_espresso')?> |
|
| 148 | 148 | </th> |
| 149 | 149 | <th> |
| 150 | 150 | </th> |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | </tr> |
| 168 | 168 | |
| 169 | 169 | <?php |
| 170 | - $count=0; |
|
| 170 | + $count = 0; |
|
| 171 | 171 | $question_options = $question->options(); |
| 172 | - if ( ! empty( $question_options )) { |
|
| 173 | - foreach( $question_options as $option_id => $option ) { |
|
| 174 | - $disabled = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
| 172 | + if ( ! empty($question_options)) { |
|
| 173 | + foreach ($question_options as $option_id => $option) { |
|
| 174 | + $disabled = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
| 175 | 175 | ?> |
| 176 | 176 | <tr class="question-option ee-options-sortable"> |
| 177 | 177 | <td class="option-value-cell"> |
| 178 | 178 | <input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>"> |
| 179 | 179 | <input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php $option->f('QSO_value')?>"<?php echo $disabled; ?>> |
| 180 | - <?php if ( $has_answers ) : ?> |
|
| 180 | + <?php if ($has_answers) : ?> |
|
| 181 | 181 | <input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" > |
| 182 | 182 | <?php endif; ?> |
| 183 | 183 | </td> |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | <input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>"> |
| 186 | 186 | </td> |
| 187 | 187 | <td> |
| 188 | - <?php if ( ! $option->system() ) { ?> |
|
| 188 | + <?php if ( ! $option->system()) { ?> |
|
| 189 | 189 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
| 190 | 190 | <?php } ?> |
| 191 | 191 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | </table> |
| 225 | 225 | |
| 226 | 226 | <a id="new-question-option" class="button" style="margin:0 0 1em 3px;"> |
| 227 | - <?php _e('Add Another Answer Option','event_espresso')?> |
|
| 227 | + <?php _e('Add Another Answer Option', 'event_espresso')?> |
|
| 228 | 228 | </a><br/> |
| 229 | 229 | |
| 230 | 230 | <p class="description"> |
| 231 | - <?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?> |
|
| 231 | + <?php _e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?> |
|
| 232 | 232 | </p> |
| 233 | - <?php if ( $has_answers ) : ?> |
|
| 233 | + <?php if ($has_answers) : ?> |
|
| 234 | 234 | <p class="description" style="color:#D54E21;"> |
| 235 | 235 | <?php _e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?> |
| 236 | 236 | </p> |
@@ -241,32 +241,32 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | <tr> |
| 243 | 243 | <th> |
| 244 | - <label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?> |
|
| 244 | + <label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?> |
|
| 245 | 245 | </th> |
| 246 | 246 | <td> |
| 247 | 247 | <?php |
| 248 | - $system_required = array( 'fname', 'email' ); |
|
| 249 | - $disabled = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : ''; |
|
| 248 | + $system_required = array('fname', 'email'); |
|
| 249 | + $disabled = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
| 250 | 250 | $required_on = $question->get('QST_admin_only'); |
| 251 | 251 | $show_required_msg = $required_on ? '' : ' display:none;'; |
| 252 | - $disabled = $required_on || ! empty( $disabled ) ? ' disabled="disabled"' : ''; |
|
| 253 | - $id = ! empty( $disabled ) && in_array( $QST_system, $system_required) ? '_disabled' : ''; |
|
| 254 | - $requiredOptions=array( |
|
| 255 | - array('text'=>'Optional','id'=>0), |
|
| 256 | - array('text'=>'Required','id'=>1) |
|
| 252 | + $disabled = $required_on || ! empty($disabled) ? ' disabled="disabled"' : ''; |
|
| 253 | + $id = ! empty($disabled) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
| 254 | + $requiredOptions = array( |
|
| 255 | + array('text'=>'Optional', 'id'=>0), |
|
| 256 | + array('text'=>'Required', 'id'=>1) |
|
| 257 | 257 | ); |
| 258 | - echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled ); |
|
| 258 | + echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled); |
|
| 259 | 259 | ?> |
| 260 | 260 | <p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
| 261 | - <?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?> |
|
| 261 | + <?php _e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?> |
|
| 262 | 262 | </span></p> |
| 263 | 263 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
| 264 | - <?php _e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?> |
|
| 264 | + <?php _e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?> |
|
| 265 | 265 | </span></p> |
| 266 | - <?php if ( ! empty( $disabled ) && in_array( $QST_system, $system_required ) ) { ?> |
|
| 266 | + <?php if ( ! empty($disabled) && in_array($QST_system, $system_required)) { ?> |
|
| 267 | 267 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
| 268 | 268 | <p><span class="description" style="color:#D54E21;"> |
| 269 | - <?php _e('System question! This field cannot be changed.','event_espresso')?> |
|
| 269 | + <?php _e('System question! This field cannot be changed.', 'event_espresso')?> |
|
| 270 | 270 | </span></p> |
| 271 | 271 | <?php } ?> |
| 272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | <tr> |
| 277 | 277 | <th> |
| 278 | - <label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?> |
|
| 278 | + <label for="QST_required_text"><?php _e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
| 279 | 279 | </th> |
| 280 | 280 | <td> |
| 281 | 281 | <input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php $question->f('QST_required_text')?>"/> |
@@ -344,6 +344,7 @@ discard block |
||
| 344 | 344 | |
| 345 | 345 | /** |
| 346 | 346 | * @param mixed string | EED_Module $module |
| 347 | + * @param string $module |
|
| 347 | 348 | * @throws \EE_Error |
| 348 | 349 | */ |
| 349 | 350 | public function add_module( $module ) { |
@@ -901,7 +902,7 @@ discard block |
||
| 901 | 902 | * |
| 902 | 903 | * @access protected |
| 903 | 904 | * @param string $class_name |
| 904 | - * @param $class_prefix |
|
| 905 | + * @param string $class_prefix |
|
| 905 | 906 | * @param array $arguments |
| 906 | 907 | * @param string $type |
| 907 | 908 | * @param bool $from_db |
@@ -60,10 +60,10 @@ |
||
| 60 | 60 | public $REQ; |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * EE_Session Object |
|
| 64 | - * @access public |
|
| 65 | - * @var EE_Session $SSN |
|
| 66 | - */ |
|
| 63 | + * EE_Session Object |
|
| 64 | + * @access public |
|
| 65 | + * @var EE_Session $SSN |
|
| 66 | + */ |
|
| 67 | 67 | public $SSN; |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | public static function instance() { |
| 188 | 188 | // check if class object is instantiated |
| 189 | - if ( ! \EE_Load_Espresso_Core::getRegistryForBlog() instanceof EE_Registry ) { |
|
| 190 | - \EE_Load_Espresso_Core::setRegistryForBlog( new self() ); |
|
| 189 | + if ( ! \EE_Load_Espresso_Core::getRegistryForBlog() instanceof EE_Registry) { |
|
| 190 | + \EE_Load_Espresso_Core::setRegistryForBlog(new self()); |
|
| 191 | 191 | } |
| 192 | 192 | return \EE_Load_Espresso_Core::getRegistryForBlog(); |
| 193 | 193 | } |
@@ -213,19 +213,19 @@ discard block |
||
| 213 | 213 | * @throws \RuntimeException |
| 214 | 214 | */ |
| 215 | 215 | public function initialize() { |
| 216 | - if ( ! $this->dependency_map() instanceof \EE_Dependency_Map ) { |
|
| 216 | + if ( ! $this->dependency_map() instanceof \EE_Dependency_Map) { |
|
| 217 | 217 | throw new RuntimeException( |
| 218 | - __( 'The EE_Dependency_Map object needs to be setter injected before initializing the Registry', 'event_espresso' ) |
|
| 218 | + __('The EE_Dependency_Map object needs to be setter injected before initializing the Registry', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | - if ( ! $this->request() instanceof \EE_Request ) { |
|
| 221 | + if ( ! $this->request() instanceof \EE_Request) { |
|
| 222 | 222 | throw new RuntimeException( |
| 223 | - __( 'The EE_Request object needs to be setter injected before initializing the Registry', 'event_espresso' ) |
|
| 223 | + __('The EE_Request object needs to be setter injected before initializing the Registry', 'event_espresso') |
|
| 224 | 224 | ); |
| 225 | 225 | } |
| 226 | - if ( ! $this->response() instanceof \EE_Response ) { |
|
| 226 | + if ( ! $this->response() instanceof \EE_Response) { |
|
| 227 | 227 | throw new RuntimeException( |
| 228 | - __( 'The EE_Response object needs to be setter injected before initializing the Registry', 'event_espresso' ) |
|
| 228 | + __('The EE_Response object needs to be setter injected before initializing the Registry', 'event_espresso') |
|
| 229 | 229 | ); |
| 230 | 230 | } |
| 231 | 231 | $this->_class_abbreviations = apply_filters( |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | $this->modules = new stdClass(); |
| 247 | 247 | $this->shortcodes = new stdClass(); |
| 248 | 248 | $this->widgets = new stdClass(); |
| 249 | - $this->_set_cached_class( $this->request(), 'EE_Request' ); |
|
| 250 | - $this->_set_cached_class( $this->response(), 'EE_Response' ); |
|
| 251 | - $this->load_core( 'Base', array(), true ); |
|
| 252 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
| 249 | + $this->_set_cached_class($this->request(), 'EE_Request'); |
|
| 250 | + $this->_set_cached_class($this->response(), 'EE_Response'); |
|
| 251 | + $this->load_core('Base', array(), true); |
|
| 252 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * @param \EE_Request $request |
| 268 | 268 | */ |
| 269 | - public function set_request( \EE_Request $request ) { |
|
| 269 | + public function set_request(\EE_Request $request) { |
|
| 270 | 270 | $this->request = $request; |
| 271 | 271 | } |
| 272 | 272 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | /** |
| 285 | 285 | * @param \EE_Response $response |
| 286 | 286 | */ |
| 287 | - public function set_response( \EE_Response $response ) { |
|
| 287 | + public function set_response(\EE_Response $response) { |
|
| 288 | 288 | $this->response = $response; |
| 289 | 289 | } |
| 290 | 290 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | /** |
| 303 | 303 | * @param \EE_Dependency_Map $dependency_map |
| 304 | 304 | */ |
| 305 | - public function set_dependency_map( \EE_Dependency_Map $dependency_map ) { |
|
| 305 | + public function set_dependency_map(\EE_Dependency_Map $dependency_map) { |
|
| 306 | 306 | $this->_dependency_map = $dependency_map; |
| 307 | 307 | } |
| 308 | 308 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | */ |
| 317 | 317 | public function init() { |
| 318 | 318 | // Get current page protocol |
| 319 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
| 319 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 320 | 320 | // Output admin-ajax.php URL with same protocol as current page |
| 321 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
| 322 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
| 321 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
| 322 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | * @return string |
| 331 | 331 | */ |
| 332 | 332 | public static function localize_i18n_js_strings() { |
| 333 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
| 334 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
| 335 | - if ( is_scalar( $value ) ) { |
|
| 336 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
| 333 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
| 334 | + foreach ($i18n_js_strings as $key => $value) { |
|
| 335 | + if (is_scalar($value)) { |
|
| 336 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
| 340 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
@@ -346,13 +346,13 @@ discard block |
||
| 346 | 346 | * @param mixed string | EED_Module $module |
| 347 | 347 | * @throws \EE_Error |
| 348 | 348 | */ |
| 349 | - public function add_module( $module ) { |
|
| 350 | - if ( $module instanceof EED_Module ) { |
|
| 351 | - $module_class = get_class( $module ); |
|
| 349 | + public function add_module($module) { |
|
| 350 | + if ($module instanceof EED_Module) { |
|
| 351 | + $module_class = get_class($module); |
|
| 352 | 352 | $this->modules->{$module_class} = $module; |
| 353 | 353 | } else { |
| 354 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
| 355 | - $this->load_core( 'Module_Request_Router' ); |
|
| 354 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
| 355 | + $this->load_core('Module_Request_Router'); |
|
| 356 | 356 | } |
| 357 | 357 | $this->modules->{$module} = EE_Module_Request_Router::module_factory( |
| 358 | 358 | $module, |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | * @param string $module_name |
| 369 | 369 | * @return mixed EED_Module | NULL |
| 370 | 370 | */ |
| 371 | - public function get_module( $module_name = '' ) { |
|
| 372 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 371 | + public function get_module($module_name = '') { |
|
| 372 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -384,20 +384,20 @@ discard block |
||
| 384 | 384 | * @return mixed |
| 385 | 385 | * @throws \EE_Error |
| 386 | 386 | */ |
| 387 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
| 387 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
| 388 | 388 | $core_paths = apply_filters( |
| 389 | 389 | 'FHEE__EE_Registry__load_core__core_paths', |
| 390 | 390 | array( |
| 391 | 391 | EE_CORE, |
| 392 | 392 | EE_ADMIN, |
| 393 | 393 | EE_CPTS, |
| 394 | - EE_CORE . 'data_migration_scripts' . DS, |
|
| 395 | - EE_CORE . 'request_stack' . DS, |
|
| 396 | - EE_CORE . 'middleware' . DS, |
|
| 394 | + EE_CORE.'data_migration_scripts'.DS, |
|
| 395 | + EE_CORE.'request_stack'.DS, |
|
| 396 | + EE_CORE.'middleware'.DS, |
|
| 397 | 397 | ) |
| 398 | 398 | ); |
| 399 | 399 | // retrieve instantiated class |
| 400 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
| 400 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
@@ -412,15 +412,15 @@ discard block |
||
| 412 | 412 | * @return mixed |
| 413 | 413 | * @throws \EE_Error |
| 414 | 414 | */ |
| 415 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
| 415 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
| 416 | 416 | $service_paths = apply_filters( |
| 417 | 417 | 'FHEE__EE_Registry__load_service__service_paths', |
| 418 | 418 | array( |
| 419 | - EE_CORE . 'services' . DS, |
|
| 419 | + EE_CORE.'services'.DS, |
|
| 420 | 420 | ) |
| 421 | 421 | ); |
| 422 | 422 | // retrieve instantiated class |
| 423 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
| 423 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | |
@@ -434,9 +434,9 @@ discard block |
||
| 434 | 434 | * @return EE_Data_Migration_Script_Base |
| 435 | 435 | * @throws \EE_Error |
| 436 | 436 | */ |
| 437 | - public function load_dms( $class_name, $arguments = array() ) { |
|
| 437 | + public function load_dms($class_name, $arguments = array()) { |
|
| 438 | 438 | // retrieve instantiated class |
| 439 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
| 439 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | |
@@ -453,14 +453,14 @@ discard block |
||
| 453 | 453 | * @return EE_Base_Class |
| 454 | 454 | * @throws \EE_Error |
| 455 | 455 | */ |
| 456 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
| 457 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
| 456 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
| 457 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
| 458 | 458 | EE_CORE, |
| 459 | 459 | EE_CLASSES, |
| 460 | 460 | EE_BUSINESS |
| 461 | - ) ); |
|
| 461 | + )); |
|
| 462 | 462 | // retrieve instantiated class |
| 463 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
| 463 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -474,11 +474,11 @@ discard block |
||
| 474 | 474 | * @return EEH_Base |
| 475 | 475 | * @throws \EE_Error |
| 476 | 476 | */ |
| 477 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
| 477 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
| 478 | 478 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
| 479 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
| 479 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
| 480 | 480 | // retrieve instantiated class |
| 481 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
| 481 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | |
@@ -494,16 +494,16 @@ discard block |
||
| 494 | 494 | * @return mixed |
| 495 | 495 | * @throws \EE_Error |
| 496 | 496 | */ |
| 497 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
| 497 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
| 498 | 498 | $paths = array( |
| 499 | 499 | EE_LIBRARIES, |
| 500 | - EE_LIBRARIES . 'messages' . DS, |
|
| 501 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
| 502 | - EE_LIBRARIES . 'qtips' . DS, |
|
| 503 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
| 500 | + EE_LIBRARIES.'messages'.DS, |
|
| 501 | + EE_LIBRARIES.'shortcodes'.DS, |
|
| 502 | + EE_LIBRARIES.'qtips'.DS, |
|
| 503 | + EE_LIBRARIES.'payment_methods'.DS, |
|
| 504 | 504 | ); |
| 505 | 505 | // retrieve instantiated class |
| 506 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
| 506 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | |
@@ -517,13 +517,13 @@ discard block |
||
| 517 | 517 | * @return EEM_Base |
| 518 | 518 | * @throws \EE_Error |
| 519 | 519 | */ |
| 520 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
| 521 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
| 520 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
| 521 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
| 522 | 522 | EE_MODELS, |
| 523 | 523 | EE_CORE |
| 524 | - ) ); |
|
| 524 | + )); |
|
| 525 | 525 | // retrieve instantiated class |
| 526 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
| 526 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | |
@@ -537,15 +537,15 @@ discard block |
||
| 537 | 537 | * @return mixed |
| 538 | 538 | * @throws \EE_Error |
| 539 | 539 | */ |
| 540 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
| 540 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
| 541 | 541 | $paths = array( |
| 542 | - EE_MODELS . 'fields' . DS, |
|
| 543 | - EE_MODELS . 'helpers' . DS, |
|
| 544 | - EE_MODELS . 'relations' . DS, |
|
| 545 | - EE_MODELS . 'strategies' . DS |
|
| 542 | + EE_MODELS.'fields'.DS, |
|
| 543 | + EE_MODELS.'helpers'.DS, |
|
| 544 | + EE_MODELS.'relations'.DS, |
|
| 545 | + EE_MODELS.'strategies'.DS |
|
| 546 | 546 | ); |
| 547 | 547 | // retrieve instantiated class |
| 548 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
| 548 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | |
@@ -555,8 +555,8 @@ discard block |
||
| 555 | 555 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
| 556 | 556 | * @return boolean |
| 557 | 557 | */ |
| 558 | - public function is_model_name( $model_name ) { |
|
| 559 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
| 558 | + public function is_model_name($model_name) { |
|
| 559 | + return isset($this->models[$model_name]) ? true : false; |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | * @return mixed |
| 573 | 573 | * @throws \EE_Error |
| 574 | 574 | */ |
| 575 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
| 575 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
| 576 | 576 | // retrieve instantiated class |
| 577 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
| 577 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | |
@@ -590,9 +590,9 @@ discard block |
||
| 590 | 590 | * @return EE_Addon |
| 591 | 591 | * @throws \EE_Error |
| 592 | 592 | */ |
| 593 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
| 593 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
| 594 | 594 | // retrieve instantiated class |
| 595 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
| 595 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | |
@@ -617,21 +617,21 @@ discard block |
||
| 617 | 617 | $load_only = false, |
| 618 | 618 | $addon = false |
| 619 | 619 | ) { |
| 620 | - if ( ! class_exists( $class_name ) ) { |
|
| 620 | + if ( ! class_exists($class_name)) { |
|
| 621 | 621 | return null; |
| 622 | 622 | } |
| 623 | 623 | // if we're only loading the class and it already exists, then let's just return true immediately |
| 624 | - if ( $load_only ) { |
|
| 624 | + if ($load_only) { |
|
| 625 | 625 | return true; |
| 626 | 626 | } |
| 627 | 627 | $addon = $addon ? 'addon' : ''; |
| 628 | - $class_obj = $this->_check_cache_for_class( $class_name, $addon, $cache, $load_only ); |
|
| 629 | - if ( $class_obj !== null ) { |
|
| 628 | + $class_obj = $this->_check_cache_for_class($class_name, $addon, $cache, $load_only); |
|
| 629 | + if ($class_obj !== null) { |
|
| 630 | 630 | // return object if it's already cached |
| 631 | 631 | return $class_obj; |
| 632 | 632 | } |
| 633 | 633 | // instantiate the requested object |
| 634 | - return $this->_create_object_and_cache( $class_name, $addon, $arguments, 'FQCN', $from_db, $cache ); |
|
| 634 | + return $this->_create_object_and_cache($class_name, $addon, $arguments, 'FQCN', $from_db, $cache); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | |
@@ -661,23 +661,23 @@ discard block |
||
| 661 | 661 | $cache = true, |
| 662 | 662 | $load_only = false |
| 663 | 663 | ) { |
| 664 | - $class_name = $this->_process_classname( $class_prefix, $class_name ); |
|
| 665 | - $class_exists = class_exists( $class_name ); |
|
| 664 | + $class_name = $this->_process_classname($class_prefix, $class_name); |
|
| 665 | + $class_exists = class_exists($class_name); |
|
| 666 | 666 | // if we're only loading the class and it already exists, then let's just return true immediately |
| 667 | - if ( $load_only && $class_exists ) { |
|
| 667 | + if ($load_only && $class_exists) { |
|
| 668 | 668 | return true; |
| 669 | 669 | } |
| 670 | - $class_obj = $this->_check_cache_for_class( $class_name, $class_prefix, $cache, $load_only ); |
|
| 671 | - if ( $class_obj !== null ) { |
|
| 670 | + $class_obj = $this->_check_cache_for_class($class_name, $class_prefix, $cache, $load_only); |
|
| 671 | + if ($class_obj !== null) { |
|
| 672 | 672 | // return object if it's already cached |
| 673 | 673 | return $class_obj; |
| 674 | 674 | } |
| 675 | 675 | // if the class doesn't exist and can't be found, then just return nothing |
| 676 | - if ( ! $this->_resolve_path_and_require_file( $class_exists, $class_name, $type, $file_paths, $load_only ) ) { |
|
| 676 | + if ( ! $this->_resolve_path_and_require_file($class_exists, $class_name, $type, $file_paths, $load_only)) { |
|
| 677 | 677 | return null; |
| 678 | 678 | } |
| 679 | 679 | // instantiate the requested object |
| 680 | - return $this->_create_object_and_cache( $class_name, $class_prefix, $arguments, $type, $from_db, $cache ); |
|
| 680 | + return $this->_create_object_and_cache($class_name, $class_prefix, $arguments, $type, $from_db, $cache); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | |
@@ -695,13 +695,13 @@ discard block |
||
| 695 | 695 | $class_name = '' |
| 696 | 696 | ) { |
| 697 | 697 | // strip php file extension |
| 698 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
| 698 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
| 699 | 699 | // does the class have a prefix ? |
| 700 | - if ( ! empty( $class_prefix ) && $class_prefix !== 'addon' ) { |
|
| 700 | + if ( ! empty($class_prefix) && $class_prefix !== 'addon') { |
|
| 701 | 701 | // make sure $class_prefix is uppercase |
| 702 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
| 702 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
| 703 | 703 | // add class prefix ONCE!!! |
| 704 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
| 704 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
| 705 | 705 | } |
| 706 | 706 | return $class_name; |
| 707 | 707 | } |
@@ -718,14 +718,14 @@ discard block |
||
| 718 | 718 | * @return mixed null = failure to load or instantiate class object. |
| 719 | 719 | * object = class loaded and instantiated successfully. |
| 720 | 720 | */ |
| 721 | - private function _check_cache_for_class( $class_name, $class_prefix, $cache, $load_only ) { |
|
| 721 | + private function _check_cache_for_class($class_name, $class_prefix, $cache, $load_only) { |
|
| 722 | 722 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
| 723 | 723 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
| 724 | 724 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
| 725 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
| 725 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
| 726 | 726 | // return object if it's already cached |
| 727 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
| 728 | - if ( $cached_class !== null ) { |
|
| 727 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
| 728 | + if ($cached_class !== null) { |
|
| 729 | 729 | return $cached_class; |
| 730 | 730 | } |
| 731 | 731 | } |
@@ -750,20 +750,20 @@ discard block |
||
| 750 | 750 | * @param string $class_prefix |
| 751 | 751 | * @return mixed |
| 752 | 752 | */ |
| 753 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
| 753 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
| 754 | 754 | // have to specify something, but not anything that will conflict |
| 755 | 755 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
| 756 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 757 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 756 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 757 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 758 | 758 | } |
| 759 | 759 | // check if class has already been loaded, and return it if it has been |
| 760 | - if ( isset( $this->{$class_abbreviation} ) && $this->{$class_abbreviation} !== null ) { |
|
| 760 | + if (isset($this->{$class_abbreviation} ) && $this->{$class_abbreviation} !== null) { |
|
| 761 | 761 | return $this->{$class_abbreviation}; |
| 762 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
| 762 | + } else if (isset ($this->{$class_name} )) { |
|
| 763 | 763 | return $this->{$class_name}; |
| 764 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
| 764 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
| 765 | 765 | return $this->LIB->{$class_name}; |
| 766 | - } else if ( $class_prefix === 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
| 766 | + } else if ($class_prefix === 'addon' && isset ($this->addons->{$class_name} )) { |
|
| 767 | 767 | return $this->addons->{$class_name}; |
| 768 | 768 | } |
| 769 | 769 | return null; |
@@ -792,13 +792,13 @@ discard block |
||
| 792 | 792 | $load_only = false |
| 793 | 793 | ) { |
| 794 | 794 | // if the class doesn't already exist.. then we need to try and find the file and load it |
| 795 | - if ( ! $class_exists ) { |
|
| 795 | + if ( ! $class_exists) { |
|
| 796 | 796 | // get full path to file |
| 797 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
| 797 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
| 798 | 798 | // load the file |
| 799 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
| 799 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
| 800 | 800 | // if loading failed, or we are only loading a file but NOT instantiating an object |
| 801 | - if ( ! $loaded || $load_only ) { |
|
| 801 | + if ( ! $loaded || $load_only) { |
|
| 802 | 802 | // return boolean if only loading, or null if an object was expected |
| 803 | 803 | return $load_only ? $loaded : false; |
| 804 | 804 | } |
@@ -821,20 +821,20 @@ discard block |
||
| 821 | 821 | * @param array $file_paths |
| 822 | 822 | * @return string | bool |
| 823 | 823 | */ |
| 824 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
| 824 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
| 825 | 825 | // make sure $file_paths is an array |
| 826 | - $file_paths = (array)$file_paths; |
|
| 826 | + $file_paths = (array) $file_paths; |
|
| 827 | 827 | // cycle thru paths |
| 828 | - foreach ( $file_paths as $key => $file_path ) { |
|
| 828 | + foreach ($file_paths as $key => $file_path) { |
|
| 829 | 829 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
| 830 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
| 830 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
| 831 | 831 | // prep file type |
| 832 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
| 832 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
| 833 | 833 | // build full file path |
| 834 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
| 834 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
| 835 | 835 | //does the file exist and can be read ? |
| 836 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
| 837 | - return $file_paths[ $key ]; |
|
| 836 | + if (is_readable($file_paths[$key])) { |
|
| 837 | + return $file_paths[$key]; |
|
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | return false; |
@@ -856,29 +856,29 @@ discard block |
||
| 856 | 856 | * @return boolean |
| 857 | 857 | * @throws \EE_Error |
| 858 | 858 | */ |
| 859 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
| 859 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
| 860 | 860 | // don't give up! you gotta... |
| 861 | 861 | try { |
| 862 | 862 | //does the file exist and can it be read ? |
| 863 | - if ( ! $path ) { |
|
| 863 | + if ( ! $path) { |
|
| 864 | 864 | // so sorry, can't find the file |
| 865 | - throw new EE_Error ( |
|
| 865 | + throw new EE_Error( |
|
| 866 | 866 | sprintf( |
| 867 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
| 868 | - trim( $type, '.' ), |
|
| 867 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
| 868 | + trim($type, '.'), |
|
| 869 | 869 | $class_name, |
| 870 | - '<br />' . implode( ',<br />', $file_paths ) |
|
| 870 | + '<br />'.implode(',<br />', $file_paths) |
|
| 871 | 871 | ) |
| 872 | 872 | ); |
| 873 | 873 | } |
| 874 | 874 | // get the file |
| 875 | - require_once( $path ); |
|
| 875 | + require_once($path); |
|
| 876 | 876 | // if the class isn't already declared somewhere |
| 877 | - if ( class_exists( $class_name, false ) === false ) { |
|
| 877 | + if (class_exists($class_name, false) === false) { |
|
| 878 | 878 | // so sorry, not a class |
| 879 | 879 | throw new EE_Error( |
| 880 | 880 | sprintf( |
| 881 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
| 881 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
| 882 | 882 | $type, |
| 883 | 883 | $path, |
| 884 | 884 | $class_name |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | ); |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | - } catch ( EE_Error $e ) { |
|
| 889 | + } catch (EE_Error $e) { |
|
| 890 | 890 | $e->get_error(); |
| 891 | 891 | return false; |
| 892 | 892 | } |
@@ -918,10 +918,10 @@ discard block |
||
| 918 | 918 | $cache = true |
| 919 | 919 | ) { |
| 920 | 920 | // instantiate the requested object |
| 921 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
| 922 | - if ( $this->_cache_on && $cache ) { |
|
| 921 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
| 922 | + if ($this->_cache_on && $cache) { |
|
| 923 | 923 | // save it for later... kinda like gum { : $ |
| 924 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
| 924 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
| 925 | 925 | } |
| 926 | 926 | $this->_cache_on = true; |
| 927 | 927 | return $class_obj; |
@@ -952,55 +952,55 @@ discard block |
||
| 952 | 952 | * @return mixed |
| 953 | 953 | * @throws \EE_Error |
| 954 | 954 | */ |
| 955 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
| 955 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
| 956 | 956 | $class_obj = null; |
| 957 | 957 | // don't give up! you gotta... |
| 958 | 958 | try { |
| 959 | 959 | // create reflection |
| 960 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
| 960 | + $reflector = $this->get_ReflectionClass($class_name); |
|
| 961 | 961 | // make sure arguments are an array |
| 962 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
| 962 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
| 963 | 963 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
| 964 | 964 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
| 965 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
| 965 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
| 966 | 966 | ? $arguments |
| 967 | - : array( $arguments ); |
|
| 967 | + : array($arguments); |
|
| 968 | 968 | // attempt to inject dependencies ? |
| 969 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
| 970 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
| 969 | + if ($this->_dependency_map->has($class_name)) { |
|
| 970 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
| 971 | 971 | } |
| 972 | 972 | // instantiate the class and add to the LIB array for tracking |
| 973 | 973 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
| 974 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) { |
|
| 974 | + if ($reflector->getConstructor() === null || $reflector->isAbstract()) { |
|
| 975 | 975 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
| 976 | 976 | //$instantiation_mode = "no constructor"; |
| 977 | 977 | $class_obj = true; |
| 978 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
| 978 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
| 979 | 979 | //$instantiation_mode = "new_instance_from_db"; |
| 980 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
| 981 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
| 980 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
| 981 | + } else if (method_exists($class_name, 'new_instance')) { |
|
| 982 | 982 | //$instantiation_mode = "new_instance"; |
| 983 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
| 984 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
| 983 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
| 984 | + } else if (method_exists($class_name, 'instance')) { |
|
| 985 | 985 | //$instantiation_mode = "instance"; |
| 986 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
| 987 | - } else if ( $reflector->isInstantiable() ) { |
|
| 986 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
| 987 | + } else if ($reflector->isInstantiable()) { |
|
| 988 | 988 | //$instantiation_mode = "isInstantiable"; |
| 989 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
| 989 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
| 990 | 990 | } else { |
| 991 | 991 | // heh ? something's not right ! |
| 992 | 992 | //$instantiation_mode = 'none'; |
| 993 | 993 | throw new EE_Error( |
| 994 | 994 | sprintf( |
| 995 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
| 995 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
| 996 | 996 | $type, |
| 997 | 997 | $class_name |
| 998 | 998 | ) |
| 999 | 999 | ); |
| 1000 | 1000 | } |
| 1001 | - } catch ( Exception $e ) { |
|
| 1002 | - if ( ! $e instanceof EE_Error ) { |
|
| 1003 | - $e = new EE_Error( $e->getMessage() ); |
|
| 1001 | + } catch (Exception $e) { |
|
| 1002 | + if ( ! $e instanceof EE_Error) { |
|
| 1003 | + $e = new EE_Error($e->getMessage()); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | $e->get_error(); |
| 1006 | 1006 | } |
@@ -1014,8 +1014,8 @@ discard block |
||
| 1014 | 1014 | * @param array $array |
| 1015 | 1015 | * @return bool |
| 1016 | 1016 | */ |
| 1017 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
| 1018 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
| 1017 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
| 1018 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | |
| 1021 | 1021 | |
@@ -1030,14 +1030,14 @@ discard block |
||
| 1030 | 1030 | * @param string $class_name |
| 1031 | 1031 | * @return ReflectionClass |
| 1032 | 1032 | */ |
| 1033 | - public function get_ReflectionClass( $class_name ) { |
|
| 1033 | + public function get_ReflectionClass($class_name) { |
|
| 1034 | 1034 | if ( |
| 1035 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
| 1036 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
| 1035 | + ! isset($this->_reflectors[$class_name]) |
|
| 1036 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
| 1037 | 1037 | ) { |
| 1038 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
| 1038 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
| 1039 | 1039 | } |
| 1040 | - return $this->_reflectors[ $class_name ]; |
|
| 1040 | + return $this->_reflectors[$class_name]; |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | |
@@ -1062,45 +1062,45 @@ discard block |
||
| 1062 | 1062 | * @param array $arguments |
| 1063 | 1063 | * @return array |
| 1064 | 1064 | */ |
| 1065 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
| 1065 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
| 1066 | 1066 | // let's examine the constructor |
| 1067 | 1067 | $constructor = $reflector->getConstructor(); |
| 1068 | 1068 | // whu? huh? nothing? |
| 1069 | - if ( ! $constructor ) { |
|
| 1069 | + if ( ! $constructor) { |
|
| 1070 | 1070 | return $arguments; |
| 1071 | 1071 | } |
| 1072 | 1072 | // get constructor parameters |
| 1073 | 1073 | $params = $constructor->getParameters(); |
| 1074 | 1074 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
| 1075 | - $argument_keys = array_keys( $arguments ); |
|
| 1075 | + $argument_keys = array_keys($arguments); |
|
| 1076 | 1076 | // now loop thru all of the constructors expected parameters |
| 1077 | - foreach ( $params as $index => $param ) { |
|
| 1077 | + foreach ($params as $index => $param) { |
|
| 1078 | 1078 | // is this a dependency for a specific class ? |
| 1079 | 1079 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
| 1080 | 1080 | if ( |
| 1081 | 1081 | // param is not even a class |
| 1082 | - empty( $param_class ) |
|
| 1082 | + empty($param_class) |
|
| 1083 | 1083 | // and something already exists in the incoming arguments for this param |
| 1084 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 1084 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 1085 | 1085 | ) { |
| 1086 | 1086 | // so let's skip this argument and move on to the next |
| 1087 | 1087 | continue; |
| 1088 | 1088 | } else if ( |
| 1089 | 1089 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
| 1090 | - ! empty( $param_class ) |
|
| 1091 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 1092 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
| 1090 | + ! empty($param_class) |
|
| 1091 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 1092 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
| 1093 | 1093 | ) { |
| 1094 | 1094 | // skip this argument and move on to the next |
| 1095 | 1095 | continue; |
| 1096 | 1096 | } else if ( |
| 1097 | 1097 | // parameter is type hinted as a class, and should be injected |
| 1098 | - ! empty( $param_class ) |
|
| 1099 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
| 1098 | + ! empty($param_class) |
|
| 1099 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
| 1100 | 1100 | ) { |
| 1101 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
| 1101 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
| 1102 | 1102 | } else { |
| 1103 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
| 1103 | + $arguments[$index] = $param->getDefaultValue(); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | } |
@@ -1117,7 +1117,7 @@ discard block |
||
| 1117 | 1117 | * @param mixed $index |
| 1118 | 1118 | * @return array |
| 1119 | 1119 | */ |
| 1120 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
| 1120 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
| 1121 | 1121 | $dependency = null; |
| 1122 | 1122 | // should dependency be loaded from cache ? |
| 1123 | 1123 | $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( |
@@ -1127,30 +1127,30 @@ discard block |
||
| 1127 | 1127 | : false; |
| 1128 | 1128 | // we might have a dependency... |
| 1129 | 1129 | // let's MAYBE try and find it in our cache if that's what's been requested |
| 1130 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
| 1130 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
| 1131 | 1131 | // and grab it if it exists |
| 1132 | - if ( $cached_class instanceof $param_class ) { |
|
| 1132 | + if ($cached_class instanceof $param_class) { |
|
| 1133 | 1133 | $dependency = $cached_class; |
| 1134 | - } else if ( $param_class !== $class_name ) { |
|
| 1134 | + } else if ($param_class !== $class_name) { |
|
| 1135 | 1135 | // obtain the loader method from the dependency map |
| 1136 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
| 1136 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
| 1137 | 1137 | // is loader a custom closure ? |
| 1138 | - if ( $loader instanceof Closure ) { |
|
| 1138 | + if ($loader instanceof Closure) { |
|
| 1139 | 1139 | $dependency = $loader(); |
| 1140 | 1140 | } else { |
| 1141 | 1141 | // set the cache on property for the recursive loading call |
| 1142 | 1142 | $this->_cache_on = $cache_on; |
| 1143 | 1143 | // if not, then let's try and load it via the registry |
| 1144 | - $dependency = $this->{$loader}( $param_class ); |
|
| 1144 | + $dependency = $this->{$loader}($param_class); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | } |
| 1147 | 1147 | // did we successfully find the correct dependency ? |
| 1148 | - if ( $dependency instanceof $param_class ) { |
|
| 1148 | + if ($dependency instanceof $param_class) { |
|
| 1149 | 1149 | // then let's inject it into the incoming array of arguments at the correct location |
| 1150 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
| 1151 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
| 1150 | + if (isset($argument_keys[$index])) { |
|
| 1151 | + $arguments[$argument_keys[$index]] = $dependency; |
|
| 1152 | 1152 | } else { |
| 1153 | - $arguments[ $index ] = $dependency; |
|
| 1153 | + $arguments[$index] = $dependency; |
|
| 1154 | 1154 | } |
| 1155 | 1155 | } |
| 1156 | 1156 | return $arguments; |
@@ -1175,16 +1175,16 @@ discard block |
||
| 1175 | 1175 | * @param bool $from_db |
| 1176 | 1176 | * @return void |
| 1177 | 1177 | */ |
| 1178 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
| 1178 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
| 1179 | 1179 | // return newly instantiated class |
| 1180 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 1181 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 1180 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 1181 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 1182 | 1182 | $this->{$class_abbreviation} = $class_obj; |
| 1183 | - } else if ( property_exists( $this, $class_name ) ) { |
|
| 1183 | + } else if (property_exists($this, $class_name)) { |
|
| 1184 | 1184 | $this->{$class_name} = $class_obj; |
| 1185 | - } else if ( $class_prefix === 'addon' ) { |
|
| 1185 | + } else if ($class_prefix === 'addon') { |
|
| 1186 | 1186 | $this->addons->{$class_name} = $class_obj; |
| 1187 | - } else if ( ! $from_db ) { |
|
| 1187 | + } else if ( ! $from_db) { |
|
| 1188 | 1188 | $this->LIB->{$class_name} = $class_obj; |
| 1189 | 1189 | } |
| 1190 | 1190 | } |
@@ -1201,12 +1201,12 @@ discard block |
||
| 1201 | 1201 | * @return mixed |
| 1202 | 1202 | * @throws \EE_Error |
| 1203 | 1203 | */ |
| 1204 | - public static function factory( $classname, $arguments = array() ) { |
|
| 1205 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
| 1206 | - if ( $loader instanceof Closure ) { |
|
| 1207 | - return $loader( $arguments ); |
|
| 1208 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
| 1209 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
| 1204 | + public static function factory($classname, $arguments = array()) { |
|
| 1205 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
| 1206 | + if ($loader instanceof Closure) { |
|
| 1207 | + return $loader($arguments); |
|
| 1208 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
| 1209 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | return null; |
| 1212 | 1212 | } |
@@ -1218,9 +1218,9 @@ discard block |
||
| 1218 | 1218 | * @param string $name |
| 1219 | 1219 | * @return EE_Addon |
| 1220 | 1220 | */ |
| 1221 | - public function get_addon_by_name( $name ) { |
|
| 1222 | - foreach ( $this->addons as $addon ) { |
|
| 1223 | - if ( $addon->name() === $name ) { |
|
| 1221 | + public function get_addon_by_name($name) { |
|
| 1222 | + foreach ($this->addons as $addon) { |
|
| 1223 | + if ($addon->name() === $name) { |
|
| 1224 | 1224 | return $addon; |
| 1225 | 1225 | } |
| 1226 | 1226 | } |
@@ -1236,8 +1236,8 @@ discard block |
||
| 1236 | 1236 | */ |
| 1237 | 1237 | public function get_addons_by_name() { |
| 1238 | 1238 | $addons = array(); |
| 1239 | - foreach ( $this->addons as $addon ) { |
|
| 1240 | - $addons[ $addon->name() ] = $addon; |
|
| 1239 | + foreach ($this->addons as $addon) { |
|
| 1240 | + $addons[$addon->name()] = $addon; |
|
| 1241 | 1241 | } |
| 1242 | 1242 | return $addons; |
| 1243 | 1243 | } |
@@ -1252,14 +1252,14 @@ discard block |
||
| 1252 | 1252 | * @return \EEM_Base |
| 1253 | 1253 | * @throws \EE_Error |
| 1254 | 1254 | */ |
| 1255 | - public function reset_model( $model_name ) { |
|
| 1256 | - $model = $this->load_model( $model_name ); |
|
| 1257 | - $model_class_name = get_class( $model ); |
|
| 1255 | + public function reset_model($model_name) { |
|
| 1256 | + $model = $this->load_model($model_name); |
|
| 1257 | + $model_class_name = get_class($model); |
|
| 1258 | 1258 | //get that model reset it and make sure we nuke the old reference to it |
| 1259 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
| 1259 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
| 1260 | 1260 | $this->LIB->{$model_class_name} = $model::reset(); |
| 1261 | 1261 | } else { |
| 1262 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
| 1262 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
| 1263 | 1263 | } |
| 1264 | 1264 | return $this->LIB->{$model_class_name}; |
| 1265 | 1265 | } |
@@ -1282,16 +1282,16 @@ discard block |
||
| 1282 | 1282 | * @return \EE_Registry |
| 1283 | 1283 | * @throws \EE_Error |
| 1284 | 1284 | */ |
| 1285 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
| 1285 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
| 1286 | 1286 | $instance = self::instance(); |
| 1287 | 1287 | EEH_Activation::reset(); |
| 1288 | 1288 | $instance->_cache_on = true; |
| 1289 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
| 1290 | - unset( $instance->LIB->EE_Data_Migration_Manager ); |
|
| 1289 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
| 1290 | + unset($instance->LIB->EE_Data_Migration_Manager); |
|
| 1291 | 1291 | $instance->LIB = new stdClass(); |
| 1292 | - if ( $reset_models ) { |
|
| 1293 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
| 1294 | - $instance->reset_model( $model_name ); |
|
| 1292 | + if ($reset_models) { |
|
| 1293 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
| 1294 | + $instance->reset_model($model_name); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | 1297 | return $instance; |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | * @param $a |
| 1313 | 1313 | * @param $b |
| 1314 | 1314 | */ |
| 1315 | - final public function __call( $a, $b ) { |
|
| 1315 | + final public function __call($a, $b) { |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | |
@@ -1320,7 +1320,7 @@ discard block |
||
| 1320 | 1320 | /** |
| 1321 | 1321 | * @param $a |
| 1322 | 1322 | */ |
| 1323 | - final public function __get( $a ) { |
|
| 1323 | + final public function __get($a) { |
|
| 1324 | 1324 | } |
| 1325 | 1325 | |
| 1326 | 1326 | |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | * @param $a |
| 1330 | 1330 | * @param $b |
| 1331 | 1331 | */ |
| 1332 | - final public function __set( $a, $b ) { |
|
| 1332 | + final public function __set($a, $b) { |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | /** |
| 1338 | 1338 | * @param $a |
| 1339 | 1339 | */ |
| 1340 | - final public function __isset( $a ) { |
|
| 1340 | + final public function __isset($a) { |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | |
@@ -1345,7 +1345,7 @@ discard block |
||
| 1345 | 1345 | /** |
| 1346 | 1346 | * @param $a |
| 1347 | 1347 | */ |
| 1348 | - final public function __unset( $a ) { |
|
| 1348 | + final public function __unset($a) { |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | * @param $a |
| 1393 | 1393 | * @param $b |
| 1394 | 1394 | */ |
| 1395 | - final public static function __callStatic( $a, $b ) { |
|
| 1395 | + final public static function __callStatic($a, $b) { |
|
| 1396 | 1396 | } |
| 1397 | 1397 | |
| 1398 | 1398 | /** |
@@ -1401,9 +1401,9 @@ discard block |
||
| 1401 | 1401 | */ |
| 1402 | 1402 | public function cpt_models() { |
| 1403 | 1403 | $cpt_models = array(); |
| 1404 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
| 1405 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
| 1406 | - $cpt_models[ $short_name ] = $classname; |
|
| 1404 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
| 1405 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
| 1406 | + $cpt_models[$short_name] = $classname; |
|
| 1407 | 1407 | } |
| 1408 | 1408 | } |
| 1409 | 1409 | return $cpt_models; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('ABSPATH')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | -if ( function_exists( 'espresso_version' ) ) { |
|
| 44 | +if (function_exists('espresso_version')) { |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * espresso_duplicate_plugin_error |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | function espresso_duplicate_plugin_error() { |
| 51 | 51 | ?> |
| 52 | 52 | <div class="error"> |
| 53 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
| 53 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
| 54 | 54 | </div> |
| 55 | 55 | <?php |
| 56 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
| 56 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 57 | 57 | } |
| 58 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
| 58 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | 59 | |
| 60 | 60 | } else { |
| 61 | 61 | |
@@ -66,103 +66,103 @@ discard block |
||
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | 68 | function espresso_version() { |
| 69 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.0.rc.036' ); |
|
| 69 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.0.rc.036'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // define versions |
| 73 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
| 74 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
| 75 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
| 76 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
| 77 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
| 78 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
| 79 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
| 73 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 74 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 75 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 76 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
| 77 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 78 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
| 79 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 80 | 80 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
| 81 | - if ( ! defined( 'DS' ) ) { |
|
| 82 | - define( 'DS', '/' ); |
|
| 81 | + if ( ! defined('DS')) { |
|
| 82 | + define('DS', '/'); |
|
| 83 | 83 | } |
| 84 | - if ( ! defined( 'PS' ) ) { |
|
| 85 | - define( 'PS', PATH_SEPARATOR ); |
|
| 84 | + if ( ! defined('PS')) { |
|
| 85 | + define('PS', PATH_SEPARATOR); |
|
| 86 | 86 | } |
| 87 | - if ( ! defined( 'SP' ) ) { |
|
| 88 | - define( 'SP', ' ' ); |
|
| 87 | + if ( ! defined('SP')) { |
|
| 88 | + define('SP', ' '); |
|
| 89 | 89 | } |
| 90 | - if ( ! defined( 'EENL' ) ) { |
|
| 91 | - define( 'EENL', "\n" ); |
|
| 90 | + if ( ! defined('EENL')) { |
|
| 91 | + define('EENL', "\n"); |
|
| 92 | 92 | } |
| 93 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
| 93 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 94 | 94 | // define the plugin directory and URL |
| 95 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 96 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 97 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 95 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 96 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 97 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 98 | 98 | // main root folder paths |
| 99 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
| 100 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
| 101 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
| 102 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
| 103 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
| 104 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
| 105 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
| 106 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
| 99 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
| 100 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
| 101 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
| 102 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
| 103 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
| 104 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
| 105 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
| 106 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
| 107 | 107 | // core system paths |
| 108 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
| 109 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
| 110 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
| 111 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
| 112 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
| 113 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
| 114 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
| 115 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
| 116 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
| 117 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
| 118 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
| 119 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
| 108 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
| 109 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
| 110 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
| 111 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
| 112 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
| 113 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
| 114 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
| 115 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
| 116 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
| 117 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
| 118 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
| 119 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
| 120 | 120 | // gateways |
| 121 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
| 122 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
| 121 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
| 122 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
| 123 | 123 | // asset URL paths |
| 124 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
| 125 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
| 126 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
| 127 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
| 128 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
| 129 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
| 124 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
| 125 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
| 126 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
| 127 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
| 128 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
| 129 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
| 130 | 130 | // define upload paths |
| 131 | 131 | $uploads = wp_upload_dir(); |
| 132 | 132 | // define the uploads directory and URL |
| 133 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
| 134 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
| 133 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
| 134 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
| 135 | 135 | // define the templates directory and URL |
| 136 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
| 137 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
| 136 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
| 137 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
| 138 | 138 | // define the gateway directory and URL |
| 139 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
| 140 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
| 139 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
| 140 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
| 141 | 141 | // languages folder/path |
| 142 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
| 143 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
| 142 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
| 143 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
| 144 | 144 | //check for dompdf fonts in uploads |
| 145 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
| 146 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
| 145 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
| 146 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
| 147 | 147 | } |
| 148 | 148 | //ajax constants |
| 149 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
| 150 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
| 149 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
| 150 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
| 151 | 151 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
| 152 | 152 | //you're better to use this than its straight value (currently -1) in case you ever |
| 153 | 153 | //want to change its default value! or find when -1 means infinity |
| 154 | - define( 'EE_INF_IN_DB', -1 ); |
|
| 155 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
| 156 | - define( 'EE_DEBUG', false ); |
|
| 154 | + define('EE_INF_IN_DB', -1); |
|
| 155 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 156 | + define('EE_DEBUG', false); |
|
| 157 | 157 | |
| 158 | 158 | /** |
| 159 | 159 | * espresso_plugin_activation |
| 160 | 160 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
| 161 | 161 | */ |
| 162 | 162 | function espresso_plugin_activation() { |
| 163 | - update_option( 'ee_espresso_activation', true ); |
|
| 163 | + update_option('ee_espresso_activation', true); |
|
| 164 | 164 | } |
| 165 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
| 165 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | // } |
| 177 | 177 | // |
| 178 | 178 | } |
| 179 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
| 179 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | function espresso_load_error_handling() { |
| 188 | 188 | // load debugging tools |
| 189 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
| 190 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
| 189 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
| 190 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
| 191 | 191 | EEH_Debug_Tools::instance(); |
| 192 | 192 | } |
| 193 | 193 | // load error handling |
| 194 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
| 195 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
| 194 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
| 195 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
| 196 | 196 | } else { |
| 197 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
| 197 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,16 +208,16 @@ discard block |
||
| 208 | 208 | * @param string $full_path_to_file |
| 209 | 209 | * @throws EE_Error |
| 210 | 210 | */ |
| 211 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
| 211 | + function espresso_load_required($classname, $full_path_to_file) { |
|
| 212 | 212 | static $error_handling_loaded = false; |
| 213 | - if ( ! $error_handling_loaded ) { |
|
| 213 | + if ( ! $error_handling_loaded) { |
|
| 214 | 214 | espresso_load_error_handling(); |
| 215 | 215 | $error_handling_loaded = true; |
| 216 | 216 | } |
| 217 | - if ( is_readable( $full_path_to_file ) ) { |
|
| 218 | - require_once( $full_path_to_file ); |
|
| 217 | + if (is_readable($full_path_to_file)) { |
|
| 218 | + require_once($full_path_to_file); |
|
| 219 | 219 | } else { |
| 220 | - throw new EE_Error ( |
|
| 220 | + throw new EE_Error( |
|
| 221 | 221 | sprintf( |
| 222 | 222 | __( |
| 223 | 223 | 'The %s class file could not be located or is not readable due to file permissions.', |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - espresso_load_required( 'EE_Base', EE_CORE . 'EE_Base.core.php' ); |
|
| 233 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
| 234 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
| 235 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
| 232 | + espresso_load_required('EE_Base', EE_CORE.'EE_Base.core.php'); |
|
| 233 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
| 234 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
| 235 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
| 236 | 236 | new EE_Bootstrap(); |
| 237 | 237 | |
| 238 | 238 | |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | |
| 244 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
| 244 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
| 245 | 245 | /** |
| 246 | 246 | * deactivate_plugin |
| 247 | 247 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
| 251 | 251 | * @return void |
| 252 | 252 | */ |
| 253 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
| 254 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
| 255 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 253 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
| 254 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 255 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 256 | 256 | } |
| 257 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
| 258 | - deactivate_plugins( $plugin_basename ); |
|
| 257 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 258 | + deactivate_plugins($plugin_basename); |
|
| 259 | 259 | } |
| 260 | 260 | } |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | * @param \EE_Registry $Registry |
| 55 | 55 | * @return \EE_System |
| 56 | 56 | */ |
| 57 | - public static function instance( EE_Registry $Registry = null ) { |
|
| 57 | + public static function instance(EE_Registry $Registry = null) { |
|
| 58 | 58 | // check if class object is instantiated |
| 59 | - if ( ! self::$_instance instanceof EE_System ) { |
|
| 60 | - self::$_instance = new self( $Registry ); |
|
| 59 | + if ( ! self::$_instance instanceof EE_System) { |
|
| 60 | + self::$_instance = new self($Registry); |
|
| 61 | 61 | } |
| 62 | 62 | return self::$_instance; |
| 63 | 63 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | //we need to reset the migration manager in order for it to detect DMSs properly |
| 76 | 76 | \EE_Data_Migration_Manager::reset(); |
| 77 | 77 | //make sure none of the old hooks are left hanging around |
| 78 | - remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ); |
|
| 78 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 79 | 79 | \EE_Activation_Manager::instance()->detect_activations_or_upgrades(); |
| 80 | 80 | \EE_Activation_Manager::instance()->perform_activations_upgrades_and_migrations(); |
| 81 | 81 | return self::instance(); |
@@ -91,28 +91,28 @@ discard block |
||
| 91 | 91 | * @access private |
| 92 | 92 | * @param \EE_Registry $Registry |
| 93 | 93 | */ |
| 94 | - private function __construct( EE_Registry $Registry ) { |
|
| 94 | + private function __construct(EE_Registry $Registry) { |
|
| 95 | 95 | $this->registry = $Registry; |
| 96 | - do_action( 'AHEE__EE_System__construct__begin', $this ); |
|
| 96 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
| 97 | 97 | // load EE_Config, EE_Textdomain, etc |
| 98 | - add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 10 ); |
|
| 98 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 10); |
|
| 99 | 99 | // load EE_Config, EE_Textdomain, etc |
| 100 | 100 | add_action( |
| 101 | 101 | 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
| 102 | - array( $this, 'register_shortcodes_modules_and_widgets' ), |
|
| 102 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 103 | 103 | 10 |
| 104 | 104 | ); |
| 105 | 105 | // you wanna get going? I wanna get going... let's get going! |
| 106 | - add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 10 ); |
|
| 106 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 10); |
|
| 107 | 107 | // for doing stuff AFTER any plugins have completed loading |
| 108 | - add_action( 'AHEE__EE_Bootstrap__after_brew_espresso', array( $this, 'after_brew_espresso' ), 10 ); |
|
| 108 | + add_action('AHEE__EE_Bootstrap__after_brew_espresso', array($this, 'after_brew_espresso'), 10); |
|
| 109 | 109 | //other housekeeping |
| 110 | 110 | //exclude EE critical pages from wp_list_pages |
| 111 | - add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 ); |
|
| 111 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
| 112 | 112 | // ALL EE Addons should use the following hook point to attach their initial setup too |
| 113 | 113 | // it's extremely important for EE Addons to register any class autoloaders |
| 114 | 114 | // so that they can be available when the EE_Config loads |
| 115 | - do_action( 'AHEE__EE_System__construct__complete', $this ); |
|
| 115 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | /** |
| 121 | 121 | * @param \EE_Request $request |
| 122 | 122 | */ |
| 123 | - public function set_request( \EE_Request $request ) { |
|
| 123 | + public function set_request(\EE_Request $request) { |
|
| 124 | 124 | $this->request = $request; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * @param \EE_Response $response |
| 131 | 131 | */ |
| 132 | - public function set_response( \EE_Response $response ) { |
|
| 132 | + public function set_response(\EE_Response $response) { |
|
| 133 | 133 | $this->response = $response; |
| 134 | 134 | } |
| 135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | /** |
| 139 | 139 | * @param EE_Registry $registry |
| 140 | 140 | */ |
| 141 | - public function set_registry( $registry ) { |
|
| 141 | + public function set_registry($registry) { |
|
| 142 | 142 | $this->registry = $registry; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -152,27 +152,27 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | - public function load_core_configuration(){ |
|
| 156 | - do_action( 'AHEE__EE_System__load_core_configuration__begin', $this ); |
|
| 155 | + public function load_core_configuration() { |
|
| 156 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 157 | 157 | // load and setup EE_Config and EE_Network_Config |
| 158 | - $this->registry->load_core( 'Config' ); |
|
| 159 | - $this->registry->load_core( 'Network_Config' ); |
|
| 158 | + $this->registry->load_core('Config'); |
|
| 159 | + $this->registry->load_core('Network_Config'); |
|
| 160 | 160 | // setup autoloaders |
| 161 | 161 | // enable logging? |
| 162 | - if ( $this->registry->CFG->admin->use_full_logging ) { |
|
| 163 | - $this->registry->load_core( 'Log' ); |
|
| 162 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
| 163 | + $this->registry->load_core('Log'); |
|
| 164 | 164 | } |
| 165 | 165 | // check for activation errors |
| 166 | - $activation_errors = get_option( 'ee_plugin_activation_errors', FALSE ); |
|
| 167 | - if ( $activation_errors ) { |
|
| 168 | - EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 169 | - update_option( 'ee_plugin_activation_errors', FALSE ); |
|
| 166 | + $activation_errors = get_option('ee_plugin_activation_errors', FALSE); |
|
| 167 | + if ($activation_errors) { |
|
| 168 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 169 | + update_option('ee_plugin_activation_errors', FALSE); |
|
| 170 | 170 | } |
| 171 | 171 | // get model names |
| 172 | 172 | $this->_parse_model_names(); |
| 173 | 173 | //load caf stuff a chance to play during the activation process too. |
| 174 | 174 | $this->_maybe_brew_regular(); |
| 175 | - do_action( 'AHEE__EE_System__load_core_configuration__complete', $this ); |
|
| 175 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -181,22 +181,22 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @return void |
| 183 | 183 | */ |
| 184 | - private function _parse_model_names(){ |
|
| 184 | + private function _parse_model_names() { |
|
| 185 | 185 | //get all the files in the EE_MODELS folder that end in .model.php |
| 186 | - $models = glob( EE_MODELS.'*.model.php'); |
|
| 186 | + $models = glob(EE_MODELS.'*.model.php'); |
|
| 187 | 187 | $model_names = array(); |
| 188 | 188 | $non_abstract_db_models = array(); |
| 189 | - foreach( $models as $model ){ |
|
| 189 | + foreach ($models as $model) { |
|
| 190 | 190 | // get model classname |
| 191 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model ); |
|
| 192 | - $short_name = str_replace( 'EEM_', '', $classname ); |
|
| 191 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 192 | + $short_name = str_replace('EEM_', '', $classname); |
|
| 193 | 193 | $reflectionClass = new ReflectionClass($classname); |
| 194 | - if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){ |
|
| 195 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
| 194 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 195 | + $non_abstract_db_models[$short_name] = $classname; |
|
| 196 | 196 | } |
| 197 | - $model_names[ $short_name ] = $classname; |
|
| 197 | + $model_names[$short_name] = $classname; |
|
| 198 | 198 | } |
| 199 | - $this->registry->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names ); |
|
| 199 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 200 | 200 | $this->registry->non_abstract_db_models = apply_filters( |
| 201 | 201 | 'FHEE__EE_System__parse_implemented_model_names', |
| 202 | 202 | $non_abstract_db_models |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | private function _maybe_brew_regular() { |
| 215 | 215 | if ( |
| 216 | - ( ! defined( 'EE_DECAF' ) || EE_DECAF !== true ) |
|
| 217 | - && is_readable( EE_CAFF_PATH . 'brewing_regular.php' ) |
|
| 216 | + ( ! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 217 | + && is_readable(EE_CAFF_PATH.'brewing_regular.php') |
|
| 218 | 218 | ) { |
| 219 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 219 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
| 220 | 220 | new EE_Brewing_Regular(); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * @return void |
| 235 | 235 | */ |
| 236 | 236 | public function register_shortcodes_modules_and_widgets() { |
| 237 | - do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' ); |
|
| 237 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 238 | 238 | // check for addons using old hookpoint |
| 239 | - if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) { |
|
| 239 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 240 | 240 | $this->_incompatible_addon_error(); |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -253,18 +253,18 @@ discard block |
||
| 253 | 253 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
| 254 | 254 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
| 255 | 255 | ); |
| 256 | - if ( ! empty( $class_names ) ) { |
|
| 256 | + if ( ! empty($class_names)) { |
|
| 257 | 257 | $msg = __( |
| 258 | 258 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
| 259 | 259 | 'event_espresso' |
| 260 | 260 | ); |
| 261 | 261 | $msg .= '<ul>'; |
| 262 | - foreach ( $class_names as $class_name ) { |
|
| 263 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 264 | - array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), |
|
| 262 | + foreach ($class_names as $class_name) { |
|
| 263 | + $msg .= '<li><b>Event Espresso - '.str_replace( |
|
| 264 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
| 265 | 265 | '', |
| 266 | 266 | $class_name |
| 267 | - ) . '</b></li>'; |
|
| 267 | + ).'</b></li>'; |
|
| 268 | 268 | } |
| 269 | 269 | $msg .= '</ul>'; |
| 270 | 270 | $msg .= __( |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | 'event_espresso' |
| 273 | 273 | ); |
| 274 | 274 | // save list of incompatible addons to wp-options for later use |
| 275 | - add_option( 'ee_incompatible_addons', $class_names, '', 'no' ); |
|
| 276 | - if ( is_admin() ) { |
|
| 277 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 275 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 276 | + if (is_admin()) { |
|
| 277 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -291,29 +291,29 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @return void |
| 293 | 293 | */ |
| 294 | - public function brew_espresso(){ |
|
| 294 | + public function brew_espresso() { |
|
| 295 | 295 | // filter switch for halting any further execution |
| 296 | - if ( apply_filters( 'FHEE__EE_System__brew_espresso', true, $this ) ) { |
|
| 297 | - do_action( 'AHEE__EE_System__brew_espresso__begin', $this ); |
|
| 296 | + if (apply_filters('FHEE__EE_System__brew_espresso', true, $this)) { |
|
| 297 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 298 | 298 | // load some final core systems |
| 299 | - add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 ); |
|
| 300 | - add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 ); |
|
| 301 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
| 302 | - add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 ); |
|
| 303 | - add_action( 'init', array( $this, 'initialize' ), 10 ); |
|
| 304 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
| 305 | - add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
| 306 | - add_action( 'admin_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 ); |
|
| 307 | - if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', true ) ) { |
|
| 299 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 300 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 301 | + add_action('init', array($this, 'load_controllers'), 7); |
|
| 302 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 303 | + add_action('init', array($this, 'initialize'), 10); |
|
| 304 | + add_action('init', array($this, 'initialize_last'), 100); |
|
| 305 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
| 306 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25); |
|
| 307 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 308 | 308 | // pew pew pew |
| 309 | - $this->registry->load_core( 'PUE' ); |
|
| 310 | - do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' ); |
|
| 309 | + $this->registry->load_core('PUE'); |
|
| 310 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 311 | 311 | } |
| 312 | - do_action( 'AHEE__EE_System__brew_espresso__complete', $this ); |
|
| 312 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 313 | 313 | } else { |
| 314 | - add_action( 'init', array( $this, 'load_controllers' ), 7 ); |
|
| 315 | - add_action( 'init', array( $this, 'initialize_last' ), 100 ); |
|
| 316 | - do_action( 'AHEE__EE_System__brew_espresso__halted', $this ); |
|
| 314 | + add_action('init', array($this, 'load_controllers'), 7); |
|
| 315 | + add_action('init', array($this, 'initialize_last'), 100); |
|
| 316 | + do_action('AHEE__EE_System__brew_espresso__halted', $this); |
|
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @return void |
| 328 | 328 | */ |
| 329 | 329 | public function after_brew_espresso() { |
| 330 | - do_action( 'AHEE__EE_System__after_brew_espresso' ); |
|
| 330 | + do_action('AHEE__EE_System__after_brew_espresso'); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | public function set_hooks_for_core() { |
| 343 | 343 | $this->_deactivate_incompatible_addons(); |
| 344 | - do_action( 'AHEE__EE_System__set_hooks_for_core' ); |
|
| 344 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -350,15 +350,15 @@ discard block |
||
| 350 | 350 | * Using the information gathered in EE_System::_incompatible_addon_error, |
| 351 | 351 | * deactivates any addons considered incompatible with the current version of EE |
| 352 | 352 | */ |
| 353 | - private function _deactivate_incompatible_addons(){ |
|
| 354 | - $incompatible_addons = get_option( 'ee_incompatible_addons', array() ); |
|
| 355 | - if ( ! empty( $incompatible_addons )) { |
|
| 356 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
| 357 | - foreach ( $active_plugins as $active_plugin ) { |
|
| 358 | - foreach ( $incompatible_addons as $incompatible_addon ) { |
|
| 359 | - if ( strpos( $active_plugin, $incompatible_addon ) !== false ) { |
|
| 360 | - unset( $_GET['activate'] ); |
|
| 361 | - espresso_deactivate_plugin( $active_plugin ); |
|
| 353 | + private function _deactivate_incompatible_addons() { |
|
| 354 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
| 355 | + if ( ! empty($incompatible_addons)) { |
|
| 356 | + $active_plugins = get_option('active_plugins', array()); |
|
| 357 | + foreach ($active_plugins as $active_plugin) { |
|
| 358 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
| 359 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
| 360 | + unset($_GET['activate']); |
|
| 361 | + espresso_deactivate_plugin($active_plugin); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -374,10 +374,10 @@ discard block |
||
| 374 | 374 | * @return void |
| 375 | 375 | */ |
| 376 | 376 | public function load_CPTs_and_session() { |
| 377 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__start' ); |
|
| 377 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 378 | 378 | // register Custom Post Types |
| 379 | - $this->registry->load_core( 'Register_CPTs' ); |
|
| 380 | - do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ); |
|
| 379 | + $this->registry->load_core('Register_CPTs'); |
|
| 380 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | |
@@ -393,16 +393,16 @@ discard block |
||
| 393 | 393 | * @throws \EE_Error |
| 394 | 394 | */ |
| 395 | 395 | public function load_controllers() { |
| 396 | - do_action( 'AHEE__EE_System__load_controllers__start' ); |
|
| 396 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
| 397 | 397 | // let's get it started |
| 398 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) { |
|
| 399 | - do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' ); |
|
| 400 | - $this->registry->load_core( 'Front_Controller' ); |
|
| 401 | - } else if ( ! EE_FRONT_AJAX ) { |
|
| 402 | - do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' ); |
|
| 403 | - $this->registry->load_core( 'Admin' ); |
|
| 398 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
| 399 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 400 | + $this->registry->load_core('Front_Controller'); |
|
| 401 | + } else if ( ! EE_FRONT_AJAX) { |
|
| 402 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 403 | + $this->registry->load_core('Admin'); |
|
| 404 | 404 | } |
| 405 | - do_action( 'AHEE__EE_System__load_controllers__complete' ); |
|
| 405 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
@@ -416,11 +416,11 @@ discard block |
||
| 416 | 416 | * @return void |
| 417 | 417 | */ |
| 418 | 418 | public function core_loaded_and_ready() { |
| 419 | - do_action( 'AHEE__EE_System__core_loaded_and_ready' ); |
|
| 420 | - do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
| 419 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 420 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 421 | 421 | // add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 ); |
| 422 | - $this->registry->load_core( 'Session' ); |
|
| 423 | - new EventEspresso\Core\Services\AdminToolbarItems( $this->registry, \EE_Maintenance_Mode::instance() ); |
|
| 422 | + $this->registry->load_core('Session'); |
|
| 423 | + new EventEspresso\Core\Services\AdminToolbarItems($this->registry, \EE_Maintenance_Mode::instance()); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @return void |
| 435 | 435 | */ |
| 436 | 436 | public function initialize() { |
| 437 | - do_action( 'AHEE__EE_System__initialize' ); |
|
| 437 | + do_action('AHEE__EE_System__initialize'); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @return void |
| 449 | 449 | */ |
| 450 | 450 | public function initialize_last() { |
| 451 | - do_action( 'AHEE__EE_System__initialize_last' ); |
|
| 451 | + do_action('AHEE__EE_System__initialize_last'); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -480,22 +480,22 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | public static function do_not_cache() { |
| 482 | 482 | // set no cache constants |
| 483 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
| 484 | - define( 'DONOTCACHEPAGE', true ); |
|
| 483 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
| 484 | + define('DONOTCACHEPAGE', true); |
|
| 485 | 485 | } |
| 486 | - if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { |
|
| 487 | - define( 'DONOTCACHCEOBJECT', true ); |
|
| 486 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
| 487 | + define('DONOTCACHCEOBJECT', true); |
|
| 488 | 488 | } |
| 489 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
| 490 | - define( 'DONOTCACHEDB', true ); |
|
| 489 | + if ( ! defined('DONOTCACHEDB')) { |
|
| 490 | + define('DONOTCACHEDB', true); |
|
| 491 | 491 | } |
| 492 | 492 | // add no cache headers |
| 493 | - add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 ); |
|
| 493 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 494 | 494 | // plus a little extra for nginx and Google Chrome |
| 495 | - add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 ); |
|
| 495 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 496 | 496 | // prevent browsers from prefetching of the rel='next' link, |
| 497 | 497 | // because it may contain content that interferes with the registration process |
| 498 | - remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); |
|
| 498 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | * @param $headers |
| 508 | 508 | * @return array |
| 509 | 509 | */ |
| 510 | - public static function extra_nocache_headers ( $headers ) { |
|
| 510 | + public static function extra_nocache_headers($headers) { |
|
| 511 | 511 | // for NGINX |
| 512 | 512 | $headers['X-Accel-Expires'] = 0; |
| 513 | 513 | // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | * @param array $exclude_array any existing pages being excluded are in this array. |
| 539 | 539 | * @return array |
| 540 | 540 | */ |
| 541 | - public function remove_pages_from_wp_list_pages( $exclude_array ) { |
|
| 542 | - return array_merge( $exclude_array, $this->registry->CFG->core->get_critical_pages_array() ); |
|
| 541 | + public function remove_pages_from_wp_list_pages($exclude_array) { |
|
| 542 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | |
@@ -558,37 +558,37 @@ discard block |
||
| 558 | 558 | // unlike other systems, EE_System_scripts loading is turned ON by default, |
| 559 | 559 | // but prior to the init hook, can be turned off via: |
| 560 | 560 | // add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
| 561 | - if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) { |
|
| 561 | + if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) { |
|
| 562 | 562 | // similarly, jquery_validate loading is turned OFF by default, |
| 563 | 563 | // but prior to the wp_enqueue_scripts hook, can be turned back on again via: |
| 564 | 564 | // add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
| 565 | 565 | // register jQuery Validate |
| 566 | - if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) { |
|
| 566 | + if (apply_filters('FHEE_load_jquery_validate', FALSE)) { |
|
| 567 | 567 | wp_register_script( |
| 568 | 568 | 'jquery-validate', |
| 569 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
| 570 | - array( 'jquery' ), |
|
| 569 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
| 570 | + array('jquery'), |
|
| 571 | 571 | '1.15.0', |
| 572 | 572 | true |
| 573 | 573 | ); |
| 574 | 574 | wp_register_script( |
| 575 | 575 | 'jquery-validate-extra-methods', |
| 576 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
| 577 | - array( 'jquery-validate' ), |
|
| 576 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
| 577 | + array('jquery-validate'), |
|
| 578 | 578 | '1.15.0', |
| 579 | 579 | true |
| 580 | 580 | ); |
| 581 | 581 | } |
| 582 | 582 | wp_register_script( |
| 583 | 583 | 'select2', |
| 584 | - EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', |
|
| 584 | + EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', |
|
| 585 | 585 | array(), |
| 586 | 586 | '4.0.2', |
| 587 | 587 | true |
| 588 | 588 | ); |
| 589 | 589 | wp_register_style( |
| 590 | 590 | 'select2', |
| 591 | - EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', |
|
| 591 | + EE_GLOBAL_ASSETS_URL.'css/select2.min.css', |
|
| 592 | 592 | array(), |
| 593 | 593 | '4.0.2', |
| 594 | 594 | 'all' |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | * @param $admin_bar |
| 696 | 696 | * @return void |
| 697 | 697 | */ |
| 698 | - public function espresso_toolbar_items( $admin_bar ) { |
|
| 698 | + public function espresso_toolbar_items($admin_bar) { |
|
| 699 | 699 | EE_Error::doing_it_wrong( |
| 700 | - __METHOD__ . "()", |
|
| 700 | + __METHOD__."()", |
|
| 701 | 701 | __( |
| 702 | 702 | 'Event Espresso admin toolbar items have already been added. But if it\'s really necessary, you can find the new method here: \EventEspresso\Core\Services\AdminToolbarItems::addToolbarItems().', |
| 703 | 703 | 'event_espresso' |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate |
| 22 | 22 | * an error occurred which means the ajax script should probably stop executing. |
| 23 | 23 | */ |
| 24 | -class EE_Data_Migration_Manager{ |
|
| 24 | +class EE_Data_Migration_Manager { |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public static function instance() { |
| 135 | 135 | // check if class object is instantiated |
| 136 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
| 136 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
| 137 | 137 | self::$_instance = new self(); |
| 138 | 138 | } |
| 139 | 139 | return self::$_instance; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
| 147 | 147 | * @return EE_Data_Migration_Manager |
| 148 | 148 | */ |
| 149 | - public static function reset(){ |
|
| 149 | + public static function reset() { |
|
| 150 | 150 | self::$_instance = NULL; |
| 151 | 151 | return self::instance(); |
| 152 | 152 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | /** |
| 157 | 157 | * constructor |
| 158 | 158 | */ |
| 159 | - private function __construct(){ |
|
| 159 | + private function __construct() { |
|
| 160 | 160 | $this->stati_that_indicate_to_continue_migrations = array( |
| 161 | 161 | self::status_continue, |
| 162 | 162 | self::status_completed |
@@ -184,14 +184,14 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function _load_dms_classes() { |
| 186 | 186 | static $loaded = false; |
| 187 | - if ( ! $loaded ) { |
|
| 187 | + if ( ! $loaded) { |
|
| 188 | 188 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
| 189 | 189 | //to be defined, because right now it doesn't get autoloaded on its own |
| 190 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), true ); |
|
| 191 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array( $this ), true ); |
|
| 192 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), true ); |
|
| 193 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), true ); |
|
| 194 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), true ); |
|
| 190 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), true); |
|
| 191 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array($this), true); |
|
| 192 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), true); |
|
| 193 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), true); |
|
| 194 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), true); |
|
| 195 | 195 | $loaded = true; |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -206,21 +206,21 @@ discard block |
||
| 206 | 206 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
| 207 | 207 | * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0') |
| 208 | 208 | */ |
| 209 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
| 210 | - $plugin_slug_and_version_string = str_replace( EE_Data_Migration_Manager::data_migration_script_option_prefix, '', $option_name); |
|
| 209 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
| 210 | + $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, '', $option_name); |
|
| 211 | 211 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
| 212 | - $parts = explode( '.', $plugin_slug_and_version_string); |
|
| 212 | + $parts = explode('.', $plugin_slug_and_version_string); |
|
| 213 | 213 | |
| 214 | - if(count($parts) === 4){ |
|
| 214 | + if (count($parts) === 4) { |
|
| 215 | 215 | //it's 4.2-style.eg Core.4.1.0 |
| 216 | - $plugin_slug = $parts[0];//eg Core |
|
| 217 | - $version_string = $parts[1] . '.' . $parts[2] . '.' . $parts[3]; //eg 4.1.0 |
|
| 218 | - }else{ |
|
| 216 | + $plugin_slug = $parts[0]; //eg Core |
|
| 217 | + $version_string = $parts[1].'.'.$parts[2].'.'.$parts[3]; //eg 4.1.0 |
|
| 218 | + } else { |
|
| 219 | 219 | //it's 4.1-style: eg 4.1.0 |
| 220 | 220 | $plugin_slug = 'Core'; |
| 221 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
| 221 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
| 222 | 222 | } |
| 223 | - return array($plugin_slug,$version_string); |
|
| 223 | + return array($plugin_slug, $version_string); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -231,22 +231,22 @@ discard block |
||
| 231 | 231 | * @return EE_Data_Migration_Script_Base |
| 232 | 232 | * @throws EE_Error |
| 233 | 233 | */ |
| 234 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
| 234 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
| 235 | 235 | $this->_load_dms_classes(); |
| 236 | 236 | $data_migration_data = maybe_unserialize($dms_option_value); |
| 237 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
| 237 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
| 238 | 238 | $class = new $data_migration_data['class']; |
| 239 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
| 239 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
| 240 | 240 | $class->instantiate_from_array_of_properties($data_migration_data); |
| 241 | 241 | return $class; |
| 242 | - }else{ |
|
| 242 | + } else { |
|
| 243 | 243 | //huh, so its an object but not a data migration script?? that shouldn't happen |
| 244 | 244 | //just leave it as an array (which will probably just get ignored) |
| 245 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
| 245 | + throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class'])); |
|
| 246 | 246 | } |
| 247 | - }else{ |
|
| 247 | + } else { |
|
| 248 | 248 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
| 249 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
| 249 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | /** |
@@ -258,35 +258,35 @@ discard block |
||
| 258 | 258 | * (but also has a few legacy arrays in there - which should probably be ignored) |
| 259 | 259 | * @throws \EE_Error |
| 260 | 260 | */ |
| 261 | - public function get_data_migrations_ran(){ |
|
| 262 | - if( ! $this->_data_migrations_ran ){ |
|
| 261 | + public function get_data_migrations_ran() { |
|
| 262 | + if ( ! $this->_data_migrations_ran) { |
|
| 263 | 263 | $this->_load_dms_classes(); |
| 264 | 264 | //setup autoloaders for each of the scripts in there |
| 265 | 265 | $this->get_all_data_migration_scripts_available(); |
| 266 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
| 266 | + $data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
| 267 | 267 | |
| 268 | 268 | $data_migrations_ran = array(); |
| 269 | 269 | //convert into data migration script classes where possible |
| 270 | - foreach($data_migrations_options as $data_migration_option){ |
|
| 271 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
| 270 | + foreach ($data_migrations_options as $data_migration_option) { |
|
| 271 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
| 272 | 272 | |
| 273 | - try{ |
|
| 274 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
| 273 | + try { |
|
| 274 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
| 275 | 275 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
| 276 | 276 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
| 277 | 277 | $this->_last_ran_script = $class; |
| 278 | - if( ! $class->is_completed()){ |
|
| 278 | + if ( ! $class->is_completed()) { |
|
| 279 | 279 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
| 280 | 280 | $this->_last_ran_incomplete_script = $class; |
| 281 | 281 | } |
| 282 | - }catch(EE_Error $e){ |
|
| 282 | + } catch (EE_Error $e) { |
|
| 283 | 283 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
| 284 | 284 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
| 288 | 288 | $this->_data_migrations_ran = $data_migrations_ran; |
| 289 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
| 289 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
| 290 | 290 | $this->_data_migrations_ran = array(); |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @return mixed string or int |
| 305 | 305 | * @throws \EE_Error |
| 306 | 306 | */ |
| 307 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
| 307 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
| 308 | 308 | $script = EE_Registry::instance()->load_dms($script_name); |
| 309 | 309 | return $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
| 310 | 310 | } |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | * option returned in this array is the most-recently ran DMS option |
| 315 | 315 | * @return array |
| 316 | 316 | */ |
| 317 | - public function get_all_migration_script_options(){ |
|
| 317 | + public function get_all_migration_script_options() { |
|
| 318 | 318 | global $wpdb; |
| 319 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
| 319 | + return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
| 325 | 325 | * folder name. |
| 326 | 326 | */ |
| 327 | - public function get_data_migration_script_folders(){ |
|
| 328 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
| 327 | + public function get_data_migration_script_folders() { |
|
| 328 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | /** |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | * } |
| 338 | 338 | * @throws EE_Error |
| 339 | 339 | */ |
| 340 | - public function script_migrates_to_version($migration_script_name){ |
|
| 340 | + public function script_migrates_to_version($migration_script_name) { |
|
| 341 | 341 | $dms_info = $this->parse_dms_classname($migration_script_name); |
| 342 | 342 | return array( |
| 343 | - 'slug'=> $dms_info[ 'slug' ], |
|
| 344 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
| 343 | + 'slug'=> $dms_info['slug'], |
|
| 344 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -350,10 +350,10 @@ discard block |
||
| 350 | 350 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
| 351 | 351 | * @throws EE_Error |
| 352 | 352 | */ |
| 353 | - public function parse_dms_classname($classname){ |
|
| 353 | + public function parse_dms_classname($classname) { |
|
| 354 | 354 | $matches = array(); |
| 355 | - preg_match( '~EE_DMS_(.*)_(\d*)_(\d*)_(\d*)~', $classname, $matches ); |
|
| 356 | - if ( ! $matches || ! isset( $matches[1], $matches[2], $matches[3] ) ) { |
|
| 355 | + preg_match('~EE_DMS_(.*)_(\d*)_(\d*)_(\d*)~', $classname, $matches); |
|
| 356 | + if ( ! $matches || ! isset($matches[1], $matches[2], $matches[3])) { |
|
| 357 | 357 | throw new EE_Error( |
| 358 | 358 | sprintf( |
| 359 | 359 | __( |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | return array( |
| 368 | 368 | 'slug' => $matches[1], |
| 369 | - 'major_version' => (int)$matches[2], |
|
| 370 | - 'minor_version' => (int)$matches[3], |
|
| 371 | - 'micro_version' => (int)$matches[4] |
|
| 369 | + 'major_version' => (int) $matches[2], |
|
| 370 | + 'minor_version' => (int) $matches[3], |
|
| 371 | + 'micro_version' => (int) $matches[4] |
|
| 372 | 372 | ); |
| 373 | 373 | } |
| 374 | 374 | |
@@ -381,33 +381,33 @@ discard block |
||
| 381 | 381 | * to 4.1.x. |
| 382 | 382 | * @return string of current db state |
| 383 | 383 | */ |
| 384 | - public function ensure_current_database_state_is_set(){ |
|
| 385 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
| 384 | + public function ensure_current_database_state_is_set() { |
|
| 385 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
| 386 | 386 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
| 387 | - if( ! $db_state ){ |
|
| 387 | + if ( ! $db_state) { |
|
| 388 | 388 | // set default |
| 389 | 389 | //echo "4.1.0 is SMALLER than $previous_version_installed"; |
| 390 | - $db_state = array( 'Core' => EVENT_ESPRESSO_VERSION ); |
|
| 390 | + $db_state = array('Core' => EVENT_ESPRESSO_VERSION); |
|
| 391 | 391 | //mark the DB as being in the state as the last version in there. |
| 392 | 392 | //this is done to trigger maintenance mode and do data migration scripts |
| 393 | 393 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
| 394 | 394 | //otherwise, the normal maintenance mode code is fine |
| 395 | 395 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
| 396 | 396 | $previous_version_installed = end($previous_versions_installed); |
| 397 | - if( version_compare('4.1.0', $previous_version_installed)){ |
|
| 397 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
| 398 | 398 | //last installed version was less than 4.1 |
| 399 | 399 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
| 400 | 400 | //echo "4.1.0 is greater than $previous_version_installed! update the option"; |
| 401 | 401 | $db_state = array('Core'=>$previous_version_installed); |
| 402 | 402 | } |
| 403 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
| 403 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
| 404 | 404 | } |
| 405 | 405 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
| 406 | 406 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
| 407 | 407 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
| 408 | - if( ! is_array($db_state)){ |
|
| 408 | + if ( ! is_array($db_state)) { |
|
| 409 | 409 | $db_state = array('Core'=>$db_state); |
| 410 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
| 410 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
| 411 | 411 | } |
| 412 | 412 | return $db_state; |
| 413 | 413 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | * @return EE_Data_Migration_Script_Base[] |
| 421 | 421 | * @throws EE_Error |
| 422 | 422 | */ |
| 423 | - public function check_for_applicable_data_migration_scripts(){ |
|
| 423 | + public function check_for_applicable_data_migration_scripts() { |
|
| 424 | 424 | $this->_load_dms_classes(); |
| 425 | 425 | //get the option describing what options have already run |
| 426 | 426 | $scripts_ran = $this->get_data_migrations_ran(); |
@@ -434,37 +434,37 @@ discard block |
||
| 434 | 434 | $iteration = 0; |
| 435 | 435 | $next_database_state_to_consider = $current_database_state; |
| 436 | 436 | $theoretical_database_state = NULL; |
| 437 | - do{ |
|
| 437 | + do { |
|
| 438 | 438 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
| 439 | 439 | $theoretical_database_state = $next_database_state_to_consider; |
| 440 | 440 | //the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?) |
| 441 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
| 441 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
| 442 | 442 | |
| 443 | 443 | $migrates_to_version = $this->script_migrates_to_version($classname); |
| 444 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
| 445 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
| 444 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
| 445 | + $script_converts_to_version = $migrates_to_version['version']; |
|
| 446 | 446 | //check if this version script is DONE or not; or if it's never been ran |
| 447 | - if( |
|
| 447 | + if ( |
|
| 448 | 448 | ! $scripts_ran |
| 449 | 449 | || ! isset( |
| 450 | 450 | $scripts_ran[$script_converts_plugin_slug], |
| 451 | 451 | $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] |
| 452 | 452 | ) |
| 453 | - ){ |
|
| 453 | + ) { |
|
| 454 | 454 | //we haven't ran this conversion script before |
| 455 | 455 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
| 456 | 456 | $script = new $classname; |
| 457 | 457 | /* @var $script EE_Data_Migration_Script_Base */ |
| 458 | 458 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
| 459 | - if($can_migrate){ |
|
| 459 | + if ($can_migrate) { |
|
| 460 | 460 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
| 461 | 461 | $migrates_to_version = $script->migrates_to_version(); |
| 462 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
| 462 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
| 463 | 463 | unset($script_class_and_filepaths_available[$classname]); |
| 464 | 464 | } |
| 465 | - } elseif( |
|
| 465 | + } elseif ( |
|
| 466 | 466 | $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base |
| 467 | - ){ |
|
| 467 | + ) { |
|
| 468 | 468 | //this script has been ran, or at least started |
| 469 | 469 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
| 470 | 470 | if ( |
@@ -472,11 +472,11 @@ discard block |
||
| 472 | 472 | && $script->get_status() !== self::status_completed |
| 473 | 473 | ) { |
| 474 | 474 | //this script is already underway... keep going with it |
| 475 | - $script_classes_that_should_run_per_iteration[ $iteration ][ $script->priority( |
|
| 476 | - ) ][] = $script; |
|
| 475 | + $script_classes_that_should_run_per_iteration[$iteration][$script->priority( |
|
| 476 | + )][] = $script; |
|
| 477 | 477 | $migrates_to_version = $script->migrates_to_version(); |
| 478 | - $next_database_state_to_consider[ $migrates_to_version['slug'] ] = $migrates_to_version['version']; |
|
| 479 | - unset( $script_class_and_filepaths_available[ $classname ] ); |
|
| 478 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
| 479 | + unset($script_class_and_filepaths_available[$classname]); |
|
| 480 | 480 | }/*else { |
| 481 | 481 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
| 482 | 482 | }*/ |
@@ -488,19 +488,19 @@ discard block |
||
| 488 | 488 | }*/ |
| 489 | 489 | } |
| 490 | 490 | $iteration++; |
| 491 | - }while( $next_database_state_to_consider !== $theoretical_database_state && $iteration<6); |
|
| 491 | + }while ($next_database_state_to_consider !== $theoretical_database_state && $iteration < 6); |
|
| 492 | 492 | //ok we have all the scripts that should run, now let's make them into flat array |
| 493 | 493 | $scripts_that_should_run = array(); |
| 494 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
| 494 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
| 495 | 495 | ksort($scripts_at_priority); |
| 496 | - foreach($scripts_at_priority as $scripts){ |
|
| 497 | - foreach($scripts as $script){ |
|
| 496 | + foreach ($scripts_at_priority as $scripts) { |
|
| 497 | + foreach ($scripts as $script) { |
|
| 498 | 498 | $scripts_that_should_run[get_class($script)] = $script; |
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
| 503 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
| 504 | 504 | return $scripts_that_should_run; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -516,14 +516,14 @@ discard block |
||
| 516 | 516 | * @return EE_Data_Migration_Script_Base |
| 517 | 517 | * @throws \EE_Error |
| 518 | 518 | */ |
| 519 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
| 519 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
| 520 | 520 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
| 521 | - if( ! $this->_data_migrations_ran){ |
|
| 521 | + if ( ! $this->_data_migrations_ran) { |
|
| 522 | 522 | $this->get_data_migrations_ran(); |
| 523 | 523 | } |
| 524 | - if($include_completed_scripts){ |
|
| 524 | + if ($include_completed_scripts) { |
|
| 525 | 525 | return $this->_last_ran_script; |
| 526 | - }else{ |
|
| 526 | + } else { |
|
| 527 | 527 | return $this->_last_ran_incomplete_script; |
| 528 | 528 | } |
| 529 | 529 | } |
@@ -546,23 +546,23 @@ discard block |
||
| 546 | 546 | * @type string $message string describing what was done during this step |
| 547 | 547 | * } |
| 548 | 548 | */ |
| 549 | - public function migration_step( $step_size = 0 ){ |
|
| 549 | + public function migration_step($step_size = 0) { |
|
| 550 | 550 | |
| 551 | 551 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
| 552 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
| 553 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
| 552 | + if (class_exists('EE_CPT_Strategy')) { |
|
| 553 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - try{ |
|
| 556 | + try { |
|
| 557 | 557 | $currently_executing_script = $this->get_last_ran_script(); |
| 558 | - if( ! $currently_executing_script){ |
|
| 558 | + if ( ! $currently_executing_script) { |
|
| 559 | 559 | //Find the next script that needs to execute |
| 560 | 560 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
| 561 | - if( ! $scripts ){ |
|
| 561 | + if ( ! $scripts) { |
|
| 562 | 562 | //huh, no more scripts to run... apparently we're done! |
| 563 | 563 | //but dont forget to make sure initial data is there |
| 564 | 564 | //we should be good to allow them to exit maintenance mode now |
| 565 | - EE_Maintenance_Mode::instance()->set_maintenance_level( EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
| 565 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 566 | 566 | //saving migrations ran should actually be unnecessary, but leaving in place just in case |
| 567 | 567 | //remember this migration was finished (even if we timeout initializing db for core and plugins) |
| 568 | 568 | $this->_save_migrations_ran(); |
@@ -579,18 +579,18 @@ discard block |
||
| 579 | 579 | //and add to the array/wp option showing the scripts ran |
| 580 | 580 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
| 581 | 581 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
| 582 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
| 583 | - $version = $migrates_to[ 'version' ]; |
|
| 582 | + $plugin_slug = $migrates_to['slug']; |
|
| 583 | + $version = $migrates_to['version']; |
|
| 584 | 584 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
| 585 | 585 | } |
| 586 | 586 | $current_script_name = get_class($currently_executing_script); |
| 587 | - }catch(Exception $e){ |
|
| 587 | + } catch (Exception $e) { |
|
| 588 | 588 | //an exception occurred while trying to get migration scripts |
| 589 | 589 | |
| 590 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
| 590 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
| 591 | 591 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
| 592 | 592 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
| 593 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
| 593 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
| 594 | 594 | return array( |
| 595 | 595 | 'records_to_migrate'=>1, |
| 596 | 596 | 'records_migrated'=>0, |
@@ -601,15 +601,15 @@ discard block |
||
| 601 | 601 | } |
| 602 | 602 | $init_dbs = false; |
| 603 | 603 | //ok so we definitely have a data migration script |
| 604 | - try{ |
|
| 604 | + try { |
|
| 605 | 605 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
| 606 | - if( ! absint( $step_size ) > 0 ){ |
|
| 607 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
| 606 | + if ( ! absint($step_size) > 0) { |
|
| 607 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
| 608 | 608 | } |
| 609 | 609 | //do what we came to do! |
| 610 | 610 | $currently_executing_script->migration_step($step_size); |
| 611 | 611 | //can we wrap it up and verify default data? |
| 612 | - switch($currently_executing_script->get_status()){ |
|
| 612 | + switch ($currently_executing_script->get_status()) { |
|
| 613 | 613 | case EE_Data_Migration_Manager::status_continue: |
| 614 | 614 | $response_array = array( |
| 615 | 615 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -621,18 +621,18 @@ discard block |
||
| 621 | 621 | case EE_Data_Migration_Manager::status_completed: |
| 622 | 622 | //ok so THAT script has completed |
| 623 | 623 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
| 624 | - $response_array = array( |
|
| 624 | + $response_array = array( |
|
| 625 | 625 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
| 626 | 626 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
| 627 | 627 | 'status'=> EE_Data_Migration_Manager::status_completed, |
| 628 | 628 | 'message'=>$currently_executing_script->get_feedback_message(), |
| 629 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
| 629 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
| 630 | 630 | ); |
| 631 | 631 | //check if there are any more after this one. |
| 632 | 632 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
| 633 | - if( ! $scripts_remaining ){ |
|
| 633 | + if ( ! $scripts_remaining) { |
|
| 634 | 634 | //we should be good to allow them to exit maintenance mode now |
| 635 | - EE_Maintenance_Mode::instance()->set_maintenance_level( EE_Maintenance_Mode::level_0_not_in_maintenance ); |
|
| 635 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 636 | 636 | ////huh, no more scripts to run... apparently we're done! |
| 637 | 637 | //but dont forget to make sure initial data is there |
| 638 | 638 | $init_dbs = true; |
@@ -644,39 +644,39 @@ discard block |
||
| 644 | 644 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
| 645 | 645 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
| 646 | 646 | 'status'=> $currently_executing_script->get_status(), |
| 647 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
| 647 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
| 648 | 648 | 'script'=>$currently_executing_script->pretty_name() |
| 649 | 649 | ); |
| 650 | 650 | break; |
| 651 | 651 | } |
| 652 | - }catch(Exception $e){ |
|
| 652 | + } catch (Exception $e) { |
|
| 653 | 653 | //ok so some exception was thrown which killed the data migration script |
| 654 | 654 | //double-check we have a real script |
| 655 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
| 655 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
| 656 | 656 | $script_name = $currently_executing_script->pretty_name(); |
| 657 | 657 | $currently_executing_script->set_broken(); |
| 658 | 658 | $currently_executing_script->add_error($e->getMessage()); |
| 659 | - }else{ |
|
| 659 | + } else { |
|
| 660 | 660 | $script_name = __("Error getting Migration Script", "event_espresso"); |
| 661 | 661 | } |
| 662 | 662 | $response_array = array( |
| 663 | 663 | 'records_to_migrate'=>1, |
| 664 | 664 | 'records_migrated'=>0, |
| 665 | 665 | 'status'=>self::status_fatal_error, |
| 666 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
| 666 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
| 667 | 667 | 'script'=>$script_name |
| 668 | 668 | ); |
| 669 | 669 | } |
| 670 | 670 | $successful_save = $this->_save_migrations_ran(); |
| 671 | - if($successful_save !== TRUE){ |
|
| 671 | + if ($successful_save !== TRUE) { |
|
| 672 | 672 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
| 673 | 673 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
| 674 | 674 | //however, if we throw an exception, and return that, then the next request |
| 675 | 675 | //won't have as much info in it, and it may be able to save |
| 676 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
| 676 | + throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save)); |
|
| 677 | 677 | } |
| 678 | 678 | //if we're all done, initialize EE plugins' default data etc. |
| 679 | - if( $init_dbs ) { |
|
| 679 | + if ($init_dbs) { |
|
| 680 | 680 | $this->initialize_db_for_enqueued_ee_plugins(); |
| 681 | 681 | } |
| 682 | 682 | return $response_array; |
@@ -696,23 +696,23 @@ discard block |
||
| 696 | 696 | * 'script'=>a pretty name of the script currently running |
| 697 | 697 | * @throws \EE_Error |
| 698 | 698 | */ |
| 699 | - public function response_to_migration_ajax_request(){ |
|
| 699 | + public function response_to_migration_ajax_request() { |
|
| 700 | 700 | // //start output buffer just to make sure we don't mess up the json |
| 701 | 701 | ob_start(); |
| 702 | - try{ |
|
| 702 | + try { |
|
| 703 | 703 | $response = $this->migration_step(); |
| 704 | - }catch(Exception $e){ |
|
| 704 | + } catch (Exception $e) { |
|
| 705 | 705 | $response = array( |
| 706 | 706 | 'records_to_migrate'=>0, |
| 707 | 707 | 'records_migrated'=>0, |
| 708 | 708 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
| 709 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
| 709 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
| 710 | 710 | 'script'=>'Unknown'); |
| 711 | 711 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
| 712 | 712 | } |
| 713 | 713 | $warnings_etc = @ob_get_contents(); |
| 714 | 714 | ob_end_clean(); |
| 715 | - $response['message'] .=$warnings_etc; |
|
| 715 | + $response['message'] .= $warnings_etc; |
|
| 716 | 716 | return $response; |
| 717 | 717 | } |
| 718 | 718 | |
@@ -725,14 +725,14 @@ discard block |
||
| 725 | 725 | * } |
| 726 | 726 | * @return void |
| 727 | 727 | */ |
| 728 | - public function update_current_database_state_to($slug_and_version = null){ |
|
| 729 | - if( ! $slug_and_version ){ |
|
| 728 | + public function update_current_database_state_to($slug_and_version = null) { |
|
| 729 | + if ( ! $slug_and_version) { |
|
| 730 | 730 | //no version was provided, assume it should be at the current code version |
| 731 | 731 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
| 732 | 732 | } |
| 733 | - $current_database_state = (array)get_option( self::current_database_state, array() ); |
|
| 734 | - $current_database_state[ $slug_and_version[ 'slug' ] ] = $slug_and_version[ 'version' ]; |
|
| 735 | - update_option(self::current_database_state,$current_database_state); |
|
| 733 | + $current_database_state = (array) get_option(self::current_database_state, array()); |
|
| 734 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
| 735 | + update_option(self::current_database_state, $current_database_state); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /** |
@@ -743,20 +743,20 @@ discard block |
||
| 743 | 743 | * } |
| 744 | 744 | * @return boolean |
| 745 | 745 | */ |
| 746 | - public function database_needs_updating_to( $slug_and_version ) { |
|
| 746 | + public function database_needs_updating_to($slug_and_version) { |
|
| 747 | 747 | |
| 748 | - $slug = $slug_and_version[ 'slug' ]; |
|
| 749 | - $version = $slug_and_version[ 'version' ]; |
|
| 750 | - $current_database_state = (array)get_option( self::current_database_state, array() ); |
|
| 751 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
| 748 | + $slug = $slug_and_version['slug']; |
|
| 749 | + $version = $slug_and_version['version']; |
|
| 750 | + $current_database_state = (array) get_option(self::current_database_state, array()); |
|
| 751 | + if ( ! isset($current_database_state[$slug])) { |
|
| 752 | 752 | return true; |
| 753 | - }else{ |
|
| 753 | + } else { |
|
| 754 | 754 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
| 755 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
| 756 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
| 755 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
| 756 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
| 757 | 757 | $needs_updating = false; |
| 758 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
| 759 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
| 758 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
| 759 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
| 760 | 760 | $needs_updating = true; |
| 761 | 761 | break; |
| 762 | 762 | } |
@@ -772,28 +772,28 @@ discard block |
||
| 772 | 772 | * @return array keys are expected classnames, values are their filepaths |
| 773 | 773 | * @throws \EE_Error |
| 774 | 774 | */ |
| 775 | - public function get_all_data_migration_scripts_available(){ |
|
| 776 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
| 775 | + public function get_all_data_migration_scripts_available() { |
|
| 776 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
| 777 | 777 | $this->_load_dms_classes(); |
| 778 | 778 | $this->_data_migration_class_to_filepath_map = array(); |
| 779 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
| 780 | - if($folder_path[count($folder_path-1)] !== DS ){ |
|
| 781 | - $folder_path.= DS; |
|
| 779 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
| 780 | + if ($folder_path[count($folder_path - 1)] !== DS) { |
|
| 781 | + $folder_path .= DS; |
|
| 782 | 782 | } |
| 783 | - $files = glob( $folder_path. '*.dms.php' ); |
|
| 783 | + $files = glob($folder_path.'*.dms.php'); |
|
| 784 | 784 | |
| 785 | - if ( empty( $files ) ) { |
|
| 785 | + if (empty($files)) { |
|
| 786 | 786 | continue; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | - foreach($files as $file){ |
|
| 790 | - $pos_of_last_slash = strrpos($file,DS); |
|
| 791 | - $classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1)); |
|
| 792 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
| 793 | - $slug = $migrates_to[ 'slug' ]; |
|
| 789 | + foreach ($files as $file) { |
|
| 790 | + $pos_of_last_slash = strrpos($file, DS); |
|
| 791 | + $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1)); |
|
| 792 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
| 793 | + $slug = $migrates_to['slug']; |
|
| 794 | 794 | //check that the slug as contained in the DMS is associated with |
| 795 | 795 | //the slug of an addon or core |
| 796 | - if( $slug !== 'Core' && ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
| 796 | + if ($slug !== 'Core' && ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
| 797 | 797 | EE_Error::doing_it_wrong( |
| 798 | 798 | __FUNCTION__, |
| 799 | 799 | sprintf( |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * from each addon, and check if they need updating, |
| 831 | 831 | * @return boolean |
| 832 | 832 | */ |
| 833 | - public function addons_need_updating(){ |
|
| 833 | + public function addons_need_updating() { |
|
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | /** |
@@ -839,21 +839,21 @@ discard block |
||
| 839 | 839 | * @param string $error_message |
| 840 | 840 | * @throws EE_Error |
| 841 | 841 | */ |
| 842 | - public function add_error_to_migrations_ran($error_message){ |
|
| 842 | + public function add_error_to_migrations_ran($error_message) { |
|
| 843 | 843 | //get last-ran migration script |
| 844 | 844 | global $wpdb; |
| 845 | - $last_migration_script_option = (array)$wpdb->get_row( |
|
| 845 | + $last_migration_script_option = (array) $wpdb->get_row( |
|
| 846 | 846 | "SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", |
| 847 | 847 | ARRAY_A |
| 848 | 848 | ); |
| 849 | - $last_ran_migration_script_properties = isset( $last_migration_script_option['option_value'] ) |
|
| 850 | - ? maybe_unserialize( $last_migration_script_option['option_value'] ) |
|
| 849 | + $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) |
|
| 850 | + ? maybe_unserialize($last_migration_script_option['option_value']) |
|
| 851 | 851 | : null; |
| 852 | 852 | //now, tread lightly because we're here because a FATAL non-catchable error |
| 853 | 853 | //was thrown last time when we were trying to run a data migration script |
| 854 | 854 | //so the fatal error could have happened while getting the migration script |
| 855 | 855 | //or doing running it... |
| 856 | - $versions_migrated_to = isset( $last_migration_script_option['option_name'] ) |
|
| 856 | + $versions_migrated_to = isset($last_migration_script_option['option_name']) |
|
| 857 | 857 | ? str_replace( |
| 858 | 858 | EE_Data_Migration_Manager::data_migration_script_option_prefix, |
| 859 | 859 | '', |
@@ -863,14 +863,14 @@ discard block |
||
| 863 | 863 | |
| 864 | 864 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
| 865 | 865 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
| 866 | - if( |
|
| 866 | + if ( |
|
| 867 | 867 | $last_ran_migration_script_properties['_status'] !== self::status_completed |
| 868 | - && isset( $last_ran_migration_script_properties['class'], $last_ran_migration_script_properties['_status'] ) |
|
| 869 | - ){ |
|
| 868 | + && isset($last_ran_migration_script_properties['class'], $last_ran_migration_script_properties['_status']) |
|
| 869 | + ) { |
|
| 870 | 870 | //ok then just add this error to its list of errors |
| 871 | 871 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
| 872 | 872 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
| 873 | - }else{ |
|
| 873 | + } else { |
|
| 874 | 874 | //so we don't even know which script was last running |
| 875 | 875 | //use the data migration error stub, which is designed specifically for this type of thing |
| 876 | 876 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -880,9 +880,9 @@ discard block |
||
| 880 | 880 | $versions_migrated_to = 'Unknown.1.0.0'; |
| 881 | 881 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
| 882 | 882 | //delete the old one |
| 883 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
| 883 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
| 884 | 884 | } |
| 885 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
| 885 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
| 886 | 886 | |
| 887 | 887 | } |
| 888 | 888 | /** |
@@ -891,29 +891,29 @@ discard block |
||
| 891 | 891 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
| 892 | 892 | * @throws \EE_Error |
| 893 | 893 | */ |
| 894 | - protected function _save_migrations_ran(){ |
|
| 895 | - if($this->_data_migrations_ran === null){ |
|
| 894 | + protected function _save_migrations_ran() { |
|
| 895 | + if ($this->_data_migrations_ran === null) { |
|
| 896 | 896 | $this->get_data_migrations_ran(); |
| 897 | 897 | } |
| 898 | 898 | //now, we don't want to save actual classes to the DB because that's messy |
| 899 | 899 | $successful_updates = true; |
| 900 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
| 901 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
| 900 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
| 901 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
| 902 | 902 | // echo "saving migration script to $version_string<br>"; |
| 903 | 903 | $option_name = self::data_migration_script_option_prefix.$plugin_slug.'.'.$version_string; |
| 904 | 904 | $old_option_value = get_option($option_name); |
| 905 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
| 905 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
| 906 | 906 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
| 907 | - if( $old_option_value !== $script_array_for_saving){ |
|
| 908 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
| 907 | + if ($old_option_value !== $script_array_for_saving) { |
|
| 908 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
| 909 | 909 | } |
| 910 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
| 910 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
| 911 | 911 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
| 912 | - if($old_option_value !== $array_or_migration_obj){ |
|
| 913 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
| 912 | + if ($old_option_value !== $array_or_migration_obj) { |
|
| 913 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | - if( ! $successful_updates ){ |
|
| 916 | + if ( ! $successful_updates) { |
|
| 917 | 917 | global $wpdb; |
| 918 | 918 | return $wpdb->last_error; |
| 919 | 919 | } |
@@ -937,27 +937,27 @@ discard block |
||
| 937 | 937 | * @return EE_Data_Migration_Script_Base |
| 938 | 938 | * @throws EE_Error |
| 939 | 939 | */ |
| 940 | - public function _instantiate_script_from_properties_array($properties_array){ |
|
| 941 | - if ( ! isset( $properties_array['class'] ) ) { |
|
| 940 | + public function _instantiate_script_from_properties_array($properties_array) { |
|
| 941 | + if ( ! isset($properties_array['class'])) { |
|
| 942 | 942 | throw new EE_Error( |
| 943 | 943 | sprintf( |
| 944 | 944 | __( |
| 945 | 945 | "Properties array has no 'class' properties. Here's what it has: %s", |
| 946 | 946 | 'event_espresso' |
| 947 | 947 | ), |
| 948 | - implode( ',', $properties_array ) |
|
| 948 | + implode(',', $properties_array) |
|
| 949 | 949 | ) |
| 950 | 950 | ); |
| 951 | 951 | } |
| 952 | 952 | $this->_load_dms_classes(); |
| 953 | 953 | $class_name = $properties_array['class']; |
| 954 | - if ( ! class_exists( $class_name ) ) { |
|
| 954 | + if ( ! class_exists($class_name)) { |
|
| 955 | 955 | throw new EE_Error( |
| 956 | - sprintf( __( 'There is no migration script named %s', 'event_espresso' ), $class_name ) |
|
| 956 | + sprintf(__('There is no migration script named %s', 'event_espresso'), $class_name) |
|
| 957 | 957 | ); |
| 958 | 958 | } |
| 959 | 959 | $class = new $class_name; |
| 960 | - if ( ! $class instanceof EE_Data_Migration_Script_Base ) { |
|
| 960 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
| 961 | 961 | throw new EE_Error( |
| 962 | 962 | sprintf( |
| 963 | 963 | __( |
@@ -965,11 +965,11 @@ discard block |
||
| 965 | 965 | 'event_espresso' |
| 966 | 966 | ), |
| 967 | 967 | $class_name, |
| 968 | - get_class( $class ) |
|
| 968 | + get_class($class) |
|
| 969 | 969 | ) |
| 970 | 970 | ); |
| 971 | 971 | } |
| 972 | - $class->instantiate_from_array_of_properties( $properties_array ); |
|
| 972 | + $class->instantiate_from_array_of_properties($properties_array); |
|
| 973 | 973 | return $class; |
| 974 | 974 | } |
| 975 | 975 | |
@@ -980,28 +980,28 @@ discard block |
||
| 980 | 980 | * @return string |
| 981 | 981 | * @throws \EE_Error |
| 982 | 982 | */ |
| 983 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
| 983 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
| 984 | 984 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
| 985 | 985 | $most_up_to_date_dms_classname = NULL; |
| 986 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
| 987 | - if($most_up_to_date_dms_classname === NULL){ |
|
| 986 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
| 987 | + if ($most_up_to_date_dms_classname === NULL) { |
|
| 988 | 988 | $migrates_to = $this->script_migrates_to_version($classname); |
| 989 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
| 989 | + $this_plugin_slug = $migrates_to['slug']; |
|
| 990 | 990 | // $version_string = $migrates_to[ 'version' ]; |
| 991 | 991 | // $details = $this->parse_dms_classname($classname); |
| 992 | - if($this_plugin_slug === $plugin_slug){ |
|
| 992 | + if ($this_plugin_slug === $plugin_slug) { |
|
| 993 | 993 | //if it's for core, it wins |
| 994 | 994 | $most_up_to_date_dms_classname = $classname; |
| 995 | 995 | } |
| 996 | 996 | //if it wasn't for core, we must keep searching for one that is! |
| 997 | 997 | continue; |
| 998 | - }else{ |
|
| 999 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
| 998 | + } else { |
|
| 999 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
| 1000 | 1000 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
| 1001 | - if( |
|
| 1002 | - $contender_migrates_to[ 'slug' ] === $plugin_slug |
|
| 1003 | - && version_compare( $champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<' ) |
|
| 1004 | - ){ |
|
| 1001 | + if ( |
|
| 1002 | + $contender_migrates_to['slug'] === $plugin_slug |
|
| 1003 | + && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<') |
|
| 1004 | + ) { |
|
| 1005 | 1005 | //so the contenders version is higher and its for Core |
| 1006 | 1006 | $most_up_to_date_dms_classname = $classname; |
| 1007 | 1007 | } |
@@ -1023,11 +1023,11 @@ discard block |
||
| 1023 | 1023 | * @return EE_Data_Migration_Script_Base |
| 1024 | 1024 | * @throws \EE_Error |
| 1025 | 1025 | */ |
| 1026 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
| 1026 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
| 1027 | 1027 | $migrations_ran = $this->get_data_migrations_ran(); |
| 1028 | - if( isset( $migrations_ran[ $plugin_slug ], $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
| 1029 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
| 1030 | - }else{ |
|
| 1028 | + if (isset($migrations_ran[$plugin_slug], $migrations_ran[$plugin_slug][$version])) { |
|
| 1029 | + return $migrations_ran[$plugin_slug][$version]; |
|
| 1030 | + } else { |
|
| 1031 | 1031 | return NULL; |
| 1032 | 1032 | } |
| 1033 | 1033 | } |
@@ -1039,26 +1039,26 @@ discard block |
||
| 1039 | 1039 | * @return bool |
| 1040 | 1040 | * @throws \EE_Error |
| 1041 | 1041 | */ |
| 1042 | - public function reattempt(){ |
|
| 1042 | + public function reattempt() { |
|
| 1043 | 1043 | //find if the last-ran script was borked |
| 1044 | 1044 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
| 1045 | 1045 | //add an 'error' saying that we attempted to reset |
| 1046 | 1046 | //does it have a stage that was borked too? if so make it no longer borked |
| 1047 | 1047 | //add an 'error' saying we attempted to reset |
| 1048 | 1048 | $last_ran_script = $this->get_last_ran_script(); |
| 1049 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
| 1049 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
| 1050 | 1050 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
| 1051 | 1051 | $last_ran_script->set_completed(); |
| 1052 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
| 1052 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
| 1053 | 1053 | $last_ran_script->reattempt(); |
| 1054 | - }else{ |
|
| 1054 | + } else { |
|
| 1055 | 1055 | throw new EE_Error( |
| 1056 | 1056 | sprintf( |
| 1057 | 1057 | __( |
| 1058 | 1058 | 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', |
| 1059 | 1059 | 'event_espresso' |
| 1060 | 1060 | ), |
| 1061 | - print_r( $last_ran_script, true ) |
|
| 1061 | + print_r($last_ran_script, true) |
|
| 1062 | 1062 | ) |
| 1063 | 1063 | ); |
| 1064 | 1064 | } |
@@ -1072,19 +1072,19 @@ discard block |
||
| 1072 | 1072 | * @return boolean |
| 1073 | 1073 | * @throws \EE_Error |
| 1074 | 1074 | */ |
| 1075 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
| 1076 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
| 1075 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
| 1076 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
| 1077 | 1077 | } |
| 1078 | 1078 | /** |
| 1079 | 1079 | * Enqueues this ee plugin to have its data initialized |
| 1080 | 1080 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
| 1081 | 1081 | */ |
| 1082 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
| 1082 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
| 1083 | 1083 | $queue = $this->get_db_initialization_queue(); |
| 1084 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
| 1084 | + if ( ! in_array($plugin_slug, $queue)) { |
|
| 1085 | 1085 | $queue[] = $plugin_slug; |
| 1086 | 1086 | } |
| 1087 | - update_option( self::db_init_queue_option_name, $queue ); |
|
| 1087 | + update_option(self::db_init_queue_option_name, $queue); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | |
@@ -1099,25 +1099,25 @@ discard block |
||
| 1099 | 1099 | public function initialize_db_for_enqueued_ee_plugins() { |
| 1100 | 1100 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
| 1101 | 1101 | $queue = $this->get_db_initialization_queue(); |
| 1102 | - foreach( $queue as $plugin_slug ) { |
|
| 1103 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
| 1104 | - if( ! $most_up_to_date_dms ) { |
|
| 1102 | + foreach ($queue as $plugin_slug) { |
|
| 1103 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
| 1104 | + if ( ! $most_up_to_date_dms) { |
|
| 1105 | 1105 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
| 1106 | 1106 | $verify_db = false; |
| 1107 | - }else{ |
|
| 1108 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
| 1109 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
| 1107 | + } else { |
|
| 1108 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
| 1109 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
| 1110 | 1110 | } |
| 1111 | - if( $plugin_slug === 'Core' ){ |
|
| 1111 | + if ($plugin_slug === 'Core') { |
|
| 1112 | 1112 | EE_Activation_Manager::instance()->initialize_db_if_no_migrations_required( |
| 1113 | 1113 | false, |
| 1114 | 1114 | $verify_db |
| 1115 | 1115 | ); |
| 1116 | - }else{ |
|
| 1116 | + } else { |
|
| 1117 | 1117 | //just loop through the addons to make sure their database is setup |
| 1118 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
| 1119 | - if( $addon->name() === $plugin_slug ) { |
|
| 1120 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
| 1118 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
| 1119 | + if ($addon->name() === $plugin_slug) { |
|
| 1120 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
| 1121 | 1121 | break; |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | // EEH_Debug_Tools::instance()->show_times(); |
| 1128 | 1128 | //because we just initialized the DBs for the enqueued ee plugins |
| 1129 | 1129 | //we don't need to keep remembering which ones needed to be initialized |
| 1130 | - delete_option( self::db_init_queue_option_name ); |
|
| 1130 | + delete_option(self::db_init_queue_option_name); |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | /** |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * 'Core', or the return value of EE_Addon::name() for an addon |
| 1137 | 1137 | * @return array |
| 1138 | 1138 | */ |
| 1139 | - public function get_db_initialization_queue(){ |
|
| 1140 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
| 1139 | + public function get_db_initialization_queue() { |
|
| 1140 | + return get_option(self::db_init_queue_option_name, array()); |
|
| 1141 | 1141 | } |
| 1142 | 1142 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public static function instance() { |
| 73 | 73 | // check if class object is instantiated |
| 74 | - if ( ! self::$_instance instanceof EE_Load_Espresso_Core ) { |
|
| 74 | + if ( ! self::$_instance instanceof EE_Load_Espresso_Core) { |
|
| 75 | 75 | self::$_instance = new self(); |
| 76 | 76 | } |
| 77 | 77 | return self::$_instance; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | private function __construct() { |
| 87 | 87 | // PSR4 Autoloaders |
| 88 | - espresso_load_required( 'EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php' ); |
|
| 88 | + espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE.'EE_Psr4AutoloaderInit.core.php'); |
|
| 89 | 89 | new EE_Psr4AutoloaderInit(); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -96,40 +96,40 @@ discard block |
||
| 96 | 96 | * @param EE_Response $response |
| 97 | 97 | * @throws \EE_Error |
| 98 | 98 | */ |
| 99 | - private function init( EE_Request $request, EE_Response $response ) { |
|
| 99 | + private function init(EE_Request $request, EE_Response $response) { |
|
| 100 | 100 | static $initialized = false; |
| 101 | - if ( ! $initialized ) { |
|
| 101 | + if ( ! $initialized) { |
|
| 102 | 102 | // load text domain right away so that any error messages can be translated asap |
| 103 | - espresso_load_required( 'EE_Load_Textdomain', EE_CORE . 'EE_Load_Textdomain.core.php' ); |
|
| 104 | - espresso_load_required( 'EEH_Sideloader', EE_CORE . 'helpers' . DS . 'EEH_Sideloader.helper.php' ); |
|
| 105 | - EE_Load_Textdomain::set_sideloader( new EEH_Sideloader() ); |
|
| 103 | + espresso_load_required('EE_Load_Textdomain', EE_CORE.'EE_Load_Textdomain.core.php'); |
|
| 104 | + espresso_load_required('EEH_Sideloader', EE_CORE.'helpers'.DS.'EEH_Sideloader.helper.php'); |
|
| 105 | + EE_Load_Textdomain::set_sideloader(new EEH_Sideloader()); |
|
| 106 | 106 | EE_Load_Textdomain::load_textdomain(); |
| 107 | 107 | // deprecated functions |
| 108 | - espresso_load_required( 'EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php' ); |
|
| 108 | + espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php'); |
|
| 109 | 109 | // load interfaces |
| 110 | 110 | espresso_load_required( |
| 111 | 111 | 'EEI_Payment_Method_Interfaces', |
| 112 | - EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php' |
|
| 112 | + EE_LIBRARIES.'payment_methods'.DS.'EEI_Payment_Method_Interfaces.php' |
|
| 113 | 113 | ); |
| 114 | 114 | // workarounds for PHP < 5.3 |
| 115 | - espresso_load_required( 'EEH_Class_Tools', EE_HELPERS . 'EEH_Class_Tools.helper.php' ); |
|
| 115 | + espresso_load_required('EEH_Class_Tools', EE_HELPERS.'EEH_Class_Tools.helper.php'); |
|
| 116 | 116 | // manages activations, upgrades, and migrations |
| 117 | - espresso_load_required( 'EE_Activation_Manager', EE_CORE . 'EE_Activation_Manager.core.php' ); |
|
| 117 | + espresso_load_required('EE_Activation_Manager', EE_CORE.'EE_Activation_Manager.core.php'); |
|
| 118 | 118 | $this->activationManager = EE_Activation_Manager::instance( |
| 119 | 119 | EE_Maintenance_Mode::instance() |
| 120 | 120 | ); |
| 121 | 121 | // info about how to load classes required by other classes |
| 122 | - $this->dependency_map = $this->_load_dependency_map( $request, $response ); |
|
| 122 | + $this->dependency_map = $this->_load_dependency_map($request, $response); |
|
| 123 | 123 | // now setup the first core |
| 124 | 124 | $this->getEspressoCore(); |
| 125 | 125 | //$this->activationManager->setEspressoCore( $this->espressoCore ); |
| 126 | 126 | // central repository for classes |
| 127 | - espresso_load_required( 'EE_Registry', EE_CORE . 'EE_Registry.core.php' ); |
|
| 127 | + espresso_load_required('EE_Registry', EE_CORE.'EE_Registry.core.php'); |
|
| 128 | 128 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
| 129 | - add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'loadAddonsAndSetCaps' ) ); |
|
| 129 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'loadAddonsAndSetCaps')); |
|
| 130 | 130 | // when an ee addon is activated, we want to call the core hook(s) again |
| 131 | 131 | // because the newly-activated addon didn't get a chance to run at all |
| 132 | - add_action( 'activate_plugin', array( $this, 'loadAddonsAndSetCaps' ), 10 ); |
|
| 132 | + add_action('activate_plugin', array($this, 'loadAddonsAndSetCaps'), 10); |
|
| 133 | 133 | $initialized = true; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -149,9 +149,9 @@ discard block |
||
| 149 | 149 | * @throws \RuntimeException |
| 150 | 150 | * @throws \EE_Error |
| 151 | 151 | */ |
| 152 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 153 | - $this->init( $request, $response ); |
|
| 154 | - $this->initializeEspressoCore( $request, $response ); |
|
| 152 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 153 | + $this->init($request, $response); |
|
| 154 | + $this->initializeEspressoCore($request, $response); |
|
| 155 | 155 | return $this->espressoCore->response(); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -164,27 +164,27 @@ discard block |
||
| 164 | 164 | * @throws \RuntimeException |
| 165 | 165 | * @throws \EE_Error |
| 166 | 166 | */ |
| 167 | - protected function initializeEspressoCore( EE_Request $request, EE_Response $response ) { |
|
| 168 | - $this->espressoCore->set_request( $request ); |
|
| 169 | - $this->espressoCore->set_response( $response ); |
|
| 167 | + protected function initializeEspressoCore(EE_Request $request, EE_Response $response) { |
|
| 168 | + $this->espressoCore->set_request($request); |
|
| 169 | + $this->espressoCore->set_response($response); |
|
| 170 | 170 | // EE_Registry |
| 171 | - $this->espressoCore->set_registry( EE_Registry::instance() ); |
|
| 172 | - $this->espressoCore->registry()->set_dependency_map( $this->dependency_map() ); |
|
| 173 | - $this->espressoCore->registry()->set_request( $this->espressoCore->request() ); |
|
| 174 | - $this->espressoCore->registry()->set_response( $this->espressoCore->response() ); |
|
| 171 | + $this->espressoCore->set_registry(EE_Registry::instance()); |
|
| 172 | + $this->espressoCore->registry()->set_dependency_map($this->dependency_map()); |
|
| 173 | + $this->espressoCore->registry()->set_request($this->espressoCore->request()); |
|
| 174 | + $this->espressoCore->registry()->set_response($this->espressoCore->response()); |
|
| 175 | 175 | $this->espressoCore->registry()->initialize(); |
| 176 | 176 | // WP cron jobs |
| 177 | - $this->espressoCore->registry()->load_core( 'Cron_Tasks' ); |
|
| 178 | - $this->espressoCore->registry()->load_core( 'Request_Handler' ); |
|
| 177 | + $this->espressoCore->registry()->load_core('Cron_Tasks'); |
|
| 178 | + $this->espressoCore->registry()->load_core('Request_Handler'); |
|
| 179 | 179 | // load EE_System |
| 180 | 180 | $this->espressoCore->set_system( |
| 181 | - $this->espressoCore->registry()->load_core( 'EE_System' ) |
|
| 181 | + $this->espressoCore->registry()->load_core('EE_System') |
|
| 182 | 182 | ); |
| 183 | - $this->espressoCore->system()->set_registry( $this->espressoCore->registry() ); |
|
| 184 | - $this->espressoCore->system()->set_request( $this->espressoCore->request() ); |
|
| 185 | - $this->espressoCore->system()->set_response( $this->espressoCore->response() ); |
|
| 183 | + $this->espressoCore->system()->set_registry($this->espressoCore->registry()); |
|
| 184 | + $this->espressoCore->system()->set_request($this->espressoCore->request()); |
|
| 185 | + $this->espressoCore->system()->set_response($this->espressoCore->response()); |
|
| 186 | 186 | // pass core to Activation Manager |
| 187 | - $this->activationManager->setEspressoCore( $this->espressoCore ); |
|
| 187 | + $this->activationManager->setEspressoCore($this->espressoCore); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
@@ -193,15 +193,15 @@ discard block |
||
| 193 | 193 | * @param int $blog_id |
| 194 | 194 | * @return \EspressoCore |
| 195 | 195 | */ |
| 196 | - protected function getEspressoCore( $blog_id = 0 ) { |
|
| 197 | - $blog_id = ! empty( $blog_id ) ? $blog_id : get_current_blog_id(); |
|
| 196 | + protected function getEspressoCore($blog_id = 0) { |
|
| 197 | + $blog_id = ! empty($blog_id) ? $blog_id : get_current_blog_id(); |
|
| 198 | 198 | if ( |
| 199 | - ! isset( $this->espressoCoreCache[ $blog_id ] ) |
|
| 200 | - || ! $this->espressoCoreCache[ $blog_id ] instanceof \EspressoCore |
|
| 199 | + ! isset($this->espressoCoreCache[$blog_id]) |
|
| 200 | + || ! $this->espressoCoreCache[$blog_id] instanceof \EspressoCore |
|
| 201 | 201 | ) { |
| 202 | - $this->espressoCoreCache[ $blog_id ] = new \EspressoCore(); |
|
| 202 | + $this->espressoCoreCache[$blog_id] = new \EspressoCore(); |
|
| 203 | 203 | } |
| 204 | - $this->espressoCore = $this->espressoCoreCache[ $blog_id ]; |
|
| 204 | + $this->espressoCore = $this->espressoCoreCache[$blog_id]; |
|
| 205 | 205 | return $this->espressoCore; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * @throws \EE_Error |
| 213 | 213 | */ |
| 214 | 214 | public function dependency_map() { |
| 215 | - if ( ! $this->dependency_map instanceof EE_Dependency_Map ) { |
|
| 215 | + if ( ! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 216 | 216 | throw new EE_Error( |
| 217 | 217 | sprintf( |
| 218 | - __( 'Invalid EE_Dependency_Map: "%1$s"', 'event_espresso' ), |
|
| 219 | - print_r( $this->dependency_map, true ) |
|
| 218 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 219 | + print_r($this->dependency_map, true) |
|
| 220 | 220 | ) |
| 221 | 221 | ); |
| 222 | 222 | } |
@@ -233,16 +233,16 @@ discard block |
||
| 233 | 233 | * @param EE_Response $response |
| 234 | 234 | * @return EE_Dependency_Map |
| 235 | 235 | */ |
| 236 | - private function _load_dependency_map( EE_Request $request, EE_Response $response ) { |
|
| 237 | - if ( ! is_readable( EE_CORE . 'EE_Dependency_Map.core.php' ) ) { |
|
| 236 | + private function _load_dependency_map(EE_Request $request, EE_Response $response) { |
|
| 237 | + if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) { |
|
| 238 | 238 | EE_Error::add_error( |
| 239 | - __( 'The EE_Dependency_Map core class could not be loaded.', 'event_espresso' ), |
|
| 239 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 240 | 240 | __FILE__, __FUNCTION__, __LINE__ |
| 241 | 241 | ); |
| 242 | - wp_die( EE_Error::get_notices() ); |
|
| 242 | + wp_die(EE_Error::get_notices()); |
|
| 243 | 243 | } |
| 244 | - require_once( EE_CORE . 'EE_Dependency_Map.core.php' ); |
|
| 245 | - return EE_Dependency_Map::instance( $request, $response ); |
|
| 244 | + require_once(EE_CORE.'EE_Dependency_Map.core.php'); |
|
| 245 | + return EE_Dependency_Map::instance($request, $response); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -254,12 +254,12 @@ discard block |
||
| 254 | 254 | * @param int $blog_id |
| 255 | 255 | * @return bool |
| 256 | 256 | */ |
| 257 | - protected function unsetEspressoCore( $blog_id = 0 ) { |
|
| 258 | - $blog_id = ! empty( $blog_id ) ? $blog_id : 0; |
|
| 259 | - if ( ! $blog_id ) { |
|
| 257 | + protected function unsetEspressoCore($blog_id = 0) { |
|
| 258 | + $blog_id = ! empty($blog_id) ? $blog_id : 0; |
|
| 259 | + if ( ! $blog_id) { |
|
| 260 | 260 | return false; |
| 261 | 261 | } |
| 262 | - unset( $this->espressoCoreCache[ $blog_id ] ); |
|
| 262 | + unset($this->espressoCoreCache[$blog_id]); |
|
| 263 | 263 | return true; |
| 264 | 264 | } |
| 265 | 265 | |
@@ -281,16 +281,16 @@ discard block |
||
| 281 | 281 | try { |
| 282 | 282 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
| 283 | 283 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
| 284 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' ); |
|
| 285 | - } catch ( Exception $e ) { |
|
| 286 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 284 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
| 285 | + } catch (Exception $e) { |
|
| 286 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
| 287 | 287 | } |
| 288 | 288 | //load and setup EE_Capabilities |
| 289 | - $this->espressoCore->registry()->load_core( 'Capabilities' ); |
|
| 289 | + $this->espressoCore->registry()->load_core('Capabilities'); |
|
| 290 | 290 | //caps need to be initialized on every request so that capability maps are set. |
| 291 | 291 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
| 292 | 292 | $this->espressoCore->registry()->CAP->init_caps(); |
| 293 | - do_action( 'AHEE__EE_System__load_espresso_addons' ); |
|
| 293 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | |
@@ -304,13 +304,13 @@ discard block |
||
| 304 | 304 | * @param \EE_Request $request |
| 305 | 305 | * @param \EE_Response $response |
| 306 | 306 | */ |
| 307 | - public function handle_response( EE_Request $request, EE_Response $response ) { |
|
| 307 | + public function handle_response(EE_Request $request, EE_Response $response) { |
|
| 308 | 308 | //\EEH_Debug_Tools::printr( __FUNCTION__, __CLASS__, __FILE__, __LINE__, 2 ); |
| 309 | 309 | //EEH_Debug_Tools::printr( $request, '$request', __FILE__, __LINE__ ); |
| 310 | 310 | //EEH_Debug_Tools::printr( $response, '$response', __FILE__, __LINE__ ); |
| 311 | 311 | //die(); |
| 312 | - if ( $response->plugin_deactivated() ) { |
|
| 313 | - espresso_deactivate_plugin( EE_PLUGIN_BASENAME ); |
|
| 312 | + if ($response->plugin_deactivated()) { |
|
| 313 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | * @throws \EE_Error |
| 326 | 326 | * @throws \RuntimeException |
| 327 | 327 | */ |
| 328 | - public static function switchToBlog( $blog_id = 0 ) { |
|
| 329 | - \EE_Load_Espresso_Core::instance()->getEspressoCore( $blog_id ); |
|
| 328 | + public static function switchToBlog($blog_id = 0) { |
|
| 329 | + \EE_Load_Espresso_Core::instance()->getEspressoCore($blog_id); |
|
| 330 | 330 | \EE_Load_Espresso_Core::instance()->initializeEspressoCore( |
| 331 | 331 | EE_Bootstrap::get_request(), |
| 332 | 332 | EE_Bootstrap::get_response() |
@@ -340,8 +340,8 @@ discard block |
||
| 340 | 340 | * @return \EE_Registry |
| 341 | 341 | * @throws \EE_Error |
| 342 | 342 | */ |
| 343 | - public static function getRegistryForBlog( $blog_id = 0 ) { |
|
| 344 | - \EE_Load_Espresso_Core::instance()->getEspressoCore( $blog_id ); |
|
| 343 | + public static function getRegistryForBlog($blog_id = 0) { |
|
| 344 | + \EE_Load_Espresso_Core::instance()->getEspressoCore($blog_id); |
|
| 345 | 345 | return \EE_Load_Espresso_Core::instance()->espressoCore->registry(); |
| 346 | 346 | } |
| 347 | 347 | |
@@ -352,9 +352,9 @@ discard block |
||
| 352 | 352 | * @param \EE_Registry $registry |
| 353 | 353 | * @throws \EE_Error |
| 354 | 354 | */ |
| 355 | - public static function setRegistryForBlog( \EE_Registry $registry, $blog_id = 0 ) { |
|
| 356 | - \EE_Load_Espresso_Core::instance()->getEspressoCore( $blog_id ); |
|
| 357 | - \EE_Load_Espresso_Core::instance()->espressoCore->set_registry( $registry ); |
|
| 355 | + public static function setRegistryForBlog(\EE_Registry $registry, $blog_id = 0) { |
|
| 356 | + \EE_Load_Espresso_Core::instance()->getEspressoCore($blog_id); |
|
| 357 | + \EE_Load_Espresso_Core::instance()->espressoCore->set_registry($registry); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | * @param \EE_Request $request |
| 71 | 71 | * @param \EE_Response $response |
| 72 | 72 | */ |
| 73 | - protected function __construct( EE_Request $request, EE_Response $response ) { |
|
| 73 | + protected function __construct(EE_Request $request, EE_Response $response) { |
|
| 74 | 74 | $this->_request = $request; |
| 75 | 75 | $this->_response = $response; |
| 76 | 76 | $this->initialize(); |
| 77 | - do_action( 'EE_Dependency_Map____construct' ); |
|
| 77 | + do_action('EE_Dependency_Map____construct'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | * @param \EE_Response $response |
| 96 | 96 | * @return \EE_Dependency_Map instance |
| 97 | 97 | */ |
| 98 | - public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
|
| 98 | + public static function instance(EE_Request $request = null, EE_Response $response = null) { |
|
| 99 | 99 | // check if class object is instantiated, and instantiated properly |
| 100 | - if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
|
| 101 | - self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
| 100 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
| 101 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
| 102 | 102 | } |
| 103 | 103 | return self::$_instance; |
| 104 | 104 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param array $dependencies |
| 111 | 111 | * @return boolean |
| 112 | 112 | */ |
| 113 | - public static function register_dependencies( $class, $dependencies ) { |
|
| 114 | - if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
|
| 115 | - self::$_instance->_dependency_map[ $class ] = (array)$dependencies; |
|
| 113 | + public static function register_dependencies($class, $dependencies) { |
|
| 114 | + if ( ! isset(self::$_instance->_dependency_map[$class])) { |
|
| 115 | + self::$_instance->_dependency_map[$class] = (array) $dependencies; |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | return false; |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | * @return bool |
| 127 | 127 | * @throws \EE_Error |
| 128 | 128 | */ |
| 129 | - public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
|
| 129 | + public static function register_class_loader($class_name, $loader = 'load_core') { |
|
| 130 | 130 | // check that loader method starts with "load_" and exists in EE_Registry |
| 131 | - if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader ) ) { |
|
| 131 | + if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) { |
|
| 132 | 132 | throw new EE_Error( |
| 133 | 133 | sprintf( |
| 134 | - __( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
|
| 134 | + __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'), |
|
| 135 | 135 | $loader |
| 136 | 136 | ) |
| 137 | 137 | ); |
| 138 | 138 | } |
| 139 | - if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
|
| 140 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 139 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 140 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | return false; |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * @param string $class_name |
| 179 | 179 | * @return boolean |
| 180 | 180 | */ |
| 181 | - public function has( $class_name = '' ) { |
|
| 182 | - return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
|
| 181 | + public function has($class_name = '') { |
|
| 182 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | * @param string $dependency |
| 192 | 192 | * @return bool |
| 193 | 193 | */ |
| 194 | - public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
|
| 195 | - return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
|
| 194 | + public function has_dependency_for_class($class_name = '', $dependency = '') { |
|
| 195 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
| 196 | 196 | ? true |
| 197 | 197 | : false; |
| 198 | 198 | } |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * @param string $dependency |
| 207 | 207 | * @return int |
| 208 | 208 | */ |
| 209 | - public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
|
| 210 | - return $this->has_dependency_for_class( $class_name, $dependency ) |
|
| 211 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 209 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') { |
|
| 210 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 211 | + ? $this->_dependency_map[$class_name][$dependency] |
|
| 212 | 212 | : EE_Dependency_Map::not_registered; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -218,8 +218,8 @@ discard block |
||
| 218 | 218 | * @param string $class_name |
| 219 | 219 | * @return string | Closure |
| 220 | 220 | */ |
| 221 | - public function class_loader( $class_name ) { |
|
| 222 | - return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 221 | + public function class_loader($class_name) { |
|
| 222 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -361,17 +361,17 @@ discard block |
||
| 361 | 361 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
| 362 | 362 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
| 363 | 363 | 'EE_Messages_Generator' => function() { |
| 364 | - return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
|
| 364 | + return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false); |
|
| 365 | 365 | }, |
| 366 | - 'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
|
| 367 | - return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
|
| 366 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
| 367 | + return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false); |
|
| 368 | 368 | }, |
| 369 | 369 | //load_model |
| 370 | 370 | 'EEM_Message_Template_Group' => 'load_model', |
| 371 | 371 | 'EEM_Message_Template' => 'load_model', |
| 372 | 372 | //load_helper |
| 373 | 373 | 'EEH_Parse_Shortcodes' => function() { |
| 374 | - if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
|
| 374 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 375 | 375 | return new EEH_Parse_Shortcodes(); |
| 376 | 376 | } |
| 377 | 377 | return null; |
@@ -22,32 +22,32 @@ discard block |
||
| 22 | 22 | * @param EE_Response $response |
| 23 | 23 | * @return EE_Response |
| 24 | 24 | */ |
| 25 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 25 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 26 | 26 | $this->request = $request; |
| 27 | 27 | $this->response = $response; |
| 28 | 28 | //$this->response->add_output( "\n\t IN >> " . __CLASS__ ); |
| 29 | 29 | //$this->response->set_notice( 1, 'hey look at this' ); |
| 30 | 30 | // check required WP version |
| 31 | - if ( ! $this->_minimum_wp_version_required() ) { |
|
| 32 | - $this->request->un_set( 'activate', true ); |
|
| 33 | - add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 ); |
|
| 31 | + if ( ! $this->_minimum_wp_version_required()) { |
|
| 32 | + $this->request->un_set('activate', true); |
|
| 33 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
| 34 | 34 | //$this->response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
| 35 | 35 | $this->response->terminate_request(); |
| 36 | 36 | $this->response->deactivate_plugin(); |
| 37 | 37 | } |
| 38 | 38 | // check required PHP version |
| 39 | - if ( ! $this->_minimum_php_version_required() ) { |
|
| 40 | - $this->request->un_set( 'activate', true ); |
|
| 41 | - add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 ); |
|
| 39 | + if ( ! $this->_minimum_php_version_required()) { |
|
| 40 | + $this->request->un_set('activate', true); |
|
| 41 | + add_action('admin_notices', array($this, 'minimum_php_version_error'), 1); |
|
| 42 | 42 | //$this->response->add_output( "\n<br />" . 'minimum_php_version_error' ); |
| 43 | 43 | $this->response->terminate_request(); |
| 44 | 44 | $this->response->deactivate_plugin(); |
| 45 | 45 | } |
| 46 | 46 | // check recommended PHP version |
| 47 | - if ( ! $this->_minimum_php_version_recommended() ) { |
|
| 47 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
| 48 | 48 | $this->_display_minimum_recommended_php_version_notice(); |
| 49 | 49 | } |
| 50 | - $this->response = $this->process_request_stack( $this->request, $this->response ); |
|
| 50 | + $this->response = $this->process_request_stack($this->request, $this->response); |
|
| 51 | 51 | return $this->response; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | * @param string $min_version |
| 61 | 61 | * @return boolean |
| 62 | 62 | */ |
| 63 | - private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) { |
|
| 63 | + private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) { |
|
| 64 | 64 | global $wp_version; |
| 65 | - return version_compare( $wp_version, $min_version, '>=' ) ? true : false; |
|
| 65 | + return version_compare($wp_version, $min_version, '>=') ? true : false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return boolean |
| 75 | 75 | */ |
| 76 | 76 | private function _minimum_wp_version_required() { |
| 77 | - return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED ); |
|
| 77 | + return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @param string $min_version |
| 87 | 87 | * @return boolean |
| 88 | 88 | */ |
| 89 | - private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) { |
|
| 90 | - return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false; |
|
| 89 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) { |
|
| 90 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @return boolean |
| 100 | 100 | */ |
| 101 | 101 | private function _minimum_php_version_required() { |
| 102 | - return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED ); |
|
| 102 | + return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return boolean |
| 112 | 112 | */ |
| 113 | 113 | private function _minimum_php_version_recommended() { |
| 114 | - return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED ); |
|
| 114 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | <p> |
| 129 | 129 | <?php |
| 130 | 130 | printf( |
| 131 | - __( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
| 131 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
| 132 | 132 | EE_MIN_WP_VER_REQUIRED, |
| 133 | 133 | $wp_version, |
| 134 | 134 | '<br/>', |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | <p> |
| 154 | 154 | <?php |
| 155 | 155 | printf( |
| 156 | - __( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
| 156 | + __('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
| 157 | 157 | EE_MIN_PHP_VER_REQUIRED, |
| 158 | 158 | PHP_VERSION, |
| 159 | 159 | '<br/>', |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | private function _display_minimum_recommended_php_version_notice() { |
| 177 | 177 | EE_Error::add_persistent_admin_notice( |
| 178 | - 'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended', |
|
| 178 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
| 179 | 179 | sprintf( |
| 180 | - __( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
| 180 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
| 181 | 181 | EE_MIN_PHP_VER_RECOMMENDED, |
| 182 | 182 | PHP_VERSION, |
| 183 | 183 | '<br/>', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param \EE_Request $request |
| 59 | 59 | * @param \EE_Response $response |
| 60 | 60 | */ |
| 61 | - public function __construct( \EE_Request $request, \EE_Response $response ) { |
|
| 61 | + public function __construct(\EE_Request $request, \EE_Response $response) { |
|
| 62 | 62 | $this->request = $request; |
| 63 | 63 | $this->response = $response; |
| 64 | 64 | } |
@@ -76,31 +76,31 @@ discard block |
||
| 76 | 76 | * @param WP_Query $WP_Query |
| 77 | 77 | * @return string | NULL |
| 78 | 78 | */ |
| 79 | - public function get_route( WP_Query $WP_Query ) { |
|
| 79 | + public function get_route(WP_Query $WP_Query) { |
|
| 80 | 80 | $this->WP_Query = $WP_Query; |
| 81 | 81 | // assume this if first route being called |
| 82 | 82 | $previous_route = FALSE; |
| 83 | 83 | // but is it really ??? |
| 84 | - if ( ! empty( self::$_previous_routes )) { |
|
| 84 | + if ( ! empty(self::$_previous_routes)) { |
|
| 85 | 85 | // get last run route |
| 86 | - $previous_routes = array_values( self::$_previous_routes ); |
|
| 87 | - $previous_route = array_pop( $previous_routes ); |
|
| 86 | + $previous_routes = array_values(self::$_previous_routes); |
|
| 87 | + $previous_route = array_pop($previous_routes); |
|
| 88 | 88 | } |
| 89 | 89 | // has another route already been run ? |
| 90 | - if ( $previous_route ) { |
|
| 90 | + if ($previous_route) { |
|
| 91 | 91 | // check if forwarding has been set |
| 92 | - $current_route = $this->get_forward( $previous_route ); |
|
| 92 | + $current_route = $this->get_forward($previous_route); |
|
| 93 | 93 | try { |
| 94 | 94 | //check for recursive forwarding |
| 95 | - if ( isset( self::$_previous_routes[ $current_route ] )) { |
|
| 95 | + if (isset(self::$_previous_routes[$current_route])) { |
|
| 96 | 96 | throw new EE_Error( |
| 97 | 97 | sprintf( |
| 98 | - __('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'), |
|
| 98 | + __('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'), |
|
| 99 | 99 | $current_route |
| 100 | 100 | ) |
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | - } catch ( EE_Error $e ) { |
|
| 103 | + } catch (EE_Error $e) { |
|
| 104 | 104 | $e->get_error(); |
| 105 | 105 | return NULL; |
| 106 | 106 | } |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | // grab all routes |
| 111 | 111 | $routes = EE_Registry::instance()->CFG->get_routes(); |
| 112 | 112 | //d( $routes ); |
| 113 | - foreach( $routes as $key => $route ) { |
|
| 113 | + foreach ($routes as $key => $route) { |
|
| 114 | 114 | // check request for module route |
| 115 | - if ( EE_Registry::instance()->REQ->is_set( $key )) { |
|
| 115 | + if (EE_Registry::instance()->REQ->is_set($key)) { |
|
| 116 | 116 | //echo '<b style="color:#2EA2CC;">key : <span style="color:#E76700">' . $key . '</span></b><br />'; |
| 117 | - $current_route = sanitize_text_field( EE_Registry::instance()->REQ->get( $key )); |
|
| 118 | - if ( $current_route ) { |
|
| 119 | - $current_route = array( $key, $current_route ); |
|
| 117 | + $current_route = sanitize_text_field(EE_Registry::instance()->REQ->get($key)); |
|
| 118 | + if ($current_route) { |
|
| 119 | + $current_route = array($key, $current_route); |
|
| 120 | 120 | //echo '<b style="color:#2EA2CC;">current_route : <span style="color:#E76700">' . $current_route . '</span></b><br />'; |
| 121 | 121 | break; |
| 122 | 122 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | // sorry, but I can't read what you route ! |
| 127 | - if ( empty( $current_route )) { |
|
| 127 | + if (empty($current_route)) { |
|
| 128 | 128 | return NULL; |
| 129 | 129 | } |
| 130 | 130 | //add route to previous routes array |
@@ -144,46 +144,46 @@ discard block |
||
| 144 | 144 | * @param string $current_route |
| 145 | 145 | * @return mixed EED_Module | boolean |
| 146 | 146 | */ |
| 147 | - public function resolve_route( $key, $current_route ) { |
|
| 147 | + public function resolve_route($key, $current_route) { |
|
| 148 | 148 | // get module method that route has been mapped to |
| 149 | - $module_method = EE_Config::get_route( $current_route, $key ); |
|
| 149 | + $module_method = EE_Config::get_route($current_route, $key); |
|
| 150 | 150 | //EEH_Debug_Tools::printr( $module_method, '$module_method <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
| 151 | 151 | // verify result was returned |
| 152 | - if ( empty( $module_method )) { |
|
| 153 | - $msg = sprintf( __( 'The requested route %s could not be mapped to any registered modules.', 'event_espresso' ), $current_route ); |
|
| 154 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 152 | + if (empty($module_method)) { |
|
| 153 | + $msg = sprintf(__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), $current_route); |
|
| 154 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 155 | 155 | return FALSE; |
| 156 | 156 | } |
| 157 | 157 | // verify that result is an array |
| 158 | - if ( ! is_array( $module_method )) { |
|
| 159 | - $msg = sprintf( __( 'The %s route has not been properly registered.', 'event_espresso' ), $current_route ); |
|
| 160 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 158 | + if ( ! is_array($module_method)) { |
|
| 159 | + $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 160 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 161 | 161 | return FALSE; |
| 162 | 162 | } |
| 163 | 163 | // grab module name |
| 164 | 164 | $module_name = $module_method[0]; |
| 165 | 165 | // verify that a class method was registered properly |
| 166 | - if ( ! isset( $module_method[1] )) { |
|
| 167 | - $msg = sprintf( __( 'A class method for the %s route has not been properly registered.', 'event_espresso' ), $current_route ); |
|
| 168 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 166 | + if ( ! isset($module_method[1])) { |
|
| 167 | + $msg = sprintf(__('A class method for the %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 168 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 169 | 169 | return FALSE; |
| 170 | 170 | } |
| 171 | 171 | // grab method |
| 172 | 172 | $method = $module_method[1]; |
| 173 | 173 | // verify that class exists |
| 174 | - if ( ! class_exists( $module_name )) { |
|
| 175 | - $msg = sprintf( __( 'The requested %s class could not be found.', 'event_espresso' ), $module_name ); |
|
| 176 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 174 | + if ( ! class_exists($module_name)) { |
|
| 175 | + $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
| 176 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 177 | 177 | return FALSE; |
| 178 | 178 | } |
| 179 | 179 | // verify that method exists |
| 180 | - if ( ! method_exists( $module_name, $method )) { |
|
| 181 | - $msg = sprintf( __( 'The class method %s for the %s route is in invalid.', 'event_espresso' ), $method, $current_route ); |
|
| 182 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 180 | + if ( ! method_exists($module_name, $method)) { |
|
| 181 | + $msg = sprintf(__('The class method %s for the %s route is in invalid.', 'event_espresso'), $method, $current_route); |
|
| 182 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 183 | 183 | return FALSE; |
| 184 | 184 | } |
| 185 | 185 | // instantiate module and call route method |
| 186 | - return $this->_module_router( $module_name, $method ); |
|
| 186 | + return $this->_module_router($module_name, $method); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | * @param \EE_Response $response |
| 200 | 200 | * @return EED_Module | NULL |
| 201 | 201 | */ |
| 202 | - public static function module_factory( $module_name, \EE_Request $request, \EE_Response $response ) { |
|
| 203 | - if ( $module_name === 'EED_Module' ) { |
|
| 204 | - 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__ ); |
|
| 202 | + public static function module_factory($module_name, \EE_Request $request, \EE_Response $response) { |
|
| 203 | + if ($module_name === 'EED_Module') { |
|
| 204 | + 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__); |
|
| 205 | 205 | return NULL; |
| 206 | 206 | } |
| 207 | 207 | // ensure that class is actually a module |
| 208 | - if ( ! is_subclass_of( $module_name, 'EED_Module' )) { |
|
| 209 | - EE_Error::add_error( sprintf( __( 'The requested %s module is not of the class EED_Module.', 'event_espresso' ), $module_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 208 | + if ( ! is_subclass_of($module_name, 'EED_Module')) { |
|
| 209 | + EE_Error::add_error(sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), __FILE__, __FUNCTION__, __LINE__); |
|
| 210 | 210 | return NULL; |
| 211 | 211 | } |
| 212 | 212 | // instantiate and return module class |
| 213 | - return new $module_name( $request, $response ); |
|
| 213 | + return new $module_name($request, $response); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
@@ -224,14 +224,14 @@ discard block |
||
| 224 | 224 | * @param string $method |
| 225 | 225 | * @return EED_Module | NULL |
| 226 | 226 | */ |
| 227 | - private function _module_router( $module_name, $method ) { |
|
| 227 | + private function _module_router($module_name, $method) { |
|
| 228 | 228 | // instantiate module class |
| 229 | - $module = EE_Module_Request_Router::module_factory( $module_name, $this->request, $this->response ); |
|
| 230 | - if ( $module instanceof EED_Module ) { |
|
| 229 | + $module = EE_Module_Request_Router::module_factory($module_name, $this->request, $this->response); |
|
| 230 | + if ($module instanceof EED_Module) { |
|
| 231 | 231 | // and call whatever action the route was for |
| 232 | 232 | try { |
| 233 | - $module->{$method}( $this->WP_Query ); |
|
| 234 | - } catch ( EE_Error $e ) { |
|
| 233 | + $module->{$method}($this->WP_Query); |
|
| 234 | + } catch (EE_Error $e) { |
|
| 235 | 235 | $e->get_error(); |
| 236 | 236 | return NULL; |
| 237 | 237 | } |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param $current_route |
| 249 | 249 | * @return string |
| 250 | 250 | */ |
| 251 | - public function get_forward( $current_route ) { |
|
| 252 | - return EE_Config::get_forward( $current_route ); |
|
| 251 | + public function get_forward($current_route) { |
|
| 252 | + return EE_Config::get_forward($current_route); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
@@ -261,8 +261,8 @@ discard block |
||
| 261 | 261 | * @param $current_route |
| 262 | 262 | * @return string |
| 263 | 263 | */ |
| 264 | - public function get_view( $current_route ) { |
|
| 265 | - return EE_Config::get_view( $current_route ); |
|
| 264 | + public function get_view($current_route) { |
|
| 265 | + return EE_Config::get_view($current_route); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param $b |
| 273 | 273 | * @return bool |
| 274 | 274 | */ |
| 275 | - public function __set($a,$b) { return FALSE; } |
|
| 275 | + public function __set($a, $b) { return FALSE; } |
|
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | |