@@ -17,7 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * @param string $value_to_normalize |
| 20 | - * @return int|mixed|string |
|
| 20 | + * @return null|integer |
|
| 21 | 21 | * @throws \EE_Validation_Error |
| 22 | 22 | */ |
| 23 | 23 | public function normalize($value_to_normalize) |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
| 37 | - return (int)$value_to_normalize; |
|
| 37 | + return (int) $value_to_normalize; |
|
| 38 | 38 | } |
| 39 | - if (! is_string($value_to_normalize)) { |
|
| 39 | + if ( ! is_string($value_to_normalize)) { |
|
| 40 | 40 | throw new EE_Validation_Error( |
| 41 | 41 | sprintf( |
| 42 | 42 | __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | // if first match is the negative sign, |
| 60 | 60 | // then the number needs to be multiplied by -1 to remain negative |
| 61 | 61 | return $matches[1] === '-' |
| 62 | - ? (int)$matches[2] * -1 |
|
| 63 | - : (int)$matches[2]; |
|
| 62 | + ? (int) $matches[2] * -1 |
|
| 63 | + : (int) $matches[2]; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | //find if this input has a int validation strategy |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | //this really shouldn't ever happen because fields with a int normalization strategy |
| 75 | 75 | //should also have a int validation strategy, but in case it doesn't use the default |
| 76 | - if (! $validation_error_message) { |
|
| 76 | + if ( ! $validation_error_message) { |
|
| 77 | 77 | $default_validation_strategy = new EE_Int_Validation_Strategy(); |
| 78 | 78 | $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
| 79 | 79 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -15,89 +15,89 @@ discard block |
||
| 15 | 15 | class EE_Int_Normalization extends EE_Normalization_Strategy_Base |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /* |
|
| 18 | + /* |
|
| 19 | 19 | * regex pattern that matches for the following: |
| 20 | 20 | * * optional negative sign |
| 21 | 21 | * * one or more digits |
| 22 | 22 | */ |
| 23 | - const REGEX = '/^(-?)(\d+)(?:\.0+)?$/'; |
|
| 23 | + const REGEX = '/^(-?)(\d+)(?:\.0+)?$/'; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @param string $value_to_normalize |
|
| 29 | - * @return int|mixed|string |
|
| 30 | - * @throws \EE_Validation_Error |
|
| 31 | - */ |
|
| 32 | - public function normalize($value_to_normalize) |
|
| 33 | - { |
|
| 34 | - if ($value_to_normalize === null) { |
|
| 35 | - return null; |
|
| 36 | - } |
|
| 37 | - if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
| 38 | - return (int)$value_to_normalize; |
|
| 39 | - } |
|
| 40 | - if (! is_string($value_to_normalize)) { |
|
| 41 | - throw new EE_Validation_Error( |
|
| 42 | - sprintf( |
|
| 43 | - __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
| 44 | - print_r($value_to_normalize, true), |
|
| 45 | - gettype($value_to_normalize) |
|
| 46 | - ) |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - $value_to_normalize = filter_var( |
|
| 50 | - $value_to_normalize, |
|
| 51 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 52 | - FILTER_FLAG_ALLOW_FRACTION |
|
| 53 | - ); |
|
| 54 | - if ($value_to_normalize === '') { |
|
| 55 | - return null; |
|
| 56 | - } |
|
| 57 | - $matches = array(); |
|
| 58 | - if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) { |
|
| 59 | - if (count($matches) === 3) { |
|
| 60 | - // if first match is the negative sign, |
|
| 61 | - // then the number needs to be multiplied by -1 to remain negative |
|
| 62 | - return $matches[1] === '-' |
|
| 63 | - ? (int)$matches[2] * -1 |
|
| 64 | - : (int)$matches[2]; |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - //find if this input has a int validation strategy |
|
| 68 | - //in which case, use its message |
|
| 69 | - $validation_error_message = null; |
|
| 70 | - foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 71 | - if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
| 72 | - $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - //this really shouldn't ever happen because fields with a int normalization strategy |
|
| 76 | - //should also have a int validation strategy, but in case it doesn't use the default |
|
| 77 | - if (! $validation_error_message) { |
|
| 78 | - $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
| 79 | - $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
| 80 | - } |
|
| 81 | - throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
| 82 | - } |
|
| 27 | + /** |
|
| 28 | + * @param string $value_to_normalize |
|
| 29 | + * @return int|mixed|string |
|
| 30 | + * @throws \EE_Validation_Error |
|
| 31 | + */ |
|
| 32 | + public function normalize($value_to_normalize) |
|
| 33 | + { |
|
| 34 | + if ($value_to_normalize === null) { |
|
| 35 | + return null; |
|
| 36 | + } |
|
| 37 | + if (is_int($value_to_normalize) || is_float($value_to_normalize)) { |
|
| 38 | + return (int)$value_to_normalize; |
|
| 39 | + } |
|
| 40 | + if (! is_string($value_to_normalize)) { |
|
| 41 | + throw new EE_Validation_Error( |
|
| 42 | + sprintf( |
|
| 43 | + __('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), |
|
| 44 | + print_r($value_to_normalize, true), |
|
| 45 | + gettype($value_to_normalize) |
|
| 46 | + ) |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + $value_to_normalize = filter_var( |
|
| 50 | + $value_to_normalize, |
|
| 51 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 52 | + FILTER_FLAG_ALLOW_FRACTION |
|
| 53 | + ); |
|
| 54 | + if ($value_to_normalize === '') { |
|
| 55 | + return null; |
|
| 56 | + } |
|
| 57 | + $matches = array(); |
|
| 58 | + if (preg_match(EE_Int_Normalization::REGEX, $value_to_normalize, $matches)) { |
|
| 59 | + if (count($matches) === 3) { |
|
| 60 | + // if first match is the negative sign, |
|
| 61 | + // then the number needs to be multiplied by -1 to remain negative |
|
| 62 | + return $matches[1] === '-' |
|
| 63 | + ? (int)$matches[2] * -1 |
|
| 64 | + : (int)$matches[2]; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + //find if this input has a int validation strategy |
|
| 68 | + //in which case, use its message |
|
| 69 | + $validation_error_message = null; |
|
| 70 | + foreach ($this->_input->get_validation_strategies() as $validation_strategy) { |
|
| 71 | + if ($validation_strategy instanceof EE_Int_Validation_Strategy) { |
|
| 72 | + $validation_error_message = $validation_strategy->get_validation_error_message(); |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + //this really shouldn't ever happen because fields with a int normalization strategy |
|
| 76 | + //should also have a int validation strategy, but in case it doesn't use the default |
|
| 77 | + if (! $validation_error_message) { |
|
| 78 | + $default_validation_strategy = new EE_Int_Validation_Strategy(); |
|
| 79 | + $validation_error_message = $default_validation_strategy->get_validation_error_message(); |
|
| 80 | + } |
|
| 81 | + throw new EE_Validation_Error($validation_error_message, 'numeric_only'); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Converts the int into a string for use in teh html form |
|
| 88 | - * |
|
| 89 | - * @param int $normalized_value |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - public function unnormalize($normalized_value) |
|
| 93 | - { |
|
| 94 | - if ($normalized_value === null || $normalized_value === '') { |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 97 | - if (empty($normalized_value)) { |
|
| 98 | - return '0'; |
|
| 99 | - } |
|
| 100 | - return "$normalized_value"; |
|
| 101 | - } |
|
| 86 | + /** |
|
| 87 | + * Converts the int into a string for use in teh html form |
|
| 88 | + * |
|
| 89 | + * @param int $normalized_value |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + public function unnormalize($normalized_value) |
|
| 93 | + { |
|
| 94 | + if ($normalized_value === null || $normalized_value === '') { |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | + if (empty($normalized_value)) { |
|
| 98 | + return '0'; |
|
| 99 | + } |
|
| 100 | + return "$normalized_value"; |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | // End of file EE_Int_Normalization.strategy.php |
@@ -33,14 +33,14 @@ |
||
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | 35 | function get_jquery_validation_rule_array(){ |
| 36 | - return array( |
|
| 37 | - 'number'=>true, |
|
| 38 | - 'step' => 1, |
|
| 39 | - 'messages' => array( |
|
| 40 | - 'number' => $this->get_validation_error_message(), |
|
| 41 | - 'step' => $this->get_validation_error_message() |
|
| 42 | - ) |
|
| 43 | - ); |
|
| 36 | + return array( |
|
| 37 | + 'number'=>true, |
|
| 38 | + 'step' => 1, |
|
| 39 | + 'messages' => array( |
|
| 40 | + 'number' => $this->get_validation_error_message(), |
|
| 41 | + 'step' => $this->get_validation_error_message() |
|
| 42 | + ) |
|
| 43 | + ); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | * @subpackage Expression package is undefined on line 19, column 19 in Templates/Scripting/PHPClass.php. |
| 7 | 7 | * @author Mike Nelson |
| 8 | 8 | */ |
| 9 | -class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 9 | +class EE_Int_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @param null $validation_error_message |
| 13 | 13 | */ |
| 14 | - public function __construct( $validation_error_message = NULL ) { |
|
| 15 | - if( ! $validation_error_message ){ |
|
| 14 | + public function __construct($validation_error_message = NULL) { |
|
| 15 | + if ( ! $validation_error_message) { |
|
| 16 | 16 | $validation_error_message = __("Only digits are allowed.", "event_espresso"); |
| 17 | 17 | } |
| 18 | - parent::__construct( $validation_error_message ); |
|
| 18 | + parent::__construct($validation_error_message); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | - function get_jquery_validation_rule_array(){ |
|
| 35 | + function get_jquery_validation_rule_array() { |
|
| 36 | 36 | return array( |
| 37 | 37 | 'number'=>true, |
| 38 | 38 | 'step' => 1, |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * ------------------------------------------------------------------------ |
| 22 | 22 | */ |
| 23 | -class EEH_Money extends EEH_Base { |
|
| 23 | +class EEH_Money extends EEH_Base { |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @return float |
| 62 | 62 | * @throws EE_Error |
| 63 | 63 | */ |
| 64 | - public static function convert_to_float_from_localized_money($money_value ) { |
|
| 64 | + public static function convert_to_float_from_localized_money($money_value) { |
|
| 65 | 65 | //float it! and round to three decimal places |
| 66 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
| 66 | + return round((float) EEH_Money::strip_localized_money_formatting($money_value), 3); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | * @throws EE_Error |
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | - public static function compare_floats( $float1, $float2, $operator='=' ) { |
|
| 85 | + public static function compare_floats($float1, $float2, $operator = '=') { |
|
| 86 | 86 | // Check numbers to 5 digits of precision |
| 87 | 87 | $epsilon = 0.00001; |
| 88 | 88 | |
| 89 | - $float1 = (float)$float1; |
|
| 90 | - $float2 = (float)$float2; |
|
| 89 | + $float1 = (float) $float1; |
|
| 90 | + $float2 = (float) $float2; |
|
| 91 | 91 | |
| 92 | 92 | switch ($operator) { |
| 93 | 93 | // equal |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | break; |
| 145 | 145 | default: |
| 146 | - throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) ); |
|
| 146 | + throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso')); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return false; |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | * @return string |
| 160 | 160 | * @throws EE_Error |
| 161 | 161 | */ |
| 162 | - public static function get_format_for_jqplot( $CNT_ISO = '') { |
|
| 162 | + public static function get_format_for_jqplot($CNT_ISO = '') { |
|
| 163 | 163 | //default format |
| 164 | 164 | $format = 'f'; |
| 165 | 165 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
| 166 | 166 | //first get the decimal place and number of places |
| 167 | - $format = "%'." . $currency_config->dec_plc . $format; |
|
| 167 | + $format = "%'.".$currency_config->dec_plc.$format; |
|
| 168 | 168 | //currency symbol on right side. |
| 169 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
| 169 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
| 170 | 170 | return $format; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,20 +182,20 @@ discard block |
||
| 182 | 182 | * @return string |
| 183 | 183 | * @throws EE_Error |
| 184 | 184 | */ |
| 185 | - public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
|
| 185 | + public static function get_format_for_google_charts($CNT_ISO = '') { |
|
| 186 | 186 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
| 187 | - $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
|
| 187 | + $decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0'); |
|
| 188 | 188 | //first get the decimal place and number of places |
| 189 | - $format = '#,##0.' . $decimal_places_placeholder; |
|
| 189 | + $format = '#,##0.'.$decimal_places_placeholder; |
|
| 190 | 190 | |
| 191 | 191 | //currency symbol on right side. |
| 192 | - $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
|
| 192 | + $format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign; |
|
| 193 | 193 | $formatterObject = array( |
| 194 | 194 | 'decimalSymbol' => $currency_config->dec_mrk, |
| 195 | 195 | 'groupingSymbol' => $currency_config->thsnds, |
| 196 | 196 | 'fractionDigits' => $currency_config->dec_plc, |
| 197 | 197 | ); |
| 198 | - if ( $currency_config->sign_b4 ) { |
|
| 198 | + if ($currency_config->sign_b4) { |
|
| 199 | 199 | $formatterObject['prefix'] = $currency_config->sign; |
| 200 | 200 | } else { |
| 201 | 201 | $formatterObject['suffix'] = $currency_config->sign; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | ? new EE_Currency_Config($CNT_ISO) |
| 221 | 221 | : null; |
| 222 | 222 | //default currency settings for site if not set |
| 223 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
| 223 | + if ( ! $currency_config instanceof EE_Currency_Config) { |
|
| 224 | 224 | $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
| 225 | 225 | ? EE_Registry::instance()->CFG->currency |
| 226 | 226 | : new EE_Currency_Config(); |
@@ -8,71 +8,71 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
| 10 | 10 | /** |
| 11 | - * |
|
| 12 | - * Money helper class. |
|
| 13 | - * This class has helper methods that help with money related conversions and calculations. |
|
| 14 | - * |
|
| 15 | - * @since %VER% |
|
| 16 | - * |
|
| 17 | - * @package Event Espresso |
|
| 18 | - * @subpackage helpers |
|
| 19 | - * @author Darren Ethier |
|
| 20 | - * |
|
| 21 | - * ------------------------------------------------------------------------ |
|
| 22 | - */ |
|
| 11 | + * |
|
| 12 | + * Money helper class. |
|
| 13 | + * This class has helper methods that help with money related conversions and calculations. |
|
| 14 | + * |
|
| 15 | + * @since %VER% |
|
| 16 | + * |
|
| 17 | + * @package Event Espresso |
|
| 18 | + * @subpackage helpers |
|
| 19 | + * @author Darren Ethier |
|
| 20 | + * |
|
| 21 | + * ------------------------------------------------------------------------ |
|
| 22 | + */ |
|
| 23 | 23 | class EEH_Money extends EEH_Base { |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * This removes all localized money formatting from the incoming value |
|
| 28 | - * |
|
| 29 | - * Note: uses this site's currency settings for deciding what is considered a |
|
| 30 | - * "thousands separator" (usually the character "," ) |
|
| 31 | - * and what is a "decimal mark" (usually the character ".") |
|
| 32 | - * |
|
| 33 | - * @param int|float|string $money_value |
|
| 34 | - * @param string $CNT_ISO |
|
| 35 | - * @return float |
|
| 36 | - * @throws EE_Error |
|
| 37 | - */ |
|
| 26 | + /** |
|
| 27 | + * This removes all localized money formatting from the incoming value |
|
| 28 | + * |
|
| 29 | + * Note: uses this site's currency settings for deciding what is considered a |
|
| 30 | + * "thousands separator" (usually the character "," ) |
|
| 31 | + * and what is a "decimal mark" (usually the character ".") |
|
| 32 | + * |
|
| 33 | + * @param int|float|string $money_value |
|
| 34 | + * @param string $CNT_ISO |
|
| 35 | + * @return float |
|
| 36 | + * @throws EE_Error |
|
| 37 | + */ |
|
| 38 | 38 | public static function strip_localized_money_formatting($money_value, $CNT_ISO = '') { |
| 39 | - $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
| 40 | - $money_value = str_replace( |
|
| 41 | - array( |
|
| 42 | - $currency_config->thsnds, |
|
| 43 | - $currency_config->dec_mrk, |
|
| 44 | - ), |
|
| 45 | - array( |
|
| 46 | - '', // remove thousands separator |
|
| 47 | - '.', // convert decimal mark to what PHP expects |
|
| 48 | - ), |
|
| 49 | - $money_value |
|
| 50 | - ); |
|
| 51 | - $money_value = filter_var( |
|
| 52 | - $money_value, |
|
| 53 | - FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 54 | - FILTER_FLAG_ALLOW_FRACTION |
|
| 55 | - ); |
|
| 56 | - return $money_value; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
| 63 | - * |
|
| 64 | - * Only use this if you know the $money_value follows your currency configuration's |
|
| 65 | - * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
| 66 | - * "thousands separator" (usually the character "," ) |
|
| 67 | - * and what is a "decimal mark" (usually the character ".") |
|
| 68 | - * |
|
| 69 | - * @param int|string $money_value |
|
| 70 | - * @return float |
|
| 71 | - * @throws EE_Error |
|
| 72 | - */ |
|
| 39 | + $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
|
| 40 | + $money_value = str_replace( |
|
| 41 | + array( |
|
| 42 | + $currency_config->thsnds, |
|
| 43 | + $currency_config->dec_mrk, |
|
| 44 | + ), |
|
| 45 | + array( |
|
| 46 | + '', // remove thousands separator |
|
| 47 | + '.', // convert decimal mark to what PHP expects |
|
| 48 | + ), |
|
| 49 | + $money_value |
|
| 50 | + ); |
|
| 51 | + $money_value = filter_var( |
|
| 52 | + $money_value, |
|
| 53 | + FILTER_SANITIZE_NUMBER_FLOAT, |
|
| 54 | + FILTER_FLAG_ALLOW_FRACTION |
|
| 55 | + ); |
|
| 56 | + return $money_value; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * This converts an incoming localized money value into a standard float item (to three decimal places) |
|
| 63 | + * |
|
| 64 | + * Only use this if you know the $money_value follows your currency configuration's |
|
| 65 | + * settings. Note: this uses this site's currency settings for deciding what is considered a |
|
| 66 | + * "thousands separator" (usually the character "," ) |
|
| 67 | + * and what is a "decimal mark" (usually the character ".") |
|
| 68 | + * |
|
| 69 | + * @param int|string $money_value |
|
| 70 | + * @return float |
|
| 71 | + * @throws EE_Error |
|
| 72 | + */ |
|
| 73 | 73 | public static function convert_to_float_from_localized_money($money_value ) { |
| 74 | 74 | //float it! and round to three decimal places |
| 75 | - return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
| 75 | + return round ( (float) EEH_Money::strip_localized_money_formatting($money_value), 3 ); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -160,19 +160,19 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * This returns a localized format string suitable for jQplot. |
|
| 165 | - * |
|
| 166 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
| 167 | - * Otherwise will use currency settings for current active country on site. |
|
| 168 | - * @return string |
|
| 169 | - * @throws EE_Error |
|
| 170 | - */ |
|
| 163 | + /** |
|
| 164 | + * This returns a localized format string suitable for jQplot. |
|
| 165 | + * |
|
| 166 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
| 167 | + * Otherwise will use currency settings for current active country on site. |
|
| 168 | + * @return string |
|
| 169 | + * @throws EE_Error |
|
| 170 | + */ |
|
| 171 | 171 | public static function get_format_for_jqplot( $CNT_ISO = '') { |
| 172 | 172 | //default format |
| 173 | 173 | $format = 'f'; |
| 174 | 174 | $currency_config = $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
| 175 | - //first get the decimal place and number of places |
|
| 175 | + //first get the decimal place and number of places |
|
| 176 | 176 | $format = "%'." . $currency_config->dec_plc . $format; |
| 177 | 177 | //currency symbol on right side. |
| 178 | 178 | $format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign; |
@@ -181,16 +181,16 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | - /** |
|
| 185 | - * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
| 186 | - * |
|
| 187 | - * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
| 188 | - * Otherwise will use currency settings for current active country on site. |
|
| 189 | - * Note: GoogleCharts uses ICU pattern set |
|
| 190 | - * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
| 191 | - * @return string |
|
| 192 | - * @throws EE_Error |
|
| 193 | - */ |
|
| 184 | + /** |
|
| 185 | + * This returns a localized format string suitable for usage with the Google Charts API format param. |
|
| 186 | + * |
|
| 187 | + * @param string $CNT_ISO If this is provided, then will attempt to get the currency settings for the country. |
|
| 188 | + * Otherwise will use currency settings for current active country on site. |
|
| 189 | + * Note: GoogleCharts uses ICU pattern set |
|
| 190 | + * (@see http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details) |
|
| 191 | + * @return string |
|
| 192 | + * @throws EE_Error |
|
| 193 | + */ |
|
| 194 | 194 | public static function get_format_for_google_charts( $CNT_ISO = '' ) { |
| 195 | 195 | $currency_config = EEH_Money::get_currency_config($CNT_ISO); |
| 196 | 196 | $decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' ); |
@@ -217,24 +217,24 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| 220 | - /** |
|
| 221 | - * @param string $CNT_ISO |
|
| 222 | - * @return EE_Currency_Config|null |
|
| 223 | - * @throws EE_Error |
|
| 224 | - */ |
|
| 225 | - public static function get_currency_config($CNT_ISO = '') |
|
| 226 | - { |
|
| 227 | - //if CNT_ISO passed lets try to get currency settings for it. |
|
| 228 | - $currency_config = $CNT_ISO !== '' |
|
| 229 | - ? new EE_Currency_Config($CNT_ISO) |
|
| 230 | - : null; |
|
| 231 | - //default currency settings for site if not set |
|
| 232 | - if (! $currency_config instanceof EE_Currency_Config) { |
|
| 233 | - $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
| 234 | - ? EE_Registry::instance()->CFG->currency |
|
| 235 | - : new EE_Currency_Config(); |
|
| 236 | - } |
|
| 237 | - return $currency_config; |
|
| 238 | - } |
|
| 220 | + /** |
|
| 221 | + * @param string $CNT_ISO |
|
| 222 | + * @return EE_Currency_Config|null |
|
| 223 | + * @throws EE_Error |
|
| 224 | + */ |
|
| 225 | + public static function get_currency_config($CNT_ISO = '') |
|
| 226 | + { |
|
| 227 | + //if CNT_ISO passed lets try to get currency settings for it. |
|
| 228 | + $currency_config = $CNT_ISO !== '' |
|
| 229 | + ? new EE_Currency_Config($CNT_ISO) |
|
| 230 | + : null; |
|
| 231 | + //default currency settings for site if not set |
|
| 232 | + if (! $currency_config instanceof EE_Currency_Config) { |
|
| 233 | + $currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
| 234 | + ? EE_Registry::instance()->CFG->currency |
|
| 235 | + : new EE_Currency_Config(); |
|
| 236 | + } |
|
| 237 | + return $currency_config; |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | } //end class EEH_Money |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -28,636 +28,636 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - public function __construct($routing = true) |
|
| 32 | - { |
|
| 33 | - parent::__construct($routing); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - protected function _init_page_props() |
|
| 39 | - { |
|
| 40 | - $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
| 41 | - $this->page_label = EE_MAINTENANCE_LABEL; |
|
| 42 | - $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
| 43 | - $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - protected function _ajax_hooks() |
|
| 49 | - { |
|
| 50 | - add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
| 51 | - add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - protected function _define_page_props() |
|
| 57 | - { |
|
| 58 | - $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
| 59 | - $this->_labels = array( |
|
| 60 | - 'buttons' => array( |
|
| 61 | - 'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), |
|
| 62 | - 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
| 63 | - ), |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - protected function _set_page_routes() |
|
| 70 | - { |
|
| 71 | - $this->_page_routes = array( |
|
| 72 | - 'default' => array( |
|
| 73 | - 'func' => '_maintenance', |
|
| 74 | - 'capability' => 'manage_options', |
|
| 75 | - ), |
|
| 76 | - 'change_maintenance_level' => array( |
|
| 77 | - 'func' => '_change_maintenance_level', |
|
| 78 | - 'capability' => 'manage_options', |
|
| 79 | - 'noheader' => true, |
|
| 80 | - ), |
|
| 81 | - 'system_status' => array( |
|
| 82 | - 'func' => '_system_status', |
|
| 83 | - 'capability' => 'manage_options', |
|
| 84 | - ), |
|
| 85 | - 'download_system_status' => array( |
|
| 86 | - 'func' => '_download_system_status', |
|
| 87 | - 'capability' => 'manage_options', |
|
| 88 | - 'noheader' => true, |
|
| 89 | - ), |
|
| 90 | - 'send_migration_crash_report' => array( |
|
| 91 | - 'func' => '_send_migration_crash_report', |
|
| 92 | - 'capability' => 'manage_options', |
|
| 93 | - 'noheader' => true, |
|
| 94 | - ), |
|
| 95 | - 'confirm_migration_crash_report_sent' => array( |
|
| 96 | - 'func' => '_confirm_migration_crash_report_sent', |
|
| 97 | - 'capability' => 'manage_options', |
|
| 98 | - ), |
|
| 99 | - 'data_reset' => array( |
|
| 100 | - 'func' => '_data_reset_and_delete', |
|
| 101 | - 'capability' => 'manage_options', |
|
| 102 | - ), |
|
| 103 | - 'reset_db' => array( |
|
| 104 | - 'func' => '_reset_db', |
|
| 105 | - 'capability' => 'manage_options', |
|
| 106 | - 'noheader' => true, |
|
| 107 | - 'args' => array('nuke_old_ee4_data' => true), |
|
| 108 | - ), |
|
| 109 | - 'start_with_fresh_ee4_db' => array( |
|
| 110 | - 'func' => '_reset_db', |
|
| 111 | - 'capability' => 'manage_options', |
|
| 112 | - 'noheader' => true, |
|
| 113 | - 'args' => array('nuke_old_ee4_data' => false), |
|
| 114 | - ), |
|
| 115 | - 'delete_db' => array( |
|
| 116 | - 'func' => '_delete_db', |
|
| 117 | - 'capability' => 'manage_options', |
|
| 118 | - 'noheader' => true, |
|
| 119 | - ), |
|
| 120 | - 'rerun_migration_from_ee3' => array( |
|
| 121 | - 'func' => '_rerun_migration_from_ee3', |
|
| 122 | - 'capability' => 'manage_options', |
|
| 123 | - 'noheader' => true, |
|
| 124 | - ), |
|
| 125 | - 'reset_reservations' => array( |
|
| 126 | - 'func' => '_reset_reservations', |
|
| 127 | - 'capability' => 'manage_options', |
|
| 128 | - 'noheader' => true, |
|
| 129 | - ), |
|
| 130 | - 'reset_capabilities' => array( |
|
| 131 | - 'func' => '_reset_capabilities', |
|
| 132 | - 'capability' => 'manage_options', |
|
| 133 | - 'noheader' => true, |
|
| 134 | - ), |
|
| 135 | - 'reattempt_migration' => array( |
|
| 136 | - 'func' => '_reattempt_migration', |
|
| 137 | - 'capability' => 'manage_options', |
|
| 138 | - 'noheader' => true, |
|
| 139 | - ), |
|
| 140 | - ); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - protected function _set_page_config() |
|
| 146 | - { |
|
| 147 | - $this->_page_config = array( |
|
| 148 | - 'default' => array( |
|
| 149 | - 'nav' => array( |
|
| 150 | - 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 151 | - 'order' => 10, |
|
| 152 | - ), |
|
| 153 | - 'require_nonce' => false, |
|
| 154 | - ), |
|
| 155 | - 'data_reset' => array( |
|
| 156 | - 'nav' => array( |
|
| 157 | - 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 158 | - 'order' => 20, |
|
| 159 | - ), |
|
| 160 | - 'require_nonce' => false, |
|
| 161 | - ), |
|
| 162 | - 'system_status' => array( |
|
| 163 | - 'nav' => array( |
|
| 164 | - 'label' => esc_html__("System Information", "event_espresso"), |
|
| 165 | - 'order' => 30, |
|
| 166 | - ), |
|
| 167 | - 'require_nonce' => false, |
|
| 168 | - ), |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 176 | - * the migration scripts and all that UI. |
|
| 177 | - */ |
|
| 178 | - public function _maintenance() |
|
| 179 | - { |
|
| 180 | - //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 181 | - //level 2 (everything except maintenance page) |
|
| 182 | - try { |
|
| 183 | - //get the current maintenance level and check if |
|
| 184 | - //we are removed |
|
| 185 | - $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 186 | - $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 187 | - if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 188 | - //we just took the site out of maintenance mode, so notify the user. |
|
| 189 | - //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 190 | - //oh well, we should really be checking for this on addon deactivation anyways |
|
| 191 | - EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 192 | - 'event_espresso')); |
|
| 193 | - $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 194 | - } |
|
| 195 | - //in case an exception is thrown while trying to handle migrations |
|
| 196 | - switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 197 | - case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 198 | - case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 199 | - $show_maintenance_switch = true; |
|
| 200 | - $show_backup_db_text = false; |
|
| 201 | - $show_migration_progress = false; |
|
| 202 | - $script_names = array(); |
|
| 203 | - $addons_should_be_upgraded_first = false; |
|
| 204 | - break; |
|
| 205 | - case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 206 | - $show_maintenance_switch = false; |
|
| 207 | - $show_migration_progress = true; |
|
| 208 | - if (isset($this->_req_data['continue_migration'])) { |
|
| 209 | - $show_backup_db_text = false; |
|
| 210 | - } else { |
|
| 211 | - $show_backup_db_text = true; |
|
| 212 | - } |
|
| 213 | - $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 214 | - ->check_for_applicable_data_migration_scripts(); |
|
| 215 | - $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 216 | - $script_names = array(); |
|
| 217 | - $current_script = null; |
|
| 218 | - foreach ($scripts_needing_to_run as $script) { |
|
| 219 | - if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 220 | - if ( ! $current_script) { |
|
| 221 | - $current_script = $script; |
|
| 222 | - $current_script->migration_page_hooks(); |
|
| 223 | - } |
|
| 224 | - $script_names[] = $script->pretty_name(); |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - break; |
|
| 228 | - } |
|
| 229 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 230 | - $exception_thrown = false; |
|
| 231 | - } catch (EE_Error $e) { |
|
| 232 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 233 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 234 | - //and also put the error on it. It only persists for the duration of this request |
|
| 235 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 236 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 237 | - $exception_thrown = true; |
|
| 238 | - } |
|
| 239 | - $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 240 | - $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 241 | - if ($exception_thrown |
|
| 242 | - || ($most_recent_migration |
|
| 243 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 244 | - && $most_recent_migration->is_broken() |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 248 | - $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 249 | - $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 250 | - 'success' => '0', |
|
| 251 | - ), EE_MAINTENANCE_ADMIN_URL); |
|
| 252 | - } elseif ($addons_should_be_upgraded_first) { |
|
| 253 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | - } else { |
|
| 255 | - if ($most_recent_migration |
|
| 256 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 257 | - && $most_recent_migration->can_continue() |
|
| 258 | - ) { |
|
| 259 | - $show_backup_db_text = false; |
|
| 260 | - $show_continue_current_migration_script = true; |
|
| 261 | - $show_most_recent_migration = true; |
|
| 262 | - } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 263 | - $show_most_recent_migration = true; |
|
| 264 | - $show_continue_current_migration_script = false; |
|
| 265 | - } else { |
|
| 266 | - $show_most_recent_migration = false; |
|
| 267 | - $show_continue_current_migration_script = false; |
|
| 268 | - } |
|
| 269 | - if (isset($current_script)) { |
|
| 270 | - $migrates_to = $current_script->migrates_to_version(); |
|
| 271 | - $plugin_slug = $migrates_to['slug']; |
|
| 272 | - $new_version = $migrates_to['version']; |
|
| 273 | - $this->_template_args = array_merge($this->_template_args, array( |
|
| 274 | - 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 275 | - isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 276 | - 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 277 | - $new_version, $plugin_slug) : null, |
|
| 278 | - )); |
|
| 279 | - } else { |
|
| 280 | - $this->_template_args['current_db_state'] = null; |
|
| 281 | - $this->_template_args['next_db_state'] = null; |
|
| 282 | - } |
|
| 283 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 284 | - $this->_template_args = array_merge( |
|
| 285 | - $this->_template_args, |
|
| 286 | - array( |
|
| 287 | - 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 288 | - //flag for showing the most recent migration's status and/or errors |
|
| 289 | - 'show_migration_progress' => $show_migration_progress, |
|
| 290 | - //flag for showing the option to run migrations and see their progress |
|
| 291 | - 'show_backup_db_text' => $show_backup_db_text, |
|
| 292 | - //flag for showing text telling the user to backup their DB |
|
| 293 | - 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 294 | - //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 295 | - 'script_names' => $script_names, |
|
| 296 | - //array of names of scripts that have run |
|
| 297 | - 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 298 | - //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 299 | - 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 300 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 301 | - 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 302 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 303 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 304 | - EE_MAINTENANCE_ADMIN_URL), |
|
| 305 | - 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 306 | - espresso_version()), |
|
| 307 | - ) |
|
| 308 | - ); |
|
| 309 | - //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 310 | - //localize script stuff |
|
| 311 | - wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 312 | - 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 313 | - 'next' => esc_html__("Next", "event_espresso"), |
|
| 314 | - 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 315 | - 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 316 | - "event_espresso"), |
|
| 317 | - 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 318 | - 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 319 | - 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 320 | - )); |
|
| 321 | - } |
|
| 322 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 323 | - //now render the migration options part, and put it in a variable |
|
| 324 | - $migration_options_template_file = apply_filters( |
|
| 325 | - 'FHEE__ee_migration_page__migration_options_template', |
|
| 326 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 327 | - ); |
|
| 328 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 329 | - $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 330 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 331 | - $this->_template_args, true); |
|
| 332 | - $this->display_admin_page_with_sidebar(); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 339 | - */ |
|
| 340 | - public function migration_step() |
|
| 341 | - { |
|
| 342 | - $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 343 | - $this->_return_json(); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - |
|
| 347 | - |
|
| 348 | - /** |
|
| 349 | - * Can be used by js when it notices a response with HTML in it in order |
|
| 350 | - * to log the malformed response |
|
| 351 | - */ |
|
| 352 | - public function add_error_to_migrations_ran() |
|
| 353 | - { |
|
| 354 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 355 | - $this->_template_args['data'] = array('ok' => true); |
|
| 356 | - $this->_return_json(); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 363 | - */ |
|
| 364 | - public function _change_maintenance_level() |
|
| 365 | - { |
|
| 366 | - $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 367 | - if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 368 | - EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 369 | - $success = true; |
|
| 370 | - } else { |
|
| 371 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 372 | - $success = false; |
|
| 373 | - } |
|
| 374 | - $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * a tab with options for resetting and/or deleting EE data |
|
| 381 | - * |
|
| 382 | - * @throws \EE_Error |
|
| 383 | - * @throws \DomainException |
|
| 384 | - */ |
|
| 385 | - public function _data_reset_and_delete() |
|
| 386 | - { |
|
| 387 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 388 | - $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 389 | - 'reset_reservations', |
|
| 390 | - 'reset_reservations', |
|
| 391 | - array(), |
|
| 392 | - 'button button-primary', |
|
| 393 | - '', |
|
| 394 | - false |
|
| 395 | - ); |
|
| 396 | - $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 397 | - 'reset_capabilities', |
|
| 398 | - 'reset_capabilities', |
|
| 399 | - array(), |
|
| 400 | - 'button button-primary', |
|
| 401 | - '', |
|
| 402 | - false |
|
| 403 | - ); |
|
| 404 | - $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 405 | - array('action' => 'delete_db'), |
|
| 406 | - EE_MAINTENANCE_ADMIN_URL |
|
| 407 | - ); |
|
| 408 | - $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 409 | - array('action' => 'reset_db'), |
|
| 410 | - EE_MAINTENANCE_ADMIN_URL |
|
| 411 | - ); |
|
| 412 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 413 | - $this->_template_path, |
|
| 414 | - $this->_template_args, |
|
| 415 | - true |
|
| 416 | - ); |
|
| 417 | - $this->display_admin_page_with_sidebar(); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - |
|
| 422 | - protected function _reset_reservations() |
|
| 423 | - { |
|
| 424 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 425 | - EE_Error::add_success( |
|
| 426 | - __( |
|
| 427 | - 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 428 | - 'event_espresso' |
|
| 429 | - ) |
|
| 430 | - ); |
|
| 431 | - } else { |
|
| 432 | - EE_Error::add_success( |
|
| 433 | - __( |
|
| 434 | - 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 435 | - 'event_espresso' |
|
| 436 | - ) |
|
| 437 | - ); |
|
| 438 | - } |
|
| 439 | - $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - protected function _reset_capabilities() |
|
| 445 | - { |
|
| 446 | - EE_Registry::instance()->CAP->init_caps(true); |
|
| 447 | - EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 448 | - 'event_espresso')); |
|
| 449 | - $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - |
|
| 453 | - |
|
| 454 | - /** |
|
| 455 | - * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 456 | - * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 457 | - * the fatal error in teh first place) |
|
| 458 | - */ |
|
| 459 | - protected function _reattempt_migration() |
|
| 460 | - { |
|
| 461 | - EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 462 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * shows the big ol' System Information page |
|
| 469 | - */ |
|
| 470 | - public function _system_status() |
|
| 471 | - { |
|
| 472 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 473 | - $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 474 | - $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 475 | - array( |
|
| 476 | - 'action' => 'download_system_status', |
|
| 477 | - ), |
|
| 478 | - EE_MAINTENANCE_ADMIN_URL |
|
| 479 | - ); |
|
| 480 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 481 | - $this->_template_args, true); |
|
| 482 | - $this->display_admin_page_with_sidebar(); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 487 | - */ |
|
| 488 | - public function _download_system_status() |
|
| 489 | - { |
|
| 490 | - $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 491 | - header( 'Content-Disposition: attachment' ); |
|
| 492 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 493 | - echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 494 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 495 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 496 | - die; |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - public function _send_migration_crash_report() |
|
| 502 | - { |
|
| 503 | - $from = $this->_req_data['from']; |
|
| 504 | - $from_name = $this->_req_data['from_name']; |
|
| 505 | - $body = $this->_req_data['body']; |
|
| 506 | - try { |
|
| 507 | - $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 508 | - 'Migration Crash Report', |
|
| 509 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 510 | - array( |
|
| 511 | - "from:$from_name<$from>", |
|
| 512 | - // 'content-type:text/html charset=UTF-8' |
|
| 513 | - )); |
|
| 514 | - } catch (Exception $e) { |
|
| 515 | - $success = false; |
|
| 516 | - } |
|
| 517 | - $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 518 | - esc_html__("sent", "event_espresso"), |
|
| 519 | - array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 520 | - } |
|
| 521 | - |
|
| 522 | - |
|
| 523 | - |
|
| 524 | - public function _confirm_migration_crash_report_sent() |
|
| 525 | - { |
|
| 526 | - try { |
|
| 527 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 528 | - } catch (EE_Error $e) { |
|
| 529 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 530 | - //now, just so we can display the page correctly, make a error migration script stage object |
|
| 531 | - //and also put the error on it. It only persists for the duration of this request |
|
| 532 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 533 | - $most_recent_migration->add_error($e->getMessage()); |
|
| 534 | - } |
|
| 535 | - $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 536 | - $this->_template_args['success'] = $success; |
|
| 537 | - $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 538 | - $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 539 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 540 | - $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 541 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 542 | - $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 543 | - EE_MAINTENANCE_ADMIN_URL); |
|
| 544 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 545 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 546 | - $this->_template_args, true); |
|
| 547 | - $this->display_admin_page_with_sidebar(); |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - |
|
| 552 | - /** |
|
| 553 | - * Resets the entire EE4 database. |
|
| 554 | - * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 555 | - * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 556 | - * |
|
| 557 | - * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 558 | - * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 559 | - */ |
|
| 560 | - public function _reset_db($nuke_old_ee4_data = true) |
|
| 561 | - { |
|
| 562 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 563 | - if ($nuke_old_ee4_data) { |
|
| 564 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 565 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 566 | - EEH_Activation::remove_cron_tasks(); |
|
| 567 | - } |
|
| 568 | - //make sure when we reset the registry's config that it |
|
| 569 | - //switches to using the new singleton |
|
| 570 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 571 | - EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 572 | - EE_System::instance()->redirect_to_about_ee(); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Deletes ALL EE tables, Records, and Options from the database. |
|
| 579 | - */ |
|
| 580 | - public function _delete_db() |
|
| 581 | - { |
|
| 582 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 583 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 584 | - EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 585 | - EEH_Activation::remove_cron_tasks(); |
|
| 586 | - EEH_Activation::deactivate_event_espresso(); |
|
| 587 | - wp_safe_redirect(admin_url('plugins.php')); |
|
| 588 | - exit; |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 595 | - */ |
|
| 596 | - public function _rerun_migration_from_ee3() |
|
| 597 | - { |
|
| 598 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 599 | - EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 600 | - EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 601 | - //set the db state to something that will require migrations |
|
| 602 | - update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 603 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 604 | - $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - |
|
| 608 | - |
|
| 609 | - //none of the below group are currently used for Gateway Settings |
|
| 610 | - protected function _add_screen_options() |
|
| 611 | - { |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - |
|
| 616 | - protected function _add_feature_pointers() |
|
| 617 | - { |
|
| 618 | - } |
|
| 619 | - |
|
| 31 | + public function __construct($routing = true) |
|
| 32 | + { |
|
| 33 | + parent::__construct($routing); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + protected function _init_page_props() |
|
| 39 | + { |
|
| 40 | + $this->page_slug = EE_MAINTENANCE_PG_SLUG; |
|
| 41 | + $this->page_label = EE_MAINTENANCE_LABEL; |
|
| 42 | + $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL; |
|
| 43 | + $this->_admin_base_path = EE_MAINTENANCE_ADMIN; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + protected function _ajax_hooks() |
|
| 49 | + { |
|
| 50 | + add_action('wp_ajax_migration_step', array($this, 'migration_step')); |
|
| 51 | + add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + protected function _define_page_props() |
|
| 57 | + { |
|
| 58 | + $this->_admin_page_title = EE_MAINTENANCE_LABEL; |
|
| 59 | + $this->_labels = array( |
|
| 60 | + 'buttons' => array( |
|
| 61 | + 'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), |
|
| 62 | + 'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), |
|
| 63 | + ), |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + protected function _set_page_routes() |
|
| 70 | + { |
|
| 71 | + $this->_page_routes = array( |
|
| 72 | + 'default' => array( |
|
| 73 | + 'func' => '_maintenance', |
|
| 74 | + 'capability' => 'manage_options', |
|
| 75 | + ), |
|
| 76 | + 'change_maintenance_level' => array( |
|
| 77 | + 'func' => '_change_maintenance_level', |
|
| 78 | + 'capability' => 'manage_options', |
|
| 79 | + 'noheader' => true, |
|
| 80 | + ), |
|
| 81 | + 'system_status' => array( |
|
| 82 | + 'func' => '_system_status', |
|
| 83 | + 'capability' => 'manage_options', |
|
| 84 | + ), |
|
| 85 | + 'download_system_status' => array( |
|
| 86 | + 'func' => '_download_system_status', |
|
| 87 | + 'capability' => 'manage_options', |
|
| 88 | + 'noheader' => true, |
|
| 89 | + ), |
|
| 90 | + 'send_migration_crash_report' => array( |
|
| 91 | + 'func' => '_send_migration_crash_report', |
|
| 92 | + 'capability' => 'manage_options', |
|
| 93 | + 'noheader' => true, |
|
| 94 | + ), |
|
| 95 | + 'confirm_migration_crash_report_sent' => array( |
|
| 96 | + 'func' => '_confirm_migration_crash_report_sent', |
|
| 97 | + 'capability' => 'manage_options', |
|
| 98 | + ), |
|
| 99 | + 'data_reset' => array( |
|
| 100 | + 'func' => '_data_reset_and_delete', |
|
| 101 | + 'capability' => 'manage_options', |
|
| 102 | + ), |
|
| 103 | + 'reset_db' => array( |
|
| 104 | + 'func' => '_reset_db', |
|
| 105 | + 'capability' => 'manage_options', |
|
| 106 | + 'noheader' => true, |
|
| 107 | + 'args' => array('nuke_old_ee4_data' => true), |
|
| 108 | + ), |
|
| 109 | + 'start_with_fresh_ee4_db' => array( |
|
| 110 | + 'func' => '_reset_db', |
|
| 111 | + 'capability' => 'manage_options', |
|
| 112 | + 'noheader' => true, |
|
| 113 | + 'args' => array('nuke_old_ee4_data' => false), |
|
| 114 | + ), |
|
| 115 | + 'delete_db' => array( |
|
| 116 | + 'func' => '_delete_db', |
|
| 117 | + 'capability' => 'manage_options', |
|
| 118 | + 'noheader' => true, |
|
| 119 | + ), |
|
| 120 | + 'rerun_migration_from_ee3' => array( |
|
| 121 | + 'func' => '_rerun_migration_from_ee3', |
|
| 122 | + 'capability' => 'manage_options', |
|
| 123 | + 'noheader' => true, |
|
| 124 | + ), |
|
| 125 | + 'reset_reservations' => array( |
|
| 126 | + 'func' => '_reset_reservations', |
|
| 127 | + 'capability' => 'manage_options', |
|
| 128 | + 'noheader' => true, |
|
| 129 | + ), |
|
| 130 | + 'reset_capabilities' => array( |
|
| 131 | + 'func' => '_reset_capabilities', |
|
| 132 | + 'capability' => 'manage_options', |
|
| 133 | + 'noheader' => true, |
|
| 134 | + ), |
|
| 135 | + 'reattempt_migration' => array( |
|
| 136 | + 'func' => '_reattempt_migration', |
|
| 137 | + 'capability' => 'manage_options', |
|
| 138 | + 'noheader' => true, |
|
| 139 | + ), |
|
| 140 | + ); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + protected function _set_page_config() |
|
| 146 | + { |
|
| 147 | + $this->_page_config = array( |
|
| 148 | + 'default' => array( |
|
| 149 | + 'nav' => array( |
|
| 150 | + 'label' => esc_html__('Maintenance', 'event_espresso'), |
|
| 151 | + 'order' => 10, |
|
| 152 | + ), |
|
| 153 | + 'require_nonce' => false, |
|
| 154 | + ), |
|
| 155 | + 'data_reset' => array( |
|
| 156 | + 'nav' => array( |
|
| 157 | + 'label' => esc_html__('Reset/Delete Data', 'event_espresso'), |
|
| 158 | + 'order' => 20, |
|
| 159 | + ), |
|
| 160 | + 'require_nonce' => false, |
|
| 161 | + ), |
|
| 162 | + 'system_status' => array( |
|
| 163 | + 'nav' => array( |
|
| 164 | + 'label' => esc_html__("System Information", "event_espresso"), |
|
| 165 | + 'order' => 30, |
|
| 166 | + ), |
|
| 167 | + 'require_nonce' => false, |
|
| 168 | + ), |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * default maintenance page. If we're in maintenance mode level 2, then we need to show |
|
| 176 | + * the migration scripts and all that UI. |
|
| 177 | + */ |
|
| 178 | + public function _maintenance() |
|
| 179 | + { |
|
| 180 | + //it all depends if we're in maintenance model level 1 (frontend-only) or |
|
| 181 | + //level 2 (everything except maintenance page) |
|
| 182 | + try { |
|
| 183 | + //get the current maintenance level and check if |
|
| 184 | + //we are removed |
|
| 185 | + $mm = EE_Maintenance_Mode::instance()->level(); |
|
| 186 | + $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 187 | + if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { |
|
| 188 | + //we just took the site out of maintenance mode, so notify the user. |
|
| 189 | + //unfortunately this message appears to be echoed on the NEXT page load... |
|
| 190 | + //oh well, we should really be checking for this on addon deactivation anyways |
|
| 191 | + EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', |
|
| 192 | + 'event_espresso')); |
|
| 193 | + $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); |
|
| 194 | + } |
|
| 195 | + //in case an exception is thrown while trying to handle migrations |
|
| 196 | + switch (EE_Maintenance_Mode::instance()->level()) { |
|
| 197 | + case EE_Maintenance_Mode::level_0_not_in_maintenance: |
|
| 198 | + case EE_Maintenance_Mode::level_1_frontend_only_maintenance: |
|
| 199 | + $show_maintenance_switch = true; |
|
| 200 | + $show_backup_db_text = false; |
|
| 201 | + $show_migration_progress = false; |
|
| 202 | + $script_names = array(); |
|
| 203 | + $addons_should_be_upgraded_first = false; |
|
| 204 | + break; |
|
| 205 | + case EE_Maintenance_Mode::level_2_complete_maintenance: |
|
| 206 | + $show_maintenance_switch = false; |
|
| 207 | + $show_migration_progress = true; |
|
| 208 | + if (isset($this->_req_data['continue_migration'])) { |
|
| 209 | + $show_backup_db_text = false; |
|
| 210 | + } else { |
|
| 211 | + $show_backup_db_text = true; |
|
| 212 | + } |
|
| 213 | + $scripts_needing_to_run = EE_Data_Migration_Manager::instance() |
|
| 214 | + ->check_for_applicable_data_migration_scripts(); |
|
| 215 | + $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating(); |
|
| 216 | + $script_names = array(); |
|
| 217 | + $current_script = null; |
|
| 218 | + foreach ($scripts_needing_to_run as $script) { |
|
| 219 | + if ($script instanceof EE_Data_Migration_Script_Base) { |
|
| 220 | + if ( ! $current_script) { |
|
| 221 | + $current_script = $script; |
|
| 222 | + $current_script->migration_page_hooks(); |
|
| 223 | + } |
|
| 224 | + $script_names[] = $script->pretty_name(); |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + break; |
|
| 228 | + } |
|
| 229 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 230 | + $exception_thrown = false; |
|
| 231 | + } catch (EE_Error $e) { |
|
| 232 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 233 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 234 | + //and also put the error on it. It only persists for the duration of this request |
|
| 235 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 236 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 237 | + $exception_thrown = true; |
|
| 238 | + } |
|
| 239 | + $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set(); |
|
| 240 | + $current_db_state = str_replace('.decaf', '', $current_db_state); |
|
| 241 | + if ($exception_thrown |
|
| 242 | + || ($most_recent_migration |
|
| 243 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 244 | + && $most_recent_migration->is_broken() |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 248 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
|
| 249 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
|
| 250 | + 'success' => '0', |
|
| 251 | + ), EE_MAINTENANCE_ADMIN_URL); |
|
| 252 | + } elseif ($addons_should_be_upgraded_first) { |
|
| 253 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | + } else { |
|
| 255 | + if ($most_recent_migration |
|
| 256 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
|
| 257 | + && $most_recent_migration->can_continue() |
|
| 258 | + ) { |
|
| 259 | + $show_backup_db_text = false; |
|
| 260 | + $show_continue_current_migration_script = true; |
|
| 261 | + $show_most_recent_migration = true; |
|
| 262 | + } elseif (isset($this->_req_data['continue_migration'])) { |
|
| 263 | + $show_most_recent_migration = true; |
|
| 264 | + $show_continue_current_migration_script = false; |
|
| 265 | + } else { |
|
| 266 | + $show_most_recent_migration = false; |
|
| 267 | + $show_continue_current_migration_script = false; |
|
| 268 | + } |
|
| 269 | + if (isset($current_script)) { |
|
| 270 | + $migrates_to = $current_script->migrates_to_version(); |
|
| 271 | + $plugin_slug = $migrates_to['slug']; |
|
| 272 | + $new_version = $migrates_to['version']; |
|
| 273 | + $this->_template_args = array_merge($this->_template_args, array( |
|
| 274 | + 'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"), |
|
| 275 | + isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug), |
|
| 276 | + 'next_db_state' => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), |
|
| 277 | + $new_version, $plugin_slug) : null, |
|
| 278 | + )); |
|
| 279 | + } else { |
|
| 280 | + $this->_template_args['current_db_state'] = null; |
|
| 281 | + $this->_template_args['next_db_state'] = null; |
|
| 282 | + } |
|
| 283 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 284 | + $this->_template_args = array_merge( |
|
| 285 | + $this->_template_args, |
|
| 286 | + array( |
|
| 287 | + 'show_most_recent_migration' => $show_most_recent_migration, |
|
| 288 | + //flag for showing the most recent migration's status and/or errors |
|
| 289 | + 'show_migration_progress' => $show_migration_progress, |
|
| 290 | + //flag for showing the option to run migrations and see their progress |
|
| 291 | + 'show_backup_db_text' => $show_backup_db_text, |
|
| 292 | + //flag for showing text telling the user to backup their DB |
|
| 293 | + 'show_maintenance_switch' => $show_maintenance_switch, |
|
| 294 | + //flag for showing the option to change maintenance mode between levels 0 and 1 |
|
| 295 | + 'script_names' => $script_names, |
|
| 296 | + //array of names of scripts that have run |
|
| 297 | + 'show_continue_current_migration_script' => $show_continue_current_migration_script, |
|
| 298 | + //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0 |
|
| 299 | + 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 300 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 301 | + 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 302 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 303 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'), |
|
| 304 | + EE_MAINTENANCE_ADMIN_URL), |
|
| 305 | + 'ultimate_db_state' => sprintf(__("EE%s", 'event_espresso'), |
|
| 306 | + espresso_version()), |
|
| 307 | + ) |
|
| 308 | + ); |
|
| 309 | + //make sure we have the form fields helper available. It usually is, but sometimes it isn't |
|
| 310 | + //localize script stuff |
|
| 311 | + wp_localize_script('ee-maintenance', 'ee_maintenance', array( |
|
| 312 | + 'migrating' => esc_html__("Updating Database...", "event_espresso"), |
|
| 313 | + 'next' => esc_html__("Next", "event_espresso"), |
|
| 314 | + 'fatal_error' => esc_html__("A Fatal Error Has Occurred", "event_espresso"), |
|
| 315 | + 'click_next_when_ready' => esc_html__("The current Database Update has ended. Click 'next' when ready to proceed", |
|
| 316 | + "event_espresso"), |
|
| 317 | + 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts, |
|
| 318 | + 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error, |
|
| 319 | + 'status_completed' => EE_Data_Migration_Manager::status_completed, |
|
| 320 | + )); |
|
| 321 | + } |
|
| 322 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 323 | + //now render the migration options part, and put it in a variable |
|
| 324 | + $migration_options_template_file = apply_filters( |
|
| 325 | + 'FHEE__ee_migration_page__migration_options_template', |
|
| 326 | + EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 327 | + ); |
|
| 328 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 329 | + $this->_template_args['migration_options_html'] = $migration_options_html; |
|
| 330 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 331 | + $this->_template_args, true); |
|
| 332 | + $this->display_admin_page_with_sidebar(); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * returns JSON and executes another step of the currently-executing data migration (called via ajax) |
|
| 339 | + */ |
|
| 340 | + public function migration_step() |
|
| 341 | + { |
|
| 342 | + $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request(); |
|
| 343 | + $this->_return_json(); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + |
|
| 347 | + |
|
| 348 | + /** |
|
| 349 | + * Can be used by js when it notices a response with HTML in it in order |
|
| 350 | + * to log the malformed response |
|
| 351 | + */ |
|
| 352 | + public function add_error_to_migrations_ran() |
|
| 353 | + { |
|
| 354 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']); |
|
| 355 | + $this->_template_args['data'] = array('ok' => true); |
|
| 356 | + $this->_return_json(); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * changes the maintenance level, provided there are still no migration scripts that should run |
|
| 363 | + */ |
|
| 364 | + public function _change_maintenance_level() |
|
| 365 | + { |
|
| 366 | + $new_level = absint($this->_req_data['maintenance_mode_level']); |
|
| 367 | + if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { |
|
| 368 | + EE_Maintenance_Mode::instance()->set_maintenance_level($new_level); |
|
| 369 | + $success = true; |
|
| 370 | + } else { |
|
| 371 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 372 | + $success = false; |
|
| 373 | + } |
|
| 374 | + $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * a tab with options for resetting and/or deleting EE data |
|
| 381 | + * |
|
| 382 | + * @throws \EE_Error |
|
| 383 | + * @throws \DomainException |
|
| 384 | + */ |
|
| 385 | + public function _data_reset_and_delete() |
|
| 386 | + { |
|
| 387 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 388 | + $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
|
| 389 | + 'reset_reservations', |
|
| 390 | + 'reset_reservations', |
|
| 391 | + array(), |
|
| 392 | + 'button button-primary', |
|
| 393 | + '', |
|
| 394 | + false |
|
| 395 | + ); |
|
| 396 | + $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( |
|
| 397 | + 'reset_capabilities', |
|
| 398 | + 'reset_capabilities', |
|
| 399 | + array(), |
|
| 400 | + 'button button-primary', |
|
| 401 | + '', |
|
| 402 | + false |
|
| 403 | + ); |
|
| 404 | + $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 405 | + array('action' => 'delete_db'), |
|
| 406 | + EE_MAINTENANCE_ADMIN_URL |
|
| 407 | + ); |
|
| 408 | + $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 409 | + array('action' => 'reset_db'), |
|
| 410 | + EE_MAINTENANCE_ADMIN_URL |
|
| 411 | + ); |
|
| 412 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 413 | + $this->_template_path, |
|
| 414 | + $this->_template_args, |
|
| 415 | + true |
|
| 416 | + ); |
|
| 417 | + $this->display_admin_page_with_sidebar(); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + |
|
| 422 | + protected function _reset_reservations() |
|
| 423 | + { |
|
| 424 | + if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 425 | + EE_Error::add_success( |
|
| 426 | + __( |
|
| 427 | + 'Ticket and datetime reserved counts have been successfully reset.', |
|
| 428 | + 'event_espresso' |
|
| 429 | + ) |
|
| 430 | + ); |
|
| 431 | + } else { |
|
| 432 | + EE_Error::add_success( |
|
| 433 | + __( |
|
| 434 | + 'Ticket and datetime reserved counts were correct and did not need resetting.', |
|
| 435 | + 'event_espresso' |
|
| 436 | + ) |
|
| 437 | + ); |
|
| 438 | + } |
|
| 439 | + $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + protected function _reset_capabilities() |
|
| 445 | + { |
|
| 446 | + EE_Registry::instance()->CAP->init_caps(true); |
|
| 447 | + EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', |
|
| 448 | + 'event_espresso')); |
|
| 449 | + $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + |
|
| 453 | + |
|
| 454 | + /** |
|
| 455 | + * resets the DMSs so we can attempt to continue migrating after a fatal error |
|
| 456 | + * (only a good idea when someone has somehow tried ot fix whatever caused |
|
| 457 | + * the fatal error in teh first place) |
|
| 458 | + */ |
|
| 459 | + protected function _reattempt_migration() |
|
| 460 | + { |
|
| 461 | + EE_Data_Migration_Manager::instance()->reattempt(); |
|
| 462 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * shows the big ol' System Information page |
|
| 469 | + */ |
|
| 470 | + public function _system_status() |
|
| 471 | + { |
|
| 472 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 473 | + $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
|
| 474 | + $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 475 | + array( |
|
| 476 | + 'action' => 'download_system_status', |
|
| 477 | + ), |
|
| 478 | + EE_MAINTENANCE_ADMIN_URL |
|
| 479 | + ); |
|
| 480 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 481 | + $this->_template_args, true); |
|
| 482 | + $this->display_admin_page_with_sidebar(); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * Downloads an HTML file of the system status that can be easily stored or emailed |
|
| 487 | + */ |
|
| 488 | + public function _download_system_status() |
|
| 489 | + { |
|
| 490 | + $status_info = EEM_System_Status::instance()->get_system_stati(); |
|
| 491 | + header( 'Content-Disposition: attachment' ); |
|
| 492 | + header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 493 | + echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
|
| 494 | + echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 495 | + echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 496 | + die; |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + public function _send_migration_crash_report() |
|
| 502 | + { |
|
| 503 | + $from = $this->_req_data['from']; |
|
| 504 | + $from_name = $this->_req_data['from_name']; |
|
| 505 | + $body = $this->_req_data['body']; |
|
| 506 | + try { |
|
| 507 | + $success = wp_mail(EE_SUPPORT_EMAIL, |
|
| 508 | + 'Migration Crash Report', |
|
| 509 | + $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 510 | + array( |
|
| 511 | + "from:$from_name<$from>", |
|
| 512 | + // 'content-type:text/html charset=UTF-8' |
|
| 513 | + )); |
|
| 514 | + } catch (Exception $e) { |
|
| 515 | + $success = false; |
|
| 516 | + } |
|
| 517 | + $this->_redirect_after_action($success, esc_html__("Migration Crash Report", "event_espresso"), |
|
| 518 | + esc_html__("sent", "event_espresso"), |
|
| 519 | + array('success' => $success, 'action' => 'confirm_migration_crash_report_sent')); |
|
| 520 | + } |
|
| 521 | + |
|
| 522 | + |
|
| 523 | + |
|
| 524 | + public function _confirm_migration_crash_report_sent() |
|
| 525 | + { |
|
| 526 | + try { |
|
| 527 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true); |
|
| 528 | + } catch (EE_Error $e) { |
|
| 529 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage()); |
|
| 530 | + //now, just so we can display the page correctly, make a error migration script stage object |
|
| 531 | + //and also put the error on it. It only persists for the duration of this request |
|
| 532 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0(); |
|
| 533 | + $most_recent_migration->add_error($e->getMessage()); |
|
| 534 | + } |
|
| 535 | + $success = $this->_req_data['success'] == '1' ? true : false; |
|
| 536 | + $this->_template_args['success'] = $success; |
|
| 537 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; |
|
| 538 | + $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'), |
|
| 539 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 540 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'), |
|
| 541 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 542 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
|
| 543 | + EE_MAINTENANCE_ADMIN_URL); |
|
| 544 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 545 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
|
| 546 | + $this->_template_args, true); |
|
| 547 | + $this->display_admin_page_with_sidebar(); |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + |
|
| 552 | + /** |
|
| 553 | + * Resets the entire EE4 database. |
|
| 554 | + * Currently basically only sets up ee4 database for a fresh install- doesn't |
|
| 555 | + * actually clean out the old wp options, or cpts (although does erase old ee table data) |
|
| 556 | + * |
|
| 557 | + * @param boolean $nuke_old_ee4_data controls whether or not we |
|
| 558 | + * destroy the old ee4 data, or just try initializing ee4 default data |
|
| 559 | + */ |
|
| 560 | + public function _reset_db($nuke_old_ee4_data = true) |
|
| 561 | + { |
|
| 562 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 563 | + if ($nuke_old_ee4_data) { |
|
| 564 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 565 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 566 | + EEH_Activation::remove_cron_tasks(); |
|
| 567 | + } |
|
| 568 | + //make sure when we reset the registry's config that it |
|
| 569 | + //switches to using the new singleton |
|
| 570 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true); |
|
| 571 | + EE_System::instance()->initialize_db_if_no_migrations_required(true); |
|
| 572 | + EE_System::instance()->redirect_to_about_ee(); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Deletes ALL EE tables, Records, and Options from the database. |
|
| 579 | + */ |
|
| 580 | + public function _delete_db() |
|
| 581 | + { |
|
| 582 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 583 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 584 | + EEH_Activation::delete_all_espresso_tables_and_data(); |
|
| 585 | + EEH_Activation::remove_cron_tasks(); |
|
| 586 | + EEH_Activation::deactivate_event_espresso(); |
|
| 587 | + wp_safe_redirect(admin_url('plugins.php')); |
|
| 588 | + exit; |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * sets up EE4 to rerun the migrations from ee3 to ee4 |
|
| 595 | + */ |
|
| 596 | + public function _rerun_migration_from_ee3() |
|
| 597 | + { |
|
| 598 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance); |
|
| 599 | + EEH_Activation::delete_all_espresso_cpt_data(); |
|
| 600 | + EEH_Activation::delete_all_espresso_tables_and_data(false); |
|
| 601 | + //set the db state to something that will require migrations |
|
| 602 | + update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0'); |
|
| 603 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance); |
|
| 604 | + $this->_redirect_after_action(true, esc_html__("Database", 'event_espresso'), esc_html__("reset", 'event_espresso')); |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + |
|
| 608 | + |
|
| 609 | + //none of the below group are currently used for Gateway Settings |
|
| 610 | + protected function _add_screen_options() |
|
| 611 | + { |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + |
|
| 616 | + protected function _add_feature_pointers() |
|
| 617 | + { |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | 620 | |
| 621 | 621 | |
| 622 | - public function admin_init() |
|
| 623 | - { |
|
| 624 | - } |
|
| 625 | - |
|
| 626 | - |
|
| 627 | - |
|
| 628 | - public function admin_notices() |
|
| 629 | - { |
|
| 630 | - } |
|
| 631 | - |
|
| 622 | + public function admin_init() |
|
| 623 | + { |
|
| 624 | + } |
|
| 625 | + |
|
| 626 | + |
|
| 627 | + |
|
| 628 | + public function admin_notices() |
|
| 629 | + { |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | 632 | |
| 633 | 633 | |
| 634 | - public function admin_footer_scripts() |
|
| 635 | - { |
|
| 636 | - } |
|
| 634 | + public function admin_footer_scripts() |
|
| 635 | + { |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | |
| 639 | 639 | |
| 640 | - public function load_scripts_styles() |
|
| 641 | - { |
|
| 642 | - wp_enqueue_script('ee_admin_js'); |
|
| 640 | + public function load_scripts_styles() |
|
| 641 | + { |
|
| 642 | + wp_enqueue_script('ee_admin_js'); |
|
| 643 | 643 | // wp_enqueue_media(); |
| 644 | 644 | // wp_enqueue_script('media-upload'); |
| 645 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 646 | - EVENT_ESPRESSO_VERSION, true); |
|
| 647 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 648 | - EVENT_ESPRESSO_VERSION); |
|
| 649 | - wp_enqueue_style('espresso_maintenance'); |
|
| 650 | - } |
|
| 645 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 646 | + EVENT_ESPRESSO_VERSION, true); |
|
| 647 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 648 | + EVENT_ESPRESSO_VERSION); |
|
| 649 | + wp_enqueue_style('espresso_maintenance'); |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | 652 | |
| 653 | 653 | |
| 654 | - public function load_scripts_styles_default() |
|
| 655 | - { |
|
| 656 | - //styles |
|
| 654 | + public function load_scripts_styles_default() |
|
| 655 | + { |
|
| 656 | + //styles |
|
| 657 | 657 | // wp_enqueue_style('ee-text-links'); |
| 658 | 658 | // //scripts |
| 659 | 659 | // wp_enqueue_script('ee-text-links'); |
| 660 | - } |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | 662 | |
| 663 | 663 | |
@@ -244,13 +244,13 @@ discard block |
||
| 244 | 244 | && $most_recent_migration->is_broken() |
| 245 | 245 | ) |
| 246 | 246 | ) { |
| 247 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php'; |
|
| 247 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php'; |
|
| 248 | 248 | $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/'; |
| 249 | 249 | $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', |
| 250 | 250 | 'success' => '0', |
| 251 | 251 | ), EE_MAINTENANCE_ADMIN_URL); |
| 252 | 252 | } elseif ($addons_should_be_upgraded_first) { |
| 253 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php'; |
|
| 253 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php'; |
|
| 254 | 254 | } else { |
| 255 | 255 | if ($most_recent_migration |
| 256 | 256 | && $most_recent_migration instanceof EE_Data_Migration_Script_Base |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $this->_template_args['current_db_state'] = null; |
| 281 | 281 | $this->_template_args['next_db_state'] = null; |
| 282 | 282 | } |
| 283 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php'; |
|
| 283 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php'; |
|
| 284 | 284 | $this->_template_args = array_merge( |
| 285 | 285 | $this->_template_args, |
| 286 | 286 | array( |
@@ -319,13 +319,13 @@ discard block |
||
| 319 | 319 | 'status_completed' => EE_Data_Migration_Manager::status_completed, |
| 320 | 320 | )); |
| 321 | 321 | } |
| 322 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration |
|
| 322 | + $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration |
|
| 323 | 323 | //now render the migration options part, and put it in a variable |
| 324 | 324 | $migration_options_template_file = apply_filters( |
| 325 | 325 | 'FHEE__ee_migration_page__migration_options_template', |
| 326 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php' |
|
| 326 | + EE_MAINTENANCE_TEMPLATE_PATH.'migration_options_from_ee4.template.php' |
|
| 327 | 327 | ); |
| 328 | - $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args,true); |
|
| 328 | + $migration_options_html = EEH_Template::display_template($migration_options_template_file, $this->_template_args, true); |
|
| 329 | 329 | $this->_template_args['migration_options_html'] = $migration_options_html; |
| 330 | 330 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 331 | 331 | $this->_template_args, true); |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | public function _data_reset_and_delete() |
| 386 | 386 | { |
| 387 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php'; |
|
| 387 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php'; |
|
| 388 | 388 | $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button( |
| 389 | 389 | 'reset_reservations', |
| 390 | 390 | 'reset_reservations', |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | protected function _reset_reservations() |
| 423 | 423 | { |
| 424 | - if(\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 424 | + if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { |
|
| 425 | 425 | EE_Error::add_success( |
| 426 | 426 | __( |
| 427 | 427 | 'Ticket and datetime reserved counts have been successfully reset.', |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | */ |
| 470 | 470 | public function _system_status() |
| 471 | 471 | { |
| 472 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php'; |
|
| 472 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php'; |
|
| 473 | 473 | $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati(); |
| 474 | 474 | $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce( |
| 475 | 475 | array( |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | public function _download_system_status() |
| 489 | 489 | { |
| 490 | 490 | $status_info = EEM_System_Status::instance()->get_system_stati(); |
| 491 | - header( 'Content-Disposition: attachment' ); |
|
| 492 | - header( "Content-Disposition: attachment; filename=system_status_" . sanitize_key( site_url() ) . ".html" ); |
|
| 491 | + header('Content-Disposition: attachment'); |
|
| 492 | + header("Content-Disposition: attachment; filename=system_status_".sanitize_key(site_url()).".html"); |
|
| 493 | 493 | echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; |
| 494 | - echo "<h1>System Information for " . site_url() . "</h1>"; |
|
| 495 | - echo EEH_Template::layout_array_as_table( $status_info ); |
|
| 494 | + echo "<h1>System Information for ".site_url()."</h1>"; |
|
| 495 | + echo EEH_Template::layout_array_as_table($status_info); |
|
| 496 | 496 | die; |
| 497 | 497 | } |
| 498 | 498 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | try { |
| 507 | 507 | $success = wp_mail(EE_SUPPORT_EMAIL, |
| 508 | 508 | 'Migration Crash Report', |
| 509 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 509 | + $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true), |
|
| 510 | 510 | array( |
| 511 | 511 | "from:$from_name<$from>", |
| 512 | 512 | // 'content-type:text/html charset=UTF-8' |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | EE_MAINTENANCE_ADMIN_URL); |
| 542 | 542 | $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), |
| 543 | 543 | EE_MAINTENANCE_ADMIN_URL); |
| 544 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 544 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php'; |
|
| 545 | 545 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, |
| 546 | 546 | $this->_template_args, true); |
| 547 | 547 | $this->display_admin_page_with_sidebar(); |
@@ -642,9 +642,9 @@ discard block |
||
| 642 | 642 | wp_enqueue_script('ee_admin_js'); |
| 643 | 643 | // wp_enqueue_media(); |
| 644 | 644 | // wp_enqueue_script('media-upload'); |
| 645 | - wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'), |
|
| 645 | + wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), |
|
| 646 | 646 | EVENT_ESPRESSO_VERSION, true); |
| 647 | - wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), |
|
| 647 | + wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), |
|
| 648 | 648 | EVENT_ESPRESSO_VERSION); |
| 649 | 649 | wp_enqueue_style('espresso_maintenance'); |
| 650 | 650 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | public function __construct($generator) |
| 40 | 40 | { |
| 41 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 41 | + if ( ! ($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 42 | 42 | throw new InvalidArgumentException( |
| 43 | 43 | esc_html__( |
| 44 | 44 | 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | /** |
| 34 | 34 | * CoreLoader constructor. |
| 35 | 35 | * |
| 36 | - * @param EE_Registry|CoffeeShop $generator |
|
| 36 | + * @param EE_Registry $generator |
|
| 37 | 37 | * @throws InvalidArgumentException |
| 38 | 38 | */ |
| 39 | 39 | public function __construct($generator) |
@@ -23,58 +23,58 @@ |
||
| 23 | 23 | class CoreLoader implements LoaderDecoratorInterface |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var EE_Registry|CoffeeShop $generator |
|
| 28 | - */ |
|
| 29 | - private $generator; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * CoreLoader constructor. |
|
| 35 | - * |
|
| 36 | - * @param EE_Registry|CoffeeShop $generator |
|
| 37 | - * @throws InvalidArgumentException |
|
| 38 | - */ |
|
| 39 | - public function __construct($generator) |
|
| 40 | - { |
|
| 41 | - if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 42 | - throw new InvalidArgumentException( |
|
| 43 | - esc_html__( |
|
| 44 | - 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
| 45 | - 'event_espresso' |
|
| 46 | - ) |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - $this->generator = $generator; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @param string $fqcn |
|
| 56 | - * @param array $arguments |
|
| 57 | - * @return mixed |
|
| 58 | - * @throws ServiceNotFoundException |
|
| 59 | - */ |
|
| 60 | - public function load($fqcn, $arguments = array()) |
|
| 61 | - { |
|
| 62 | - return $this->generator instanceof EE_Registry |
|
| 63 | - ? $this->generator->create($fqcn, $arguments) |
|
| 64 | - : $this->generator->brew($fqcn, $arguments); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * calls reset() on generator if method exists |
|
| 71 | - */ |
|
| 72 | - public function reset() |
|
| 73 | - { |
|
| 74 | - if (method_exists($this->generator, 'reset')) { |
|
| 75 | - $this->generator->reset(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 26 | + /** |
|
| 27 | + * @var EE_Registry|CoffeeShop $generator |
|
| 28 | + */ |
|
| 29 | + private $generator; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * CoreLoader constructor. |
|
| 35 | + * |
|
| 36 | + * @param EE_Registry|CoffeeShop $generator |
|
| 37 | + * @throws InvalidArgumentException |
|
| 38 | + */ |
|
| 39 | + public function __construct($generator) |
|
| 40 | + { |
|
| 41 | + if(!($generator instanceof EE_Registry || $generator instanceof CoffeeShop)) { |
|
| 42 | + throw new InvalidArgumentException( |
|
| 43 | + esc_html__( |
|
| 44 | + 'The CoreLoader class must receive an instance of EE_Registry or the CoffeeShop DI container.', |
|
| 45 | + 'event_espresso' |
|
| 46 | + ) |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + $this->generator = $generator; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @param string $fqcn |
|
| 56 | + * @param array $arguments |
|
| 57 | + * @return mixed |
|
| 58 | + * @throws ServiceNotFoundException |
|
| 59 | + */ |
|
| 60 | + public function load($fqcn, $arguments = array()) |
|
| 61 | + { |
|
| 62 | + return $this->generator instanceof EE_Registry |
|
| 63 | + ? $this->generator->create($fqcn, $arguments) |
|
| 64 | + : $this->generator->brew($fqcn, $arguments); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * calls reset() on generator if method exists |
|
| 71 | + */ |
|
| 72 | + public function reset() |
|
| 73 | + { |
|
| 74 | + if (method_exists($this->generator, 'reset')) { |
|
| 75 | + $this->generator->reset(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | // End of file CoreLoader.php |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\services\collections; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @param mixed $identifier |
| 28 | 28 | * @return bool |
| 29 | 29 | */ |
| 30 | - public function add( $object, $identifier = null ); |
|
| 30 | + public function add($object, $identifier = null); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * setIdentifier |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param mixed $identifier |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function setIdentifier( $object, $identifier = null ); |
|
| 42 | + public function setIdentifier($object, $identifier = null); |
|
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * get |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param mixed $identifier |
| 51 | 51 | * @return mixed |
| 52 | 52 | */ |
| 53 | - public function get( $identifier ); |
|
| 53 | + public function get($identifier); |
|
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * has |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param mixed $identifier |
| 63 | 63 | * @return bool |
| 64 | 64 | */ |
| 65 | - public function has( $identifier ); |
|
| 65 | + public function has($identifier); |
|
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | 68 | * hasObject |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param $object |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public function hasObject( $object ); |
|
| 75 | + public function hasObject($object); |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * remove |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param $object |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - public function remove( $object ); |
|
| 85 | + public function remove($object); |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * setCurrent |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param mixed $identifier |
| 93 | 93 | * @return boolean |
| 94 | 94 | */ |
| 95 | - public function setCurrent( $identifier ) ; |
|
| 95 | + public function setCurrent($identifier); |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * setCurrentUsingObject |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param $object |
| 103 | 103 | * @return boolean |
| 104 | 104 | */ |
| 105 | - public function setCurrentUsingObject( $object ); |
|
| 105 | + public function setCurrentUsingObject($object); |
|
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Returns the object occupying the index before the current object, |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param $object |
| 120 | 120 | * @return boolean|int|string |
| 121 | 121 | */ |
| 122 | - public function indexOf( $object ); |
|
| 122 | + public function indexOf($object); |
|
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param $index |
| 130 | 130 | * @return mixed |
| 131 | 131 | */ |
| 132 | - public function objectAtIndex( $index ); |
|
| 132 | + public function objectAtIndex($index); |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * Returns the sequence of objects as specified by the offset and length |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param int $length |
| 140 | 140 | * @return array |
| 141 | 141 | */ |
| 142 | - public function slice( $offset, $length ); |
|
| 142 | + public function slice($offset, $length); |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Inserts an object (or an array of objects) at a certain point |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param mixed $objects A single object or an array of objects |
| 149 | 149 | * @param integer $index |
| 150 | 150 | */ |
| 151 | - public function insertAt( $objects, $index ); |
|
| 151 | + public function insertAt($objects, $index); |
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * Removes the object at the given index |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @see http://stackoverflow.com/a/8736013 |
| 157 | 157 | * @param integer $index |
| 158 | 158 | */ |
| 159 | - public function removeAt( $index ) ; |
|
| 159 | + public function removeAt($index); |
|
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | public function previous(); |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | - * Returns the index of a given object, or false if not found |
|
| 117 | - * |
|
| 118 | - * @see http://stackoverflow.com/a/8736013 |
|
| 119 | - * @param $object |
|
| 120 | - * @return boolean|int|string |
|
| 121 | - */ |
|
| 116 | + * Returns the index of a given object, or false if not found |
|
| 117 | + * |
|
| 118 | + * @see http://stackoverflow.com/a/8736013 |
|
| 119 | + * @param $object |
|
| 120 | + * @return boolean|int|string |
|
| 121 | + */ |
|
| 122 | 122 | public function indexOf( $object ); |
| 123 | 123 | |
| 124 | 124 | |
@@ -160,10 +160,10 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - /** |
|
| 164 | - * detaches ALL objects from the Collection |
|
| 165 | - */ |
|
| 166 | - public function detachAll(); |
|
| 163 | + /** |
|
| 164 | + * detaches ALL objects from the Collection |
|
| 165 | + */ |
|
| 166 | + public function detachAll(); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | // End of file CollectionInterface.php |
@@ -83,7 +83,6 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * setIdentifier |
| 86 | - |
|
| 87 | 86 | * Sets the data associated with an object in the Collection |
| 88 | 87 | * if no $identifier is supplied, then the spl_object_hash() is used |
| 89 | 88 | * |
@@ -352,18 +351,18 @@ discard block |
||
| 352 | 351 | |
| 353 | 352 | |
| 354 | 353 | |
| 355 | - /** |
|
| 356 | - * detaches ALL objects from the Collection |
|
| 357 | - */ |
|
| 358 | - public function detachAll() |
|
| 359 | - { |
|
| 360 | - $this->rewind(); |
|
| 361 | - while ($this->valid()) { |
|
| 362 | - $object = $this->current(); |
|
| 363 | - $this->next(); |
|
| 364 | - $this->detach($object); |
|
| 365 | - } |
|
| 366 | - } |
|
| 354 | + /** |
|
| 355 | + * detaches ALL objects from the Collection |
|
| 356 | + */ |
|
| 357 | + public function detachAll() |
|
| 358 | + { |
|
| 359 | + $this->rewind(); |
|
| 360 | + while ($this->valid()) { |
|
| 361 | + $object = $this->current(); |
|
| 362 | + $this->next(); |
|
| 363 | + $this->detach($object); |
|
| 364 | + } |
|
| 365 | + } |
|
| 367 | 366 | |
| 368 | 367 | |
| 369 | 368 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * by calling EE_Object_Collection::set_identifier() |
| 66 | 66 | * |
| 67 | 67 | * @access public |
| 68 | - * @param $object |
|
| 68 | + * @param \EventEspresso\core\services\progress_steps\ProgressStep $object |
|
| 69 | 69 | * @param mixed $identifier |
| 70 | 70 | * @return bool |
| 71 | 71 | * @throws \EventEspresso\core\exceptions\InvalidEntityException |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * advances pointer to the provided object |
| 212 | 212 | * |
| 213 | 213 | * @access public |
| 214 | - * @param $object |
|
| 214 | + * @param \EventEspresso\core\libraries\form_sections\form_handlers\SequentialStepForm $object |
|
| 215 | 215 | * @return boolean |
| 216 | 216 | */ |
| 217 | 217 | public function setCurrentUsingObject( $object ) { |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @see http://stackoverflow.com/a/8736013 |
| 251 | 251 | * @param $object |
| 252 | - * @return boolean|int|string |
|
| 252 | + * @return integer |
|
| 253 | 253 | */ |
| 254 | 254 | public function indexOf( $object ) { |
| 255 | 255 | if ( ! $this->contains( $object ) ) { |
@@ -102,17 +102,17 @@ |
||
| 102 | 102 | $fqcn = ltrim($fqcn, '\\'); |
| 103 | 103 | // caching can be turned off via the following code: |
| 104 | 104 | // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
| 105 | - if( |
|
| 105 | + if ( |
|
| 106 | 106 | apply_filters( |
| 107 | 107 | 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
| 108 | 108 | false, |
| 109 | 109 | $this |
| 110 | 110 | ) |
| 111 | - ){ |
|
| 111 | + ) { |
|
| 112 | 112 | return $this->loader->load($fqcn, $arguments); |
| 113 | 113 | } |
| 114 | - $identifier = md5($fqcn . serialize($arguments)); |
|
| 115 | - if($this->cache->has($identifier)){ |
|
| 114 | + $identifier = md5($fqcn.serialize($arguments)); |
|
| 115 | + if ($this->cache->has($identifier)) { |
|
| 116 | 116 | return $this->cache->get($identifier); |
| 117 | 117 | } |
| 118 | 118 | $object = $this->loader->load($fqcn, $arguments); |
@@ -22,114 +22,114 @@ |
||
| 22 | 22 | class CachingLoader extends LoaderDecorator |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var CollectionInterface $cache |
|
| 27 | - */ |
|
| 28 | - protected $cache; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var string $identifier |
|
| 32 | - */ |
|
| 33 | - protected $identifier; |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * CachingLoader constructor. |
|
| 39 | - * |
|
| 40 | - * @param LoaderDecoratorInterface $loader |
|
| 41 | - * @param CollectionInterface $cache |
|
| 42 | - * @param string $identifier |
|
| 43 | - * @throws InvalidDataTypeException |
|
| 44 | - */ |
|
| 45 | - public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
| 46 | - { |
|
| 47 | - parent::__construct($loader); |
|
| 48 | - $this->cache = $cache; |
|
| 49 | - $this->setIdentifier($identifier); |
|
| 50 | - if ($this->identifier !== '') { |
|
| 51 | - // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
| 52 | - // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
| 53 | - // where "IDENTIFIER" = the string that was set during construction |
|
| 54 | - add_action( |
|
| 55 | - "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
| 56 | - array($this, 'reset') |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - // to clear ALL caches, simply do the following: |
|
| 60 | - // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
| 61 | - add_action( |
|
| 62 | - 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
| 63 | - array($this, 'reset') |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - public function identifier() |
|
| 73 | - { |
|
| 74 | - return $this->identifier; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param string $identifier |
|
| 81 | - * @throws InvalidDataTypeException |
|
| 82 | - */ |
|
| 83 | - private function setIdentifier($identifier) |
|
| 84 | - { |
|
| 85 | - if ( ! is_string($identifier)) { |
|
| 86 | - throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
| 87 | - } |
|
| 88 | - $this->identifier = $identifier; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @param string $fqcn |
|
| 95 | - * @param array $arguments |
|
| 96 | - * @return mixed |
|
| 97 | - * @throws InvalidEntityException |
|
| 98 | - * @throws ServiceNotFoundException |
|
| 99 | - */ |
|
| 100 | - public function load($fqcn, $arguments = array()) |
|
| 101 | - { |
|
| 102 | - $fqcn = ltrim($fqcn, '\\'); |
|
| 103 | - // caching can be turned off via the following code: |
|
| 104 | - // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
| 105 | - if( |
|
| 106 | - apply_filters( |
|
| 107 | - 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
| 108 | - false, |
|
| 109 | - $this |
|
| 110 | - ) |
|
| 111 | - ){ |
|
| 112 | - return $this->loader->load($fqcn, $arguments); |
|
| 113 | - } |
|
| 114 | - $identifier = md5($fqcn . serialize($arguments)); |
|
| 115 | - if($this->cache->has($identifier)){ |
|
| 116 | - return $this->cache->get($identifier); |
|
| 117 | - } |
|
| 118 | - $object = $this->loader->load($fqcn, $arguments); |
|
| 119 | - $this->cache->add($object, $identifier); |
|
| 120 | - return $object; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * empties cache and calls reset() on loader if method exists |
|
| 127 | - */ |
|
| 128 | - public function reset() |
|
| 129 | - { |
|
| 130 | - $this->cache->detachAll(); |
|
| 131 | - $this->loader->reset(); |
|
| 132 | - } |
|
| 25 | + /** |
|
| 26 | + * @var CollectionInterface $cache |
|
| 27 | + */ |
|
| 28 | + protected $cache; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var string $identifier |
|
| 32 | + */ |
|
| 33 | + protected $identifier; |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * CachingLoader constructor. |
|
| 39 | + * |
|
| 40 | + * @param LoaderDecoratorInterface $loader |
|
| 41 | + * @param CollectionInterface $cache |
|
| 42 | + * @param string $identifier |
|
| 43 | + * @throws InvalidDataTypeException |
|
| 44 | + */ |
|
| 45 | + public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
| 46 | + { |
|
| 47 | + parent::__construct($loader); |
|
| 48 | + $this->cache = $cache; |
|
| 49 | + $this->setIdentifier($identifier); |
|
| 50 | + if ($this->identifier !== '') { |
|
| 51 | + // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
| 52 | + // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
| 53 | + // where "IDENTIFIER" = the string that was set during construction |
|
| 54 | + add_action( |
|
| 55 | + "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
| 56 | + array($this, 'reset') |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + // to clear ALL caches, simply do the following: |
|
| 60 | + // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
| 61 | + add_action( |
|
| 62 | + 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
| 63 | + array($this, 'reset') |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + public function identifier() |
|
| 73 | + { |
|
| 74 | + return $this->identifier; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param string $identifier |
|
| 81 | + * @throws InvalidDataTypeException |
|
| 82 | + */ |
|
| 83 | + private function setIdentifier($identifier) |
|
| 84 | + { |
|
| 85 | + if ( ! is_string($identifier)) { |
|
| 86 | + throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
| 87 | + } |
|
| 88 | + $this->identifier = $identifier; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @param string $fqcn |
|
| 95 | + * @param array $arguments |
|
| 96 | + * @return mixed |
|
| 97 | + * @throws InvalidEntityException |
|
| 98 | + * @throws ServiceNotFoundException |
|
| 99 | + */ |
|
| 100 | + public function load($fqcn, $arguments = array()) |
|
| 101 | + { |
|
| 102 | + $fqcn = ltrim($fqcn, '\\'); |
|
| 103 | + // caching can be turned off via the following code: |
|
| 104 | + // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
| 105 | + if( |
|
| 106 | + apply_filters( |
|
| 107 | + 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
| 108 | + false, |
|
| 109 | + $this |
|
| 110 | + ) |
|
| 111 | + ){ |
|
| 112 | + return $this->loader->load($fqcn, $arguments); |
|
| 113 | + } |
|
| 114 | + $identifier = md5($fqcn . serialize($arguments)); |
|
| 115 | + if($this->cache->has($identifier)){ |
|
| 116 | + return $this->cache->get($identifier); |
|
| 117 | + } |
|
| 118 | + $object = $this->loader->load($fqcn, $arguments); |
|
| 119 | + $this->cache->add($object, $identifier); |
|
| 120 | + return $object; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * empties cache and calls reset() on loader if method exists |
|
| 127 | + */ |
|
| 128 | + public function reset() |
|
| 129 | + { |
|
| 130 | + $this->cache->detachAll(); |
|
| 131 | + $this->loader->reset(); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -19,1048 +19,1048 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * possibly truncated version of the EE core version string |
|
| 24 | - * |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - protected static $_core_version = ''; |
|
| 22 | + /** |
|
| 23 | + * possibly truncated version of the EE core version string |
|
| 24 | + * |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + protected static $_core_version = ''; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Holds values for registered addons |
|
| 31 | - * |
|
| 32 | - * @var array |
|
| 33 | - */ |
|
| 34 | - protected static $_settings = array(); |
|
| 29 | + /** |
|
| 30 | + * Holds values for registered addons |
|
| 31 | + * |
|
| 32 | + * @var array |
|
| 33 | + */ |
|
| 34 | + protected static $_settings = array(); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array $_incompatible_addons keys are addon SLUGS |
|
| 38 | - * (first argument passed to EE_Register_Addon::register()), keys are |
|
| 39 | - * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
| 40 | - * Generally this should be used sparingly, as we don't want to muddle up |
|
| 41 | - * EE core with knowledge of ALL the addons out there. |
|
| 42 | - * If you want NO versions of an addon to run with a certain version of core, |
|
| 43 | - * it's usually best to define the addon's "min_core_version" as part of its call |
|
| 44 | - * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
| 45 | - * minimum plugin version. |
|
| 46 | - * @access protected |
|
| 47 | - */ |
|
| 48 | - protected static $_incompatible_addons = array( |
|
| 49 | - 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
| 50 | - 'Promotions' => '1.0.0.rc.084', |
|
| 51 | - ); |
|
| 36 | + /** |
|
| 37 | + * @var array $_incompatible_addons keys are addon SLUGS |
|
| 38 | + * (first argument passed to EE_Register_Addon::register()), keys are |
|
| 39 | + * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
| 40 | + * Generally this should be used sparingly, as we don't want to muddle up |
|
| 41 | + * EE core with knowledge of ALL the addons out there. |
|
| 42 | + * If you want NO versions of an addon to run with a certain version of core, |
|
| 43 | + * it's usually best to define the addon's "min_core_version" as part of its call |
|
| 44 | + * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
| 45 | + * minimum plugin version. |
|
| 46 | + * @access protected |
|
| 47 | + */ |
|
| 48 | + protected static $_incompatible_addons = array( |
|
| 49 | + 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
| 50 | + 'Promotions' => '1.0.0.rc.084', |
|
| 51 | + ); |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * We should always be comparing core to a version like '4.3.0.rc.000', |
|
| 56 | - * not just '4.3.0'. |
|
| 57 | - * So if the addon developer doesn't provide that full version string, |
|
| 58 | - * fill in the blanks for them |
|
| 59 | - * |
|
| 60 | - * @param string $min_core_version |
|
| 61 | - * @return string always like '4.3.0.rc.000' |
|
| 62 | - */ |
|
| 63 | - protected static function _effective_version($min_core_version) |
|
| 64 | - { |
|
| 65 | - // versions: 4 . 3 . 1 . p . 123 |
|
| 66 | - // offsets: 0 . 1 . 2 . 3 . 4 |
|
| 67 | - $version_parts = explode('.', $min_core_version); |
|
| 68 | - //check they specified the micro version (after 2nd period) |
|
| 69 | - if (! isset($version_parts[2])) { |
|
| 70 | - $version_parts[2] = '0'; |
|
| 71 | - } |
|
| 72 | - //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
| 73 | - //soon we can assume that's 'rc', but this current version is 'alpha' |
|
| 74 | - if (! isset($version_parts[3])) { |
|
| 75 | - $version_parts[3] = 'dev'; |
|
| 76 | - } |
|
| 77 | - if (! isset($version_parts[4])) { |
|
| 78 | - $version_parts[4] = '000'; |
|
| 79 | - } |
|
| 80 | - return implode('.', $version_parts); |
|
| 81 | - } |
|
| 54 | + /** |
|
| 55 | + * We should always be comparing core to a version like '4.3.0.rc.000', |
|
| 56 | + * not just '4.3.0'. |
|
| 57 | + * So if the addon developer doesn't provide that full version string, |
|
| 58 | + * fill in the blanks for them |
|
| 59 | + * |
|
| 60 | + * @param string $min_core_version |
|
| 61 | + * @return string always like '4.3.0.rc.000' |
|
| 62 | + */ |
|
| 63 | + protected static function _effective_version($min_core_version) |
|
| 64 | + { |
|
| 65 | + // versions: 4 . 3 . 1 . p . 123 |
|
| 66 | + // offsets: 0 . 1 . 2 . 3 . 4 |
|
| 67 | + $version_parts = explode('.', $min_core_version); |
|
| 68 | + //check they specified the micro version (after 2nd period) |
|
| 69 | + if (! isset($version_parts[2])) { |
|
| 70 | + $version_parts[2] = '0'; |
|
| 71 | + } |
|
| 72 | + //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
| 73 | + //soon we can assume that's 'rc', but this current version is 'alpha' |
|
| 74 | + if (! isset($version_parts[3])) { |
|
| 75 | + $version_parts[3] = 'dev'; |
|
| 76 | + } |
|
| 77 | + if (! isset($version_parts[4])) { |
|
| 78 | + $version_parts[4] = '000'; |
|
| 79 | + } |
|
| 80 | + return implode('.', $version_parts); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Returns whether or not the min core version requirement of the addon is met |
|
| 86 | - * |
|
| 87 | - * @param string $min_core_version the minimum core version required by the addon |
|
| 88 | - * @param string $actual_core_version the actual core version, optional |
|
| 89 | - * @return boolean |
|
| 90 | - */ |
|
| 91 | - public static function _meets_min_core_version_requirement( |
|
| 92 | - $min_core_version, |
|
| 93 | - $actual_core_version = EVENT_ESPRESSO_VERSION |
|
| 94 | - ) { |
|
| 95 | - return version_compare( |
|
| 96 | - self::_effective_version($actual_core_version), |
|
| 97 | - self::_effective_version($min_core_version), |
|
| 98 | - '>=' |
|
| 99 | - ); |
|
| 100 | - } |
|
| 84 | + /** |
|
| 85 | + * Returns whether or not the min core version requirement of the addon is met |
|
| 86 | + * |
|
| 87 | + * @param string $min_core_version the minimum core version required by the addon |
|
| 88 | + * @param string $actual_core_version the actual core version, optional |
|
| 89 | + * @return boolean |
|
| 90 | + */ |
|
| 91 | + public static function _meets_min_core_version_requirement( |
|
| 92 | + $min_core_version, |
|
| 93 | + $actual_core_version = EVENT_ESPRESSO_VERSION |
|
| 94 | + ) { |
|
| 95 | + return version_compare( |
|
| 96 | + self::_effective_version($actual_core_version), |
|
| 97 | + self::_effective_version($min_core_version), |
|
| 98 | + '>=' |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Method for registering new EE_Addons. |
|
| 105 | - * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
| 106 | - * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
| 107 | - * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
| 108 | - * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
| 109 | - * 'activate_plugin', it registers the addon still, but its components are not registered |
|
| 110 | - * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
| 111 | - * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
| 112 | - * (so that we can detect that the addon has activated on the subsequent request) |
|
| 113 | - * |
|
| 114 | - * @since 4.3.0 |
|
| 115 | - * @param string $addon_name the EE_Addon's name. Required. |
|
| 116 | - * @param array $setup_args { An |
|
| 117 | - * array of arguments provided for registering |
|
| 118 | - * the message type. |
|
| 119 | - * @type string $class_name the addon's main file name. |
|
| 120 | - * If left blank, generated from the addon |
|
| 121 | - * name, changes something like "calendar" to |
|
| 122 | - * "EE_Calendar" |
|
| 123 | - * @type string $min_core_version the minimum version of EE Core that the |
|
| 124 | - * addon will work with. eg "4.8.1.rc.084" |
|
| 125 | - * @type string $version the "software" version for the addon. eg |
|
| 126 | - * "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress |
|
| 127 | - * @type string $main_file_path the full server path to the main file |
|
| 128 | - * loaded |
|
| 129 | - * directly by WP |
|
| 130 | - * @type string $admin_path full server path to the folder where the |
|
| 131 | - * addon\'s admin files reside |
|
| 132 | - * @type string $admin_callback a method to be called when the EE Admin is |
|
| 133 | - * first invoked, can be used for hooking into any admin page |
|
| 134 | - * @type string $config_section the section name for this addon's |
|
| 135 | - * configuration settings section (defaults to "addons") |
|
| 136 | - * @type string $config_class the class name for this addon's |
|
| 137 | - * configuration settings object |
|
| 138 | - * @type string $config_name the class name for this addon's |
|
| 139 | - * configuration settings object |
|
| 140 | - * @type string $autoloader_paths an array of class names and the full server |
|
| 141 | - * paths to those files. Required. |
|
| 142 | - * @type string $autoloader_folders an array of "full server paths" for any |
|
| 143 | - * folders containing classes that might be invoked by the addon |
|
| 144 | - * @type string $dms_paths an array of full server paths to folders |
|
| 145 | - * that contain data migration scripts. Required. |
|
| 146 | - * @type string $module_paths an array of full server paths to any |
|
| 147 | - * EED_Modules used by the addon |
|
| 148 | - * @type string $shortcode_paths an array of full server paths to folders |
|
| 149 | - * that contain EES_Shortcodes |
|
| 150 | - * @type string $widget_paths an array of full server paths to folders |
|
| 151 | - * that contain WP_Widgets |
|
| 152 | - * @type string $pue_options |
|
| 153 | - * @type array $capabilities an array indexed by role name |
|
| 154 | - * (i.e administrator,author ) and the values |
|
| 155 | - * are an array of caps to add to the role. |
|
| 156 | - * 'administrator' => array( |
|
| 157 | - * 'read_addon', 'edit_addon', etc. |
|
| 158 | - * ). |
|
| 159 | - * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
| 160 | - * for any addons that need to register any special meta mapped capabilities. Should be indexed where the |
|
| 161 | - * key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class. |
|
| 162 | - * @type array $model_paths array of folders containing DB models |
|
| 163 | - * @see EE_Register_Model |
|
| 164 | - * @type array $class_paths array of folders containing DB classes |
|
| 165 | - * @see EE_Register_Model |
|
| 166 | - * @type array $model_extension_paths array of folders containing DB model |
|
| 167 | - * extensions |
|
| 168 | - * @see EE_Register_Model_Extension |
|
| 169 | - * @type array $class_extension_paths array of folders containing DB class |
|
| 170 | - * extensions |
|
| 171 | - * @see EE_Register_Model_Extension |
|
| 172 | - * @type array message_types { |
|
| 173 | - * An array of message types with the key as |
|
| 174 | - * the message type name and the values as |
|
| 175 | - * below: |
|
| 176 | - * @type string $mtfilename The filename of the message type being |
|
| 177 | - * registered. This will be the main EE_{Messagetype_Name}_message_type class. |
|
| 178 | - * (eg. |
|
| 179 | - * EE_Declined_Registration_message_type.class.php) |
|
| 180 | - * Required. |
|
| 181 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
| 182 | - * autoloader for the new message type. |
|
| 183 | - * Required. |
|
| 184 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
| 185 | - * type should activate with. Each value in |
|
| 186 | - * the |
|
| 187 | - * array |
|
| 188 | - * should match the name property of a |
|
| 189 | - * EE_messenger. Optional. |
|
| 190 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
| 191 | - * type should validate with. Each value in |
|
| 192 | - * the |
|
| 193 | - * array |
|
| 194 | - * should match the name property of an |
|
| 195 | - * EE_messenger. |
|
| 196 | - * Optional. |
|
| 197 | - * } |
|
| 198 | - * @type array $custom_post_types |
|
| 199 | - * @type array $custom_taxonomies |
|
| 200 | - * @type array $payment_method_paths each element is the folder containing the |
|
| 201 | - * EE_PMT_Base child class |
|
| 202 | - * (eg, |
|
| 203 | - * '/wp-content/plugins/my_plugin/Payomatic/' |
|
| 204 | - * which contains the files |
|
| 205 | - * EE_PMT_Payomatic.pm.php) |
|
| 206 | - * @type array $default_terms |
|
| 207 | - * @type array $namespace { |
|
| 208 | - * An array with two items for registering the |
|
| 209 | - * addon's namespace. (If, for some reason, |
|
| 210 | - * you |
|
| 211 | - * require additional namespaces, use |
|
| 212 | - * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 213 | - * directly) |
|
| 214 | - * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 215 | - * @type string $FQNS the namespace prefix |
|
| 216 | - * @type string $DIR a base directory for class files in the |
|
| 217 | - * namespace. |
|
| 218 | - * } |
|
| 219 | - * } |
|
| 220 | - * @throws EE_Error |
|
| 221 | - * @return void |
|
| 222 | - */ |
|
| 223 | - public static function register($addon_name = '', $setup_args = array()) |
|
| 224 | - { |
|
| 225 | - // required fields MUST be present, so let's make sure they are. |
|
| 226 | - \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
| 227 | - // get class name for addon |
|
| 228 | - $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
| 229 | - //setup $_settings array from incoming values. |
|
| 230 | - $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
| 231 | - // setup PUE |
|
| 232 | - \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
| 233 | - // does this addon work with this version of core or WordPress ? |
|
| 234 | - if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 235 | - return; |
|
| 236 | - } |
|
| 237 | - // register namespaces |
|
| 238 | - \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
| 239 | - // check if this is an activation request |
|
| 240 | - if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
| 241 | - // dont bother setting up the rest of the addon atm |
|
| 242 | - return; |
|
| 243 | - } |
|
| 244 | - // we need cars |
|
| 245 | - \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
| 246 | - // register new models and extensions |
|
| 247 | - \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
| 248 | - // setup DMS |
|
| 249 | - \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
| 250 | - // if config_class is present let's register config. |
|
| 251 | - \EE_Register_Addon::_register_config($addon_name); |
|
| 252 | - // register admin pages |
|
| 253 | - \EE_Register_Addon::_register_admin_pages($addon_name); |
|
| 254 | - // add to list of modules to be registered |
|
| 255 | - \EE_Register_Addon::_register_modules($addon_name); |
|
| 256 | - // add to list of shortcodes to be registered |
|
| 257 | - \EE_Register_Addon::_register_shortcodes($addon_name); |
|
| 258 | - // add to list of widgets to be registered |
|
| 259 | - \EE_Register_Addon::_register_widgets($addon_name); |
|
| 260 | - // register capability related stuff. |
|
| 261 | - \EE_Register_Addon::_register_capabilities($addon_name); |
|
| 262 | - // any message type to register? |
|
| 263 | - \EE_Register_Addon::_register_message_types($addon_name); |
|
| 264 | - // any custom post type/ custom capabilities or default terms to register |
|
| 265 | - \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
| 266 | - // and any payment methods |
|
| 267 | - \EE_Register_Addon::_register_payment_methods($addon_name); |
|
| 268 | - // load and instantiate main addon class |
|
| 269 | - $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
| 270 | - $addon->after_registration(); |
|
| 271 | - } |
|
| 103 | + /** |
|
| 104 | + * Method for registering new EE_Addons. |
|
| 105 | + * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
| 106 | + * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
| 107 | + * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
| 108 | + * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
| 109 | + * 'activate_plugin', it registers the addon still, but its components are not registered |
|
| 110 | + * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
| 111 | + * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
| 112 | + * (so that we can detect that the addon has activated on the subsequent request) |
|
| 113 | + * |
|
| 114 | + * @since 4.3.0 |
|
| 115 | + * @param string $addon_name the EE_Addon's name. Required. |
|
| 116 | + * @param array $setup_args { An |
|
| 117 | + * array of arguments provided for registering |
|
| 118 | + * the message type. |
|
| 119 | + * @type string $class_name the addon's main file name. |
|
| 120 | + * If left blank, generated from the addon |
|
| 121 | + * name, changes something like "calendar" to |
|
| 122 | + * "EE_Calendar" |
|
| 123 | + * @type string $min_core_version the minimum version of EE Core that the |
|
| 124 | + * addon will work with. eg "4.8.1.rc.084" |
|
| 125 | + * @type string $version the "software" version for the addon. eg |
|
| 126 | + * "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress |
|
| 127 | + * @type string $main_file_path the full server path to the main file |
|
| 128 | + * loaded |
|
| 129 | + * directly by WP |
|
| 130 | + * @type string $admin_path full server path to the folder where the |
|
| 131 | + * addon\'s admin files reside |
|
| 132 | + * @type string $admin_callback a method to be called when the EE Admin is |
|
| 133 | + * first invoked, can be used for hooking into any admin page |
|
| 134 | + * @type string $config_section the section name for this addon's |
|
| 135 | + * configuration settings section (defaults to "addons") |
|
| 136 | + * @type string $config_class the class name for this addon's |
|
| 137 | + * configuration settings object |
|
| 138 | + * @type string $config_name the class name for this addon's |
|
| 139 | + * configuration settings object |
|
| 140 | + * @type string $autoloader_paths an array of class names and the full server |
|
| 141 | + * paths to those files. Required. |
|
| 142 | + * @type string $autoloader_folders an array of "full server paths" for any |
|
| 143 | + * folders containing classes that might be invoked by the addon |
|
| 144 | + * @type string $dms_paths an array of full server paths to folders |
|
| 145 | + * that contain data migration scripts. Required. |
|
| 146 | + * @type string $module_paths an array of full server paths to any |
|
| 147 | + * EED_Modules used by the addon |
|
| 148 | + * @type string $shortcode_paths an array of full server paths to folders |
|
| 149 | + * that contain EES_Shortcodes |
|
| 150 | + * @type string $widget_paths an array of full server paths to folders |
|
| 151 | + * that contain WP_Widgets |
|
| 152 | + * @type string $pue_options |
|
| 153 | + * @type array $capabilities an array indexed by role name |
|
| 154 | + * (i.e administrator,author ) and the values |
|
| 155 | + * are an array of caps to add to the role. |
|
| 156 | + * 'administrator' => array( |
|
| 157 | + * 'read_addon', 'edit_addon', etc. |
|
| 158 | + * ). |
|
| 159 | + * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
| 160 | + * for any addons that need to register any special meta mapped capabilities. Should be indexed where the |
|
| 161 | + * key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class. |
|
| 162 | + * @type array $model_paths array of folders containing DB models |
|
| 163 | + * @see EE_Register_Model |
|
| 164 | + * @type array $class_paths array of folders containing DB classes |
|
| 165 | + * @see EE_Register_Model |
|
| 166 | + * @type array $model_extension_paths array of folders containing DB model |
|
| 167 | + * extensions |
|
| 168 | + * @see EE_Register_Model_Extension |
|
| 169 | + * @type array $class_extension_paths array of folders containing DB class |
|
| 170 | + * extensions |
|
| 171 | + * @see EE_Register_Model_Extension |
|
| 172 | + * @type array message_types { |
|
| 173 | + * An array of message types with the key as |
|
| 174 | + * the message type name and the values as |
|
| 175 | + * below: |
|
| 176 | + * @type string $mtfilename The filename of the message type being |
|
| 177 | + * registered. This will be the main EE_{Messagetype_Name}_message_type class. |
|
| 178 | + * (eg. |
|
| 179 | + * EE_Declined_Registration_message_type.class.php) |
|
| 180 | + * Required. |
|
| 181 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
| 182 | + * autoloader for the new message type. |
|
| 183 | + * Required. |
|
| 184 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
| 185 | + * type should activate with. Each value in |
|
| 186 | + * the |
|
| 187 | + * array |
|
| 188 | + * should match the name property of a |
|
| 189 | + * EE_messenger. Optional. |
|
| 190 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
| 191 | + * type should validate with. Each value in |
|
| 192 | + * the |
|
| 193 | + * array |
|
| 194 | + * should match the name property of an |
|
| 195 | + * EE_messenger. |
|
| 196 | + * Optional. |
|
| 197 | + * } |
|
| 198 | + * @type array $custom_post_types |
|
| 199 | + * @type array $custom_taxonomies |
|
| 200 | + * @type array $payment_method_paths each element is the folder containing the |
|
| 201 | + * EE_PMT_Base child class |
|
| 202 | + * (eg, |
|
| 203 | + * '/wp-content/plugins/my_plugin/Payomatic/' |
|
| 204 | + * which contains the files |
|
| 205 | + * EE_PMT_Payomatic.pm.php) |
|
| 206 | + * @type array $default_terms |
|
| 207 | + * @type array $namespace { |
|
| 208 | + * An array with two items for registering the |
|
| 209 | + * addon's namespace. (If, for some reason, |
|
| 210 | + * you |
|
| 211 | + * require additional namespaces, use |
|
| 212 | + * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 213 | + * directly) |
|
| 214 | + * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 215 | + * @type string $FQNS the namespace prefix |
|
| 216 | + * @type string $DIR a base directory for class files in the |
|
| 217 | + * namespace. |
|
| 218 | + * } |
|
| 219 | + * } |
|
| 220 | + * @throws EE_Error |
|
| 221 | + * @return void |
|
| 222 | + */ |
|
| 223 | + public static function register($addon_name = '', $setup_args = array()) |
|
| 224 | + { |
|
| 225 | + // required fields MUST be present, so let's make sure they are. |
|
| 226 | + \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
| 227 | + // get class name for addon |
|
| 228 | + $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
| 229 | + //setup $_settings array from incoming values. |
|
| 230 | + $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
| 231 | + // setup PUE |
|
| 232 | + \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
| 233 | + // does this addon work with this version of core or WordPress ? |
|
| 234 | + if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 235 | + return; |
|
| 236 | + } |
|
| 237 | + // register namespaces |
|
| 238 | + \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
| 239 | + // check if this is an activation request |
|
| 240 | + if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
| 241 | + // dont bother setting up the rest of the addon atm |
|
| 242 | + return; |
|
| 243 | + } |
|
| 244 | + // we need cars |
|
| 245 | + \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
| 246 | + // register new models and extensions |
|
| 247 | + \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
| 248 | + // setup DMS |
|
| 249 | + \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
| 250 | + // if config_class is present let's register config. |
|
| 251 | + \EE_Register_Addon::_register_config($addon_name); |
|
| 252 | + // register admin pages |
|
| 253 | + \EE_Register_Addon::_register_admin_pages($addon_name); |
|
| 254 | + // add to list of modules to be registered |
|
| 255 | + \EE_Register_Addon::_register_modules($addon_name); |
|
| 256 | + // add to list of shortcodes to be registered |
|
| 257 | + \EE_Register_Addon::_register_shortcodes($addon_name); |
|
| 258 | + // add to list of widgets to be registered |
|
| 259 | + \EE_Register_Addon::_register_widgets($addon_name); |
|
| 260 | + // register capability related stuff. |
|
| 261 | + \EE_Register_Addon::_register_capabilities($addon_name); |
|
| 262 | + // any message type to register? |
|
| 263 | + \EE_Register_Addon::_register_message_types($addon_name); |
|
| 264 | + // any custom post type/ custom capabilities or default terms to register |
|
| 265 | + \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
| 266 | + // and any payment methods |
|
| 267 | + \EE_Register_Addon::_register_payment_methods($addon_name); |
|
| 268 | + // load and instantiate main addon class |
|
| 269 | + $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
| 270 | + $addon->after_registration(); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * @param string $addon_name |
|
| 276 | - * @param array $setup_args |
|
| 277 | - * @return void |
|
| 278 | - * @throws \EE_Error |
|
| 279 | - */ |
|
| 280 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
| 281 | - { |
|
| 282 | - // required fields MUST be present, so let's make sure they are. |
|
| 283 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
| 284 | - throw new EE_Error( |
|
| 285 | - __( |
|
| 286 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
| 287 | - 'event_espresso' |
|
| 288 | - ) |
|
| 289 | - ); |
|
| 290 | - } |
|
| 291 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 292 | - throw new EE_Error( |
|
| 293 | - sprintf( |
|
| 294 | - __( |
|
| 295 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
| 296 | - 'event_espresso' |
|
| 297 | - ), |
|
| 298 | - implode(',', array_keys($setup_args)) |
|
| 299 | - ) |
|
| 300 | - ); |
|
| 301 | - } |
|
| 302 | - // check that addon has not already been registered with that name |
|
| 303 | - if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
| 304 | - throw new EE_Error( |
|
| 305 | - sprintf( |
|
| 306 | - __( |
|
| 307 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
| 308 | - 'event_espresso' |
|
| 309 | - ), |
|
| 310 | - $addon_name |
|
| 311 | - ) |
|
| 312 | - ); |
|
| 313 | - } |
|
| 314 | - } |
|
| 274 | + /** |
|
| 275 | + * @param string $addon_name |
|
| 276 | + * @param array $setup_args |
|
| 277 | + * @return void |
|
| 278 | + * @throws \EE_Error |
|
| 279 | + */ |
|
| 280 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
| 281 | + { |
|
| 282 | + // required fields MUST be present, so let's make sure they are. |
|
| 283 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
| 284 | + throw new EE_Error( |
|
| 285 | + __( |
|
| 286 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
| 287 | + 'event_espresso' |
|
| 288 | + ) |
|
| 289 | + ); |
|
| 290 | + } |
|
| 291 | + if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 292 | + throw new EE_Error( |
|
| 293 | + sprintf( |
|
| 294 | + __( |
|
| 295 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
| 296 | + 'event_espresso' |
|
| 297 | + ), |
|
| 298 | + implode(',', array_keys($setup_args)) |
|
| 299 | + ) |
|
| 300 | + ); |
|
| 301 | + } |
|
| 302 | + // check that addon has not already been registered with that name |
|
| 303 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
| 304 | + throw new EE_Error( |
|
| 305 | + sprintf( |
|
| 306 | + __( |
|
| 307 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
| 308 | + 'event_espresso' |
|
| 309 | + ), |
|
| 310 | + $addon_name |
|
| 311 | + ) |
|
| 312 | + ); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | - /** |
|
| 318 | - * @param string $addon_name |
|
| 319 | - * @param array $setup_args |
|
| 320 | - * @return string |
|
| 321 | - */ |
|
| 322 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
| 323 | - { |
|
| 324 | - if (empty($setup_args['class_name'])) { |
|
| 325 | - // generate one by first separating name with spaces |
|
| 326 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
| 327 | - //capitalize, then replace spaces with underscores |
|
| 328 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
| 329 | - } else { |
|
| 330 | - $class_name = $setup_args['class_name']; |
|
| 331 | - } |
|
| 332 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
| 333 | - } |
|
| 317 | + /** |
|
| 318 | + * @param string $addon_name |
|
| 319 | + * @param array $setup_args |
|
| 320 | + * @return string |
|
| 321 | + */ |
|
| 322 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
| 323 | + { |
|
| 324 | + if (empty($setup_args['class_name'])) { |
|
| 325 | + // generate one by first separating name with spaces |
|
| 326 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
| 327 | + //capitalize, then replace spaces with underscores |
|
| 328 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
| 329 | + } else { |
|
| 330 | + $class_name = $setup_args['class_name']; |
|
| 331 | + } |
|
| 332 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | 335 | |
| 336 | - /** |
|
| 337 | - * @param string $class_name |
|
| 338 | - * @param array $setup_args |
|
| 339 | - * @return array |
|
| 340 | - */ |
|
| 341 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
| 342 | - { |
|
| 343 | - //setup $_settings array from incoming values. |
|
| 344 | - $addon_settings = array( |
|
| 345 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
| 346 | - 'class_name' => $class_name, |
|
| 347 | - // the addon slug for use in URLs, etc |
|
| 348 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
| 349 | - ? (string)$setup_args['plugin_slug'] |
|
| 350 | - : '', |
|
| 351 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 352 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
| 353 | - ? (string)$setup_args['plugin_action_slug'] |
|
| 354 | - : '', |
|
| 355 | - // the "software" version for the addon |
|
| 356 | - 'version' => isset($setup_args['version']) |
|
| 357 | - ? (string)$setup_args['version'] |
|
| 358 | - : '', |
|
| 359 | - // the minimum version of EE Core that the addon will work with |
|
| 360 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
| 361 | - ? (string)$setup_args['min_core_version'] |
|
| 362 | - : '', |
|
| 363 | - // the minimum version of WordPress that the addon will work with |
|
| 364 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
| 365 | - ? (string)$setup_args['min_wp_version'] |
|
| 366 | - : EE_MIN_WP_VER_REQUIRED, |
|
| 367 | - // full server path to main file (file loaded directly by WP) |
|
| 368 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
| 369 | - ? (string)$setup_args['main_file_path'] |
|
| 370 | - : '', |
|
| 371 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
| 372 | - 'admin_path' => isset($setup_args['admin_path']) |
|
| 373 | - ? (string)$setup_args['admin_path'] : '', |
|
| 374 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
| 375 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
| 376 | - ? (string)$setup_args['admin_callback'] |
|
| 377 | - : '', |
|
| 378 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
| 379 | - 'config_section' => isset($setup_args['config_section']) |
|
| 380 | - ? (string)$setup_args['config_section'] |
|
| 381 | - : 'addons', |
|
| 382 | - // the class name for this addon's configuration settings object |
|
| 383 | - 'config_class' => isset($setup_args['config_class']) |
|
| 384 | - ? (string)$setup_args['config_class'] : '', |
|
| 385 | - //the name given to the config for this addons' configuration settings object (optional) |
|
| 386 | - 'config_name' => isset($setup_args['config_name']) |
|
| 387 | - ? (string)$setup_args['config_name'] : '', |
|
| 388 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
| 389 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
| 390 | - ? (array)$setup_args['autoloader_paths'] |
|
| 391 | - : array(), |
|
| 392 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
| 393 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
| 394 | - ? (array)$setup_args['autoloader_folders'] |
|
| 395 | - : array(), |
|
| 396 | - // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
| 397 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
| 398 | - ? (array)$setup_args['dms_paths'] |
|
| 399 | - : array(), |
|
| 400 | - // array of full server paths to any EED_Modules used by the addon |
|
| 401 | - 'module_paths' => isset($setup_args['module_paths']) |
|
| 402 | - ? (array)$setup_args['module_paths'] |
|
| 403 | - : array(), |
|
| 404 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
| 405 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
| 406 | - ? (array)$setup_args['shortcode_paths'] |
|
| 407 | - : array(), |
|
| 408 | - // array of full server paths to any WP_Widgets used by the addon |
|
| 409 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
| 410 | - ? (array)$setup_args['widget_paths'] |
|
| 411 | - : array(), |
|
| 412 | - // array of PUE options used by the addon |
|
| 413 | - 'pue_options' => isset($setup_args['pue_options']) |
|
| 414 | - ? (array)$setup_args['pue_options'] |
|
| 415 | - : array(), |
|
| 416 | - 'message_types' => isset($setup_args['message_types']) |
|
| 417 | - ? (array)$setup_args['message_types'] |
|
| 418 | - : array(), |
|
| 419 | - 'capabilities' => isset($setup_args['capabilities']) |
|
| 420 | - ? (array)$setup_args['capabilities'] |
|
| 421 | - : array(), |
|
| 422 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
| 423 | - ? (array)$setup_args['capability_maps'] |
|
| 424 | - : array(), |
|
| 425 | - 'model_paths' => isset($setup_args['model_paths']) |
|
| 426 | - ? (array)$setup_args['model_paths'] |
|
| 427 | - : array(), |
|
| 428 | - 'class_paths' => isset($setup_args['class_paths']) |
|
| 429 | - ? (array)$setup_args['class_paths'] |
|
| 430 | - : array(), |
|
| 431 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
| 432 | - ? (array)$setup_args['model_extension_paths'] |
|
| 433 | - : array(), |
|
| 434 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
| 435 | - ? (array)$setup_args['class_extension_paths'] |
|
| 436 | - : array(), |
|
| 437 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
| 438 | - ? (array)$setup_args['custom_post_types'] |
|
| 439 | - : array(), |
|
| 440 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
| 441 | - ? (array)$setup_args['custom_taxonomies'] |
|
| 442 | - : array(), |
|
| 443 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 444 | - ? (array)$setup_args['payment_method_paths'] |
|
| 445 | - : array(), |
|
| 446 | - 'default_terms' => isset($setup_args['default_terms']) |
|
| 447 | - ? (array)$setup_args['default_terms'] |
|
| 448 | - : array(), |
|
| 449 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 450 | - // that can be used for adding upgrading/marketing info |
|
| 451 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
| 452 | - ? $setup_args['plugins_page_row'] |
|
| 453 | - : '', |
|
| 454 | - 'namespace' => isset( |
|
| 455 | - $setup_args['namespace'], |
|
| 456 | - $setup_args['namespace']['FQNS'], |
|
| 457 | - $setup_args['namespace']['DIR'] |
|
| 458 | - ) |
|
| 459 | - ? (array)$setup_args['namespace'] |
|
| 460 | - : array(), |
|
| 461 | - ); |
|
| 462 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
| 463 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
| 464 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
| 465 | - && ! empty($addon_settings['admin_path']) |
|
| 466 | - ? $addon_settings['plugin_slug'] |
|
| 467 | - : $addon_settings['plugin_action_slug']; |
|
| 468 | - // full server path to main file (file loaded directly by WP) |
|
| 469 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
| 470 | - return $addon_settings; |
|
| 471 | - } |
|
| 336 | + /** |
|
| 337 | + * @param string $class_name |
|
| 338 | + * @param array $setup_args |
|
| 339 | + * @return array |
|
| 340 | + */ |
|
| 341 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
| 342 | + { |
|
| 343 | + //setup $_settings array from incoming values. |
|
| 344 | + $addon_settings = array( |
|
| 345 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
| 346 | + 'class_name' => $class_name, |
|
| 347 | + // the addon slug for use in URLs, etc |
|
| 348 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
| 349 | + ? (string)$setup_args['plugin_slug'] |
|
| 350 | + : '', |
|
| 351 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 352 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
| 353 | + ? (string)$setup_args['plugin_action_slug'] |
|
| 354 | + : '', |
|
| 355 | + // the "software" version for the addon |
|
| 356 | + 'version' => isset($setup_args['version']) |
|
| 357 | + ? (string)$setup_args['version'] |
|
| 358 | + : '', |
|
| 359 | + // the minimum version of EE Core that the addon will work with |
|
| 360 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
| 361 | + ? (string)$setup_args['min_core_version'] |
|
| 362 | + : '', |
|
| 363 | + // the minimum version of WordPress that the addon will work with |
|
| 364 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
| 365 | + ? (string)$setup_args['min_wp_version'] |
|
| 366 | + : EE_MIN_WP_VER_REQUIRED, |
|
| 367 | + // full server path to main file (file loaded directly by WP) |
|
| 368 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
| 369 | + ? (string)$setup_args['main_file_path'] |
|
| 370 | + : '', |
|
| 371 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
| 372 | + 'admin_path' => isset($setup_args['admin_path']) |
|
| 373 | + ? (string)$setup_args['admin_path'] : '', |
|
| 374 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
| 375 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
| 376 | + ? (string)$setup_args['admin_callback'] |
|
| 377 | + : '', |
|
| 378 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
| 379 | + 'config_section' => isset($setup_args['config_section']) |
|
| 380 | + ? (string)$setup_args['config_section'] |
|
| 381 | + : 'addons', |
|
| 382 | + // the class name for this addon's configuration settings object |
|
| 383 | + 'config_class' => isset($setup_args['config_class']) |
|
| 384 | + ? (string)$setup_args['config_class'] : '', |
|
| 385 | + //the name given to the config for this addons' configuration settings object (optional) |
|
| 386 | + 'config_name' => isset($setup_args['config_name']) |
|
| 387 | + ? (string)$setup_args['config_name'] : '', |
|
| 388 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
| 389 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
| 390 | + ? (array)$setup_args['autoloader_paths'] |
|
| 391 | + : array(), |
|
| 392 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
| 393 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
| 394 | + ? (array)$setup_args['autoloader_folders'] |
|
| 395 | + : array(), |
|
| 396 | + // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
| 397 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
| 398 | + ? (array)$setup_args['dms_paths'] |
|
| 399 | + : array(), |
|
| 400 | + // array of full server paths to any EED_Modules used by the addon |
|
| 401 | + 'module_paths' => isset($setup_args['module_paths']) |
|
| 402 | + ? (array)$setup_args['module_paths'] |
|
| 403 | + : array(), |
|
| 404 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
| 405 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
| 406 | + ? (array)$setup_args['shortcode_paths'] |
|
| 407 | + : array(), |
|
| 408 | + // array of full server paths to any WP_Widgets used by the addon |
|
| 409 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
| 410 | + ? (array)$setup_args['widget_paths'] |
|
| 411 | + : array(), |
|
| 412 | + // array of PUE options used by the addon |
|
| 413 | + 'pue_options' => isset($setup_args['pue_options']) |
|
| 414 | + ? (array)$setup_args['pue_options'] |
|
| 415 | + : array(), |
|
| 416 | + 'message_types' => isset($setup_args['message_types']) |
|
| 417 | + ? (array)$setup_args['message_types'] |
|
| 418 | + : array(), |
|
| 419 | + 'capabilities' => isset($setup_args['capabilities']) |
|
| 420 | + ? (array)$setup_args['capabilities'] |
|
| 421 | + : array(), |
|
| 422 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
| 423 | + ? (array)$setup_args['capability_maps'] |
|
| 424 | + : array(), |
|
| 425 | + 'model_paths' => isset($setup_args['model_paths']) |
|
| 426 | + ? (array)$setup_args['model_paths'] |
|
| 427 | + : array(), |
|
| 428 | + 'class_paths' => isset($setup_args['class_paths']) |
|
| 429 | + ? (array)$setup_args['class_paths'] |
|
| 430 | + : array(), |
|
| 431 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
| 432 | + ? (array)$setup_args['model_extension_paths'] |
|
| 433 | + : array(), |
|
| 434 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
| 435 | + ? (array)$setup_args['class_extension_paths'] |
|
| 436 | + : array(), |
|
| 437 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
| 438 | + ? (array)$setup_args['custom_post_types'] |
|
| 439 | + : array(), |
|
| 440 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
| 441 | + ? (array)$setup_args['custom_taxonomies'] |
|
| 442 | + : array(), |
|
| 443 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 444 | + ? (array)$setup_args['payment_method_paths'] |
|
| 445 | + : array(), |
|
| 446 | + 'default_terms' => isset($setup_args['default_terms']) |
|
| 447 | + ? (array)$setup_args['default_terms'] |
|
| 448 | + : array(), |
|
| 449 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 450 | + // that can be used for adding upgrading/marketing info |
|
| 451 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
| 452 | + ? $setup_args['plugins_page_row'] |
|
| 453 | + : '', |
|
| 454 | + 'namespace' => isset( |
|
| 455 | + $setup_args['namespace'], |
|
| 456 | + $setup_args['namespace']['FQNS'], |
|
| 457 | + $setup_args['namespace']['DIR'] |
|
| 458 | + ) |
|
| 459 | + ? (array)$setup_args['namespace'] |
|
| 460 | + : array(), |
|
| 461 | + ); |
|
| 462 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
| 463 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
| 464 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
| 465 | + && ! empty($addon_settings['admin_path']) |
|
| 466 | + ? $addon_settings['plugin_slug'] |
|
| 467 | + : $addon_settings['plugin_action_slug']; |
|
| 468 | + // full server path to main file (file loaded directly by WP) |
|
| 469 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
| 470 | + return $addon_settings; |
|
| 471 | + } |
|
| 472 | 472 | |
| 473 | 473 | |
| 474 | - /** |
|
| 475 | - * @param string $addon_name |
|
| 476 | - * @param array $addon_settings |
|
| 477 | - * @return boolean |
|
| 478 | - */ |
|
| 479 | - private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
| 480 | - { |
|
| 481 | - global $wp_version; |
|
| 482 | - $incompatibility_message = ''; |
|
| 483 | - //check whether this addon version is compatible with EE core |
|
| 484 | - if ( |
|
| 485 | - isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
| 486 | - && ! self::_meets_min_core_version_requirement( |
|
| 487 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 488 | - $addon_settings['version'] |
|
| 489 | - ) |
|
| 490 | - ) { |
|
| 491 | - $incompatibility_message = sprintf( |
|
| 492 | - __( |
|
| 493 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
| 494 | - ), |
|
| 495 | - $addon_name, |
|
| 496 | - '<br />', |
|
| 497 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 498 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 499 | - '</span><br />' |
|
| 500 | - ); |
|
| 501 | - } else if ( |
|
| 502 | - ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
| 503 | - ) { |
|
| 504 | - $incompatibility_message = sprintf( |
|
| 505 | - __( |
|
| 506 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
| 507 | - 'event_espresso' |
|
| 508 | - ), |
|
| 509 | - $addon_name, |
|
| 510 | - self::_effective_version($addon_settings['min_core_version']), |
|
| 511 | - self::_effective_version(espresso_version()), |
|
| 512 | - '<br />', |
|
| 513 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 514 | - '</span><br />' |
|
| 515 | - ); |
|
| 516 | - } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
| 517 | - $incompatibility_message = sprintf( |
|
| 518 | - __( |
|
| 519 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
| 520 | - 'event_espresso' |
|
| 521 | - ), |
|
| 522 | - $addon_name, |
|
| 523 | - $addon_settings['min_wp_version'], |
|
| 524 | - '<br />', |
|
| 525 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 526 | - '</span><br />' |
|
| 527 | - ); |
|
| 528 | - } |
|
| 529 | - if (! empty($incompatibility_message)) { |
|
| 530 | - // remove 'activate' from the REQUEST |
|
| 531 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
| 532 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 533 | - if (current_user_can('activate_plugins')) { |
|
| 534 | - // show an error message indicating the plugin didn't activate properly |
|
| 535 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
| 536 | - } |
|
| 537 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
| 538 | - return false; |
|
| 539 | - } |
|
| 540 | - // addon IS compatible |
|
| 541 | - return true; |
|
| 542 | - } |
|
| 474 | + /** |
|
| 475 | + * @param string $addon_name |
|
| 476 | + * @param array $addon_settings |
|
| 477 | + * @return boolean |
|
| 478 | + */ |
|
| 479 | + private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
| 480 | + { |
|
| 481 | + global $wp_version; |
|
| 482 | + $incompatibility_message = ''; |
|
| 483 | + //check whether this addon version is compatible with EE core |
|
| 484 | + if ( |
|
| 485 | + isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
| 486 | + && ! self::_meets_min_core_version_requirement( |
|
| 487 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 488 | + $addon_settings['version'] |
|
| 489 | + ) |
|
| 490 | + ) { |
|
| 491 | + $incompatibility_message = sprintf( |
|
| 492 | + __( |
|
| 493 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
| 494 | + ), |
|
| 495 | + $addon_name, |
|
| 496 | + '<br />', |
|
| 497 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 498 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 499 | + '</span><br />' |
|
| 500 | + ); |
|
| 501 | + } else if ( |
|
| 502 | + ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
| 503 | + ) { |
|
| 504 | + $incompatibility_message = sprintf( |
|
| 505 | + __( |
|
| 506 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
| 507 | + 'event_espresso' |
|
| 508 | + ), |
|
| 509 | + $addon_name, |
|
| 510 | + self::_effective_version($addon_settings['min_core_version']), |
|
| 511 | + self::_effective_version(espresso_version()), |
|
| 512 | + '<br />', |
|
| 513 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 514 | + '</span><br />' |
|
| 515 | + ); |
|
| 516 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
| 517 | + $incompatibility_message = sprintf( |
|
| 518 | + __( |
|
| 519 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
| 520 | + 'event_espresso' |
|
| 521 | + ), |
|
| 522 | + $addon_name, |
|
| 523 | + $addon_settings['min_wp_version'], |
|
| 524 | + '<br />', |
|
| 525 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 526 | + '</span><br />' |
|
| 527 | + ); |
|
| 528 | + } |
|
| 529 | + if (! empty($incompatibility_message)) { |
|
| 530 | + // remove 'activate' from the REQUEST |
|
| 531 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
| 532 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 533 | + if (current_user_can('activate_plugins')) { |
|
| 534 | + // show an error message indicating the plugin didn't activate properly |
|
| 535 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
| 536 | + } |
|
| 537 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
| 538 | + return false; |
|
| 539 | + } |
|
| 540 | + // addon IS compatible |
|
| 541 | + return true; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | 544 | |
| 545 | - /** |
|
| 546 | - * if plugin update engine is being used for auto-updates, |
|
| 547 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
| 548 | - * (not needed if PUE is not being used) |
|
| 549 | - * |
|
| 550 | - * @param string $addon_name |
|
| 551 | - * @param string $class_name |
|
| 552 | - * @param array $setup_args |
|
| 553 | - * @return void |
|
| 554 | - */ |
|
| 555 | - private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
| 556 | - { |
|
| 557 | - if (! empty($setup_args['pue_options'])) { |
|
| 558 | - self::$_settings[$addon_name]['pue_options'] = array( |
|
| 559 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
| 560 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
| 561 | - : 'espresso_' . strtolower($class_name), |
|
| 562 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
| 563 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
| 564 | - : plugin_basename($setup_args['main_file_path']), |
|
| 565 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
| 566 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
| 567 | - : '24', |
|
| 568 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
| 569 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
| 570 | - : false, |
|
| 571 | - ); |
|
| 572 | - add_action( |
|
| 573 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
| 574 | - array('EE_Register_Addon', 'load_pue_update') |
|
| 575 | - ); |
|
| 576 | - } |
|
| 577 | - } |
|
| 545 | + /** |
|
| 546 | + * if plugin update engine is being used for auto-updates, |
|
| 547 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
| 548 | + * (not needed if PUE is not being used) |
|
| 549 | + * |
|
| 550 | + * @param string $addon_name |
|
| 551 | + * @param string $class_name |
|
| 552 | + * @param array $setup_args |
|
| 553 | + * @return void |
|
| 554 | + */ |
|
| 555 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
| 556 | + { |
|
| 557 | + if (! empty($setup_args['pue_options'])) { |
|
| 558 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
| 559 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
| 560 | + ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
| 561 | + : 'espresso_' . strtolower($class_name), |
|
| 562 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
| 563 | + ? (string)$setup_args['pue_options']['plugin_basename'] |
|
| 564 | + : plugin_basename($setup_args['main_file_path']), |
|
| 565 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
| 566 | + ? (string)$setup_args['pue_options']['checkPeriod'] |
|
| 567 | + : '24', |
|
| 568 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
| 569 | + ? (string)$setup_args['pue_options']['use_wp_update'] |
|
| 570 | + : false, |
|
| 571 | + ); |
|
| 572 | + add_action( |
|
| 573 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
| 574 | + array('EE_Register_Addon', 'load_pue_update') |
|
| 575 | + ); |
|
| 576 | + } |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | 579 | |
| 580 | - /** |
|
| 581 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
| 582 | - * |
|
| 583 | - * @param array $addon_settings |
|
| 584 | - * @return void |
|
| 585 | - */ |
|
| 586 | - private static function _setup_namespaces(array $addon_settings) |
|
| 587 | - { |
|
| 588 | - // |
|
| 589 | - if ( |
|
| 590 | - isset( |
|
| 591 | - $addon_settings['namespace'], |
|
| 592 | - $addon_settings['namespace']['FQNS'], |
|
| 593 | - $addon_settings['namespace']['DIR'] |
|
| 594 | - ) |
|
| 595 | - ) { |
|
| 596 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
| 597 | - $addon_settings['namespace']['FQNS'], |
|
| 598 | - $addon_settings['namespace']['DIR'] |
|
| 599 | - ); |
|
| 600 | - } |
|
| 601 | - } |
|
| 580 | + /** |
|
| 581 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
| 582 | + * |
|
| 583 | + * @param array $addon_settings |
|
| 584 | + * @return void |
|
| 585 | + */ |
|
| 586 | + private static function _setup_namespaces(array $addon_settings) |
|
| 587 | + { |
|
| 588 | + // |
|
| 589 | + if ( |
|
| 590 | + isset( |
|
| 591 | + $addon_settings['namespace'], |
|
| 592 | + $addon_settings['namespace']['FQNS'], |
|
| 593 | + $addon_settings['namespace']['DIR'] |
|
| 594 | + ) |
|
| 595 | + ) { |
|
| 596 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
| 597 | + $addon_settings['namespace']['FQNS'], |
|
| 598 | + $addon_settings['namespace']['DIR'] |
|
| 599 | + ); |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | 603 | |
| 604 | - /** |
|
| 605 | - * @param string $addon_name |
|
| 606 | - * @param array $addon_settings |
|
| 607 | - * @return bool |
|
| 608 | - */ |
|
| 609 | - private static function _addon_activation($addon_name, array $addon_settings) |
|
| 610 | - { |
|
| 611 | - // this is an activation request |
|
| 612 | - if (did_action('activate_plugin')) { |
|
| 613 | - //to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
| 614 | - //(as the newly-activated addon wasn't around the first time addons were registered). |
|
| 615 | - //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
| 616 | - //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
| 617 | - if (! isset(self::$_settings[$addon_name]) |
|
| 618 | - || (isset(self::$_settings[$addon_name]) |
|
| 619 | - && ! isset(self::$_settings[$addon_name]['class_name']) |
|
| 620 | - ) |
|
| 621 | - ) { |
|
| 622 | - self::$_settings[$addon_name] = $addon_settings; |
|
| 623 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
| 624 | - $addon->set_activation_indicator_option(); |
|
| 625 | - // dont bother setting up the rest of the addon. |
|
| 626 | - // we know it was just activated and the request will end soon |
|
| 627 | - } |
|
| 628 | - return true; |
|
| 629 | - } else { |
|
| 630 | - // make sure this was called in the right place! |
|
| 631 | - if ( |
|
| 632 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 633 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 634 | - ) { |
|
| 635 | - EE_Error::doing_it_wrong( |
|
| 636 | - __METHOD__, |
|
| 637 | - sprintf( |
|
| 638 | - __( |
|
| 639 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
| 640 | - 'event_espresso' |
|
| 641 | - ), |
|
| 642 | - $addon_name |
|
| 643 | - ), |
|
| 644 | - '4.3.0' |
|
| 645 | - ); |
|
| 646 | - } |
|
| 647 | - // make sure addon settings are set correctly without overwriting anything existing |
|
| 648 | - if (isset(self::$_settings[$addon_name])) { |
|
| 649 | - self::$_settings[$addon_name] += $addon_settings; |
|
| 650 | - } else { |
|
| 651 | - self::$_settings[$addon_name] = $addon_settings; |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - return false; |
|
| 655 | - } |
|
| 604 | + /** |
|
| 605 | + * @param string $addon_name |
|
| 606 | + * @param array $addon_settings |
|
| 607 | + * @return bool |
|
| 608 | + */ |
|
| 609 | + private static function _addon_activation($addon_name, array $addon_settings) |
|
| 610 | + { |
|
| 611 | + // this is an activation request |
|
| 612 | + if (did_action('activate_plugin')) { |
|
| 613 | + //to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
| 614 | + //(as the newly-activated addon wasn't around the first time addons were registered). |
|
| 615 | + //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
| 616 | + //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
| 617 | + if (! isset(self::$_settings[$addon_name]) |
|
| 618 | + || (isset(self::$_settings[$addon_name]) |
|
| 619 | + && ! isset(self::$_settings[$addon_name]['class_name']) |
|
| 620 | + ) |
|
| 621 | + ) { |
|
| 622 | + self::$_settings[$addon_name] = $addon_settings; |
|
| 623 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
| 624 | + $addon->set_activation_indicator_option(); |
|
| 625 | + // dont bother setting up the rest of the addon. |
|
| 626 | + // we know it was just activated and the request will end soon |
|
| 627 | + } |
|
| 628 | + return true; |
|
| 629 | + } else { |
|
| 630 | + // make sure this was called in the right place! |
|
| 631 | + if ( |
|
| 632 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 633 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 634 | + ) { |
|
| 635 | + EE_Error::doing_it_wrong( |
|
| 636 | + __METHOD__, |
|
| 637 | + sprintf( |
|
| 638 | + __( |
|
| 639 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
| 640 | + 'event_espresso' |
|
| 641 | + ), |
|
| 642 | + $addon_name |
|
| 643 | + ), |
|
| 644 | + '4.3.0' |
|
| 645 | + ); |
|
| 646 | + } |
|
| 647 | + // make sure addon settings are set correctly without overwriting anything existing |
|
| 648 | + if (isset(self::$_settings[$addon_name])) { |
|
| 649 | + self::$_settings[$addon_name] += $addon_settings; |
|
| 650 | + } else { |
|
| 651 | + self::$_settings[$addon_name] = $addon_settings; |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + return false; |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | 657 | |
| 658 | - /** |
|
| 659 | - * @param string $addon_name |
|
| 660 | - * @return void |
|
| 661 | - * @throws \EE_Error |
|
| 662 | - */ |
|
| 663 | - private static function _setup_autoloaders($addon_name) |
|
| 664 | - { |
|
| 665 | - if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
| 666 | - // setup autoloader for single file |
|
| 667 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
| 668 | - } |
|
| 669 | - // setup autoloaders for folders |
|
| 670 | - if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
| 671 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
| 672 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - } |
|
| 658 | + /** |
|
| 659 | + * @param string $addon_name |
|
| 660 | + * @return void |
|
| 661 | + * @throws \EE_Error |
|
| 662 | + */ |
|
| 663 | + private static function _setup_autoloaders($addon_name) |
|
| 664 | + { |
|
| 665 | + if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
| 666 | + // setup autoloader for single file |
|
| 667 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
| 668 | + } |
|
| 669 | + // setup autoloaders for folders |
|
| 670 | + if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
| 671 | + foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
| 672 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | 676 | |
| 677 | 677 | |
| 678 | - /** |
|
| 679 | - * register new models and extensions |
|
| 680 | - * |
|
| 681 | - * @param string $addon_name |
|
| 682 | - * @return void |
|
| 683 | - * @throws \EE_Error |
|
| 684 | - */ |
|
| 685 | - private static function _register_models_and_extensions($addon_name) |
|
| 686 | - { |
|
| 687 | - // register new models |
|
| 688 | - if ( |
|
| 689 | - ! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 690 | - || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 691 | - ) { |
|
| 692 | - EE_Register_Model::register( |
|
| 693 | - $addon_name, |
|
| 694 | - array( |
|
| 695 | - 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
| 696 | - 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
| 697 | - ) |
|
| 698 | - ); |
|
| 699 | - } |
|
| 700 | - // register model extensions |
|
| 701 | - if ( |
|
| 702 | - ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 703 | - || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 704 | - ) { |
|
| 705 | - EE_Register_Model_Extensions::register( |
|
| 706 | - $addon_name, |
|
| 707 | - array( |
|
| 708 | - 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
| 709 | - 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
| 710 | - ) |
|
| 711 | - ); |
|
| 712 | - } |
|
| 713 | - } |
|
| 678 | + /** |
|
| 679 | + * register new models and extensions |
|
| 680 | + * |
|
| 681 | + * @param string $addon_name |
|
| 682 | + * @return void |
|
| 683 | + * @throws \EE_Error |
|
| 684 | + */ |
|
| 685 | + private static function _register_models_and_extensions($addon_name) |
|
| 686 | + { |
|
| 687 | + // register new models |
|
| 688 | + if ( |
|
| 689 | + ! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 690 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 691 | + ) { |
|
| 692 | + EE_Register_Model::register( |
|
| 693 | + $addon_name, |
|
| 694 | + array( |
|
| 695 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
| 696 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
| 697 | + ) |
|
| 698 | + ); |
|
| 699 | + } |
|
| 700 | + // register model extensions |
|
| 701 | + if ( |
|
| 702 | + ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 703 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 704 | + ) { |
|
| 705 | + EE_Register_Model_Extensions::register( |
|
| 706 | + $addon_name, |
|
| 707 | + array( |
|
| 708 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
| 709 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
| 710 | + ) |
|
| 711 | + ); |
|
| 712 | + } |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | 715 | |
| 716 | - /** |
|
| 717 | - * @param string $addon_name |
|
| 718 | - * @return void |
|
| 719 | - * @throws \EE_Error |
|
| 720 | - */ |
|
| 721 | - private static function _register_data_migration_scripts($addon_name) |
|
| 722 | - { |
|
| 723 | - // setup DMS |
|
| 724 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 725 | - EE_Register_Data_Migration_Scripts::register( |
|
| 726 | - $addon_name, |
|
| 727 | - array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
| 728 | - ); |
|
| 729 | - } |
|
| 730 | - } |
|
| 716 | + /** |
|
| 717 | + * @param string $addon_name |
|
| 718 | + * @return void |
|
| 719 | + * @throws \EE_Error |
|
| 720 | + */ |
|
| 721 | + private static function _register_data_migration_scripts($addon_name) |
|
| 722 | + { |
|
| 723 | + // setup DMS |
|
| 724 | + if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 725 | + EE_Register_Data_Migration_Scripts::register( |
|
| 726 | + $addon_name, |
|
| 727 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
| 728 | + ); |
|
| 729 | + } |
|
| 730 | + } |
|
| 731 | 731 | |
| 732 | 732 | |
| 733 | - /** |
|
| 734 | - * @param string $addon_name |
|
| 735 | - * @return void |
|
| 736 | - * @throws \EE_Error |
|
| 737 | - */ |
|
| 738 | - private static function _register_config($addon_name) |
|
| 739 | - { |
|
| 740 | - // if config_class is present let's register config. |
|
| 741 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 742 | - EE_Register_Config::register( |
|
| 743 | - self::$_settings[$addon_name]['config_class'], |
|
| 744 | - array( |
|
| 745 | - 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
| 746 | - 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
| 747 | - ) |
|
| 748 | - ); |
|
| 749 | - } |
|
| 750 | - } |
|
| 733 | + /** |
|
| 734 | + * @param string $addon_name |
|
| 735 | + * @return void |
|
| 736 | + * @throws \EE_Error |
|
| 737 | + */ |
|
| 738 | + private static function _register_config($addon_name) |
|
| 739 | + { |
|
| 740 | + // if config_class is present let's register config. |
|
| 741 | + if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 742 | + EE_Register_Config::register( |
|
| 743 | + self::$_settings[$addon_name]['config_class'], |
|
| 744 | + array( |
|
| 745 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
| 746 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
| 747 | + ) |
|
| 748 | + ); |
|
| 749 | + } |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | 752 | |
| 753 | - /** |
|
| 754 | - * @param string $addon_name |
|
| 755 | - * @return void |
|
| 756 | - * @throws \EE_Error |
|
| 757 | - */ |
|
| 758 | - private static function _register_admin_pages($addon_name) |
|
| 759 | - { |
|
| 760 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 761 | - EE_Register_Admin_Page::register( |
|
| 762 | - $addon_name, |
|
| 763 | - array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
| 764 | - ); |
|
| 765 | - } |
|
| 766 | - } |
|
| 753 | + /** |
|
| 754 | + * @param string $addon_name |
|
| 755 | + * @return void |
|
| 756 | + * @throws \EE_Error |
|
| 757 | + */ |
|
| 758 | + private static function _register_admin_pages($addon_name) |
|
| 759 | + { |
|
| 760 | + if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 761 | + EE_Register_Admin_Page::register( |
|
| 762 | + $addon_name, |
|
| 763 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
| 764 | + ); |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | 767 | |
| 768 | 768 | |
| 769 | - /** |
|
| 770 | - * @param string $addon_name |
|
| 771 | - * @return void |
|
| 772 | - * @throws \EE_Error |
|
| 773 | - */ |
|
| 774 | - private static function _register_modules($addon_name) |
|
| 775 | - { |
|
| 776 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 777 | - EE_Register_Module::register( |
|
| 778 | - $addon_name, |
|
| 779 | - array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
| 780 | - ); |
|
| 781 | - } |
|
| 782 | - } |
|
| 769 | + /** |
|
| 770 | + * @param string $addon_name |
|
| 771 | + * @return void |
|
| 772 | + * @throws \EE_Error |
|
| 773 | + */ |
|
| 774 | + private static function _register_modules($addon_name) |
|
| 775 | + { |
|
| 776 | + if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 777 | + EE_Register_Module::register( |
|
| 778 | + $addon_name, |
|
| 779 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
| 780 | + ); |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | 784 | |
| 785 | - /** |
|
| 786 | - * @param string $addon_name |
|
| 787 | - * @return void |
|
| 788 | - * @throws \EE_Error |
|
| 789 | - */ |
|
| 790 | - private static function _register_shortcodes($addon_name) |
|
| 791 | - { |
|
| 792 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 793 | - EE_Register_Shortcode::register( |
|
| 794 | - $addon_name, |
|
| 795 | - array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
| 796 | - ); |
|
| 797 | - } |
|
| 798 | - } |
|
| 785 | + /** |
|
| 786 | + * @param string $addon_name |
|
| 787 | + * @return void |
|
| 788 | + * @throws \EE_Error |
|
| 789 | + */ |
|
| 790 | + private static function _register_shortcodes($addon_name) |
|
| 791 | + { |
|
| 792 | + if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 793 | + EE_Register_Shortcode::register( |
|
| 794 | + $addon_name, |
|
| 795 | + array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
| 796 | + ); |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | 800 | |
| 801 | - /** |
|
| 802 | - * @param string $addon_name |
|
| 803 | - * @return void |
|
| 804 | - * @throws \EE_Error |
|
| 805 | - */ |
|
| 806 | - private static function _register_widgets($addon_name) |
|
| 807 | - { |
|
| 808 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 809 | - EE_Register_Widget::register( |
|
| 810 | - $addon_name, |
|
| 811 | - array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
| 812 | - ); |
|
| 813 | - } |
|
| 814 | - } |
|
| 801 | + /** |
|
| 802 | + * @param string $addon_name |
|
| 803 | + * @return void |
|
| 804 | + * @throws \EE_Error |
|
| 805 | + */ |
|
| 806 | + private static function _register_widgets($addon_name) |
|
| 807 | + { |
|
| 808 | + if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 809 | + EE_Register_Widget::register( |
|
| 810 | + $addon_name, |
|
| 811 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
| 812 | + ); |
|
| 813 | + } |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | 816 | |
| 817 | - /** |
|
| 818 | - * @param string $addon_name |
|
| 819 | - * @return void |
|
| 820 | - * @throws \EE_Error |
|
| 821 | - */ |
|
| 822 | - private static function _register_capabilities($addon_name) |
|
| 823 | - { |
|
| 824 | - if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
| 825 | - EE_Register_Capabilities::register( |
|
| 826 | - $addon_name, |
|
| 827 | - array( |
|
| 828 | - 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
| 829 | - 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
| 830 | - ) |
|
| 831 | - ); |
|
| 832 | - } |
|
| 833 | - } |
|
| 817 | + /** |
|
| 818 | + * @param string $addon_name |
|
| 819 | + * @return void |
|
| 820 | + * @throws \EE_Error |
|
| 821 | + */ |
|
| 822 | + private static function _register_capabilities($addon_name) |
|
| 823 | + { |
|
| 824 | + if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
| 825 | + EE_Register_Capabilities::register( |
|
| 826 | + $addon_name, |
|
| 827 | + array( |
|
| 828 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
| 829 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
| 830 | + ) |
|
| 831 | + ); |
|
| 832 | + } |
|
| 833 | + } |
|
| 834 | 834 | |
| 835 | 835 | |
| 836 | - /** |
|
| 837 | - * @param string $addon_name |
|
| 838 | - * @return void |
|
| 839 | - * @throws \EE_Error |
|
| 840 | - */ |
|
| 841 | - private static function _register_message_types($addon_name) |
|
| 842 | - { |
|
| 843 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 844 | - add_action( |
|
| 845 | - 'EE_Brewing_Regular___messages_caf', |
|
| 846 | - array('EE_Register_Addon', 'register_message_types') |
|
| 847 | - ); |
|
| 848 | - } |
|
| 849 | - } |
|
| 836 | + /** |
|
| 837 | + * @param string $addon_name |
|
| 838 | + * @return void |
|
| 839 | + * @throws \EE_Error |
|
| 840 | + */ |
|
| 841 | + private static function _register_message_types($addon_name) |
|
| 842 | + { |
|
| 843 | + if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 844 | + add_action( |
|
| 845 | + 'EE_Brewing_Regular___messages_caf', |
|
| 846 | + array('EE_Register_Addon', 'register_message_types') |
|
| 847 | + ); |
|
| 848 | + } |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | 851 | |
| 852 | - /** |
|
| 853 | - * @param string $addon_name |
|
| 854 | - * @return void |
|
| 855 | - * @throws \EE_Error |
|
| 856 | - */ |
|
| 857 | - private static function _register_custom_post_types($addon_name) |
|
| 858 | - { |
|
| 859 | - if ( |
|
| 860 | - ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
| 861 | - || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
| 862 | - ) { |
|
| 863 | - EE_Register_CPT::register( |
|
| 864 | - $addon_name, |
|
| 865 | - array( |
|
| 866 | - 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
| 867 | - 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
| 868 | - 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
| 869 | - ) |
|
| 870 | - ); |
|
| 871 | - } |
|
| 872 | - } |
|
| 852 | + /** |
|
| 853 | + * @param string $addon_name |
|
| 854 | + * @return void |
|
| 855 | + * @throws \EE_Error |
|
| 856 | + */ |
|
| 857 | + private static function _register_custom_post_types($addon_name) |
|
| 858 | + { |
|
| 859 | + if ( |
|
| 860 | + ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
| 861 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
| 862 | + ) { |
|
| 863 | + EE_Register_CPT::register( |
|
| 864 | + $addon_name, |
|
| 865 | + array( |
|
| 866 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
| 867 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
| 868 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
| 869 | + ) |
|
| 870 | + ); |
|
| 871 | + } |
|
| 872 | + } |
|
| 873 | 873 | |
| 874 | 874 | |
| 875 | - /** |
|
| 876 | - * @param string $addon_name |
|
| 877 | - * @return void |
|
| 878 | - * @throws \EE_Error |
|
| 879 | - */ |
|
| 880 | - private static function _register_payment_methods($addon_name) |
|
| 881 | - { |
|
| 882 | - if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 883 | - EE_Register_Payment_Method::register( |
|
| 884 | - $addon_name, |
|
| 885 | - array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
| 886 | - ); |
|
| 887 | - } |
|
| 888 | - } |
|
| 875 | + /** |
|
| 876 | + * @param string $addon_name |
|
| 877 | + * @return void |
|
| 878 | + * @throws \EE_Error |
|
| 879 | + */ |
|
| 880 | + private static function _register_payment_methods($addon_name) |
|
| 881 | + { |
|
| 882 | + if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 883 | + EE_Register_Payment_Method::register( |
|
| 884 | + $addon_name, |
|
| 885 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
| 886 | + ); |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | 889 | |
| 890 | 890 | |
| 891 | - /** |
|
| 892 | - * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
| 893 | - * |
|
| 894 | - * @param string $addon_name |
|
| 895 | - * @return EE_Addon |
|
| 896 | - */ |
|
| 897 | - private static function _load_and_init_addon_class($addon_name) |
|
| 898 | - { |
|
| 899 | - $addon = EE_Registry::instance()->load_addon( |
|
| 900 | - dirname(self::$_settings[$addon_name]['main_file_path']), |
|
| 901 | - self::$_settings[$addon_name]['class_name'] |
|
| 902 | - ); |
|
| 903 | - $addon->set_name($addon_name); |
|
| 904 | - $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
| 905 | - $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
| 906 | - $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
| 907 | - $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
| 908 | - $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
| 909 | - $addon->set_version(self::$_settings[$addon_name]['version']); |
|
| 910 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
| 911 | - $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
| 912 | - $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
| 913 | - $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
| 914 | - //unfortunately this can't be hooked in upon construction, because we don't have |
|
| 915 | - //the plugin mainfile's path upon construction. |
|
| 916 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
| 917 | - // call any additional admin_callback functions during load_admin_controller hook |
|
| 918 | - if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
| 919 | - add_action( |
|
| 920 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
| 921 | - array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
| 922 | - ); |
|
| 923 | - } |
|
| 924 | - return $addon; |
|
| 925 | - } |
|
| 891 | + /** |
|
| 892 | + * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
| 893 | + * |
|
| 894 | + * @param string $addon_name |
|
| 895 | + * @return EE_Addon |
|
| 896 | + */ |
|
| 897 | + private static function _load_and_init_addon_class($addon_name) |
|
| 898 | + { |
|
| 899 | + $addon = EE_Registry::instance()->load_addon( |
|
| 900 | + dirname(self::$_settings[$addon_name]['main_file_path']), |
|
| 901 | + self::$_settings[$addon_name]['class_name'] |
|
| 902 | + ); |
|
| 903 | + $addon->set_name($addon_name); |
|
| 904 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
| 905 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
| 906 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
| 907 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
| 908 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
| 909 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
| 910 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
| 911 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
| 912 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
| 913 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
| 914 | + //unfortunately this can't be hooked in upon construction, because we don't have |
|
| 915 | + //the plugin mainfile's path upon construction. |
|
| 916 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
| 917 | + // call any additional admin_callback functions during load_admin_controller hook |
|
| 918 | + if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
| 919 | + add_action( |
|
| 920 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
| 921 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
| 922 | + ); |
|
| 923 | + } |
|
| 924 | + return $addon; |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | 927 | |
| 928 | - /** |
|
| 929 | - * load_pue_update - Update notifications |
|
| 930 | - * |
|
| 931 | - * @return void |
|
| 932 | - */ |
|
| 933 | - public static function load_pue_update() |
|
| 934 | - { |
|
| 935 | - // load PUE client |
|
| 936 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 937 | - // cycle thru settings |
|
| 938 | - foreach (self::$_settings as $settings) { |
|
| 939 | - if (! empty($settings['pue_options'])) { |
|
| 940 | - // initiate the class and start the plugin update engine! |
|
| 941 | - new PluginUpdateEngineChecker( |
|
| 942 | - // host file URL |
|
| 943 | - 'https://eventespresso.com', |
|
| 944 | - // plugin slug(s) |
|
| 945 | - array( |
|
| 946 | - 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
| 947 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 948 | - ), |
|
| 949 | - // options |
|
| 950 | - array( |
|
| 951 | - 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
| 952 | - 'lang_domain' => 'event_espresso', |
|
| 953 | - 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
| 954 | - 'option_key' => 'site_license_key', |
|
| 955 | - 'options_page_slug' => 'event_espresso', |
|
| 956 | - 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
| 957 | - // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
| 958 | - 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
| 959 | - ) |
|
| 960 | - ); |
|
| 961 | - } |
|
| 962 | - } |
|
| 963 | - } |
|
| 928 | + /** |
|
| 929 | + * load_pue_update - Update notifications |
|
| 930 | + * |
|
| 931 | + * @return void |
|
| 932 | + */ |
|
| 933 | + public static function load_pue_update() |
|
| 934 | + { |
|
| 935 | + // load PUE client |
|
| 936 | + require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 937 | + // cycle thru settings |
|
| 938 | + foreach (self::$_settings as $settings) { |
|
| 939 | + if (! empty($settings['pue_options'])) { |
|
| 940 | + // initiate the class and start the plugin update engine! |
|
| 941 | + new PluginUpdateEngineChecker( |
|
| 942 | + // host file URL |
|
| 943 | + 'https://eventespresso.com', |
|
| 944 | + // plugin slug(s) |
|
| 945 | + array( |
|
| 946 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
| 947 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 948 | + ), |
|
| 949 | + // options |
|
| 950 | + array( |
|
| 951 | + 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
| 952 | + 'lang_domain' => 'event_espresso', |
|
| 953 | + 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
| 954 | + 'option_key' => 'site_license_key', |
|
| 955 | + 'options_page_slug' => 'event_espresso', |
|
| 956 | + 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
| 957 | + // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
| 958 | + 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
| 959 | + ) |
|
| 960 | + ); |
|
| 961 | + } |
|
| 962 | + } |
|
| 963 | + } |
|
| 964 | 964 | |
| 965 | 965 | |
| 966 | - /** |
|
| 967 | - * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
| 968 | - * |
|
| 969 | - * @since 4.4.0 |
|
| 970 | - * @return void |
|
| 971 | - * @throws \EE_Error |
|
| 972 | - */ |
|
| 973 | - public static function register_message_types() |
|
| 974 | - { |
|
| 975 | - foreach (self::$_settings as $addon_name => $settings) { |
|
| 976 | - if (! empty($settings['message_types'])) { |
|
| 977 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
| 978 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
| 979 | - } |
|
| 980 | - } |
|
| 981 | - } |
|
| 982 | - } |
|
| 966 | + /** |
|
| 967 | + * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
| 968 | + * |
|
| 969 | + * @since 4.4.0 |
|
| 970 | + * @return void |
|
| 971 | + * @throws \EE_Error |
|
| 972 | + */ |
|
| 973 | + public static function register_message_types() |
|
| 974 | + { |
|
| 975 | + foreach (self::$_settings as $addon_name => $settings) { |
|
| 976 | + if (! empty($settings['message_types'])) { |
|
| 977 | + foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
| 978 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
| 979 | + } |
|
| 980 | + } |
|
| 981 | + } |
|
| 982 | + } |
|
| 983 | 983 | |
| 984 | 984 | |
| 985 | - /** |
|
| 986 | - * This deregisters an addon that was previously registered with a specific addon_name. |
|
| 987 | - * |
|
| 988 | - * @since 4.3.0 |
|
| 989 | - * @param string $addon_name the name for the addon that was previously registered |
|
| 990 | - * @throws EE_Error |
|
| 991 | - * @return void |
|
| 992 | - */ |
|
| 993 | - public static function deregister($addon_name = null) |
|
| 994 | - { |
|
| 995 | - if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
|
| 996 | - do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
| 997 | - $class_name = self::$_settings[$addon_name]['class_name']; |
|
| 998 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 999 | - // setup DMS |
|
| 1000 | - EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
| 1001 | - } |
|
| 1002 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 1003 | - // register admin page |
|
| 1004 | - EE_Register_Admin_Page::deregister($addon_name); |
|
| 1005 | - } |
|
| 1006 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 1007 | - // add to list of modules to be registered |
|
| 1008 | - EE_Register_Module::deregister($addon_name); |
|
| 1009 | - } |
|
| 1010 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 1011 | - // add to list of shortcodes to be registered |
|
| 1012 | - EE_Register_Shortcode::deregister($addon_name); |
|
| 1013 | - } |
|
| 1014 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 1015 | - // if config_class present let's register config. |
|
| 1016 | - EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
| 1017 | - } |
|
| 1018 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 1019 | - // add to list of widgets to be registered |
|
| 1020 | - EE_Register_Widget::deregister($addon_name); |
|
| 1021 | - } |
|
| 1022 | - if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 1023 | - || |
|
| 1024 | - ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 1025 | - ) { |
|
| 1026 | - // add to list of shortcodes to be registered |
|
| 1027 | - EE_Register_Model::deregister($addon_name); |
|
| 1028 | - } |
|
| 1029 | - if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 1030 | - || |
|
| 1031 | - ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 1032 | - ) { |
|
| 1033 | - // add to list of shortcodes to be registered |
|
| 1034 | - EE_Register_Model_Extensions::deregister($addon_name); |
|
| 1035 | - } |
|
| 1036 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 1037 | - foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
| 1038 | - EE_Register_Message_Type::deregister($message_type); |
|
| 1039 | - } |
|
| 1040 | - } |
|
| 1041 | - //deregister capabilities for addon |
|
| 1042 | - if ( |
|
| 1043 | - ! empty(self::$_settings[$addon_name]['capabilities']) |
|
| 1044 | - || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
| 1045 | - ) { |
|
| 1046 | - EE_Register_Capabilities::deregister($addon_name); |
|
| 1047 | - } |
|
| 1048 | - //deregister custom_post_types for addon |
|
| 1049 | - if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
| 1050 | - EE_Register_CPT::deregister($addon_name); |
|
| 1051 | - } |
|
| 1052 | - remove_action( |
|
| 1053 | - 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
| 1054 | - array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
|
| 1055 | - ); |
|
| 1056 | - remove_action( |
|
| 1057 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 1058 | - array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required') |
|
| 1059 | - ); |
|
| 1060 | - unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]); |
|
| 1061 | - do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
| 1062 | - } |
|
| 1063 | - } |
|
| 985 | + /** |
|
| 986 | + * This deregisters an addon that was previously registered with a specific addon_name. |
|
| 987 | + * |
|
| 988 | + * @since 4.3.0 |
|
| 989 | + * @param string $addon_name the name for the addon that was previously registered |
|
| 990 | + * @throws EE_Error |
|
| 991 | + * @return void |
|
| 992 | + */ |
|
| 993 | + public static function deregister($addon_name = null) |
|
| 994 | + { |
|
| 995 | + if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
|
| 996 | + do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
| 997 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
| 998 | + if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 999 | + // setup DMS |
|
| 1000 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
| 1001 | + } |
|
| 1002 | + if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 1003 | + // register admin page |
|
| 1004 | + EE_Register_Admin_Page::deregister($addon_name); |
|
| 1005 | + } |
|
| 1006 | + if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 1007 | + // add to list of modules to be registered |
|
| 1008 | + EE_Register_Module::deregister($addon_name); |
|
| 1009 | + } |
|
| 1010 | + if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 1011 | + // add to list of shortcodes to be registered |
|
| 1012 | + EE_Register_Shortcode::deregister($addon_name); |
|
| 1013 | + } |
|
| 1014 | + if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 1015 | + // if config_class present let's register config. |
|
| 1016 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
| 1017 | + } |
|
| 1018 | + if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 1019 | + // add to list of widgets to be registered |
|
| 1020 | + EE_Register_Widget::deregister($addon_name); |
|
| 1021 | + } |
|
| 1022 | + if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 1023 | + || |
|
| 1024 | + ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 1025 | + ) { |
|
| 1026 | + // add to list of shortcodes to be registered |
|
| 1027 | + EE_Register_Model::deregister($addon_name); |
|
| 1028 | + } |
|
| 1029 | + if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 1030 | + || |
|
| 1031 | + ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 1032 | + ) { |
|
| 1033 | + // add to list of shortcodes to be registered |
|
| 1034 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
| 1035 | + } |
|
| 1036 | + if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 1037 | + foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
| 1038 | + EE_Register_Message_Type::deregister($message_type); |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + //deregister capabilities for addon |
|
| 1042 | + if ( |
|
| 1043 | + ! empty(self::$_settings[$addon_name]['capabilities']) |
|
| 1044 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
| 1045 | + ) { |
|
| 1046 | + EE_Register_Capabilities::deregister($addon_name); |
|
| 1047 | + } |
|
| 1048 | + //deregister custom_post_types for addon |
|
| 1049 | + if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
| 1050 | + EE_Register_CPT::deregister($addon_name); |
|
| 1051 | + } |
|
| 1052 | + remove_action( |
|
| 1053 | + 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
| 1054 | + array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
|
| 1055 | + ); |
|
| 1056 | + remove_action( |
|
| 1057 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 1058 | + array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required') |
|
| 1059 | + ); |
|
| 1060 | + unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]); |
|
| 1061 | + do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
| 1062 | + } |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | 1065 | |
| 1066 | 1066 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | // offsets: 0 . 1 . 2 . 3 . 4 |
| 67 | 67 | $version_parts = explode('.', $min_core_version); |
| 68 | 68 | //check they specified the micro version (after 2nd period) |
| 69 | - if (! isset($version_parts[2])) { |
|
| 69 | + if ( ! isset($version_parts[2])) { |
|
| 70 | 70 | $version_parts[2] = '0'; |
| 71 | 71 | } |
| 72 | 72 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
| 73 | 73 | //soon we can assume that's 'rc', but this current version is 'alpha' |
| 74 | - if (! isset($version_parts[3])) { |
|
| 74 | + if ( ! isset($version_parts[3])) { |
|
| 75 | 75 | $version_parts[3] = 'dev'; |
| 76 | 76 | } |
| 77 | - if (! isset($version_parts[4])) { |
|
| 77 | + if ( ! isset($version_parts[4])) { |
|
| 78 | 78 | $version_parts[4] = '000'; |
| 79 | 79 | } |
| 80 | 80 | return implode('.', $version_parts); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | // setup PUE |
| 232 | 232 | \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
| 233 | 233 | // does this addon work with this version of core or WordPress ? |
| 234 | - if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 234 | + if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | // register namespaces |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | ) |
| 289 | 289 | ); |
| 290 | 290 | } |
| 291 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 291 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 292 | 292 | throw new EE_Error( |
| 293 | 293 | sprintf( |
| 294 | 294 | __( |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } else { |
| 330 | 330 | $class_name = $setup_args['class_name']; |
| 331 | 331 | } |
| 332 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
| 332 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
@@ -346,105 +346,105 @@ discard block |
||
| 346 | 346 | 'class_name' => $class_name, |
| 347 | 347 | // the addon slug for use in URLs, etc |
| 348 | 348 | 'plugin_slug' => isset($setup_args['plugin_slug']) |
| 349 | - ? (string)$setup_args['plugin_slug'] |
|
| 349 | + ? (string) $setup_args['plugin_slug'] |
|
| 350 | 350 | : '', |
| 351 | 351 | // page slug to be used when generating the "Settings" link on the WP plugin page |
| 352 | 352 | 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
| 353 | - ? (string)$setup_args['plugin_action_slug'] |
|
| 353 | + ? (string) $setup_args['plugin_action_slug'] |
|
| 354 | 354 | : '', |
| 355 | 355 | // the "software" version for the addon |
| 356 | 356 | 'version' => isset($setup_args['version']) |
| 357 | - ? (string)$setup_args['version'] |
|
| 357 | + ? (string) $setup_args['version'] |
|
| 358 | 358 | : '', |
| 359 | 359 | // the minimum version of EE Core that the addon will work with |
| 360 | 360 | 'min_core_version' => isset($setup_args['min_core_version']) |
| 361 | - ? (string)$setup_args['min_core_version'] |
|
| 361 | + ? (string) $setup_args['min_core_version'] |
|
| 362 | 362 | : '', |
| 363 | 363 | // the minimum version of WordPress that the addon will work with |
| 364 | 364 | 'min_wp_version' => isset($setup_args['min_wp_version']) |
| 365 | - ? (string)$setup_args['min_wp_version'] |
|
| 365 | + ? (string) $setup_args['min_wp_version'] |
|
| 366 | 366 | : EE_MIN_WP_VER_REQUIRED, |
| 367 | 367 | // full server path to main file (file loaded directly by WP) |
| 368 | 368 | 'main_file_path' => isset($setup_args['main_file_path']) |
| 369 | - ? (string)$setup_args['main_file_path'] |
|
| 369 | + ? (string) $setup_args['main_file_path'] |
|
| 370 | 370 | : '', |
| 371 | 371 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
| 372 | 372 | 'admin_path' => isset($setup_args['admin_path']) |
| 373 | - ? (string)$setup_args['admin_path'] : '', |
|
| 373 | + ? (string) $setup_args['admin_path'] : '', |
|
| 374 | 374 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
| 375 | 375 | 'admin_callback' => isset($setup_args['admin_callback']) |
| 376 | - ? (string)$setup_args['admin_callback'] |
|
| 376 | + ? (string) $setup_args['admin_callback'] |
|
| 377 | 377 | : '', |
| 378 | 378 | // the section name for this addon's configuration settings section (defaults to "addons") |
| 379 | 379 | 'config_section' => isset($setup_args['config_section']) |
| 380 | - ? (string)$setup_args['config_section'] |
|
| 380 | + ? (string) $setup_args['config_section'] |
|
| 381 | 381 | : 'addons', |
| 382 | 382 | // the class name for this addon's configuration settings object |
| 383 | 383 | 'config_class' => isset($setup_args['config_class']) |
| 384 | - ? (string)$setup_args['config_class'] : '', |
|
| 384 | + ? (string) $setup_args['config_class'] : '', |
|
| 385 | 385 | //the name given to the config for this addons' configuration settings object (optional) |
| 386 | 386 | 'config_name' => isset($setup_args['config_name']) |
| 387 | - ? (string)$setup_args['config_name'] : '', |
|
| 387 | + ? (string) $setup_args['config_name'] : '', |
|
| 388 | 388 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
| 389 | 389 | 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
| 390 | - ? (array)$setup_args['autoloader_paths'] |
|
| 390 | + ? (array) $setup_args['autoloader_paths'] |
|
| 391 | 391 | : array(), |
| 392 | 392 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
| 393 | 393 | 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
| 394 | - ? (array)$setup_args['autoloader_folders'] |
|
| 394 | + ? (array) $setup_args['autoloader_folders'] |
|
| 395 | 395 | : array(), |
| 396 | 396 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
| 397 | 397 | 'dms_paths' => isset($setup_args['dms_paths']) |
| 398 | - ? (array)$setup_args['dms_paths'] |
|
| 398 | + ? (array) $setup_args['dms_paths'] |
|
| 399 | 399 | : array(), |
| 400 | 400 | // array of full server paths to any EED_Modules used by the addon |
| 401 | 401 | 'module_paths' => isset($setup_args['module_paths']) |
| 402 | - ? (array)$setup_args['module_paths'] |
|
| 402 | + ? (array) $setup_args['module_paths'] |
|
| 403 | 403 | : array(), |
| 404 | 404 | // array of full server paths to any EES_Shortcodes used by the addon |
| 405 | 405 | 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
| 406 | - ? (array)$setup_args['shortcode_paths'] |
|
| 406 | + ? (array) $setup_args['shortcode_paths'] |
|
| 407 | 407 | : array(), |
| 408 | 408 | // array of full server paths to any WP_Widgets used by the addon |
| 409 | 409 | 'widget_paths' => isset($setup_args['widget_paths']) |
| 410 | - ? (array)$setup_args['widget_paths'] |
|
| 410 | + ? (array) $setup_args['widget_paths'] |
|
| 411 | 411 | : array(), |
| 412 | 412 | // array of PUE options used by the addon |
| 413 | 413 | 'pue_options' => isset($setup_args['pue_options']) |
| 414 | - ? (array)$setup_args['pue_options'] |
|
| 414 | + ? (array) $setup_args['pue_options'] |
|
| 415 | 415 | : array(), |
| 416 | 416 | 'message_types' => isset($setup_args['message_types']) |
| 417 | - ? (array)$setup_args['message_types'] |
|
| 417 | + ? (array) $setup_args['message_types'] |
|
| 418 | 418 | : array(), |
| 419 | 419 | 'capabilities' => isset($setup_args['capabilities']) |
| 420 | - ? (array)$setup_args['capabilities'] |
|
| 420 | + ? (array) $setup_args['capabilities'] |
|
| 421 | 421 | : array(), |
| 422 | 422 | 'capability_maps' => isset($setup_args['capability_maps']) |
| 423 | - ? (array)$setup_args['capability_maps'] |
|
| 423 | + ? (array) $setup_args['capability_maps'] |
|
| 424 | 424 | : array(), |
| 425 | 425 | 'model_paths' => isset($setup_args['model_paths']) |
| 426 | - ? (array)$setup_args['model_paths'] |
|
| 426 | + ? (array) $setup_args['model_paths'] |
|
| 427 | 427 | : array(), |
| 428 | 428 | 'class_paths' => isset($setup_args['class_paths']) |
| 429 | - ? (array)$setup_args['class_paths'] |
|
| 429 | + ? (array) $setup_args['class_paths'] |
|
| 430 | 430 | : array(), |
| 431 | 431 | 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
| 432 | - ? (array)$setup_args['model_extension_paths'] |
|
| 432 | + ? (array) $setup_args['model_extension_paths'] |
|
| 433 | 433 | : array(), |
| 434 | 434 | 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
| 435 | - ? (array)$setup_args['class_extension_paths'] |
|
| 435 | + ? (array) $setup_args['class_extension_paths'] |
|
| 436 | 436 | : array(), |
| 437 | 437 | 'custom_post_types' => isset($setup_args['custom_post_types']) |
| 438 | - ? (array)$setup_args['custom_post_types'] |
|
| 438 | + ? (array) $setup_args['custom_post_types'] |
|
| 439 | 439 | : array(), |
| 440 | 440 | 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
| 441 | - ? (array)$setup_args['custom_taxonomies'] |
|
| 441 | + ? (array) $setup_args['custom_taxonomies'] |
|
| 442 | 442 | : array(), |
| 443 | 443 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
| 444 | - ? (array)$setup_args['payment_method_paths'] |
|
| 444 | + ? (array) $setup_args['payment_method_paths'] |
|
| 445 | 445 | : array(), |
| 446 | 446 | 'default_terms' => isset($setup_args['default_terms']) |
| 447 | - ? (array)$setup_args['default_terms'] |
|
| 447 | + ? (array) $setup_args['default_terms'] |
|
| 448 | 448 | : array(), |
| 449 | 449 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
| 450 | 450 | // that can be used for adding upgrading/marketing info |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | $setup_args['namespace']['FQNS'], |
| 457 | 457 | $setup_args['namespace']['DIR'] |
| 458 | 458 | ) |
| 459 | - ? (array)$setup_args['namespace'] |
|
| 459 | + ? (array) $setup_args['namespace'] |
|
| 460 | 460 | : array(), |
| 461 | 461 | ); |
| 462 | 462 | // if plugin_action_slug is NOT set, but an admin page path IS set, |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | '</span><br />' |
| 527 | 527 | ); |
| 528 | 528 | } |
| 529 | - if (! empty($incompatibility_message)) { |
|
| 529 | + if ( ! empty($incompatibility_message)) { |
|
| 530 | 530 | // remove 'activate' from the REQUEST |
| 531 | 531 | // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
| 532 | 532 | unset($_GET['activate'], $_REQUEST['activate']); |
@@ -554,19 +554,19 @@ discard block |
||
| 554 | 554 | */ |
| 555 | 555 | private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
| 556 | 556 | { |
| 557 | - if (! empty($setup_args['pue_options'])) { |
|
| 557 | + if ( ! empty($setup_args['pue_options'])) { |
|
| 558 | 558 | self::$_settings[$addon_name]['pue_options'] = array( |
| 559 | 559 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
| 560 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
| 561 | - : 'espresso_' . strtolower($class_name), |
|
| 560 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
| 561 | + : 'espresso_'.strtolower($class_name), |
|
| 562 | 562 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
| 563 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
| 563 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
| 564 | 564 | : plugin_basename($setup_args['main_file_path']), |
| 565 | 565 | 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
| 566 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
| 566 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
| 567 | 567 | : '24', |
| 568 | 568 | 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
| 569 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
| 569 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
| 570 | 570 | : false, |
| 571 | 571 | ); |
| 572 | 572 | add_action( |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | //(as the newly-activated addon wasn't around the first time addons were registered). |
| 615 | 615 | //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
| 616 | 616 | //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
| 617 | - if (! isset(self::$_settings[$addon_name]) |
|
| 617 | + if ( ! isset(self::$_settings[$addon_name]) |
|
| 618 | 618 | || (isset(self::$_settings[$addon_name]) |
| 619 | 619 | && ! isset(self::$_settings[$addon_name]['class_name']) |
| 620 | 620 | ) |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | */ |
| 663 | 663 | private static function _setup_autoloaders($addon_name) |
| 664 | 664 | { |
| 665 | - if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
| 665 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
| 666 | 666 | // setup autoloader for single file |
| 667 | 667 | EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
| 668 | 668 | } |
| 669 | 669 | // setup autoloaders for folders |
| 670 | - if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
| 671 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
| 670 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
| 671 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
| 672 | 672 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
| 673 | 673 | } |
| 674 | 674 | } |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | private static function _register_data_migration_scripts($addon_name) |
| 722 | 722 | { |
| 723 | 723 | // setup DMS |
| 724 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 724 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 725 | 725 | EE_Register_Data_Migration_Scripts::register( |
| 726 | 726 | $addon_name, |
| 727 | 727 | array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | private static function _register_config($addon_name) |
| 739 | 739 | { |
| 740 | 740 | // if config_class is present let's register config. |
| 741 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 741 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 742 | 742 | EE_Register_Config::register( |
| 743 | 743 | self::$_settings[$addon_name]['config_class'], |
| 744 | 744 | array( |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | private static function _register_admin_pages($addon_name) |
| 759 | 759 | { |
| 760 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 760 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 761 | 761 | EE_Register_Admin_Page::register( |
| 762 | 762 | $addon_name, |
| 763 | 763 | array('page_path' => self::$_settings[$addon_name]['admin_path']) |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | */ |
| 774 | 774 | private static function _register_modules($addon_name) |
| 775 | 775 | { |
| 776 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 776 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 777 | 777 | EE_Register_Module::register( |
| 778 | 778 | $addon_name, |
| 779 | 779 | array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | */ |
| 790 | 790 | private static function _register_shortcodes($addon_name) |
| 791 | 791 | { |
| 792 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 792 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 793 | 793 | EE_Register_Shortcode::register( |
| 794 | 794 | $addon_name, |
| 795 | 795 | array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | */ |
| 806 | 806 | private static function _register_widgets($addon_name) |
| 807 | 807 | { |
| 808 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 808 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 809 | 809 | EE_Register_Widget::register( |
| 810 | 810 | $addon_name, |
| 811 | 811 | array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | */ |
| 822 | 822 | private static function _register_capabilities($addon_name) |
| 823 | 823 | { |
| 824 | - if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
| 824 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
| 825 | 825 | EE_Register_Capabilities::register( |
| 826 | 826 | $addon_name, |
| 827 | 827 | array( |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | */ |
| 841 | 841 | private static function _register_message_types($addon_name) |
| 842 | 842 | { |
| 843 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 843 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 844 | 844 | add_action( |
| 845 | 845 | 'EE_Brewing_Regular___messages_caf', |
| 846 | 846 | array('EE_Register_Addon', 'register_message_types') |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | */ |
| 880 | 880 | private static function _register_payment_methods($addon_name) |
| 881 | 881 | { |
| 882 | - if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 882 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 883 | 883 | EE_Register_Payment_Method::register( |
| 884 | 884 | $addon_name, |
| 885 | 885 | array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | //the plugin mainfile's path upon construction. |
| 916 | 916 | register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
| 917 | 917 | // call any additional admin_callback functions during load_admin_controller hook |
| 918 | - if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
| 918 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
| 919 | 919 | add_action( |
| 920 | 920 | 'AHEE__EE_System__load_controllers__load_admin_controllers', |
| 921 | 921 | array($addon, self::$_settings[$addon_name]['admin_callback']) |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | public static function load_pue_update() |
| 934 | 934 | { |
| 935 | 935 | // load PUE client |
| 936 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 936 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
| 937 | 937 | // cycle thru settings |
| 938 | 938 | foreach (self::$_settings as $settings) { |
| 939 | - if (! empty($settings['pue_options'])) { |
|
| 939 | + if ( ! empty($settings['pue_options'])) { |
|
| 940 | 940 | // initiate the class and start the plugin update engine! |
| 941 | 941 | new PluginUpdateEngineChecker( |
| 942 | 942 | // host file URL |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | // plugin slug(s) |
| 945 | 945 | array( |
| 946 | 946 | 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
| 947 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 947 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
| 948 | 948 | ), |
| 949 | 949 | // options |
| 950 | 950 | array( |
@@ -973,8 +973,8 @@ discard block |
||
| 973 | 973 | public static function register_message_types() |
| 974 | 974 | { |
| 975 | 975 | foreach (self::$_settings as $addon_name => $settings) { |
| 976 | - if (! empty($settings['message_types'])) { |
|
| 977 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
| 976 | + if ( ! empty($settings['message_types'])) { |
|
| 977 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
| 978 | 978 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
| 979 | 979 | } |
| 980 | 980 | } |
@@ -995,46 +995,46 @@ discard block |
||
| 995 | 995 | if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
| 996 | 996 | do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
| 997 | 997 | $class_name = self::$_settings[$addon_name]['class_name']; |
| 998 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 998 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 999 | 999 | // setup DMS |
| 1000 | 1000 | EE_Register_Data_Migration_Scripts::deregister($addon_name); |
| 1001 | 1001 | } |
| 1002 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 1002 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 1003 | 1003 | // register admin page |
| 1004 | 1004 | EE_Register_Admin_Page::deregister($addon_name); |
| 1005 | 1005 | } |
| 1006 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 1006 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 1007 | 1007 | // add to list of modules to be registered |
| 1008 | 1008 | EE_Register_Module::deregister($addon_name); |
| 1009 | 1009 | } |
| 1010 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 1010 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
| 1011 | 1011 | // add to list of shortcodes to be registered |
| 1012 | 1012 | EE_Register_Shortcode::deregister($addon_name); |
| 1013 | 1013 | } |
| 1014 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 1014 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 1015 | 1015 | // if config_class present let's register config. |
| 1016 | 1016 | EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
| 1017 | 1017 | } |
| 1018 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 1018 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 1019 | 1019 | // add to list of widgets to be registered |
| 1020 | 1020 | EE_Register_Widget::deregister($addon_name); |
| 1021 | 1021 | } |
| 1022 | - if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 1022 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 1023 | 1023 | || |
| 1024 | 1024 | ! empty(self::$_settings[$addon_name]['class_paths']) |
| 1025 | 1025 | ) { |
| 1026 | 1026 | // add to list of shortcodes to be registered |
| 1027 | 1027 | EE_Register_Model::deregister($addon_name); |
| 1028 | 1028 | } |
| 1029 | - if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 1029 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 1030 | 1030 | || |
| 1031 | 1031 | ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
| 1032 | 1032 | ) { |
| 1033 | 1033 | // add to list of shortcodes to be registered |
| 1034 | 1034 | EE_Register_Model_Extensions::deregister($addon_name); |
| 1035 | 1035 | } |
| 1036 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 1037 | - foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
| 1036 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 1037 | + foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
| 1038 | 1038 | EE_Register_Message_Type::deregister($message_type); |
| 1039 | 1039 | } |
| 1040 | 1040 | } |
@@ -1046,11 +1046,11 @@ discard block |
||
| 1046 | 1046 | EE_Register_Capabilities::deregister($addon_name); |
| 1047 | 1047 | } |
| 1048 | 1048 | //deregister custom_post_types for addon |
| 1049 | - if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
| 1049 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
| 1050 | 1050 | EE_Register_CPT::deregister($addon_name); |
| 1051 | 1051 | } |
| 1052 | 1052 | remove_action( |
| 1053 | - 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
| 1053 | + 'deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
| 1054 | 1054 | array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
| 1055 | 1055 | ); |
| 1056 | 1056 | remove_action( |