@@ -18,184 +18,184 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * |
|
| 23 | - * @var EE_Registration |
|
| 24 | - */ |
|
| 25 | - protected $_registration = null; |
|
| 21 | + /** |
|
| 22 | + * |
|
| 23 | + * @var EE_Registration |
|
| 24 | + */ |
|
| 25 | + protected $_registration = null; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * |
|
| 29 | - * @param EE_Registration $reg |
|
| 30 | - * @param array $options |
|
| 31 | - */ |
|
| 32 | - public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | - { |
|
| 34 | - $this->_registration = $reg; |
|
| 35 | - if (! isset($options['layout_strategy'])) { |
|
| 36 | - $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | - } |
|
| 38 | - if (! isset($options['html_id'])) { |
|
| 39 | - $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | - } |
|
| 41 | - $this->build_form_from_registration(); |
|
| 42 | - parent::__construct($options); |
|
| 43 | - } |
|
| 27 | + /** |
|
| 28 | + * |
|
| 29 | + * @param EE_Registration $reg |
|
| 30 | + * @param array $options |
|
| 31 | + */ |
|
| 32 | + public function __construct(EE_Registration $reg, $options = array()) |
|
| 33 | + { |
|
| 34 | + $this->_registration = $reg; |
|
| 35 | + if (! isset($options['layout_strategy'])) { |
|
| 36 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
| 37 | + } |
|
| 38 | + if (! isset($options['html_id'])) { |
|
| 39 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
| 40 | + } |
|
| 41 | + $this->build_form_from_registration(); |
|
| 42 | + parent::__construct($options); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Gets the registration object this form is about |
|
| 48 | - * @return EE_Registration |
|
| 49 | - */ |
|
| 50 | - public function get_registration() |
|
| 51 | - { |
|
| 52 | - return $this->_registration; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Gets the registration object this form is about |
|
| 48 | + * @return EE_Registration |
|
| 49 | + */ |
|
| 50 | + public function get_registration() |
|
| 51 | + { |
|
| 52 | + return $this->_registration; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @since $VID:$ |
|
| 57 | - * @throws EE_Error |
|
| 58 | - * @throws InvalidArgumentException |
|
| 59 | - * @throws ReflectionException |
|
| 60 | - * @throws InvalidDataTypeException |
|
| 61 | - * @throws InvalidInterfaceException |
|
| 62 | - */ |
|
| 63 | - public function build_form_from_registration() |
|
| 64 | - { |
|
| 65 | - $reg = $this->get_registration(); |
|
| 66 | - if (! $reg instanceof EE_Registration) { |
|
| 67 | - throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | - } |
|
| 69 | - // we want to get all their question groups |
|
| 70 | - $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | - [ |
|
| 72 | - [ |
|
| 73 | - 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | - 'OR' => [ |
|
| 75 | - 'Question.QST_system*blank' => '', |
|
| 76 | - 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | - ], |
|
| 78 | - 'Event_Question_Group.' |
|
| 79 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | - $reg->is_primary_registrant() |
|
| 81 | - ) => true |
|
| 82 | - ], |
|
| 83 | - 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | - ] |
|
| 85 | - ); |
|
| 86 | - // get each question groups questions |
|
| 87 | - foreach ($question_groups as $question_group) { |
|
| 88 | - if ($question_group instanceof EE_Question_Group) { |
|
| 89 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | - $question_group, |
|
| 91 | - $reg |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 55 | + /** |
|
| 56 | + * @since $VID:$ |
|
| 57 | + * @throws EE_Error |
|
| 58 | + * @throws InvalidArgumentException |
|
| 59 | + * @throws ReflectionException |
|
| 60 | + * @throws InvalidDataTypeException |
|
| 61 | + * @throws InvalidInterfaceException |
|
| 62 | + */ |
|
| 63 | + public function build_form_from_registration() |
|
| 64 | + { |
|
| 65 | + $reg = $this->get_registration(); |
|
| 66 | + if (! $reg instanceof EE_Registration) { |
|
| 67 | + throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
| 68 | + } |
|
| 69 | + // we want to get all their question groups |
|
| 70 | + $question_groups = EEM_Question_Group::instance()->get_all( |
|
| 71 | + [ |
|
| 72 | + [ |
|
| 73 | + 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
| 74 | + 'OR' => [ |
|
| 75 | + 'Question.QST_system*blank' => '', |
|
| 76 | + 'Question.QST_system*null' => ['IS_NULL'] |
|
| 77 | + ], |
|
| 78 | + 'Event_Question_Group.' |
|
| 79 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
| 80 | + $reg->is_primary_registrant() |
|
| 81 | + ) => true |
|
| 82 | + ], |
|
| 83 | + 'order_by' => ['QSG_order' => 'ASC'] |
|
| 84 | + ] |
|
| 85 | + ); |
|
| 86 | + // get each question groups questions |
|
| 87 | + foreach ($question_groups as $question_group) { |
|
| 88 | + if ($question_group instanceof EE_Question_Group) { |
|
| 89 | + $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 90 | + $question_group, |
|
| 91 | + $reg |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * |
|
| 101 | - * @param EE_Question_Group $question_group |
|
| 102 | - * @param EE_Registration $registration |
|
| 103 | - * @return \EE_Form_Section_Proper |
|
| 104 | - * @throws \EE_Error |
|
| 105 | - */ |
|
| 106 | - public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | - { |
|
| 108 | - if (! $question_group instanceof EE_Question_Group || |
|
| 109 | - ! $registration instanceof EE_Registration) { |
|
| 110 | - throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | - } |
|
| 112 | - $parts_of_subsection = array( |
|
| 113 | - 'title' => new EE_Form_Section_HTML( |
|
| 114 | - EEH_HTML::h5( |
|
| 115 | - $question_group->name(), |
|
| 116 | - $question_group->identifier(), |
|
| 117 | - 'espresso-question-group-title-h5 section-title' |
|
| 118 | - ) |
|
| 119 | - ) |
|
| 120 | - ); |
|
| 121 | - $questions = $question_group->questions( |
|
| 122 | - array( |
|
| 123 | - array( |
|
| 124 | - 'OR' => array( |
|
| 125 | - 'QST_system*blank' => '', |
|
| 126 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | - ) |
|
| 128 | - ) |
|
| 129 | - ) |
|
| 130 | - ); |
|
| 131 | - foreach ($questions as $question) { |
|
| 132 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | - } |
|
| 134 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | - 'ee_edit_registration', |
|
| 136 | - 'edit-reg-questions-mbox', |
|
| 137 | - $this->_registration->ID() |
|
| 138 | - )) { |
|
| 139 | - $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | - EEH_HTML::table( |
|
| 141 | - EEH_HTML::tr( |
|
| 142 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 99 | + /** |
|
| 100 | + * |
|
| 101 | + * @param EE_Question_Group $question_group |
|
| 102 | + * @param EE_Registration $registration |
|
| 103 | + * @return \EE_Form_Section_Proper |
|
| 104 | + * @throws \EE_Error |
|
| 105 | + */ |
|
| 106 | + public function build_subform_from_question_group($question_group, $registration) |
|
| 107 | + { |
|
| 108 | + if (! $question_group instanceof EE_Question_Group || |
|
| 109 | + ! $registration instanceof EE_Registration) { |
|
| 110 | + throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
| 111 | + } |
|
| 112 | + $parts_of_subsection = array( |
|
| 113 | + 'title' => new EE_Form_Section_HTML( |
|
| 114 | + EEH_HTML::h5( |
|
| 115 | + $question_group->name(), |
|
| 116 | + $question_group->identifier(), |
|
| 117 | + 'espresso-question-group-title-h5 section-title' |
|
| 118 | + ) |
|
| 119 | + ) |
|
| 120 | + ); |
|
| 121 | + $questions = $question_group->questions( |
|
| 122 | + array( |
|
| 123 | + array( |
|
| 124 | + 'OR' => array( |
|
| 125 | + 'QST_system*blank' => '', |
|
| 126 | + 'QST_system*null' => array( 'IS_NULL' ) |
|
| 127 | + ) |
|
| 128 | + ) |
|
| 129 | + ) |
|
| 130 | + ); |
|
| 131 | + foreach ($questions as $question) { |
|
| 132 | + $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 133 | + } |
|
| 134 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 135 | + 'ee_edit_registration', |
|
| 136 | + 'edit-reg-questions-mbox', |
|
| 137 | + $this->_registration->ID() |
|
| 138 | + )) { |
|
| 139 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
| 140 | + EEH_HTML::table( |
|
| 141 | + EEH_HTML::tr( |
|
| 142 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 143 | 143 | <span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span> |
| 144 | 144 | <div class="dashicons dashicons-edit"></div> |
| 145 | 145 | </a></td>' |
| 146 | - ) . |
|
| 147 | - EEH_HTML::no_row('', 2) |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - return new EE_Form_Section_Proper( |
|
| 152 | - array( |
|
| 153 | - 'subsections' => $parts_of_subsection, |
|
| 154 | - 'html_class' => 'question-group-questions', |
|
| 155 | - ) |
|
| 156 | - ); |
|
| 157 | - } |
|
| 146 | + ) . |
|
| 147 | + EEH_HTML::no_row('', 2) |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + return new EE_Form_Section_Proper( |
|
| 152 | + array( |
|
| 153 | + 'subsections' => $parts_of_subsection, |
|
| 154 | + 'html_class' => 'question-group-questions', |
|
| 155 | + ) |
|
| 156 | + ); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | - * from the answers in the DB |
|
| 162 | - * @param array $req_data like $_POST |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 165 | - protected function _normalize($req_data) |
|
| 166 | - { |
|
| 167 | - $this->_received_submission = true; |
|
| 168 | - $this->_validation_errors = array(); |
|
| 169 | - foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | - if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | - try { |
|
| 172 | - $subsection->_normalize($req_data); |
|
| 173 | - } catch (EE_Validation_Error $e) { |
|
| 174 | - $subsection->add_validation_error($e); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - } |
|
| 159 | + /** |
|
| 160 | + * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
| 161 | + * from the answers in the DB |
|
| 162 | + * @param array $req_data like $_POST |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | + protected function _normalize($req_data) |
|
| 166 | + { |
|
| 167 | + $this->_received_submission = true; |
|
| 168 | + $this->_validation_errors = array(); |
|
| 169 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 170 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 171 | + try { |
|
| 172 | + $subsection->_normalize($req_data); |
|
| 173 | + } catch (EE_Validation_Error $e) { |
|
| 174 | + $subsection->add_validation_error($e); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | - * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | - * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | - * calling parent::_validate() first. |
|
| 187 | - */ |
|
| 188 | - protected function _validate() |
|
| 189 | - { |
|
| 190 | - foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | - if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | - if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | - } |
|
| 195 | - $subsection->_validate(); |
|
| 196 | - } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | - $subsection->_received_submission = true; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 182 | + /** |
|
| 183 | + * Performs validation on this form section and its subsections. For each subsection, |
|
| 184 | + * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection. |
|
| 185 | + * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method, |
|
| 186 | + * calling parent::_validate() first. |
|
| 187 | + */ |
|
| 188 | + protected function _validate() |
|
| 189 | + { |
|
| 190 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 191 | + if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
|
| 192 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 193 | + call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 194 | + } |
|
| 195 | + $subsection->_validate(); |
|
| 196 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 197 | + $subsection->_received_submission = true; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | } |
@@ -32,10 +32,10 @@ discard block |
||
| 32 | 32 | public function __construct(EE_Registration $reg, $options = array()) |
| 33 | 33 | { |
| 34 | 34 | $this->_registration = $reg; |
| 35 | - if (! isset($options['layout_strategy'])) { |
|
| 35 | + if ( ! isset($options['layout_strategy'])) { |
|
| 36 | 36 | $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
| 37 | 37 | } |
| 38 | - if (! isset($options['html_id'])) { |
|
| 38 | + if ( ! isset($options['html_id'])) { |
|
| 39 | 39 | $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
| 40 | 40 | } |
| 41 | 41 | $this->build_form_from_registration(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function build_form_from_registration() |
| 64 | 64 | { |
| 65 | 65 | $reg = $this->get_registration(); |
| 66 | - if (! $reg instanceof EE_Registration) { |
|
| 66 | + if ( ! $reg instanceof EE_Registration) { |
|
| 67 | 67 | throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
| 68 | 68 | } |
| 69 | 69 | // we want to get all their question groups |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // get each question groups questions |
| 87 | 87 | foreach ($question_groups as $question_group) { |
| 88 | 88 | if ($question_group instanceof EE_Question_Group) { |
| 89 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
| 89 | + $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group( |
|
| 90 | 90 | $question_group, |
| 91 | 91 | $reg |
| 92 | 92 | ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function build_subform_from_question_group($question_group, $registration) |
| 107 | 107 | { |
| 108 | - if (! $question_group instanceof EE_Question_Group || |
|
| 108 | + if ( ! $question_group instanceof EE_Question_Group || |
|
| 109 | 109 | ! $registration instanceof EE_Registration) { |
| 110 | 110 | throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
| 111 | 111 | } |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | array( |
| 124 | 124 | 'OR' => array( |
| 125 | 125 | 'QST_system*blank' => '', |
| 126 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
| 126 | + 'QST_system*null' => array('IS_NULL') |
|
| 127 | 127 | ) |
| 128 | 128 | ) |
| 129 | 129 | ) |
| 130 | 130 | ); |
| 131 | 131 | foreach ($questions as $question) { |
| 132 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
| 132 | + $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration); |
|
| 133 | 133 | } |
| 134 | 134 | if (EE_Registry::instance()->CAP->current_user_can( |
| 135 | 135 | 'ee_edit_registration', |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
| 140 | 140 | EEH_HTML::table( |
| 141 | 141 | EEH_HTML::tr( |
| 142 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
| 143 | - <span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span> |
|
| 142 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'"> |
|
| 143 | + <span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso').'</span> |
|
| 144 | 144 | <div class="dashicons dashicons-edit"></div> |
| 145 | 145 | </a></td>' |
| 146 | - ) . |
|
| 146 | + ). |
|
| 147 | 147 | EEH_HTML::no_row('', 2) |
| 148 | 148 | ) |
| 149 | 149 | ); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
| 191 | 191 | if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) { |
| 192 | 192 | if (method_exists($this, '_validate_'.$subsection_name)) { |
| 193 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 193 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
| 194 | 194 | } |
| 195 | 195 | $subsection->_validate(); |
| 196 | 196 | } elseif ($subsection instanceof EE_Form_Section_Proper) { |
@@ -38,103 +38,103 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - '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.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + '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.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
| 65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - '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.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + '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.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.0.rc.002'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.0.rc.002'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | - bootstrap_espresso(); |
|
| 121 | - } |
|
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
| 120 | + bootstrap_espresso(); |
|
| 121 | + } |
|
| 122 | 122 | } |
| 123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
| 124 | - /** |
|
| 125 | - * deactivate_plugin |
|
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | - * |
|
| 128 | - * @access public |
|
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | - { |
|
| 134 | - if (! function_exists('deactivate_plugins')) { |
|
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | - } |
|
| 137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | - deactivate_plugins($plugin_basename); |
|
| 139 | - } |
|
| 124 | + /** |
|
| 125 | + * deactivate_plugin |
|
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 127 | + * |
|
| 128 | + * @access public |
|
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 133 | + { |
|
| 134 | + if (! function_exists('deactivate_plugins')) { |
|
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 136 | + } |
|
| 137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 138 | + deactivate_plugins($plugin_basename); |
|
| 139 | + } |
|
| 140 | 140 | } |