@@ -11,59 +11,59 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_Maybe_Serialized_Simple_HTML_Field extends EE_Maybe_Serialized_Text_Field |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * removes all non-basic tags when setting |
|
| 16 | - * |
|
| 17 | - * @param string $value_inputted_for_field_on_model_object |
|
| 18 | - * @return string |
|
| 19 | - */ |
|
| 20 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 21 | - { |
|
| 22 | - return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * removes all non-basic tags when setting |
|
| 16 | + * |
|
| 17 | + * @param string $value_inputted_for_field_on_model_object |
|
| 18 | + * @return string |
|
| 19 | + */ |
|
| 20 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
| 21 | + { |
|
| 22 | + return parent::prepare_for_set($this->_remove_tags($value_inputted_for_field_on_model_object)); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
| 27 | - * |
|
| 28 | - * @param array|string $value |
|
| 29 | - * @return array|string |
|
| 30 | - */ |
|
| 31 | - protected function _remove_tags($value) |
|
| 32 | - { |
|
| 33 | - if (is_array($value)) { |
|
| 34 | - foreach ($value as $key => $v) { |
|
| 35 | - $value[ $key ] = $this->_remove_tags($v); |
|
| 36 | - } |
|
| 37 | - } elseif (is_string($value)) { |
|
| 38 | - $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
| 39 | - } |
|
| 40 | - return $value; |
|
| 41 | - } |
|
| 25 | + /** |
|
| 26 | + * Remove any non-"simple" html tags. @see EE_Simple_HTML_Field |
|
| 27 | + * |
|
| 28 | + * @param array|string $value |
|
| 29 | + * @return array|string |
|
| 30 | + */ |
|
| 31 | + protected function _remove_tags($value) |
|
| 32 | + { |
|
| 33 | + if (is_array($value)) { |
|
| 34 | + foreach ($value as $key => $v) { |
|
| 35 | + $value[ $key ] = $this->_remove_tags($v); |
|
| 36 | + } |
|
| 37 | + } elseif (is_string($value)) { |
|
| 38 | + $value = wp_kses("$value", $this->_get_allowed_tags()); |
|
| 39 | + } |
|
| 40 | + return $value; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
| 45 | - * |
|
| 46 | - * @param array|string $value_found_in_db_for_model_object |
|
| 47 | - * @return array|string |
|
| 48 | - */ |
|
| 49 | - public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 50 | - { |
|
| 51 | - return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * In case unsafe data somehow got inserted into the database, we want to remove tags again |
|
| 45 | + * |
|
| 46 | + * @param array|string $value_found_in_db_for_model_object |
|
| 47 | + * @return array|string |
|
| 48 | + */ |
|
| 49 | + public function prepare_for_set_from_db($value_found_in_db_for_model_object) |
|
| 50 | + { |
|
| 51 | + return $this->_remove_tags(parent::prepare_for_set_from_db($value_found_in_db_for_model_object)); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Determines what tags to allow in this model field |
|
| 57 | - * |
|
| 58 | - * @global array $allowedtags |
|
| 59 | - * @return array |
|
| 60 | - */ |
|
| 61 | - public function _get_allowed_tags() |
|
| 62 | - { |
|
| 63 | - return apply_filters( |
|
| 64 | - 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
| 65 | - EEH_HTML::get_simple_tags(), |
|
| 66 | - $this |
|
| 67 | - ); |
|
| 68 | - } |
|
| 55 | + /** |
|
| 56 | + * Determines what tags to allow in this model field |
|
| 57 | + * |
|
| 58 | + * @global array $allowedtags |
|
| 59 | + * @return array |
|
| 60 | + */ |
|
| 61 | + public function _get_allowed_tags() |
|
| 62 | + { |
|
| 63 | + return apply_filters( |
|
| 64 | + 'FHEE__EE_Maybe_Serialized_Simple_HTML_Field___get_allowed_tags', |
|
| 65 | + EEH_HTML::get_simple_tags(), |
|
| 66 | + $this |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | { |
| 33 | 33 | if (is_array($value)) { |
| 34 | 34 | foreach ($value as $key => $v) { |
| 35 | - $value[ $key ] = $this->_remove_tags($v); |
|
| 35 | + $value[$key] = $this->_remove_tags($v); |
|
| 36 | 36 | } |
| 37 | 37 | } elseif (is_string($value)) { |
| 38 | 38 | $value = wp_kses("$value", $this->_get_allowed_tags()); |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class EE_Unique_Index extends EE_Index |
| 8 | 8 | { |
| 9 | - // yep, actually the same as index right now |
|
| 9 | + // yep, actually the same as index right now |
|
| 10 | 10 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class EE_Primary_Key_Index extends EE_Unique_Index |
| 8 | 8 | { |
| 9 | - // yep, actually the same as unique index right now |
|
| 9 | + // yep, actually the same as unique index right now |
|
| 10 | 10 | } |
@@ -14,141 +14,141 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @var string SQL for performing joins (Eg, "INNER JOIN blah ON blah=blah INNER JOIN FOO ON foo=foo...") |
| 16 | 16 | */ |
| 17 | - private $_join_sql; |
|
| 17 | + private $_join_sql; |
|
| 18 | 18 | /** |
| 19 | 19 | * |
| 20 | 20 | * @var array stating all the models that have been included thus far,so we don't get duplicates. |
| 21 | 21 | * Keys are the model relation chains to them from the queried model |
| 22 | 22 | * (eg, "Registration.Transaction.Payment"), and valuesare model names (eg "Payment") |
| 23 | 23 | */ |
| 24 | - private $_models_included; |
|
| 24 | + private $_models_included; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * After we've acquired all the data types, we can create this sql. |
| 28 | 28 | * @var string |
| 29 | 29 | */ |
| 30 | - private $_where_sql; |
|
| 30 | + private $_where_sql; |
|
| 31 | 31 | /** |
| 32 | 32 | * Full join sql. Eg, in a select query, that's everything after the "FROM", and before the "WHERE", so it includes |
| 33 | 33 | * the declaration of the main model's tables, and then appends all the joining sql to other models |
| 34 | 34 | * @var string |
| 35 | 35 | */ |
| 36 | - private $_main_join_sql; |
|
| 36 | + private $_main_join_sql; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - private $_limit_sql; |
|
| 39 | + private $_limit_sql; |
|
| 40 | 40 | |
| 41 | - private $_order_by_sql; |
|
| 41 | + private $_order_by_sql; |
|
| 42 | 42 | |
| 43 | - private $_having_sql; |
|
| 43 | + private $_having_sql; |
|
| 44 | 44 | |
| 45 | - private $_group_by_sql; |
|
| 45 | + private $_group_by_sql; |
|
| 46 | 46 | |
| 47 | - public function set_limit_sql($limit_sql) |
|
| 48 | - { |
|
| 49 | - $this->_limit_sql = $limit_sql; |
|
| 50 | - } |
|
| 47 | + public function set_limit_sql($limit_sql) |
|
| 48 | + { |
|
| 49 | + $this->_limit_sql = $limit_sql; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - public function set_order_by_sql($order_by_sql) |
|
| 53 | - { |
|
| 54 | - $this->_order_by_sql = $order_by_sql; |
|
| 55 | - } |
|
| 56 | - public function set_group_by_sql($group_by_sql) |
|
| 57 | - { |
|
| 58 | - $this->_group_by_sql = $group_by_sql; |
|
| 59 | - } |
|
| 60 | - public function set_having_sql($having_sql) |
|
| 61 | - { |
|
| 62 | - $this->_having_sql = $having_sql; |
|
| 63 | - } |
|
| 64 | - public function get_limit_sql() |
|
| 65 | - { |
|
| 66 | - return $this->_limit_sql; |
|
| 67 | - } |
|
| 68 | - public function get_order_by_sql() |
|
| 69 | - { |
|
| 70 | - return $this->_order_by_sql; |
|
| 71 | - } |
|
| 72 | - public function get_group_by_sql() |
|
| 73 | - { |
|
| 74 | - return $this->_group_by_sql; |
|
| 75 | - } |
|
| 76 | - public function get_having_sql() |
|
| 77 | - { |
|
| 78 | - return $this->_having_sql; |
|
| 79 | - } |
|
| 52 | + public function set_order_by_sql($order_by_sql) |
|
| 53 | + { |
|
| 54 | + $this->_order_by_sql = $order_by_sql; |
|
| 55 | + } |
|
| 56 | + public function set_group_by_sql($group_by_sql) |
|
| 57 | + { |
|
| 58 | + $this->_group_by_sql = $group_by_sql; |
|
| 59 | + } |
|
| 60 | + public function set_having_sql($having_sql) |
|
| 61 | + { |
|
| 62 | + $this->_having_sql = $having_sql; |
|
| 63 | + } |
|
| 64 | + public function get_limit_sql() |
|
| 65 | + { |
|
| 66 | + return $this->_limit_sql; |
|
| 67 | + } |
|
| 68 | + public function get_order_by_sql() |
|
| 69 | + { |
|
| 70 | + return $this->_order_by_sql; |
|
| 71 | + } |
|
| 72 | + public function get_group_by_sql() |
|
| 73 | + { |
|
| 74 | + return $this->_group_by_sql; |
|
| 75 | + } |
|
| 76 | + public function get_having_sql() |
|
| 77 | + { |
|
| 78 | + return $this->_having_sql; |
|
| 79 | + } |
|
| 80 | 80 | /** |
| 81 | 81 | * |
| 82 | 82 | * @param type $model_included_name |
| 83 | 83 | * @param type $join_sql |
| 84 | 84 | * @param type $data_types |
| 85 | 85 | */ |
| 86 | - public function __construct($model_included_name = array(), $join_sql = '') |
|
| 87 | - { |
|
| 88 | - $this->_models_included = $model_included_name; |
|
| 89 | - $this->_join_sql = $join_sql; |
|
| 90 | - } |
|
| 86 | + public function __construct($model_included_name = array(), $join_sql = '') |
|
| 87 | + { |
|
| 88 | + $this->_models_included = $model_included_name; |
|
| 89 | + $this->_join_sql = $join_sql; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * Merges info from the other EEM_Related_Model_Info_Carrier into this one. |
| 94 | 94 | * @param EE_Model_Query_Info_Carrier $other_model_query_info_carrier |
| 95 | 95 | */ |
| 96 | - public function merge($other_model_query_info_carrier) |
|
| 97 | - { |
|
| 98 | - if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
| 99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 100 | - $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
| 101 | - $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
| 102 | - } |
|
| 103 | - // otherwise don't merge our data. |
|
| 104 | - // yes, this means that we must immediately merge any model data into our grand list |
|
| 105 | - // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
| 106 | - // which is carrying info from two models WHERE one is already included but the other is NOT |
|
| 107 | - } |
|
| 96 | + public function merge($other_model_query_info_carrier) |
|
| 97 | + { |
|
| 98 | + if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
|
| 99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 100 | + $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
|
| 101 | + $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
|
| 102 | + } |
|
| 103 | + // otherwise don't merge our data. |
|
| 104 | + // yes, this means that we must immediately merge any model data into our grand list |
|
| 105 | + // as soon as we get some from ONE model, or else we could reject a EEM_Related_Model_Info_Carrier |
|
| 106 | + // which is carrying info from two models WHERE one is already included but the other is NOT |
|
| 107 | + } |
|
| 108 | 108 | /** |
| 109 | 109 | * Checks whether or not we have already included all the models mentione din $model_names on the query info varrier |
| 110 | 110 | * @param array $model_names just like EE_MOdel_QUery_Info_Carrier::_models_included: keys are model chain paths, values are the model names only |
| 111 | 111 | * @return boolean |
| 112 | 112 | */ |
| 113 | - protected function _have_already_included_one_of_these_models($model_names) |
|
| 114 | - { |
|
| 115 | - foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
| 116 | - if (array_key_exists($model_relation_path, $model_names)) { |
|
| 117 | - return true; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - return false; |
|
| 121 | - } |
|
| 113 | + protected function _have_already_included_one_of_these_models($model_names) |
|
| 114 | + { |
|
| 115 | + foreach ($this->_models_included as $model_relation_path => $model_included) { |
|
| 116 | + if (array_key_exists($model_relation_path, $model_names)) { |
|
| 117 | + return true; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 122 | 122 | /** |
| 123 | 123 | * Array keys are model names, values are "model relation paths". See EE_Model_Query_Info_Carrier::_models_included for details |
| 124 | 124 | * @return array like EE_Model_Query_Info_Carrier::_models_included |
| 125 | 125 | */ |
| 126 | - public function get_model_names_included() |
|
| 127 | - { |
|
| 128 | - return $this->_models_included; |
|
| 129 | - } |
|
| 126 | + public function get_model_names_included() |
|
| 127 | + { |
|
| 128 | + return $this->_models_included; |
|
| 129 | + } |
|
| 130 | 130 | /** |
| 131 | 131 | * sets the $where_sql for later use from client code |
| 132 | 132 | * @param string $where_sql |
| 133 | 133 | */ |
| 134 | - public function set_where_sql($where_sql) |
|
| 135 | - { |
|
| 136 | - $this->_where_sql = $where_sql; |
|
| 137 | - } |
|
| 138 | - public function get_where_sql() |
|
| 139 | - { |
|
| 140 | - return $this->_where_sql; |
|
| 141 | - } |
|
| 134 | + public function set_where_sql($where_sql) |
|
| 135 | + { |
|
| 136 | + $this->_where_sql = $where_sql; |
|
| 137 | + } |
|
| 138 | + public function get_where_sql() |
|
| 139 | + { |
|
| 140 | + return $this->_where_sql; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * Gets the SQL for joining the main model to other models involves in the query, which was set earlier on |
| 145 | 145 | * the EE_Model_Query_info_Carrier by calling set_main_model_join_sql() |
| 146 | 146 | * @return string |
| 147 | 147 | */ |
| 148 | - public function get_main_model_join_sql() |
|
| 149 | - { |
|
| 150 | - return $this->_main_join_sql; |
|
| 151 | - } |
|
| 148 | + public function get_main_model_join_sql() |
|
| 149 | + { |
|
| 150 | + return $this->_main_join_sql; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | * after the FROM and before the WHERE.) |
| 159 | 159 | * @param string $join_sql |
| 160 | 160 | */ |
| 161 | - public function set_main_model_join_sql($join_sql) |
|
| 162 | - { |
|
| 163 | - $this->_main_join_sql = $join_sql; |
|
| 164 | - } |
|
| 165 | - public function get_full_join_sql() |
|
| 166 | - { |
|
| 167 | - return $this->_main_join_sql . $this->_join_sql; |
|
| 168 | - } |
|
| 161 | + public function set_main_model_join_sql($join_sql) |
|
| 162 | + { |
|
| 163 | + $this->_main_join_sql = $join_sql; |
|
| 164 | + } |
|
| 165 | + public function get_full_join_sql() |
|
| 166 | + { |
|
| 167 | + return $this->_main_join_sql . $this->_join_sql; |
|
| 168 | + } |
|
| 169 | 169 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | public function merge($other_model_query_info_carrier) |
| 97 | 97 | { |
| 98 | 98 | if ($other_model_query_info_carrier && ! $this->_have_already_included_one_of_these_models($other_model_query_info_carrier->get_model_names_included())) { |
| 99 | - $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 99 | + $model_included_on_other_join_sql_and_data_types_carrier = $other_model_query_info_carrier->get_model_names_included(); |
|
| 100 | 100 | $this->_models_included = array_merge($this->_models_included, $model_included_on_other_join_sql_and_data_types_carrier); |
| 101 | 101 | $this->_join_sql .= $other_model_query_info_carrier->_join_sql; |
| 102 | 102 | } |
@@ -164,6 +164,6 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | public function get_full_join_sql() |
| 166 | 166 | { |
| 167 | - return $this->_main_join_sql . $this->_join_sql; |
|
| 167 | + return $this->_main_join_sql.$this->_join_sql; |
|
| 168 | 168 | } |
| 169 | 169 | } |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | self::$_instance = new self($grand_total, $session); |
| 66 | 66 | } |
| 67 | 67 | // or maybe retrieve an existing one ? |
| 68 | - if (! self::$_instance instanceof EE_Cart) { |
|
| 68 | + if ( ! self::$_instance instanceof EE_Cart) { |
|
| 69 | 69 | // try getting the cart out of the session |
| 70 | 70 | $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
| 71 | 71 | self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
| 72 | 72 | unset($saved_cart); |
| 73 | 73 | } |
| 74 | 74 | // verify that cart is ok and grand total line item exists |
| 75 | - if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 75 | + if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 76 | 76 | self::$_instance = new self($grand_total, $session); |
| 77 | 77 | } |
| 78 | 78 | self::$_instance->get_grand_total(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function session() |
| 126 | 126 | { |
| 127 | - if (! $this->_session instanceof EE_Session) { |
|
| 127 | + if ( ! $this->_session instanceof EE_Session) { |
|
| 128 | 128 | $this->set_session(); |
| 129 | 129 | } |
| 130 | 130 | return $this->_session; |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | public function __wakeup() |
| 394 | 394 | { |
| 395 | - if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 395 | + if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 396 | 396 | // $this->_grand_total is actually just an ID, so use it to get the object from the db |
| 397 | 397 | $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
| 398 | 398 | } |
@@ -16,412 +16,412 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class EE_Cart implements ResettableInterface |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * instance of the EE_Cart object |
|
| 21 | - * |
|
| 22 | - * @access private |
|
| 23 | - * @var EE_Cart $_instance |
|
| 24 | - */ |
|
| 25 | - private static $_instance; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * instance of the EE_Session object |
|
| 29 | - * |
|
| 30 | - * @access protected |
|
| 31 | - * @var EE_Session $_session |
|
| 32 | - */ |
|
| 33 | - protected $_session; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The total Line item which comprises all the children line-item subtotals, |
|
| 37 | - * which in turn each have their line items. |
|
| 38 | - * Typically, the line item structure will look like: |
|
| 39 | - * grand total |
|
| 40 | - * -tickets-sub-total |
|
| 41 | - * --ticket1 |
|
| 42 | - * --ticket2 |
|
| 43 | - * --... |
|
| 44 | - * -taxes-sub-total |
|
| 45 | - * --tax1 |
|
| 46 | - * --tax2 |
|
| 47 | - * |
|
| 48 | - * @var EE_Line_Item |
|
| 49 | - */ |
|
| 50 | - private $_grand_total; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @singleton method used to instantiate class object |
|
| 55 | - * @access public |
|
| 56 | - * @param EE_Line_Item $grand_total |
|
| 57 | - * @param EE_Session $session |
|
| 58 | - * @return EE_Cart |
|
| 59 | - * @throws EE_Error |
|
| 60 | - * @throws ReflectionException |
|
| 61 | - */ |
|
| 62 | - public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 63 | - { |
|
| 64 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 65 | - self::$_instance = new self($grand_total, $session); |
|
| 66 | - } |
|
| 67 | - // or maybe retrieve an existing one ? |
|
| 68 | - if (! self::$_instance instanceof EE_Cart) { |
|
| 69 | - // try getting the cart out of the session |
|
| 70 | - $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
| 71 | - self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
| 72 | - unset($saved_cart); |
|
| 73 | - } |
|
| 74 | - // verify that cart is ok and grand total line item exists |
|
| 75 | - if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 76 | - self::$_instance = new self($grand_total, $session); |
|
| 77 | - } |
|
| 78 | - self::$_instance->get_grand_total(); |
|
| 79 | - // once everything is all said and done, save the cart to the EE_Session |
|
| 80 | - add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 81 | - return self::$_instance; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * private constructor to prevent direct creation |
|
| 87 | - * |
|
| 88 | - * @Constructor |
|
| 89 | - * @access private |
|
| 90 | - * @param EE_Line_Item $grand_total |
|
| 91 | - * @param EE_Session $session |
|
| 92 | - */ |
|
| 93 | - private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 94 | - { |
|
| 95 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 96 | - $this->set_session($session); |
|
| 97 | - if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 98 | - $this->set_grand_total_line_item($grand_total); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Resets the cart completely (whereas empty_cart |
|
| 105 | - * |
|
| 106 | - * @param EE_Line_Item $grand_total |
|
| 107 | - * @param EE_Session $session |
|
| 108 | - * @return EE_Cart |
|
| 109 | - * @throws EE_Error |
|
| 110 | - * @throws ReflectionException |
|
| 111 | - */ |
|
| 112 | - public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 113 | - { |
|
| 114 | - remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 115 | - if ($session instanceof EE_Session) { |
|
| 116 | - $session->reset_cart(); |
|
| 117 | - } |
|
| 118 | - self::$_instance = null; |
|
| 119 | - return self::instance($grand_total, $session); |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @return EE_Session |
|
| 125 | - */ |
|
| 126 | - public function session() |
|
| 127 | - { |
|
| 128 | - if (! $this->_session instanceof EE_Session) { |
|
| 129 | - $this->set_session(); |
|
| 130 | - } |
|
| 131 | - return $this->_session; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @param EE_Session $session |
|
| 137 | - */ |
|
| 138 | - public function set_session(EE_Session $session = null) |
|
| 139 | - { |
|
| 140 | - $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
| 146 | - * know the grand total line item on it |
|
| 147 | - * |
|
| 148 | - * @param EE_Line_Item $line_item |
|
| 149 | - */ |
|
| 150 | - public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
| 151 | - { |
|
| 152 | - $this->_grand_total = $line_item; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * get_cart_from_reg_url_link |
|
| 158 | - * |
|
| 159 | - * @access public |
|
| 160 | - * @param EE_Transaction $transaction |
|
| 161 | - * @param EE_Session $session |
|
| 162 | - * @return EE_Cart |
|
| 163 | - * @throws EE_Error |
|
| 164 | - * @throws ReflectionException |
|
| 165 | - */ |
|
| 166 | - public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
| 167 | - { |
|
| 168 | - $grand_total = $transaction->total_line_item(); |
|
| 169 | - $grand_total->get_items(); |
|
| 170 | - $grand_total->tax_descendants(); |
|
| 171 | - return EE_Cart::instance($grand_total, $session); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
| 177 | - * |
|
| 178 | - * @return EE_Line_Item |
|
| 179 | - * @throws EE_Error |
|
| 180 | - * @throws ReflectionException |
|
| 181 | - */ |
|
| 182 | - private function _create_grand_total() |
|
| 183 | - { |
|
| 184 | - $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
| 185 | - return $this->_grand_total; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Gets all the line items of object type Ticket |
|
| 191 | - * |
|
| 192 | - * @access public |
|
| 193 | - * @return EE_Line_Item[] |
|
| 194 | - */ |
|
| 195 | - public function get_tickets() |
|
| 196 | - { |
|
| 197 | - if ($this->_grand_total === null) { |
|
| 198 | - return array(); |
|
| 199 | - } |
|
| 200 | - return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * returns the total quantity of tickets in the cart |
|
| 206 | - * |
|
| 207 | - * @access public |
|
| 208 | - * @return int |
|
| 209 | - * @throws EE_Error |
|
| 210 | - * @throws ReflectionException |
|
| 211 | - */ |
|
| 212 | - public function all_ticket_quantity_count() |
|
| 213 | - { |
|
| 214 | - $tickets = $this->get_tickets(); |
|
| 215 | - if (empty($tickets)) { |
|
| 216 | - return 0; |
|
| 217 | - } |
|
| 218 | - $count = 0; |
|
| 219 | - foreach ($tickets as $ticket) { |
|
| 220 | - $count += $ticket->get('LIN_quantity'); |
|
| 221 | - } |
|
| 222 | - return $count; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Gets all the tax line items |
|
| 228 | - * |
|
| 229 | - * @return EE_Line_Item[] |
|
| 230 | - * @throws EE_Error |
|
| 231 | - * @throws ReflectionException |
|
| 232 | - */ |
|
| 233 | - public function get_taxes() |
|
| 234 | - { |
|
| 235 | - return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Gets the total line item (which is a parent of all other line items) on this cart |
|
| 241 | - * |
|
| 242 | - * @return EE_Line_Item |
|
| 243 | - * @throws EE_Error |
|
| 244 | - * @throws ReflectionException |
|
| 245 | - */ |
|
| 246 | - public function get_grand_total() |
|
| 247 | - { |
|
| 248 | - return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @process items for adding to cart |
|
| 254 | - * @access public |
|
| 255 | - * @param EE_Ticket $ticket |
|
| 256 | - * @param int $qty |
|
| 257 | - * @return bool TRUE on success, FALSE on fail |
|
| 258 | - * @throws EE_Error |
|
| 259 | - * @throws ReflectionException |
|
| 260 | - */ |
|
| 261 | - public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
| 262 | - { |
|
| 263 | - EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty, false); |
|
| 264 | - return $this->save_cart(); |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * get_cart_total_before_tax |
|
| 270 | - * |
|
| 271 | - * @access public |
|
| 272 | - * @return float |
|
| 273 | - * @throws EE_Error |
|
| 274 | - * @throws ReflectionException |
|
| 275 | - */ |
|
| 276 | - public function get_cart_total_before_tax() |
|
| 277 | - { |
|
| 278 | - return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * gets the total amount of tax paid for items in this cart |
|
| 284 | - * |
|
| 285 | - * @access public |
|
| 286 | - * @return float |
|
| 287 | - * @throws EE_Error |
|
| 288 | - * @throws ReflectionException |
|
| 289 | - */ |
|
| 290 | - public function get_applied_taxes() |
|
| 291 | - { |
|
| 292 | - return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 298 | - * |
|
| 299 | - * @access public |
|
| 300 | - * @return float |
|
| 301 | - * @throws EE_Error |
|
| 302 | - * @throws ReflectionException |
|
| 303 | - */ |
|
| 304 | - public function get_cart_grand_total() |
|
| 305 | - { |
|
| 306 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 307 | - return $this->get_grand_total()->total(); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 313 | - * |
|
| 314 | - * @access public |
|
| 315 | - * @return float |
|
| 316 | - * @throws EE_Error |
|
| 317 | - * @throws ReflectionException |
|
| 318 | - */ |
|
| 319 | - public function recalculate_all_cart_totals() |
|
| 320 | - { |
|
| 321 | - $pre_tax_total = $this->get_cart_total_before_tax(); |
|
| 322 | - $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 323 | - $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
| 324 | - $this->_grand_total->save_this_and_descendants_to_txn(); |
|
| 325 | - return $this->get_grand_total()->total(); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * deletes an item from the cart |
|
| 331 | - * |
|
| 332 | - * @access public |
|
| 333 | - * @param array|bool|string $line_item_codes |
|
| 334 | - * @return int on success, FALSE on fail |
|
| 335 | - * @throws EE_Error |
|
| 336 | - * @throws ReflectionException |
|
| 337 | - */ |
|
| 338 | - public function delete_items($line_item_codes = false) |
|
| 339 | - { |
|
| 340 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 341 | - return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * @remove ALL items from cart and zero ALL totals |
|
| 347 | - * @access public |
|
| 348 | - * @return bool |
|
| 349 | - * @throws EE_Error |
|
| 350 | - * @throws ReflectionException |
|
| 351 | - */ |
|
| 352 | - public function empty_cart() |
|
| 353 | - { |
|
| 354 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 355 | - $this->_grand_total = $this->_create_grand_total(); |
|
| 356 | - return $this->save_cart(true); |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * @remove ALL items from cart and delete total as well |
|
| 362 | - * @access public |
|
| 363 | - * @return bool |
|
| 364 | - * @throws EE_Error |
|
| 365 | - * @throws ReflectionException |
|
| 366 | - */ |
|
| 367 | - public function delete_cart() |
|
| 368 | - { |
|
| 369 | - if ($this->_grand_total instanceof EE_Line_Item) { |
|
| 370 | - $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
| 371 | - if ($deleted) { |
|
| 372 | - $deleted += $this->_grand_total->delete(); |
|
| 373 | - $this->_grand_total = null; |
|
| 374 | - return true; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - return false; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * @save cart to session |
|
| 383 | - * @access public |
|
| 384 | - * @param bool $apply_taxes |
|
| 385 | - * @return bool TRUE on success, FALSE on fail |
|
| 386 | - * @throws EE_Error |
|
| 387 | - * @throws ReflectionException |
|
| 388 | - */ |
|
| 389 | - public function save_cart($apply_taxes = true) |
|
| 390 | - { |
|
| 391 | - if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
| 392 | - EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 393 | - // make sure we don't cache the transaction because it can get stale |
|
| 394 | - if ( |
|
| 395 | - $this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
| 396 | - && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
| 397 | - ) { |
|
| 398 | - $this->_grand_total->clear_cache('Transaction', null, true); |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - if ($this->session() instanceof EE_Session) { |
|
| 402 | - return $this->session()->set_cart($this); |
|
| 403 | - } |
|
| 404 | - return false; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - public function __wakeup() |
|
| 409 | - { |
|
| 410 | - if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 411 | - // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
| 412 | - $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * @return array |
|
| 419 | - */ |
|
| 420 | - public function __sleep() |
|
| 421 | - { |
|
| 422 | - if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
| 423 | - $this->_grand_total = $this->_grand_total->ID(); |
|
| 424 | - } |
|
| 425 | - return array('_grand_total'); |
|
| 426 | - } |
|
| 19 | + /** |
|
| 20 | + * instance of the EE_Cart object |
|
| 21 | + * |
|
| 22 | + * @access private |
|
| 23 | + * @var EE_Cart $_instance |
|
| 24 | + */ |
|
| 25 | + private static $_instance; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * instance of the EE_Session object |
|
| 29 | + * |
|
| 30 | + * @access protected |
|
| 31 | + * @var EE_Session $_session |
|
| 32 | + */ |
|
| 33 | + protected $_session; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The total Line item which comprises all the children line-item subtotals, |
|
| 37 | + * which in turn each have their line items. |
|
| 38 | + * Typically, the line item structure will look like: |
|
| 39 | + * grand total |
|
| 40 | + * -tickets-sub-total |
|
| 41 | + * --ticket1 |
|
| 42 | + * --ticket2 |
|
| 43 | + * --... |
|
| 44 | + * -taxes-sub-total |
|
| 45 | + * --tax1 |
|
| 46 | + * --tax2 |
|
| 47 | + * |
|
| 48 | + * @var EE_Line_Item |
|
| 49 | + */ |
|
| 50 | + private $_grand_total; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @singleton method used to instantiate class object |
|
| 55 | + * @access public |
|
| 56 | + * @param EE_Line_Item $grand_total |
|
| 57 | + * @param EE_Session $session |
|
| 58 | + * @return EE_Cart |
|
| 59 | + * @throws EE_Error |
|
| 60 | + * @throws ReflectionException |
|
| 61 | + */ |
|
| 62 | + public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 63 | + { |
|
| 64 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 65 | + self::$_instance = new self($grand_total, $session); |
|
| 66 | + } |
|
| 67 | + // or maybe retrieve an existing one ? |
|
| 68 | + if (! self::$_instance instanceof EE_Cart) { |
|
| 69 | + // try getting the cart out of the session |
|
| 70 | + $saved_cart = $session instanceof EE_Session ? $session->cart() : null; |
|
| 71 | + self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session); |
|
| 72 | + unset($saved_cart); |
|
| 73 | + } |
|
| 74 | + // verify that cart is ok and grand total line item exists |
|
| 75 | + if (! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) { |
|
| 76 | + self::$_instance = new self($grand_total, $session); |
|
| 77 | + } |
|
| 78 | + self::$_instance->get_grand_total(); |
|
| 79 | + // once everything is all said and done, save the cart to the EE_Session |
|
| 80 | + add_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 81 | + return self::$_instance; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * private constructor to prevent direct creation |
|
| 87 | + * |
|
| 88 | + * @Constructor |
|
| 89 | + * @access private |
|
| 90 | + * @param EE_Line_Item $grand_total |
|
| 91 | + * @param EE_Session $session |
|
| 92 | + */ |
|
| 93 | + private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 94 | + { |
|
| 95 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 96 | + $this->set_session($session); |
|
| 97 | + if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) { |
|
| 98 | + $this->set_grand_total_line_item($grand_total); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Resets the cart completely (whereas empty_cart |
|
| 105 | + * |
|
| 106 | + * @param EE_Line_Item $grand_total |
|
| 107 | + * @param EE_Session $session |
|
| 108 | + * @return EE_Cart |
|
| 109 | + * @throws EE_Error |
|
| 110 | + * @throws ReflectionException |
|
| 111 | + */ |
|
| 112 | + public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null) |
|
| 113 | + { |
|
| 114 | + remove_action('shutdown', array(self::$_instance, 'save_cart'), 90); |
|
| 115 | + if ($session instanceof EE_Session) { |
|
| 116 | + $session->reset_cart(); |
|
| 117 | + } |
|
| 118 | + self::$_instance = null; |
|
| 119 | + return self::instance($grand_total, $session); |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @return EE_Session |
|
| 125 | + */ |
|
| 126 | + public function session() |
|
| 127 | + { |
|
| 128 | + if (! $this->_session instanceof EE_Session) { |
|
| 129 | + $this->set_session(); |
|
| 130 | + } |
|
| 131 | + return $this->_session; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @param EE_Session $session |
|
| 137 | + */ |
|
| 138 | + public function set_session(EE_Session $session = null) |
|
| 139 | + { |
|
| 140 | + $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session'); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Sets the cart to match the line item. Especially handy for loading an old cart where you |
|
| 146 | + * know the grand total line item on it |
|
| 147 | + * |
|
| 148 | + * @param EE_Line_Item $line_item |
|
| 149 | + */ |
|
| 150 | + public function set_grand_total_line_item(EE_Line_Item $line_item) |
|
| 151 | + { |
|
| 152 | + $this->_grand_total = $line_item; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * get_cart_from_reg_url_link |
|
| 158 | + * |
|
| 159 | + * @access public |
|
| 160 | + * @param EE_Transaction $transaction |
|
| 161 | + * @param EE_Session $session |
|
| 162 | + * @return EE_Cart |
|
| 163 | + * @throws EE_Error |
|
| 164 | + * @throws ReflectionException |
|
| 165 | + */ |
|
| 166 | + public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null) |
|
| 167 | + { |
|
| 168 | + $grand_total = $transaction->total_line_item(); |
|
| 169 | + $grand_total->get_items(); |
|
| 170 | + $grand_total->tax_descendants(); |
|
| 171 | + return EE_Cart::instance($grand_total, $session); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items |
|
| 177 | + * |
|
| 178 | + * @return EE_Line_Item |
|
| 179 | + * @throws EE_Error |
|
| 180 | + * @throws ReflectionException |
|
| 181 | + */ |
|
| 182 | + private function _create_grand_total() |
|
| 183 | + { |
|
| 184 | + $this->_grand_total = EEH_Line_Item::create_total_line_item(); |
|
| 185 | + return $this->_grand_total; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Gets all the line items of object type Ticket |
|
| 191 | + * |
|
| 192 | + * @access public |
|
| 193 | + * @return EE_Line_Item[] |
|
| 194 | + */ |
|
| 195 | + public function get_tickets() |
|
| 196 | + { |
|
| 197 | + if ($this->_grand_total === null) { |
|
| 198 | + return array(); |
|
| 199 | + } |
|
| 200 | + return EEH_Line_Item::get_ticket_line_items($this->_grand_total); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * returns the total quantity of tickets in the cart |
|
| 206 | + * |
|
| 207 | + * @access public |
|
| 208 | + * @return int |
|
| 209 | + * @throws EE_Error |
|
| 210 | + * @throws ReflectionException |
|
| 211 | + */ |
|
| 212 | + public function all_ticket_quantity_count() |
|
| 213 | + { |
|
| 214 | + $tickets = $this->get_tickets(); |
|
| 215 | + if (empty($tickets)) { |
|
| 216 | + return 0; |
|
| 217 | + } |
|
| 218 | + $count = 0; |
|
| 219 | + foreach ($tickets as $ticket) { |
|
| 220 | + $count += $ticket->get('LIN_quantity'); |
|
| 221 | + } |
|
| 222 | + return $count; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Gets all the tax line items |
|
| 228 | + * |
|
| 229 | + * @return EE_Line_Item[] |
|
| 230 | + * @throws EE_Error |
|
| 231 | + * @throws ReflectionException |
|
| 232 | + */ |
|
| 233 | + public function get_taxes() |
|
| 234 | + { |
|
| 235 | + return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children(); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Gets the total line item (which is a parent of all other line items) on this cart |
|
| 241 | + * |
|
| 242 | + * @return EE_Line_Item |
|
| 243 | + * @throws EE_Error |
|
| 244 | + * @throws ReflectionException |
|
| 245 | + */ |
|
| 246 | + public function get_grand_total() |
|
| 247 | + { |
|
| 248 | + return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total(); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @process items for adding to cart |
|
| 254 | + * @access public |
|
| 255 | + * @param EE_Ticket $ticket |
|
| 256 | + * @param int $qty |
|
| 257 | + * @return bool TRUE on success, FALSE on fail |
|
| 258 | + * @throws EE_Error |
|
| 259 | + * @throws ReflectionException |
|
| 260 | + */ |
|
| 261 | + public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1) |
|
| 262 | + { |
|
| 263 | + EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty, false); |
|
| 264 | + return $this->save_cart(); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * get_cart_total_before_tax |
|
| 270 | + * |
|
| 271 | + * @access public |
|
| 272 | + * @return float |
|
| 273 | + * @throws EE_Error |
|
| 274 | + * @throws ReflectionException |
|
| 275 | + */ |
|
| 276 | + public function get_cart_total_before_tax() |
|
| 277 | + { |
|
| 278 | + return $this->get_grand_total()->recalculate_pre_tax_total(); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * gets the total amount of tax paid for items in this cart |
|
| 284 | + * |
|
| 285 | + * @access public |
|
| 286 | + * @return float |
|
| 287 | + * @throws EE_Error |
|
| 288 | + * @throws ReflectionException |
|
| 289 | + */ |
|
| 290 | + public function get_applied_taxes() |
|
| 291 | + { |
|
| 292 | + return EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 298 | + * |
|
| 299 | + * @access public |
|
| 300 | + * @return float |
|
| 301 | + * @throws EE_Error |
|
| 302 | + * @throws ReflectionException |
|
| 303 | + */ |
|
| 304 | + public function get_cart_grand_total() |
|
| 305 | + { |
|
| 306 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 307 | + return $this->get_grand_total()->total(); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers |
|
| 313 | + * |
|
| 314 | + * @access public |
|
| 315 | + * @return float |
|
| 316 | + * @throws EE_Error |
|
| 317 | + * @throws ReflectionException |
|
| 318 | + */ |
|
| 319 | + public function recalculate_all_cart_totals() |
|
| 320 | + { |
|
| 321 | + $pre_tax_total = $this->get_cart_total_before_tax(); |
|
| 322 | + $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 323 | + $this->_grand_total->set_total($pre_tax_total + $taxes_total); |
|
| 324 | + $this->_grand_total->save_this_and_descendants_to_txn(); |
|
| 325 | + return $this->get_grand_total()->total(); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * deletes an item from the cart |
|
| 331 | + * |
|
| 332 | + * @access public |
|
| 333 | + * @param array|bool|string $line_item_codes |
|
| 334 | + * @return int on success, FALSE on fail |
|
| 335 | + * @throws EE_Error |
|
| 336 | + * @throws ReflectionException |
|
| 337 | + */ |
|
| 338 | + public function delete_items($line_item_codes = false) |
|
| 339 | + { |
|
| 340 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 341 | + return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * @remove ALL items from cart and zero ALL totals |
|
| 347 | + * @access public |
|
| 348 | + * @return bool |
|
| 349 | + * @throws EE_Error |
|
| 350 | + * @throws ReflectionException |
|
| 351 | + */ |
|
| 352 | + public function empty_cart() |
|
| 353 | + { |
|
| 354 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 355 | + $this->_grand_total = $this->_create_grand_total(); |
|
| 356 | + return $this->save_cart(true); |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * @remove ALL items from cart and delete total as well |
|
| 362 | + * @access public |
|
| 363 | + * @return bool |
|
| 364 | + * @throws EE_Error |
|
| 365 | + * @throws ReflectionException |
|
| 366 | + */ |
|
| 367 | + public function delete_cart() |
|
| 368 | + { |
|
| 369 | + if ($this->_grand_total instanceof EE_Line_Item) { |
|
| 370 | + $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total); |
|
| 371 | + if ($deleted) { |
|
| 372 | + $deleted += $this->_grand_total->delete(); |
|
| 373 | + $this->_grand_total = null; |
|
| 374 | + return true; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + return false; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * @save cart to session |
|
| 383 | + * @access public |
|
| 384 | + * @param bool $apply_taxes |
|
| 385 | + * @return bool TRUE on success, FALSE on fail |
|
| 386 | + * @throws EE_Error |
|
| 387 | + * @throws ReflectionException |
|
| 388 | + */ |
|
| 389 | + public function save_cart($apply_taxes = true) |
|
| 390 | + { |
|
| 391 | + if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) { |
|
| 392 | + EEH_Line_Item::ensure_taxes_applied($this->_grand_total); |
|
| 393 | + // make sure we don't cache the transaction because it can get stale |
|
| 394 | + if ( |
|
| 395 | + $this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction |
|
| 396 | + && $this->_grand_total->get_one_from_cache('Transaction')->ID() |
|
| 397 | + ) { |
|
| 398 | + $this->_grand_total->clear_cache('Transaction', null, true); |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + if ($this->session() instanceof EE_Session) { |
|
| 402 | + return $this->session()->set_cart($this); |
|
| 403 | + } |
|
| 404 | + return false; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + public function __wakeup() |
|
| 409 | + { |
|
| 410 | + if (! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) { |
|
| 411 | + // $this->_grand_total is actually just an ID, so use it to get the object from the db |
|
| 412 | + $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total); |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * @return array |
|
| 419 | + */ |
|
| 420 | + public function __sleep() |
|
| 421 | + { |
|
| 422 | + if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) { |
|
| 423 | + $this->_grand_total = $this->_grand_total->ID(); |
|
| 424 | + } |
|
| 425 | + return array('_grand_total'); |
|
| 426 | + } |
|
| 427 | 427 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | return htmlspecialchars($string); |
| 47 | 47 | } else { |
| 48 | 48 | if ($translate === false) { |
| 49 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 49 | + return self::ee_tep_parse_input_field_data($string, array('"' => '"')); |
|
| 50 | 50 | } else { |
| 51 | 51 | return self::ee_tep_parse_input_field_data($string, $translate); |
| 52 | 52 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | } else { |
| 87 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 87 | + if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) { |
|
| 88 | 88 | return true; |
| 89 | 89 | } else { |
| 90 | 90 | return false; |
@@ -10,108 +10,108 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class EEH_Formatter |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * _admin_format_content |
|
| 15 | - * Text formatting function for wp_editor. |
|
| 16 | - * This should fix all of the formatting issues of text output from the database. |
|
| 17 | - * |
|
| 18 | - * @static |
|
| 19 | - * @access public |
|
| 20 | - * @param string $content content to format |
|
| 21 | - * @return string formatted content |
|
| 22 | - */ |
|
| 23 | - public static function admin_format_content($content = '') |
|
| 24 | - { |
|
| 25 | - return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
| 26 | - } |
|
| 13 | + /** |
|
| 14 | + * _admin_format_content |
|
| 15 | + * Text formatting function for wp_editor. |
|
| 16 | + * This should fix all of the formatting issues of text output from the database. |
|
| 17 | + * |
|
| 18 | + * @static |
|
| 19 | + * @access public |
|
| 20 | + * @param string $content content to format |
|
| 21 | + * @return string formatted content |
|
| 22 | + */ |
|
| 23 | + public static function admin_format_content($content = '') |
|
| 24 | + { |
|
| 25 | + return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8"))); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * ee_tep_output_string |
|
| 32 | - * todo: we need a description for this. |
|
| 33 | - * |
|
| 34 | - * @static |
|
| 35 | - * @access public |
|
| 36 | - * @param string $string string to handle |
|
| 37 | - * @param boolean $translate //todo what is this for? |
|
| 38 | - * @param boolean $protected true then we run htmlspecialchars and return |
|
| 39 | - * @return string |
|
| 40 | - */ |
|
| 41 | - public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
| 42 | - { |
|
| 43 | - if ($protected === true) { |
|
| 44 | - return htmlspecialchars($string); |
|
| 45 | - } else { |
|
| 46 | - if ($translate === false) { |
|
| 47 | - return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 48 | - } else { |
|
| 49 | - return self::ee_tep_parse_input_field_data($string, $translate); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 30 | + /** |
|
| 31 | + * ee_tep_output_string |
|
| 32 | + * todo: we need a description for this. |
|
| 33 | + * |
|
| 34 | + * @static |
|
| 35 | + * @access public |
|
| 36 | + * @param string $string string to handle |
|
| 37 | + * @param boolean $translate //todo what is this for? |
|
| 38 | + * @param boolean $protected true then we run htmlspecialchars and return |
|
| 39 | + * @return string |
|
| 40 | + */ |
|
| 41 | + public static function ee_tep_output_string($string, $translate = false, $protected = false) |
|
| 42 | + { |
|
| 43 | + if ($protected === true) { |
|
| 44 | + return htmlspecialchars($string); |
|
| 45 | + } else { |
|
| 46 | + if ($translate === false) { |
|
| 47 | + return self::ee_tep_parse_input_field_data($string, array( '"' => '"' )); |
|
| 48 | + } else { |
|
| 49 | + return self::ee_tep_parse_input_field_data($string, $translate); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * ee_tep_parse_input_field_data |
|
| 58 | - * |
|
| 59 | - * @param string $data string to be "translated" |
|
| 60 | - * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
| 61 | - * @return string |
|
| 62 | - */ |
|
| 63 | - public static function ee_tep_parse_input_field_data($data, $parse) |
|
| 64 | - { |
|
| 65 | - return strtr(trim($data), $parse); |
|
| 66 | - } |
|
| 56 | + /** |
|
| 57 | + * ee_tep_parse_input_field_data |
|
| 58 | + * |
|
| 59 | + * @param string $data string to be "translated" |
|
| 60 | + * @param array ] $parse array in the form array( 'from' => 'to', ... ) |
|
| 61 | + * @return string |
|
| 62 | + */ |
|
| 63 | + public static function ee_tep_parse_input_field_data($data, $parse) |
|
| 64 | + { |
|
| 65 | + return strtr(trim($data), $parse); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * [ee_tep_not_null description] |
|
| 72 | - * |
|
| 73 | - * @param string | array $value [description] |
|
| 74 | - * @return bool [description] |
|
| 75 | - */ |
|
| 76 | - public static function ee_tep_not_null($value) |
|
| 77 | - { |
|
| 78 | - if (is_array($value)) { |
|
| 79 | - if (count($value) > 0) { |
|
| 80 | - return true; |
|
| 81 | - } else { |
|
| 82 | - return false; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 86 | - return true; |
|
| 87 | - } else { |
|
| 88 | - return false; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } |
|
| 70 | + /** |
|
| 71 | + * [ee_tep_not_null description] |
|
| 72 | + * |
|
| 73 | + * @param string | array $value [description] |
|
| 74 | + * @return bool [description] |
|
| 75 | + */ |
|
| 76 | + public static function ee_tep_not_null($value) |
|
| 77 | + { |
|
| 78 | + if (is_array($value)) { |
|
| 79 | + if (count($value) > 0) { |
|
| 80 | + return true; |
|
| 81 | + } else { |
|
| 82 | + return false; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) { |
|
| 86 | + return true; |
|
| 87 | + } else { |
|
| 88 | + return false; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Formats a date |
|
| 97 | - * |
|
| 98 | - * @param string $date |
|
| 99 | - * @param string $format - format for the date |
|
| 100 | - * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
| 101 | - * addons at time of writing this. So just deprecated in case of third party use. |
|
| 102 | - * @return string |
|
| 103 | - * @deprecated v4.6.21 |
|
| 104 | - */ |
|
| 105 | - public static function event_date_display($date, $format = '') |
|
| 106 | - { |
|
| 107 | - EE_Error::doing_it_wrong( |
|
| 108 | - __METHOD__, |
|
| 109 | - esc_html__( |
|
| 110 | - 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
| 111 | - 'event_espresso' |
|
| 112 | - ), |
|
| 113 | - '4.6.21' |
|
| 114 | - ); |
|
| 115 | - return $date; |
|
| 116 | - } |
|
| 95 | + /** |
|
| 96 | + * Formats a date |
|
| 97 | + * |
|
| 98 | + * @param string $date |
|
| 99 | + * @param string $format - format for the date |
|
| 100 | + * @deprecated 4.6.12 Note, a search revealed this was not used anywhere in core or in our |
|
| 101 | + * addons at time of writing this. So just deprecated in case of third party use. |
|
| 102 | + * @return string |
|
| 103 | + * @deprecated v4.6.21 |
|
| 104 | + */ |
|
| 105 | + public static function event_date_display($date, $format = '') |
|
| 106 | + { |
|
| 107 | + EE_Error::doing_it_wrong( |
|
| 108 | + __METHOD__, |
|
| 109 | + esc_html__( |
|
| 110 | + 'This method is deprecated as of EE 4.6.12. Currently it does not reformat as with prior behaviour but just returns the incoming string. Please use the EE_Datetime helpers for Datetime on the event to display as desired.', |
|
| 111 | + 'event_espresso' |
|
| 112 | + ), |
|
| 113 | + '4.6.21' |
|
| 114 | + ); |
|
| 115 | + return $date; |
|
| 116 | + } |
|
| 117 | 117 | } |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public function pre_get_posts(WP_Query $WP_Query) |
| 46 | 46 | { |
| 47 | - if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
| 47 | + if ( ! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
| 48 | 48 | return $WP_Query; |
| 49 | 49 | } |
| 50 | 50 | return $WP_Query; |
@@ -11,70 +11,70 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class EE_CPT_Default_Strategy |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * $CPT - the current page, if it utilizes CPTs |
|
| 16 | - * |
|
| 17 | - * @var object |
|
| 18 | - * @access protected |
|
| 19 | - */ |
|
| 20 | - protected $CPT = null; |
|
| 14 | + /** |
|
| 15 | + * $CPT - the current page, if it utilizes CPTs |
|
| 16 | + * |
|
| 17 | + * @var object |
|
| 18 | + * @access protected |
|
| 19 | + */ |
|
| 20 | + protected $CPT = null; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * class constructor |
|
| 25 | - * |
|
| 26 | - * @access private |
|
| 27 | - * @param array $arguments |
|
| 28 | - * @return \EE_CPT_Default_Strategy |
|
| 29 | - */ |
|
| 30 | - public function __construct($arguments = array()) |
|
| 31 | - { |
|
| 32 | - $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
| 33 | - } |
|
| 23 | + /** |
|
| 24 | + * class constructor |
|
| 25 | + * |
|
| 26 | + * @access private |
|
| 27 | + * @param array $arguments |
|
| 28 | + * @return \EE_CPT_Default_Strategy |
|
| 29 | + */ |
|
| 30 | + public function __construct($arguments = array()) |
|
| 31 | + { |
|
| 32 | + $this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : null; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * pre_get_posts |
|
| 38 | - * |
|
| 39 | - * @access public |
|
| 40 | - * @param \WP_Query $WP_Query |
|
| 41 | - * @return \WP_Query |
|
| 42 | - */ |
|
| 43 | - public function pre_get_posts(WP_Query $WP_Query) |
|
| 44 | - { |
|
| 45 | - if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
| 46 | - return $WP_Query; |
|
| 47 | - } |
|
| 48 | - return $WP_Query; |
|
| 49 | - } |
|
| 36 | + /** |
|
| 37 | + * pre_get_posts |
|
| 38 | + * |
|
| 39 | + * @access public |
|
| 40 | + * @param \WP_Query $WP_Query |
|
| 41 | + * @return \WP_Query |
|
| 42 | + */ |
|
| 43 | + public function pre_get_posts(WP_Query $WP_Query) |
|
| 44 | + { |
|
| 45 | + if (! $WP_Query->is_main_query() && ! $WP_Query->is_archive()) { |
|
| 46 | + return $WP_Query; |
|
| 47 | + } |
|
| 48 | + return $WP_Query; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * wp |
|
| 54 | - * |
|
| 55 | - * @access public |
|
| 56 | - * @param \WP_Post[] $posts |
|
| 57 | - * @param \WP_Query $WP_Query |
|
| 58 | - * @return \WP_Post[] |
|
| 59 | - */ |
|
| 60 | - public function the_posts($posts, WP_Query $WP_Query) |
|
| 61 | - { |
|
| 62 | - return $posts; |
|
| 63 | - } |
|
| 52 | + /** |
|
| 53 | + * wp |
|
| 54 | + * |
|
| 55 | + * @access public |
|
| 56 | + * @param \WP_Post[] $posts |
|
| 57 | + * @param \WP_Query $WP_Query |
|
| 58 | + * @return \WP_Post[] |
|
| 59 | + */ |
|
| 60 | + public function the_posts($posts, WP_Query $WP_Query) |
|
| 61 | + { |
|
| 62 | + return $posts; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * get_EE_post_type_metadata |
|
| 68 | - * |
|
| 69 | - * @access public |
|
| 70 | - * @param mixed $meta_value |
|
| 71 | - * @param int $post_id |
|
| 72 | - * @param string $meta_key |
|
| 73 | - * @param string $single |
|
| 74 | - * @return mixed |
|
| 75 | - */ |
|
| 76 | - public function get_EE_post_type_metadata($meta_value = null, $post_id, $meta_key, $single) |
|
| 77 | - { |
|
| 78 | - return $meta_value; |
|
| 79 | - } |
|
| 66 | + /** |
|
| 67 | + * get_EE_post_type_metadata |
|
| 68 | + * |
|
| 69 | + * @access public |
|
| 70 | + * @param mixed $meta_value |
|
| 71 | + * @param int $post_id |
|
| 72 | + * @param string $meta_key |
|
| 73 | + * @param string $single |
|
| 74 | + * @return mixed |
|
| 75 | + */ |
|
| 76 | + public function get_EE_post_type_metadata($meta_value = null, $post_id, $meta_key, $single) |
|
| 77 | + { |
|
| 78 | + return $meta_value; |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | public static function getInvalidCheckoutAccess() |
| 62 | 62 | { |
| 63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
| 63 | + if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
| 64 | 64 | self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
| 65 | 65 | } |
| 66 | 66 | return self::$invalid_checkout_access_form; |
@@ -13,84 +13,84 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class EED_Invalid_Checkout_Access extends EED_Module |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
| 18 | - */ |
|
| 19 | - private static $invalid_checkout_access_form; |
|
| 16 | + /** |
|
| 17 | + * @var InvalidCheckoutAccess $invalid_checkout_access_form |
|
| 18 | + */ |
|
| 19 | + private static $invalid_checkout_access_form; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 23 | - */ |
|
| 24 | - public static function set_hooks() |
|
| 25 | - { |
|
| 26 | - } |
|
| 21 | + /** |
|
| 22 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 23 | + */ |
|
| 24 | + public static function set_hooks() |
|
| 25 | + { |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 31 | - */ |
|
| 32 | - public static function set_hooks_admin() |
|
| 33 | - { |
|
| 34 | - add_action( |
|
| 35 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
| 36 | - array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
| 37 | - 15 |
|
| 38 | - ); |
|
| 39 | - add_filter( |
|
| 40 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
| 41 | - array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
| 42 | - ); |
|
| 43 | - } |
|
| 29 | + /** |
|
| 30 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 31 | + */ |
|
| 32 | + public static function set_hooks_admin() |
|
| 33 | + { |
|
| 34 | + add_action( |
|
| 35 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
| 36 | + array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'), |
|
| 37 | + 15 |
|
| 38 | + ); |
|
| 39 | + add_filter( |
|
| 40 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
| 41 | + array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form') |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * run - initial module setup |
|
| 48 | - * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 49 | - * |
|
| 50 | - * @var WP $WP |
|
| 51 | - */ |
|
| 52 | - public function run($WP) |
|
| 53 | - { |
|
| 54 | - // TODO: Implement run() method. |
|
| 55 | - } |
|
| 46 | + /** |
|
| 47 | + * run - initial module setup |
|
| 48 | + * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
|
| 49 | + * |
|
| 50 | + * @var WP $WP |
|
| 51 | + */ |
|
| 52 | + public function run($WP) |
|
| 53 | + { |
|
| 54 | + // TODO: Implement run() method. |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * @return InvalidCheckoutAccess |
|
| 60 | - */ |
|
| 61 | - public static function getInvalidCheckoutAccess() |
|
| 62 | - { |
|
| 63 | - if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
| 64 | - self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
| 65 | - } |
|
| 66 | - return self::$invalid_checkout_access_form; |
|
| 67 | - } |
|
| 58 | + /** |
|
| 59 | + * @return InvalidCheckoutAccess |
|
| 60 | + */ |
|
| 61 | + public static function getInvalidCheckoutAccess() |
|
| 62 | + { |
|
| 63 | + if (! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) { |
|
| 64 | + self::$invalid_checkout_access_form = new InvalidCheckoutAccess(); |
|
| 65 | + } |
|
| 66 | + return self::$invalid_checkout_access_form; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * email_validation_settings_form |
|
| 72 | - * |
|
| 73 | - * @return void |
|
| 74 | - * @throws EE_Error |
|
| 75 | - */ |
|
| 76 | - public static function display_invalid_checkout_access_form() |
|
| 77 | - { |
|
| 78 | - $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 79 | - echo wp_kses($invalid_checkout_access_form->getForm()->get_html(), AllowedTags::getWithFormTags()); |
|
| 80 | - } |
|
| 70 | + /** |
|
| 71 | + * email_validation_settings_form |
|
| 72 | + * |
|
| 73 | + * @return void |
|
| 74 | + * @throws EE_Error |
|
| 75 | + */ |
|
| 76 | + public static function display_invalid_checkout_access_form() |
|
| 77 | + { |
|
| 78 | + $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 79 | + echo wp_kses($invalid_checkout_access_form->getForm()->get_html(), AllowedTags::getWithFormTags()); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * email_validation_settings_form |
|
| 85 | - * |
|
| 86 | - * @param EE_Registration_Config $EE_Registration_Config |
|
| 87 | - * @return EE_Registration_Config |
|
| 88 | - * @throws EE_Error |
|
| 89 | - * @throws ReflectionException |
|
| 90 | - */ |
|
| 91 | - public static function process_invalid_checkout_access_form(EE_Registration_Config $EE_Registration_Config) |
|
| 92 | - { |
|
| 93 | - $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 94 | - return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
| 95 | - } |
|
| 83 | + /** |
|
| 84 | + * email_validation_settings_form |
|
| 85 | + * |
|
| 86 | + * @param EE_Registration_Config $EE_Registration_Config |
|
| 87 | + * @return EE_Registration_Config |
|
| 88 | + * @throws EE_Error |
|
| 89 | + * @throws ReflectionException |
|
| 90 | + */ |
|
| 91 | + public static function process_invalid_checkout_access_form(EE_Registration_Config $EE_Registration_Config) |
|
| 92 | + { |
|
| 93 | + $invalid_checkout_access_form = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
| 94 | + return $invalid_checkout_access_form->processForm($EE_Registration_Config); |
|
| 95 | + } |
|
| 96 | 96 | } |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | // if this is decaf, which is put on WordPress.org, we need to inform users that |
| 4 | 4 | // we just put an affiliate link there. See https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/ section 12 |
| 5 | 5 | if (apply_filters('FHEE__ee_show_affiliate_links', true)) { |
| 6 | - $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso'); |
|
| 6 | + $closing_tag .= esc_html__(' (affiliate link)', 'event_espresso'); |
|
| 7 | 7 | } |
| 8 | 8 | printf( |
| 9 | - esc_html__( |
|
| 10 | - 'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
| 11 | - 'event_espresso' |
|
| 12 | - ), |
|
| 13 | - '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', |
|
| 14 | - $closing_tag |
|
| 9 | + esc_html__( |
|
| 10 | + 'PayPal Standard (PayPal Payments Standard) is an off-site payment method and is available to event organizers in many countries. A PayPal premier or business account is needed to accept payments. Need a PayPal account? Call 1-855-456-1338 or %1$sclick here to sign up for a merchant account%2$s.', |
|
| 11 | + 'event_espresso' |
|
| 12 | + ), |
|
| 13 | + '<a href="https://eventespresso.com/go/paypalstandard/" target="_blank">', |
|
| 14 | + $closing_tag |
|
| 15 | 15 | ); |