@@ -11,209 +11,209 @@ |
||
| 11 | 11 | class EEM_Country extends EEM_Base |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - // private instance of the Attendee object |
|
| 15 | - protected static $_instance = null; |
|
| 16 | - |
|
| 17 | - // array of all countries |
|
| 18 | - private static $_all_countries = false; |
|
| 19 | - |
|
| 20 | - // array of all active countries |
|
| 21 | - private static $_active_countries = false; |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Resets the country |
|
| 26 | - * |
|
| 27 | - * @param string $timezone |
|
| 28 | - * @return EEM_Country|EEM_Base|null |
|
| 29 | - * @throws EE_Error |
|
| 30 | - * @throws ReflectionException |
|
| 31 | - */ |
|
| 32 | - public static function reset($timezone = null) |
|
| 33 | - { |
|
| 34 | - self::$_active_countries = null; |
|
| 35 | - self::$_all_countries = null; |
|
| 36 | - return parent::reset($timezone); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - protected function __construct(?string $timezone = '') |
|
| 41 | - { |
|
| 42 | - $this->singular_item = esc_html__('Country', 'event_espresso'); |
|
| 43 | - $this->plural_item = esc_html__('Countries', 'event_espresso'); |
|
| 44 | - |
|
| 45 | - $this->_tables = [ |
|
| 46 | - 'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'), |
|
| 47 | - ]; |
|
| 48 | - |
|
| 49 | - $this->_fields = [ |
|
| 50 | - 'Country' => [ |
|
| 51 | - 'CNT_active' => new EE_Boolean_Field( |
|
| 52 | - 'CNT_active', |
|
| 53 | - esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), |
|
| 54 | - false, |
|
| 55 | - true |
|
| 56 | - ), |
|
| 57 | - 'CNT_ISO' => new EE_Primary_Key_String_Field( |
|
| 58 | - 'CNT_ISO', |
|
| 59 | - esc_html__('Country ISO Code', 'event_espresso') |
|
| 60 | - ), |
|
| 61 | - 'CNT_ISO3' => new EE_All_Caps_Text_Field( |
|
| 62 | - 'CNT_ISO3', |
|
| 63 | - esc_html__('Country ISO3 Code', 'event_espresso'), |
|
| 64 | - false, |
|
| 65 | - '' |
|
| 66 | - ), |
|
| 67 | - 'RGN_ID' => new EE_Integer_Field( |
|
| 68 | - 'RGN_ID', |
|
| 69 | - esc_html__('Region ID', 'event_espresso'), |
|
| 70 | - false, |
|
| 71 | - 0 |
|
| 72 | - ), |
|
| 73 | - // should be a foreign key, but no region table exists yet |
|
| 74 | - 'CNT_name' => new EE_Plain_Text_Field( |
|
| 75 | - 'CNT_name', |
|
| 76 | - esc_html__('Country Name', 'event_espresso'), |
|
| 77 | - false, |
|
| 78 | - '' |
|
| 79 | - ), |
|
| 80 | - 'CNT_cur_code' => new EE_All_Caps_Text_Field( |
|
| 81 | - 'CNT_cur_code', |
|
| 82 | - esc_html__('Country Currency Code', 'event_espresso'), |
|
| 83 | - false |
|
| 84 | - ), |
|
| 85 | - 'CNT_cur_single' => new EE_Plain_Text_Field( |
|
| 86 | - 'CNT_cur_single', |
|
| 87 | - esc_html__('Currency Name Singular', 'event_espresso'), |
|
| 88 | - false |
|
| 89 | - ), |
|
| 90 | - 'CNT_cur_plural' => new EE_Plain_Text_Field( |
|
| 91 | - 'CNT_cur_plural', |
|
| 92 | - esc_html__('Currency Name Plural', 'event_espresso'), |
|
| 93 | - false |
|
| 94 | - ), |
|
| 95 | - 'CNT_cur_sign' => new EE_Plain_Text_Field( |
|
| 96 | - 'CNT_cur_sign', |
|
| 97 | - esc_html__('Currency Sign', 'event_espresso'), |
|
| 98 | - false |
|
| 99 | - ), |
|
| 100 | - 'CNT_cur_sign_b4' => new EE_Boolean_Field( |
|
| 101 | - 'CNT_cur_sign_b4', |
|
| 102 | - esc_html__('Currency Sign Before Number', 'event_espresso'), |
|
| 103 | - false, |
|
| 104 | - true |
|
| 105 | - ), |
|
| 106 | - 'CNT_cur_dec_plc' => new EE_Integer_Field( |
|
| 107 | - 'CNT_cur_dec_plc', |
|
| 108 | - esc_html__('Currency Decimal Places', 'event_espresso'), |
|
| 109 | - false, |
|
| 110 | - 2 |
|
| 111 | - ), |
|
| 112 | - 'CNT_cur_dec_mrk' => new EE_Plain_Text_Field( |
|
| 113 | - 'CNT_cur_dec_mrk', |
|
| 114 | - esc_html__('Currency Decimal Mark', 'event_espresso'), |
|
| 115 | - false, |
|
| 116 | - '.' |
|
| 117 | - ), |
|
| 118 | - 'CNT_cur_thsnds' => new EE_Plain_Text_Field( |
|
| 119 | - 'CNT_cur_thsnds', |
|
| 120 | - esc_html__('Currency Thousands Separator', 'event_espresso'), |
|
| 121 | - false, |
|
| 122 | - ',' |
|
| 123 | - ), |
|
| 124 | - 'CNT_tel_code' => new EE_Plain_Text_Field( |
|
| 125 | - 'CNT_tel_code', |
|
| 126 | - esc_html__('Country Telephone Code', 'event_espresso'), |
|
| 127 | - false, |
|
| 128 | - '' |
|
| 129 | - ), |
|
| 130 | - 'CNT_is_EU' => new EE_Boolean_Field( |
|
| 131 | - 'CNT_is_EU', |
|
| 132 | - esc_html__('Country is Member of EU', 'event_espresso'), |
|
| 133 | - false, |
|
| 134 | - false |
|
| 135 | - ), |
|
| 136 | - ], |
|
| 137 | - ]; |
|
| 138 | - $this->_model_relations = [ |
|
| 139 | - 'Attendee' => new EE_Has_Many_Relation(), |
|
| 140 | - 'State' => new EE_Has_Many_Relation(), |
|
| 141 | - 'Venue' => new EE_Has_Many_Relation(), |
|
| 142 | - ]; |
|
| 143 | - // only anyone to view, but only those with the default role can do anything |
|
| 144 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 145 | - |
|
| 146 | - parent::__construct($timezone); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * @return EE_Country[] |
|
| 152 | - * @throws EE_Error |
|
| 153 | - */ |
|
| 154 | - public function get_all_countries(): array |
|
| 155 | - { |
|
| 156 | - if (! self::$_all_countries) { |
|
| 157 | - self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
|
| 158 | - } |
|
| 159 | - return self::$_all_countries; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Gets and caches the list of active countries. If you know the list of active countries |
|
| 165 | - * has changed during this request, first use EEM_Country::reset() to flush the cache |
|
| 166 | - * |
|
| 167 | - * @return EE_Country[] |
|
| 168 | - * @throws EE_Error |
|
| 169 | - */ |
|
| 170 | - public function get_all_active_countries(): array |
|
| 171 | - { |
|
| 172 | - if (! self::$_active_countries) { |
|
| 173 | - self::$_active_countries = |
|
| 174 | - $this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
|
| 175 | - } |
|
| 176 | - return self::$_active_countries; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * Gets the country's name by its ISO |
|
| 182 | - * |
|
| 183 | - * @param string $country_ISO |
|
| 184 | - * @return string |
|
| 185 | - * @throws EE_Error |
|
| 186 | - */ |
|
| 187 | - public function get_country_name_by_ISO(string $country_ISO): string |
|
| 188 | - { |
|
| 189 | - $countries = $this->get_all_countries(); |
|
| 190 | - if (isset($countries[ $country_ISO ]) && $countries[ $country_ISO ] instanceof EE_Country) { |
|
| 191 | - return $countries[ $country_ISO ]->name(); |
|
| 192 | - } |
|
| 193 | - $names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name'); |
|
| 194 | - if (is_array($names) && ! empty($names)) { |
|
| 195 | - return reset($names); |
|
| 196 | - } else { |
|
| 197 | - return ''; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Gets the country's name by its name |
|
| 204 | - * |
|
| 205 | - * @param string $country_name |
|
| 206 | - * @return EE_Country|null |
|
| 207 | - * @throws EE_Error |
|
| 208 | - */ |
|
| 209 | - public function getCountryByName(string $country_name): ?EE_Country |
|
| 210 | - { |
|
| 211 | - $countries = $this->get_all_countries(); |
|
| 212 | - foreach ($countries as $country) { |
|
| 213 | - if ($country instanceof EE_Country && $country->name() === $country_name) { |
|
| 214 | - return $country; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - return $this->get_one([['CNT_name' => $country_name]]); |
|
| 218 | - } |
|
| 14 | + // private instance of the Attendee object |
|
| 15 | + protected static $_instance = null; |
|
| 16 | + |
|
| 17 | + // array of all countries |
|
| 18 | + private static $_all_countries = false; |
|
| 19 | + |
|
| 20 | + // array of all active countries |
|
| 21 | + private static $_active_countries = false; |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Resets the country |
|
| 26 | + * |
|
| 27 | + * @param string $timezone |
|
| 28 | + * @return EEM_Country|EEM_Base|null |
|
| 29 | + * @throws EE_Error |
|
| 30 | + * @throws ReflectionException |
|
| 31 | + */ |
|
| 32 | + public static function reset($timezone = null) |
|
| 33 | + { |
|
| 34 | + self::$_active_countries = null; |
|
| 35 | + self::$_all_countries = null; |
|
| 36 | + return parent::reset($timezone); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + protected function __construct(?string $timezone = '') |
|
| 41 | + { |
|
| 42 | + $this->singular_item = esc_html__('Country', 'event_espresso'); |
|
| 43 | + $this->plural_item = esc_html__('Countries', 'event_espresso'); |
|
| 44 | + |
|
| 45 | + $this->_tables = [ |
|
| 46 | + 'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'), |
|
| 47 | + ]; |
|
| 48 | + |
|
| 49 | + $this->_fields = [ |
|
| 50 | + 'Country' => [ |
|
| 51 | + 'CNT_active' => new EE_Boolean_Field( |
|
| 52 | + 'CNT_active', |
|
| 53 | + esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), |
|
| 54 | + false, |
|
| 55 | + true |
|
| 56 | + ), |
|
| 57 | + 'CNT_ISO' => new EE_Primary_Key_String_Field( |
|
| 58 | + 'CNT_ISO', |
|
| 59 | + esc_html__('Country ISO Code', 'event_espresso') |
|
| 60 | + ), |
|
| 61 | + 'CNT_ISO3' => new EE_All_Caps_Text_Field( |
|
| 62 | + 'CNT_ISO3', |
|
| 63 | + esc_html__('Country ISO3 Code', 'event_espresso'), |
|
| 64 | + false, |
|
| 65 | + '' |
|
| 66 | + ), |
|
| 67 | + 'RGN_ID' => new EE_Integer_Field( |
|
| 68 | + 'RGN_ID', |
|
| 69 | + esc_html__('Region ID', 'event_espresso'), |
|
| 70 | + false, |
|
| 71 | + 0 |
|
| 72 | + ), |
|
| 73 | + // should be a foreign key, but no region table exists yet |
|
| 74 | + 'CNT_name' => new EE_Plain_Text_Field( |
|
| 75 | + 'CNT_name', |
|
| 76 | + esc_html__('Country Name', 'event_espresso'), |
|
| 77 | + false, |
|
| 78 | + '' |
|
| 79 | + ), |
|
| 80 | + 'CNT_cur_code' => new EE_All_Caps_Text_Field( |
|
| 81 | + 'CNT_cur_code', |
|
| 82 | + esc_html__('Country Currency Code', 'event_espresso'), |
|
| 83 | + false |
|
| 84 | + ), |
|
| 85 | + 'CNT_cur_single' => new EE_Plain_Text_Field( |
|
| 86 | + 'CNT_cur_single', |
|
| 87 | + esc_html__('Currency Name Singular', 'event_espresso'), |
|
| 88 | + false |
|
| 89 | + ), |
|
| 90 | + 'CNT_cur_plural' => new EE_Plain_Text_Field( |
|
| 91 | + 'CNT_cur_plural', |
|
| 92 | + esc_html__('Currency Name Plural', 'event_espresso'), |
|
| 93 | + false |
|
| 94 | + ), |
|
| 95 | + 'CNT_cur_sign' => new EE_Plain_Text_Field( |
|
| 96 | + 'CNT_cur_sign', |
|
| 97 | + esc_html__('Currency Sign', 'event_espresso'), |
|
| 98 | + false |
|
| 99 | + ), |
|
| 100 | + 'CNT_cur_sign_b4' => new EE_Boolean_Field( |
|
| 101 | + 'CNT_cur_sign_b4', |
|
| 102 | + esc_html__('Currency Sign Before Number', 'event_espresso'), |
|
| 103 | + false, |
|
| 104 | + true |
|
| 105 | + ), |
|
| 106 | + 'CNT_cur_dec_plc' => new EE_Integer_Field( |
|
| 107 | + 'CNT_cur_dec_plc', |
|
| 108 | + esc_html__('Currency Decimal Places', 'event_espresso'), |
|
| 109 | + false, |
|
| 110 | + 2 |
|
| 111 | + ), |
|
| 112 | + 'CNT_cur_dec_mrk' => new EE_Plain_Text_Field( |
|
| 113 | + 'CNT_cur_dec_mrk', |
|
| 114 | + esc_html__('Currency Decimal Mark', 'event_espresso'), |
|
| 115 | + false, |
|
| 116 | + '.' |
|
| 117 | + ), |
|
| 118 | + 'CNT_cur_thsnds' => new EE_Plain_Text_Field( |
|
| 119 | + 'CNT_cur_thsnds', |
|
| 120 | + esc_html__('Currency Thousands Separator', 'event_espresso'), |
|
| 121 | + false, |
|
| 122 | + ',' |
|
| 123 | + ), |
|
| 124 | + 'CNT_tel_code' => new EE_Plain_Text_Field( |
|
| 125 | + 'CNT_tel_code', |
|
| 126 | + esc_html__('Country Telephone Code', 'event_espresso'), |
|
| 127 | + false, |
|
| 128 | + '' |
|
| 129 | + ), |
|
| 130 | + 'CNT_is_EU' => new EE_Boolean_Field( |
|
| 131 | + 'CNT_is_EU', |
|
| 132 | + esc_html__('Country is Member of EU', 'event_espresso'), |
|
| 133 | + false, |
|
| 134 | + false |
|
| 135 | + ), |
|
| 136 | + ], |
|
| 137 | + ]; |
|
| 138 | + $this->_model_relations = [ |
|
| 139 | + 'Attendee' => new EE_Has_Many_Relation(), |
|
| 140 | + 'State' => new EE_Has_Many_Relation(), |
|
| 141 | + 'Venue' => new EE_Has_Many_Relation(), |
|
| 142 | + ]; |
|
| 143 | + // only anyone to view, but only those with the default role can do anything |
|
| 144 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 145 | + |
|
| 146 | + parent::__construct($timezone); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @return EE_Country[] |
|
| 152 | + * @throws EE_Error |
|
| 153 | + */ |
|
| 154 | + public function get_all_countries(): array |
|
| 155 | + { |
|
| 156 | + if (! self::$_all_countries) { |
|
| 157 | + self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
|
| 158 | + } |
|
| 159 | + return self::$_all_countries; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Gets and caches the list of active countries. If you know the list of active countries |
|
| 165 | + * has changed during this request, first use EEM_Country::reset() to flush the cache |
|
| 166 | + * |
|
| 167 | + * @return EE_Country[] |
|
| 168 | + * @throws EE_Error |
|
| 169 | + */ |
|
| 170 | + public function get_all_active_countries(): array |
|
| 171 | + { |
|
| 172 | + if (! self::$_active_countries) { |
|
| 173 | + self::$_active_countries = |
|
| 174 | + $this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
|
| 175 | + } |
|
| 176 | + return self::$_active_countries; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * Gets the country's name by its ISO |
|
| 182 | + * |
|
| 183 | + * @param string $country_ISO |
|
| 184 | + * @return string |
|
| 185 | + * @throws EE_Error |
|
| 186 | + */ |
|
| 187 | + public function get_country_name_by_ISO(string $country_ISO): string |
|
| 188 | + { |
|
| 189 | + $countries = $this->get_all_countries(); |
|
| 190 | + if (isset($countries[ $country_ISO ]) && $countries[ $country_ISO ] instanceof EE_Country) { |
|
| 191 | + return $countries[ $country_ISO ]->name(); |
|
| 192 | + } |
|
| 193 | + $names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name'); |
|
| 194 | + if (is_array($names) && ! empty($names)) { |
|
| 195 | + return reset($names); |
|
| 196 | + } else { |
|
| 197 | + return ''; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Gets the country's name by its name |
|
| 204 | + * |
|
| 205 | + * @param string $country_name |
|
| 206 | + * @return EE_Country|null |
|
| 207 | + * @throws EE_Error |
|
| 208 | + */ |
|
| 209 | + public function getCountryByName(string $country_name): ?EE_Country |
|
| 210 | + { |
|
| 211 | + $countries = $this->get_all_countries(); |
|
| 212 | + foreach ($countries as $country) { |
|
| 213 | + if ($country instanceof EE_Country && $country->name() === $country_name) { |
|
| 214 | + return $country; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + return $this->get_one([['CNT_name' => $country_name]]); |
|
| 218 | + } |
|
| 219 | 219 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'), |
| 47 | 47 | ]; |
| 48 | 48 | |
| 49 | - $this->_fields = [ |
|
| 49 | + $this->_fields = [ |
|
| 50 | 50 | 'Country' => [ |
| 51 | 51 | 'CNT_active' => new EE_Boolean_Field( |
| 52 | 52 | 'CNT_active', |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | 'Venue' => new EE_Has_Many_Relation(), |
| 142 | 142 | ]; |
| 143 | 143 | // only anyone to view, but only those with the default role can do anything |
| 144 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 144 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
| 145 | 145 | |
| 146 | 146 | parent::__construct($timezone); |
| 147 | 147 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | */ |
| 154 | 154 | public function get_all_countries(): array |
| 155 | 155 | { |
| 156 | - if (! self::$_all_countries) { |
|
| 156 | + if ( ! self::$_all_countries) { |
|
| 157 | 157 | self::$_all_countries = $this->get_all(['order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
| 158 | 158 | } |
| 159 | 159 | return self::$_all_countries; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function get_all_active_countries(): array |
| 171 | 171 | { |
| 172 | - if (! self::$_active_countries) { |
|
| 172 | + if ( ! self::$_active_countries) { |
|
| 173 | 173 | self::$_active_countries = |
| 174 | 174 | $this->get_all([['CNT_active' => true], 'order_by' => ['CNT_name' => 'ASC'], 'limit' => [0, 99999]]); |
| 175 | 175 | } |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | public function get_country_name_by_ISO(string $country_ISO): string |
| 188 | 188 | { |
| 189 | 189 | $countries = $this->get_all_countries(); |
| 190 | - if (isset($countries[ $country_ISO ]) && $countries[ $country_ISO ] instanceof EE_Country) { |
|
| 191 | - return $countries[ $country_ISO ]->name(); |
|
| 190 | + if (isset($countries[$country_ISO]) && $countries[$country_ISO] instanceof EE_Country) { |
|
| 191 | + return $countries[$country_ISO]->name(); |
|
| 192 | 192 | } |
| 193 | 193 | $names = $this->get_col([['CNT_ISO' => $country_ISO], 'limit' => 1], 'CNT_name'); |
| 194 | 194 | if (is_array($names) && ! empty($names)) { |
@@ -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.6.2'); |
|
| 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.6.2'); |
|
| 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.20.rc.001'); |
|
| 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.20.rc.001'); |
|
| 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 | } |