@@ -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 | |
@@ -27,201 +27,201 @@ discard block |
||
| 27 | 27 | class EE_Template_Layout extends EE_Div_Per_Section_Layout |
| 28 | 28 | { |
| 29 | 29 | |
| 30 | - protected $_layout_template_file = null; |
|
| 31 | - |
|
| 32 | - protected $_layout_begin_template_file = null; |
|
| 33 | - |
|
| 34 | - protected $_input_template_file = null; |
|
| 35 | - |
|
| 36 | - protected $_subsection_template_file = null; |
|
| 37 | - |
|
| 38 | - protected $_layout_end_template_file = null; |
|
| 39 | - |
|
| 40 | - protected $_template_args = array(); |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @param array $template_options { |
|
| 46 | - * @type string $_layout_template_file |
|
| 47 | - * @type string $_begin_template_file |
|
| 48 | - * @type string $_input_template_file |
|
| 49 | - * @type string $_subsection_template_file |
|
| 50 | - * @type string $_end_template_file |
|
| 51 | - * @type array $_template_args |
|
| 52 | - * } |
|
| 53 | - */ |
|
| 54 | - public function __construct($template_options = array()) |
|
| 55 | - { |
|
| 56 | - // loop through incoming options |
|
| 57 | - foreach ($template_options as $key => $value) { |
|
| 58 | - // add underscore to $key to match property names |
|
| 59 | - $_key = '_' . $key; |
|
| 60 | - if (property_exists($this, $_key)) { |
|
| 61 | - $this->{$_key} = $value; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - parent::__construct(); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * Also has the side effect of enqueuing any needed JS and CSS for |
|
| 71 | - * this form. |
|
| 72 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 73 | - * proper subsections. |
|
| 74 | - * Returns the HTML |
|
| 75 | - * |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - public function layout_form() |
|
| 79 | - { |
|
| 80 | - if ($this->_layout_template_file) { |
|
| 81 | - return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
| 82 | - } else { |
|
| 83 | - return parent::layout_form(); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * opening div tag for a form |
|
| 91 | - * |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function layout_form_begin() |
|
| 95 | - { |
|
| 96 | - if ($this->_layout_begin_template_file) { |
|
| 97 | - return EEH_Template::locate_template( |
|
| 98 | - $this->_layout_begin_template_file, |
|
| 99 | - $this->template_args(), |
|
| 100 | - true, |
|
| 101 | - true |
|
| 102 | - ); |
|
| 103 | - } else { |
|
| 104 | - return parent::layout_form_begin(); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
| 112 | - * |
|
| 113 | - * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
| 114 | - * @param EE_Form_Input_Base $input |
|
| 115 | - * @return string |
|
| 116 | - */ |
|
| 117 | - public function layout_input($input) |
|
| 118 | - { |
|
| 119 | - if ($this->_input_template_file) { |
|
| 120 | - return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
| 121 | - } |
|
| 122 | - return parent::layout_input($input); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
| 129 | - * |
|
| 130 | - * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
| 131 | - * @param EE_Form_Section_Proper $form_section |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function layout_subsection($form_section) |
|
| 135 | - { |
|
| 136 | - if ($this->_subsection_template_file) { |
|
| 137 | - return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
| 138 | - } |
|
| 139 | - return parent::layout_subsection($form_section); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * closing div tag for a form |
|
| 146 | - * |
|
| 147 | - * @return string |
|
| 148 | - */ |
|
| 149 | - public function layout_form_end() |
|
| 150 | - { |
|
| 151 | - if ($this->_layout_end_template_file) { |
|
| 152 | - return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
| 153 | - } else { |
|
| 154 | - return parent::layout_form_end(); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @param array $template_args |
|
| 162 | - */ |
|
| 163 | - public function set_template_args($template_args = array()) |
|
| 164 | - { |
|
| 165 | - $this->_template_args = $template_args; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * @param array $template_args |
|
| 172 | - */ |
|
| 173 | - public function add_template_args($template_args = array()) |
|
| 174 | - { |
|
| 175 | - $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * @return array |
|
| 182 | - */ |
|
| 183 | - public function template_args() |
|
| 184 | - { |
|
| 185 | - foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
| 186 | - $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
| 187 | - if (strpos($subsection_name, '[') !== false) { |
|
| 188 | - $sub_name = explode('[', $subsection_name); |
|
| 189 | - $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
| 190 | - } else { |
|
| 191 | - $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - // d( $this->_template_args ); |
|
| 195 | - return $this->_template_args; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * prep_form_section_key_name |
|
| 202 | - * |
|
| 203 | - * @access public |
|
| 204 | - * @param string $subsection_name |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 207 | - public static function prep_form_subsection_key_name($subsection_name = '') |
|
| 208 | - { |
|
| 209 | - $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
| 210 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * get_subform - just a wrapper for the above method |
|
| 217 | - * |
|
| 218 | - * @access public |
|
| 219 | - * @param string $subsection_name |
|
| 220 | - * @return string |
|
| 221 | - */ |
|
| 222 | - public static function get_subform_name($subsection_name = '') |
|
| 223 | - { |
|
| 224 | - return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
| 225 | - } |
|
| 30 | + protected $_layout_template_file = null; |
|
| 31 | + |
|
| 32 | + protected $_layout_begin_template_file = null; |
|
| 33 | + |
|
| 34 | + protected $_input_template_file = null; |
|
| 35 | + |
|
| 36 | + protected $_subsection_template_file = null; |
|
| 37 | + |
|
| 38 | + protected $_layout_end_template_file = null; |
|
| 39 | + |
|
| 40 | + protected $_template_args = array(); |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @param array $template_options { |
|
| 46 | + * @type string $_layout_template_file |
|
| 47 | + * @type string $_begin_template_file |
|
| 48 | + * @type string $_input_template_file |
|
| 49 | + * @type string $_subsection_template_file |
|
| 50 | + * @type string $_end_template_file |
|
| 51 | + * @type array $_template_args |
|
| 52 | + * } |
|
| 53 | + */ |
|
| 54 | + public function __construct($template_options = array()) |
|
| 55 | + { |
|
| 56 | + // loop through incoming options |
|
| 57 | + foreach ($template_options as $key => $value) { |
|
| 58 | + // add underscore to $key to match property names |
|
| 59 | + $_key = '_' . $key; |
|
| 60 | + if (property_exists($this, $_key)) { |
|
| 61 | + $this->{$_key} = $value; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + parent::__construct(); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * Also has the side effect of enqueuing any needed JS and CSS for |
|
| 71 | + * this form. |
|
| 72 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 73 | + * proper subsections. |
|
| 74 | + * Returns the HTML |
|
| 75 | + * |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + public function layout_form() |
|
| 79 | + { |
|
| 80 | + if ($this->_layout_template_file) { |
|
| 81 | + return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), true, true); |
|
| 82 | + } else { |
|
| 83 | + return parent::layout_form(); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * opening div tag for a form |
|
| 91 | + * |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function layout_form_begin() |
|
| 95 | + { |
|
| 96 | + if ($this->_layout_begin_template_file) { |
|
| 97 | + return EEH_Template::locate_template( |
|
| 98 | + $this->_layout_begin_template_file, |
|
| 99 | + $this->template_args(), |
|
| 100 | + true, |
|
| 101 | + true |
|
| 102 | + ); |
|
| 103 | + } else { |
|
| 104 | + return parent::layout_form_begin(); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * If an input_template_file was provided upon construction, uses that to layout the input. Otherwise uses parent. |
|
| 112 | + * |
|
| 113 | + * @see EE_DIv_Per_Section_Layout::layout_input() for documentation |
|
| 114 | + * @param EE_Form_Input_Base $input |
|
| 115 | + * @return string |
|
| 116 | + */ |
|
| 117 | + public function layout_input($input) |
|
| 118 | + { |
|
| 119 | + if ($this->_input_template_file) { |
|
| 120 | + return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), true, true); |
|
| 121 | + } |
|
| 122 | + return parent::layout_input($input); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * If a subsection_template_file was provided upon construction, uses that to layout the subsection. Otherwise uses parent. |
|
| 129 | + * |
|
| 130 | + * @see EE_Div_Per_Section_Layout::layout_subsection() for documentation |
|
| 131 | + * @param EE_Form_Section_Proper $form_section |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function layout_subsection($form_section) |
|
| 135 | + { |
|
| 136 | + if ($this->_subsection_template_file) { |
|
| 137 | + return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), true, true); |
|
| 138 | + } |
|
| 139 | + return parent::layout_subsection($form_section); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * closing div tag for a form |
|
| 146 | + * |
|
| 147 | + * @return string |
|
| 148 | + */ |
|
| 149 | + public function layout_form_end() |
|
| 150 | + { |
|
| 151 | + if ($this->_layout_end_template_file) { |
|
| 152 | + return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), true, true); |
|
| 153 | + } else { |
|
| 154 | + return parent::layout_form_end(); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @param array $template_args |
|
| 162 | + */ |
|
| 163 | + public function set_template_args($template_args = array()) |
|
| 164 | + { |
|
| 165 | + $this->_template_args = $template_args; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * @param array $template_args |
|
| 172 | + */ |
|
| 173 | + public function add_template_args($template_args = array()) |
|
| 174 | + { |
|
| 175 | + $this->_template_args = array_merge_recursive($this->_template_args, $template_args); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * @return array |
|
| 182 | + */ |
|
| 183 | + public function template_args() |
|
| 184 | + { |
|
| 185 | + foreach ($this->form_section()->subsections() as $subsection_name => $subsection) { |
|
| 186 | + $subsection_name = self::prep_form_subsection_key_name($subsection_name); |
|
| 187 | + if (strpos($subsection_name, '[') !== false) { |
|
| 188 | + $sub_name = explode('[', $subsection_name); |
|
| 189 | + $this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection); |
|
| 190 | + } else { |
|
| 191 | + $this->_template_args[$subsection_name] = $this->layout_subsection($subsection); |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + // d( $this->_template_args ); |
|
| 195 | + return $this->_template_args; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * prep_form_section_key_name |
|
| 202 | + * |
|
| 203 | + * @access public |
|
| 204 | + * @param string $subsection_name |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | + public static function prep_form_subsection_key_name($subsection_name = '') |
|
| 208 | + { |
|
| 209 | + $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
|
| 210 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * get_subform - just a wrapper for the above method |
|
| 217 | + * |
|
| 218 | + * @access public |
|
| 219 | + * @param string $subsection_name |
|
| 220 | + * @return string |
|
| 221 | + */ |
|
| 222 | + public static function get_subform_name($subsection_name = '') |
|
| 223 | + { |
|
| 224 | + return EE_Template_Layout::prep_form_subsection_key_name($subsection_name); |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | // End of file EE_Template_Layout.strategy.php |
@@ -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 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | // loop through incoming options |
| 57 | 57 | foreach ($template_options as $key => $value) { |
| 58 | 58 | // add underscore to $key to match property names |
| 59 | - $_key = '_' . $key; |
|
| 59 | + $_key = '_'.$key; |
|
| 60 | 60 | if (property_exists($this, $_key)) { |
| 61 | 61 | $this->{$_key} = $value; |
| 62 | 62 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | public static function prep_form_subsection_key_name($subsection_name = '') |
| 208 | 208 | { |
| 209 | 209 | $subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name); |
| 210 | - return is_numeric(substr($subsection_name, 0, 1)) ? 'form_' . $subsection_name : $subsection_name; |
|
| 210 | + return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | |
@@ -111,7 +111,7 @@ |
||
| 111 | 111 | * |
| 112 | 112 | * @abstract |
| 113 | 113 | * @access protected |
| 114 | - * @return array |
|
| 114 | + * @return string[] |
|
| 115 | 115 | */ |
| 116 | 116 | protected function _get_table_filters() |
| 117 | 117 | { |
@@ -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 | /** |
@@ -22,106 +22,106 @@ discard block |
||
| 22 | 22 | class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - private $_status; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @param \Transactions_Admin_Page $admin_page |
|
| 30 | - */ |
|
| 31 | - public function __construct(\Transactions_Admin_Page $admin_page) |
|
| 32 | - { |
|
| 33 | - parent::__construct($admin_page); |
|
| 34 | - $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - *_setup_data |
|
| 40 | - */ |
|
| 41 | - protected function _setup_data() |
|
| 42 | - { |
|
| 43 | - $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
| 44 | - $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
| 45 | - $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - *_set_properties |
|
| 51 | - */ |
|
| 52 | - protected function _set_properties() |
|
| 53 | - { |
|
| 54 | - $this->_wp_list_args = array( |
|
| 55 | - 'singular' => __('transaction', 'event_espresso'), |
|
| 56 | - 'plural' => __('transactions', 'event_espresso'), |
|
| 57 | - 'ajax' => true, |
|
| 58 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 59 | - ); |
|
| 60 | - $ID_column_name = __('ID', 'event_espresso'); |
|
| 61 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 62 | - $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
| 63 | - $ID_column_name .= '</span> '; |
|
| 64 | - $this->_columns = array( |
|
| 65 | - 'TXN_ID' => $ID_column_name, |
|
| 66 | - 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
| 67 | - 'TXN_total' => __('Total', 'event_espresso'), |
|
| 68 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 69 | - 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
| 70 | - 'event_name' => __('Event', 'event_espresso'), |
|
| 71 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 72 | - ); |
|
| 73 | - |
|
| 74 | - $this->_sortable_columns = array( |
|
| 75 | - 'TXN_ID' => array('TXN_ID' => false), |
|
| 76 | - 'event_name' => array('event_name' => false), |
|
| 77 | - 'ATT_fname' => array('ATT_fname' => false), |
|
| 78 | - 'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted |
|
| 79 | - ); |
|
| 80 | - |
|
| 81 | - $this->_primary_column = 'TXN_ID'; |
|
| 82 | - |
|
| 83 | - $this->_hidden_columns = array(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * This simply sets up the row class for the table rows. |
|
| 89 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 90 | - * |
|
| 91 | - * @param EE_Transaction $item the current item |
|
| 92 | - * @return string |
|
| 93 | - * @throws \EE_Error |
|
| 94 | - */ |
|
| 95 | - protected function _get_row_class($item) |
|
| 96 | - { |
|
| 97 | - $class = parent::_get_row_class($item); |
|
| 98 | - //add status class |
|
| 99 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
| 100 | - if ($this->_has_checkbox_column) { |
|
| 101 | - $class .= ' has-checkbox-column'; |
|
| 102 | - } |
|
| 103 | - return $class; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * _get_table_filters |
|
| 109 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 110 | - * get's shown in the table. |
|
| 111 | - * |
|
| 112 | - * @abstract |
|
| 113 | - * @access protected |
|
| 114 | - * @return array |
|
| 115 | - */ |
|
| 116 | - protected function _get_table_filters() |
|
| 117 | - { |
|
| 118 | - $filters = array(); |
|
| 119 | - $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
| 120 | - strtotime('-10 year')); |
|
| 121 | - $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', |
|
| 122 | - current_time('timestamp')); |
|
| 123 | - ob_start(); |
|
| 124 | - ?> |
|
| 25 | + private $_status; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param \Transactions_Admin_Page $admin_page |
|
| 30 | + */ |
|
| 31 | + public function __construct(\Transactions_Admin_Page $admin_page) |
|
| 32 | + { |
|
| 33 | + parent::__construct($admin_page); |
|
| 34 | + $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + *_setup_data |
|
| 40 | + */ |
|
| 41 | + protected function _setup_data() |
|
| 42 | + { |
|
| 43 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
| 44 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
| 45 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + *_set_properties |
|
| 51 | + */ |
|
| 52 | + protected function _set_properties() |
|
| 53 | + { |
|
| 54 | + $this->_wp_list_args = array( |
|
| 55 | + 'singular' => __('transaction', 'event_espresso'), |
|
| 56 | + 'plural' => __('transactions', 'event_espresso'), |
|
| 57 | + 'ajax' => true, |
|
| 58 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 59 | + ); |
|
| 60 | + $ID_column_name = __('ID', 'event_espresso'); |
|
| 61 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 62 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
| 63 | + $ID_column_name .= '</span> '; |
|
| 64 | + $this->_columns = array( |
|
| 65 | + 'TXN_ID' => $ID_column_name, |
|
| 66 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
| 67 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
| 68 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 69 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
| 70 | + 'event_name' => __('Event', 'event_espresso'), |
|
| 71 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 72 | + ); |
|
| 73 | + |
|
| 74 | + $this->_sortable_columns = array( |
|
| 75 | + 'TXN_ID' => array('TXN_ID' => false), |
|
| 76 | + 'event_name' => array('event_name' => false), |
|
| 77 | + 'ATT_fname' => array('ATT_fname' => false), |
|
| 78 | + 'TXN_timestamp' => array('TXN_timestamp' => true) //true means its already sorted |
|
| 79 | + ); |
|
| 80 | + |
|
| 81 | + $this->_primary_column = 'TXN_ID'; |
|
| 82 | + |
|
| 83 | + $this->_hidden_columns = array(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * This simply sets up the row class for the table rows. |
|
| 89 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 90 | + * |
|
| 91 | + * @param EE_Transaction $item the current item |
|
| 92 | + * @return string |
|
| 93 | + * @throws \EE_Error |
|
| 94 | + */ |
|
| 95 | + protected function _get_row_class($item) |
|
| 96 | + { |
|
| 97 | + $class = parent::_get_row_class($item); |
|
| 98 | + //add status class |
|
| 99 | + $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
| 100 | + if ($this->_has_checkbox_column) { |
|
| 101 | + $class .= ' has-checkbox-column'; |
|
| 102 | + } |
|
| 103 | + return $class; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * _get_table_filters |
|
| 109 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
| 110 | + * get's shown in the table. |
|
| 111 | + * |
|
| 112 | + * @abstract |
|
| 113 | + * @access protected |
|
| 114 | + * @return array |
|
| 115 | + */ |
|
| 116 | + protected function _get_table_filters() |
|
| 117 | + { |
|
| 118 | + $filters = array(); |
|
| 119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', |
|
| 120 | + strtotime('-10 year')); |
|
| 121 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y', |
|
| 122 | + current_time('timestamp')); |
|
| 123 | + ob_start(); |
|
| 124 | + ?> |
|
| 125 | 125 | <label for="txn-filter-start-date">Display Transactions from </label> |
| 126 | 126 | <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>" |
| 127 | 127 | name="txn-filter-start-date" size="15"/> |
@@ -129,361 +129,361 @@ discard block |
||
| 129 | 129 | <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>" |
| 130 | 130 | name="txn-filter-end-date" size="15"/> |
| 131 | 131 | <?php |
| 132 | - $filters[] = ob_get_contents(); |
|
| 133 | - ob_end_clean(); |
|
| 134 | - return $filters; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - *_add_view_counts |
|
| 140 | - */ |
|
| 141 | - protected function _add_view_counts() |
|
| 142 | - { |
|
| 143 | - $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all'); |
|
| 144 | - $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned'); |
|
| 145 | - $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed'); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * column TXN_ID |
|
| 151 | - * |
|
| 152 | - * @param \EE_Transaction $item |
|
| 153 | - * @return string |
|
| 154 | - * @throws \EE_Error |
|
| 155 | - */ |
|
| 156 | - public function column_TXN_ID(EE_Transaction $item) |
|
| 157 | - { |
|
| 158 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 159 | - 'action' => 'view_transaction', |
|
| 160 | - 'TXN_ID' => $item->ID(), |
|
| 161 | - ), TXN_ADMIN_URL); |
|
| 162 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
| 163 | - 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
| 164 | - |
|
| 165 | - //txn timestamp |
|
| 166 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
| 167 | - return $content; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * @param \EE_Transaction $item |
|
| 173 | - * @return mixed|string|void |
|
| 174 | - * @throws \EE_Error |
|
| 175 | - */ |
|
| 176 | - protected function _get_txn_timestamp(EE_Transaction $item) |
|
| 177 | - { |
|
| 178 | - //txn timestamp |
|
| 179 | - // is TXN less than 2 hours old ? |
|
| 180 | - if ( |
|
| 181 | - ($item->failed() || $item->is_abandoned()) |
|
| 182 | - && ( |
|
| 183 | - (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
| 184 | - ) |
|
| 185 | - ) { |
|
| 186 | - $timestamp = __('TXN in progress...', 'event_espresso'); |
|
| 187 | - } else { |
|
| 188 | - $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
| 189 | - } |
|
| 190 | - return $timestamp; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * column_cb |
|
| 196 | - * |
|
| 197 | - * @param \EE_Transaction $item |
|
| 198 | - * @return string |
|
| 199 | - * @throws \EE_Error |
|
| 200 | - */ |
|
| 201 | - public function column_cb($item) |
|
| 202 | - { |
|
| 203 | - return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], |
|
| 204 | - $item->ID()); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * column_TXN_timestamp |
|
| 210 | - * |
|
| 211 | - * @param \EE_Transaction $item |
|
| 212 | - * @return string |
|
| 213 | - * @throws \EE_Error |
|
| 214 | - */ |
|
| 215 | - public function column_TXN_timestamp(EE_Transaction $item) |
|
| 216 | - { |
|
| 217 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 218 | - 'action' => 'view_transaction', |
|
| 219 | - 'TXN_ID' => $item->ID(), |
|
| 220 | - ), TXN_ADMIN_URL); |
|
| 221 | - $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
| 222 | - 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
| 223 | - //status |
|
| 224 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 225 | - 'sentence') . '</span>'; |
|
| 226 | - return $txn_date; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * column_TXN_total |
|
| 232 | - * |
|
| 233 | - * @param \EE_Transaction $item |
|
| 234 | - * @return string |
|
| 235 | - * @throws \EE_Error |
|
| 236 | - */ |
|
| 237 | - public function column_TXN_total(EE_Transaction $item) |
|
| 238 | - { |
|
| 239 | - if ($item->get('TXN_total') > 0) { |
|
| 240 | - return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 241 | - $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
| 242 | - } else { |
|
| 243 | - return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * column_TXN_paid |
|
| 250 | - * |
|
| 251 | - * @param \EE_Transaction $item |
|
| 252 | - * @return mixed|string |
|
| 253 | - * @throws \EE_Error |
|
| 254 | - */ |
|
| 255 | - public function column_TXN_paid(EE_Transaction $item) |
|
| 256 | - { |
|
| 257 | - $transaction_total = $item->get('TXN_total'); |
|
| 258 | - $transaction_paid = $item->get('TXN_paid'); |
|
| 259 | - |
|
| 260 | - if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
| 261 | - // monies owing |
|
| 262 | - $span_class = 'txn-overview-part-payment-spn'; |
|
| 263 | - if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
| 264 | - // paid in full |
|
| 265 | - $span_class = 'txn-overview-full-payment-spn'; |
|
| 266 | - } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
| 267 | - // no payments made |
|
| 268 | - $span_class = 'txn-overview-no-payment-spn'; |
|
| 269 | - } |
|
| 270 | - } else { |
|
| 271 | - $span_class = 'txn-overview-free-event-spn'; |
|
| 272 | - $transaction_paid = 0; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - $payment_method = $item->payment_method(); |
|
| 276 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
|
| 277 | - 'event_espresso'); |
|
| 278 | - |
|
| 279 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
| 280 | - if ($transaction_paid > 0) { |
|
| 281 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 282 | - $payment_method_name) . '</span>'; |
|
| 283 | - } |
|
| 284 | - return $content; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * column_ATT_fname |
|
| 290 | - * |
|
| 291 | - * @param \EE_Transaction $item |
|
| 292 | - * @return string|void |
|
| 293 | - * @throws \EE_Error |
|
| 294 | - */ |
|
| 295 | - public function column_ATT_fname(EE_Transaction $item) |
|
| 296 | - { |
|
| 297 | - $primary_reg = $item->primary_registration(); |
|
| 298 | - $attendee = $primary_reg->get_first_related('Attendee'); |
|
| 299 | - if ($attendee instanceof EE_Attendee) { |
|
| 300 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 301 | - 'action' => 'view_registration', |
|
| 302 | - '_REG_ID' => $primary_reg->ID(), |
|
| 303 | - ), REG_ADMIN_URL); |
|
| 304 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 305 | - 'espresso_registrations_view_registration', |
|
| 306 | - $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
| 307 | - 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
| 308 | - $content .= '<br>' . $attendee->email(); |
|
| 309 | - return $content; |
|
| 310 | - } |
|
| 311 | - return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
|
| 312 | - 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 313 | - 'event_espresso'); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - /** |
|
| 318 | - * column_ATT_email |
|
| 319 | - * |
|
| 320 | - * @param \EE_Transaction $item |
|
| 321 | - * @return string|void |
|
| 322 | - * @throws \EE_Error |
|
| 323 | - */ |
|
| 324 | - public function column_ATT_email(EE_Transaction $item) |
|
| 325 | - { |
|
| 326 | - $attendee = $item->primary_registration()->get_first_related('Attendee'); |
|
| 327 | - if (! empty($attendee)) { |
|
| 328 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
| 329 | - } else { |
|
| 330 | - return $item->failed() || $item->is_abandoned() |
|
| 331 | - ? __('no contact record.', 'event_espresso') |
|
| 332 | - : __( |
|
| 333 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 334 | - 'event_espresso' |
|
| 335 | - ); |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * column_event_name |
|
| 342 | - * |
|
| 343 | - * @param \EE_Transaction $item |
|
| 344 | - * @return string|void |
|
| 345 | - * @throws \EE_Error |
|
| 346 | - */ |
|
| 347 | - public function column_event_name(EE_Transaction $item) |
|
| 348 | - { |
|
| 349 | - $actions = array(); |
|
| 350 | - $event = $item->primary_registration()->get_first_related('Event'); |
|
| 351 | - if (! empty($event)) { |
|
| 352 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 353 | - EVENTS_ADMIN_URL); |
|
| 354 | - $event_name = $event->get('EVT_name'); |
|
| 355 | - |
|
| 356 | - //filter this view by transactions for this event |
|
| 357 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 358 | - 'action' => 'default', |
|
| 359 | - 'EVT_ID' => $event->ID(), |
|
| 360 | - )); |
|
| 361 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
| 362 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
| 363 | - 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - return sprintf('%1$s %2$s', |
|
| 367 | - EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
|
| 368 | - $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
| 369 | - 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
| 370 | - '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
| 371 | - } else { |
|
| 372 | - return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
|
| 373 | - 'event_espresso'); |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * column_actions |
|
| 380 | - * |
|
| 381 | - * @param \EE_Transaction $item |
|
| 382 | - * @return string |
|
| 383 | - * @throws \EE_Error |
|
| 384 | - */ |
|
| 385 | - public function column_actions(EE_Transaction $item) |
|
| 386 | - { |
|
| 387 | - |
|
| 388 | - $registration = $item->primary_registration(); |
|
| 389 | - $attendee = $registration->attendee(); |
|
| 390 | - |
|
| 391 | - //Build row actions |
|
| 392 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 393 | - 'action' => 'view_transaction', |
|
| 394 | - 'TXN_ID' => $item->ID(), |
|
| 395 | - ), TXN_ADMIN_URL); |
|
| 396 | - $dl_invoice_lnk_url = $registration->invoice_url(); |
|
| 397 | - $dl_receipt_lnk_url = $registration->receipt_url(); |
|
| 398 | - $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 399 | - 'action' => 'view_registration', |
|
| 400 | - '_REG_ID' => $registration->ID(), |
|
| 401 | - ), REG_ADMIN_URL); |
|
| 402 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 403 | - 'action' => 'send_payment_reminder', |
|
| 404 | - 'TXN_ID' => $item->ID(), |
|
| 405 | - ), TXN_ADMIN_URL); |
|
| 406 | - $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
| 407 | - 'TXN_ID' => $item->ID(), |
|
| 408 | - )); |
|
| 409 | - |
|
| 410 | - //Build row actions |
|
| 411 | - $view_lnk = ' |
|
| 132 | + $filters[] = ob_get_contents(); |
|
| 133 | + ob_end_clean(); |
|
| 134 | + return $filters; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + *_add_view_counts |
|
| 140 | + */ |
|
| 141 | + protected function _add_view_counts() |
|
| 142 | + { |
|
| 143 | + $this->_views['all']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'all'); |
|
| 144 | + $this->_views['abandoned']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'abandoned'); |
|
| 145 | + $this->_views['failed']['count'] = $this->_admin_page->get_transactions($this->_per_page, true, 'failed'); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * column TXN_ID |
|
| 151 | + * |
|
| 152 | + * @param \EE_Transaction $item |
|
| 153 | + * @return string |
|
| 154 | + * @throws \EE_Error |
|
| 155 | + */ |
|
| 156 | + public function column_TXN_ID(EE_Transaction $item) |
|
| 157 | + { |
|
| 158 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 159 | + 'action' => 'view_transaction', |
|
| 160 | + 'TXN_ID' => $item->ID(), |
|
| 161 | + ), TXN_ADMIN_URL); |
|
| 162 | + $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
| 163 | + 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
| 164 | + |
|
| 165 | + //txn timestamp |
|
| 166 | + $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
| 167 | + return $content; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * @param \EE_Transaction $item |
|
| 173 | + * @return mixed|string|void |
|
| 174 | + * @throws \EE_Error |
|
| 175 | + */ |
|
| 176 | + protected function _get_txn_timestamp(EE_Transaction $item) |
|
| 177 | + { |
|
| 178 | + //txn timestamp |
|
| 179 | + // is TXN less than 2 hours old ? |
|
| 180 | + if ( |
|
| 181 | + ($item->failed() || $item->is_abandoned()) |
|
| 182 | + && ( |
|
| 183 | + (time() - EE_Registry::instance()->SSN->lifespan()) < $item->datetime(false, true) |
|
| 184 | + ) |
|
| 185 | + ) { |
|
| 186 | + $timestamp = __('TXN in progress...', 'event_espresso'); |
|
| 187 | + } else { |
|
| 188 | + $timestamp = $item->get_i18n_datetime('TXN_timestamp'); |
|
| 189 | + } |
|
| 190 | + return $timestamp; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * column_cb |
|
| 196 | + * |
|
| 197 | + * @param \EE_Transaction $item |
|
| 198 | + * @return string |
|
| 199 | + * @throws \EE_Error |
|
| 200 | + */ |
|
| 201 | + public function column_cb($item) |
|
| 202 | + { |
|
| 203 | + return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', $this->_wp_list_args['singular'], |
|
| 204 | + $item->ID()); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * column_TXN_timestamp |
|
| 210 | + * |
|
| 211 | + * @param \EE_Transaction $item |
|
| 212 | + * @return string |
|
| 213 | + * @throws \EE_Error |
|
| 214 | + */ |
|
| 215 | + public function column_TXN_timestamp(EE_Transaction $item) |
|
| 216 | + { |
|
| 217 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 218 | + 'action' => 'view_transaction', |
|
| 219 | + 'TXN_ID' => $item->ID(), |
|
| 220 | + ), TXN_ADMIN_URL); |
|
| 221 | + $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
| 222 | + 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
| 223 | + //status |
|
| 224 | + $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 225 | + 'sentence') . '</span>'; |
|
| 226 | + return $txn_date; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * column_TXN_total |
|
| 232 | + * |
|
| 233 | + * @param \EE_Transaction $item |
|
| 234 | + * @return string |
|
| 235 | + * @throws \EE_Error |
|
| 236 | + */ |
|
| 237 | + public function column_TXN_total(EE_Transaction $item) |
|
| 238 | + { |
|
| 239 | + if ($item->get('TXN_total') > 0) { |
|
| 240 | + return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 241 | + $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
| 242 | + } else { |
|
| 243 | + return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * column_TXN_paid |
|
| 250 | + * |
|
| 251 | + * @param \EE_Transaction $item |
|
| 252 | + * @return mixed|string |
|
| 253 | + * @throws \EE_Error |
|
| 254 | + */ |
|
| 255 | + public function column_TXN_paid(EE_Transaction $item) |
|
| 256 | + { |
|
| 257 | + $transaction_total = $item->get('TXN_total'); |
|
| 258 | + $transaction_paid = $item->get('TXN_paid'); |
|
| 259 | + |
|
| 260 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
| 261 | + // monies owing |
|
| 262 | + $span_class = 'txn-overview-part-payment-spn'; |
|
| 263 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
| 264 | + // paid in full |
|
| 265 | + $span_class = 'txn-overview-full-payment-spn'; |
|
| 266 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
| 267 | + // no payments made |
|
| 268 | + $span_class = 'txn-overview-no-payment-spn'; |
|
| 269 | + } |
|
| 270 | + } else { |
|
| 271 | + $span_class = 'txn-overview-free-event-spn'; |
|
| 272 | + $transaction_paid = 0; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + $payment_method = $item->payment_method(); |
|
| 276 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
|
| 277 | + 'event_espresso'); |
|
| 278 | + |
|
| 279 | + $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
| 280 | + if ($transaction_paid > 0) { |
|
| 281 | + $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 282 | + $payment_method_name) . '</span>'; |
|
| 283 | + } |
|
| 284 | + return $content; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * column_ATT_fname |
|
| 290 | + * |
|
| 291 | + * @param \EE_Transaction $item |
|
| 292 | + * @return string|void |
|
| 293 | + * @throws \EE_Error |
|
| 294 | + */ |
|
| 295 | + public function column_ATT_fname(EE_Transaction $item) |
|
| 296 | + { |
|
| 297 | + $primary_reg = $item->primary_registration(); |
|
| 298 | + $attendee = $primary_reg->get_first_related('Attendee'); |
|
| 299 | + if ($attendee instanceof EE_Attendee) { |
|
| 300 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 301 | + 'action' => 'view_registration', |
|
| 302 | + '_REG_ID' => $primary_reg->ID(), |
|
| 303 | + ), REG_ADMIN_URL); |
|
| 304 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 305 | + 'espresso_registrations_view_registration', |
|
| 306 | + $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
| 307 | + 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
| 308 | + $content .= '<br>' . $attendee->email(); |
|
| 309 | + return $content; |
|
| 310 | + } |
|
| 311 | + return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
|
| 312 | + 'event_espresso') : __('No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 313 | + 'event_espresso'); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + /** |
|
| 318 | + * column_ATT_email |
|
| 319 | + * |
|
| 320 | + * @param \EE_Transaction $item |
|
| 321 | + * @return string|void |
|
| 322 | + * @throws \EE_Error |
|
| 323 | + */ |
|
| 324 | + public function column_ATT_email(EE_Transaction $item) |
|
| 325 | + { |
|
| 326 | + $attendee = $item->primary_registration()->get_first_related('Attendee'); |
|
| 327 | + if (! empty($attendee)) { |
|
| 328 | + return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
| 329 | + } else { |
|
| 330 | + return $item->failed() || $item->is_abandoned() |
|
| 331 | + ? __('no contact record.', 'event_espresso') |
|
| 332 | + : __( |
|
| 333 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
| 334 | + 'event_espresso' |
|
| 335 | + ); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * column_event_name |
|
| 342 | + * |
|
| 343 | + * @param \EE_Transaction $item |
|
| 344 | + * @return string|void |
|
| 345 | + * @throws \EE_Error |
|
| 346 | + */ |
|
| 347 | + public function column_event_name(EE_Transaction $item) |
|
| 348 | + { |
|
| 349 | + $actions = array(); |
|
| 350 | + $event = $item->primary_registration()->get_first_related('Event'); |
|
| 351 | + if (! empty($event)) { |
|
| 352 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
|
| 353 | + EVENTS_ADMIN_URL); |
|
| 354 | + $event_name = $event->get('EVT_name'); |
|
| 355 | + |
|
| 356 | + //filter this view by transactions for this event |
|
| 357 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 358 | + 'action' => 'default', |
|
| 359 | + 'EVT_ID' => $event->ID(), |
|
| 360 | + )); |
|
| 361 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
|
| 362 | + $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
| 363 | + 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + return sprintf('%1$s %2$s', |
|
| 367 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
|
| 368 | + $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
| 369 | + 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
| 370 | + '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
| 371 | + } else { |
|
| 372 | + return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
|
| 373 | + 'event_espresso'); |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * column_actions |
|
| 380 | + * |
|
| 381 | + * @param \EE_Transaction $item |
|
| 382 | + * @return string |
|
| 383 | + * @throws \EE_Error |
|
| 384 | + */ |
|
| 385 | + public function column_actions(EE_Transaction $item) |
|
| 386 | + { |
|
| 387 | + |
|
| 388 | + $registration = $item->primary_registration(); |
|
| 389 | + $attendee = $registration->attendee(); |
|
| 390 | + |
|
| 391 | + //Build row actions |
|
| 392 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 393 | + 'action' => 'view_transaction', |
|
| 394 | + 'TXN_ID' => $item->ID(), |
|
| 395 | + ), TXN_ADMIN_URL); |
|
| 396 | + $dl_invoice_lnk_url = $registration->invoice_url(); |
|
| 397 | + $dl_receipt_lnk_url = $registration->receipt_url(); |
|
| 398 | + $view_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 399 | + 'action' => 'view_registration', |
|
| 400 | + '_REG_ID' => $registration->ID(), |
|
| 401 | + ), REG_ADMIN_URL); |
|
| 402 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 403 | + 'action' => 'send_payment_reminder', |
|
| 404 | + 'TXN_ID' => $item->ID(), |
|
| 405 | + ), TXN_ADMIN_URL); |
|
| 406 | + $related_messages_link = EEH_MSG_Template::get_message_action_link('see_notifications_for', null, array( |
|
| 407 | + 'TXN_ID' => $item->ID(), |
|
| 408 | + )); |
|
| 409 | + |
|
| 410 | + //Build row actions |
|
| 411 | + $view_lnk = ' |
|
| 412 | 412 | <li> |
| 413 | 413 | <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
| 414 | 414 | <span class="dashicons dashicons-cart"></span> |
| 415 | 415 | </a> |
| 416 | 416 | </li>'; |
| 417 | 417 | |
| 418 | - $dl_invoice_lnk = ''; |
|
| 419 | - //only show invoice link if message type is active. |
|
| 420 | - if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
| 421 | - $dl_invoice_lnk = ' |
|
| 418 | + $dl_invoice_lnk = ''; |
|
| 419 | + //only show invoice link if message type is active. |
|
| 420 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('invoice')) { |
|
| 421 | + $dl_invoice_lnk = ' |
|
| 422 | 422 | <li> |
| 423 | 423 | <a title="' . esc_attr__('View Transaction Invoice', |
| 424 | - 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
| 424 | + 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
| 425 | 425 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
| 426 | 426 | </a> |
| 427 | 427 | </li>'; |
| 428 | - } |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - $dl_receipt_lnk = ''; |
|
| 431 | - //only show receipt link if message type is active. |
|
| 432 | - if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
| 433 | - $dl_receipt_lnk = ' |
|
| 430 | + $dl_receipt_lnk = ''; |
|
| 431 | + //only show receipt link if message type is active. |
|
| 432 | + if ($attendee instanceof EE_Attendee && EEH_MSG_Template::is_mt_active('receipt')) { |
|
| 433 | + $dl_receipt_lnk = ' |
|
| 434 | 434 | <li> |
| 435 | 435 | <a title="' . esc_attr__('View Transaction Receipt', |
| 436 | - 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
| 436 | + 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
| 437 | 437 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
| 438 | 438 | </a> |
| 439 | 439 | </li>'; |
| 440 | - } |
|
| 441 | - |
|
| 442 | - //only show payment reminder link if the message type is active. |
|
| 443 | - if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
| 444 | - $send_pay_lnk = $attendee instanceof EE_Attendee |
|
| 445 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 446 | - 'ee_send_message', |
|
| 447 | - 'espresso_transactions_send_payment_reminder' |
|
| 448 | - ) |
|
| 449 | - ? ' |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + //only show payment reminder link if the message type is active. |
|
| 443 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
| 444 | + $send_pay_lnk = $attendee instanceof EE_Attendee |
|
| 445 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 446 | + 'ee_send_message', |
|
| 447 | + 'espresso_transactions_send_payment_reminder' |
|
| 448 | + ) |
|
| 449 | + ? ' |
|
| 450 | 450 | <li> |
| 451 | 451 | <a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', |
| 452 | - 'event_espresso') . '" class="tiny-text"> |
|
| 452 | + 'event_espresso') . '" class="tiny-text"> |
|
| 453 | 453 | <span class="dashicons dashicons-email-alt"></span> |
| 454 | 454 | </a> |
| 455 | 455 | </li>' |
| 456 | - : ''; |
|
| 457 | - $send_pay_lnk = $item->get('STS_ID') !== EEM_Transaction::complete_status_code |
|
| 458 | - && $item->get('STS_ID') !== EEM_Transaction::overpaid_status_code |
|
| 459 | - ? $send_pay_lnk |
|
| 460 | - : ''; |
|
| 461 | - } else { |
|
| 462 | - $send_pay_lnk = ''; |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can( |
|
| 466 | - 'ee_read_registration', |
|
| 467 | - 'espresso_registrations_view_registration', |
|
| 468 | - $registration->ID() |
|
| 469 | - ) |
|
| 470 | - ? ' |
|
| 456 | + : ''; |
|
| 457 | + $send_pay_lnk = $item->get('STS_ID') !== EEM_Transaction::complete_status_code |
|
| 458 | + && $item->get('STS_ID') !== EEM_Transaction::overpaid_status_code |
|
| 459 | + ? $send_pay_lnk |
|
| 460 | + : ''; |
|
| 461 | + } else { |
|
| 462 | + $send_pay_lnk = ''; |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + $view_reg_lnk = EE_Registry::instance()->CAP->current_user_can( |
|
| 466 | + 'ee_read_registration', |
|
| 467 | + 'espresso_registrations_view_registration', |
|
| 468 | + $registration->ID() |
|
| 469 | + ) |
|
| 470 | + ? ' |
|
| 471 | 471 | <li> |
| 472 | 472 | <a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', |
| 473 | - 'event_espresso') . '" class="tiny-text"> |
|
| 473 | + 'event_espresso') . '" class="tiny-text"> |
|
| 474 | 474 | <span class="dashicons dashicons-clipboard"></span> |
| 475 | 475 | </a> |
| 476 | 476 | </li>' |
| 477 | - : ''; |
|
| 477 | + : ''; |
|
| 478 | 478 | |
| 479 | - $view_related_messages_lnk = ''; |
|
| 480 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 481 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
| 482 | - } |
|
| 479 | + $view_related_messages_lnk = ''; |
|
| 480 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 481 | + $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
| 482 | + } |
|
| 483 | 483 | |
| 484 | - return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
| 485 | - $item, 'ul', 'txn-overview-actions-ul'); |
|
| 486 | - } |
|
| 484 | + return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
| 485 | + $item, 'ul', 'txn-overview-actions-ul'); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | } |
@@ -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 | |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | 'ajax' => true, |
| 58 | 58 | 'screen' => $this->_admin_page->get_current_screen()->id, |
| 59 | 59 | ); |
| 60 | - $ID_column_name = __('ID', 'event_espresso'); |
|
| 60 | + $ID_column_name = __('ID', 'event_espresso'); |
|
| 61 | 61 | $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
| 62 | 62 | $ID_column_name .= __('Transaction Date', 'event_espresso'); |
| 63 | 63 | $ID_column_name .= '</span> '; |
| 64 | - $this->_columns = array( |
|
| 64 | + $this->_columns = array( |
|
| 65 | 65 | 'TXN_ID' => $ID_column_name, |
| 66 | 66 | 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
| 67 | 67 | 'TXN_total' => __('Total', 'event_espresso'), |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | $class = parent::_get_row_class($item); |
| 98 | 98 | //add status class |
| 99 | - $class .= ' ee-status-strip txn-status-' . $item->status_ID(); |
|
| 99 | + $class .= ' ee-status-strip txn-status-'.$item->status_ID(); |
|
| 100 | 100 | if ($this->_has_checkbox_column) { |
| 101 | 101 | $class .= ' has-checkbox-column'; |
| 102 | 102 | } |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | 'action' => 'view_transaction', |
| 160 | 160 | 'TXN_ID' => $item->ID(), |
| 161 | 161 | ), TXN_ADMIN_URL); |
| 162 | - $content = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('Go to Transaction Details', |
|
| 163 | - 'event_espresso') . '">' . $item->ID() . '</a>'; |
|
| 162 | + $content = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('Go to Transaction Details', |
|
| 163 | + 'event_espresso').'">'.$item->ID().'</a>'; |
|
| 164 | 164 | |
| 165 | 165 | //txn timestamp |
| 166 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($item) . '</span>'; |
|
| 166 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($item).'</span>'; |
|
| 167 | 167 | return $content; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | 'action' => 'view_transaction', |
| 219 | 219 | 'TXN_ID' => $item->ID(), |
| 220 | 220 | ), TXN_ADMIN_URL); |
| 221 | - $txn_date = '<a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details for TXN #', |
|
| 222 | - 'event_espresso') . $item->ID() . '">' . $this->_get_txn_timestamp($item) . '</a>'; |
|
| 221 | + $txn_date = '<a href="'.$view_lnk_url.'" title="'.esc_attr__('View Transaction Details for TXN #', |
|
| 222 | + 'event_espresso').$item->ID().'">'.$this->_get_txn_timestamp($item).'</a>'; |
|
| 223 | 223 | //status |
| 224 | - $txn_date .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 225 | - 'sentence') . '</span>'; |
|
| 224 | + $txn_date .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, |
|
| 225 | + 'sentence').'</span>'; |
|
| 226 | 226 | return $txn_date; |
| 227 | 227 | } |
| 228 | 228 | |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | public function column_TXN_total(EE_Transaction $item) |
| 238 | 238 | { |
| 239 | 239 | if ($item->get('TXN_total') > 0) { |
| 240 | - return '<span class="txn-pad-rght">' . apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 241 | - $item->get_pretty('TXN_total'), $item) . '</span>'; |
|
| 240 | + return '<span class="txn-pad-rght">'.apply_filters('FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
| 241 | + $item->get_pretty('TXN_total'), $item).'</span>'; |
|
| 242 | 242 | } else { |
| 243 | - return '<span class="txn-overview-free-event-spn">' . __('free', 'event_espresso') . '</span>'; |
|
| 243 | + return '<span class="txn-overview-free-event-spn">'.__('free', 'event_espresso').'</span>'; |
|
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
@@ -276,10 +276,10 @@ discard block |
||
| 276 | 276 | $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', |
| 277 | 277 | 'event_espresso'); |
| 278 | 278 | |
| 279 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' . $transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid . '</span>'; |
|
| 279 | + $content = '<span class="'.$span_class.' txn-pad-rght">'.$transaction_paid !== 0 ? $item->get_pretty('TXN_paid') : $transaction_paid.'</span>'; |
|
| 280 | 280 | if ($transaction_paid > 0) { |
| 281 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 282 | - $payment_method_name) . '</span>'; |
|
| 281 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), |
|
| 282 | + $payment_method_name).'</span>'; |
|
| 283 | 283 | } |
| 284 | 284 | return $content; |
| 285 | 285 | } |
@@ -301,11 +301,11 @@ discard block |
||
| 301 | 301 | 'action' => 'view_registration', |
| 302 | 302 | '_REG_ID' => $primary_reg->ID(), |
| 303 | 303 | ), REG_ADMIN_URL); |
| 304 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 304 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 305 | 305 | 'espresso_registrations_view_registration', |
| 306 | - $primary_reg->ID()) ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
| 307 | - 'event_espresso') . '">' . $attendee->full_name() . '</a>' : $attendee->full_name(); |
|
| 308 | - $content .= '<br>' . $attendee->email(); |
|
| 306 | + $primary_reg->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', |
|
| 307 | + 'event_espresso').'">'.$attendee->full_name().'</a>' : $attendee->full_name(); |
|
| 308 | + $content .= '<br>'.$attendee->email(); |
|
| 309 | 309 | return $content; |
| 310 | 310 | } |
| 311 | 311 | return $item->failed() || $item->is_abandoned() ? __('no contact record.', |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | public function column_ATT_email(EE_Transaction $item) |
| 325 | 325 | { |
| 326 | 326 | $attendee = $item->primary_registration()->get_first_related('Attendee'); |
| 327 | - if (! empty($attendee)) { |
|
| 328 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' . $attendee->get('ATT_email') . '</a>'; |
|
| 327 | + if ( ! empty($attendee)) { |
|
| 328 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">'.$attendee->get('ATT_email').'</a>'; |
|
| 329 | 329 | } else { |
| 330 | 330 | return $item->failed() || $item->is_abandoned() |
| 331 | 331 | ? __('no contact record.', 'event_espresso') |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | { |
| 349 | 349 | $actions = array(); |
| 350 | 350 | $event = $item->primary_registration()->get_first_related('Event'); |
| 351 | - if (! empty($event)) { |
|
| 351 | + if ( ! empty($event)) { |
|
| 352 | 352 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), |
| 353 | 353 | EVENTS_ADMIN_URL); |
| 354 | 354 | $event_name = $event->get('EVT_name'); |
@@ -359,15 +359,15 @@ discard block |
||
| 359 | 359 | 'EVT_ID' => $event->ID(), |
| 360 | 360 | )); |
| 361 | 361 | if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $event->ID())) { |
| 362 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '" title="' . esc_attr__('Filter transactions by this event', |
|
| 363 | - 'event_espresso') . '">' . __('View Transactions for this event', 'event_espresso') . '</a>'; |
|
| 362 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'" title="'.esc_attr__('Filter transactions by this event', |
|
| 363 | + 'event_espresso').'">'.__('View Transactions for this event', 'event_espresso').'</a>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | return sprintf('%1$s %2$s', |
| 367 | 367 | EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', |
| 368 | - $event->ID()) ? '<a href="' . $edit_event_url . '" title="' . sprintf(esc_attr__('Edit Event: %s', |
|
| 369 | - 'event_espresso'), $event->get('EVT_name')) . '">' . wp_trim_words($event_name, 30, |
|
| 370 | - '...') . '</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
| 368 | + $event->ID()) ? '<a href="'.$edit_event_url.'" title="'.sprintf(esc_attr__('Edit Event: %s', |
|
| 369 | + 'event_espresso'), $event->get('EVT_name')).'">'.wp_trim_words($event_name, 30, |
|
| 370 | + '...').'</a>' : wp_trim_words($event_name, 30, '...'), $this->row_actions($actions)); |
|
| 371 | 371 | } else { |
| 372 | 372 | return __('The event associated with this transaction via the primary registration cannot be retrieved.', |
| 373 | 373 | 'event_espresso'); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $attendee = $registration->attendee(); |
| 390 | 390 | |
| 391 | 391 | //Build row actions |
| 392 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 392 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 393 | 393 | 'action' => 'view_transaction', |
| 394 | 394 | 'TXN_ID' => $item->ID(), |
| 395 | 395 | ), TXN_ADMIN_URL); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | 'action' => 'view_registration', |
| 400 | 400 | '_REG_ID' => $registration->ID(), |
| 401 | 401 | ), REG_ADMIN_URL); |
| 402 | - $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 402 | + $send_pay_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 403 | 403 | 'action' => 'send_payment_reminder', |
| 404 | 404 | 'TXN_ID' => $item->ID(), |
| 405 | 405 | ), TXN_ADMIN_URL); |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | //Build row actions |
| 411 | 411 | $view_lnk = ' |
| 412 | 412 | <li> |
| 413 | - <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
|
| 413 | + <a href="' . $view_lnk_url.'" title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
| 414 | 414 | <span class="dashicons dashicons-cart"></span> |
| 415 | 415 | </a> |
| 416 | 416 | </li>'; |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | $dl_invoice_lnk = ' |
| 422 | 422 | <li> |
| 423 | 423 | <a title="' . esc_attr__('View Transaction Invoice', |
| 424 | - 'event_espresso') . '" target="_blank" href="' . $dl_invoice_lnk_url . '" class="tiny-text"> |
|
| 424 | + 'event_espresso').'" target="_blank" href="'.$dl_invoice_lnk_url.'" class="tiny-text"> |
|
| 425 | 425 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
| 426 | 426 | </a> |
| 427 | 427 | </li>'; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $dl_receipt_lnk = ' |
| 434 | 434 | <li> |
| 435 | 435 | <a title="' . esc_attr__('View Transaction Receipt', |
| 436 | - 'event_espresso') . '" target="_blank" href="' . $dl_receipt_lnk_url . '" class="tiny-text"> |
|
| 436 | + 'event_espresso').'" target="_blank" href="'.$dl_receipt_lnk_url.'" class="tiny-text"> |
|
| 437 | 437 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
| 438 | 438 | </a> |
| 439 | 439 | </li>'; |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | ) |
| 449 | 449 | ? ' |
| 450 | 450 | <li> |
| 451 | - <a href="' . $send_pay_lnk_url . '" title="' . esc_attr__('Send Payment Reminder', |
|
| 452 | - 'event_espresso') . '" class="tiny-text"> |
|
| 451 | + <a href="' . $send_pay_lnk_url.'" title="'.esc_attr__('Send Payment Reminder', |
|
| 452 | + 'event_espresso').'" class="tiny-text"> |
|
| 453 | 453 | <span class="dashicons dashicons-email-alt"></span> |
| 454 | 454 | </a> |
| 455 | 455 | </li>' |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | ) |
| 470 | 470 | ? ' |
| 471 | 471 | <li> |
| 472 | - <a href="' . $view_reg_lnk_url . '" title="' . esc_attr__('View Registration Details', |
|
| 473 | - 'event_espresso') . '" class="tiny-text"> |
|
| 472 | + <a href="' . $view_reg_lnk_url.'" title="'.esc_attr__('View Registration Details', |
|
| 473 | + 'event_espresso').'" class="tiny-text"> |
|
| 474 | 474 | <span class="dashicons dashicons-clipboard"></span> |
| 475 | 475 | </a> |
| 476 | 476 | </li>' |
@@ -478,10 +478,10 @@ discard block |
||
| 478 | 478 | |
| 479 | 479 | $view_related_messages_lnk = ''; |
| 480 | 480 | if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
| 481 | - $view_related_messages_lnk = '<li>' . $related_messages_link . '</li>'; |
|
| 481 | + $view_related_messages_lnk = '<li>'.$related_messages_link.'</li>'; |
|
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - return $this->_action_string($view_lnk . $dl_invoice_lnk . $dl_receipt_lnk . $view_reg_lnk . $send_pay_lnk . $view_related_messages_lnk, |
|
| 484 | + return $this->_action_string($view_lnk.$dl_invoice_lnk.$dl_receipt_lnk.$view_reg_lnk.$send_pay_lnk.$view_related_messages_lnk, |
|
| 485 | 485 | $item, 'ul', 'txn-overview-actions-ul'); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -16,612 +16,612 @@ |
||
| 16 | 16 | class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * array of events |
|
| 21 | - * |
|
| 22 | - * @type EE_Line_Item[] $_events |
|
| 23 | - */ |
|
| 24 | - private $_events = array(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * whether to display the taxes row or not |
|
| 28 | - * |
|
| 29 | - * @type bool $_show_taxes |
|
| 30 | - */ |
|
| 31 | - private $_show_taxes = false; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * html for any tax rows |
|
| 35 | - * |
|
| 36 | - * @type string $_show_taxes |
|
| 37 | - */ |
|
| 38 | - private $_taxes_html = ''; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * total amount including tax we can bill for at this time |
|
| 42 | - * |
|
| 43 | - * @type float $_grand_total |
|
| 44 | - */ |
|
| 45 | - private $_grand_total = 0.00; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * total number of items being billed for |
|
| 49 | - * |
|
| 50 | - * @type int $_total_items |
|
| 51 | - */ |
|
| 52 | - private $_total_items = 0; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @return float |
|
| 58 | - */ |
|
| 59 | - public function grand_total() |
|
| 60 | - { |
|
| 61 | - return $this->_grand_total; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * @return int |
|
| 68 | - */ |
|
| 69 | - public function total_items() |
|
| 70 | - { |
|
| 71 | - return $this->_total_items; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param EE_Line_Item $line_item |
|
| 78 | - * @param array $options |
|
| 79 | - * @param EE_Line_Item $parent_line_item |
|
| 80 | - * @return mixed |
|
| 81 | - * @throws EE_Error |
|
| 82 | - */ |
|
| 83 | - public function display_line_item( |
|
| 84 | - EE_Line_Item $line_item, |
|
| 85 | - $options = array(), |
|
| 86 | - EE_Line_Item $parent_line_item = null |
|
| 87 | - ) { |
|
| 88 | - $html = ''; |
|
| 89 | - // set some default options and merge with incoming |
|
| 90 | - $default_options = array( |
|
| 91 | - 'show_desc' => true, // true false |
|
| 92 | - 'odd' => false, |
|
| 93 | - ); |
|
| 94 | - $options = array_merge($default_options, (array)$options); |
|
| 95 | - switch ($line_item->type()) { |
|
| 96 | - case EEM_Line_Item::type_line_item: |
|
| 97 | - $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
| 98 | - if ($line_item->OBJ_type() === 'Ticket') { |
|
| 99 | - // item row |
|
| 100 | - $html .= $this->_ticket_row($line_item, $options); |
|
| 101 | - } else { |
|
| 102 | - // item row |
|
| 103 | - $html .= $this->_item_row($line_item, $options); |
|
| 104 | - } |
|
| 105 | - if ( |
|
| 106 | - apply_filters( |
|
| 107 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
| 108 | - true |
|
| 109 | - ) |
|
| 110 | - ) { |
|
| 111 | - // got any kids? |
|
| 112 | - foreach ($line_item->children() as $child_line_item) { |
|
| 113 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - break; |
|
| 117 | - case EEM_Line_Item::type_sub_line_item: |
|
| 118 | - $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
| 119 | - break; |
|
| 120 | - case EEM_Line_Item::type_sub_total: |
|
| 121 | - static $sub_total = 0; |
|
| 122 | - $event_sub_total = 0; |
|
| 123 | - $text = esc_html__('Sub-Total', 'event_espresso'); |
|
| 124 | - if ($line_item->OBJ_type() === 'Event') { |
|
| 125 | - $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
| 126 | - if (! isset($this->_events[$options['event_id']])) { |
|
| 127 | - $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
| 128 | - // if event has default reg status of Not Approved, then don't display info on it |
|
| 129 | - if ( |
|
| 130 | - $event instanceof EE_Event |
|
| 131 | - && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
| 132 | - ) { |
|
| 133 | - $display_event = false; |
|
| 134 | - // unless there are registrations for it that are returning to pay |
|
| 135 | - if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
| 136 | - foreach ($options['registrations'] as $registration) { |
|
| 137 | - if (! $registration instanceof EE_Registration) { |
|
| 138 | - continue; |
|
| 139 | - } |
|
| 140 | - $display_event = $registration->event_ID() === $options['event_id'] |
|
| 141 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 142 | - ? true |
|
| 143 | - : $display_event; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - if (! $display_event) { |
|
| 147 | - return ''; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - $this->_events[$options['event_id']] = 0; |
|
| 151 | - $html .= $this->_event_row($line_item); |
|
| 152 | - $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - $child_line_items = $line_item->children(); |
|
| 156 | - // loop thru children |
|
| 157 | - foreach ($child_line_items as $child_line_item) { |
|
| 158 | - // recursively feed children back into this method |
|
| 159 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 160 | - } |
|
| 161 | - $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
| 162 | - $sub_total += $event_sub_total; |
|
| 163 | - if ( |
|
| 164 | - ( |
|
| 165 | - // event subtotals |
|
| 166 | - $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
| 167 | - ) |
|
| 168 | - || ( |
|
| 169 | - // pre-tax subtotals |
|
| 170 | - $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
| 171 | - ) |
|
| 172 | - ) { |
|
| 173 | - $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
| 174 | - $html .= $this->_sub_total_row($line_item, $text, $options); |
|
| 175 | - } |
|
| 176 | - break; |
|
| 177 | - case EEM_Line_Item::type_tax: |
|
| 178 | - if ($this->_show_taxes) { |
|
| 179 | - $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
| 180 | - } |
|
| 181 | - break; |
|
| 182 | - case EEM_Line_Item::type_tax_sub_total: |
|
| 183 | - if ($this->_show_taxes) { |
|
| 184 | - $child_line_items = $line_item->children(); |
|
| 185 | - // loop thru children |
|
| 186 | - foreach ($child_line_items as $child_line_item) { |
|
| 187 | - // recursively feed children back into this method |
|
| 188 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 189 | - } |
|
| 190 | - if (count($child_line_items) > 1) { |
|
| 191 | - $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - break; |
|
| 195 | - case EEM_Line_Item::type_total: |
|
| 196 | - // get all child line items |
|
| 197 | - $children = $line_item->children(); |
|
| 198 | - // loop thru all non-tax child line items |
|
| 199 | - foreach ($children as $child_line_item) { |
|
| 200 | - if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
| 201 | - // recursively feed children back into this method |
|
| 202 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - // now loop thru tax child line items |
|
| 206 | - foreach ($children as $child_line_item) { |
|
| 207 | - if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
| 208 | - // recursively feed children back into this method |
|
| 209 | - $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - $html .= $this->_taxes_html; |
|
| 213 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
| 214 | - $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
| 215 | - break; |
|
| 216 | - } |
|
| 217 | - return $html; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
| 224 | - * |
|
| 225 | - * @param EE_Line_Item $line_item |
|
| 226 | - * @return mixed |
|
| 227 | - */ |
|
| 228 | - private function _event_row(EE_Line_Item $line_item) |
|
| 229 | - { |
|
| 230 | - // start of row |
|
| 231 | - $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
| 232 | - // event name td |
|
| 233 | - $html .= EEH_HTML::td( |
|
| 234 | - EEH_HTML::strong($line_item->name()), |
|
| 235 | - '', |
|
| 236 | - 'event-header', |
|
| 237 | - '', |
|
| 238 | - ' colspan="4"' |
|
| 239 | - ); |
|
| 240 | - // end of row |
|
| 241 | - $html .= EEH_HTML::trx(); |
|
| 242 | - return $html; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * _ticket_row |
|
| 249 | - * |
|
| 250 | - * @param EE_Line_Item $line_item |
|
| 251 | - * @param array $options |
|
| 252 | - * @return mixed |
|
| 253 | - * @throws EE_Error |
|
| 254 | - */ |
|
| 255 | - private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
| 256 | - { |
|
| 257 | - // start of row |
|
| 258 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 259 | - $html = EEH_HTML::tr('', '', $row_class); |
|
| 260 | - // name && desc |
|
| 261 | - $name_and_desc = apply_filters( |
|
| 262 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 263 | - $line_item->name(), |
|
| 264 | - $line_item |
|
| 265 | - ); |
|
| 266 | - $name_and_desc .= apply_filters( |
|
| 267 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 268 | - ( |
|
| 269 | - $options['show_desc'] |
|
| 270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 271 | - : '' |
|
| 272 | - ), |
|
| 273 | - $line_item, |
|
| 274 | - $options |
|
| 275 | - ); |
|
| 276 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 277 | - // name td |
|
| 278 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 279 | - $name_and_desc, '', 'item_l'); |
|
| 280 | - // price td |
|
| 281 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 282 | - // quantity td |
|
| 283 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 284 | - $this->_total_items += $line_item->quantity(); |
|
| 285 | - // determine total for line item |
|
| 286 | - $total = $line_item->total(); |
|
| 287 | - $this->_events[$options['event_id']] += $total; |
|
| 288 | - // total td |
|
| 289 | - $html .= EEH_HTML::td( |
|
| 290 | - EEH_Template::format_currency($total, false, false), |
|
| 291 | - '', |
|
| 292 | - 'item_r jst-rght' |
|
| 293 | - ); |
|
| 294 | - // end of row |
|
| 295 | - $html .= EEH_HTML::trx(); |
|
| 296 | - return $html; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * _item_row |
|
| 303 | - * |
|
| 304 | - * @param EE_Line_Item $line_item |
|
| 305 | - * @param array $options |
|
| 306 | - * @return mixed |
|
| 307 | - * @throws EE_Error |
|
| 308 | - */ |
|
| 309 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
| 310 | - { |
|
| 311 | - // start of row |
|
| 312 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 313 | - $html = EEH_HTML::tr('', '', $row_class); |
|
| 314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 315 | - // name && desc |
|
| 316 | - $name_and_desc = apply_filters( |
|
| 317 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 318 | - $obj_name . $line_item->name(), |
|
| 319 | - $line_item |
|
| 320 | - ); |
|
| 321 | - $name_and_desc .= apply_filters( |
|
| 322 | - 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 323 | - ( |
|
| 324 | - $options['show_desc'] |
|
| 325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 326 | - : '' |
|
| 327 | - ), |
|
| 328 | - $line_item, |
|
| 329 | - $options |
|
| 330 | - ); |
|
| 331 | - $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 332 | - // name td |
|
| 333 | - $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
| 334 | - // price td |
|
| 335 | - if ($line_item->is_percent()) { |
|
| 336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
| 337 | - } else { |
|
| 338 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 339 | - } |
|
| 340 | - // quantity td |
|
| 341 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 342 | - //$total = $line_item->total() * $line_item->quantity(); |
|
| 343 | - $total = $line_item->total(); |
|
| 344 | - if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
| 345 | - $this->_events[$options['event_id']] += $total; |
|
| 346 | - } |
|
| 347 | - // total td |
|
| 348 | - $html .= EEH_HTML::td( |
|
| 349 | - EEH_Template::format_currency($total, false, false), |
|
| 350 | - '', |
|
| 351 | - 'item_r jst-rght' |
|
| 352 | - ); |
|
| 353 | - // end of row |
|
| 354 | - $html .= EEH_HTML::trx(); |
|
| 355 | - return $html; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * _sub_item_row |
|
| 362 | - * |
|
| 363 | - * @param EE_Line_Item $line_item |
|
| 364 | - * @param array $options |
|
| 365 | - * @param EE_Line_Item $parent_line_item |
|
| 366 | - * @return mixed |
|
| 367 | - * @throws EE_Error |
|
| 368 | - */ |
|
| 369 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
| 370 | - { |
|
| 371 | - if($parent_line_item instanceof EE_Line_Item && $line_item->name() === $parent_line_item->name()) { |
|
| 372 | - return ''; |
|
| 373 | - } |
|
| 374 | - // start of row |
|
| 375 | - $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
| 376 | - // name && desc |
|
| 377 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
| 378 | - . $line_item->name(); |
|
| 379 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
| 380 | - . $line_item->desc() |
|
| 381 | - . '</span>' : ''; |
|
| 382 | - // name td |
|
| 383 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
| 384 | - $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
| 385 | - // discount/surcharge td |
|
| 386 | - if ($line_item->is_percent()) { |
|
| 387 | - $html .= EEH_HTML::td( |
|
| 388 | - EEH_Template::format_currency( |
|
| 389 | - $line_item->total() / $qty, |
|
| 390 | - false, false |
|
| 391 | - ), |
|
| 392 | - '', 'item_c jst-rght' |
|
| 393 | - ); |
|
| 394 | - } else { |
|
| 395 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 396 | - } |
|
| 397 | - // no quantity td |
|
| 398 | - $html .= EEH_HTML::td(); |
|
| 399 | - // no total td |
|
| 400 | - $html .= EEH_HTML::td(); |
|
| 401 | - // end of row |
|
| 402 | - $html .= EEH_HTML::trx(); |
|
| 403 | - return $html; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * _tax_row |
|
| 410 | - * |
|
| 411 | - * @param EE_Line_Item $line_item |
|
| 412 | - * @param array $options |
|
| 413 | - * @return mixed |
|
| 414 | - * @throws EE_Error |
|
| 415 | - */ |
|
| 416 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
| 417 | - { |
|
| 418 | - // start of row |
|
| 419 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
| 420 | - // name && desc |
|
| 421 | - $name_and_desc = $line_item->name(); |
|
| 422 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
| 423 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
| 424 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
| 425 | - // name td |
|
| 426 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 427 | - $name_and_desc, '', 'item_l sub-item'); |
|
| 428 | - // percent td |
|
| 429 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
| 430 | - // empty td (price) |
|
| 431 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 432 | - // total td |
|
| 433 | - $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
| 434 | - $line_item->total(), false, false), |
|
| 435 | - '', |
|
| 436 | - 'item_r jst-rght' |
|
| 437 | - ); |
|
| 438 | - // end of row |
|
| 439 | - $html .= EEH_HTML::trx(); |
|
| 440 | - return $html; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * _total_row |
|
| 447 | - * |
|
| 448 | - * @param EE_Line_Item $line_item |
|
| 449 | - * @param string $text |
|
| 450 | - * @return mixed |
|
| 451 | - * @throws EE_Error |
|
| 452 | - */ |
|
| 453 | - private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
| 454 | - { |
|
| 455 | - $html = ''; |
|
| 456 | - if ($line_item->total()) { |
|
| 457 | - // start of row |
|
| 458 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 459 | - // total td |
|
| 460 | - $html .= EEH_HTML::td( |
|
| 461 | - $text, |
|
| 462 | - '', |
|
| 463 | - 'total_currency total jst-rght', |
|
| 464 | - '', |
|
| 465 | - ' colspan="2"' |
|
| 466 | - ); |
|
| 467 | - // empty td (price) |
|
| 468 | - $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 469 | - // total td |
|
| 470 | - $html .= EEH_HTML::td( |
|
| 471 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
| 472 | - '', |
|
| 473 | - 'total jst-rght' |
|
| 474 | - ); |
|
| 475 | - // end of row |
|
| 476 | - $html .= EEH_HTML::trx(); |
|
| 477 | - } |
|
| 478 | - return $html; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * _total_row |
|
| 485 | - * |
|
| 486 | - * @param EE_Line_Item $line_item |
|
| 487 | - * @param string $text |
|
| 488 | - * @param array $options |
|
| 489 | - * @return mixed |
|
| 490 | - * @throws EE_Error |
|
| 491 | - */ |
|
| 492 | - private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
| 493 | - { |
|
| 494 | - $html = ''; |
|
| 495 | - if ($line_item->total()) { |
|
| 496 | - // start of row |
|
| 497 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 498 | - // total td |
|
| 499 | - $html .= EEH_HTML::td( |
|
| 500 | - $text, |
|
| 501 | - '', |
|
| 502 | - 'total_currency total jst-rght', |
|
| 503 | - '', |
|
| 504 | - ' colspan="3"' |
|
| 505 | - ); |
|
| 506 | - // total td |
|
| 507 | - $html .= EEH_HTML::td( |
|
| 508 | - EEH_Template::format_currency($options['sub_total'], false, false), |
|
| 509 | - '', |
|
| 510 | - 'total jst-rght' |
|
| 511 | - ); |
|
| 512 | - // end of row |
|
| 513 | - $html .= EEH_HTML::trx(); |
|
| 514 | - } |
|
| 515 | - return $html; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * _total_row |
|
| 522 | - * |
|
| 523 | - * @param EE_Line_Item $line_item |
|
| 524 | - * @param string $text |
|
| 525 | - * @return mixed |
|
| 526 | - * @throws EE_Error |
|
| 527 | - */ |
|
| 528 | - private function _total_row(EE_Line_Item $line_item, $text = '') |
|
| 529 | - { |
|
| 530 | - // start of row |
|
| 531 | - $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
| 532 | - // total td |
|
| 533 | - $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 534 | - // total td |
|
| 535 | - $html .= EEH_HTML::td( |
|
| 536 | - EEH_Template::format_currency($line_item->total(), false, false), |
|
| 537 | - '', |
|
| 538 | - 'total jst-rght' |
|
| 539 | - ); |
|
| 540 | - // end of row |
|
| 541 | - $html .= EEH_HTML::trx(); |
|
| 542 | - return $html; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - |
|
| 547 | - /** |
|
| 548 | - * _payments_and_amount_owing_rows |
|
| 549 | - * |
|
| 550 | - * @param EE_Line_Item $line_item |
|
| 551 | - * @param array $options |
|
| 552 | - * @return mixed |
|
| 553 | - * @throws EE_Error |
|
| 554 | - */ |
|
| 555 | - private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
| 556 | - { |
|
| 557 | - $html = ''; |
|
| 558 | - $owing = $line_item->total(); |
|
| 559 | - $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
| 560 | - if ($transaction instanceof EE_Transaction) { |
|
| 561 | - $registration_payments = array(); |
|
| 562 | - $registrations = ! empty($options['registrations']) |
|
| 563 | - ? $options['registrations'] |
|
| 564 | - : $transaction->registrations(); |
|
| 565 | - foreach ($registrations as $registration) { |
|
| 566 | - if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 567 | - $registration_payments += $registration->registration_payments(); |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - if (! empty($registration_payments)) { |
|
| 571 | - foreach ($registration_payments as $registration_payment) { |
|
| 572 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
| 573 | - $owing -= $registration_payment->amount(); |
|
| 574 | - $payment = $registration_payment->payment(); |
|
| 575 | - $payment_desc = ''; |
|
| 576 | - if ($payment instanceof EE_Payment) { |
|
| 577 | - $payment_desc = sprintf( |
|
| 578 | - esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
| 579 | - $payment->txn_id_chq_nmbr() !== '' |
|
| 580 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 581 | - : '', |
|
| 582 | - $payment->timestamp() |
|
| 583 | - ); |
|
| 584 | - } |
|
| 585 | - // start of row |
|
| 586 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 587 | - // payment desc |
|
| 588 | - $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
| 589 | - // total td |
|
| 590 | - $html .= EEH_HTML::td( |
|
| 591 | - EEH_Template::format_currency( |
|
| 592 | - $registration_payment->amount(), |
|
| 593 | - false, |
|
| 594 | - false |
|
| 595 | - ), |
|
| 596 | - '', |
|
| 597 | - 'total jst-rght' |
|
| 598 | - ); |
|
| 599 | - // end of row |
|
| 600 | - $html .= EEH_HTML::trx(); |
|
| 601 | - } |
|
| 602 | - } |
|
| 603 | - if ($line_item->total()) { |
|
| 604 | - // start of row |
|
| 605 | - $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 606 | - // total td |
|
| 607 | - $html .= EEH_HTML::td( |
|
| 608 | - esc_html__('Amount Owing', 'event_espresso'), |
|
| 609 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
| 610 | - ); |
|
| 611 | - // total td |
|
| 612 | - $html .= EEH_HTML::td( |
|
| 613 | - EEH_Template::format_currency($owing, false, false), |
|
| 614 | - '', |
|
| 615 | - 'total jst-rght' |
|
| 616 | - ); |
|
| 617 | - // end of row |
|
| 618 | - $html .= EEH_HTML::trx(); |
|
| 619 | - } |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - $this->_grand_total = $owing; |
|
| 623 | - return $html; |
|
| 624 | - } |
|
| 19 | + /** |
|
| 20 | + * array of events |
|
| 21 | + * |
|
| 22 | + * @type EE_Line_Item[] $_events |
|
| 23 | + */ |
|
| 24 | + private $_events = array(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * whether to display the taxes row or not |
|
| 28 | + * |
|
| 29 | + * @type bool $_show_taxes |
|
| 30 | + */ |
|
| 31 | + private $_show_taxes = false; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * html for any tax rows |
|
| 35 | + * |
|
| 36 | + * @type string $_show_taxes |
|
| 37 | + */ |
|
| 38 | + private $_taxes_html = ''; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * total amount including tax we can bill for at this time |
|
| 42 | + * |
|
| 43 | + * @type float $_grand_total |
|
| 44 | + */ |
|
| 45 | + private $_grand_total = 0.00; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * total number of items being billed for |
|
| 49 | + * |
|
| 50 | + * @type int $_total_items |
|
| 51 | + */ |
|
| 52 | + private $_total_items = 0; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @return float |
|
| 58 | + */ |
|
| 59 | + public function grand_total() |
|
| 60 | + { |
|
| 61 | + return $this->_grand_total; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * @return int |
|
| 68 | + */ |
|
| 69 | + public function total_items() |
|
| 70 | + { |
|
| 71 | + return $this->_total_items; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param EE_Line_Item $line_item |
|
| 78 | + * @param array $options |
|
| 79 | + * @param EE_Line_Item $parent_line_item |
|
| 80 | + * @return mixed |
|
| 81 | + * @throws EE_Error |
|
| 82 | + */ |
|
| 83 | + public function display_line_item( |
|
| 84 | + EE_Line_Item $line_item, |
|
| 85 | + $options = array(), |
|
| 86 | + EE_Line_Item $parent_line_item = null |
|
| 87 | + ) { |
|
| 88 | + $html = ''; |
|
| 89 | + // set some default options and merge with incoming |
|
| 90 | + $default_options = array( |
|
| 91 | + 'show_desc' => true, // true false |
|
| 92 | + 'odd' => false, |
|
| 93 | + ); |
|
| 94 | + $options = array_merge($default_options, (array)$options); |
|
| 95 | + switch ($line_item->type()) { |
|
| 96 | + case EEM_Line_Item::type_line_item: |
|
| 97 | + $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
|
| 98 | + if ($line_item->OBJ_type() === 'Ticket') { |
|
| 99 | + // item row |
|
| 100 | + $html .= $this->_ticket_row($line_item, $options); |
|
| 101 | + } else { |
|
| 102 | + // item row |
|
| 103 | + $html .= $this->_item_row($line_item, $options); |
|
| 104 | + } |
|
| 105 | + if ( |
|
| 106 | + apply_filters( |
|
| 107 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__display_line_item__display_sub_line_items', |
|
| 108 | + true |
|
| 109 | + ) |
|
| 110 | + ) { |
|
| 111 | + // got any kids? |
|
| 112 | + foreach ($line_item->children() as $child_line_item) { |
|
| 113 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + break; |
|
| 117 | + case EEM_Line_Item::type_sub_line_item: |
|
| 118 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
| 119 | + break; |
|
| 120 | + case EEM_Line_Item::type_sub_total: |
|
| 121 | + static $sub_total = 0; |
|
| 122 | + $event_sub_total = 0; |
|
| 123 | + $text = esc_html__('Sub-Total', 'event_espresso'); |
|
| 124 | + if ($line_item->OBJ_type() === 'Event') { |
|
| 125 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
| 126 | + if (! isset($this->_events[$options['event_id']])) { |
|
| 127 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
| 128 | + // if event has default reg status of Not Approved, then don't display info on it |
|
| 129 | + if ( |
|
| 130 | + $event instanceof EE_Event |
|
| 131 | + && $event->default_registration_status() === EEM_Registration::status_id_not_approved |
|
| 132 | + ) { |
|
| 133 | + $display_event = false; |
|
| 134 | + // unless there are registrations for it that are returning to pay |
|
| 135 | + if (isset($options['registrations']) && is_array($options['registrations'])) { |
|
| 136 | + foreach ($options['registrations'] as $registration) { |
|
| 137 | + if (! $registration instanceof EE_Registration) { |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 140 | + $display_event = $registration->event_ID() === $options['event_id'] |
|
| 141 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
| 142 | + ? true |
|
| 143 | + : $display_event; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + if (! $display_event) { |
|
| 147 | + return ''; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + $this->_events[$options['event_id']] = 0; |
|
| 151 | + $html .= $this->_event_row($line_item); |
|
| 152 | + $text = esc_html__('Event Sub-Total', 'event_espresso'); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + $child_line_items = $line_item->children(); |
|
| 156 | + // loop thru children |
|
| 157 | + foreach ($child_line_items as $child_line_item) { |
|
| 158 | + // recursively feed children back into this method |
|
| 159 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 160 | + } |
|
| 161 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
| 162 | + $sub_total += $event_sub_total; |
|
| 163 | + if ( |
|
| 164 | + ( |
|
| 165 | + // event subtotals |
|
| 166 | + $line_item->code() !== 'pre-tax-subtotal' && count($child_line_items) > 1 |
|
| 167 | + ) |
|
| 168 | + || ( |
|
| 169 | + // pre-tax subtotals |
|
| 170 | + $line_item->code() === 'pre-tax-subtotal' && count($this->_events) > 1 |
|
| 171 | + ) |
|
| 172 | + ) { |
|
| 173 | + $options['sub_total'] = $line_item->OBJ_type() === 'Event' ? $event_sub_total : $sub_total; |
|
| 174 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
| 175 | + } |
|
| 176 | + break; |
|
| 177 | + case EEM_Line_Item::type_tax: |
|
| 178 | + if ($this->_show_taxes) { |
|
| 179 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
| 180 | + } |
|
| 181 | + break; |
|
| 182 | + case EEM_Line_Item::type_tax_sub_total: |
|
| 183 | + if ($this->_show_taxes) { |
|
| 184 | + $child_line_items = $line_item->children(); |
|
| 185 | + // loop thru children |
|
| 186 | + foreach ($child_line_items as $child_line_item) { |
|
| 187 | + // recursively feed children back into this method |
|
| 188 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 189 | + } |
|
| 190 | + if (count($child_line_items) > 1) { |
|
| 191 | + $this->_taxes_html .= $this->_total_tax_row($line_item, esc_html__('Tax Total', 'event_espresso')); |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + break; |
|
| 195 | + case EEM_Line_Item::type_total: |
|
| 196 | + // get all child line items |
|
| 197 | + $children = $line_item->children(); |
|
| 198 | + // loop thru all non-tax child line items |
|
| 199 | + foreach ($children as $child_line_item) { |
|
| 200 | + if ($child_line_item->type() !== EEM_Line_Item::type_tax_sub_total) { |
|
| 201 | + // recursively feed children back into this method |
|
| 202 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + // now loop thru tax child line items |
|
| 206 | + foreach ($children as $child_line_item) { |
|
| 207 | + if ($child_line_item->type() === EEM_Line_Item::type_tax_sub_total) { |
|
| 208 | + // recursively feed children back into this method |
|
| 209 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + $html .= $this->_taxes_html; |
|
| 213 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso')); |
|
| 214 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
| 215 | + break; |
|
| 216 | + } |
|
| 217 | + return $html; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * _event_row - basically a Heading row displayed once above each event's ticket rows |
|
| 224 | + * |
|
| 225 | + * @param EE_Line_Item $line_item |
|
| 226 | + * @return mixed |
|
| 227 | + */ |
|
| 228 | + private function _event_row(EE_Line_Item $line_item) |
|
| 229 | + { |
|
| 230 | + // start of row |
|
| 231 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
| 232 | + // event name td |
|
| 233 | + $html .= EEH_HTML::td( |
|
| 234 | + EEH_HTML::strong($line_item->name()), |
|
| 235 | + '', |
|
| 236 | + 'event-header', |
|
| 237 | + '', |
|
| 238 | + ' colspan="4"' |
|
| 239 | + ); |
|
| 240 | + // end of row |
|
| 241 | + $html .= EEH_HTML::trx(); |
|
| 242 | + return $html; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * _ticket_row |
|
| 249 | + * |
|
| 250 | + * @param EE_Line_Item $line_item |
|
| 251 | + * @param array $options |
|
| 252 | + * @return mixed |
|
| 253 | + * @throws EE_Error |
|
| 254 | + */ |
|
| 255 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) |
|
| 256 | + { |
|
| 257 | + // start of row |
|
| 258 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 259 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 260 | + // name && desc |
|
| 261 | + $name_and_desc = apply_filters( |
|
| 262 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 263 | + $line_item->name(), |
|
| 264 | + $line_item |
|
| 265 | + ); |
|
| 266 | + $name_and_desc .= apply_filters( |
|
| 267 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 268 | + ( |
|
| 269 | + $options['show_desc'] |
|
| 270 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 271 | + : '' |
|
| 272 | + ), |
|
| 273 | + $line_item, |
|
| 274 | + $options |
|
| 275 | + ); |
|
| 276 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 277 | + // name td |
|
| 278 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 279 | + $name_and_desc, '', 'item_l'); |
|
| 280 | + // price td |
|
| 281 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 282 | + // quantity td |
|
| 283 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 284 | + $this->_total_items += $line_item->quantity(); |
|
| 285 | + // determine total for line item |
|
| 286 | + $total = $line_item->total(); |
|
| 287 | + $this->_events[$options['event_id']] += $total; |
|
| 288 | + // total td |
|
| 289 | + $html .= EEH_HTML::td( |
|
| 290 | + EEH_Template::format_currency($total, false, false), |
|
| 291 | + '', |
|
| 292 | + 'item_r jst-rght' |
|
| 293 | + ); |
|
| 294 | + // end of row |
|
| 295 | + $html .= EEH_HTML::trx(); |
|
| 296 | + return $html; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * _item_row |
|
| 303 | + * |
|
| 304 | + * @param EE_Line_Item $line_item |
|
| 305 | + * @param array $options |
|
| 306 | + * @return mixed |
|
| 307 | + * @throws EE_Error |
|
| 308 | + */ |
|
| 309 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
| 310 | + { |
|
| 311 | + // start of row |
|
| 312 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
| 313 | + $html = EEH_HTML::tr('', '', $row_class); |
|
| 314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 315 | + // name && desc |
|
| 316 | + $name_and_desc = apply_filters( |
|
| 317 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
|
| 318 | + $obj_name . $line_item->name(), |
|
| 319 | + $line_item |
|
| 320 | + ); |
|
| 321 | + $name_and_desc .= apply_filters( |
|
| 322 | + 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
|
| 323 | + ( |
|
| 324 | + $options['show_desc'] |
|
| 325 | + ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 326 | + : '' |
|
| 327 | + ), |
|
| 328 | + $line_item, |
|
| 329 | + $options |
|
| 330 | + ); |
|
| 331 | + $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
|
| 332 | + // name td |
|
| 333 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
| 334 | + // price td |
|
| 335 | + if ($line_item->is_percent()) { |
|
| 336 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
| 337 | + } else { |
|
| 338 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 339 | + } |
|
| 340 | + // quantity td |
|
| 341 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
| 342 | + //$total = $line_item->total() * $line_item->quantity(); |
|
| 343 | + $total = $line_item->total(); |
|
| 344 | + if (isset($options['event_id'], $this->_events[$options['event_id']])) { |
|
| 345 | + $this->_events[$options['event_id']] += $total; |
|
| 346 | + } |
|
| 347 | + // total td |
|
| 348 | + $html .= EEH_HTML::td( |
|
| 349 | + EEH_Template::format_currency($total, false, false), |
|
| 350 | + '', |
|
| 351 | + 'item_r jst-rght' |
|
| 352 | + ); |
|
| 353 | + // end of row |
|
| 354 | + $html .= EEH_HTML::trx(); |
|
| 355 | + return $html; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * _sub_item_row |
|
| 362 | + * |
|
| 363 | + * @param EE_Line_Item $line_item |
|
| 364 | + * @param array $options |
|
| 365 | + * @param EE_Line_Item $parent_line_item |
|
| 366 | + * @return mixed |
|
| 367 | + * @throws EE_Error |
|
| 368 | + */ |
|
| 369 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
|
| 370 | + { |
|
| 371 | + if($parent_line_item instanceof EE_Line_Item && $line_item->name() === $parent_line_item->name()) { |
|
| 372 | + return ''; |
|
| 373 | + } |
|
| 374 | + // start of row |
|
| 375 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
| 376 | + // name && desc |
|
| 377 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right') |
|
| 378 | + . $line_item->name(); |
|
| 379 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' |
|
| 380 | + . $line_item->desc() |
|
| 381 | + . '</span>' : ''; |
|
| 382 | + // name td |
|
| 383 | + $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
| 384 | + $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
|
| 385 | + // discount/surcharge td |
|
| 386 | + if ($line_item->is_percent()) { |
|
| 387 | + $html .= EEH_HTML::td( |
|
| 388 | + EEH_Template::format_currency( |
|
| 389 | + $line_item->total() / $qty, |
|
| 390 | + false, false |
|
| 391 | + ), |
|
| 392 | + '', 'item_c jst-rght' |
|
| 393 | + ); |
|
| 394 | + } else { |
|
| 395 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
| 396 | + } |
|
| 397 | + // no quantity td |
|
| 398 | + $html .= EEH_HTML::td(); |
|
| 399 | + // no total td |
|
| 400 | + $html .= EEH_HTML::td(); |
|
| 401 | + // end of row |
|
| 402 | + $html .= EEH_HTML::trx(); |
|
| 403 | + return $html; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * _tax_row |
|
| 410 | + * |
|
| 411 | + * @param EE_Line_Item $line_item |
|
| 412 | + * @param array $options |
|
| 413 | + * @return mixed |
|
| 414 | + * @throws EE_Error |
|
| 415 | + */ |
|
| 416 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
| 417 | + { |
|
| 418 | + // start of row |
|
| 419 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
| 420 | + // name && desc |
|
| 421 | + $name_and_desc = $line_item->name(); |
|
| 422 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
|
| 423 | + . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
| 424 | + $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
| 425 | + // name td |
|
| 426 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
|
| 427 | + $name_and_desc, '', 'item_l sub-item'); |
|
| 428 | + // percent td |
|
| 429 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
| 430 | + // empty td (price) |
|
| 431 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 432 | + // total td |
|
| 433 | + $html .= EEH_HTML::td(EEH_Template::format_currency( |
|
| 434 | + $line_item->total(), false, false), |
|
| 435 | + '', |
|
| 436 | + 'item_r jst-rght' |
|
| 437 | + ); |
|
| 438 | + // end of row |
|
| 439 | + $html .= EEH_HTML::trx(); |
|
| 440 | + return $html; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * _total_row |
|
| 447 | + * |
|
| 448 | + * @param EE_Line_Item $line_item |
|
| 449 | + * @param string $text |
|
| 450 | + * @return mixed |
|
| 451 | + * @throws EE_Error |
|
| 452 | + */ |
|
| 453 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') |
|
| 454 | + { |
|
| 455 | + $html = ''; |
|
| 456 | + if ($line_item->total()) { |
|
| 457 | + // start of row |
|
| 458 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 459 | + // total td |
|
| 460 | + $html .= EEH_HTML::td( |
|
| 461 | + $text, |
|
| 462 | + '', |
|
| 463 | + 'total_currency total jst-rght', |
|
| 464 | + '', |
|
| 465 | + ' colspan="2"' |
|
| 466 | + ); |
|
| 467 | + // empty td (price) |
|
| 468 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
| 469 | + // total td |
|
| 470 | + $html .= EEH_HTML::td( |
|
| 471 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
| 472 | + '', |
|
| 473 | + 'total jst-rght' |
|
| 474 | + ); |
|
| 475 | + // end of row |
|
| 476 | + $html .= EEH_HTML::trx(); |
|
| 477 | + } |
|
| 478 | + return $html; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * _total_row |
|
| 485 | + * |
|
| 486 | + * @param EE_Line_Item $line_item |
|
| 487 | + * @param string $text |
|
| 488 | + * @param array $options |
|
| 489 | + * @return mixed |
|
| 490 | + * @throws EE_Error |
|
| 491 | + */ |
|
| 492 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
| 493 | + { |
|
| 494 | + $html = ''; |
|
| 495 | + if ($line_item->total()) { |
|
| 496 | + // start of row |
|
| 497 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 498 | + // total td |
|
| 499 | + $html .= EEH_HTML::td( |
|
| 500 | + $text, |
|
| 501 | + '', |
|
| 502 | + 'total_currency total jst-rght', |
|
| 503 | + '', |
|
| 504 | + ' colspan="3"' |
|
| 505 | + ); |
|
| 506 | + // total td |
|
| 507 | + $html .= EEH_HTML::td( |
|
| 508 | + EEH_Template::format_currency($options['sub_total'], false, false), |
|
| 509 | + '', |
|
| 510 | + 'total jst-rght' |
|
| 511 | + ); |
|
| 512 | + // end of row |
|
| 513 | + $html .= EEH_HTML::trx(); |
|
| 514 | + } |
|
| 515 | + return $html; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * _total_row |
|
| 522 | + * |
|
| 523 | + * @param EE_Line_Item $line_item |
|
| 524 | + * @param string $text |
|
| 525 | + * @return mixed |
|
| 526 | + * @throws EE_Error |
|
| 527 | + */ |
|
| 528 | + private function _total_row(EE_Line_Item $line_item, $text = '') |
|
| 529 | + { |
|
| 530 | + // start of row |
|
| 531 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
| 532 | + // total td |
|
| 533 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
| 534 | + // total td |
|
| 535 | + $html .= EEH_HTML::td( |
|
| 536 | + EEH_Template::format_currency($line_item->total(), false, false), |
|
| 537 | + '', |
|
| 538 | + 'total jst-rght' |
|
| 539 | + ); |
|
| 540 | + // end of row |
|
| 541 | + $html .= EEH_HTML::trx(); |
|
| 542 | + return $html; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + |
|
| 547 | + /** |
|
| 548 | + * _payments_and_amount_owing_rows |
|
| 549 | + * |
|
| 550 | + * @param EE_Line_Item $line_item |
|
| 551 | + * @param array $options |
|
| 552 | + * @return mixed |
|
| 553 | + * @throws EE_Error |
|
| 554 | + */ |
|
| 555 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) |
|
| 556 | + { |
|
| 557 | + $html = ''; |
|
| 558 | + $owing = $line_item->total(); |
|
| 559 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
| 560 | + if ($transaction instanceof EE_Transaction) { |
|
| 561 | + $registration_payments = array(); |
|
| 562 | + $registrations = ! empty($options['registrations']) |
|
| 563 | + ? $options['registrations'] |
|
| 564 | + : $transaction->registrations(); |
|
| 565 | + foreach ($registrations as $registration) { |
|
| 566 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
| 567 | + $registration_payments += $registration->registration_payments(); |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + if (! empty($registration_payments)) { |
|
| 571 | + foreach ($registration_payments as $registration_payment) { |
|
| 572 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
| 573 | + $owing -= $registration_payment->amount(); |
|
| 574 | + $payment = $registration_payment->payment(); |
|
| 575 | + $payment_desc = ''; |
|
| 576 | + if ($payment instanceof EE_Payment) { |
|
| 577 | + $payment_desc = sprintf( |
|
| 578 | + esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
|
| 579 | + $payment->txn_id_chq_nmbr() !== '' |
|
| 580 | + ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 581 | + : '', |
|
| 582 | + $payment->timestamp() |
|
| 583 | + ); |
|
| 584 | + } |
|
| 585 | + // start of row |
|
| 586 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 587 | + // payment desc |
|
| 588 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
| 589 | + // total td |
|
| 590 | + $html .= EEH_HTML::td( |
|
| 591 | + EEH_Template::format_currency( |
|
| 592 | + $registration_payment->amount(), |
|
| 593 | + false, |
|
| 594 | + false |
|
| 595 | + ), |
|
| 596 | + '', |
|
| 597 | + 'total jst-rght' |
|
| 598 | + ); |
|
| 599 | + // end of row |
|
| 600 | + $html .= EEH_HTML::trx(); |
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | + if ($line_item->total()) { |
|
| 604 | + // start of row |
|
| 605 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
| 606 | + // total td |
|
| 607 | + $html .= EEH_HTML::td( |
|
| 608 | + esc_html__('Amount Owing', 'event_espresso'), |
|
| 609 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
| 610 | + ); |
|
| 611 | + // total td |
|
| 612 | + $html .= EEH_HTML::td( |
|
| 613 | + EEH_Template::format_currency($owing, false, false), |
|
| 614 | + '', |
|
| 615 | + 'total jst-rght' |
|
| 616 | + ); |
|
| 617 | + // end of row |
|
| 618 | + $html .= EEH_HTML::trx(); |
|
| 619 | + } |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + $this->_grand_total = $owing; |
|
| 623 | + return $html; |
|
| 624 | + } |
|
| 625 | 625 | |
| 626 | 626 | |
| 627 | 627 | } |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | $html = ''; |
| 89 | 89 | // set some default options and merge with incoming |
| 90 | 90 | $default_options = array( |
| 91 | - 'show_desc' => true, // true false |
|
| 91 | + 'show_desc' => true, // true false |
|
| 92 | 92 | 'odd' => false, |
| 93 | 93 | ); |
| 94 | - $options = array_merge($default_options, (array)$options); |
|
| 94 | + $options = array_merge($default_options, (array) $options); |
|
| 95 | 95 | switch ($line_item->type()) { |
| 96 | 96 | case EEM_Line_Item::type_line_item: |
| 97 | 97 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $text = esc_html__('Sub-Total', 'event_espresso'); |
| 124 | 124 | if ($line_item->OBJ_type() === 'Event') { |
| 125 | 125 | $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
| 126 | - if (! isset($this->_events[$options['event_id']])) { |
|
| 126 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
| 127 | 127 | $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
| 128 | 128 | // if event has default reg status of Not Approved, then don't display info on it |
| 129 | 129 | if ( |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | // unless there are registrations for it that are returning to pay |
| 135 | 135 | if (isset($options['registrations']) && is_array($options['registrations'])) { |
| 136 | 136 | foreach ($options['registrations'] as $registration) { |
| 137 | - if (! $registration instanceof EE_Registration) { |
|
| 137 | + if ( ! $registration instanceof EE_Registration) { |
|
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | $display_event = $registration->event_ID() === $options['event_id'] |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | : $display_event; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | - if (! $display_event) { |
|
| 146 | + if ( ! $display_event) { |
|
| 147 | 147 | return ''; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
| 268 | 268 | ( |
| 269 | 269 | $options['show_desc'] |
| 270 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 270 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
| 271 | 271 | : '' |
| 272 | 272 | ), |
| 273 | 273 | $line_item, |
@@ -311,18 +311,18 @@ discard block |
||
| 311 | 311 | // start of row |
| 312 | 312 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
| 313 | 313 | $html = EEH_HTML::tr('', '', $row_class); |
| 314 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
| 314 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
| 315 | 315 | // name && desc |
| 316 | 316 | $name_and_desc = apply_filters( |
| 317 | 317 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
| 318 | - $obj_name . $line_item->name(), |
|
| 318 | + $obj_name.$line_item->name(), |
|
| 319 | 319 | $line_item |
| 320 | 320 | ); |
| 321 | 321 | $name_and_desc .= apply_filters( |
| 322 | 322 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
| 323 | 323 | ( |
| 324 | 324 | $options['show_desc'] |
| 325 | - ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' |
|
| 325 | + ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' |
|
| 326 | 326 | : '' |
| 327 | 327 | ), |
| 328 | 328 | $line_item, |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
| 334 | 334 | // price td |
| 335 | 335 | if ($line_item->is_percent()) { |
| 336 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c jst-rght'); |
|
| 336 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
| 337 | 337 | } else { |
| 338 | 338 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
| 339 | 339 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | */ |
| 369 | 369 | private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) |
| 370 | 370 | { |
| 371 | - if($parent_line_item instanceof EE_Line_Item && $line_item->name() === $parent_line_item->name()) { |
|
| 371 | + if ($parent_line_item instanceof EE_Line_Item && $line_item->name() === $parent_line_item->name()) { |
|
| 372 | 372 | return ''; |
| 373 | 373 | } |
| 374 | 374 | // start of row |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | . $line_item->desc() |
| 381 | 381 | . '</span>' : ''; |
| 382 | 382 | // name td |
| 383 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l sub-item'); |
|
| 383 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item'); |
|
| 384 | 384 | $qty = $parent_line_item instanceof EE_Line_Item ? $parent_line_item->quantity() : 1; |
| 385 | 385 | // discount/surcharge td |
| 386 | 386 | if ($line_item->is_percent()) { |
@@ -420,13 +420,13 @@ discard block |
||
| 420 | 420 | // name && desc |
| 421 | 421 | $name_and_desc = $line_item->name(); |
| 422 | 422 | $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' |
| 423 | - . esc_html__(' * taxable items', 'event_espresso') . '</span>'; |
|
| 424 | - $name_and_desc .= $options['show_desc'] ? '<br/>' . $line_item->desc() : ''; |
|
| 423 | + . esc_html__(' * taxable items', 'event_espresso').'</span>'; |
|
| 424 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
| 425 | 425 | // name td |
| 426 | 426 | $html .= EEH_HTML::td( /*__FUNCTION__ .*/ |
| 427 | 427 | $name_and_desc, '', 'item_l sub-item'); |
| 428 | 428 | // percent td |
| 429 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', ' jst-rght', ''); |
|
| 429 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
| 430 | 430 | // empty td (price) |
| 431 | 431 | $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
| 432 | 432 | // total td |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | $registration_payments += $registration->registration_payments(); |
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | - if (! empty($registration_payments)) { |
|
| 570 | + if ( ! empty($registration_payments)) { |
|
| 571 | 571 | foreach ($registration_payments as $registration_payment) { |
| 572 | 572 | if ($registration_payment instanceof EE_Registration_Payment) { |
| 573 | 573 | $owing -= $registration_payment->amount(); |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | $payment_desc = sprintf( |
| 578 | 578 | esc_html__('Payment%1$s Received: %2$s', 'event_espresso'), |
| 579 | 579 | $payment->txn_id_chq_nmbr() !== '' |
| 580 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
| 580 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
| 581 | 581 | : '', |
| 582 | 582 | $payment->timestamp() |
| 583 | 583 | ); |
@@ -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 | /** |
@@ -24,445 +24,445 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * This gets set in _setup_cpt |
|
| 29 | - * It will contain the object for the custom post type. |
|
| 30 | - * |
|
| 31 | - * @var object |
|
| 32 | - */ |
|
| 33 | - protected $_cpt_object; |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * a boolean flag to set whether the current route is a cpt route or not. |
|
| 39 | - * |
|
| 40 | - * @var bool |
|
| 41 | - */ |
|
| 42 | - protected $_cpt_route = false; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * This property allows cpt classes to define multiple routes as cpt routes. |
|
| 48 | - * //in this array we define what the custom post type for this route is. |
|
| 49 | - * array( |
|
| 50 | - * 'route_name' => 'custom_post_type_slug' |
|
| 51 | - * ) |
|
| 52 | - * |
|
| 53 | - * @var array |
|
| 54 | - */ |
|
| 55 | - protected $_cpt_routes = array(); |
|
| 56 | - |
|
| 27 | + /** |
|
| 28 | + * This gets set in _setup_cpt |
|
| 29 | + * It will contain the object for the custom post type. |
|
| 30 | + * |
|
| 31 | + * @var object |
|
| 32 | + */ |
|
| 33 | + protected $_cpt_object; |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * a boolean flag to set whether the current route is a cpt route or not. |
|
| 39 | + * |
|
| 40 | + * @var bool |
|
| 41 | + */ |
|
| 42 | + protected $_cpt_route = false; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * This property allows cpt classes to define multiple routes as cpt routes. |
|
| 48 | + * //in this array we define what the custom post type for this route is. |
|
| 49 | + * array( |
|
| 50 | + * 'route_name' => 'custom_post_type_slug' |
|
| 51 | + * ) |
|
| 52 | + * |
|
| 53 | + * @var array |
|
| 54 | + */ |
|
| 55 | + protected $_cpt_routes = array(); |
|
| 56 | + |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update. |
|
| 61 | - * in this format: |
|
| 62 | - * array( |
|
| 63 | - * 'post_type_slug' => 'edit_route' |
|
| 64 | - * ) |
|
| 65 | - * |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 68 | - protected $_cpt_edit_routes = array(); |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will |
|
| 74 | - * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the |
|
| 75 | - * _cpt_model_names property should be in the following format: array( |
|
| 76 | - * 'route_defined_by_action_param' => 'Model_Name') |
|
| 77 | - * |
|
| 78 | - * @var array $_cpt_model_names |
|
| 79 | - */ |
|
| 80 | - protected $_cpt_model_names = array(); |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @var EE_CPT_Base |
|
| 85 | - */ |
|
| 86 | - protected $_cpt_model_obj = false; |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP |
|
| 92 | - * autosave so we can save our inputs on the save_post hook! Children classes should add to this array by using |
|
| 93 | - * the _register_autosave_containers() method so that we don't override any other containers already registered. |
|
| 94 | - * Registration of containers should be done before load_page_dependencies() is run. |
|
| 95 | - * |
|
| 96 | - * @var array() |
|
| 97 | - */ |
|
| 98 | - protected $_autosave_containers = array(); |
|
| 99 | - protected $_autosave_fields = array(); |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits |
|
| 103 | - * a page for an action, it will appear as if they were visiting the wp core page for that custom post type |
|
| 104 | - * |
|
| 105 | - * @var array |
|
| 106 | - */ |
|
| 107 | - protected $_pagenow_map = null; |
|
| 108 | - |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 113 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
| 114 | - * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important. When a |
|
| 115 | - * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data |
|
| 116 | - * containing any extra info you may have from other meta saves. So MAKE sure that you handle this accordingly. |
|
| 117 | - * |
|
| 118 | - * @access protected |
|
| 119 | - * @abstract |
|
| 120 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 121 | - * @param object $post The post object of the cpt that was saved. |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - abstract protected function _insert_update_cpt_item($post_id, $post); |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed. |
|
| 130 | - * |
|
| 131 | - * @abstract |
|
| 132 | - * @access public |
|
| 133 | - * @param string $post_id The ID of the cpt that was trashed |
|
| 134 | - * @return void |
|
| 135 | - */ |
|
| 136 | - abstract public function trash_cpt_item($post_id); |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed |
|
| 142 | - * |
|
| 143 | - * @param string $post_id theID of the cpt that was untrashed |
|
| 144 | - * @return void |
|
| 145 | - */ |
|
| 146 | - abstract public function restore_cpt_item($post_id); |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted |
|
| 152 | - * from the db |
|
| 153 | - * |
|
| 154 | - * @param string $post_id the ID of the cpt that was deleted |
|
| 155 | - * @return void |
|
| 156 | - */ |
|
| 157 | - abstract public function delete_cpt_item($post_id); |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Just utilizing the method EE_Admin exposes for doing things before page setup. |
|
| 163 | - * |
|
| 164 | - * @access protected |
|
| 165 | - * @return void |
|
| 166 | - */ |
|
| 167 | - protected function _before_page_setup() |
|
| 168 | - { |
|
| 169 | - $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
| 170 | - $this->_cpt_routes = array_merge(array( |
|
| 171 | - 'create_new' => $this->page_slug, |
|
| 172 | - 'edit' => $this->page_slug, |
|
| 173 | - 'trash' => $this->page_slug, |
|
| 174 | - ), $this->_cpt_routes); |
|
| 175 | - //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
|
| 176 | - $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 177 | - ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) |
|
| 178 | - : get_post_type_object($page); |
|
| 179 | - //tweak pagenow for page loading. |
|
| 180 | - if ( ! $this->_pagenow_map) { |
|
| 181 | - $this->_pagenow_map = array( |
|
| 182 | - 'create_new' => 'post-new.php', |
|
| 183 | - 'edit' => 'post.php', |
|
| 184 | - 'trash' => 'post.php', |
|
| 185 | - ); |
|
| 186 | - } |
|
| 187 | - add_action('current_screen', array($this, 'modify_pagenow')); |
|
| 188 | - //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
|
| 189 | - //get current page from autosave |
|
| 190 | - $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) |
|
| 191 | - ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] |
|
| 192 | - : null; |
|
| 193 | - $this->_current_page = isset($this->_req_data['current_page']) |
|
| 194 | - ? $this->_req_data['current_page'] |
|
| 195 | - : $current_page; |
|
| 196 | - //autosave... make sure its only for the correct page |
|
| 197 | - if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
| 198 | - //setup autosave ajax hook |
|
| 199 | - //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Simply ensure that we simulate the correct post route for cpt screens |
|
| 207 | - * |
|
| 208 | - * @param WP_Screen $current_screen |
|
| 209 | - * @return void |
|
| 210 | - */ |
|
| 211 | - public function modify_pagenow($current_screen) |
|
| 212 | - { |
|
| 213 | - global $pagenow, $hook_suffix; |
|
| 214 | - //possibly reset pagenow. |
|
| 215 | - if ( ! empty($this->_req_data['page']) |
|
| 216 | - && $this->_req_data['page'] == $this->page_slug |
|
| 217 | - && ! empty($this->_req_data['action']) |
|
| 218 | - && isset($this->_pagenow_map[$this->_req_data['action']]) |
|
| 219 | - ) { |
|
| 220 | - $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
|
| 221 | - $hook_suffix = $pagenow; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * This method is used to register additional autosave containers to the _autosave_containers property. |
|
| 229 | - * |
|
| 230 | - * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we |
|
| 231 | - * automatically register the id for the post metabox as a container. |
|
| 232 | - * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically |
|
| 233 | - * you would send along the id of a metabox container. |
|
| 234 | - * @return void |
|
| 235 | - */ |
|
| 236 | - protected function _register_autosave_containers($ids) |
|
| 237 | - { |
|
| 238 | - $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Something nifty. We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of |
|
| 245 | - * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array. |
|
| 246 | - */ |
|
| 247 | - protected function _set_autosave_containers() |
|
| 248 | - { |
|
| 249 | - global $wp_meta_boxes; |
|
| 250 | - $containers = array(); |
|
| 251 | - if (empty($wp_meta_boxes)) { |
|
| 252 | - return; |
|
| 253 | - } |
|
| 254 | - $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
| 255 | - foreach ($current_metaboxes as $box_context) { |
|
| 256 | - foreach ($box_context as $box_details) { |
|
| 257 | - foreach ($box_details as $box) { |
|
| 258 | - if (is_array($box['callback']) |
|
| 259 | - && ($box['callback'][0] instanceof EE_Admin_Page |
|
| 260 | - || $box['callback'][0] instanceof EE_Admin_Hooks) |
|
| 261 | - ) { |
|
| 262 | - $containers[] = $box['id']; |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
| 268 | - //add hidden inputs container |
|
| 269 | - $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - protected function _load_autosave_scripts_styles() |
|
| 275 | - { |
|
| 276 | - /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 59 | + /** |
|
| 60 | + * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update. |
|
| 61 | + * in this format: |
|
| 62 | + * array( |
|
| 63 | + * 'post_type_slug' => 'edit_route' |
|
| 64 | + * ) |
|
| 65 | + * |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | + protected $_cpt_edit_routes = array(); |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will |
|
| 74 | + * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the |
|
| 75 | + * _cpt_model_names property should be in the following format: array( |
|
| 76 | + * 'route_defined_by_action_param' => 'Model_Name') |
|
| 77 | + * |
|
| 78 | + * @var array $_cpt_model_names |
|
| 79 | + */ |
|
| 80 | + protected $_cpt_model_names = array(); |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @var EE_CPT_Base |
|
| 85 | + */ |
|
| 86 | + protected $_cpt_model_obj = false; |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP |
|
| 92 | + * autosave so we can save our inputs on the save_post hook! Children classes should add to this array by using |
|
| 93 | + * the _register_autosave_containers() method so that we don't override any other containers already registered. |
|
| 94 | + * Registration of containers should be done before load_page_dependencies() is run. |
|
| 95 | + * |
|
| 96 | + * @var array() |
|
| 97 | + */ |
|
| 98 | + protected $_autosave_containers = array(); |
|
| 99 | + protected $_autosave_fields = array(); |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits |
|
| 103 | + * a page for an action, it will appear as if they were visiting the wp core page for that custom post type |
|
| 104 | + * |
|
| 105 | + * @var array |
|
| 106 | + */ |
|
| 107 | + protected $_pagenow_map = null; |
|
| 108 | + |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 113 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
| 114 | + * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important. When a |
|
| 115 | + * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data |
|
| 116 | + * containing any extra info you may have from other meta saves. So MAKE sure that you handle this accordingly. |
|
| 117 | + * |
|
| 118 | + * @access protected |
|
| 119 | + * @abstract |
|
| 120 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 121 | + * @param object $post The post object of the cpt that was saved. |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + abstract protected function _insert_update_cpt_item($post_id, $post); |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed. |
|
| 130 | + * |
|
| 131 | + * @abstract |
|
| 132 | + * @access public |
|
| 133 | + * @param string $post_id The ID of the cpt that was trashed |
|
| 134 | + * @return void |
|
| 135 | + */ |
|
| 136 | + abstract public function trash_cpt_item($post_id); |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed |
|
| 142 | + * |
|
| 143 | + * @param string $post_id theID of the cpt that was untrashed |
|
| 144 | + * @return void |
|
| 145 | + */ |
|
| 146 | + abstract public function restore_cpt_item($post_id); |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted |
|
| 152 | + * from the db |
|
| 153 | + * |
|
| 154 | + * @param string $post_id the ID of the cpt that was deleted |
|
| 155 | + * @return void |
|
| 156 | + */ |
|
| 157 | + abstract public function delete_cpt_item($post_id); |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Just utilizing the method EE_Admin exposes for doing things before page setup. |
|
| 163 | + * |
|
| 164 | + * @access protected |
|
| 165 | + * @return void |
|
| 166 | + */ |
|
| 167 | + protected function _before_page_setup() |
|
| 168 | + { |
|
| 169 | + $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug; |
|
| 170 | + $this->_cpt_routes = array_merge(array( |
|
| 171 | + 'create_new' => $this->page_slug, |
|
| 172 | + 'edit' => $this->page_slug, |
|
| 173 | + 'trash' => $this->page_slug, |
|
| 174 | + ), $this->_cpt_routes); |
|
| 175 | + //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page |
|
| 176 | + $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 177 | + ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']]) |
|
| 178 | + : get_post_type_object($page); |
|
| 179 | + //tweak pagenow for page loading. |
|
| 180 | + if ( ! $this->_pagenow_map) { |
|
| 181 | + $this->_pagenow_map = array( |
|
| 182 | + 'create_new' => 'post-new.php', |
|
| 183 | + 'edit' => 'post.php', |
|
| 184 | + 'trash' => 'post.php', |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | + add_action('current_screen', array($this, 'modify_pagenow')); |
|
| 188 | + //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param. |
|
| 189 | + //get current page from autosave |
|
| 190 | + $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']) |
|
| 191 | + ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'] |
|
| 192 | + : null; |
|
| 193 | + $this->_current_page = isset($this->_req_data['current_page']) |
|
| 194 | + ? $this->_req_data['current_page'] |
|
| 195 | + : $current_page; |
|
| 196 | + //autosave... make sure its only for the correct page |
|
| 197 | + if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) { |
|
| 198 | + //setup autosave ajax hook |
|
| 199 | + //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Simply ensure that we simulate the correct post route for cpt screens |
|
| 207 | + * |
|
| 208 | + * @param WP_Screen $current_screen |
|
| 209 | + * @return void |
|
| 210 | + */ |
|
| 211 | + public function modify_pagenow($current_screen) |
|
| 212 | + { |
|
| 213 | + global $pagenow, $hook_suffix; |
|
| 214 | + //possibly reset pagenow. |
|
| 215 | + if ( ! empty($this->_req_data['page']) |
|
| 216 | + && $this->_req_data['page'] == $this->page_slug |
|
| 217 | + && ! empty($this->_req_data['action']) |
|
| 218 | + && isset($this->_pagenow_map[$this->_req_data['action']]) |
|
| 219 | + ) { |
|
| 220 | + $pagenow = $this->_pagenow_map[$this->_req_data['action']]; |
|
| 221 | + $hook_suffix = $pagenow; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * This method is used to register additional autosave containers to the _autosave_containers property. |
|
| 229 | + * |
|
| 230 | + * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we |
|
| 231 | + * automatically register the id for the post metabox as a container. |
|
| 232 | + * @param array $ids an array of ids for containers that hold form inputs we want autosave to pickup. Typically |
|
| 233 | + * you would send along the id of a metabox container. |
|
| 234 | + * @return void |
|
| 235 | + */ |
|
| 236 | + protected function _register_autosave_containers($ids) |
|
| 237 | + { |
|
| 238 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Something nifty. We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of |
|
| 245 | + * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array. |
|
| 246 | + */ |
|
| 247 | + protected function _set_autosave_containers() |
|
| 248 | + { |
|
| 249 | + global $wp_meta_boxes; |
|
| 250 | + $containers = array(); |
|
| 251 | + if (empty($wp_meta_boxes)) { |
|
| 252 | + return; |
|
| 253 | + } |
|
| 254 | + $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array(); |
|
| 255 | + foreach ($current_metaboxes as $box_context) { |
|
| 256 | + foreach ($box_context as $box_details) { |
|
| 257 | + foreach ($box_details as $box) { |
|
| 258 | + if (is_array($box['callback']) |
|
| 259 | + && ($box['callback'][0] instanceof EE_Admin_Page |
|
| 260 | + || $box['callback'][0] instanceof EE_Admin_Hooks) |
|
| 261 | + ) { |
|
| 262 | + $containers[] = $box['id']; |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + $this->_autosave_containers = array_merge($this->_autosave_containers, $containers); |
|
| 268 | + //add hidden inputs container |
|
| 269 | + $this->_autosave_containers[] = 'ee-cpt-hidden-inputs'; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + protected function _load_autosave_scripts_styles() |
|
| 275 | + { |
|
| 276 | + /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 277 | 277 | wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2 |
| 278 | 278 | |
| 279 | - //filter _autosave_containers |
|
| 280 | - $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', |
|
| 281 | - $this->_autosave_containers, $this); |
|
| 282 | - $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', |
|
| 283 | - $containers, $this); |
|
| 284 | - |
|
| 285 | - wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', |
|
| 286 | - $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
| 287 | - |
|
| 288 | - $unsaved_data_msg = array( |
|
| 289 | - 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", |
|
| 290 | - 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 291 | - 'inputChanged' => 0, |
|
| 292 | - ); |
|
| 293 | - wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - |
|
| 298 | - public function load_page_dependencies() |
|
| 299 | - { |
|
| 300 | - try { |
|
| 301 | - $this->_load_page_dependencies(); |
|
| 302 | - } catch (EE_Error $e) { |
|
| 303 | - $e->get_error(); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately |
|
| 311 | - * |
|
| 312 | - * @access protected |
|
| 313 | - * @return void |
|
| 314 | - */ |
|
| 315 | - protected function _load_page_dependencies() |
|
| 316 | - { |
|
| 317 | - //we only add stuff if this is a cpt_route! |
|
| 318 | - if ( ! $this->_cpt_route) { |
|
| 319 | - parent::_load_page_dependencies(); |
|
| 320 | - return; |
|
| 321 | - } |
|
| 322 | - //now let's do some automatic filters into the wp_system and we'll check to make sure the CHILD class automatically has the required methods in place. |
|
| 323 | - //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
|
| 324 | - //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
|
| 325 | - add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
| 326 | - //inject our Admin page nav tabs... |
|
| 327 | - //let's make sure the nav tabs are set if they aren't already |
|
| 328 | - //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
|
| 329 | - add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
| 330 | - //modify the post_updated messages array |
|
| 331 | - add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
| 332 | - //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
|
| 333 | - add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
| 334 | - //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
|
| 335 | - if ( ! empty($this->_labels['publishbox'])) { |
|
| 336 | - $box_label = is_array($this->_labels['publishbox']) |
|
| 337 | - && isset($this->_labels['publishbox'][$this->_req_action]) |
|
| 338 | - ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 339 | - remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 340 | - 'side', 'core'); |
|
| 341 | - add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 342 | - 'side', 'core'); |
|
| 343 | - } |
|
| 344 | - //let's add page_templates metabox if this cpt added support for it. |
|
| 345 | - if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
| 346 | - add_meta_box('page_templates', __('Page Template', 'event_espresso'), |
|
| 347 | - array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
| 348 | - } |
|
| 349 | - //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
| 350 | - if (method_exists($this, 'extra_permalink_field_buttons')) { |
|
| 351 | - add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
| 352 | - } |
|
| 353 | - //add preview button |
|
| 354 | - add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
| 355 | - //insert our own post_stati dropdown |
|
| 356 | - add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
| 357 | - //This allows adding additional information to the publish post submitbox on the wp post edit form |
|
| 358 | - if (method_exists($this, 'extra_misc_actions_publish_box')) { |
|
| 359 | - add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
| 360 | - } |
|
| 361 | - //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
|
| 362 | - if (method_exists($this, 'edit_form_after_title')) { |
|
| 363 | - add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
| 364 | - } |
|
| 365 | - /** |
|
| 366 | - * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
|
| 367 | - */ |
|
| 368 | - add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
| 369 | - parent::_load_page_dependencies(); |
|
| 370 | - //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
|
| 371 | - global $pagenow; |
|
| 372 | - do_action('load-' . $pagenow); |
|
| 373 | - $this->modify_current_screen(); |
|
| 374 | - add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
| 375 | - //we route REALLY early. |
|
| 376 | - try { |
|
| 377 | - $this->_route_admin_request(); |
|
| 378 | - } catch (EE_Error $e) { |
|
| 379 | - $e->get_error(); |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * Since we don't want users going to default core wp routes, this will check any wp urls run through the |
|
| 387 | - * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR |
|
| 388 | - * route instead. |
|
| 389 | - * |
|
| 390 | - * @param string $good_protocol_url The escaped url. |
|
| 391 | - * @param string $original_url The original url. |
|
| 392 | - * @param string $_context The context sendt to the esc_url method. |
|
| 393 | - * @return string possibly a new url for our route. |
|
| 394 | - */ |
|
| 395 | - public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) |
|
| 396 | - { |
|
| 397 | - $routes_to_match = array( |
|
| 398 | - 0 => array( |
|
| 399 | - 'edit.php?post_type=espresso_attendees', |
|
| 400 | - 'admin.php?page=espresso_registrations&action=contact_list', |
|
| 401 | - ), |
|
| 402 | - 1 => array( |
|
| 403 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
| 404 | - 'admin.php?page=' . $this->_cpt_object->name, |
|
| 405 | - ), |
|
| 406 | - ); |
|
| 407 | - foreach ($routes_to_match as $route_matches) { |
|
| 408 | - if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
| 409 | - return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
| 410 | - } |
|
| 411 | - } |
|
| 412 | - return $good_protocol_url; |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * Determine whether the current cpt supports page templates or not. |
|
| 419 | - * |
|
| 420 | - * @since %VER% |
|
| 421 | - * @param string $cpt_name The cpt slug we're checking on. |
|
| 422 | - * @return bool True supported, false not. |
|
| 423 | - */ |
|
| 424 | - private function _supports_page_templates($cpt_name) |
|
| 425 | - { |
|
| 426 | - |
|
| 427 | - $cpt_args = EE_Register_CPTs::get_CPTs(); |
|
| 428 | - $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
| 429 | - $cpt_has_support = ! empty($cpt_args['page_templates']); |
|
| 430 | - |
|
| 431 | - //if the installed version of WP is > 4.7 we do some additional checks. |
|
| 432 | - if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 433 | - $post_templates = wp_get_theme()->get_post_templates(); |
|
| 434 | - //if there are $post_templates for this cpt, then we return false for this method because |
|
| 435 | - //that means we aren't going to load our page template manager and leave that up to the native |
|
| 436 | - //cpt template manager. |
|
| 437 | - $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - return $cpt_has_support; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * Callback for the page_templates metabox selector. |
|
| 446 | - * |
|
| 447 | - * @since %VER% |
|
| 448 | - * @return string html |
|
| 449 | - */ |
|
| 450 | - public function page_template_meta_box() |
|
| 451 | - { |
|
| 452 | - global $post; |
|
| 453 | - $template = ''; |
|
| 454 | - |
|
| 455 | - if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 456 | - $page_template_count = count(get_page_templates()); |
|
| 457 | - } else { |
|
| 458 | - $page_template_count = count(get_page_templates($post)); |
|
| 459 | - }; |
|
| 460 | - |
|
| 461 | - if ($page_template_count) { |
|
| 462 | - $page_template = get_post_meta($post->ID, '_wp_page_template', true); |
|
| 463 | - $template = ! empty($page_template) ? $page_template : ''; |
|
| 464 | - } |
|
| 465 | - ?> |
|
| 279 | + //filter _autosave_containers |
|
| 280 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', |
|
| 281 | + $this->_autosave_containers, $this); |
|
| 282 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', |
|
| 283 | + $containers, $this); |
|
| 284 | + |
|
| 285 | + wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', |
|
| 286 | + $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave" |
|
| 287 | + |
|
| 288 | + $unsaved_data_msg = array( |
|
| 289 | + 'eventmsg' => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.", |
|
| 290 | + 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 291 | + 'inputChanged' => 0, |
|
| 292 | + ); |
|
| 293 | + wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + |
|
| 298 | + public function load_page_dependencies() |
|
| 299 | + { |
|
| 300 | + try { |
|
| 301 | + $this->_load_page_dependencies(); |
|
| 302 | + } catch (EE_Error $e) { |
|
| 303 | + $e->get_error(); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately |
|
| 311 | + * |
|
| 312 | + * @access protected |
|
| 313 | + * @return void |
|
| 314 | + */ |
|
| 315 | + protected function _load_page_dependencies() |
|
| 316 | + { |
|
| 317 | + //we only add stuff if this is a cpt_route! |
|
| 318 | + if ( ! $this->_cpt_route) { |
|
| 319 | + parent::_load_page_dependencies(); |
|
| 320 | + return; |
|
| 321 | + } |
|
| 322 | + //now let's do some automatic filters into the wp_system and we'll check to make sure the CHILD class automatically has the required methods in place. |
|
| 323 | + //the following filters are for setting all the redirects on DEFAULT WP custom post type actions |
|
| 324 | + //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects! Otherwise the redirects will happen on ALL post saves which wouldn't be good of course! |
|
| 325 | + add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input')); |
|
| 326 | + //inject our Admin page nav tabs... |
|
| 327 | + //let's make sure the nav tabs are set if they aren't already |
|
| 328 | + //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs(); |
|
| 329 | + add_action('post_edit_form_tag', array($this, 'inject_nav_tabs')); |
|
| 330 | + //modify the post_updated messages array |
|
| 331 | + add_action('post_updated_messages', array($this, 'post_update_messages'), 10); |
|
| 332 | + //add shortlink button to cpt edit screens. We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts! |
|
| 333 | + add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4); |
|
| 334 | + //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class. |
|
| 335 | + if ( ! empty($this->_labels['publishbox'])) { |
|
| 336 | + $box_label = is_array($this->_labels['publishbox']) |
|
| 337 | + && isset($this->_labels['publishbox'][$this->_req_action]) |
|
| 338 | + ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 339 | + remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 340 | + 'side', 'core'); |
|
| 341 | + add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action], |
|
| 342 | + 'side', 'core'); |
|
| 343 | + } |
|
| 344 | + //let's add page_templates metabox if this cpt added support for it. |
|
| 345 | + if ($this->_supports_page_templates($this->_cpt_object->name)) { |
|
| 346 | + add_meta_box('page_templates', __('Page Template', 'event_espresso'), |
|
| 347 | + array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default'); |
|
| 348 | + } |
|
| 349 | + //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form |
|
| 350 | + if (method_exists($this, 'extra_permalink_field_buttons')) { |
|
| 351 | + add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4); |
|
| 352 | + } |
|
| 353 | + //add preview button |
|
| 354 | + add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4); |
|
| 355 | + //insert our own post_stati dropdown |
|
| 356 | + add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10); |
|
| 357 | + //This allows adding additional information to the publish post submitbox on the wp post edit form |
|
| 358 | + if (method_exists($this, 'extra_misc_actions_publish_box')) { |
|
| 359 | + add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10); |
|
| 360 | + } |
|
| 361 | + //This allows for adding additional stuff after the title field on the wp post edit form. This is also before the wp_editor for post description field. |
|
| 362 | + if (method_exists($this, 'edit_form_after_title')) { |
|
| 363 | + add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10); |
|
| 364 | + } |
|
| 365 | + /** |
|
| 366 | + * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route. |
|
| 367 | + */ |
|
| 368 | + add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3); |
|
| 369 | + parent::_load_page_dependencies(); |
|
| 370 | + //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
|
| 371 | + global $pagenow; |
|
| 372 | + do_action('load-' . $pagenow); |
|
| 373 | + $this->modify_current_screen(); |
|
| 374 | + add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
|
| 375 | + //we route REALLY early. |
|
| 376 | + try { |
|
| 377 | + $this->_route_admin_request(); |
|
| 378 | + } catch (EE_Error $e) { |
|
| 379 | + $e->get_error(); |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Since we don't want users going to default core wp routes, this will check any wp urls run through the |
|
| 387 | + * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR |
|
| 388 | + * route instead. |
|
| 389 | + * |
|
| 390 | + * @param string $good_protocol_url The escaped url. |
|
| 391 | + * @param string $original_url The original url. |
|
| 392 | + * @param string $_context The context sendt to the esc_url method. |
|
| 393 | + * @return string possibly a new url for our route. |
|
| 394 | + */ |
|
| 395 | + public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context) |
|
| 396 | + { |
|
| 397 | + $routes_to_match = array( |
|
| 398 | + 0 => array( |
|
| 399 | + 'edit.php?post_type=espresso_attendees', |
|
| 400 | + 'admin.php?page=espresso_registrations&action=contact_list', |
|
| 401 | + ), |
|
| 402 | + 1 => array( |
|
| 403 | + 'edit.php?post_type=' . $this->_cpt_object->name, |
|
| 404 | + 'admin.php?page=' . $this->_cpt_object->name, |
|
| 405 | + ), |
|
| 406 | + ); |
|
| 407 | + foreach ($routes_to_match as $route_matches) { |
|
| 408 | + if (strpos($good_protocol_url, $route_matches[0]) !== false) { |
|
| 409 | + return str_replace($route_matches[0], $route_matches[1], $good_protocol_url); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + return $good_protocol_url; |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * Determine whether the current cpt supports page templates or not. |
|
| 419 | + * |
|
| 420 | + * @since %VER% |
|
| 421 | + * @param string $cpt_name The cpt slug we're checking on. |
|
| 422 | + * @return bool True supported, false not. |
|
| 423 | + */ |
|
| 424 | + private function _supports_page_templates($cpt_name) |
|
| 425 | + { |
|
| 426 | + |
|
| 427 | + $cpt_args = EE_Register_CPTs::get_CPTs(); |
|
| 428 | + $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array(); |
|
| 429 | + $cpt_has_support = ! empty($cpt_args['page_templates']); |
|
| 430 | + |
|
| 431 | + //if the installed version of WP is > 4.7 we do some additional checks. |
|
| 432 | + if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 433 | + $post_templates = wp_get_theme()->get_post_templates(); |
|
| 434 | + //if there are $post_templates for this cpt, then we return false for this method because |
|
| 435 | + //that means we aren't going to load our page template manager and leave that up to the native |
|
| 436 | + //cpt template manager. |
|
| 437 | + $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + return $cpt_has_support; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * Callback for the page_templates metabox selector. |
|
| 446 | + * |
|
| 447 | + * @since %VER% |
|
| 448 | + * @return string html |
|
| 449 | + */ |
|
| 450 | + public function page_template_meta_box() |
|
| 451 | + { |
|
| 452 | + global $post; |
|
| 453 | + $template = ''; |
|
| 454 | + |
|
| 455 | + if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 456 | + $page_template_count = count(get_page_templates()); |
|
| 457 | + } else { |
|
| 458 | + $page_template_count = count(get_page_templates($post)); |
|
| 459 | + }; |
|
| 460 | + |
|
| 461 | + if ($page_template_count) { |
|
| 462 | + $page_template = get_post_meta($post->ID, '_wp_page_template', true); |
|
| 463 | + $template = ! empty($page_template) ? $page_template : ''; |
|
| 464 | + } |
|
| 465 | + ?> |
|
| 466 | 466 | <p><strong><?php _e('Template') ?></strong></p> |
| 467 | 467 | <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select |
| 468 | 468 | name="page_template" id="page_template"> |
@@ -470,435 +470,435 @@ discard block |
||
| 470 | 470 | <?php page_template_dropdown($template); ?> |
| 471 | 471 | </select> |
| 472 | 472 | <?php |
| 473 | - } |
|
| 474 | - |
|
| 475 | - |
|
| 476 | - |
|
| 477 | - /** |
|
| 478 | - * if this post is a draft or scheduled post then we provide a preview button for user to click |
|
| 479 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 480 | - * |
|
| 481 | - * @param string $return the current html |
|
| 482 | - * @param int $id the post id for the page |
|
| 483 | - * @param string $new_title What the title is |
|
| 484 | - * @param string $new_slug what the slug is |
|
| 485 | - * @return string The new html string for the permalink area |
|
| 486 | - */ |
|
| 487 | - public function preview_button_html($return, $id, $new_title, $new_slug) |
|
| 488 | - { |
|
| 489 | - $post = get_post($id); |
|
| 490 | - if ('publish' != get_post_status($post)) { |
|
| 491 | - //include shims for the `get_preview_post_link` function |
|
| 492 | - require_once( EE_CORE . 'wordpress-shims.php' ); |
|
| 493 | - $return .= '<span_id="view-post-btn"><a target="_blank" href="' |
|
| 494 | - . get_preview_post_link($id) |
|
| 495 | - . '" class="button button-small">' |
|
| 496 | - . __('Preview', 'event_espresso') |
|
| 497 | - . '</a></span>' |
|
| 498 | - . "\n"; |
|
| 499 | - } |
|
| 500 | - return $return; |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - |
|
| 504 | - |
|
| 505 | - /** |
|
| 506 | - * add our custom post stati dropdown on the wp post page for this cpt |
|
| 507 | - * |
|
| 508 | - * @return string html for dropdown |
|
| 509 | - */ |
|
| 510 | - public function custom_post_stati_dropdown() |
|
| 511 | - { |
|
| 512 | - |
|
| 513 | - $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
|
| 514 | - $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses) |
|
| 515 | - ? $statuses[$this->_cpt_model_obj->status()] |
|
| 516 | - : ''; |
|
| 517 | - $template_args = array( |
|
| 518 | - 'cur_status' => $this->_cpt_model_obj->status(), |
|
| 519 | - 'statuses' => $statuses, |
|
| 520 | - 'cur_status_label' => $cur_status_label, |
|
| 521 | - 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label), |
|
| 522 | - ); |
|
| 523 | - //we'll add a trash post status (WP doesn't add one for some reason) |
|
| 524 | - if ($this->_cpt_model_obj->status() == 'trash') { |
|
| 525 | - $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
|
| 526 | - $statuses['trash'] = __('Trashed', 'event_espresso'); |
|
| 527 | - $template_args['statuses'] = $statuses; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
| 531 | - EEH_Template::display_template($template, $template_args); |
|
| 532 | - } |
|
| 533 | - |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - public function setup_autosave_hooks() |
|
| 537 | - { |
|
| 538 | - $this->_set_autosave_containers(); |
|
| 539 | - $this->_load_autosave_scripts_styles(); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - |
|
| 544 | - /** |
|
| 545 | - * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available |
|
| 546 | - * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check |
|
| 547 | - * for the nonce in here, but then this method looks for two things: |
|
| 548 | - * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR |
|
| 549 | - * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an |
|
| 550 | - * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the |
|
| 551 | - * $_template_args property should be used to hold the $data array. We're expecting the following things set in |
|
| 552 | - * template args. |
|
| 553 | - * 1. $template_args['error'] = IF there is an error you can add the message in here. |
|
| 554 | - * 2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go' |
|
| 555 | - * => 'values_to_add'. In other words, for the datetime metabox we'll have something like |
|
| 556 | - * $this->_template_args['data']['items'] = array( |
|
| 557 | - * 'event-datetime-ids' => '1,2,3'; |
|
| 558 | - * ); |
|
| 559 | - * Keep in mind the following things: |
|
| 560 | - * - "where" index is for the input with the id as that string. |
|
| 561 | - * - "what" index is what will be used for the value of that input. |
|
| 562 | - * |
|
| 563 | - * @return void |
|
| 564 | - */ |
|
| 565 | - public function do_extra_autosave_stuff() |
|
| 566 | - { |
|
| 567 | - //next let's check for the autosave nonce (we'll use _verify_nonce ) |
|
| 568 | - $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : null; |
|
| 569 | - $this->_verify_nonce($nonce, 'autosave'); |
|
| 570 | - //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
|
| 571 | - if ( ! defined('DOING_AUTOSAVE')) { |
|
| 572 | - define('DOING_AUTOSAVE', true); |
|
| 573 | - } |
|
| 574 | - //if we made it here then the nonce checked out. Let's run our methods and actions |
|
| 575 | - if (method_exists($this, '_ee_autosave_' . $this->_current_view)) { |
|
| 576 | - call_user_func(array($this, '_ee_autosave_' . $this->_current_view)); |
|
| 577 | - } else { |
|
| 578 | - $this->_template_args['success'] = true; |
|
| 579 | - } |
|
| 580 | - do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
| 581 | - do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this); |
|
| 582 | - //now let's return json |
|
| 583 | - $this->_return_json(); |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * This takes care of setting up default routes and pages that utilize the core WP admin pages. |
|
| 590 | - * Child classes can override the defaults (in cases for adding metaboxes etc.) |
|
| 591 | - * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work! |
|
| 592 | - * |
|
| 593 | - * @access protected |
|
| 594 | - * @throws EE_Error |
|
| 595 | - * @return void |
|
| 596 | - */ |
|
| 597 | - protected function _extend_page_config_for_cpt() |
|
| 598 | - { |
|
| 599 | - //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
|
| 600 | - if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) { |
|
| 601 | - return; |
|
| 602 | - } |
|
| 603 | - //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
|
| 604 | - if ( ! empty($this->_cpt_object)) { |
|
| 605 | - $this->_page_routes = array_merge(array( |
|
| 606 | - 'create_new' => '_create_new_cpt_item', |
|
| 607 | - 'edit' => '_edit_cpt_item', |
|
| 608 | - ), $this->_page_routes); |
|
| 609 | - $this->_page_config = array_merge(array( |
|
| 610 | - 'create_new' => array( |
|
| 611 | - 'nav' => array( |
|
| 612 | - 'label' => $this->_cpt_object->labels->add_new_item, |
|
| 613 | - 'order' => 5, |
|
| 614 | - ), |
|
| 615 | - 'require_nonce' => false, |
|
| 616 | - ), |
|
| 617 | - 'edit' => array( |
|
| 618 | - 'nav' => array( |
|
| 619 | - 'label' => $this->_cpt_object->labels->edit_item, |
|
| 620 | - 'order' => 5, |
|
| 621 | - 'persistent' => false, |
|
| 622 | - 'url' => '', |
|
| 623 | - ), |
|
| 624 | - 'require_nonce' => false, |
|
| 625 | - ), |
|
| 626 | - ), |
|
| 627 | - $this->_page_config |
|
| 628 | - ); |
|
| 629 | - } |
|
| 630 | - //load the next section only if this is a matching cpt route as set in the cpt routes array. |
|
| 631 | - if ( ! isset($this->_cpt_routes[$this->_req_action])) { |
|
| 632 | - return; |
|
| 633 | - } |
|
| 634 | - $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false; |
|
| 635 | - //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
|
| 636 | - if (empty($this->_cpt_object)) { |
|
| 637 | - $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), |
|
| 638 | - $this->page_slug, $this->_req_action, get_class($this)); |
|
| 639 | - throw new EE_Error($msg); |
|
| 640 | - } |
|
| 641 | - if ($this->_cpt_route) { |
|
| 642 | - $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 643 | - $this->_set_model_object($id); |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id. |
|
| 651 | - * |
|
| 652 | - * @access protected |
|
| 653 | - * @param int $id The id to retrieve the model object for. If empty we set a default object. |
|
| 654 | - * @param bool $ignore_route_check |
|
| 655 | - */ |
|
| 656 | - protected function _set_model_object($id = null, $ignore_route_check = false) |
|
| 657 | - { |
|
| 658 | - $model = null; |
|
| 659 | - if ( |
|
| 660 | - empty($this->_cpt_model_names) |
|
| 661 | - || ( |
|
| 662 | - ! $ignore_route_check |
|
| 663 | - && ! isset($this->_cpt_routes[$this->_req_action]) |
|
| 664 | - ) || ( |
|
| 665 | - $this->_cpt_model_obj instanceof EE_CPT_Base |
|
| 666 | - && $this->_cpt_model_obj->ID() === $id |
|
| 667 | - ) |
|
| 668 | - ) { |
|
| 669 | - //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent. |
|
| 670 | - return; |
|
| 671 | - } |
|
| 672 | - //if ignore_route_check is true, then get the model name via EE_Register_CPTs |
|
| 673 | - if ($ignore_route_check) { |
|
| 674 | - $model_names = EE_Register_CPTs::get_cpt_model_names(); |
|
| 675 | - $post_type = get_post_type($id); |
|
| 676 | - if (isset($model_names[$post_type])) { |
|
| 677 | - $model = EE_Registry::instance()->load_model($model_names[$post_type]); |
|
| 678 | - } |
|
| 679 | - } else { |
|
| 680 | - $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
| 681 | - } |
|
| 682 | - if ($model instanceof EEM_Base) { |
|
| 683 | - $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
| 684 | - } |
|
| 685 | - do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * admin_init_global |
|
| 692 | - * This runs all the code that we want executed within the WP admin_init hook. |
|
| 693 | - * This method executes for ALL EE Admin pages. |
|
| 694 | - * |
|
| 695 | - * @access public |
|
| 696 | - * @return void |
|
| 697 | - */ |
|
| 698 | - public function admin_init_global() |
|
| 699 | - { |
|
| 700 | - $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null; |
|
| 701 | - //its possible this is a new save so let's catch that instead |
|
| 702 | - $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
| 703 | - $post_type = $post ? $post->post_type : false; |
|
| 704 | - $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] |
|
| 705 | - : 'shouldneverwork'; |
|
| 706 | - $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] |
|
| 707 | - : ''; |
|
| 708 | - add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
| 709 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
| 710 | - if ($post_type === $route_to_check) { |
|
| 711 | - add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
| 712 | - } |
|
| 713 | - //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
|
| 714 | - $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null; |
|
| 715 | - if ( ! empty($revision)) { |
|
| 716 | - $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null; |
|
| 717 | - //doing a restore? |
|
| 718 | - if ( ! empty($action) && $action == 'restore') { |
|
| 719 | - //get post for revision |
|
| 720 | - $rev_post = get_post($revision); |
|
| 721 | - $rev_parent = get_post($rev_post->post_parent); |
|
| 722 | - //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
|
| 723 | - if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
| 724 | - add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
| 725 | - //restores of revisions |
|
| 726 | - add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
| 727 | - } |
|
| 728 | - } |
|
| 729 | - } |
|
| 730 | - //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
|
| 731 | - if ($post_type && $post_type === $route_to_check) { |
|
| 732 | - //$post_id, $post |
|
| 733 | - add_action('save_post', array($this, 'insert_update'), 10, 3); |
|
| 734 | - //$post_id |
|
| 735 | - add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10); |
|
| 736 | - add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
| 737 | - add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10); |
|
| 738 | - add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10); |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - |
|
| 743 | - |
|
| 744 | - /** |
|
| 745 | - * Callback for the WordPress trashed_post hook. |
|
| 746 | - * Execute some basic checks before calling the trash_cpt_item declared in the child class. |
|
| 747 | - * |
|
| 748 | - * @param int $post_id |
|
| 749 | - */ |
|
| 750 | - public function before_trash_cpt_item($post_id) |
|
| 751 | - { |
|
| 752 | - $this->_set_model_object($post_id, true); |
|
| 753 | - //if our cpt object isn't existent then get out immediately. |
|
| 754 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 755 | - return; |
|
| 756 | - } |
|
| 757 | - $this->trash_cpt_item($post_id); |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * Callback for the WordPress untrashed_post hook. |
|
| 764 | - * Execute some basic checks before calling the restore_cpt_method in the child class. |
|
| 765 | - * |
|
| 766 | - * @param $post_id |
|
| 767 | - */ |
|
| 768 | - public function before_restore_cpt_item($post_id) |
|
| 769 | - { |
|
| 770 | - $this->_set_model_object($post_id, true); |
|
| 771 | - //if our cpt object isn't existent then get out immediately. |
|
| 772 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 773 | - return; |
|
| 774 | - } |
|
| 775 | - $this->restore_cpt_item($post_id); |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * Callback for the WordPress after_delete_post hook. |
|
| 782 | - * Execute some basic checks before calling the delete_cpt_item method in the child class. |
|
| 783 | - * |
|
| 784 | - * @param $post_id |
|
| 785 | - */ |
|
| 786 | - public function before_delete_cpt_item($post_id) |
|
| 787 | - { |
|
| 788 | - $this->_set_model_object($post_id, true); |
|
| 789 | - //if our cpt object isn't existent then get out immediately. |
|
| 790 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 791 | - return; |
|
| 792 | - } |
|
| 793 | - $this->delete_cpt_item($post_id); |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - |
|
| 797 | - |
|
| 798 | - /** |
|
| 799 | - * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message |
|
| 800 | - * accordingly. |
|
| 801 | - * |
|
| 802 | - * @access public |
|
| 803 | - * @throws EE_Error |
|
| 804 | - * @return void |
|
| 805 | - */ |
|
| 806 | - public function verify_cpt_object() |
|
| 807 | - { |
|
| 808 | - $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
| 809 | - // verify event object |
|
| 810 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 811 | - throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', |
|
| 812 | - 'event_espresso'), $label)); |
|
| 813 | - } |
|
| 814 | - //if auto-draft then throw an error |
|
| 815 | - if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
| 816 | - EE_Error::overwrite_errors(); |
|
| 817 | - EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), |
|
| 818 | - $label), __FILE__, __FUNCTION__, __LINE__); |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * admin_footer_scripts_global |
|
| 826 | - * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method |
|
| 827 | - * will apply on ALL EE_Admin pages. |
|
| 828 | - * |
|
| 829 | - * @access public |
|
| 830 | - * @return void |
|
| 831 | - */ |
|
| 832 | - public function admin_footer_scripts_global() |
|
| 833 | - { |
|
| 834 | - $this->_add_admin_page_ajax_loading_img(); |
|
| 835 | - $this->_add_admin_page_overlay(); |
|
| 836 | - } |
|
| 837 | - |
|
| 838 | - |
|
| 839 | - |
|
| 840 | - /** |
|
| 841 | - * add in any global scripts for cpt routes |
|
| 842 | - * |
|
| 843 | - * @return void |
|
| 844 | - */ |
|
| 845 | - public function load_global_scripts_styles() |
|
| 846 | - { |
|
| 847 | - parent::load_global_scripts_styles(); |
|
| 848 | - if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 849 | - //setup custom post status object for localize script but only if we've got a cpt object |
|
| 850 | - $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
|
| 851 | - if ( ! empty($statuses)) { |
|
| 852 | - //get ALL statuses! |
|
| 853 | - $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
|
| 854 | - //setup object |
|
| 855 | - $ee_cpt_statuses = array(); |
|
| 856 | - foreach ($statuses as $status => $label) { |
|
| 857 | - $ee_cpt_statuses[$status] = array( |
|
| 858 | - 'label' => $label, |
|
| 859 | - 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label), |
|
| 860 | - ); |
|
| 861 | - } |
|
| 862 | - wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
| 863 | - } |
|
| 864 | - } |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - |
|
| 868 | - |
|
| 869 | - /** |
|
| 870 | - * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL |
|
| 871 | - * insert/updates |
|
| 872 | - * |
|
| 873 | - * @param int $post_id ID of post being updated |
|
| 874 | - * @param WP_Post $post Post object from WP |
|
| 875 | - * @param bool $update Whether this is an update or a new save. |
|
| 876 | - * @return void |
|
| 877 | - */ |
|
| 878 | - public function insert_update($post_id, $post, $update) |
|
| 879 | - { |
|
| 880 | - //make sure that if this is a revision OR trash action that we don't do any updates! |
|
| 881 | - if ( |
|
| 882 | - isset($this->_req_data['action']) |
|
| 883 | - && ( |
|
| 884 | - $this->_req_data['action'] == 'restore' |
|
| 885 | - || $this->_req_data['action'] == 'trash' |
|
| 886 | - ) |
|
| 887 | - ) { |
|
| 888 | - return; |
|
| 889 | - } |
|
| 890 | - $this->_set_model_object($post_id, true); |
|
| 891 | - //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
|
| 892 | - if ($update |
|
| 893 | - && ( |
|
| 894 | - ! $this->_cpt_model_obj instanceof EE_CPT_Base |
|
| 895 | - || $this->_cpt_model_obj->ID() !== $post_id |
|
| 896 | - ) |
|
| 897 | - ) { |
|
| 898 | - return; |
|
| 899 | - } |
|
| 900 | - //check for autosave and update our req_data property accordingly. |
|
| 901 | - /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) { |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + |
|
| 476 | + |
|
| 477 | + /** |
|
| 478 | + * if this post is a draft or scheduled post then we provide a preview button for user to click |
|
| 479 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 480 | + * |
|
| 481 | + * @param string $return the current html |
|
| 482 | + * @param int $id the post id for the page |
|
| 483 | + * @param string $new_title What the title is |
|
| 484 | + * @param string $new_slug what the slug is |
|
| 485 | + * @return string The new html string for the permalink area |
|
| 486 | + */ |
|
| 487 | + public function preview_button_html($return, $id, $new_title, $new_slug) |
|
| 488 | + { |
|
| 489 | + $post = get_post($id); |
|
| 490 | + if ('publish' != get_post_status($post)) { |
|
| 491 | + //include shims for the `get_preview_post_link` function |
|
| 492 | + require_once( EE_CORE . 'wordpress-shims.php' ); |
|
| 493 | + $return .= '<span_id="view-post-btn"><a target="_blank" href="' |
|
| 494 | + . get_preview_post_link($id) |
|
| 495 | + . '" class="button button-small">' |
|
| 496 | + . __('Preview', 'event_espresso') |
|
| 497 | + . '</a></span>' |
|
| 498 | + . "\n"; |
|
| 499 | + } |
|
| 500 | + return $return; |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + |
|
| 504 | + |
|
| 505 | + /** |
|
| 506 | + * add our custom post stati dropdown on the wp post page for this cpt |
|
| 507 | + * |
|
| 508 | + * @return string html for dropdown |
|
| 509 | + */ |
|
| 510 | + public function custom_post_stati_dropdown() |
|
| 511 | + { |
|
| 512 | + |
|
| 513 | + $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
|
| 514 | + $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses) |
|
| 515 | + ? $statuses[$this->_cpt_model_obj->status()] |
|
| 516 | + : ''; |
|
| 517 | + $template_args = array( |
|
| 518 | + 'cur_status' => $this->_cpt_model_obj->status(), |
|
| 519 | + 'statuses' => $statuses, |
|
| 520 | + 'cur_status_label' => $cur_status_label, |
|
| 521 | + 'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label), |
|
| 522 | + ); |
|
| 523 | + //we'll add a trash post status (WP doesn't add one for some reason) |
|
| 524 | + if ($this->_cpt_model_obj->status() == 'trash') { |
|
| 525 | + $template_args['cur_status_label'] = __('Trashed', 'event_espresso'); |
|
| 526 | + $statuses['trash'] = __('Trashed', 'event_espresso'); |
|
| 527 | + $template_args['statuses'] = $statuses; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
| 531 | + EEH_Template::display_template($template, $template_args); |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + public function setup_autosave_hooks() |
|
| 537 | + { |
|
| 538 | + $this->_set_autosave_containers(); |
|
| 539 | + $this->_load_autosave_scripts_styles(); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + |
|
| 544 | + /** |
|
| 545 | + * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available |
|
| 546 | + * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check |
|
| 547 | + * for the nonce in here, but then this method looks for two things: |
|
| 548 | + * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR |
|
| 549 | + * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an |
|
| 550 | + * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the |
|
| 551 | + * $_template_args property should be used to hold the $data array. We're expecting the following things set in |
|
| 552 | + * template args. |
|
| 553 | + * 1. $template_args['error'] = IF there is an error you can add the message in here. |
|
| 554 | + * 2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go' |
|
| 555 | + * => 'values_to_add'. In other words, for the datetime metabox we'll have something like |
|
| 556 | + * $this->_template_args['data']['items'] = array( |
|
| 557 | + * 'event-datetime-ids' => '1,2,3'; |
|
| 558 | + * ); |
|
| 559 | + * Keep in mind the following things: |
|
| 560 | + * - "where" index is for the input with the id as that string. |
|
| 561 | + * - "what" index is what will be used for the value of that input. |
|
| 562 | + * |
|
| 563 | + * @return void |
|
| 564 | + */ |
|
| 565 | + public function do_extra_autosave_stuff() |
|
| 566 | + { |
|
| 567 | + //next let's check for the autosave nonce (we'll use _verify_nonce ) |
|
| 568 | + $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : null; |
|
| 569 | + $this->_verify_nonce($nonce, 'autosave'); |
|
| 570 | + //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it) |
|
| 571 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
| 572 | + define('DOING_AUTOSAVE', true); |
|
| 573 | + } |
|
| 574 | + //if we made it here then the nonce checked out. Let's run our methods and actions |
|
| 575 | + if (method_exists($this, '_ee_autosave_' . $this->_current_view)) { |
|
| 576 | + call_user_func(array($this, '_ee_autosave_' . $this->_current_view)); |
|
| 577 | + } else { |
|
| 578 | + $this->_template_args['success'] = true; |
|
| 579 | + } |
|
| 580 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
|
| 581 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this); |
|
| 582 | + //now let's return json |
|
| 583 | + $this->_return_json(); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * This takes care of setting up default routes and pages that utilize the core WP admin pages. |
|
| 590 | + * Child classes can override the defaults (in cases for adding metaboxes etc.) |
|
| 591 | + * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work! |
|
| 592 | + * |
|
| 593 | + * @access protected |
|
| 594 | + * @throws EE_Error |
|
| 595 | + * @return void |
|
| 596 | + */ |
|
| 597 | + protected function _extend_page_config_for_cpt() |
|
| 598 | + { |
|
| 599 | + //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug |
|
| 600 | + if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) { |
|
| 601 | + return; |
|
| 602 | + } |
|
| 603 | + //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes |
|
| 604 | + if ( ! empty($this->_cpt_object)) { |
|
| 605 | + $this->_page_routes = array_merge(array( |
|
| 606 | + 'create_new' => '_create_new_cpt_item', |
|
| 607 | + 'edit' => '_edit_cpt_item', |
|
| 608 | + ), $this->_page_routes); |
|
| 609 | + $this->_page_config = array_merge(array( |
|
| 610 | + 'create_new' => array( |
|
| 611 | + 'nav' => array( |
|
| 612 | + 'label' => $this->_cpt_object->labels->add_new_item, |
|
| 613 | + 'order' => 5, |
|
| 614 | + ), |
|
| 615 | + 'require_nonce' => false, |
|
| 616 | + ), |
|
| 617 | + 'edit' => array( |
|
| 618 | + 'nav' => array( |
|
| 619 | + 'label' => $this->_cpt_object->labels->edit_item, |
|
| 620 | + 'order' => 5, |
|
| 621 | + 'persistent' => false, |
|
| 622 | + 'url' => '', |
|
| 623 | + ), |
|
| 624 | + 'require_nonce' => false, |
|
| 625 | + ), |
|
| 626 | + ), |
|
| 627 | + $this->_page_config |
|
| 628 | + ); |
|
| 629 | + } |
|
| 630 | + //load the next section only if this is a matching cpt route as set in the cpt routes array. |
|
| 631 | + if ( ! isset($this->_cpt_routes[$this->_req_action])) { |
|
| 632 | + return; |
|
| 633 | + } |
|
| 634 | + $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false; |
|
| 635 | + //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') ); |
|
| 636 | + if (empty($this->_cpt_object)) { |
|
| 637 | + $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this: 1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'), |
|
| 638 | + $this->page_slug, $this->_req_action, get_class($this)); |
|
| 639 | + throw new EE_Error($msg); |
|
| 640 | + } |
|
| 641 | + if ($this->_cpt_route) { |
|
| 642 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 643 | + $this->_set_model_object($id); |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id. |
|
| 651 | + * |
|
| 652 | + * @access protected |
|
| 653 | + * @param int $id The id to retrieve the model object for. If empty we set a default object. |
|
| 654 | + * @param bool $ignore_route_check |
|
| 655 | + */ |
|
| 656 | + protected function _set_model_object($id = null, $ignore_route_check = false) |
|
| 657 | + { |
|
| 658 | + $model = null; |
|
| 659 | + if ( |
|
| 660 | + empty($this->_cpt_model_names) |
|
| 661 | + || ( |
|
| 662 | + ! $ignore_route_check |
|
| 663 | + && ! isset($this->_cpt_routes[$this->_req_action]) |
|
| 664 | + ) || ( |
|
| 665 | + $this->_cpt_model_obj instanceof EE_CPT_Base |
|
| 666 | + && $this->_cpt_model_obj->ID() === $id |
|
| 667 | + ) |
|
| 668 | + ) { |
|
| 669 | + //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent. |
|
| 670 | + return; |
|
| 671 | + } |
|
| 672 | + //if ignore_route_check is true, then get the model name via EE_Register_CPTs |
|
| 673 | + if ($ignore_route_check) { |
|
| 674 | + $model_names = EE_Register_CPTs::get_cpt_model_names(); |
|
| 675 | + $post_type = get_post_type($id); |
|
| 676 | + if (isset($model_names[$post_type])) { |
|
| 677 | + $model = EE_Registry::instance()->load_model($model_names[$post_type]); |
|
| 678 | + } |
|
| 679 | + } else { |
|
| 680 | + $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]); |
|
| 681 | + } |
|
| 682 | + if ($model instanceof EEM_Base) { |
|
| 683 | + $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object(); |
|
| 684 | + } |
|
| 685 | + do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object'); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * admin_init_global |
|
| 692 | + * This runs all the code that we want executed within the WP admin_init hook. |
|
| 693 | + * This method executes for ALL EE Admin pages. |
|
| 694 | + * |
|
| 695 | + * @access public |
|
| 696 | + * @return void |
|
| 697 | + */ |
|
| 698 | + public function admin_init_global() |
|
| 699 | + { |
|
| 700 | + $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null; |
|
| 701 | + //its possible this is a new save so let's catch that instead |
|
| 702 | + $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post; |
|
| 703 | + $post_type = $post ? $post->post_type : false; |
|
| 704 | + $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] |
|
| 705 | + : 'shouldneverwork'; |
|
| 706 | + $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] |
|
| 707 | + : ''; |
|
| 708 | + add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3); |
|
| 709 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3); |
|
| 710 | + if ($post_type === $route_to_check) { |
|
| 711 | + add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2); |
|
| 712 | + } |
|
| 713 | + //now let's filter redirect if we're on a revision page and the revision is for an event CPT. |
|
| 714 | + $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null; |
|
| 715 | + if ( ! empty($revision)) { |
|
| 716 | + $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null; |
|
| 717 | + //doing a restore? |
|
| 718 | + if ( ! empty($action) && $action == 'restore') { |
|
| 719 | + //get post for revision |
|
| 720 | + $rev_post = get_post($revision); |
|
| 721 | + $rev_parent = get_post($rev_post->post_parent); |
|
| 722 | + //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts. |
|
| 723 | + if ($rev_parent && $rev_parent->post_type == $this->page_slug) { |
|
| 724 | + add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2); |
|
| 725 | + //restores of revisions |
|
| 726 | + add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2); |
|
| 727 | + } |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | + //NOTE we ONLY want to run these hooks if we're on the right class for the given post type. Otherwise we could see some really freaky things happen! |
|
| 731 | + if ($post_type && $post_type === $route_to_check) { |
|
| 732 | + //$post_id, $post |
|
| 733 | + add_action('save_post', array($this, 'insert_update'), 10, 3); |
|
| 734 | + //$post_id |
|
| 735 | + add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10); |
|
| 736 | + add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10); |
|
| 737 | + add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10); |
|
| 738 | + add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10); |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Callback for the WordPress trashed_post hook. |
|
| 746 | + * Execute some basic checks before calling the trash_cpt_item declared in the child class. |
|
| 747 | + * |
|
| 748 | + * @param int $post_id |
|
| 749 | + */ |
|
| 750 | + public function before_trash_cpt_item($post_id) |
|
| 751 | + { |
|
| 752 | + $this->_set_model_object($post_id, true); |
|
| 753 | + //if our cpt object isn't existent then get out immediately. |
|
| 754 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 755 | + return; |
|
| 756 | + } |
|
| 757 | + $this->trash_cpt_item($post_id); |
|
| 758 | + } |
|
| 759 | + |
|
| 760 | + |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * Callback for the WordPress untrashed_post hook. |
|
| 764 | + * Execute some basic checks before calling the restore_cpt_method in the child class. |
|
| 765 | + * |
|
| 766 | + * @param $post_id |
|
| 767 | + */ |
|
| 768 | + public function before_restore_cpt_item($post_id) |
|
| 769 | + { |
|
| 770 | + $this->_set_model_object($post_id, true); |
|
| 771 | + //if our cpt object isn't existent then get out immediately. |
|
| 772 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 773 | + return; |
|
| 774 | + } |
|
| 775 | + $this->restore_cpt_item($post_id); |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + |
|
| 779 | + |
|
| 780 | + /** |
|
| 781 | + * Callback for the WordPress after_delete_post hook. |
|
| 782 | + * Execute some basic checks before calling the delete_cpt_item method in the child class. |
|
| 783 | + * |
|
| 784 | + * @param $post_id |
|
| 785 | + */ |
|
| 786 | + public function before_delete_cpt_item($post_id) |
|
| 787 | + { |
|
| 788 | + $this->_set_model_object($post_id, true); |
|
| 789 | + //if our cpt object isn't existent then get out immediately. |
|
| 790 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) { |
|
| 791 | + return; |
|
| 792 | + } |
|
| 793 | + $this->delete_cpt_item($post_id); |
|
| 794 | + } |
|
| 795 | + |
|
| 796 | + |
|
| 797 | + |
|
| 798 | + /** |
|
| 799 | + * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message |
|
| 800 | + * accordingly. |
|
| 801 | + * |
|
| 802 | + * @access public |
|
| 803 | + * @throws EE_Error |
|
| 804 | + * @return void |
|
| 805 | + */ |
|
| 806 | + public function verify_cpt_object() |
|
| 807 | + { |
|
| 808 | + $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label; |
|
| 809 | + // verify event object |
|
| 810 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 811 | + throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s. This usually happens when the given id for the page route is NOT for the correct custom post type for this page', |
|
| 812 | + 'event_espresso'), $label)); |
|
| 813 | + } |
|
| 814 | + //if auto-draft then throw an error |
|
| 815 | + if ($this->_cpt_model_obj->get('status') == 'auto-draft') { |
|
| 816 | + EE_Error::overwrite_errors(); |
|
| 817 | + EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly. All autodrafts will show up in the "draft" view of your event list table. You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'), |
|
| 818 | + $label), __FILE__, __FUNCTION__, __LINE__); |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * admin_footer_scripts_global |
|
| 826 | + * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method |
|
| 827 | + * will apply on ALL EE_Admin pages. |
|
| 828 | + * |
|
| 829 | + * @access public |
|
| 830 | + * @return void |
|
| 831 | + */ |
|
| 832 | + public function admin_footer_scripts_global() |
|
| 833 | + { |
|
| 834 | + $this->_add_admin_page_ajax_loading_img(); |
|
| 835 | + $this->_add_admin_page_overlay(); |
|
| 836 | + } |
|
| 837 | + |
|
| 838 | + |
|
| 839 | + |
|
| 840 | + /** |
|
| 841 | + * add in any global scripts for cpt routes |
|
| 842 | + * |
|
| 843 | + * @return void |
|
| 844 | + */ |
|
| 845 | + public function load_global_scripts_styles() |
|
| 846 | + { |
|
| 847 | + parent::load_global_scripts_styles(); |
|
| 848 | + if ($this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 849 | + //setup custom post status object for localize script but only if we've got a cpt object |
|
| 850 | + $statuses = $this->_cpt_model_obj->get_custom_post_statuses(); |
|
| 851 | + if ( ! empty($statuses)) { |
|
| 852 | + //get ALL statuses! |
|
| 853 | + $statuses = $this->_cpt_model_obj->get_all_post_statuses(); |
|
| 854 | + //setup object |
|
| 855 | + $ee_cpt_statuses = array(); |
|
| 856 | + foreach ($statuses as $status => $label) { |
|
| 857 | + $ee_cpt_statuses[$status] = array( |
|
| 858 | + 'label' => $label, |
|
| 859 | + 'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label), |
|
| 860 | + ); |
|
| 861 | + } |
|
| 862 | + wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses); |
|
| 863 | + } |
|
| 864 | + } |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + |
|
| 868 | + |
|
| 869 | + /** |
|
| 870 | + * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL |
|
| 871 | + * insert/updates |
|
| 872 | + * |
|
| 873 | + * @param int $post_id ID of post being updated |
|
| 874 | + * @param WP_Post $post Post object from WP |
|
| 875 | + * @param bool $update Whether this is an update or a new save. |
|
| 876 | + * @return void |
|
| 877 | + */ |
|
| 878 | + public function insert_update($post_id, $post, $update) |
|
| 879 | + { |
|
| 880 | + //make sure that if this is a revision OR trash action that we don't do any updates! |
|
| 881 | + if ( |
|
| 882 | + isset($this->_req_data['action']) |
|
| 883 | + && ( |
|
| 884 | + $this->_req_data['action'] == 'restore' |
|
| 885 | + || $this->_req_data['action'] == 'trash' |
|
| 886 | + ) |
|
| 887 | + ) { |
|
| 888 | + return; |
|
| 889 | + } |
|
| 890 | + $this->_set_model_object($post_id, true); |
|
| 891 | + //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit. |
|
| 892 | + if ($update |
|
| 893 | + && ( |
|
| 894 | + ! $this->_cpt_model_obj instanceof EE_CPT_Base |
|
| 895 | + || $this->_cpt_model_obj->ID() !== $post_id |
|
| 896 | + ) |
|
| 897 | + ) { |
|
| 898 | + return; |
|
| 899 | + } |
|
| 900 | + //check for autosave and update our req_data property accordingly. |
|
| 901 | + /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) { |
|
| 902 | 902 | foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) { |
| 903 | 903 | |
| 904 | 904 | foreach ( (array) $values as $key => $value ) { |
@@ -908,524 +908,524 @@ discard block |
||
| 908 | 908 | |
| 909 | 909 | }/**/ //TODO reactivate after autosave is implemented in 4.2 |
| 910 | 910 | |
| 911 | - //take care of updating any selected page_template IF this cpt supports it. |
|
| 912 | - if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
| 913 | - //wp version aware. |
|
| 914 | - if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) { |
|
| 915 | - $page_templates = wp_get_theme()->get_page_templates(); |
|
| 916 | - } else { |
|
| 917 | - $post->page_template = $this->_req_data['page_template']; |
|
| 918 | - $page_templates = wp_get_theme()->get_page_templates($post); |
|
| 919 | - } |
|
| 920 | - if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
| 921 | - EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 922 | - } else { |
|
| 923 | - update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
| 924 | - } |
|
| 925 | - } |
|
| 926 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 927 | - return; |
|
| 928 | - } //TODO we'll remove this after reimplementing autosave in 4.2 |
|
| 929 | - $this->_insert_update_cpt_item($post_id, $post); |
|
| 930 | - } |
|
| 931 | - |
|
| 932 | - |
|
| 933 | - |
|
| 934 | - /** |
|
| 935 | - * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time` |
|
| 936 | - * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes |
|
| 937 | - * so we don't have to check for our CPT. |
|
| 938 | - * |
|
| 939 | - * @param int $post_id ID of the post |
|
| 940 | - * @return void |
|
| 941 | - */ |
|
| 942 | - public function dont_permanently_delete_ee_cpts($post_id) |
|
| 943 | - { |
|
| 944 | - //only do this if we're actually processing one of our CPTs |
|
| 945 | - //if our cpt object isn't existent then get out immediately. |
|
| 946 | - if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 947 | - return; |
|
| 948 | - } |
|
| 949 | - delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
| 950 | - delete_post_meta($post_id, '_wp_trash_meta_time'); |
|
| 951 | - //our cpts may have comments so let's take care of that too |
|
| 952 | - delete_post_meta($post_id, '_wp_trash_meta_comments_status'); |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is |
|
| 959 | - * triggered that we restore related items. In order to work cpt classes MUST have a restore_cpt_revision method |
|
| 960 | - * in them. We also have our OWN action in here so addons can hook into the restore process easily. |
|
| 961 | - * |
|
| 962 | - * @param int $post_id ID of cpt item |
|
| 963 | - * @param int $revision_id ID of revision being restored |
|
| 964 | - * @return void |
|
| 965 | - */ |
|
| 966 | - public function restore_revision($post_id, $revision_id) |
|
| 967 | - { |
|
| 968 | - $this->_restore_cpt_item($post_id, $revision_id); |
|
| 969 | - //global action |
|
| 970 | - do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
| 971 | - //class specific action so you can limit hooking into a specific page. |
|
| 972 | - do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id); |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - |
|
| 976 | - |
|
| 977 | - /** |
|
| 978 | - * @see restore_revision() for details |
|
| 979 | - * @param int $post_id ID of cpt item |
|
| 980 | - * @param int $revision_id ID of revision for item |
|
| 981 | - * @return void |
|
| 982 | - */ |
|
| 983 | - abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
| 984 | - |
|
| 985 | - |
|
| 986 | - |
|
| 987 | - /** |
|
| 988 | - * Execution of this method is added to the end of the load_page_dependencies method in the parent |
|
| 989 | - * so that we can fix a bug where default core metaboxes were not being called in the sidebar. |
|
| 990 | - * To fix we have to reset the current_screen using the page_slug |
|
| 991 | - * (which is identical - or should be - to our registered_post_type id.) |
|
| 992 | - * Also, since the core WP file loads the admin_header.php for WP |
|
| 993 | - * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early) |
|
| 994 | - * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set). |
|
| 995 | - * |
|
| 996 | - * @return void |
|
| 997 | - */ |
|
| 998 | - public function modify_current_screen() |
|
| 999 | - { |
|
| 1000 | - //ONLY do this if the current page_route IS a cpt route |
|
| 1001 | - if ( ! $this->_cpt_route) { |
|
| 1002 | - return; |
|
| 1003 | - } |
|
| 1004 | - //routing things REALLY early b/c this is a cpt admin page |
|
| 1005 | - set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
| 1006 | - $this->_current_screen = get_current_screen(); |
|
| 1007 | - $this->_current_screen->base = 'event-espresso'; |
|
| 1008 | - $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
|
| 1009 | - /*try { |
|
| 911 | + //take care of updating any selected page_template IF this cpt supports it. |
|
| 912 | + if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) { |
|
| 913 | + //wp version aware. |
|
| 914 | + if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) { |
|
| 915 | + $page_templates = wp_get_theme()->get_page_templates(); |
|
| 916 | + } else { |
|
| 917 | + $post->page_template = $this->_req_data['page_template']; |
|
| 918 | + $page_templates = wp_get_theme()->get_page_templates($post); |
|
| 919 | + } |
|
| 920 | + if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) { |
|
| 921 | + EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 922 | + } else { |
|
| 923 | + update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']); |
|
| 924 | + } |
|
| 925 | + } |
|
| 926 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 927 | + return; |
|
| 928 | + } //TODO we'll remove this after reimplementing autosave in 4.2 |
|
| 929 | + $this->_insert_update_cpt_item($post_id, $post); |
|
| 930 | + } |
|
| 931 | + |
|
| 932 | + |
|
| 933 | + |
|
| 934 | + /** |
|
| 935 | + * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time` |
|
| 936 | + * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes |
|
| 937 | + * so we don't have to check for our CPT. |
|
| 938 | + * |
|
| 939 | + * @param int $post_id ID of the post |
|
| 940 | + * @return void |
|
| 941 | + */ |
|
| 942 | + public function dont_permanently_delete_ee_cpts($post_id) |
|
| 943 | + { |
|
| 944 | + //only do this if we're actually processing one of our CPTs |
|
| 945 | + //if our cpt object isn't existent then get out immediately. |
|
| 946 | + if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) { |
|
| 947 | + return; |
|
| 948 | + } |
|
| 949 | + delete_post_meta($post_id, '_wp_trash_meta_status'); |
|
| 950 | + delete_post_meta($post_id, '_wp_trash_meta_time'); |
|
| 951 | + //our cpts may have comments so let's take care of that too |
|
| 952 | + delete_post_meta($post_id, '_wp_trash_meta_comments_status'); |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is |
|
| 959 | + * triggered that we restore related items. In order to work cpt classes MUST have a restore_cpt_revision method |
|
| 960 | + * in them. We also have our OWN action in here so addons can hook into the restore process easily. |
|
| 961 | + * |
|
| 962 | + * @param int $post_id ID of cpt item |
|
| 963 | + * @param int $revision_id ID of revision being restored |
|
| 964 | + * @return void |
|
| 965 | + */ |
|
| 966 | + public function restore_revision($post_id, $revision_id) |
|
| 967 | + { |
|
| 968 | + $this->_restore_cpt_item($post_id, $revision_id); |
|
| 969 | + //global action |
|
| 970 | + do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
|
| 971 | + //class specific action so you can limit hooking into a specific page. |
|
| 972 | + do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id); |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + |
|
| 976 | + |
|
| 977 | + /** |
|
| 978 | + * @see restore_revision() for details |
|
| 979 | + * @param int $post_id ID of cpt item |
|
| 980 | + * @param int $revision_id ID of revision for item |
|
| 981 | + * @return void |
|
| 982 | + */ |
|
| 983 | + abstract protected function _restore_cpt_item($post_id, $revision_id); |
|
| 984 | + |
|
| 985 | + |
|
| 986 | + |
|
| 987 | + /** |
|
| 988 | + * Execution of this method is added to the end of the load_page_dependencies method in the parent |
|
| 989 | + * so that we can fix a bug where default core metaboxes were not being called in the sidebar. |
|
| 990 | + * To fix we have to reset the current_screen using the page_slug |
|
| 991 | + * (which is identical - or should be - to our registered_post_type id.) |
|
| 992 | + * Also, since the core WP file loads the admin_header.php for WP |
|
| 993 | + * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early) |
|
| 994 | + * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set). |
|
| 995 | + * |
|
| 996 | + * @return void |
|
| 997 | + */ |
|
| 998 | + public function modify_current_screen() |
|
| 999 | + { |
|
| 1000 | + //ONLY do this if the current page_route IS a cpt route |
|
| 1001 | + if ( ! $this->_cpt_route) { |
|
| 1002 | + return; |
|
| 1003 | + } |
|
| 1004 | + //routing things REALLY early b/c this is a cpt admin page |
|
| 1005 | + set_current_screen($this->_cpt_routes[$this->_req_action]); |
|
| 1006 | + $this->_current_screen = get_current_screen(); |
|
| 1007 | + $this->_current_screen->base = 'event-espresso'; |
|
| 1008 | + $this->_add_help_tabs(); //we make sure we add any help tabs back in! |
|
| 1009 | + /*try { |
|
| 1010 | 1010 | $this->_route_admin_request(); |
| 1011 | 1011 | } catch ( EE_Error $e ) { |
| 1012 | 1012 | $e->get_error(); |
| 1013 | 1013 | }/**/ |
| 1014 | - } |
|
| 1015 | - |
|
| 1016 | - |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * This allows child classes to modify the default editor title that appears when people add a new or edit an |
|
| 1020 | - * existing CPT item. * This uses the _labels property set by the child class via _define_page_props. Just make |
|
| 1021 | - * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the |
|
| 1022 | - * default to be. |
|
| 1023 | - * |
|
| 1024 | - * @param string $title The new title (or existing if there is no editor_title defined) |
|
| 1025 | - * @return string |
|
| 1026 | - */ |
|
| 1027 | - public function add_custom_editor_default_title($title) |
|
| 1028 | - { |
|
| 1029 | - return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) |
|
| 1030 | - ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] |
|
| 1031 | - : $title; |
|
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - |
|
| 1035 | - |
|
| 1036 | - /** |
|
| 1037 | - * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated |
|
| 1038 | - * |
|
| 1039 | - * @param string $shortlink The already generated shortlink |
|
| 1040 | - * @param int $id Post ID for this item |
|
| 1041 | - * @param string $context The context for the link |
|
| 1042 | - * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
|
| 1043 | - * @return string |
|
| 1044 | - */ |
|
| 1045 | - public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) |
|
| 1046 | - { |
|
| 1047 | - if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
| 1048 | - $post = get_post($id); |
|
| 1049 | - if (isset($post->post_type) && $this->page_slug == $post->post_type) { |
|
| 1050 | - $shortlink = home_url('?p=' . $post->ID); |
|
| 1051 | - } |
|
| 1052 | - } |
|
| 1053 | - return $shortlink; |
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - |
|
| 1057 | - |
|
| 1058 | - /** |
|
| 1059 | - * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's |
|
| 1060 | - * already run in modify_current_screen()) |
|
| 1061 | - * |
|
| 1062 | - * @return void |
|
| 1063 | - */ |
|
| 1064 | - public function route_admin_request() |
|
| 1065 | - { |
|
| 1066 | - if ($this->_cpt_route) { |
|
| 1067 | - return; |
|
| 1068 | - } |
|
| 1069 | - try { |
|
| 1070 | - $this->_route_admin_request(); |
|
| 1071 | - } catch (EE_Error $e) { |
|
| 1072 | - $e->get_error(); |
|
| 1073 | - } |
|
| 1074 | - } |
|
| 1075 | - |
|
| 1076 | - |
|
| 1077 | - |
|
| 1078 | - /** |
|
| 1079 | - * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves |
|
| 1080 | - * |
|
| 1081 | - * @return string html |
|
| 1082 | - */ |
|
| 1083 | - public function cpt_post_form_hidden_input() |
|
| 1084 | - { |
|
| 1085 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
| 1086 | - //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
|
| 1087 | - echo '<div id="ee-cpt-hidden-inputs">'; |
|
| 1088 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
| 1089 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
| 1090 | - echo '</div>'; |
|
| 1091 | - } |
|
| 1092 | - |
|
| 1093 | - |
|
| 1094 | - |
|
| 1095 | - /** |
|
| 1096 | - * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes. |
|
| 1097 | - * |
|
| 1098 | - * @param string $location Original location url |
|
| 1099 | - * @param int $status Status for http header |
|
| 1100 | - * @return string new (or original) url to redirect to. |
|
| 1101 | - */ |
|
| 1102 | - public function revision_redirect($location, $status) |
|
| 1103 | - { |
|
| 1104 | - //get revision |
|
| 1105 | - $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null; |
|
| 1106 | - //can't do anything without revision so let's get out if not present |
|
| 1107 | - if (empty($rev_id)) { |
|
| 1108 | - return $location; |
|
| 1109 | - } |
|
| 1110 | - //get rev_post_data |
|
| 1111 | - $rev = get_post($rev_id); |
|
| 1112 | - $admin_url = $this->_admin_base_url; |
|
| 1113 | - $query_args = array( |
|
| 1114 | - 'action' => 'edit', |
|
| 1115 | - 'post' => $rev->post_parent, |
|
| 1116 | - 'revision' => $rev_id, |
|
| 1117 | - 'message' => 5, |
|
| 1118 | - ); |
|
| 1119 | - $this->_process_notices($query_args, true); |
|
| 1120 | - return self::add_query_args_and_nonce($query_args, $admin_url); |
|
| 1121 | - } |
|
| 1122 | - |
|
| 1123 | - |
|
| 1124 | - |
|
| 1125 | - /** |
|
| 1126 | - * Modify the edit post link generated by wp core function so that EE CPTs get setup differently. |
|
| 1127 | - * |
|
| 1128 | - * @param string $link the original generated link |
|
| 1129 | - * @param int $id post id |
|
| 1130 | - * @param string $context optional, defaults to display. How to write the '&' |
|
| 1131 | - * @return string the link |
|
| 1132 | - */ |
|
| 1133 | - public function modify_edit_post_link($link, $id, $context) |
|
| 1134 | - { |
|
| 1135 | - $post = get_post($id); |
|
| 1136 | - if ( ! isset($this->_req_data['action']) |
|
| 1137 | - || ! isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1138 | - || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] |
|
| 1139 | - ) { |
|
| 1140 | - return $link; |
|
| 1141 | - } |
|
| 1142 | - $query_args = array( |
|
| 1143 | - 'action' => isset($this->_cpt_edit_routes[$post->post_type]) |
|
| 1144 | - ? $this->_cpt_edit_routes[$post->post_type] |
|
| 1145 | - : 'edit', |
|
| 1146 | - 'post' => $id, |
|
| 1147 | - ); |
|
| 1148 | - return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
| 1149 | - } |
|
| 1150 | - |
|
| 1151 | - |
|
| 1152 | - /** |
|
| 1153 | - * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on |
|
| 1154 | - * our routes. |
|
| 1155 | - * |
|
| 1156 | - * @param string $delete_link original delete link |
|
| 1157 | - * @param int $post_id id of cpt object |
|
| 1158 | - * @param bool $force_delete whether this is forcing a hard delete instead of trash |
|
| 1159 | - * @return string new delete link |
|
| 1160 | - * @throws EE_Error |
|
| 1161 | - */ |
|
| 1162 | - public function modify_delete_post_link($delete_link, $post_id, $force_delete) |
|
| 1163 | - { |
|
| 1164 | - $post = get_post($post_id); |
|
| 1165 | - if (! isset($this->_req_data['action'], $this->_req_data['post']) |
|
| 1166 | - || (isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1167 | - && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
| 1168 | - ) { |
|
| 1169 | - return $delete_link; |
|
| 1170 | - } |
|
| 1171 | - $this->_set_model_object($this->_req_data['post'], true); |
|
| 1172 | - //returns something like `trash_event` or `trash_attendee` or `trash_venue` |
|
| 1173 | - $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj))); |
|
| 1174 | - |
|
| 1175 | - return EE_Admin_Page::add_query_args_and_nonce( |
|
| 1176 | - array( |
|
| 1177 | - 'page' => $this->_req_data['page'], |
|
| 1178 | - 'action' => $action, |
|
| 1179 | - $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name() |
|
| 1180 | - => $this->_req_data['post'] |
|
| 1181 | - ), |
|
| 1182 | - admin_url() |
|
| 1183 | - ); |
|
| 1184 | - } |
|
| 1185 | - |
|
| 1186 | - |
|
| 1187 | - |
|
| 1188 | - /** |
|
| 1189 | - * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php |
|
| 1190 | - * so that we can hijack the default redirect locations for wp custom post types |
|
| 1191 | - * that WE'RE using and send back to OUR routes. This should only be hooked in on the right route. |
|
| 1192 | - * |
|
| 1193 | - * @param string $location This is the incoming currently set redirect location |
|
| 1194 | - * @param string $post_id This is the 'ID' value of the wp_posts table |
|
| 1195 | - * @return string the new location to redirect to |
|
| 1196 | - */ |
|
| 1197 | - public function cpt_post_location_redirect($location, $post_id) |
|
| 1198 | - { |
|
| 1199 | - //we DO have a match so let's setup the url |
|
| 1200 | - //we have to get the post to determine our route |
|
| 1201 | - $post = get_post($post_id); |
|
| 1202 | - $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
|
| 1203 | - //shared query_args |
|
| 1204 | - $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
| 1205 | - $admin_url = $this->_admin_base_url; |
|
| 1206 | - if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
| 1207 | - $status = get_post_status($post_id); |
|
| 1208 | - if (isset($this->_req_data['publish'])) { |
|
| 1209 | - switch ($status) { |
|
| 1210 | - case 'pending': |
|
| 1211 | - $message = 8; |
|
| 1212 | - break; |
|
| 1213 | - case 'future': |
|
| 1214 | - $message = 9; |
|
| 1215 | - break; |
|
| 1216 | - default: |
|
| 1217 | - $message = 6; |
|
| 1218 | - } |
|
| 1219 | - } else { |
|
| 1220 | - $message = 'draft' == $status ? 10 : 1; |
|
| 1221 | - } |
|
| 1222 | - } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
| 1223 | - $message = 2; |
|
| 1224 | - // $append = '#postcustom'; |
|
| 1225 | - } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
| 1226 | - $message = 3; |
|
| 1227 | - // $append = '#postcustom'; |
|
| 1228 | - } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
| 1229 | - $message = 7; |
|
| 1230 | - } else { |
|
| 1231 | - $message = 4; |
|
| 1232 | - } |
|
| 1233 | - //change the message if the post type is not viewable on the frontend |
|
| 1234 | - $this->_cpt_object = get_post_type_object($post->post_type); |
|
| 1235 | - $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
| 1236 | - $query_args = array_merge(array('message' => $message), $query_args); |
|
| 1237 | - $this->_process_notices($query_args, true); |
|
| 1238 | - return self::add_query_args_and_nonce($query_args, $admin_url); |
|
| 1239 | - } |
|
| 1240 | - |
|
| 1241 | - |
|
| 1242 | - |
|
| 1243 | - /** |
|
| 1244 | - * This method is called to inject nav tabs on core WP cpt pages |
|
| 1245 | - * |
|
| 1246 | - * @access public |
|
| 1247 | - * @return string html |
|
| 1248 | - */ |
|
| 1249 | - public function inject_nav_tabs() |
|
| 1250 | - { |
|
| 1251 | - //can we hijack and insert the nav_tabs? |
|
| 1252 | - $nav_tabs = $this->_get_main_nav_tabs(); |
|
| 1253 | - //first close off existing form tag |
|
| 1254 | - $html = '>'; |
|
| 1255 | - $html .= $nav_tabs; |
|
| 1256 | - //now let's handle the remaining tag ( missing ">" is CORRECT ) |
|
| 1257 | - $html .= '<span></span'; |
|
| 1258 | - echo $html; |
|
| 1259 | - } |
|
| 1260 | - |
|
| 1261 | - |
|
| 1262 | - |
|
| 1263 | - /** |
|
| 1264 | - * This just sets up the post update messages when an update form is loaded |
|
| 1265 | - * |
|
| 1266 | - * @access public |
|
| 1267 | - * @param array $messages the original messages array |
|
| 1268 | - * @return array the new messages array |
|
| 1269 | - */ |
|
| 1270 | - public function post_update_messages($messages) |
|
| 1271 | - { |
|
| 1272 | - global $post; |
|
| 1273 | - $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 1274 | - $id = empty($id) && is_object($post) ? $post->ID : null; |
|
| 1275 | - // $post_type = $post ? $post->post_type : false; |
|
| 1276 | - /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + |
|
| 1017 | + |
|
| 1018 | + /** |
|
| 1019 | + * This allows child classes to modify the default editor title that appears when people add a new or edit an |
|
| 1020 | + * existing CPT item. * This uses the _labels property set by the child class via _define_page_props. Just make |
|
| 1021 | + * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the |
|
| 1022 | + * default to be. |
|
| 1023 | + * |
|
| 1024 | + * @param string $title The new title (or existing if there is no editor_title defined) |
|
| 1025 | + * @return string |
|
| 1026 | + */ |
|
| 1027 | + public function add_custom_editor_default_title($title) |
|
| 1028 | + { |
|
| 1029 | + return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]) |
|
| 1030 | + ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]] |
|
| 1031 | + : $title; |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + |
|
| 1035 | + |
|
| 1036 | + /** |
|
| 1037 | + * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated |
|
| 1038 | + * |
|
| 1039 | + * @param string $shortlink The already generated shortlink |
|
| 1040 | + * @param int $id Post ID for this item |
|
| 1041 | + * @param string $context The context for the link |
|
| 1042 | + * @param bool $allow_slugs Whether to allow post slugs in the shortlink. |
|
| 1043 | + * @return string |
|
| 1044 | + */ |
|
| 1045 | + public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs) |
|
| 1046 | + { |
|
| 1047 | + if ( ! empty($id) && '' != get_option('permalink_structure')) { |
|
| 1048 | + $post = get_post($id); |
|
| 1049 | + if (isset($post->post_type) && $this->page_slug == $post->post_type) { |
|
| 1050 | + $shortlink = home_url('?p=' . $post->ID); |
|
| 1051 | + } |
|
| 1052 | + } |
|
| 1053 | + return $shortlink; |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + |
|
| 1057 | + |
|
| 1058 | + /** |
|
| 1059 | + * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's |
|
| 1060 | + * already run in modify_current_screen()) |
|
| 1061 | + * |
|
| 1062 | + * @return void |
|
| 1063 | + */ |
|
| 1064 | + public function route_admin_request() |
|
| 1065 | + { |
|
| 1066 | + if ($this->_cpt_route) { |
|
| 1067 | + return; |
|
| 1068 | + } |
|
| 1069 | + try { |
|
| 1070 | + $this->_route_admin_request(); |
|
| 1071 | + } catch (EE_Error $e) { |
|
| 1072 | + $e->get_error(); |
|
| 1073 | + } |
|
| 1074 | + } |
|
| 1075 | + |
|
| 1076 | + |
|
| 1077 | + |
|
| 1078 | + /** |
|
| 1079 | + * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves |
|
| 1080 | + * |
|
| 1081 | + * @return string html |
|
| 1082 | + */ |
|
| 1083 | + public function cpt_post_form_hidden_input() |
|
| 1084 | + { |
|
| 1085 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
| 1086 | + //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
|
| 1087 | + echo '<div id="ee-cpt-hidden-inputs">'; |
|
| 1088 | + echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
| 1089 | + echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
| 1090 | + echo '</div>'; |
|
| 1091 | + } |
|
| 1092 | + |
|
| 1093 | + |
|
| 1094 | + |
|
| 1095 | + /** |
|
| 1096 | + * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes. |
|
| 1097 | + * |
|
| 1098 | + * @param string $location Original location url |
|
| 1099 | + * @param int $status Status for http header |
|
| 1100 | + * @return string new (or original) url to redirect to. |
|
| 1101 | + */ |
|
| 1102 | + public function revision_redirect($location, $status) |
|
| 1103 | + { |
|
| 1104 | + //get revision |
|
| 1105 | + $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null; |
|
| 1106 | + //can't do anything without revision so let's get out if not present |
|
| 1107 | + if (empty($rev_id)) { |
|
| 1108 | + return $location; |
|
| 1109 | + } |
|
| 1110 | + //get rev_post_data |
|
| 1111 | + $rev = get_post($rev_id); |
|
| 1112 | + $admin_url = $this->_admin_base_url; |
|
| 1113 | + $query_args = array( |
|
| 1114 | + 'action' => 'edit', |
|
| 1115 | + 'post' => $rev->post_parent, |
|
| 1116 | + 'revision' => $rev_id, |
|
| 1117 | + 'message' => 5, |
|
| 1118 | + ); |
|
| 1119 | + $this->_process_notices($query_args, true); |
|
| 1120 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
| 1121 | + } |
|
| 1122 | + |
|
| 1123 | + |
|
| 1124 | + |
|
| 1125 | + /** |
|
| 1126 | + * Modify the edit post link generated by wp core function so that EE CPTs get setup differently. |
|
| 1127 | + * |
|
| 1128 | + * @param string $link the original generated link |
|
| 1129 | + * @param int $id post id |
|
| 1130 | + * @param string $context optional, defaults to display. How to write the '&' |
|
| 1131 | + * @return string the link |
|
| 1132 | + */ |
|
| 1133 | + public function modify_edit_post_link($link, $id, $context) |
|
| 1134 | + { |
|
| 1135 | + $post = get_post($id); |
|
| 1136 | + if ( ! isset($this->_req_data['action']) |
|
| 1137 | + || ! isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1138 | + || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']] |
|
| 1139 | + ) { |
|
| 1140 | + return $link; |
|
| 1141 | + } |
|
| 1142 | + $query_args = array( |
|
| 1143 | + 'action' => isset($this->_cpt_edit_routes[$post->post_type]) |
|
| 1144 | + ? $this->_cpt_edit_routes[$post->post_type] |
|
| 1145 | + : 'edit', |
|
| 1146 | + 'post' => $id, |
|
| 1147 | + ); |
|
| 1148 | + return self::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
| 1149 | + } |
|
| 1150 | + |
|
| 1151 | + |
|
| 1152 | + /** |
|
| 1153 | + * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on |
|
| 1154 | + * our routes. |
|
| 1155 | + * |
|
| 1156 | + * @param string $delete_link original delete link |
|
| 1157 | + * @param int $post_id id of cpt object |
|
| 1158 | + * @param bool $force_delete whether this is forcing a hard delete instead of trash |
|
| 1159 | + * @return string new delete link |
|
| 1160 | + * @throws EE_Error |
|
| 1161 | + */ |
|
| 1162 | + public function modify_delete_post_link($delete_link, $post_id, $force_delete) |
|
| 1163 | + { |
|
| 1164 | + $post = get_post($post_id); |
|
| 1165 | + if (! isset($this->_req_data['action'], $this->_req_data['post']) |
|
| 1166 | + || (isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1167 | + && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
|
| 1168 | + ) { |
|
| 1169 | + return $delete_link; |
|
| 1170 | + } |
|
| 1171 | + $this->_set_model_object($this->_req_data['post'], true); |
|
| 1172 | + //returns something like `trash_event` or `trash_attendee` or `trash_venue` |
|
| 1173 | + $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj))); |
|
| 1174 | + |
|
| 1175 | + return EE_Admin_Page::add_query_args_and_nonce( |
|
| 1176 | + array( |
|
| 1177 | + 'page' => $this->_req_data['page'], |
|
| 1178 | + 'action' => $action, |
|
| 1179 | + $this->_cpt_model_obj->get_model()->get_primary_key_field()->get_name() |
|
| 1180 | + => $this->_req_data['post'] |
|
| 1181 | + ), |
|
| 1182 | + admin_url() |
|
| 1183 | + ); |
|
| 1184 | + } |
|
| 1185 | + |
|
| 1186 | + |
|
| 1187 | + |
|
| 1188 | + /** |
|
| 1189 | + * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php |
|
| 1190 | + * so that we can hijack the default redirect locations for wp custom post types |
|
| 1191 | + * that WE'RE using and send back to OUR routes. This should only be hooked in on the right route. |
|
| 1192 | + * |
|
| 1193 | + * @param string $location This is the incoming currently set redirect location |
|
| 1194 | + * @param string $post_id This is the 'ID' value of the wp_posts table |
|
| 1195 | + * @return string the new location to redirect to |
|
| 1196 | + */ |
|
| 1197 | + public function cpt_post_location_redirect($location, $post_id) |
|
| 1198 | + { |
|
| 1199 | + //we DO have a match so let's setup the url |
|
| 1200 | + //we have to get the post to determine our route |
|
| 1201 | + $post = get_post($post_id); |
|
| 1202 | + $edit_route = $this->_cpt_edit_routes[$post->post_type]; |
|
| 1203 | + //shared query_args |
|
| 1204 | + $query_args = array('action' => $edit_route, 'post' => $post_id); |
|
| 1205 | + $admin_url = $this->_admin_base_url; |
|
| 1206 | + if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) { |
|
| 1207 | + $status = get_post_status($post_id); |
|
| 1208 | + if (isset($this->_req_data['publish'])) { |
|
| 1209 | + switch ($status) { |
|
| 1210 | + case 'pending': |
|
| 1211 | + $message = 8; |
|
| 1212 | + break; |
|
| 1213 | + case 'future': |
|
| 1214 | + $message = 9; |
|
| 1215 | + break; |
|
| 1216 | + default: |
|
| 1217 | + $message = 6; |
|
| 1218 | + } |
|
| 1219 | + } else { |
|
| 1220 | + $message = 'draft' == $status ? 10 : 1; |
|
| 1221 | + } |
|
| 1222 | + } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) { |
|
| 1223 | + $message = 2; |
|
| 1224 | + // $append = '#postcustom'; |
|
| 1225 | + } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) { |
|
| 1226 | + $message = 3; |
|
| 1227 | + // $append = '#postcustom'; |
|
| 1228 | + } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') { |
|
| 1229 | + $message = 7; |
|
| 1230 | + } else { |
|
| 1231 | + $message = 4; |
|
| 1232 | + } |
|
| 1233 | + //change the message if the post type is not viewable on the frontend |
|
| 1234 | + $this->_cpt_object = get_post_type_object($post->post_type); |
|
| 1235 | + $message = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message; |
|
| 1236 | + $query_args = array_merge(array('message' => $message), $query_args); |
|
| 1237 | + $this->_process_notices($query_args, true); |
|
| 1238 | + return self::add_query_args_and_nonce($query_args, $admin_url); |
|
| 1239 | + } |
|
| 1240 | + |
|
| 1241 | + |
|
| 1242 | + |
|
| 1243 | + /** |
|
| 1244 | + * This method is called to inject nav tabs on core WP cpt pages |
|
| 1245 | + * |
|
| 1246 | + * @access public |
|
| 1247 | + * @return string html |
|
| 1248 | + */ |
|
| 1249 | + public function inject_nav_tabs() |
|
| 1250 | + { |
|
| 1251 | + //can we hijack and insert the nav_tabs? |
|
| 1252 | + $nav_tabs = $this->_get_main_nav_tabs(); |
|
| 1253 | + //first close off existing form tag |
|
| 1254 | + $html = '>'; |
|
| 1255 | + $html .= $nav_tabs; |
|
| 1256 | + //now let's handle the remaining tag ( missing ">" is CORRECT ) |
|
| 1257 | + $html .= '<span></span'; |
|
| 1258 | + echo $html; |
|
| 1259 | + } |
|
| 1260 | + |
|
| 1261 | + |
|
| 1262 | + |
|
| 1263 | + /** |
|
| 1264 | + * This just sets up the post update messages when an update form is loaded |
|
| 1265 | + * |
|
| 1266 | + * @access public |
|
| 1267 | + * @param array $messages the original messages array |
|
| 1268 | + * @return array the new messages array |
|
| 1269 | + */ |
|
| 1270 | + public function post_update_messages($messages) |
|
| 1271 | + { |
|
| 1272 | + global $post; |
|
| 1273 | + $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 1274 | + $id = empty($id) && is_object($post) ? $post->ID : null; |
|
| 1275 | + // $post_type = $post ? $post->post_type : false; |
|
| 1276 | + /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork'; |
|
| 1277 | 1277 | |
| 1278 | 1278 | $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/ |
| 1279 | - $messages[$post->post_type] = array( |
|
| 1280 | - 0 => '', //Unused. Messages start at index 1. |
|
| 1281 | - 1 => sprintf( |
|
| 1282 | - __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
| 1283 | - $this->_cpt_object->labels->singular_name, |
|
| 1284 | - '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1285 | - '</a>' |
|
| 1286 | - ), |
|
| 1287 | - 2 => __('Custom field updated'), |
|
| 1288 | - 3 => __('Custom field deleted.'), |
|
| 1289 | - 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 1290 | - 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), |
|
| 1291 | - $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) |
|
| 1292 | - : false, |
|
| 1293 | - 6 => sprintf( |
|
| 1294 | - __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
| 1295 | - $this->_cpt_object->labels->singular_name, |
|
| 1296 | - '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1297 | - '</a>' |
|
| 1298 | - ), |
|
| 1299 | - 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 1300 | - 8 => sprintf( |
|
| 1301 | - __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
|
| 1302 | - $this->_cpt_object->labels->singular_name, |
|
| 1303 | - '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">', |
|
| 1304 | - '</a>' |
|
| 1305 | - ), |
|
| 1306 | - 9 => sprintf( |
|
| 1307 | - __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
| 1308 | - $this->_cpt_object->labels->singular_name, |
|
| 1309 | - '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>', |
|
| 1310 | - '<a target="_blank" href="' . esc_url(get_permalink($id)), |
|
| 1311 | - '</a>' |
|
| 1312 | - ), |
|
| 1313 | - 10 => sprintf( |
|
| 1314 | - __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
|
| 1315 | - $this->_cpt_object->labels->singular_name, |
|
| 1316 | - '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
| 1317 | - '</a>' |
|
| 1318 | - ), |
|
| 1319 | - ); |
|
| 1320 | - return $messages; |
|
| 1321 | - } |
|
| 1322 | - |
|
| 1323 | - |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * default method for the 'create_new' route for cpt admin pages. |
|
| 1327 | - * For reference what to include in here, see wp-admin/post-new.php |
|
| 1328 | - * |
|
| 1329 | - * @access protected |
|
| 1330 | - * @return string template for add new cpt form |
|
| 1331 | - */ |
|
| 1332 | - protected function _create_new_cpt_item() |
|
| 1333 | - { |
|
| 1334 | - global $post, $title, $is_IE, $post_type, $post_type_object; |
|
| 1335 | - $post_type = $this->_cpt_routes[$this->_req_action]; |
|
| 1336 | - $post_type_object = $this->_cpt_object; |
|
| 1337 | - $title = $post_type_object->labels->add_new_item; |
|
| 1338 | - $editing = true; |
|
| 1339 | - wp_enqueue_script('autosave'); |
|
| 1340 | - $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true); |
|
| 1341 | - $post_ID = $post->ID; |
|
| 1342 | - $is_IE = $is_IE; |
|
| 1343 | - add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
| 1344 | - //modify the default editor title field with default title. |
|
| 1345 | - add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
| 1346 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1347 | - } |
|
| 1348 | - |
|
| 1349 | - |
|
| 1350 | - |
|
| 1351 | - public function add_new_admin_page_global() |
|
| 1352 | - { |
|
| 1353 | - $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
| 1354 | - ?> |
|
| 1279 | + $messages[$post->post_type] = array( |
|
| 1280 | + 0 => '', //Unused. Messages start at index 1. |
|
| 1281 | + 1 => sprintf( |
|
| 1282 | + __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
|
| 1283 | + $this->_cpt_object->labels->singular_name, |
|
| 1284 | + '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1285 | + '</a>' |
|
| 1286 | + ), |
|
| 1287 | + 2 => __('Custom field updated'), |
|
| 1288 | + 3 => __('Custom field deleted.'), |
|
| 1289 | + 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 1290 | + 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), |
|
| 1291 | + $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) |
|
| 1292 | + : false, |
|
| 1293 | + 6 => sprintf( |
|
| 1294 | + __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
|
| 1295 | + $this->_cpt_object->labels->singular_name, |
|
| 1296 | + '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1297 | + '</a>' |
|
| 1298 | + ), |
|
| 1299 | + 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
|
| 1300 | + 8 => sprintf( |
|
| 1301 | + __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
|
| 1302 | + $this->_cpt_object->labels->singular_name, |
|
| 1303 | + '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">', |
|
| 1304 | + '</a>' |
|
| 1305 | + ), |
|
| 1306 | + 9 => sprintf( |
|
| 1307 | + __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
|
| 1308 | + $this->_cpt_object->labels->singular_name, |
|
| 1309 | + '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>', |
|
| 1310 | + '<a target="_blank" href="' . esc_url(get_permalink($id)), |
|
| 1311 | + '</a>' |
|
| 1312 | + ), |
|
| 1313 | + 10 => sprintf( |
|
| 1314 | + __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
|
| 1315 | + $this->_cpt_object->labels->singular_name, |
|
| 1316 | + '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
| 1317 | + '</a>' |
|
| 1318 | + ), |
|
| 1319 | + ); |
|
| 1320 | + return $messages; |
|
| 1321 | + } |
|
| 1322 | + |
|
| 1323 | + |
|
| 1324 | + |
|
| 1325 | + /** |
|
| 1326 | + * default method for the 'create_new' route for cpt admin pages. |
|
| 1327 | + * For reference what to include in here, see wp-admin/post-new.php |
|
| 1328 | + * |
|
| 1329 | + * @access protected |
|
| 1330 | + * @return string template for add new cpt form |
|
| 1331 | + */ |
|
| 1332 | + protected function _create_new_cpt_item() |
|
| 1333 | + { |
|
| 1334 | + global $post, $title, $is_IE, $post_type, $post_type_object; |
|
| 1335 | + $post_type = $this->_cpt_routes[$this->_req_action]; |
|
| 1336 | + $post_type_object = $this->_cpt_object; |
|
| 1337 | + $title = $post_type_object->labels->add_new_item; |
|
| 1338 | + $editing = true; |
|
| 1339 | + wp_enqueue_script('autosave'); |
|
| 1340 | + $post = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true); |
|
| 1341 | + $post_ID = $post->ID; |
|
| 1342 | + $is_IE = $is_IE; |
|
| 1343 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
| 1344 | + //modify the default editor title field with default title. |
|
| 1345 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
| 1346 | + include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1347 | + } |
|
| 1348 | + |
|
| 1349 | + |
|
| 1350 | + |
|
| 1351 | + public function add_new_admin_page_global() |
|
| 1352 | + { |
|
| 1353 | + $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php'; |
|
| 1354 | + ?> |
|
| 1355 | 1355 | <script type="text/javascript"> |
| 1356 | 1356 | adminpage = '<?php echo $admin_page; ?>'; |
| 1357 | 1357 | </script> |
| 1358 | 1358 | <?php |
| 1359 | - } |
|
| 1360 | - |
|
| 1361 | - |
|
| 1362 | - |
|
| 1363 | - /** |
|
| 1364 | - * default method for the 'edit' route for cpt admin pages |
|
| 1365 | - * For reference on what to put in here, refer to wp-admin/post.php |
|
| 1366 | - * |
|
| 1367 | - * @access protected |
|
| 1368 | - * @return string template for edit cpt form |
|
| 1369 | - */ |
|
| 1370 | - protected function _edit_cpt_item() |
|
| 1371 | - { |
|
| 1372 | - global $post, $title, $is_IE, $post_type, $post_type_object; |
|
| 1373 | - $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 1374 | - $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null; |
|
| 1375 | - if (empty ($post)) { |
|
| 1376 | - wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
| 1377 | - } |
|
| 1378 | - if ( ! empty($_GET['get-post-lock'])) { |
|
| 1379 | - wp_set_post_lock($post_id); |
|
| 1380 | - wp_redirect(get_edit_post_link($post_id, 'url')); |
|
| 1381 | - exit(); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - // template vars |
|
| 1385 | - $editing = true; |
|
| 1386 | - $post_ID = $post_id; |
|
| 1387 | - $post_type = $this->_cpt_routes[$this->_req_action]; |
|
| 1388 | - $post_type_object = $this->_cpt_object; |
|
| 1389 | - |
|
| 1390 | - if ( ! wp_check_post_lock($post->ID)) { |
|
| 1391 | - $active_post_lock = wp_set_post_lock($post->ID); |
|
| 1392 | - //wp_enqueue_script('autosave'); |
|
| 1393 | - } |
|
| 1394 | - $title = $this->_cpt_object->labels->edit_item; |
|
| 1395 | - add_action('admin_footer', '_admin_notice_post_locked'); |
|
| 1396 | - if (isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1397 | - && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']]) |
|
| 1398 | - ) { |
|
| 1399 | - $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', |
|
| 1400 | - 'create_new', $this); |
|
| 1401 | - $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1402 | - 'action' => $create_new_action, |
|
| 1403 | - 'page' => $this->page_slug, |
|
| 1404 | - ), 'admin.php'); |
|
| 1405 | - } |
|
| 1406 | - if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
| 1407 | - wp_enqueue_script('admin-comments'); |
|
| 1408 | - enqueue_comment_hotkeys_js(); |
|
| 1409 | - } |
|
| 1410 | - add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
| 1411 | - //modify the default editor title field with default title. |
|
| 1412 | - add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
| 1413 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - |
|
| 1417 | - |
|
| 1418 | - /** |
|
| 1419 | - * some getters |
|
| 1420 | - */ |
|
| 1421 | - /** |
|
| 1422 | - * This returns the protected _cpt_model_obj property |
|
| 1423 | - * |
|
| 1424 | - * @return EE_CPT_Base |
|
| 1425 | - */ |
|
| 1426 | - public function get_cpt_model_obj() |
|
| 1427 | - { |
|
| 1428 | - return $this->_cpt_model_obj; |
|
| 1429 | - } |
|
| 1359 | + } |
|
| 1360 | + |
|
| 1361 | + |
|
| 1362 | + |
|
| 1363 | + /** |
|
| 1364 | + * default method for the 'edit' route for cpt admin pages |
|
| 1365 | + * For reference on what to put in here, refer to wp-admin/post.php |
|
| 1366 | + * |
|
| 1367 | + * @access protected |
|
| 1368 | + * @return string template for edit cpt form |
|
| 1369 | + */ |
|
| 1370 | + protected function _edit_cpt_item() |
|
| 1371 | + { |
|
| 1372 | + global $post, $title, $is_IE, $post_type, $post_type_object; |
|
| 1373 | + $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null; |
|
| 1374 | + $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null; |
|
| 1375 | + if (empty ($post)) { |
|
| 1376 | + wp_die(__('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?')); |
|
| 1377 | + } |
|
| 1378 | + if ( ! empty($_GET['get-post-lock'])) { |
|
| 1379 | + wp_set_post_lock($post_id); |
|
| 1380 | + wp_redirect(get_edit_post_link($post_id, 'url')); |
|
| 1381 | + exit(); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + // template vars |
|
| 1385 | + $editing = true; |
|
| 1386 | + $post_ID = $post_id; |
|
| 1387 | + $post_type = $this->_cpt_routes[$this->_req_action]; |
|
| 1388 | + $post_type_object = $this->_cpt_object; |
|
| 1389 | + |
|
| 1390 | + if ( ! wp_check_post_lock($post->ID)) { |
|
| 1391 | + $active_post_lock = wp_set_post_lock($post->ID); |
|
| 1392 | + //wp_enqueue_script('autosave'); |
|
| 1393 | + } |
|
| 1394 | + $title = $this->_cpt_object->labels->edit_item; |
|
| 1395 | + add_action('admin_footer', '_admin_notice_post_locked'); |
|
| 1396 | + if (isset($this->_cpt_routes[$this->_req_data['action']]) |
|
| 1397 | + && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']]) |
|
| 1398 | + ) { |
|
| 1399 | + $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action', |
|
| 1400 | + 'create_new', $this); |
|
| 1401 | + $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 1402 | + 'action' => $create_new_action, |
|
| 1403 | + 'page' => $this->page_slug, |
|
| 1404 | + ), 'admin.php'); |
|
| 1405 | + } |
|
| 1406 | + if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) { |
|
| 1407 | + wp_enqueue_script('admin-comments'); |
|
| 1408 | + enqueue_comment_hotkeys_js(); |
|
| 1409 | + } |
|
| 1410 | + add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
|
| 1411 | + //modify the default editor title field with default title. |
|
| 1412 | + add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
|
| 1413 | + include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + |
|
| 1417 | + |
|
| 1418 | + /** |
|
| 1419 | + * some getters |
|
| 1420 | + */ |
|
| 1421 | + /** |
|
| 1422 | + * This returns the protected _cpt_model_obj property |
|
| 1423 | + * |
|
| 1424 | + * @return EE_CPT_Base |
|
| 1425 | + */ |
|
| 1426 | + public function get_cpt_model_obj() |
|
| 1427 | + { |
|
| 1428 | + return $this->_cpt_model_obj; |
|
| 1429 | + } |
|
| 1430 | 1430 | |
| 1431 | 1431 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | protected function _register_autosave_containers($ids) |
| 237 | 237 | { |
| 238 | - $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids); |
|
| 238 | + $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | //filter _autosave_containers |
| 280 | 280 | $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers', |
| 281 | 281 | $this->_autosave_containers, $this); |
| 282 | - $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers', |
|
| 282 | + $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers', |
|
| 283 | 283 | $containers, $this); |
| 284 | 284 | |
| 285 | 285 | wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS', |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | parent::_load_page_dependencies(); |
| 370 | 370 | //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes. |
| 371 | 371 | global $pagenow; |
| 372 | - do_action('load-' . $pagenow); |
|
| 372 | + do_action('load-'.$pagenow); |
|
| 373 | 373 | $this->modify_current_screen(); |
| 374 | 374 | add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30); |
| 375 | 375 | //we route REALLY early. |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | 'admin.php?page=espresso_registrations&action=contact_list', |
| 401 | 401 | ), |
| 402 | 402 | 1 => array( |
| 403 | - 'edit.php?post_type=' . $this->_cpt_object->name, |
|
| 404 | - 'admin.php?page=' . $this->_cpt_object->name, |
|
| 403 | + 'edit.php?post_type='.$this->_cpt_object->name, |
|
| 404 | + 'admin.php?page='.$this->_cpt_object->name, |
|
| 405 | 405 | ), |
| 406 | 406 | ); |
| 407 | 407 | foreach ($routes_to_match as $route_matches) { |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $cpt_has_support = ! empty($cpt_args['page_templates']); |
| 430 | 430 | |
| 431 | 431 | //if the installed version of WP is > 4.7 we do some additional checks. |
| 432 | - if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 432 | + if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) { |
|
| 433 | 433 | $post_templates = wp_get_theme()->get_post_templates(); |
| 434 | 434 | //if there are $post_templates for this cpt, then we return false for this method because |
| 435 | 435 | //that means we aren't going to load our page template manager and leave that up to the native |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | global $post; |
| 453 | 453 | $template = ''; |
| 454 | 454 | |
| 455 | - if (EE_Recommended_Versions::check_wp_version('4.7','>=')) { |
|
| 455 | + if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) { |
|
| 456 | 456 | $page_template_count = count(get_page_templates()); |
| 457 | 457 | } else { |
| 458 | 458 | $page_template_count = count(get_page_templates($post)); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | $post = get_post($id); |
| 490 | 490 | if ('publish' != get_post_status($post)) { |
| 491 | 491 | //include shims for the `get_preview_post_link` function |
| 492 | - require_once( EE_CORE . 'wordpress-shims.php' ); |
|
| 492 | + require_once(EE_CORE.'wordpress-shims.php'); |
|
| 493 | 493 | $return .= '<span_id="view-post-btn"><a target="_blank" href="' |
| 494 | 494 | . get_preview_post_link($id) |
| 495 | 495 | . '" class="button button-small">' |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | $template_args['statuses'] = $statuses; |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | - $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php'; |
|
| 530 | + $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php'; |
|
| 531 | 531 | EEH_Template::display_template($template, $template_args); |
| 532 | 532 | } |
| 533 | 533 | |
@@ -572,13 +572,13 @@ discard block |
||
| 572 | 572 | define('DOING_AUTOSAVE', true); |
| 573 | 573 | } |
| 574 | 574 | //if we made it here then the nonce checked out. Let's run our methods and actions |
| 575 | - if (method_exists($this, '_ee_autosave_' . $this->_current_view)) { |
|
| 576 | - call_user_func(array($this, '_ee_autosave_' . $this->_current_view)); |
|
| 575 | + if (method_exists($this, '_ee_autosave_'.$this->_current_view)) { |
|
| 576 | + call_user_func(array($this, '_ee_autosave_'.$this->_current_view)); |
|
| 577 | 577 | } else { |
| 578 | 578 | $this->_template_args['success'] = true; |
| 579 | 579 | } |
| 580 | 580 | do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this); |
| 581 | - do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this); |
|
| 581 | + do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this); |
|
| 582 | 582 | //now let's return json |
| 583 | 583 | $this->_return_json(); |
| 584 | 584 | } |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | //global action |
| 970 | 970 | do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id); |
| 971 | 971 | //class specific action so you can limit hooking into a specific page. |
| 972 | - do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id); |
|
| 972 | + do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | if ( ! empty($id) && '' != get_option('permalink_structure')) { |
| 1048 | 1048 | $post = get_post($id); |
| 1049 | 1049 | if (isset($post->post_type) && $this->page_slug == $post->post_type) { |
| 1050 | - $shortlink = home_url('?p=' . $post->ID); |
|
| 1050 | + $shortlink = home_url('?p='.$post->ID); |
|
| 1051 | 1051 | } |
| 1052 | 1052 | } |
| 1053 | 1053 | return $shortlink; |
@@ -1082,11 +1082,11 @@ discard block |
||
| 1082 | 1082 | */ |
| 1083 | 1083 | public function cpt_post_form_hidden_input() |
| 1084 | 1084 | { |
| 1085 | - echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />'; |
|
| 1085 | + echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />'; |
|
| 1086 | 1086 | //we're also going to add the route value and the current page so we can direct autosave parsing correctly |
| 1087 | 1087 | echo '<div id="ee-cpt-hidden-inputs">'; |
| 1088 | - echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />'; |
|
| 1089 | - echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />'; |
|
| 1088 | + echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />'; |
|
| 1089 | + echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />'; |
|
| 1090 | 1090 | echo '</div>'; |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1162,7 +1162,7 @@ discard block |
||
| 1162 | 1162 | public function modify_delete_post_link($delete_link, $post_id, $force_delete) |
| 1163 | 1163 | { |
| 1164 | 1164 | $post = get_post($post_id); |
| 1165 | - if (! isset($this->_req_data['action'], $this->_req_data['post']) |
|
| 1165 | + if ( ! isset($this->_req_data['action'], $this->_req_data['post']) |
|
| 1166 | 1166 | || (isset($this->_cpt_routes[$this->_req_data['action']]) |
| 1167 | 1167 | && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]) |
| 1168 | 1168 | ) { |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | } |
| 1171 | 1171 | $this->_set_model_object($this->_req_data['post'], true); |
| 1172 | 1172 | //returns something like `trash_event` or `trash_attendee` or `trash_venue` |
| 1173 | - $action = 'trash_' . str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj))); |
|
| 1173 | + $action = 'trash_'.str_replace('ee_', '', strtolower(get_class($this->_cpt_model_obj))); |
|
| 1174 | 1174 | |
| 1175 | 1175 | return EE_Admin_Page::add_query_args_and_nonce( |
| 1176 | 1176 | array( |
@@ -1281,39 +1281,39 @@ discard block |
||
| 1281 | 1281 | 1 => sprintf( |
| 1282 | 1282 | __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'), |
| 1283 | 1283 | $this->_cpt_object->labels->singular_name, |
| 1284 | - '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1284 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
| 1285 | 1285 | '</a>' |
| 1286 | 1286 | ), |
| 1287 | 1287 | 2 => __('Custom field updated'), |
| 1288 | 1288 | 3 => __('Custom field deleted.'), |
| 1289 | 1289 | 4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
| 1290 | 1290 | 5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'), |
| 1291 | - $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false)) |
|
| 1291 | + $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false)) |
|
| 1292 | 1292 | : false, |
| 1293 | 1293 | 6 => sprintf( |
| 1294 | 1294 | __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'), |
| 1295 | 1295 | $this->_cpt_object->labels->singular_name, |
| 1296 | - '<a href="' . esc_url(get_permalink($id)) . '">', |
|
| 1296 | + '<a href="'.esc_url(get_permalink($id)).'">', |
|
| 1297 | 1297 | '</a>' |
| 1298 | 1298 | ), |
| 1299 | 1299 | 7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name), |
| 1300 | 1300 | 8 => sprintf( |
| 1301 | 1301 | __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'), |
| 1302 | 1302 | $this->_cpt_object->labels->singular_name, |
| 1303 | - '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">', |
|
| 1303 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">', |
|
| 1304 | 1304 | '</a>' |
| 1305 | 1305 | ), |
| 1306 | 1306 | 9 => sprintf( |
| 1307 | 1307 | __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'), |
| 1308 | 1308 | $this->_cpt_object->labels->singular_name, |
| 1309 | - '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>', |
|
| 1310 | - '<a target="_blank" href="' . esc_url(get_permalink($id)), |
|
| 1309 | + '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>', |
|
| 1310 | + '<a target="_blank" href="'.esc_url(get_permalink($id)), |
|
| 1311 | 1311 | '</a>' |
| 1312 | 1312 | ), |
| 1313 | 1313 | 10 => sprintf( |
| 1314 | 1314 | __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'), |
| 1315 | 1315 | $this->_cpt_object->labels->singular_name, |
| 1316 | - '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
| 1316 | + '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))), |
|
| 1317 | 1317 | '</a>' |
| 1318 | 1318 | ), |
| 1319 | 1319 | ); |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
| 1344 | 1344 | //modify the default editor title field with default title. |
| 1345 | 1345 | add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
| 1346 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1346 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | add_action('admin_print_styles', array($this, 'add_new_admin_page_global')); |
| 1411 | 1411 | //modify the default editor title field with default title. |
| 1412 | 1412 | add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10); |
| 1413 | - include_once WP_ADMIN_PATH . 'edit-form-advanced.php'; |
|
| 1413 | + include_once WP_ADMIN_PATH.'edit-form-advanced.php'; |
|
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | 1416 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if ( ! defined('ABSPATH')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
| 40 | 40 | * @since 4.0 |
| 41 | 41 | */ |
| 42 | 42 | if (function_exists('espresso_version')) { |
| 43 | - /** |
|
| 44 | - * espresso_duplicate_plugin_error |
|
| 45 | - * displays if more than one version of EE is activated at the same time |
|
| 46 | - */ |
|
| 47 | - function espresso_duplicate_plugin_error() |
|
| 48 | - { |
|
| 49 | - ?> |
|
| 43 | + /** |
|
| 44 | + * espresso_duplicate_plugin_error |
|
| 45 | + * displays if more than one version of EE is activated at the same time |
|
| 46 | + */ |
|
| 47 | + function espresso_duplicate_plugin_error() |
|
| 48 | + { |
|
| 49 | + ?> |
|
| 50 | 50 | <div class="error"> |
| 51 | 51 | <p> |
| 52 | 52 | <?php echo esc_html__( |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | } else { |
| 64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | - /** |
|
| 67 | - * espresso_minimum_php_version_error |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + /** |
|
| 67 | + * espresso_minimum_php_version_error |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - /** |
|
| 97 | - * espresso_version |
|
| 98 | - * Returns the plugin version |
|
| 99 | - * |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - function espresso_version() |
|
| 103 | - { |
|
| 104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.43.rc.009'); |
|
| 105 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + /** |
|
| 97 | + * espresso_version |
|
| 98 | + * Returns the plugin version |
|
| 99 | + * |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + function espresso_version() |
|
| 103 | + { |
|
| 104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.43.rc.009'); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - // define versions |
|
| 108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | - if ( ! defined('DS')) { |
|
| 115 | - define('DS', '/'); |
|
| 116 | - } |
|
| 117 | - if ( ! defined('PS')) { |
|
| 118 | - define('PS', PATH_SEPARATOR); |
|
| 119 | - } |
|
| 120 | - if ( ! defined('SP')) { |
|
| 121 | - define('SP', ' '); |
|
| 122 | - } |
|
| 123 | - if ( ! defined('EENL')) { |
|
| 124 | - define('EENL', "\n"); |
|
| 125 | - } |
|
| 126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | - // define the plugin directory and URL |
|
| 128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | - // main root folder paths |
|
| 132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | - // core system paths |
|
| 141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | - // gateways |
|
| 154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | - // asset URL paths |
|
| 157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | - // define upload paths |
|
| 164 | - $uploads = wp_upload_dir(); |
|
| 165 | - // define the uploads directory and URL |
|
| 166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | - // define the templates directory and URL |
|
| 169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | - // define the gateway directory and URL |
|
| 172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | - // languages folder/path |
|
| 175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | - //check for dompdf fonts in uploads |
|
| 178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | - } |
|
| 181 | - //ajax constants |
|
| 182 | - define( |
|
| 183 | - 'EE_FRONT_AJAX', |
|
| 184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | - ); |
|
| 186 | - define( |
|
| 187 | - 'EE_ADMIN_AJAX', |
|
| 188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | - ); |
|
| 190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | - //want to change its default value! or find when -1 means infinity |
|
| 193 | - define('EE_INF_IN_DB', -1); |
|
| 194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | - define('EE_DEBUG', false); |
|
| 196 | - // for older WP versions |
|
| 197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | - } |
|
| 200 | - /** |
|
| 201 | - * espresso_plugin_activation |
|
| 202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | - */ |
|
| 204 | - function espresso_plugin_activation() |
|
| 205 | - { |
|
| 206 | - update_option('ee_espresso_activation', true); |
|
| 207 | - } |
|
| 107 | + // define versions |
|
| 108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
| 114 | + if ( ! defined('DS')) { |
|
| 115 | + define('DS', '/'); |
|
| 116 | + } |
|
| 117 | + if ( ! defined('PS')) { |
|
| 118 | + define('PS', PATH_SEPARATOR); |
|
| 119 | + } |
|
| 120 | + if ( ! defined('SP')) { |
|
| 121 | + define('SP', ' '); |
|
| 122 | + } |
|
| 123 | + if ( ! defined('EENL')) { |
|
| 124 | + define('EENL', "\n"); |
|
| 125 | + } |
|
| 126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 127 | + // define the plugin directory and URL |
|
| 128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 131 | + // main root folder paths |
|
| 132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
| 133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
| 134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
| 135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
| 136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
| 137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
| 138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
| 139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
| 140 | + // core system paths |
|
| 141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
| 142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
| 143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
| 144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
| 145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
| 146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
| 147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
| 148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
| 149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
| 150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
| 151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
| 152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
| 153 | + // gateways |
|
| 154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
| 155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
| 156 | + // asset URL paths |
|
| 157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
| 158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
| 159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
| 160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
| 161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
| 162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
| 163 | + // define upload paths |
|
| 164 | + $uploads = wp_upload_dir(); |
|
| 165 | + // define the uploads directory and URL |
|
| 166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
| 167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
| 168 | + // define the templates directory and URL |
|
| 169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
| 171 | + // define the gateway directory and URL |
|
| 172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
| 174 | + // languages folder/path |
|
| 175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
| 176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
| 177 | + //check for dompdf fonts in uploads |
|
| 178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
| 179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
| 180 | + } |
|
| 181 | + //ajax constants |
|
| 182 | + define( |
|
| 183 | + 'EE_FRONT_AJAX', |
|
| 184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
| 185 | + ); |
|
| 186 | + define( |
|
| 187 | + 'EE_ADMIN_AJAX', |
|
| 188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
| 189 | + ); |
|
| 190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
| 191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
| 192 | + //want to change its default value! or find when -1 means infinity |
|
| 193 | + define('EE_INF_IN_DB', -1); |
|
| 194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 195 | + define('EE_DEBUG', false); |
|
| 196 | + // for older WP versions |
|
| 197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
| 198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
| 199 | + } |
|
| 200 | + /** |
|
| 201 | + * espresso_plugin_activation |
|
| 202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 203 | + */ |
|
| 204 | + function espresso_plugin_activation() |
|
| 205 | + { |
|
| 206 | + update_option('ee_espresso_activation', true); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | - /** |
|
| 211 | - * espresso_load_error_handling |
|
| 212 | - * this function loads EE's class for handling exceptions and errors |
|
| 213 | - */ |
|
| 214 | - function espresso_load_error_handling() |
|
| 215 | - { |
|
| 216 | - // load debugging tools |
|
| 217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | - EEH_Debug_Tools::instance(); |
|
| 220 | - } |
|
| 221 | - // load error handling |
|
| 222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | - } else { |
|
| 225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | - } |
|
| 227 | - } |
|
| 209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 210 | + /** |
|
| 211 | + * espresso_load_error_handling |
|
| 212 | + * this function loads EE's class for handling exceptions and errors |
|
| 213 | + */ |
|
| 214 | + function espresso_load_error_handling() |
|
| 215 | + { |
|
| 216 | + // load debugging tools |
|
| 217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
| 219 | + EEH_Debug_Tools::instance(); |
|
| 220 | + } |
|
| 221 | + // load error handling |
|
| 222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
| 224 | + } else { |
|
| 225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - /** |
|
| 230 | - * espresso_load_required |
|
| 231 | - * given a class name and path, this function will load that file or throw an exception |
|
| 232 | - * |
|
| 233 | - * @param string $classname |
|
| 234 | - * @param string $full_path_to_file |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | - { |
|
| 239 | - static $error_handling_loaded = false; |
|
| 240 | - if ( ! $error_handling_loaded) { |
|
| 241 | - espresso_load_error_handling(); |
|
| 242 | - $error_handling_loaded = true; |
|
| 243 | - } |
|
| 244 | - if (is_readable($full_path_to_file)) { |
|
| 245 | - require_once($full_path_to_file); |
|
| 246 | - } else { |
|
| 247 | - throw new EE_Error ( |
|
| 248 | - sprintf( |
|
| 249 | - esc_html__( |
|
| 250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | - 'event_espresso' |
|
| 252 | - ), |
|
| 253 | - $classname |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 229 | + /** |
|
| 230 | + * espresso_load_required |
|
| 231 | + * given a class name and path, this function will load that file or throw an exception |
|
| 232 | + * |
|
| 233 | + * @param string $classname |
|
| 234 | + * @param string $full_path_to_file |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 238 | + { |
|
| 239 | + static $error_handling_loaded = false; |
|
| 240 | + if ( ! $error_handling_loaded) { |
|
| 241 | + espresso_load_error_handling(); |
|
| 242 | + $error_handling_loaded = true; |
|
| 243 | + } |
|
| 244 | + if (is_readable($full_path_to_file)) { |
|
| 245 | + require_once($full_path_to_file); |
|
| 246 | + } else { |
|
| 247 | + throw new EE_Error ( |
|
| 248 | + sprintf( |
|
| 249 | + esc_html__( |
|
| 250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 251 | + 'event_espresso' |
|
| 252 | + ), |
|
| 253 | + $classname |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | - new EE_Bootstrap(); |
|
| 263 | - } |
|
| 259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
| 260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
| 261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
| 262 | + new EE_Bootstrap(); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
| 266 | - /** |
|
| 267 | - * deactivate_plugin |
|
| 268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | - * |
|
| 270 | - * @access public |
|
| 271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | - * @return void |
|
| 273 | - */ |
|
| 274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | - { |
|
| 276 | - if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | - } |
|
| 279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | - deactivate_plugins($plugin_basename); |
|
| 281 | - } |
|
| 266 | + /** |
|
| 267 | + * deactivate_plugin |
|
| 268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 269 | + * |
|
| 270 | + * @access public |
|
| 271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 272 | + * @return void |
|
| 273 | + */ |
|
| 274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 275 | + { |
|
| 276 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 278 | + } |
|
| 279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 280 | + deactivate_plugins($plugin_basename); |
|
| 281 | + } |
|
| 282 | 282 | } |
| 283 | 283 | \ No newline at end of file |
@@ -15,2677 +15,2677 @@ |
||
| 15 | 15 | class Events_Admin_Page extends EE_Admin_Page_CPT |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * This will hold the event object for event_details screen. |
|
| 20 | - * |
|
| 21 | - * @access protected |
|
| 22 | - * @var EE_Event $_event |
|
| 23 | - */ |
|
| 24 | - protected $_event; |
|
| 25 | - |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * This will hold the category object for category_details screen. |
|
| 29 | - * |
|
| 30 | - * @var stdClass $_category |
|
| 31 | - */ |
|
| 32 | - protected $_category; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * This will hold the event model instance |
|
| 37 | - * |
|
| 38 | - * @var EEM_Event $_event_model |
|
| 39 | - */ |
|
| 40 | - protected $_event_model; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var EE_Event |
|
| 46 | - */ |
|
| 47 | - protected $_cpt_model_obj = false; |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Initialize page props for this admin page group. |
|
| 52 | - */ |
|
| 53 | - protected function _init_page_props() |
|
| 54 | - { |
|
| 55 | - $this->page_slug = EVENTS_PG_SLUG; |
|
| 56 | - $this->page_label = EVENTS_LABEL; |
|
| 57 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 58 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
| 59 | - $this->_cpt_model_names = array( |
|
| 60 | - 'create_new' => 'EEM_Event', |
|
| 61 | - 'edit' => 'EEM_Event', |
|
| 62 | - ); |
|
| 63 | - $this->_cpt_edit_routes = array( |
|
| 64 | - 'espresso_events' => 'edit', |
|
| 65 | - ); |
|
| 66 | - add_action( |
|
| 67 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 68 | - array($this, 'verify_event_edit') |
|
| 69 | - ); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Sets the ajax hooks used for this admin page group. |
|
| 75 | - */ |
|
| 76 | - protected function _ajax_hooks() |
|
| 77 | - { |
|
| 78 | - add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Sets the page properties for this admin page group. |
|
| 84 | - */ |
|
| 85 | - protected function _define_page_props() |
|
| 86 | - { |
|
| 87 | - $this->_admin_page_title = EVENTS_LABEL; |
|
| 88 | - $this->_labels = array( |
|
| 89 | - 'buttons' => array( |
|
| 90 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 91 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 92 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 93 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 94 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 95 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 96 | - ), |
|
| 97 | - 'editor_title' => array( |
|
| 98 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 99 | - ), |
|
| 100 | - 'publishbox' => array( |
|
| 101 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 102 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 103 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 104 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 105 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 106 | - ), |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Sets the page routes property for this admin page group. |
|
| 113 | - */ |
|
| 114 | - protected function _set_page_routes() |
|
| 115 | - { |
|
| 116 | - //load formatter helper |
|
| 117 | - //load field generator helper |
|
| 118 | - //is there a evt_id in the request? |
|
| 119 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 120 | - ? $this->_req_data['EVT_ID'] |
|
| 121 | - : 0; |
|
| 122 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 123 | - $this->_page_routes = array( |
|
| 124 | - 'default' => array( |
|
| 125 | - 'func' => '_events_overview_list_table', |
|
| 126 | - 'capability' => 'ee_read_events', |
|
| 127 | - ), |
|
| 128 | - 'create_new' => array( |
|
| 129 | - 'func' => '_create_new_cpt_item', |
|
| 130 | - 'capability' => 'ee_edit_events', |
|
| 131 | - ), |
|
| 132 | - 'edit' => array( |
|
| 133 | - 'func' => '_edit_cpt_item', |
|
| 134 | - 'capability' => 'ee_edit_event', |
|
| 135 | - 'obj_id' => $evt_id, |
|
| 136 | - ), |
|
| 137 | - 'copy_event' => array( |
|
| 138 | - 'func' => '_copy_events', |
|
| 139 | - 'capability' => 'ee_edit_event', |
|
| 140 | - 'obj_id' => $evt_id, |
|
| 141 | - 'noheader' => true, |
|
| 142 | - ), |
|
| 143 | - 'trash_event' => array( |
|
| 144 | - 'func' => '_trash_or_restore_event', |
|
| 145 | - 'args' => array('event_status' => 'trash'), |
|
| 146 | - 'capability' => 'ee_delete_event', |
|
| 147 | - 'obj_id' => $evt_id, |
|
| 148 | - 'noheader' => true, |
|
| 149 | - ), |
|
| 150 | - 'trash_events' => array( |
|
| 151 | - 'func' => '_trash_or_restore_events', |
|
| 152 | - 'args' => array('event_status' => 'trash'), |
|
| 153 | - 'capability' => 'ee_delete_events', |
|
| 154 | - 'noheader' => true, |
|
| 155 | - ), |
|
| 156 | - 'restore_event' => array( |
|
| 157 | - 'func' => '_trash_or_restore_event', |
|
| 158 | - 'args' => array('event_status' => 'draft'), |
|
| 159 | - 'capability' => 'ee_delete_event', |
|
| 160 | - 'obj_id' => $evt_id, |
|
| 161 | - 'noheader' => true, |
|
| 162 | - ), |
|
| 163 | - 'restore_events' => array( |
|
| 164 | - 'func' => '_trash_or_restore_events', |
|
| 165 | - 'args' => array('event_status' => 'draft'), |
|
| 166 | - 'capability' => 'ee_delete_events', |
|
| 167 | - 'noheader' => true, |
|
| 168 | - ), |
|
| 169 | - 'delete_event' => array( |
|
| 170 | - 'func' => '_delete_event', |
|
| 171 | - 'capability' => 'ee_delete_event', |
|
| 172 | - 'obj_id' => $evt_id, |
|
| 173 | - 'noheader' => true, |
|
| 174 | - ), |
|
| 175 | - 'delete_events' => array( |
|
| 176 | - 'func' => '_delete_events', |
|
| 177 | - 'capability' => 'ee_delete_events', |
|
| 178 | - 'noheader' => true, |
|
| 179 | - ), |
|
| 180 | - 'view_report' => array( |
|
| 181 | - 'func' => '_view_report', |
|
| 182 | - 'capablity' => 'ee_edit_events', |
|
| 183 | - ), |
|
| 184 | - 'default_event_settings' => array( |
|
| 185 | - 'func' => '_default_event_settings', |
|
| 186 | - 'capability' => 'manage_options', |
|
| 187 | - ), |
|
| 188 | - 'update_default_event_settings' => array( |
|
| 189 | - 'func' => '_update_default_event_settings', |
|
| 190 | - 'capability' => 'manage_options', |
|
| 191 | - 'noheader' => true, |
|
| 192 | - ), |
|
| 193 | - 'template_settings' => array( |
|
| 194 | - 'func' => '_template_settings', |
|
| 195 | - 'capability' => 'manage_options', |
|
| 196 | - ), |
|
| 197 | - //event category tab related |
|
| 198 | - 'add_category' => array( |
|
| 199 | - 'func' => '_category_details', |
|
| 200 | - 'capability' => 'ee_edit_event_category', |
|
| 201 | - 'args' => array('add'), |
|
| 202 | - ), |
|
| 203 | - 'edit_category' => array( |
|
| 204 | - 'func' => '_category_details', |
|
| 205 | - 'capability' => 'ee_edit_event_category', |
|
| 206 | - 'args' => array('edit'), |
|
| 207 | - ), |
|
| 208 | - 'delete_categories' => array( |
|
| 209 | - 'func' => '_delete_categories', |
|
| 210 | - 'capability' => 'ee_delete_event_category', |
|
| 211 | - 'noheader' => true, |
|
| 212 | - ), |
|
| 213 | - 'delete_category' => array( |
|
| 214 | - 'func' => '_delete_categories', |
|
| 215 | - 'capability' => 'ee_delete_event_category', |
|
| 216 | - 'noheader' => true, |
|
| 217 | - ), |
|
| 218 | - 'insert_category' => array( |
|
| 219 | - 'func' => '_insert_or_update_category', |
|
| 220 | - 'args' => array('new_category' => true), |
|
| 221 | - 'capability' => 'ee_edit_event_category', |
|
| 222 | - 'noheader' => true, |
|
| 223 | - ), |
|
| 224 | - 'update_category' => array( |
|
| 225 | - 'func' => '_insert_or_update_category', |
|
| 226 | - 'args' => array('new_category' => false), |
|
| 227 | - 'capability' => 'ee_edit_event_category', |
|
| 228 | - 'noheader' => true, |
|
| 229 | - ), |
|
| 230 | - 'category_list' => array( |
|
| 231 | - 'func' => '_category_list_table', |
|
| 232 | - 'capability' => 'ee_manage_event_categories', |
|
| 233 | - ), |
|
| 234 | - ); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Set the _page_config property for this admin page group. |
|
| 240 | - */ |
|
| 241 | - protected function _set_page_config() |
|
| 242 | - { |
|
| 243 | - $this->_page_config = array( |
|
| 244 | - 'default' => array( |
|
| 245 | - 'nav' => array( |
|
| 246 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 247 | - 'order' => 10, |
|
| 248 | - ), |
|
| 249 | - 'list_table' => 'Events_Admin_List_Table', |
|
| 250 | - 'help_tabs' => array( |
|
| 251 | - 'events_overview_help_tab' => array( |
|
| 252 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 253 | - 'filename' => 'events_overview', |
|
| 254 | - ), |
|
| 255 | - 'events_overview_table_column_headings_help_tab' => array( |
|
| 256 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 257 | - 'filename' => 'events_overview_table_column_headings', |
|
| 258 | - ), |
|
| 259 | - 'events_overview_filters_help_tab' => array( |
|
| 260 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 261 | - 'filename' => 'events_overview_filters', |
|
| 262 | - ), |
|
| 263 | - 'events_overview_view_help_tab' => array( |
|
| 264 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 265 | - 'filename' => 'events_overview_views', |
|
| 266 | - ), |
|
| 267 | - 'events_overview_other_help_tab' => array( |
|
| 268 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 269 | - 'filename' => 'events_overview_other', |
|
| 270 | - ), |
|
| 271 | - ), |
|
| 272 | - 'help_tour' => array( |
|
| 273 | - 'Event_Overview_Help_Tour', |
|
| 274 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 275 | - ), |
|
| 276 | - 'qtips' => array( |
|
| 277 | - 'EE_Event_List_Table_Tips', |
|
| 278 | - ), |
|
| 279 | - 'require_nonce' => false, |
|
| 280 | - ), |
|
| 281 | - 'create_new' => array( |
|
| 282 | - 'nav' => array( |
|
| 283 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 284 | - 'order' => 5, |
|
| 285 | - 'persistent' => false, |
|
| 286 | - ), |
|
| 287 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 288 | - 'help_tabs' => array( |
|
| 289 | - 'event_editor_help_tab' => array( |
|
| 290 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 291 | - 'filename' => 'event_editor', |
|
| 292 | - ), |
|
| 293 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 294 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 295 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 296 | - ), |
|
| 297 | - 'event_editor_venue_details_help_tab' => array( |
|
| 298 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 299 | - 'filename' => 'event_editor_venue_details', |
|
| 300 | - ), |
|
| 301 | - 'event_editor_event_datetimes_help_tab' => array( |
|
| 302 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 303 | - 'filename' => 'event_editor_event_datetimes', |
|
| 304 | - ), |
|
| 305 | - 'event_editor_event_tickets_help_tab' => array( |
|
| 306 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 307 | - 'filename' => 'event_editor_event_tickets', |
|
| 308 | - ), |
|
| 309 | - 'event_editor_event_registration_options_help_tab' => array( |
|
| 310 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 311 | - 'filename' => 'event_editor_event_registration_options', |
|
| 312 | - ), |
|
| 313 | - 'event_editor_tags_categories_help_tab' => array( |
|
| 314 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 315 | - 'filename' => 'event_editor_tags_categories', |
|
| 316 | - ), |
|
| 317 | - 'event_editor_questions_registrants_help_tab' => array( |
|
| 318 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 319 | - 'filename' => 'event_editor_questions_registrants', |
|
| 320 | - ), |
|
| 321 | - 'event_editor_save_new_event_help_tab' => array( |
|
| 322 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 323 | - 'filename' => 'event_editor_save_new_event', |
|
| 324 | - ), |
|
| 325 | - 'event_editor_other_help_tab' => array( |
|
| 326 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 327 | - 'filename' => 'event_editor_other', |
|
| 328 | - ), |
|
| 329 | - ), |
|
| 330 | - 'help_tour' => array( |
|
| 331 | - 'Event_Editor_Help_Tour', |
|
| 332 | - ), |
|
| 333 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 334 | - 'require_nonce' => false, |
|
| 335 | - ), |
|
| 336 | - 'edit' => array( |
|
| 337 | - 'nav' => array( |
|
| 338 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 339 | - 'order' => 5, |
|
| 340 | - 'persistent' => false, |
|
| 341 | - 'url' => isset($this->_req_data['post']) |
|
| 342 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 343 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
| 344 | - $this->_current_page_view_url |
|
| 345 | - ) |
|
| 346 | - : $this->_admin_base_url, |
|
| 347 | - ), |
|
| 348 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 349 | - 'help_tabs' => array( |
|
| 350 | - 'event_editor_help_tab' => array( |
|
| 351 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 352 | - 'filename' => 'event_editor', |
|
| 353 | - ), |
|
| 354 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 355 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 356 | - 'filename' => 'event_editor_title_richtexteditor', |
|
| 357 | - ), |
|
| 358 | - 'event_editor_venue_details_help_tab' => array( |
|
| 359 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 360 | - 'filename' => 'event_editor_venue_details', |
|
| 361 | - ), |
|
| 362 | - 'event_editor_event_datetimes_help_tab' => array( |
|
| 363 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 364 | - 'filename' => 'event_editor_event_datetimes', |
|
| 365 | - ), |
|
| 366 | - 'event_editor_event_tickets_help_tab' => array( |
|
| 367 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 368 | - 'filename' => 'event_editor_event_tickets', |
|
| 369 | - ), |
|
| 370 | - 'event_editor_event_registration_options_help_tab' => array( |
|
| 371 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 372 | - 'filename' => 'event_editor_event_registration_options', |
|
| 373 | - ), |
|
| 374 | - 'event_editor_tags_categories_help_tab' => array( |
|
| 375 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 376 | - 'filename' => 'event_editor_tags_categories', |
|
| 377 | - ), |
|
| 378 | - 'event_editor_questions_registrants_help_tab' => array( |
|
| 379 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 380 | - 'filename' => 'event_editor_questions_registrants', |
|
| 381 | - ), |
|
| 382 | - 'event_editor_save_new_event_help_tab' => array( |
|
| 383 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 384 | - 'filename' => 'event_editor_save_new_event', |
|
| 385 | - ), |
|
| 386 | - 'event_editor_other_help_tab' => array( |
|
| 387 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 388 | - 'filename' => 'event_editor_other', |
|
| 389 | - ), |
|
| 390 | - ), |
|
| 391 | - /*'help_tour' => array( |
|
| 18 | + /** |
|
| 19 | + * This will hold the event object for event_details screen. |
|
| 20 | + * |
|
| 21 | + * @access protected |
|
| 22 | + * @var EE_Event $_event |
|
| 23 | + */ |
|
| 24 | + protected $_event; |
|
| 25 | + |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * This will hold the category object for category_details screen. |
|
| 29 | + * |
|
| 30 | + * @var stdClass $_category |
|
| 31 | + */ |
|
| 32 | + protected $_category; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * This will hold the event model instance |
|
| 37 | + * |
|
| 38 | + * @var EEM_Event $_event_model |
|
| 39 | + */ |
|
| 40 | + protected $_event_model; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var EE_Event |
|
| 46 | + */ |
|
| 47 | + protected $_cpt_model_obj = false; |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Initialize page props for this admin page group. |
|
| 52 | + */ |
|
| 53 | + protected function _init_page_props() |
|
| 54 | + { |
|
| 55 | + $this->page_slug = EVENTS_PG_SLUG; |
|
| 56 | + $this->page_label = EVENTS_LABEL; |
|
| 57 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
| 58 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
| 59 | + $this->_cpt_model_names = array( |
|
| 60 | + 'create_new' => 'EEM_Event', |
|
| 61 | + 'edit' => 'EEM_Event', |
|
| 62 | + ); |
|
| 63 | + $this->_cpt_edit_routes = array( |
|
| 64 | + 'espresso_events' => 'edit', |
|
| 65 | + ); |
|
| 66 | + add_action( |
|
| 67 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
| 68 | + array($this, 'verify_event_edit') |
|
| 69 | + ); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Sets the ajax hooks used for this admin page group. |
|
| 75 | + */ |
|
| 76 | + protected function _ajax_hooks() |
|
| 77 | + { |
|
| 78 | + add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Sets the page properties for this admin page group. |
|
| 84 | + */ |
|
| 85 | + protected function _define_page_props() |
|
| 86 | + { |
|
| 87 | + $this->_admin_page_title = EVENTS_LABEL; |
|
| 88 | + $this->_labels = array( |
|
| 89 | + 'buttons' => array( |
|
| 90 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
| 91 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
| 92 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
| 93 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
| 94 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
| 95 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
| 96 | + ), |
|
| 97 | + 'editor_title' => array( |
|
| 98 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
| 99 | + ), |
|
| 100 | + 'publishbox' => array( |
|
| 101 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
| 102 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
| 103 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
| 104 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
| 105 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
| 106 | + ), |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Sets the page routes property for this admin page group. |
|
| 113 | + */ |
|
| 114 | + protected function _set_page_routes() |
|
| 115 | + { |
|
| 116 | + //load formatter helper |
|
| 117 | + //load field generator helper |
|
| 118 | + //is there a evt_id in the request? |
|
| 119 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 120 | + ? $this->_req_data['EVT_ID'] |
|
| 121 | + : 0; |
|
| 122 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 123 | + $this->_page_routes = array( |
|
| 124 | + 'default' => array( |
|
| 125 | + 'func' => '_events_overview_list_table', |
|
| 126 | + 'capability' => 'ee_read_events', |
|
| 127 | + ), |
|
| 128 | + 'create_new' => array( |
|
| 129 | + 'func' => '_create_new_cpt_item', |
|
| 130 | + 'capability' => 'ee_edit_events', |
|
| 131 | + ), |
|
| 132 | + 'edit' => array( |
|
| 133 | + 'func' => '_edit_cpt_item', |
|
| 134 | + 'capability' => 'ee_edit_event', |
|
| 135 | + 'obj_id' => $evt_id, |
|
| 136 | + ), |
|
| 137 | + 'copy_event' => array( |
|
| 138 | + 'func' => '_copy_events', |
|
| 139 | + 'capability' => 'ee_edit_event', |
|
| 140 | + 'obj_id' => $evt_id, |
|
| 141 | + 'noheader' => true, |
|
| 142 | + ), |
|
| 143 | + 'trash_event' => array( |
|
| 144 | + 'func' => '_trash_or_restore_event', |
|
| 145 | + 'args' => array('event_status' => 'trash'), |
|
| 146 | + 'capability' => 'ee_delete_event', |
|
| 147 | + 'obj_id' => $evt_id, |
|
| 148 | + 'noheader' => true, |
|
| 149 | + ), |
|
| 150 | + 'trash_events' => array( |
|
| 151 | + 'func' => '_trash_or_restore_events', |
|
| 152 | + 'args' => array('event_status' => 'trash'), |
|
| 153 | + 'capability' => 'ee_delete_events', |
|
| 154 | + 'noheader' => true, |
|
| 155 | + ), |
|
| 156 | + 'restore_event' => array( |
|
| 157 | + 'func' => '_trash_or_restore_event', |
|
| 158 | + 'args' => array('event_status' => 'draft'), |
|
| 159 | + 'capability' => 'ee_delete_event', |
|
| 160 | + 'obj_id' => $evt_id, |
|
| 161 | + 'noheader' => true, |
|
| 162 | + ), |
|
| 163 | + 'restore_events' => array( |
|
| 164 | + 'func' => '_trash_or_restore_events', |
|
| 165 | + 'args' => array('event_status' => 'draft'), |
|
| 166 | + 'capability' => 'ee_delete_events', |
|
| 167 | + 'noheader' => true, |
|
| 168 | + ), |
|
| 169 | + 'delete_event' => array( |
|
| 170 | + 'func' => '_delete_event', |
|
| 171 | + 'capability' => 'ee_delete_event', |
|
| 172 | + 'obj_id' => $evt_id, |
|
| 173 | + 'noheader' => true, |
|
| 174 | + ), |
|
| 175 | + 'delete_events' => array( |
|
| 176 | + 'func' => '_delete_events', |
|
| 177 | + 'capability' => 'ee_delete_events', |
|
| 178 | + 'noheader' => true, |
|
| 179 | + ), |
|
| 180 | + 'view_report' => array( |
|
| 181 | + 'func' => '_view_report', |
|
| 182 | + 'capablity' => 'ee_edit_events', |
|
| 183 | + ), |
|
| 184 | + 'default_event_settings' => array( |
|
| 185 | + 'func' => '_default_event_settings', |
|
| 186 | + 'capability' => 'manage_options', |
|
| 187 | + ), |
|
| 188 | + 'update_default_event_settings' => array( |
|
| 189 | + 'func' => '_update_default_event_settings', |
|
| 190 | + 'capability' => 'manage_options', |
|
| 191 | + 'noheader' => true, |
|
| 192 | + ), |
|
| 193 | + 'template_settings' => array( |
|
| 194 | + 'func' => '_template_settings', |
|
| 195 | + 'capability' => 'manage_options', |
|
| 196 | + ), |
|
| 197 | + //event category tab related |
|
| 198 | + 'add_category' => array( |
|
| 199 | + 'func' => '_category_details', |
|
| 200 | + 'capability' => 'ee_edit_event_category', |
|
| 201 | + 'args' => array('add'), |
|
| 202 | + ), |
|
| 203 | + 'edit_category' => array( |
|
| 204 | + 'func' => '_category_details', |
|
| 205 | + 'capability' => 'ee_edit_event_category', |
|
| 206 | + 'args' => array('edit'), |
|
| 207 | + ), |
|
| 208 | + 'delete_categories' => array( |
|
| 209 | + 'func' => '_delete_categories', |
|
| 210 | + 'capability' => 'ee_delete_event_category', |
|
| 211 | + 'noheader' => true, |
|
| 212 | + ), |
|
| 213 | + 'delete_category' => array( |
|
| 214 | + 'func' => '_delete_categories', |
|
| 215 | + 'capability' => 'ee_delete_event_category', |
|
| 216 | + 'noheader' => true, |
|
| 217 | + ), |
|
| 218 | + 'insert_category' => array( |
|
| 219 | + 'func' => '_insert_or_update_category', |
|
| 220 | + 'args' => array('new_category' => true), |
|
| 221 | + 'capability' => 'ee_edit_event_category', |
|
| 222 | + 'noheader' => true, |
|
| 223 | + ), |
|
| 224 | + 'update_category' => array( |
|
| 225 | + 'func' => '_insert_or_update_category', |
|
| 226 | + 'args' => array('new_category' => false), |
|
| 227 | + 'capability' => 'ee_edit_event_category', |
|
| 228 | + 'noheader' => true, |
|
| 229 | + ), |
|
| 230 | + 'category_list' => array( |
|
| 231 | + 'func' => '_category_list_table', |
|
| 232 | + 'capability' => 'ee_manage_event_categories', |
|
| 233 | + ), |
|
| 234 | + ); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Set the _page_config property for this admin page group. |
|
| 240 | + */ |
|
| 241 | + protected function _set_page_config() |
|
| 242 | + { |
|
| 243 | + $this->_page_config = array( |
|
| 244 | + 'default' => array( |
|
| 245 | + 'nav' => array( |
|
| 246 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
| 247 | + 'order' => 10, |
|
| 248 | + ), |
|
| 249 | + 'list_table' => 'Events_Admin_List_Table', |
|
| 250 | + 'help_tabs' => array( |
|
| 251 | + 'events_overview_help_tab' => array( |
|
| 252 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
| 253 | + 'filename' => 'events_overview', |
|
| 254 | + ), |
|
| 255 | + 'events_overview_table_column_headings_help_tab' => array( |
|
| 256 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
| 257 | + 'filename' => 'events_overview_table_column_headings', |
|
| 258 | + ), |
|
| 259 | + 'events_overview_filters_help_tab' => array( |
|
| 260 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
| 261 | + 'filename' => 'events_overview_filters', |
|
| 262 | + ), |
|
| 263 | + 'events_overview_view_help_tab' => array( |
|
| 264 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
| 265 | + 'filename' => 'events_overview_views', |
|
| 266 | + ), |
|
| 267 | + 'events_overview_other_help_tab' => array( |
|
| 268 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
| 269 | + 'filename' => 'events_overview_other', |
|
| 270 | + ), |
|
| 271 | + ), |
|
| 272 | + 'help_tour' => array( |
|
| 273 | + 'Event_Overview_Help_Tour', |
|
| 274 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
| 275 | + ), |
|
| 276 | + 'qtips' => array( |
|
| 277 | + 'EE_Event_List_Table_Tips', |
|
| 278 | + ), |
|
| 279 | + 'require_nonce' => false, |
|
| 280 | + ), |
|
| 281 | + 'create_new' => array( |
|
| 282 | + 'nav' => array( |
|
| 283 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
| 284 | + 'order' => 5, |
|
| 285 | + 'persistent' => false, |
|
| 286 | + ), |
|
| 287 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 288 | + 'help_tabs' => array( |
|
| 289 | + 'event_editor_help_tab' => array( |
|
| 290 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 291 | + 'filename' => 'event_editor', |
|
| 292 | + ), |
|
| 293 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 294 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 295 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 296 | + ), |
|
| 297 | + 'event_editor_venue_details_help_tab' => array( |
|
| 298 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 299 | + 'filename' => 'event_editor_venue_details', |
|
| 300 | + ), |
|
| 301 | + 'event_editor_event_datetimes_help_tab' => array( |
|
| 302 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 303 | + 'filename' => 'event_editor_event_datetimes', |
|
| 304 | + ), |
|
| 305 | + 'event_editor_event_tickets_help_tab' => array( |
|
| 306 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 307 | + 'filename' => 'event_editor_event_tickets', |
|
| 308 | + ), |
|
| 309 | + 'event_editor_event_registration_options_help_tab' => array( |
|
| 310 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 311 | + 'filename' => 'event_editor_event_registration_options', |
|
| 312 | + ), |
|
| 313 | + 'event_editor_tags_categories_help_tab' => array( |
|
| 314 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 315 | + 'filename' => 'event_editor_tags_categories', |
|
| 316 | + ), |
|
| 317 | + 'event_editor_questions_registrants_help_tab' => array( |
|
| 318 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 319 | + 'filename' => 'event_editor_questions_registrants', |
|
| 320 | + ), |
|
| 321 | + 'event_editor_save_new_event_help_tab' => array( |
|
| 322 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 323 | + 'filename' => 'event_editor_save_new_event', |
|
| 324 | + ), |
|
| 325 | + 'event_editor_other_help_tab' => array( |
|
| 326 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 327 | + 'filename' => 'event_editor_other', |
|
| 328 | + ), |
|
| 329 | + ), |
|
| 330 | + 'help_tour' => array( |
|
| 331 | + 'Event_Editor_Help_Tour', |
|
| 332 | + ), |
|
| 333 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 334 | + 'require_nonce' => false, |
|
| 335 | + ), |
|
| 336 | + 'edit' => array( |
|
| 337 | + 'nav' => array( |
|
| 338 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
| 339 | + 'order' => 5, |
|
| 340 | + 'persistent' => false, |
|
| 341 | + 'url' => isset($this->_req_data['post']) |
|
| 342 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 343 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
| 344 | + $this->_current_page_view_url |
|
| 345 | + ) |
|
| 346 | + : $this->_admin_base_url, |
|
| 347 | + ), |
|
| 348 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
| 349 | + 'help_tabs' => array( |
|
| 350 | + 'event_editor_help_tab' => array( |
|
| 351 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
| 352 | + 'filename' => 'event_editor', |
|
| 353 | + ), |
|
| 354 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
| 355 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
| 356 | + 'filename' => 'event_editor_title_richtexteditor', |
|
| 357 | + ), |
|
| 358 | + 'event_editor_venue_details_help_tab' => array( |
|
| 359 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
| 360 | + 'filename' => 'event_editor_venue_details', |
|
| 361 | + ), |
|
| 362 | + 'event_editor_event_datetimes_help_tab' => array( |
|
| 363 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
| 364 | + 'filename' => 'event_editor_event_datetimes', |
|
| 365 | + ), |
|
| 366 | + 'event_editor_event_tickets_help_tab' => array( |
|
| 367 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
| 368 | + 'filename' => 'event_editor_event_tickets', |
|
| 369 | + ), |
|
| 370 | + 'event_editor_event_registration_options_help_tab' => array( |
|
| 371 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
| 372 | + 'filename' => 'event_editor_event_registration_options', |
|
| 373 | + ), |
|
| 374 | + 'event_editor_tags_categories_help_tab' => array( |
|
| 375 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
| 376 | + 'filename' => 'event_editor_tags_categories', |
|
| 377 | + ), |
|
| 378 | + 'event_editor_questions_registrants_help_tab' => array( |
|
| 379 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
| 380 | + 'filename' => 'event_editor_questions_registrants', |
|
| 381 | + ), |
|
| 382 | + 'event_editor_save_new_event_help_tab' => array( |
|
| 383 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
| 384 | + 'filename' => 'event_editor_save_new_event', |
|
| 385 | + ), |
|
| 386 | + 'event_editor_other_help_tab' => array( |
|
| 387 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
| 388 | + 'filename' => 'event_editor_other', |
|
| 389 | + ), |
|
| 390 | + ), |
|
| 391 | + /*'help_tour' => array( |
|
| 392 | 392 | 'Event_Edit_Help_Tour' |
| 393 | 393 | ),*/ |
| 394 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 395 | - 'require_nonce' => false, |
|
| 396 | - ), |
|
| 397 | - 'default_event_settings' => array( |
|
| 398 | - 'nav' => array( |
|
| 399 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 400 | - 'order' => 40, |
|
| 401 | - ), |
|
| 402 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 403 | - 'labels' => array( |
|
| 404 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 405 | - ), |
|
| 406 | - 'help_tabs' => array( |
|
| 407 | - 'default_settings_help_tab' => array( |
|
| 408 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 409 | - 'filename' => 'events_default_settings', |
|
| 410 | - ), |
|
| 411 | - 'default_settings_status_help_tab' => array( |
|
| 412 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 413 | - 'filename' => 'events_default_settings_status', |
|
| 414 | - ), |
|
| 415 | - 'default_maximum_tickets_help_tab' => array( |
|
| 416 | - 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 417 | - 'filename' => 'events_default_settings_max_tickets', |
|
| 418 | - ) |
|
| 419 | - ), |
|
| 420 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
| 421 | - 'require_nonce' => false, |
|
| 422 | - ), |
|
| 423 | - //template settings |
|
| 424 | - 'template_settings' => array( |
|
| 425 | - 'nav' => array( |
|
| 426 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 427 | - 'order' => 30, |
|
| 428 | - ), |
|
| 429 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 430 | - 'help_tabs' => array( |
|
| 431 | - 'general_settings_templates_help_tab' => array( |
|
| 432 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 433 | - 'filename' => 'general_settings_templates', |
|
| 434 | - ), |
|
| 435 | - ), |
|
| 436 | - 'help_tour' => array('Templates_Help_Tour'), |
|
| 437 | - 'require_nonce' => false, |
|
| 438 | - ), |
|
| 439 | - //event category stuff |
|
| 440 | - 'add_category' => array( |
|
| 441 | - 'nav' => array( |
|
| 442 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 443 | - 'order' => 15, |
|
| 444 | - 'persistent' => false, |
|
| 445 | - ), |
|
| 446 | - 'help_tabs' => array( |
|
| 447 | - 'add_category_help_tab' => array( |
|
| 448 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 449 | - 'filename' => 'events_add_category', |
|
| 450 | - ), |
|
| 451 | - ), |
|
| 452 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
| 453 | - 'metaboxes' => array('_publish_post_box'), |
|
| 454 | - 'require_nonce' => false, |
|
| 455 | - ), |
|
| 456 | - 'edit_category' => array( |
|
| 457 | - 'nav' => array( |
|
| 458 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 459 | - 'order' => 15, |
|
| 460 | - 'persistent' => false, |
|
| 461 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
| 462 | - ? add_query_arg( |
|
| 463 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
| 464 | - $this->_current_page_view_url |
|
| 465 | - ) |
|
| 466 | - : $this->_admin_base_url, |
|
| 467 | - ), |
|
| 468 | - 'help_tabs' => array( |
|
| 469 | - 'edit_category_help_tab' => array( |
|
| 470 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 471 | - 'filename' => 'events_edit_category', |
|
| 472 | - ), |
|
| 473 | - ), |
|
| 474 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
| 475 | - 'metaboxes' => array('_publish_post_box'), |
|
| 476 | - 'require_nonce' => false, |
|
| 477 | - ), |
|
| 478 | - 'category_list' => array( |
|
| 479 | - 'nav' => array( |
|
| 480 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 481 | - 'order' => 20, |
|
| 482 | - ), |
|
| 483 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 484 | - 'help_tabs' => array( |
|
| 485 | - 'events_categories_help_tab' => array( |
|
| 486 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 487 | - 'filename' => 'events_categories', |
|
| 488 | - ), |
|
| 489 | - 'events_categories_table_column_headings_help_tab' => array( |
|
| 490 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 491 | - 'filename' => 'events_categories_table_column_headings', |
|
| 492 | - ), |
|
| 493 | - 'events_categories_view_help_tab' => array( |
|
| 494 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 495 | - 'filename' => 'events_categories_views', |
|
| 496 | - ), |
|
| 497 | - 'events_categories_other_help_tab' => array( |
|
| 498 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 499 | - 'filename' => 'events_categories_other', |
|
| 500 | - ), |
|
| 501 | - ), |
|
| 502 | - 'help_tour' => array( |
|
| 503 | - 'Event_Categories_Help_Tour', |
|
| 504 | - ), |
|
| 505 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 506 | - 'require_nonce' => false, |
|
| 507 | - ), |
|
| 508 | - ); |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 514 | - */ |
|
| 515 | - protected function _add_screen_options() |
|
| 516 | - { |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * Implementing the screen options for the 'default' route. |
|
| 522 | - */ |
|
| 523 | - protected function _add_screen_options_default() |
|
| 524 | - { |
|
| 525 | - $this->_per_page_screen_option(); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Implementing screen options for the category list route. |
|
| 531 | - */ |
|
| 532 | - protected function _add_screen_options_category_list() |
|
| 533 | - { |
|
| 534 | - $page_title = $this->_admin_page_title; |
|
| 535 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 536 | - $this->_per_page_screen_option(); |
|
| 537 | - $this->_admin_page_title = $page_title; |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - |
|
| 541 | - /** |
|
| 542 | - * Used to register any global feature pointers for the admin page group. |
|
| 543 | - */ |
|
| 544 | - protected function _add_feature_pointers() |
|
| 545 | - { |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 551 | - */ |
|
| 552 | - public function load_scripts_styles() |
|
| 553 | - { |
|
| 554 | - wp_register_style( |
|
| 555 | - 'events-admin-css', |
|
| 556 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 557 | - array(), |
|
| 558 | - EVENT_ESPRESSO_VERSION |
|
| 559 | - ); |
|
| 560 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | - wp_enqueue_style('events-admin-css'); |
|
| 562 | - wp_enqueue_style('ee-cat-admin'); |
|
| 563 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
| 564 | - //registers for all views |
|
| 565 | - //scripts |
|
| 566 | - wp_register_script( |
|
| 567 | - 'event_editor_js', |
|
| 568 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 569 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
| 570 | - EVENT_ESPRESSO_VERSION, |
|
| 571 | - true |
|
| 572 | - ); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - |
|
| 576 | - |
|
| 577 | - /** |
|
| 578 | - * Enqueuing scripts and styles specific to this view |
|
| 579 | - */ |
|
| 580 | - public function load_scripts_styles_create_new() |
|
| 581 | - { |
|
| 582 | - $this->load_scripts_styles_edit(); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Enqueuing scripts and styles specific to this view |
|
| 589 | - */ |
|
| 590 | - public function load_scripts_styles_edit() |
|
| 591 | - { |
|
| 592 | - //styles |
|
| 593 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 594 | - wp_register_style( |
|
| 595 | - 'event-editor-css', |
|
| 596 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 597 | - array('ee-admin-css'), |
|
| 598 | - EVENT_ESPRESSO_VERSION |
|
| 599 | - ); |
|
| 600 | - wp_enqueue_style('event-editor-css'); |
|
| 601 | - //scripts |
|
| 602 | - wp_register_script( |
|
| 603 | - 'event-datetime-metabox', |
|
| 604 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 605 | - array('event_editor_js', 'ee-datepicker'), |
|
| 606 | - EVENT_ESPRESSO_VERSION |
|
| 607 | - ); |
|
| 608 | - wp_enqueue_script('event-datetime-metabox'); |
|
| 609 | - } |
|
| 610 | - |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Populating the _views property for the category list table view. |
|
| 614 | - */ |
|
| 615 | - protected function _set_list_table_views_category_list() |
|
| 616 | - { |
|
| 617 | - $this->_views = array( |
|
| 618 | - 'all' => array( |
|
| 619 | - 'slug' => 'all', |
|
| 620 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 621 | - 'count' => 0, |
|
| 622 | - 'bulk_action' => array( |
|
| 623 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 624 | - ), |
|
| 625 | - ), |
|
| 626 | - ); |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 632 | - */ |
|
| 633 | - public function admin_init() |
|
| 634 | - { |
|
| 635 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 636 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 637 | - 'event_espresso' |
|
| 638 | - ); |
|
| 639 | - } |
|
| 640 | - |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * For adding anything that should be triggered on the admin_notices hook for any route within this admin page group. |
|
| 644 | - */ |
|
| 645 | - public function admin_notices() |
|
| 646 | - { |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - /** |
|
| 651 | - * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 652 | - * this admin page group. |
|
| 653 | - */ |
|
| 654 | - public function admin_footer_scripts() |
|
| 655 | - { |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 662 | - * warning (via EE_Error::add_error()); |
|
| 663 | - * |
|
| 664 | - * @param EE_Event $event Event object |
|
| 665 | - * @access public |
|
| 666 | - * @return void |
|
| 667 | - */ |
|
| 668 | - public function verify_event_edit($event = null) |
|
| 669 | - { |
|
| 670 | - // no event? |
|
| 671 | - if (empty($event)) { |
|
| 672 | - // set event |
|
| 673 | - $event = $this->_cpt_model_obj; |
|
| 674 | - } |
|
| 675 | - // STILL no event? |
|
| 676 | - if (! $event instanceof EE_Event) { |
|
| 677 | - return; |
|
| 678 | - } |
|
| 679 | - $orig_status = $event->status(); |
|
| 680 | - // first check if event is active. |
|
| 681 | - if ( |
|
| 682 | - $orig_status === EEM_Event::cancelled |
|
| 683 | - || $orig_status === EEM_Event::postponed |
|
| 684 | - || $event->is_expired() |
|
| 685 | - || $event->is_inactive() |
|
| 686 | - ) { |
|
| 687 | - return; |
|
| 688 | - } |
|
| 689 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
| 690 | - if ($event->is_sold_out(true)) { |
|
| 691 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 692 | - EE_Error::add_attention( |
|
| 693 | - sprintf( |
|
| 694 | - esc_html__( |
|
| 695 | - 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 696 | - 'event_espresso' |
|
| 697 | - ), |
|
| 698 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 699 | - ) |
|
| 700 | - ); |
|
| 701 | - } |
|
| 702 | - return; |
|
| 703 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
| 704 | - EE_Error::add_attention( |
|
| 705 | - sprintf( |
|
| 706 | - esc_html__( |
|
| 707 | - 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 708 | - 'event_espresso' |
|
| 709 | - ), |
|
| 710 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 711 | - ) |
|
| 712 | - ); |
|
| 713 | - } |
|
| 714 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 715 | - if ( ! $event->tickets_on_sale()) { |
|
| 716 | - return; |
|
| 717 | - } |
|
| 718 | - //made it here so show warning |
|
| 719 | - $this->_edit_event_warning(); |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - |
|
| 723 | - |
|
| 724 | - /** |
|
| 725 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 726 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
| 727 | - * |
|
| 728 | - * @access protected |
|
| 729 | - * @return void |
|
| 730 | - */ |
|
| 731 | - protected function _edit_event_warning() |
|
| 732 | - { |
|
| 733 | - // we don't want to add warnings during these requests |
|
| 734 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
| 735 | - return; |
|
| 736 | - } |
|
| 737 | - EE_Error::add_attention( |
|
| 738 | - esc_html__( |
|
| 739 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
| 740 | - 'event_espresso' |
|
| 741 | - ) |
|
| 742 | - ); |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 749 | - * Otherwise, do the normal logic |
|
| 750 | - * |
|
| 751 | - * @return string |
|
| 752 | - * @throws \EE_Error |
|
| 753 | - */ |
|
| 754 | - protected function _create_new_cpt_item() |
|
| 755 | - { |
|
| 756 | - $has_timezone_string = get_option('timezone_string'); |
|
| 757 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 758 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 759 | - EE_Error::add_attention( |
|
| 760 | - sprintf( |
|
| 761 | - __( |
|
| 762 | - 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 763 | - 'event_espresso' |
|
| 764 | - ), |
|
| 765 | - '<br>', |
|
| 766 | - '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 767 | - . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 768 | - . '</select>', |
|
| 769 | - '<button class="button button-secondary timezone-submit">', |
|
| 770 | - '</button><span class="spinner"></span>' |
|
| 771 | - ), |
|
| 772 | - __FILE__, |
|
| 773 | - __FUNCTION__, |
|
| 774 | - __LINE__ |
|
| 775 | - ); |
|
| 776 | - } |
|
| 777 | - return parent::_create_new_cpt_item(); |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * Sets the _views property for the default route in this admin page group. |
|
| 783 | - */ |
|
| 784 | - protected function _set_list_table_views_default() |
|
| 785 | - { |
|
| 786 | - $this->_views = array( |
|
| 787 | - 'all' => array( |
|
| 788 | - 'slug' => 'all', |
|
| 789 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 790 | - 'count' => 0, |
|
| 791 | - 'bulk_action' => array( |
|
| 792 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 793 | - ), |
|
| 794 | - ), |
|
| 795 | - 'draft' => array( |
|
| 796 | - 'slug' => 'draft', |
|
| 797 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 798 | - 'count' => 0, |
|
| 799 | - 'bulk_action' => array( |
|
| 800 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 801 | - ), |
|
| 802 | - ), |
|
| 803 | - ); |
|
| 804 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 805 | - $this->_views['trash'] = array( |
|
| 806 | - 'slug' => 'trash', |
|
| 807 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 808 | - 'count' => 0, |
|
| 809 | - 'bulk_action' => array( |
|
| 810 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 811 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 812 | - ), |
|
| 813 | - ); |
|
| 814 | - } |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - |
|
| 818 | - |
|
| 819 | - /** |
|
| 820 | - * Provides the legend item array for the default list table view. |
|
| 821 | - * @return array |
|
| 822 | - */ |
|
| 823 | - protected function _event_legend_items() |
|
| 824 | - { |
|
| 825 | - $items = array( |
|
| 826 | - 'view_details' => array( |
|
| 827 | - 'class' => 'dashicons dashicons-search', |
|
| 828 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 829 | - ), |
|
| 830 | - 'edit_event' => array( |
|
| 831 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
| 832 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 833 | - ), |
|
| 834 | - 'view_attendees' => array( |
|
| 835 | - 'class' => 'dashicons dashicons-groups', |
|
| 836 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 837 | - ), |
|
| 838 | - ); |
|
| 839 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 840 | - $statuses = array( |
|
| 841 | - 'sold_out_status' => array( |
|
| 842 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 843 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 844 | - ), |
|
| 845 | - 'active_status' => array( |
|
| 846 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 847 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 848 | - ), |
|
| 849 | - 'upcoming_status' => array( |
|
| 850 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 851 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 852 | - ), |
|
| 853 | - 'postponed_status' => array( |
|
| 854 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 855 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 856 | - ), |
|
| 857 | - 'cancelled_status' => array( |
|
| 858 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 859 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 860 | - ), |
|
| 861 | - 'expired_status' => array( |
|
| 862 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 863 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 864 | - ), |
|
| 865 | - 'inactive_status' => array( |
|
| 866 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 867 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 868 | - ), |
|
| 869 | - ); |
|
| 870 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 871 | - return array_merge($items, $statuses); |
|
| 872 | - } |
|
| 873 | - |
|
| 874 | - |
|
| 875 | - |
|
| 876 | - /** |
|
| 877 | - * @return EEM_Event |
|
| 878 | - */ |
|
| 879 | - private function _event_model() |
|
| 880 | - { |
|
| 881 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
| 882 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 883 | - } |
|
| 884 | - return $this->_event_model; |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * Adds extra buttons to the WP CPT permalink field row. |
|
| 891 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 892 | - * |
|
| 893 | - * @param string $return the current html |
|
| 894 | - * @param int $id the post id for the page |
|
| 895 | - * @param string $new_title What the title is |
|
| 896 | - * @param string $new_slug what the slug is |
|
| 897 | - * @return string The new html string for the permalink area |
|
| 898 | - */ |
|
| 899 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 900 | - { |
|
| 901 | - //make sure this is only when editing |
|
| 902 | - if ( ! empty($id)) { |
|
| 903 | - $post = get_post($id); |
|
| 904 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 905 | - . esc_html__('Shortcode', 'event_espresso') |
|
| 906 | - . '</a> '; |
|
| 907 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 908 | - . $post->ID |
|
| 909 | - . ']">'; |
|
| 910 | - } |
|
| 911 | - return $return; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - |
|
| 915 | - |
|
| 916 | - /** |
|
| 917 | - * _events_overview_list_table |
|
| 918 | - * This contains the logic for showing the events_overview list |
|
| 919 | - * |
|
| 920 | - * @access protected |
|
| 921 | - * @return void |
|
| 922 | - * @throws \EE_Error |
|
| 923 | - */ |
|
| 924 | - protected function _events_overview_list_table() |
|
| 925 | - { |
|
| 926 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 927 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
| 928 | - ? (array)$this->_template_args['after_list_table'] |
|
| 929 | - : array(); |
|
| 930 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
| 931 | - . EEH_Template::get_button_or_link( |
|
| 932 | - get_post_type_archive_link('espresso_events'), |
|
| 933 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
| 934 | - 'button' |
|
| 935 | - ); |
|
| 936 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 937 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 938 | - 'create_new', |
|
| 939 | - 'add', |
|
| 940 | - array(), |
|
| 941 | - 'add-new-h2' |
|
| 942 | - ); |
|
| 943 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 944 | - } |
|
| 945 | - |
|
| 946 | - |
|
| 947 | - |
|
| 948 | - /** |
|
| 949 | - * this allows for extra misc actions in the default WP publish box |
|
| 950 | - * |
|
| 951 | - * @return void |
|
| 952 | - */ |
|
| 953 | - public function extra_misc_actions_publish_box() |
|
| 954 | - { |
|
| 955 | - $this->_generate_publish_box_extra_content(); |
|
| 956 | - } |
|
| 957 | - |
|
| 958 | - |
|
| 959 | - |
|
| 960 | - /** |
|
| 961 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 962 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
| 963 | - * data. |
|
| 964 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 965 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
| 966 | - * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
| 967 | - * you handle this accordingly. |
|
| 968 | - * |
|
| 969 | - * @access protected |
|
| 970 | - * @abstract |
|
| 971 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 972 | - * @param object $post The post object of the cpt that was saved. |
|
| 973 | - * @return void |
|
| 974 | - */ |
|
| 975 | - protected function _insert_update_cpt_item($post_id, $post) |
|
| 976 | - { |
|
| 977 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 978 | - //get out we're not processing an event save. |
|
| 979 | - return; |
|
| 980 | - } |
|
| 981 | - $event_values = array( |
|
| 982 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
| 983 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
| 984 | - 'EVT_additional_limit' => min( |
|
| 985 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 986 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
| 987 | - ), |
|
| 988 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
| 989 | - ? $this->_req_data['EVT_default_registration_status'] |
|
| 990 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
| 991 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
| 992 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
| 993 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
| 994 | - ? $this->_req_data['timezone_string'] : null, |
|
| 995 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
| 996 | - ? $this->_req_data['externalURL'] : null, |
|
| 997 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
| 998 | - ? $this->_req_data['event_phone'] : null, |
|
| 999 | - ); |
|
| 1000 | - //update event |
|
| 1001 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1002 | - //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1003 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
| 1004 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
| 1005 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
| 1006 | - $event_update_callbacks = apply_filters( |
|
| 1007 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1008 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
| 1009 | - ); |
|
| 1010 | - $att_success = true; |
|
| 1011 | - foreach ($event_update_callbacks as $e_callback) { |
|
| 1012 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
| 1013 | - $att_success = ! $att_success ? $att_success |
|
| 1014 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
| 1015 | - } |
|
| 1016 | - //any errors? |
|
| 1017 | - if ($success && false === $att_success) { |
|
| 1018 | - EE_Error::add_error( |
|
| 1019 | - esc_html__( |
|
| 1020 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1021 | - 'event_espresso' |
|
| 1022 | - ), |
|
| 1023 | - __FILE__, |
|
| 1024 | - __FUNCTION__, |
|
| 1025 | - __LINE__ |
|
| 1026 | - ); |
|
| 1027 | - } else if ($success === false) { |
|
| 1028 | - EE_Error::add_error( |
|
| 1029 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1030 | - __FILE__, |
|
| 1031 | - __FUNCTION__, |
|
| 1032 | - __LINE__ |
|
| 1033 | - ); |
|
| 1034 | - } |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - |
|
| 1038 | - |
|
| 1039 | - /** |
|
| 1040 | - * @see parent::restore_item() |
|
| 1041 | - * @param int $post_id |
|
| 1042 | - * @param int $revision_id |
|
| 1043 | - */ |
|
| 1044 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1045 | - { |
|
| 1046 | - //copy existing event meta to new post |
|
| 1047 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1048 | - if ($post_evt instanceof EE_Event) { |
|
| 1049 | - //meta revision restore |
|
| 1050 | - $post_evt->restore_revision($revision_id); |
|
| 1051 | - //related objs restore |
|
| 1052 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - |
|
| 1057 | - |
|
| 1058 | - /** |
|
| 1059 | - * Attach the venue to the Event |
|
| 1060 | - * |
|
| 1061 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
| 1062 | - * @param array $data The request data from the form |
|
| 1063 | - * @return bool Success or fail. |
|
| 1064 | - */ |
|
| 1065 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
| 1066 | - { |
|
| 1067 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1068 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1069 | - $rows_affected = null; |
|
| 1070 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1071 | - // very important. If we don't have a venue name... |
|
| 1072 | - // then we'll get out because not necessary to create empty venue |
|
| 1073 | - if (empty($data['venue_title'])) { |
|
| 1074 | - return false; |
|
| 1075 | - } |
|
| 1076 | - $venue_array = array( |
|
| 1077 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
| 1078 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1079 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1080 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1081 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
| 1082 | - : null, |
|
| 1083 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1084 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1085 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1086 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1087 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1088 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1089 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1090 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1091 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1092 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1093 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1094 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1095 | - 'status' => 'publish', |
|
| 1096 | - ); |
|
| 1097 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1098 | - if ( ! empty($venue_id)) { |
|
| 1099 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
| 1100 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
| 1101 | - //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
| 1102 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1103 | - return $rows_affected > 0 ? true : false; |
|
| 1104 | - } else { |
|
| 1105 | - //we insert the venue |
|
| 1106 | - $venue_id = $venue_model->insert($venue_array); |
|
| 1107 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1108 | - return ! empty($venue_id) ? true : false; |
|
| 1109 | - } |
|
| 1110 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
| 1111 | - } |
|
| 1112 | - |
|
| 1113 | - |
|
| 1114 | - |
|
| 1115 | - /** |
|
| 1116 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1117 | - * |
|
| 1118 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
| 1119 | - * @param array $data The request data from the form |
|
| 1120 | - * @return array |
|
| 1121 | - */ |
|
| 1122 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
| 1123 | - { |
|
| 1124 | - $success = true; |
|
| 1125 | - $saved_dtt = null; |
|
| 1126 | - $saved_tickets = array(); |
|
| 1127 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1128 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
| 1129 | - //trim all values to ensure any excess whitespace is removed. |
|
| 1130 | - $dtt = array_map('trim', $dtt); |
|
| 1131 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
| 1132 | - : $dtt['DTT_EVT_start']; |
|
| 1133 | - $datetime_values = array( |
|
| 1134 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
| 1135 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
| 1136 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
| 1137 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
| 1138 | - 'DTT_order' => $row, |
|
| 1139 | - ); |
|
| 1140 | - //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
| 1141 | - if ( ! empty($dtt['DTT_ID'])) { |
|
| 1142 | - $DTM = EE_Registry::instance() |
|
| 1143 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
| 1144 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
| 1145 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
| 1146 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
| 1147 | - foreach ($datetime_values as $field => $value) { |
|
| 1148 | - $DTM->set($field, $value); |
|
| 1149 | - } |
|
| 1150 | - //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
| 1151 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
| 1152 | - } else { |
|
| 1153 | - $DTM = EE_Registry::instance()->load_class( |
|
| 1154 | - 'Datetime', |
|
| 1155 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
| 1156 | - false, |
|
| 1157 | - false |
|
| 1158 | - ); |
|
| 1159 | - foreach ($datetime_values as $field => $value) { |
|
| 1160 | - $DTM->set($field, $value); |
|
| 1161 | - } |
|
| 1162 | - } |
|
| 1163 | - $DTM->save(); |
|
| 1164 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
| 1165 | - //load DTT helper |
|
| 1166 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1167 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
| 1168 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
| 1169 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
| 1170 | - $DTT->save(); |
|
| 1171 | - } |
|
| 1172 | - //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
| 1173 | - $saved_dtt = $DTT; |
|
| 1174 | - $success = ! $success ? $success : $DTT; |
|
| 1175 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
| 1176 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
| 1177 | - } |
|
| 1178 | - //no dtts get deleted so we don't do any of that logic here. |
|
| 1179 | - //update tickets next |
|
| 1180 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
| 1181 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
| 1182 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1183 | - $update_prices = false; |
|
| 1184 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
| 1185 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
| 1186 | - // trim inputs to ensure any excess whitespace is removed. |
|
| 1187 | - $tkt = array_map('trim', $tkt); |
|
| 1188 | - if (empty($tkt['TKT_start_date'])) { |
|
| 1189 | - //let's use now in the set timezone. |
|
| 1190 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
| 1191 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1192 | - } |
|
| 1193 | - if (empty($tkt['TKT_end_date'])) { |
|
| 1194 | - //use the start date of the first datetime |
|
| 1195 | - $dtt = $evtobj->first_datetime(); |
|
| 1196 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
| 1197 | - $incoming_date_formats[0], |
|
| 1198 | - $incoming_date_formats[1] |
|
| 1199 | - ); |
|
| 1200 | - } |
|
| 1201 | - $TKT_values = array( |
|
| 1202 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
| 1203 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
| 1204 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
| 1205 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
| 1206 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
| 1207 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
| 1208 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
| 1209 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
| 1210 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
| 1211 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
| 1212 | - 'TKT_row' => $row, |
|
| 1213 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
| 1214 | - 'TKT_price' => $ticket_price, |
|
| 1215 | - ); |
|
| 1216 | - //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
| 1217 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
| 1218 | - $TKT_values['TKT_ID'] = 0; |
|
| 1219 | - $TKT_values['TKT_is_default'] = 0; |
|
| 1220 | - $TKT_values['TKT_price'] = $ticket_price; |
|
| 1221 | - $update_prices = true; |
|
| 1222 | - } |
|
| 1223 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1224 | - //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
| 1225 | - //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1226 | - if ( ! empty($tkt['TKT_ID'])) { |
|
| 1227 | - $TKT = EE_Registry::instance() |
|
| 1228 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
| 1229 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
| 1230 | - if ($TKT instanceof EE_Ticket) { |
|
| 1231 | - $ticket_sold = $TKT->count_related( |
|
| 1232 | - 'Registration', |
|
| 1233 | - array( |
|
| 1234 | - array( |
|
| 1235 | - 'STS_ID' => array( |
|
| 1236 | - 'NOT IN', |
|
| 1237 | - array(EEM_Registration::status_id_incomplete), |
|
| 1238 | - ), |
|
| 1239 | - ), |
|
| 1240 | - ) |
|
| 1241 | - ) > 0 ? true : false; |
|
| 1242 | - //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
| 1243 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
| 1244 | - && ! $TKT->get( |
|
| 1245 | - 'TKT_deleted' |
|
| 1246 | - ) ? true : false; |
|
| 1247 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1248 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1249 | - //set new values |
|
| 1250 | - foreach ($TKT_values as $field => $value) { |
|
| 1251 | - if ($field == 'TKT_qty') { |
|
| 1252 | - $TKT->set_qty($value); |
|
| 1253 | - } else { |
|
| 1254 | - $TKT->set($field, $value); |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
| 1258 | - if ($create_new_TKT) { |
|
| 1259 | - //archive the old ticket first |
|
| 1260 | - $TKT->set('TKT_deleted', 1); |
|
| 1261 | - $TKT->save(); |
|
| 1262 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
| 1263 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1264 | - //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
| 1265 | - $TKT = clone $TKT; |
|
| 1266 | - $TKT->set('TKT_ID', 0); |
|
| 1267 | - $TKT->set('TKT_deleted', 0); |
|
| 1268 | - $TKT->set('TKT_price', $ticket_price); |
|
| 1269 | - $TKT->set('TKT_sold', 0); |
|
| 1270 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1271 | - $update_prices = true; |
|
| 1272 | - } |
|
| 1273 | - //make sure price is set if it hasn't been already |
|
| 1274 | - $TKT->set('TKT_price', $ticket_price); |
|
| 1275 | - } |
|
| 1276 | - } else { |
|
| 1277 | - //no TKT_id so a new TKT |
|
| 1278 | - $TKT_values['TKT_price'] = $ticket_price; |
|
| 1279 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
| 1280 | - if ($TKT instanceof EE_Ticket) { |
|
| 1281 | - //need to reset values to properly account for the date formats |
|
| 1282 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1283 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1284 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
| 1285 | - //set new values |
|
| 1286 | - foreach ($TKT_values as $field => $value) { |
|
| 1287 | - if ($field == 'TKT_qty') { |
|
| 1288 | - $TKT->set_qty($value); |
|
| 1289 | - } else { |
|
| 1290 | - $TKT->set($field, $value); |
|
| 1291 | - } |
|
| 1292 | - } |
|
| 1293 | - $update_prices = true; |
|
| 1294 | - } |
|
| 1295 | - } |
|
| 1296 | - // cap ticket qty by datetime reg limits |
|
| 1297 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
| 1298 | - //update ticket. |
|
| 1299 | - $TKT->save(); |
|
| 1300 | - //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1301 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
| 1302 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
| 1303 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
| 1304 | - $TKT->save(); |
|
| 1305 | - } |
|
| 1306 | - //initially let's add the ticket to the dtt |
|
| 1307 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
| 1308 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1309 | - //add prices to ticket |
|
| 1310 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
| 1311 | - } |
|
| 1312 | - //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1313 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
| 1314 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1315 | - foreach ($tickets_removed as $id) { |
|
| 1316 | - $id = absint($id); |
|
| 1317 | - //get the ticket for this id |
|
| 1318 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
| 1319 | - //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
| 1320 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
| 1321 | - foreach ($dtts as $dtt) { |
|
| 1322 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
| 1323 | - } |
|
| 1324 | - //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1325 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
| 1326 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1327 | - $tkt_to_remove->delete_permanently(); |
|
| 1328 | - } |
|
| 1329 | - return array($saved_dtt, $saved_tickets); |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - |
|
| 1333 | - |
|
| 1334 | - /** |
|
| 1335 | - * This attaches a list of given prices to a ticket. |
|
| 1336 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 1337 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 1338 | - * price info and prices are automatically "archived" via the ticket. |
|
| 1339 | - * |
|
| 1340 | - * @access private |
|
| 1341 | - * @param array $prices Array of prices from the form. |
|
| 1342 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1343 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1344 | - * @return void |
|
| 1345 | - */ |
|
| 1346 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
| 1347 | - { |
|
| 1348 | - foreach ($prices as $row => $prc) { |
|
| 1349 | - $PRC_values = array( |
|
| 1350 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
| 1351 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
| 1352 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
| 1353 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
| 1354 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
| 1355 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
| 1356 | - 'PRC_order' => $row, |
|
| 1357 | - ); |
|
| 1358 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 1359 | - $PRC_values['PRC_ID'] = 0; |
|
| 1360 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
| 1361 | - } else { |
|
| 1362 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
| 1363 | - //update this price with new values |
|
| 1364 | - foreach ($PRC_values as $field => $newprc) { |
|
| 1365 | - $PRC->set($field, $newprc); |
|
| 1366 | - } |
|
| 1367 | - $PRC->save(); |
|
| 1368 | - } |
|
| 1369 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
| 1370 | - } |
|
| 1371 | - } |
|
| 1372 | - |
|
| 1373 | - |
|
| 1374 | - |
|
| 1375 | - /** |
|
| 1376 | - * Add in our autosave ajax handlers |
|
| 1377 | - * |
|
| 1378 | - */ |
|
| 1379 | - protected function _ee_autosave_create_new() |
|
| 1380 | - { |
|
| 1381 | - } |
|
| 1382 | - |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * More autosave handlers. |
|
| 1386 | - */ |
|
| 1387 | - protected function _ee_autosave_edit() |
|
| 1388 | - { |
|
| 1389 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
| 1390 | - } |
|
| 1391 | - |
|
| 1392 | - |
|
| 1393 | - |
|
| 1394 | - /** |
|
| 1395 | - * _generate_publish_box_extra_content |
|
| 1396 | - */ |
|
| 1397 | - private function _generate_publish_box_extra_content() |
|
| 1398 | - { |
|
| 1399 | - //load formatter helper |
|
| 1400 | - //args for getting related registrations |
|
| 1401 | - $approved_query_args = array( |
|
| 1402 | - array( |
|
| 1403 | - 'REG_deleted' => 0, |
|
| 1404 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1405 | - ), |
|
| 1406 | - ); |
|
| 1407 | - $not_approved_query_args = array( |
|
| 1408 | - array( |
|
| 1409 | - 'REG_deleted' => 0, |
|
| 1410 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1411 | - ), |
|
| 1412 | - ); |
|
| 1413 | - $pending_payment_query_args = array( |
|
| 1414 | - array( |
|
| 1415 | - 'REG_deleted' => 0, |
|
| 1416 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1417 | - ), |
|
| 1418 | - ); |
|
| 1419 | - // publish box |
|
| 1420 | - $publish_box_extra_args = array( |
|
| 1421 | - 'view_approved_reg_url' => add_query_arg( |
|
| 1422 | - array( |
|
| 1423 | - 'action' => 'default', |
|
| 1424 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1425 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1426 | - ), |
|
| 1427 | - REG_ADMIN_URL |
|
| 1428 | - ), |
|
| 1429 | - 'view_not_approved_reg_url' => add_query_arg( |
|
| 1430 | - array( |
|
| 1431 | - 'action' => 'default', |
|
| 1432 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1433 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1434 | - ), |
|
| 1435 | - REG_ADMIN_URL |
|
| 1436 | - ), |
|
| 1437 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1438 | - array( |
|
| 1439 | - 'action' => 'default', |
|
| 1440 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1441 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1442 | - ), |
|
| 1443 | - REG_ADMIN_URL |
|
| 1444 | - ), |
|
| 1445 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1446 | - 'Registration', |
|
| 1447 | - $approved_query_args |
|
| 1448 | - ), |
|
| 1449 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1450 | - 'Registration', |
|
| 1451 | - $not_approved_query_args |
|
| 1452 | - ), |
|
| 1453 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1454 | - 'Registration', |
|
| 1455 | - $pending_payment_query_args |
|
| 1456 | - ), |
|
| 1457 | - 'misc_pub_section_class' => apply_filters( |
|
| 1458 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1459 | - 'misc-pub-section' |
|
| 1460 | - ), |
|
| 1461 | - ); |
|
| 1462 | - ob_start(); |
|
| 1463 | - do_action( |
|
| 1464 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1465 | - $this->_cpt_model_obj |
|
| 1466 | - ); |
|
| 1467 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1468 | - // load template |
|
| 1469 | - EEH_Template::display_template( |
|
| 1470 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1471 | - $publish_box_extra_args |
|
| 1472 | - ); |
|
| 1473 | - } |
|
| 1474 | - |
|
| 1475 | - |
|
| 1476 | - |
|
| 1477 | - /** |
|
| 1478 | - * @return EE_Event |
|
| 1479 | - */ |
|
| 1480 | - public function get_event_object() |
|
| 1481 | - { |
|
| 1482 | - return $this->_cpt_model_obj; |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - |
|
| 1486 | - |
|
| 1487 | - |
|
| 1488 | - /** METABOXES * */ |
|
| 1489 | - /** |
|
| 1490 | - * _register_event_editor_meta_boxes |
|
| 1491 | - * add all metaboxes related to the event_editor |
|
| 1492 | - * |
|
| 1493 | - * @return void |
|
| 1494 | - */ |
|
| 1495 | - protected function _register_event_editor_meta_boxes() |
|
| 1496 | - { |
|
| 1497 | - $this->verify_cpt_object(); |
|
| 1498 | - add_meta_box( |
|
| 1499 | - 'espresso_event_editor_tickets', |
|
| 1500 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1501 | - array($this, 'ticket_metabox'), |
|
| 1502 | - $this->page_slug, |
|
| 1503 | - 'normal', |
|
| 1504 | - 'high' |
|
| 1505 | - ); |
|
| 1506 | - add_meta_box( |
|
| 1507 | - 'espresso_event_editor_event_options', |
|
| 1508 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1509 | - array($this, 'registration_options_meta_box'), |
|
| 1510 | - $this->page_slug, |
|
| 1511 | - 'side', |
|
| 1512 | - 'default' |
|
| 1513 | - ); |
|
| 1514 | - // NOTE: if you're looking for other metaboxes in here, |
|
| 1515 | - // where a metabox has a related management page in the admin |
|
| 1516 | - // you will find it setup in the related management page's "_Hooks" file. |
|
| 1517 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - |
|
| 1521 | - /** |
|
| 1522 | - * @throws DomainException |
|
| 1523 | - * @throws EE_Error |
|
| 1524 | - */ |
|
| 1525 | - public function ticket_metabox() |
|
| 1526 | - { |
|
| 1527 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
| 1528 | - //defaults for template args |
|
| 1529 | - $template_args = array( |
|
| 1530 | - 'existing_datetime_ids' => '', |
|
| 1531 | - 'event_datetime_help_link' => '', |
|
| 1532 | - 'ticket_options_help_link' => '', |
|
| 1533 | - 'time' => null, |
|
| 1534 | - 'ticket_rows' => '', |
|
| 1535 | - 'existing_ticket_ids' => '', |
|
| 1536 | - 'total_ticket_rows' => 1, |
|
| 1537 | - 'ticket_js_structure' => '', |
|
| 1538 | - 'trash_icon' => 'ee-lock-icon', |
|
| 1539 | - 'disabled' => '', |
|
| 1540 | - ); |
|
| 1541 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1542 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1543 | - /** |
|
| 1544 | - * 1. Start with retrieving Datetimes |
|
| 1545 | - * 2. Fore each datetime get related tickets |
|
| 1546 | - * 3. For each ticket get related prices |
|
| 1547 | - */ |
|
| 1548 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
| 1549 | - /** @type EE_Datetime $first_datetime */ |
|
| 1550 | - $first_datetime = reset($times); |
|
| 1551 | - //do we get related tickets? |
|
| 1552 | - if ($first_datetime instanceof EE_Datetime |
|
| 1553 | - && $first_datetime->ID() !== 0 |
|
| 1554 | - ) { |
|
| 1555 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1556 | - $template_args['time'] = $first_datetime; |
|
| 1557 | - $related_tickets = $first_datetime->tickets( |
|
| 1558 | - array( |
|
| 1559 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
| 1560 | - 'default_where_conditions' => 'none', |
|
| 1561 | - ) |
|
| 1562 | - ); |
|
| 1563 | - if ( ! empty($related_tickets)) { |
|
| 1564 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1565 | - $row = 0; |
|
| 1566 | - foreach ($related_tickets as $ticket) { |
|
| 1567 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1568 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1569 | - $row++; |
|
| 1570 | - } |
|
| 1571 | - } else { |
|
| 1572 | - $template_args['total_ticket_rows'] = 1; |
|
| 1573 | - /** @type EE_Ticket $ticket */ |
|
| 1574 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
| 1575 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1576 | - } |
|
| 1577 | - } else { |
|
| 1578 | - $template_args['time'] = $times[0]; |
|
| 1579 | - /** @type EE_Ticket $ticket */ |
|
| 1580 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
| 1581 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
| 1582 | - // NOTE: we're just sending the first default row |
|
| 1583 | - // (decaf can't manage default tickets so this should be sufficient); |
|
| 1584 | - } |
|
| 1585 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1586 | - 'event_editor_event_datetimes_help_tab' |
|
| 1587 | - ); |
|
| 1588 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1589 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1590 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1591 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1592 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
| 1593 | - true |
|
| 1594 | - ); |
|
| 1595 | - $template = apply_filters( |
|
| 1596 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1597 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1598 | - ); |
|
| 1599 | - EEH_Template::display_template($template, $template_args); |
|
| 1600 | - } |
|
| 1601 | - |
|
| 1602 | - |
|
| 1603 | - |
|
| 1604 | - /** |
|
| 1605 | - * Setup an individual ticket form for the decaf event editor page |
|
| 1606 | - * |
|
| 1607 | - * @access private |
|
| 1608 | - * @param EE_Ticket $ticket the ticket object |
|
| 1609 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1610 | - * @param int $row |
|
| 1611 | - * @return string generated html for the ticket row. |
|
| 1612 | - */ |
|
| 1613 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1614 | - { |
|
| 1615 | - $template_args = array( |
|
| 1616 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1617 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1618 | - : '', |
|
| 1619 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1620 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1621 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1622 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1623 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1624 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1625 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1626 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1627 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1628 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1629 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1630 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
| 1631 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1632 | - : ' disabled=disabled', |
|
| 1633 | - ); |
|
| 1634 | - $price = $ticket->ID() !== 0 |
|
| 1635 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
| 1636 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
| 1637 | - $price_args = array( |
|
| 1638 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1639 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1640 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1641 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1642 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1643 | - ); |
|
| 1644 | - //make sure we have default start and end dates if skeleton |
|
| 1645 | - //handle rows that should NOT be empty |
|
| 1646 | - if (empty($template_args['TKT_start_date'])) { |
|
| 1647 | - //if empty then the start date will be now. |
|
| 1648 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1649 | - } |
|
| 1650 | - if (empty($template_args['TKT_end_date'])) { |
|
| 1651 | - //get the earliest datetime (if present); |
|
| 1652 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
| 1653 | - ? $this->_cpt_model_obj->get_first_related( |
|
| 1654 | - 'Datetime', |
|
| 1655 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
| 1656 | - ) |
|
| 1657 | - : null; |
|
| 1658 | - if ( ! empty($earliest_dtt)) { |
|
| 1659 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
| 1660 | - } else { |
|
| 1661 | - $template_args['TKT_end_date'] = date( |
|
| 1662 | - 'Y-m-d h:i a', |
|
| 1663 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
| 1664 | - ); |
|
| 1665 | - } |
|
| 1666 | - } |
|
| 1667 | - $template_args = array_merge($template_args, $price_args); |
|
| 1668 | - $template = apply_filters( |
|
| 1669 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1670 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1671 | - $ticket |
|
| 1672 | - ); |
|
| 1673 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 1674 | - } |
|
| 1675 | - |
|
| 1676 | - |
|
| 1677 | - /** |
|
| 1678 | - * @throws DomainException |
|
| 1679 | - */ |
|
| 1680 | - public function registration_options_meta_box() |
|
| 1681 | - { |
|
| 1682 | - $yes_no_values = array( |
|
| 1683 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 1684 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 1685 | - ); |
|
| 1686 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1687 | - array( |
|
| 1688 | - EEM_Registration::status_id_cancelled, |
|
| 1689 | - EEM_Registration::status_id_declined, |
|
| 1690 | - EEM_Registration::status_id_incomplete, |
|
| 1691 | - ), |
|
| 1692 | - true |
|
| 1693 | - ); |
|
| 1694 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1695 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1696 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1697 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1698 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1699 | - 'default_reg_status', |
|
| 1700 | - $default_reg_status_values, |
|
| 1701 | - $this->_cpt_model_obj->default_registration_status() |
|
| 1702 | - ); |
|
| 1703 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1704 | - 'display_desc', |
|
| 1705 | - $yes_no_values, |
|
| 1706 | - $this->_cpt_model_obj->display_description() |
|
| 1707 | - ); |
|
| 1708 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1709 | - 'display_ticket_selector', |
|
| 1710 | - $yes_no_values, |
|
| 1711 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1712 | - '', |
|
| 1713 | - '', |
|
| 1714 | - false |
|
| 1715 | - ); |
|
| 1716 | - $template_args['additional_registration_options'] = apply_filters( |
|
| 1717 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1718 | - '', |
|
| 1719 | - $template_args, |
|
| 1720 | - $yes_no_values, |
|
| 1721 | - $default_reg_status_values |
|
| 1722 | - ); |
|
| 1723 | - EEH_Template::display_template( |
|
| 1724 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1725 | - $template_args |
|
| 1726 | - ); |
|
| 1727 | - } |
|
| 1728 | - |
|
| 1729 | - |
|
| 1730 | - |
|
| 1731 | - /** |
|
| 1732 | - * _get_events() |
|
| 1733 | - * This method simply returns all the events (for the given _view and paging) |
|
| 1734 | - * |
|
| 1735 | - * @access public |
|
| 1736 | - * @param int $per_page count of items per page (20 default); |
|
| 1737 | - * @param int $current_page what is the current page being viewed. |
|
| 1738 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1739 | - * If FALSE then we return an array of event objects |
|
| 1740 | - * that match the given _view and paging parameters. |
|
| 1741 | - * @return array an array of event objects. |
|
| 1742 | - */ |
|
| 1743 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1744 | - { |
|
| 1745 | - $EEME = $this->_event_model(); |
|
| 1746 | - $offset = ($current_page - 1) * $per_page; |
|
| 1747 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1748 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
| 1749 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
| 1750 | - if (isset($this->_req_data['month_range'])) { |
|
| 1751 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
| 1752 | - //simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1753 | - //where PHP doesn't know what to assume for date. |
|
| 1754 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1755 | - $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1756 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1757 | - } |
|
| 1758 | - $where = array(); |
|
| 1759 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 1760 | - //determine what post_status our condition will have for the query. |
|
| 1761 | - switch ($status) { |
|
| 1762 | - case 'month' : |
|
| 1763 | - case 'today' : |
|
| 1764 | - case null : |
|
| 1765 | - case 'all' : |
|
| 1766 | - break; |
|
| 1767 | - case 'draft' : |
|
| 1768 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
| 1769 | - break; |
|
| 1770 | - default : |
|
| 1771 | - $where['status'] = $status; |
|
| 1772 | - } |
|
| 1773 | - //categories? |
|
| 1774 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 1775 | - ? $this->_req_data['EVT_CAT'] : null; |
|
| 1776 | - if ( ! empty ($category)) { |
|
| 1777 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1778 | - $where['Term_Taxonomy.term_id'] = $category; |
|
| 1779 | - } |
|
| 1780 | - //date where conditions |
|
| 1781 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1782 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
| 1783 | - $DateTime = new DateTime( |
|
| 1784 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1785 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
| 1786 | - ); |
|
| 1787 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
| 1788 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
| 1789 | - ->format('t'))->setTime(23, 59, 59) |
|
| 1790 | - ->format(implode(' ', $start_formats)); |
|
| 1791 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1792 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
| 1793 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1794 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1795 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1796 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1797 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
| 1798 | - $now = date('Y-m-01'); |
|
| 1799 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1800 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1801 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1802 | - ->setTime(23, 59, 59) |
|
| 1803 | - ->format(implode(' ', $start_formats)); |
|
| 1804 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1805 | - } |
|
| 1806 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1807 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1808 | - } else { |
|
| 1809 | - if ( ! isset($where['status'])) { |
|
| 1810 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1811 | - $where['OR'] = array( |
|
| 1812 | - 'status*restrict_private' => array('!=', 'private'), |
|
| 1813 | - 'AND' => array( |
|
| 1814 | - 'status*inclusive' => array('=', 'private'), |
|
| 1815 | - 'EVT_wp_user' => get_current_user_id(), |
|
| 1816 | - ), |
|
| 1817 | - ); |
|
| 1818 | - } |
|
| 1819 | - } |
|
| 1820 | - } |
|
| 1821 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
| 1822 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
| 1823 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 1824 | - ) { |
|
| 1825 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
| 1826 | - } |
|
| 1827 | - } |
|
| 1828 | - //search query handling |
|
| 1829 | - if (isset($this->_req_data['s'])) { |
|
| 1830 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1831 | - $where['OR'] = array( |
|
| 1832 | - 'EVT_name' => array('LIKE', $search_string), |
|
| 1833 | - 'EVT_desc' => array('LIKE', $search_string), |
|
| 1834 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
| 1835 | - ); |
|
| 1836 | - } |
|
| 1837 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
| 1838 | - $query_params = apply_filters( |
|
| 1839 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 1840 | - array( |
|
| 1841 | - $where, |
|
| 1842 | - 'limit' => $limit, |
|
| 1843 | - 'order_by' => $orderby, |
|
| 1844 | - 'order' => $order, |
|
| 1845 | - 'group_by' => 'EVT_ID', |
|
| 1846 | - ), |
|
| 1847 | - $this->_req_data |
|
| 1848 | - ); |
|
| 1849 | - //let's first check if we have special requests coming in. |
|
| 1850 | - if (isset($this->_req_data['active_status'])) { |
|
| 1851 | - switch ($this->_req_data['active_status']) { |
|
| 1852 | - case 'upcoming' : |
|
| 1853 | - return $EEME->get_upcoming_events($query_params, $count); |
|
| 1854 | - break; |
|
| 1855 | - case 'expired' : |
|
| 1856 | - return $EEME->get_expired_events($query_params, $count); |
|
| 1857 | - break; |
|
| 1858 | - case 'active' : |
|
| 1859 | - return $EEME->get_active_events($query_params, $count); |
|
| 1860 | - break; |
|
| 1861 | - case 'inactive' : |
|
| 1862 | - return $EEME->get_inactive_events($query_params, $count); |
|
| 1863 | - break; |
|
| 1864 | - } |
|
| 1865 | - } |
|
| 1866 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
| 1867 | - return $events; |
|
| 1868 | - } |
|
| 1869 | - |
|
| 1870 | - |
|
| 1871 | - |
|
| 1872 | - /** |
|
| 1873 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
| 1874 | - * |
|
| 1875 | - * @param string $post_id |
|
| 1876 | - */ |
|
| 1877 | - public function trash_cpt_item($post_id) |
|
| 1878 | - { |
|
| 1879 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1880 | - $this->_trash_or_restore_event('trash', false); |
|
| 1881 | - } |
|
| 1882 | - |
|
| 1883 | - |
|
| 1884 | - |
|
| 1885 | - /** |
|
| 1886 | - * @param string $post_id |
|
| 1887 | - */ |
|
| 1888 | - public function restore_cpt_item($post_id) |
|
| 1889 | - { |
|
| 1890 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1891 | - $this->_trash_or_restore_event('draft', false); |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - |
|
| 1895 | - |
|
| 1896 | - /** |
|
| 1897 | - * @param string $post_id |
|
| 1898 | - */ |
|
| 1899 | - public function delete_cpt_item($post_id) |
|
| 1900 | - { |
|
| 1901 | - $this->_req_data['EVT_ID'] = $post_id; |
|
| 1902 | - $this->_delete_event(false); |
|
| 1903 | - } |
|
| 1904 | - |
|
| 1905 | - |
|
| 1906 | - |
|
| 1907 | - /** |
|
| 1908 | - * _trash_or_restore_event |
|
| 1909 | - * |
|
| 1910 | - * @access protected |
|
| 1911 | - * @param string $event_status |
|
| 1912 | - * @param bool $redirect_after |
|
| 1913 | - */ |
|
| 1914 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 1915 | - { |
|
| 1916 | - //determine the event id and set to array. |
|
| 1917 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
| 1918 | - // loop thru events |
|
| 1919 | - if ($EVT_ID) { |
|
| 1920 | - // clean status |
|
| 1921 | - $event_status = sanitize_key($event_status); |
|
| 1922 | - // grab status |
|
| 1923 | - if ( ! empty($event_status)) { |
|
| 1924 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1925 | - } else { |
|
| 1926 | - $success = false; |
|
| 1927 | - $msg = esc_html__( |
|
| 1928 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1929 | - 'event_espresso' |
|
| 1930 | - ); |
|
| 1931 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1932 | - } |
|
| 1933 | - } else { |
|
| 1934 | - $success = false; |
|
| 1935 | - $msg = esc_html__( |
|
| 1936 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1937 | - 'event_espresso' |
|
| 1938 | - ); |
|
| 1939 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1940 | - } |
|
| 1941 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1942 | - if ($redirect_after) { |
|
| 1943 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
| 1944 | - } |
|
| 1945 | - } |
|
| 1946 | - |
|
| 1947 | - |
|
| 1948 | - |
|
| 1949 | - /** |
|
| 1950 | - * _trash_or_restore_events |
|
| 1951 | - * |
|
| 1952 | - * @access protected |
|
| 1953 | - * @param string $event_status |
|
| 1954 | - * @return void |
|
| 1955 | - */ |
|
| 1956 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
| 1957 | - { |
|
| 1958 | - // clean status |
|
| 1959 | - $event_status = sanitize_key($event_status); |
|
| 1960 | - // grab status |
|
| 1961 | - if ( ! empty($event_status)) { |
|
| 1962 | - $success = true; |
|
| 1963 | - //determine the event id and set to array. |
|
| 1964 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1965 | - // loop thru events |
|
| 1966 | - foreach ($EVT_IDs as $EVT_ID) { |
|
| 1967 | - if ($EVT_ID = absint($EVT_ID)) { |
|
| 1968 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1969 | - $success = $results !== false ? $success : false; |
|
| 1970 | - } else { |
|
| 1971 | - $msg = sprintf( |
|
| 1972 | - esc_html__( |
|
| 1973 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1974 | - 'event_espresso' |
|
| 1975 | - ), |
|
| 1976 | - $EVT_ID |
|
| 1977 | - ); |
|
| 1978 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1979 | - $success = false; |
|
| 1980 | - } |
|
| 1981 | - } |
|
| 1982 | - } else { |
|
| 1983 | - $success = false; |
|
| 1984 | - $msg = esc_html__( |
|
| 1985 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1986 | - 'event_espresso' |
|
| 1987 | - ); |
|
| 1988 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1989 | - } |
|
| 1990 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 1991 | - $success = $success ? 2 : false; |
|
| 1992 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1993 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
| 1994 | - } |
|
| 1995 | - |
|
| 1996 | - |
|
| 1997 | - |
|
| 1998 | - /** |
|
| 1999 | - * _trash_or_restore_events |
|
| 2000 | - * |
|
| 2001 | - * @access private |
|
| 2002 | - * @param int $EVT_ID |
|
| 2003 | - * @param string $event_status |
|
| 2004 | - * @return bool |
|
| 2005 | - */ |
|
| 2006 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2007 | - { |
|
| 2008 | - // grab event id |
|
| 2009 | - if ( ! $EVT_ID) { |
|
| 2010 | - $msg = esc_html__( |
|
| 2011 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2012 | - 'event_espresso' |
|
| 2013 | - ); |
|
| 2014 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2015 | - return false; |
|
| 2016 | - } |
|
| 2017 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2018 | - // clean status |
|
| 2019 | - $event_status = sanitize_key($event_status); |
|
| 2020 | - // grab status |
|
| 2021 | - if (empty($event_status)) { |
|
| 2022 | - $msg = esc_html__( |
|
| 2023 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2024 | - 'event_espresso' |
|
| 2025 | - ); |
|
| 2026 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2027 | - return false; |
|
| 2028 | - } |
|
| 2029 | - // was event trashed or restored ? |
|
| 2030 | - switch ($event_status) { |
|
| 2031 | - case 'draft' : |
|
| 2032 | - $action = 'restored from the trash'; |
|
| 2033 | - $hook = 'AHEE_event_restored_from_trash'; |
|
| 2034 | - break; |
|
| 2035 | - case 'trash' : |
|
| 2036 | - $action = 'moved to the trash'; |
|
| 2037 | - $hook = 'AHEE_event_moved_to_trash'; |
|
| 2038 | - break; |
|
| 2039 | - default : |
|
| 2040 | - $action = 'updated'; |
|
| 2041 | - $hook = false; |
|
| 2042 | - } |
|
| 2043 | - //use class to change status |
|
| 2044 | - $this->_cpt_model_obj->set_status($event_status); |
|
| 2045 | - $success = $this->_cpt_model_obj->save(); |
|
| 2046 | - if ($success === false) { |
|
| 2047 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2048 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2049 | - return false; |
|
| 2050 | - } |
|
| 2051 | - if ($hook) { |
|
| 2052 | - do_action($hook); |
|
| 2053 | - } |
|
| 2054 | - return true; |
|
| 2055 | - } |
|
| 2056 | - |
|
| 2057 | - |
|
| 2058 | - |
|
| 2059 | - /** |
|
| 2060 | - * _delete_event |
|
| 2061 | - * |
|
| 2062 | - * @access protected |
|
| 2063 | - * @param bool $redirect_after |
|
| 2064 | - */ |
|
| 2065 | - protected function _delete_event($redirect_after = true) |
|
| 2066 | - { |
|
| 2067 | - //determine the event id and set to array. |
|
| 2068 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
| 2069 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
| 2070 | - // loop thru events |
|
| 2071 | - if ($EVT_ID) { |
|
| 2072 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
| 2073 | - // get list of events with no prices |
|
| 2074 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2075 | - // remove this event from the list of events with no prices |
|
| 2076 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
| 2077 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2078 | - } |
|
| 2079 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2080 | - } else { |
|
| 2081 | - $success = false; |
|
| 2082 | - $msg = esc_html__( |
|
| 2083 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2084 | - 'event_espresso' |
|
| 2085 | - ); |
|
| 2086 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2087 | - } |
|
| 2088 | - if ($redirect_after) { |
|
| 2089 | - $this->_redirect_after_action( |
|
| 2090 | - $success, |
|
| 2091 | - 'Event', |
|
| 2092 | - 'deleted', |
|
| 2093 | - array('action' => 'default', 'status' => 'trash') |
|
| 2094 | - ); |
|
| 2095 | - } |
|
| 2096 | - } |
|
| 2097 | - |
|
| 2098 | - |
|
| 2099 | - |
|
| 2100 | - /** |
|
| 2101 | - * _delete_events |
|
| 2102 | - * |
|
| 2103 | - * @access protected |
|
| 2104 | - * @return void |
|
| 2105 | - */ |
|
| 2106 | - protected function _delete_events() |
|
| 2107 | - { |
|
| 2108 | - $success = true; |
|
| 2109 | - // get list of events with no prices |
|
| 2110 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2111 | - //determine the event id and set to array. |
|
| 2112 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2113 | - // loop thru events |
|
| 2114 | - foreach ($EVT_IDs as $EVT_ID) { |
|
| 2115 | - $EVT_ID = absint($EVT_ID); |
|
| 2116 | - if ($EVT_ID) { |
|
| 2117 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
| 2118 | - $success = $results !== false ? $success : false; |
|
| 2119 | - // remove this event from the list of events with no prices |
|
| 2120 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2121 | - } else { |
|
| 2122 | - $success = false; |
|
| 2123 | - $msg = esc_html__( |
|
| 2124 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2125 | - 'event_espresso' |
|
| 2126 | - ); |
|
| 2127 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2128 | - } |
|
| 2129 | - } |
|
| 2130 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2131 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2132 | - $success = $success ? 2 : false; |
|
| 2133 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
| 2134 | - } |
|
| 2135 | - |
|
| 2136 | - |
|
| 2137 | - |
|
| 2138 | - /** |
|
| 2139 | - * _permanently_delete_event |
|
| 2140 | - * |
|
| 2141 | - * @access private |
|
| 2142 | - * @param int $EVT_ID |
|
| 2143 | - * @return bool |
|
| 2144 | - */ |
|
| 2145 | - private function _permanently_delete_event($EVT_ID = 0) |
|
| 2146 | - { |
|
| 2147 | - // grab event id |
|
| 2148 | - if ( ! $EVT_ID) { |
|
| 2149 | - $msg = esc_html__( |
|
| 2150 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2151 | - 'event_espresso' |
|
| 2152 | - ); |
|
| 2153 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2154 | - return false; |
|
| 2155 | - } |
|
| 2156 | - if ( |
|
| 2157 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
| 2158 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
| 2159 | - ) { |
|
| 2160 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2161 | - } |
|
| 2162 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
| 2163 | - return false; |
|
| 2164 | - } |
|
| 2165 | - //need to delete related tickets and prices first. |
|
| 2166 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
| 2167 | - foreach ($datetimes as $datetime) { |
|
| 2168 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
| 2169 | - $tickets = $datetime->get_many_related('Ticket'); |
|
| 2170 | - foreach ($tickets as $ticket) { |
|
| 2171 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
| 2172 | - $ticket->delete_related_permanently('Price'); |
|
| 2173 | - $ticket->delete_permanently(); |
|
| 2174 | - } |
|
| 2175 | - $datetime->delete(); |
|
| 2176 | - } |
|
| 2177 | - //what about related venues or terms? |
|
| 2178 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
| 2179 | - foreach ($venues as $venue) { |
|
| 2180 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
| 2181 | - } |
|
| 2182 | - //any attached question groups? |
|
| 2183 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
| 2184 | - if ( ! empty($question_groups)) { |
|
| 2185 | - foreach ($question_groups as $question_group) { |
|
| 2186 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
| 2187 | - } |
|
| 2188 | - } |
|
| 2189 | - //Message Template Groups |
|
| 2190 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
| 2191 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
| 2192 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
| 2193 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
| 2194 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
| 2195 | - } |
|
| 2196 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
| 2197 | - // did it all go as planned ? |
|
| 2198 | - if ($success) { |
|
| 2199 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
| 2200 | - EE_Error::add_success($msg); |
|
| 2201 | - } else { |
|
| 2202 | - $msg = sprintf( |
|
| 2203 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
| 2204 | - $EVT_ID |
|
| 2205 | - ); |
|
| 2206 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2207 | - return false; |
|
| 2208 | - } |
|
| 2209 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
| 2210 | - return true; |
|
| 2211 | - } |
|
| 2212 | - |
|
| 2213 | - |
|
| 2214 | - |
|
| 2215 | - /** |
|
| 2216 | - * get total number of events |
|
| 2217 | - * |
|
| 2218 | - * @access public |
|
| 2219 | - * @return int |
|
| 2220 | - */ |
|
| 2221 | - public function total_events() |
|
| 2222 | - { |
|
| 2223 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2224 | - return $count; |
|
| 2225 | - } |
|
| 2226 | - |
|
| 2227 | - |
|
| 2228 | - |
|
| 2229 | - /** |
|
| 2230 | - * get total number of draft events |
|
| 2231 | - * |
|
| 2232 | - * @access public |
|
| 2233 | - * @return int |
|
| 2234 | - */ |
|
| 2235 | - public function total_events_draft() |
|
| 2236 | - { |
|
| 2237 | - $where = array( |
|
| 2238 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
| 2239 | - ); |
|
| 2240 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2241 | - return $count; |
|
| 2242 | - } |
|
| 2243 | - |
|
| 2244 | - |
|
| 2245 | - |
|
| 2246 | - /** |
|
| 2247 | - * get total number of trashed events |
|
| 2248 | - * |
|
| 2249 | - * @access public |
|
| 2250 | - * @return int |
|
| 2251 | - */ |
|
| 2252 | - public function total_trashed_events() |
|
| 2253 | - { |
|
| 2254 | - $where = array( |
|
| 2255 | - 'status' => 'trash', |
|
| 2256 | - ); |
|
| 2257 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2258 | - return $count; |
|
| 2259 | - } |
|
| 2260 | - |
|
| 2261 | - |
|
| 2262 | - /** |
|
| 2263 | - * _default_event_settings |
|
| 2264 | - * This generates the Default Settings Tab |
|
| 2265 | - * |
|
| 2266 | - * @return void |
|
| 2267 | - * @throws EE_Error |
|
| 2268 | - */ |
|
| 2269 | - protected function _default_event_settings() |
|
| 2270 | - { |
|
| 2271 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2272 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2273 | - $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html(); |
|
| 2274 | - $this->display_admin_page_with_sidebar(); |
|
| 2275 | - } |
|
| 2276 | - |
|
| 2277 | - |
|
| 2278 | - /** |
|
| 2279 | - * Return the form for event settings. |
|
| 2280 | - * @return EE_Form_Section_Proper |
|
| 2281 | - */ |
|
| 2282 | - protected function _default_event_settings_form() |
|
| 2283 | - { |
|
| 2284 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2285 | - $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2286 | - //exclude |
|
| 2287 | - array( |
|
| 2288 | - EEM_Registration::status_id_cancelled, |
|
| 2289 | - EEM_Registration::status_id_declined, |
|
| 2290 | - EEM_Registration::status_id_incomplete, |
|
| 2291 | - EEM_Registration::status_id_wait_list, |
|
| 2292 | - ), |
|
| 2293 | - true |
|
| 2294 | - ); |
|
| 2295 | - return new EE_Form_Section_Proper( |
|
| 2296 | - array( |
|
| 2297 | - 'name' => 'update_default_event_settings', |
|
| 2298 | - 'html_id' => 'update_default_event_settings', |
|
| 2299 | - 'html_class' => 'form-table', |
|
| 2300 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2301 | - 'subsections' => apply_filters( |
|
| 2302 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2303 | - array( |
|
| 2304 | - 'default_reg_status' => new EE_Select_Input( |
|
| 2305 | - $registration_stati_for_selection, |
|
| 2306 | - array( |
|
| 2307 | - 'default' => isset($registration_config->default_STS_ID) |
|
| 2308 | - && array_key_exists( |
|
| 2309 | - $registration_config->default_STS_ID, |
|
| 2310 | - $registration_stati_for_selection |
|
| 2311 | - ) |
|
| 2312 | - ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2313 | - : EEM_Registration::status_id_pending_payment, |
|
| 2314 | - 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2315 | - . EEH_Template::get_help_tab_link( |
|
| 2316 | - 'default_settings_status_help_tab' |
|
| 2317 | - ), |
|
| 2318 | - 'html_help_text' => esc_html__( |
|
| 2319 | - 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2320 | - 'event_espresso' |
|
| 2321 | - ) |
|
| 2322 | - ) |
|
| 2323 | - ), |
|
| 2324 | - 'default_max_tickets' => new EE_Integer_Input( |
|
| 2325 | - array( |
|
| 2326 | - 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2327 | - ? $registration_config->default_maximum_number_of_tickets |
|
| 2328 | - : EEM_Event::get_default_additional_limit(), |
|
| 2329 | - 'html_label_text' => esc_html__( |
|
| 2330 | - 'Default Maximum Tickets Allowed Per Order:', |
|
| 2331 | - 'event_espresso' |
|
| 2332 | - ) . EEH_Template::get_help_tab_link( |
|
| 2333 | - 'default_maximum_tickets_help_tab"' |
|
| 2334 | - ), |
|
| 2335 | - 'html_help_text' => esc_html__( |
|
| 2336 | - 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2337 | - 'event_espresso' |
|
| 2338 | - ) |
|
| 2339 | - ) |
|
| 2340 | - ) |
|
| 2341 | - ) |
|
| 2342 | - ) |
|
| 2343 | - ) |
|
| 2344 | - ); |
|
| 2345 | - } |
|
| 2346 | - |
|
| 2347 | - |
|
| 2348 | - /** |
|
| 2349 | - * _update_default_event_settings |
|
| 2350 | - * |
|
| 2351 | - * @access protected |
|
| 2352 | - * @return void |
|
| 2353 | - * @throws EE_Error |
|
| 2354 | - */ |
|
| 2355 | - protected function _update_default_event_settings() |
|
| 2356 | - { |
|
| 2357 | - $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2358 | - $form = $this->_default_event_settings_form(); |
|
| 2359 | - if ($form->was_submitted()) { |
|
| 2360 | - $form->receive_form_submission(); |
|
| 2361 | - if ($form->is_valid()) { |
|
| 2362 | - $valid_data = $form->valid_data(); |
|
| 2363 | - if (isset($valid_data['default_reg_status'])) { |
|
| 2364 | - $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2365 | - } |
|
| 2366 | - if (isset($valid_data['default_max_tickets'])) { |
|
| 2367 | - $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2368 | - } |
|
| 2369 | - //update because data was valid! |
|
| 2370 | - EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2371 | - EE_Error::overwrite_success(); |
|
| 2372 | - EE_Error::add_success( |
|
| 2373 | - __('Default Event Settings were updated', 'event_espresso') |
|
| 2374 | - ); |
|
| 2375 | - } |
|
| 2376 | - } |
|
| 2377 | - $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); |
|
| 2378 | - } |
|
| 2379 | - |
|
| 2380 | - |
|
| 2381 | - |
|
| 2382 | - /************* Templates *************/ |
|
| 2383 | - protected function _template_settings() |
|
| 2384 | - { |
|
| 2385 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2386 | - $this->_template_args['preview_img'] = '<img src="' |
|
| 2387 | - . EVENTS_ASSETS_URL |
|
| 2388 | - . DS |
|
| 2389 | - . 'images' |
|
| 2390 | - . DS |
|
| 2391 | - . 'caffeinated_template_features.jpg" alt="' |
|
| 2392 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2393 | - . '" />'; |
|
| 2394 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2395 | - 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2396 | - 'event_espresso' |
|
| 2397 | - ) . '</strong>'; |
|
| 2398 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2399 | - } |
|
| 2400 | - |
|
| 2401 | - |
|
| 2402 | - /** Event Category Stuff **/ |
|
| 2403 | - /** |
|
| 2404 | - * set the _category property with the category object for the loaded page. |
|
| 2405 | - * |
|
| 2406 | - * @access private |
|
| 2407 | - * @return void |
|
| 2408 | - */ |
|
| 2409 | - private function _set_category_object() |
|
| 2410 | - { |
|
| 2411 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2412 | - return; |
|
| 2413 | - } //already have the category object so get out. |
|
| 2414 | - //set default category object |
|
| 2415 | - $this->_set_empty_category_object(); |
|
| 2416 | - //only set if we've got an id |
|
| 2417 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
| 2418 | - return; |
|
| 2419 | - } |
|
| 2420 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
| 2421 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
| 2422 | - if ( ! empty($term)) { |
|
| 2423 | - $this->_category->category_name = $term->name; |
|
| 2424 | - $this->_category->category_identifier = $term->slug; |
|
| 2425 | - $this->_category->category_desc = $term->description; |
|
| 2426 | - $this->_category->id = $term->term_id; |
|
| 2427 | - $this->_category->parent = $term->parent; |
|
| 2428 | - } |
|
| 2429 | - } |
|
| 2430 | - |
|
| 2431 | - |
|
| 2432 | - /** |
|
| 2433 | - * Clears out category properties. |
|
| 2434 | - */ |
|
| 2435 | - private function _set_empty_category_object() |
|
| 2436 | - { |
|
| 2437 | - $this->_category = new stdClass(); |
|
| 2438 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2439 | - $this->_category->id = $this->_category->parent = 0; |
|
| 2440 | - } |
|
| 2441 | - |
|
| 2442 | - |
|
| 2443 | - /** |
|
| 2444 | - * @throws EE_Error |
|
| 2445 | - */ |
|
| 2446 | - protected function _category_list_table() |
|
| 2447 | - { |
|
| 2448 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2449 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2450 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2451 | - 'add_category', |
|
| 2452 | - 'add_category', |
|
| 2453 | - array(), |
|
| 2454 | - 'add-new-h2' |
|
| 2455 | - ); |
|
| 2456 | - $this->display_admin_list_table_page_with_sidebar(); |
|
| 2457 | - } |
|
| 2458 | - |
|
| 2459 | - |
|
| 2460 | - |
|
| 2461 | - /** |
|
| 2462 | - * Output category details view. |
|
| 2463 | - */ |
|
| 2464 | - protected function _category_details($view) |
|
| 2465 | - { |
|
| 2466 | - //load formatter helper |
|
| 2467 | - //load field generator helper |
|
| 2468 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
| 2469 | - $this->_set_add_edit_form_tags($route); |
|
| 2470 | - $this->_set_category_object(); |
|
| 2471 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2472 | - $delete_action = 'delete_category'; |
|
| 2473 | - //custom redirect |
|
| 2474 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2475 | - array('action' => 'category_list'), |
|
| 2476 | - $this->_admin_base_url |
|
| 2477 | - ); |
|
| 2478 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2479 | - //take care of contents |
|
| 2480 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2481 | - $this->display_admin_page_with_sidebar(); |
|
| 2482 | - } |
|
| 2483 | - |
|
| 2484 | - |
|
| 2485 | - |
|
| 2486 | - /** |
|
| 2487 | - * Output category details content. |
|
| 2488 | - */ |
|
| 2489 | - protected function _category_details_content() |
|
| 2490 | - { |
|
| 2491 | - $editor_args['category_desc'] = array( |
|
| 2492 | - 'type' => 'wp_editor', |
|
| 2493 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2494 | - 'class' => 'my_editor_custom', |
|
| 2495 | - 'wpeditor_args' => array('media_buttons' => false), |
|
| 2496 | - ); |
|
| 2497 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2498 | - $all_terms = get_terms( |
|
| 2499 | - array('espresso_event_categories'), |
|
| 2500 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
| 2501 | - ); |
|
| 2502 | - //setup category select for term parents. |
|
| 2503 | - $category_select_values[] = array( |
|
| 2504 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2505 | - 'id' => 0, |
|
| 2506 | - ); |
|
| 2507 | - foreach ($all_terms as $term) { |
|
| 2508 | - $category_select_values[] = array( |
|
| 2509 | - 'text' => $term->name, |
|
| 2510 | - 'id' => $term->term_id, |
|
| 2511 | - ); |
|
| 2512 | - } |
|
| 2513 | - $category_select = EEH_Form_Fields::select_input( |
|
| 2514 | - 'category_parent', |
|
| 2515 | - $category_select_values, |
|
| 2516 | - $this->_category->parent |
|
| 2517 | - ); |
|
| 2518 | - $template_args = array( |
|
| 2519 | - 'category' => $this->_category, |
|
| 2520 | - 'category_select' => $category_select, |
|
| 2521 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2522 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2523 | - 'disable' => '', |
|
| 2524 | - 'disabled_message' => false, |
|
| 2525 | - ); |
|
| 2526 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2527 | - return EEH_Template::display_template($template, $template_args, true); |
|
| 2528 | - } |
|
| 2529 | - |
|
| 2530 | - |
|
| 2531 | - /** |
|
| 2532 | - * Handles deleting categories. |
|
| 2533 | - */ |
|
| 2534 | - protected function _delete_categories() |
|
| 2535 | - { |
|
| 2536 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2537 | - : (array)$this->_req_data['category_id']; |
|
| 2538 | - foreach ($cat_ids as $cat_id) { |
|
| 2539 | - $this->_delete_category($cat_id); |
|
| 2540 | - } |
|
| 2541 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2542 | - $query_args = array( |
|
| 2543 | - 'action' => 'category_list', |
|
| 2544 | - ); |
|
| 2545 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2546 | - } |
|
| 2547 | - |
|
| 2548 | - |
|
| 2549 | - |
|
| 2550 | - /** |
|
| 2551 | - * Handles deleting specific category. |
|
| 2552 | - * @param int $cat_id |
|
| 2553 | - */ |
|
| 2554 | - protected function _delete_category($cat_id) |
|
| 2555 | - { |
|
| 2556 | - $cat_id = absint($cat_id); |
|
| 2557 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
| 2558 | - } |
|
| 2559 | - |
|
| 2560 | - |
|
| 2561 | - |
|
| 2562 | - /** |
|
| 2563 | - * Handles triggering the update or insertion of a new category. |
|
| 2564 | - * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2565 | - */ |
|
| 2566 | - protected function _insert_or_update_category($new_category) |
|
| 2567 | - { |
|
| 2568 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2569 | - $success = 0; //we already have a success message so lets not send another. |
|
| 2570 | - if ($cat_id) { |
|
| 2571 | - $query_args = array( |
|
| 2572 | - 'action' => 'edit_category', |
|
| 2573 | - 'EVT_CAT_ID' => $cat_id, |
|
| 2574 | - ); |
|
| 2575 | - } else { |
|
| 2576 | - $query_args = array('action' => 'add_category'); |
|
| 2577 | - } |
|
| 2578 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2579 | - } |
|
| 2580 | - |
|
| 2581 | - |
|
| 2582 | - |
|
| 2583 | - /** |
|
| 2584 | - * Inserts or updates category |
|
| 2585 | - * @param bool $update (true indicates we're updating a category). |
|
| 2586 | - * @return bool|mixed|string |
|
| 2587 | - */ |
|
| 2588 | - private function _insert_category($update = false) |
|
| 2589 | - { |
|
| 2590 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
| 2591 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
| 2592 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
| 2593 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
| 2594 | - if (empty($category_name)) { |
|
| 2595 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2596 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2597 | - return false; |
|
| 2598 | - } |
|
| 2599 | - $term_args = array( |
|
| 2600 | - 'name' => $category_name, |
|
| 2601 | - 'description' => $category_desc, |
|
| 2602 | - 'parent' => $category_parent, |
|
| 2603 | - ); |
|
| 2604 | - //was the category_identifier input disabled? |
|
| 2605 | - if (isset($this->_req_data['category_identifier'])) { |
|
| 2606 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
| 2607 | - } |
|
| 2608 | - $insert_ids = $update |
|
| 2609 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
| 2610 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
| 2611 | - if ( ! is_array($insert_ids)) { |
|
| 2612 | - $msg = esc_html__( |
|
| 2613 | - 'An error occurred and the category has not been saved to the database.', |
|
| 2614 | - 'event_espresso' |
|
| 2615 | - ); |
|
| 2616 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2617 | - } else { |
|
| 2618 | - $cat_id = $insert_ids['term_id']; |
|
| 2619 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
| 2620 | - EE_Error::add_success($msg); |
|
| 2621 | - } |
|
| 2622 | - return $cat_id; |
|
| 2623 | - } |
|
| 2624 | - |
|
| 2625 | - |
|
| 2626 | - |
|
| 2627 | - /** |
|
| 2628 | - * Gets categories or count of categories matching the arguments in the request. |
|
| 2629 | - * @param int $per_page |
|
| 2630 | - * @param int $current_page |
|
| 2631 | - * @param bool $count |
|
| 2632 | - * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int |
|
| 2633 | - */ |
|
| 2634 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2635 | - { |
|
| 2636 | - //testing term stuff |
|
| 2637 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
| 2638 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
| 2639 | - $limit = ($current_page - 1) * $per_page; |
|
| 2640 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
| 2641 | - if (isset($this->_req_data['s'])) { |
|
| 2642 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2643 | - $where['OR'] = array( |
|
| 2644 | - 'Term.name' => array('LIKE', $sstr), |
|
| 2645 | - 'description' => array('LIKE', $sstr), |
|
| 2646 | - ); |
|
| 2647 | - } |
|
| 2648 | - $query_params = array( |
|
| 2649 | - $where, |
|
| 2650 | - 'order_by' => array($orderby => $order), |
|
| 2651 | - 'limit' => $limit . ',' . $per_page, |
|
| 2652 | - 'force_join' => array('Term'), |
|
| 2653 | - ); |
|
| 2654 | - $categories = $count |
|
| 2655 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2656 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2657 | - return $categories; |
|
| 2658 | - } |
|
| 2659 | - |
|
| 2660 | - /* end category stuff */ |
|
| 2661 | - /**************/ |
|
| 2662 | - |
|
| 2663 | - |
|
| 2664 | - /** |
|
| 2665 | - * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2666 | - * @throws EE_Error |
|
| 2667 | - */ |
|
| 2668 | - public function save_timezonestring_setting() |
|
| 2669 | - { |
|
| 2670 | - $timezone_string = isset($this->_req_data['timezone_selected']) |
|
| 2671 | - ? $this->_req_data['timezone_selected'] |
|
| 2672 | - : ''; |
|
| 2673 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2674 | - { |
|
| 2675 | - EE_Error::add_error( |
|
| 2676 | - esc_html('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2677 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2678 | - ); |
|
| 2679 | - $this->_template_args['error'] = true; |
|
| 2680 | - $this->_return_json(); |
|
| 2681 | - } |
|
| 2682 | - |
|
| 2683 | - update_option('timezone_string', $timezone_string); |
|
| 2684 | - EE_Error::add_success( |
|
| 2685 | - esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2686 | - ); |
|
| 2687 | - $this->_template_args['success'] = true; |
|
| 2688 | - $this->_return_json(true, array('action' => 'create_new')); |
|
| 2689 | - } |
|
| 394 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
| 395 | + 'require_nonce' => false, |
|
| 396 | + ), |
|
| 397 | + 'default_event_settings' => array( |
|
| 398 | + 'nav' => array( |
|
| 399 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
| 400 | + 'order' => 40, |
|
| 401 | + ), |
|
| 402 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 403 | + 'labels' => array( |
|
| 404 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
| 405 | + ), |
|
| 406 | + 'help_tabs' => array( |
|
| 407 | + 'default_settings_help_tab' => array( |
|
| 408 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
| 409 | + 'filename' => 'events_default_settings', |
|
| 410 | + ), |
|
| 411 | + 'default_settings_status_help_tab' => array( |
|
| 412 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
| 413 | + 'filename' => 'events_default_settings_status', |
|
| 414 | + ), |
|
| 415 | + 'default_maximum_tickets_help_tab' => array( |
|
| 416 | + 'title' => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), |
|
| 417 | + 'filename' => 'events_default_settings_max_tickets', |
|
| 418 | + ) |
|
| 419 | + ), |
|
| 420 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
| 421 | + 'require_nonce' => false, |
|
| 422 | + ), |
|
| 423 | + //template settings |
|
| 424 | + 'template_settings' => array( |
|
| 425 | + 'nav' => array( |
|
| 426 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 427 | + 'order' => 30, |
|
| 428 | + ), |
|
| 429 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 430 | + 'help_tabs' => array( |
|
| 431 | + 'general_settings_templates_help_tab' => array( |
|
| 432 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 433 | + 'filename' => 'general_settings_templates', |
|
| 434 | + ), |
|
| 435 | + ), |
|
| 436 | + 'help_tour' => array('Templates_Help_Tour'), |
|
| 437 | + 'require_nonce' => false, |
|
| 438 | + ), |
|
| 439 | + //event category stuff |
|
| 440 | + 'add_category' => array( |
|
| 441 | + 'nav' => array( |
|
| 442 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
| 443 | + 'order' => 15, |
|
| 444 | + 'persistent' => false, |
|
| 445 | + ), |
|
| 446 | + 'help_tabs' => array( |
|
| 447 | + 'add_category_help_tab' => array( |
|
| 448 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
| 449 | + 'filename' => 'events_add_category', |
|
| 450 | + ), |
|
| 451 | + ), |
|
| 452 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
| 453 | + 'metaboxes' => array('_publish_post_box'), |
|
| 454 | + 'require_nonce' => false, |
|
| 455 | + ), |
|
| 456 | + 'edit_category' => array( |
|
| 457 | + 'nav' => array( |
|
| 458 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
| 459 | + 'order' => 15, |
|
| 460 | + 'persistent' => false, |
|
| 461 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
| 462 | + ? add_query_arg( |
|
| 463 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
| 464 | + $this->_current_page_view_url |
|
| 465 | + ) |
|
| 466 | + : $this->_admin_base_url, |
|
| 467 | + ), |
|
| 468 | + 'help_tabs' => array( |
|
| 469 | + 'edit_category_help_tab' => array( |
|
| 470 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
| 471 | + 'filename' => 'events_edit_category', |
|
| 472 | + ), |
|
| 473 | + ), |
|
| 474 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
| 475 | + 'metaboxes' => array('_publish_post_box'), |
|
| 476 | + 'require_nonce' => false, |
|
| 477 | + ), |
|
| 478 | + 'category_list' => array( |
|
| 479 | + 'nav' => array( |
|
| 480 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
| 481 | + 'order' => 20, |
|
| 482 | + ), |
|
| 483 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
| 484 | + 'help_tabs' => array( |
|
| 485 | + 'events_categories_help_tab' => array( |
|
| 486 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
| 487 | + 'filename' => 'events_categories', |
|
| 488 | + ), |
|
| 489 | + 'events_categories_table_column_headings_help_tab' => array( |
|
| 490 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
| 491 | + 'filename' => 'events_categories_table_column_headings', |
|
| 492 | + ), |
|
| 493 | + 'events_categories_view_help_tab' => array( |
|
| 494 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
| 495 | + 'filename' => 'events_categories_views', |
|
| 496 | + ), |
|
| 497 | + 'events_categories_other_help_tab' => array( |
|
| 498 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
| 499 | + 'filename' => 'events_categories_other', |
|
| 500 | + ), |
|
| 501 | + ), |
|
| 502 | + 'help_tour' => array( |
|
| 503 | + 'Event_Categories_Help_Tour', |
|
| 504 | + ), |
|
| 505 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
| 506 | + 'require_nonce' => false, |
|
| 507 | + ), |
|
| 508 | + ); |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * Used to register any global screen options if necessary for every route in this admin page group. |
|
| 514 | + */ |
|
| 515 | + protected function _add_screen_options() |
|
| 516 | + { |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * Implementing the screen options for the 'default' route. |
|
| 522 | + */ |
|
| 523 | + protected function _add_screen_options_default() |
|
| 524 | + { |
|
| 525 | + $this->_per_page_screen_option(); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Implementing screen options for the category list route. |
|
| 531 | + */ |
|
| 532 | + protected function _add_screen_options_category_list() |
|
| 533 | + { |
|
| 534 | + $page_title = $this->_admin_page_title; |
|
| 535 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
| 536 | + $this->_per_page_screen_option(); |
|
| 537 | + $this->_admin_page_title = $page_title; |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * Used to register any global feature pointers for the admin page group. |
|
| 543 | + */ |
|
| 544 | + protected function _add_feature_pointers() |
|
| 545 | + { |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * Registers and enqueues any global scripts and styles for the entire admin page group. |
|
| 551 | + */ |
|
| 552 | + public function load_scripts_styles() |
|
| 553 | + { |
|
| 554 | + wp_register_style( |
|
| 555 | + 'events-admin-css', |
|
| 556 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 557 | + array(), |
|
| 558 | + EVENT_ESPRESSO_VERSION |
|
| 559 | + ); |
|
| 560 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | + wp_enqueue_style('events-admin-css'); |
|
| 562 | + wp_enqueue_style('ee-cat-admin'); |
|
| 563 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
| 564 | + //registers for all views |
|
| 565 | + //scripts |
|
| 566 | + wp_register_script( |
|
| 567 | + 'event_editor_js', |
|
| 568 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 569 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
| 570 | + EVENT_ESPRESSO_VERSION, |
|
| 571 | + true |
|
| 572 | + ); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + |
|
| 576 | + |
|
| 577 | + /** |
|
| 578 | + * Enqueuing scripts and styles specific to this view |
|
| 579 | + */ |
|
| 580 | + public function load_scripts_styles_create_new() |
|
| 581 | + { |
|
| 582 | + $this->load_scripts_styles_edit(); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + /** |
|
| 588 | + * Enqueuing scripts and styles specific to this view |
|
| 589 | + */ |
|
| 590 | + public function load_scripts_styles_edit() |
|
| 591 | + { |
|
| 592 | + //styles |
|
| 593 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 594 | + wp_register_style( |
|
| 595 | + 'event-editor-css', |
|
| 596 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 597 | + array('ee-admin-css'), |
|
| 598 | + EVENT_ESPRESSO_VERSION |
|
| 599 | + ); |
|
| 600 | + wp_enqueue_style('event-editor-css'); |
|
| 601 | + //scripts |
|
| 602 | + wp_register_script( |
|
| 603 | + 'event-datetime-metabox', |
|
| 604 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 605 | + array('event_editor_js', 'ee-datepicker'), |
|
| 606 | + EVENT_ESPRESSO_VERSION |
|
| 607 | + ); |
|
| 608 | + wp_enqueue_script('event-datetime-metabox'); |
|
| 609 | + } |
|
| 610 | + |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Populating the _views property for the category list table view. |
|
| 614 | + */ |
|
| 615 | + protected function _set_list_table_views_category_list() |
|
| 616 | + { |
|
| 617 | + $this->_views = array( |
|
| 618 | + 'all' => array( |
|
| 619 | + 'slug' => 'all', |
|
| 620 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 621 | + 'count' => 0, |
|
| 622 | + 'bulk_action' => array( |
|
| 623 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 624 | + ), |
|
| 625 | + ), |
|
| 626 | + ); |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * For adding anything that fires on the admin_init hook for any route within this admin page group. |
|
| 632 | + */ |
|
| 633 | + public function admin_init() |
|
| 634 | + { |
|
| 635 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
| 636 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 637 | + 'event_espresso' |
|
| 638 | + ); |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * For adding anything that should be triggered on the admin_notices hook for any route within this admin page group. |
|
| 644 | + */ |
|
| 645 | + public function admin_notices() |
|
| 646 | + { |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + /** |
|
| 651 | + * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within |
|
| 652 | + * this admin page group. |
|
| 653 | + */ |
|
| 654 | + public function admin_footer_scripts() |
|
| 655 | + { |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + |
|
| 659 | + |
|
| 660 | + /** |
|
| 661 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
| 662 | + * warning (via EE_Error::add_error()); |
|
| 663 | + * |
|
| 664 | + * @param EE_Event $event Event object |
|
| 665 | + * @access public |
|
| 666 | + * @return void |
|
| 667 | + */ |
|
| 668 | + public function verify_event_edit($event = null) |
|
| 669 | + { |
|
| 670 | + // no event? |
|
| 671 | + if (empty($event)) { |
|
| 672 | + // set event |
|
| 673 | + $event = $this->_cpt_model_obj; |
|
| 674 | + } |
|
| 675 | + // STILL no event? |
|
| 676 | + if (! $event instanceof EE_Event) { |
|
| 677 | + return; |
|
| 678 | + } |
|
| 679 | + $orig_status = $event->status(); |
|
| 680 | + // first check if event is active. |
|
| 681 | + if ( |
|
| 682 | + $orig_status === EEM_Event::cancelled |
|
| 683 | + || $orig_status === EEM_Event::postponed |
|
| 684 | + || $event->is_expired() |
|
| 685 | + || $event->is_inactive() |
|
| 686 | + ) { |
|
| 687 | + return; |
|
| 688 | + } |
|
| 689 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
| 690 | + if ($event->is_sold_out(true)) { |
|
| 691 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
| 692 | + EE_Error::add_attention( |
|
| 693 | + sprintf( |
|
| 694 | + esc_html__( |
|
| 695 | + 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
|
| 696 | + 'event_espresso' |
|
| 697 | + ), |
|
| 698 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
| 699 | + ) |
|
| 700 | + ); |
|
| 701 | + } |
|
| 702 | + return; |
|
| 703 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
| 704 | + EE_Error::add_attention( |
|
| 705 | + sprintf( |
|
| 706 | + esc_html__( |
|
| 707 | + 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
|
| 708 | + 'event_espresso' |
|
| 709 | + ), |
|
| 710 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
| 711 | + ) |
|
| 712 | + ); |
|
| 713 | + } |
|
| 714 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
| 715 | + if ( ! $event->tickets_on_sale()) { |
|
| 716 | + return; |
|
| 717 | + } |
|
| 718 | + //made it here so show warning |
|
| 719 | + $this->_edit_event_warning(); |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + |
|
| 723 | + |
|
| 724 | + /** |
|
| 725 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
| 726 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
| 727 | + * |
|
| 728 | + * @access protected |
|
| 729 | + * @return void |
|
| 730 | + */ |
|
| 731 | + protected function _edit_event_warning() |
|
| 732 | + { |
|
| 733 | + // we don't want to add warnings during these requests |
|
| 734 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
| 735 | + return; |
|
| 736 | + } |
|
| 737 | + EE_Error::add_attention( |
|
| 738 | + esc_html__( |
|
| 739 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
| 740 | + 'event_espresso' |
|
| 741 | + ) |
|
| 742 | + ); |
|
| 743 | + } |
|
| 744 | + |
|
| 745 | + |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
| 749 | + * Otherwise, do the normal logic |
|
| 750 | + * |
|
| 751 | + * @return string |
|
| 752 | + * @throws \EE_Error |
|
| 753 | + */ |
|
| 754 | + protected function _create_new_cpt_item() |
|
| 755 | + { |
|
| 756 | + $has_timezone_string = get_option('timezone_string'); |
|
| 757 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
| 758 | + if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 759 | + EE_Error::add_attention( |
|
| 760 | + sprintf( |
|
| 761 | + __( |
|
| 762 | + 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s', |
|
| 763 | + 'event_espresso' |
|
| 764 | + ), |
|
| 765 | + '<br>', |
|
| 766 | + '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">' |
|
| 767 | + . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) |
|
| 768 | + . '</select>', |
|
| 769 | + '<button class="button button-secondary timezone-submit">', |
|
| 770 | + '</button><span class="spinner"></span>' |
|
| 771 | + ), |
|
| 772 | + __FILE__, |
|
| 773 | + __FUNCTION__, |
|
| 774 | + __LINE__ |
|
| 775 | + ); |
|
| 776 | + } |
|
| 777 | + return parent::_create_new_cpt_item(); |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * Sets the _views property for the default route in this admin page group. |
|
| 783 | + */ |
|
| 784 | + protected function _set_list_table_views_default() |
|
| 785 | + { |
|
| 786 | + $this->_views = array( |
|
| 787 | + 'all' => array( |
|
| 788 | + 'slug' => 'all', |
|
| 789 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
| 790 | + 'count' => 0, |
|
| 791 | + 'bulk_action' => array( |
|
| 792 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 793 | + ), |
|
| 794 | + ), |
|
| 795 | + 'draft' => array( |
|
| 796 | + 'slug' => 'draft', |
|
| 797 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
| 798 | + 'count' => 0, |
|
| 799 | + 'bulk_action' => array( |
|
| 800 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 801 | + ), |
|
| 802 | + ), |
|
| 803 | + ); |
|
| 804 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
| 805 | + $this->_views['trash'] = array( |
|
| 806 | + 'slug' => 'trash', |
|
| 807 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 808 | + 'count' => 0, |
|
| 809 | + 'bulk_action' => array( |
|
| 810 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
| 811 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 812 | + ), |
|
| 813 | + ); |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + |
|
| 818 | + |
|
| 819 | + /** |
|
| 820 | + * Provides the legend item array for the default list table view. |
|
| 821 | + * @return array |
|
| 822 | + */ |
|
| 823 | + protected function _event_legend_items() |
|
| 824 | + { |
|
| 825 | + $items = array( |
|
| 826 | + 'view_details' => array( |
|
| 827 | + 'class' => 'dashicons dashicons-search', |
|
| 828 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
| 829 | + ), |
|
| 830 | + 'edit_event' => array( |
|
| 831 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
| 832 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
| 833 | + ), |
|
| 834 | + 'view_attendees' => array( |
|
| 835 | + 'class' => 'dashicons dashicons-groups', |
|
| 836 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
| 837 | + ), |
|
| 838 | + ); |
|
| 839 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
| 840 | + $statuses = array( |
|
| 841 | + 'sold_out_status' => array( |
|
| 842 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 843 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
| 844 | + ), |
|
| 845 | + 'active_status' => array( |
|
| 846 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 847 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
| 848 | + ), |
|
| 849 | + 'upcoming_status' => array( |
|
| 850 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 851 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
| 852 | + ), |
|
| 853 | + 'postponed_status' => array( |
|
| 854 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 855 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
| 856 | + ), |
|
| 857 | + 'cancelled_status' => array( |
|
| 858 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 859 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
| 860 | + ), |
|
| 861 | + 'expired_status' => array( |
|
| 862 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 863 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
| 864 | + ), |
|
| 865 | + 'inactive_status' => array( |
|
| 866 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 867 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
| 868 | + ), |
|
| 869 | + ); |
|
| 870 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
| 871 | + return array_merge($items, $statuses); |
|
| 872 | + } |
|
| 873 | + |
|
| 874 | + |
|
| 875 | + |
|
| 876 | + /** |
|
| 877 | + * @return EEM_Event |
|
| 878 | + */ |
|
| 879 | + private function _event_model() |
|
| 880 | + { |
|
| 881 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
| 882 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
| 883 | + } |
|
| 884 | + return $this->_event_model; |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * Adds extra buttons to the WP CPT permalink field row. |
|
| 891 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
| 892 | + * |
|
| 893 | + * @param string $return the current html |
|
| 894 | + * @param int $id the post id for the page |
|
| 895 | + * @param string $new_title What the title is |
|
| 896 | + * @param string $new_slug what the slug is |
|
| 897 | + * @return string The new html string for the permalink area |
|
| 898 | + */ |
|
| 899 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 900 | + { |
|
| 901 | + //make sure this is only when editing |
|
| 902 | + if ( ! empty($id)) { |
|
| 903 | + $post = get_post($id); |
|
| 904 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
| 905 | + . esc_html__('Shortcode', 'event_espresso') |
|
| 906 | + . '</a> '; |
|
| 907 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
| 908 | + . $post->ID |
|
| 909 | + . ']">'; |
|
| 910 | + } |
|
| 911 | + return $return; |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + |
|
| 915 | + |
|
| 916 | + /** |
|
| 917 | + * _events_overview_list_table |
|
| 918 | + * This contains the logic for showing the events_overview list |
|
| 919 | + * |
|
| 920 | + * @access protected |
|
| 921 | + * @return void |
|
| 922 | + * @throws \EE_Error |
|
| 923 | + */ |
|
| 924 | + protected function _events_overview_list_table() |
|
| 925 | + { |
|
| 926 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 927 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
| 928 | + ? (array)$this->_template_args['after_list_table'] |
|
| 929 | + : array(); |
|
| 930 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
| 931 | + . EEH_Template::get_button_or_link( |
|
| 932 | + get_post_type_archive_link('espresso_events'), |
|
| 933 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
| 934 | + 'button' |
|
| 935 | + ); |
|
| 936 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
| 937 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 938 | + 'create_new', |
|
| 939 | + 'add', |
|
| 940 | + array(), |
|
| 941 | + 'add-new-h2' |
|
| 942 | + ); |
|
| 943 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 944 | + } |
|
| 945 | + |
|
| 946 | + |
|
| 947 | + |
|
| 948 | + /** |
|
| 949 | + * this allows for extra misc actions in the default WP publish box |
|
| 950 | + * |
|
| 951 | + * @return void |
|
| 952 | + */ |
|
| 953 | + public function extra_misc_actions_publish_box() |
|
| 954 | + { |
|
| 955 | + $this->_generate_publish_box_extra_content(); |
|
| 956 | + } |
|
| 957 | + |
|
| 958 | + |
|
| 959 | + |
|
| 960 | + /** |
|
| 961 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
| 962 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
| 963 | + * data. |
|
| 964 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
| 965 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
| 966 | + * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
| 967 | + * you handle this accordingly. |
|
| 968 | + * |
|
| 969 | + * @access protected |
|
| 970 | + * @abstract |
|
| 971 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
| 972 | + * @param object $post The post object of the cpt that was saved. |
|
| 973 | + * @return void |
|
| 974 | + */ |
|
| 975 | + protected function _insert_update_cpt_item($post_id, $post) |
|
| 976 | + { |
|
| 977 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
| 978 | + //get out we're not processing an event save. |
|
| 979 | + return; |
|
| 980 | + } |
|
| 981 | + $event_values = array( |
|
| 982 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
| 983 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
| 984 | + 'EVT_additional_limit' => min( |
|
| 985 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
| 986 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
| 987 | + ), |
|
| 988 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
| 989 | + ? $this->_req_data['EVT_default_registration_status'] |
|
| 990 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
| 991 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
| 992 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
| 993 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
| 994 | + ? $this->_req_data['timezone_string'] : null, |
|
| 995 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
| 996 | + ? $this->_req_data['externalURL'] : null, |
|
| 997 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
| 998 | + ? $this->_req_data['event_phone'] : null, |
|
| 999 | + ); |
|
| 1000 | + //update event |
|
| 1001 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
| 1002 | + //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
|
| 1003 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
| 1004 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
| 1005 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
| 1006 | + $event_update_callbacks = apply_filters( |
|
| 1007 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
| 1008 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
| 1009 | + ); |
|
| 1010 | + $att_success = true; |
|
| 1011 | + foreach ($event_update_callbacks as $e_callback) { |
|
| 1012 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
| 1013 | + $att_success = ! $att_success ? $att_success |
|
| 1014 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
| 1015 | + } |
|
| 1016 | + //any errors? |
|
| 1017 | + if ($success && false === $att_success) { |
|
| 1018 | + EE_Error::add_error( |
|
| 1019 | + esc_html__( |
|
| 1020 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
| 1021 | + 'event_espresso' |
|
| 1022 | + ), |
|
| 1023 | + __FILE__, |
|
| 1024 | + __FUNCTION__, |
|
| 1025 | + __LINE__ |
|
| 1026 | + ); |
|
| 1027 | + } else if ($success === false) { |
|
| 1028 | + EE_Error::add_error( |
|
| 1029 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
| 1030 | + __FILE__, |
|
| 1031 | + __FUNCTION__, |
|
| 1032 | + __LINE__ |
|
| 1033 | + ); |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + |
|
| 1038 | + |
|
| 1039 | + /** |
|
| 1040 | + * @see parent::restore_item() |
|
| 1041 | + * @param int $post_id |
|
| 1042 | + * @param int $revision_id |
|
| 1043 | + */ |
|
| 1044 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
| 1045 | + { |
|
| 1046 | + //copy existing event meta to new post |
|
| 1047 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
| 1048 | + if ($post_evt instanceof EE_Event) { |
|
| 1049 | + //meta revision restore |
|
| 1050 | + $post_evt->restore_revision($revision_id); |
|
| 1051 | + //related objs restore |
|
| 1052 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + |
|
| 1057 | + |
|
| 1058 | + /** |
|
| 1059 | + * Attach the venue to the Event |
|
| 1060 | + * |
|
| 1061 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
| 1062 | + * @param array $data The request data from the form |
|
| 1063 | + * @return bool Success or fail. |
|
| 1064 | + */ |
|
| 1065 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
| 1066 | + { |
|
| 1067 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1068 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
| 1069 | + $rows_affected = null; |
|
| 1070 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
| 1071 | + // very important. If we don't have a venue name... |
|
| 1072 | + // then we'll get out because not necessary to create empty venue |
|
| 1073 | + if (empty($data['venue_title'])) { |
|
| 1074 | + return false; |
|
| 1075 | + } |
|
| 1076 | + $venue_array = array( |
|
| 1077 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
| 1078 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
| 1079 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
| 1080 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
| 1081 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
| 1082 | + : null, |
|
| 1083 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
| 1084 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
| 1085 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
| 1086 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
| 1087 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
| 1088 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
| 1089 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
| 1090 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
| 1091 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
| 1092 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
| 1093 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
| 1094 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
| 1095 | + 'status' => 'publish', |
|
| 1096 | + ); |
|
| 1097 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
| 1098 | + if ( ! empty($venue_id)) { |
|
| 1099 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
| 1100 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
| 1101 | + //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
|
| 1102 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1103 | + return $rows_affected > 0 ? true : false; |
|
| 1104 | + } else { |
|
| 1105 | + //we insert the venue |
|
| 1106 | + $venue_id = $venue_model->insert($venue_array); |
|
| 1107 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
| 1108 | + return ! empty($venue_id) ? true : false; |
|
| 1109 | + } |
|
| 1110 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
| 1111 | + } |
|
| 1112 | + |
|
| 1113 | + |
|
| 1114 | + |
|
| 1115 | + /** |
|
| 1116 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
| 1117 | + * |
|
| 1118 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
| 1119 | + * @param array $data The request data from the form |
|
| 1120 | + * @return array |
|
| 1121 | + */ |
|
| 1122 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
| 1123 | + { |
|
| 1124 | + $success = true; |
|
| 1125 | + $saved_dtt = null; |
|
| 1126 | + $saved_tickets = array(); |
|
| 1127 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1128 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
| 1129 | + //trim all values to ensure any excess whitespace is removed. |
|
| 1130 | + $dtt = array_map('trim', $dtt); |
|
| 1131 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
| 1132 | + : $dtt['DTT_EVT_start']; |
|
| 1133 | + $datetime_values = array( |
|
| 1134 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
| 1135 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
| 1136 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
| 1137 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
| 1138 | + 'DTT_order' => $row, |
|
| 1139 | + ); |
|
| 1140 | + //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
|
| 1141 | + if ( ! empty($dtt['DTT_ID'])) { |
|
| 1142 | + $DTM = EE_Registry::instance() |
|
| 1143 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
| 1144 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
| 1145 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
| 1146 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
| 1147 | + foreach ($datetime_values as $field => $value) { |
|
| 1148 | + $DTM->set($field, $value); |
|
| 1149 | + } |
|
| 1150 | + //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
|
| 1151 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
| 1152 | + } else { |
|
| 1153 | + $DTM = EE_Registry::instance()->load_class( |
|
| 1154 | + 'Datetime', |
|
| 1155 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
| 1156 | + false, |
|
| 1157 | + false |
|
| 1158 | + ); |
|
| 1159 | + foreach ($datetime_values as $field => $value) { |
|
| 1160 | + $DTM->set($field, $value); |
|
| 1161 | + } |
|
| 1162 | + } |
|
| 1163 | + $DTM->save(); |
|
| 1164 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
| 1165 | + //load DTT helper |
|
| 1166 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1167 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
| 1168 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
| 1169 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
| 1170 | + $DTT->save(); |
|
| 1171 | + } |
|
| 1172 | + //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
|
| 1173 | + $saved_dtt = $DTT; |
|
| 1174 | + $success = ! $success ? $success : $DTT; |
|
| 1175 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
| 1176 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
| 1177 | + } |
|
| 1178 | + //no dtts get deleted so we don't do any of that logic here. |
|
| 1179 | + //update tickets next |
|
| 1180 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
| 1181 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
| 1182 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
| 1183 | + $update_prices = false; |
|
| 1184 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
| 1185 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
| 1186 | + // trim inputs to ensure any excess whitespace is removed. |
|
| 1187 | + $tkt = array_map('trim', $tkt); |
|
| 1188 | + if (empty($tkt['TKT_start_date'])) { |
|
| 1189 | + //let's use now in the set timezone. |
|
| 1190 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
| 1191 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1192 | + } |
|
| 1193 | + if (empty($tkt['TKT_end_date'])) { |
|
| 1194 | + //use the start date of the first datetime |
|
| 1195 | + $dtt = $evtobj->first_datetime(); |
|
| 1196 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
| 1197 | + $incoming_date_formats[0], |
|
| 1198 | + $incoming_date_formats[1] |
|
| 1199 | + ); |
|
| 1200 | + } |
|
| 1201 | + $TKT_values = array( |
|
| 1202 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
| 1203 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
| 1204 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
| 1205 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
| 1206 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
| 1207 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
| 1208 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
| 1209 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
| 1210 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
| 1211 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
| 1212 | + 'TKT_row' => $row, |
|
| 1213 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
| 1214 | + 'TKT_price' => $ticket_price, |
|
| 1215 | + ); |
|
| 1216 | + //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
|
| 1217 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
| 1218 | + $TKT_values['TKT_ID'] = 0; |
|
| 1219 | + $TKT_values['TKT_is_default'] = 0; |
|
| 1220 | + $TKT_values['TKT_price'] = $ticket_price; |
|
| 1221 | + $update_prices = true; |
|
| 1222 | + } |
|
| 1223 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
| 1224 | + //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
|
| 1225 | + //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
|
| 1226 | + if ( ! empty($tkt['TKT_ID'])) { |
|
| 1227 | + $TKT = EE_Registry::instance() |
|
| 1228 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
| 1229 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
| 1230 | + if ($TKT instanceof EE_Ticket) { |
|
| 1231 | + $ticket_sold = $TKT->count_related( |
|
| 1232 | + 'Registration', |
|
| 1233 | + array( |
|
| 1234 | + array( |
|
| 1235 | + 'STS_ID' => array( |
|
| 1236 | + 'NOT IN', |
|
| 1237 | + array(EEM_Registration::status_id_incomplete), |
|
| 1238 | + ), |
|
| 1239 | + ), |
|
| 1240 | + ) |
|
| 1241 | + ) > 0 ? true : false; |
|
| 1242 | + //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
|
| 1243 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
| 1244 | + && ! $TKT->get( |
|
| 1245 | + 'TKT_deleted' |
|
| 1246 | + ) ? true : false; |
|
| 1247 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1248 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1249 | + //set new values |
|
| 1250 | + foreach ($TKT_values as $field => $value) { |
|
| 1251 | + if ($field == 'TKT_qty') { |
|
| 1252 | + $TKT->set_qty($value); |
|
| 1253 | + } else { |
|
| 1254 | + $TKT->set($field, $value); |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
| 1258 | + if ($create_new_TKT) { |
|
| 1259 | + //archive the old ticket first |
|
| 1260 | + $TKT->set('TKT_deleted', 1); |
|
| 1261 | + $TKT->save(); |
|
| 1262 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
| 1263 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1264 | + //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
|
| 1265 | + $TKT = clone $TKT; |
|
| 1266 | + $TKT->set('TKT_ID', 0); |
|
| 1267 | + $TKT->set('TKT_deleted', 0); |
|
| 1268 | + $TKT->set('TKT_price', $ticket_price); |
|
| 1269 | + $TKT->set('TKT_sold', 0); |
|
| 1270 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
| 1271 | + $update_prices = true; |
|
| 1272 | + } |
|
| 1273 | + //make sure price is set if it hasn't been already |
|
| 1274 | + $TKT->set('TKT_price', $ticket_price); |
|
| 1275 | + } |
|
| 1276 | + } else { |
|
| 1277 | + //no TKT_id so a new TKT |
|
| 1278 | + $TKT_values['TKT_price'] = $ticket_price; |
|
| 1279 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
| 1280 | + if ($TKT instanceof EE_Ticket) { |
|
| 1281 | + //need to reset values to properly account for the date formats |
|
| 1282 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
| 1283 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
| 1284 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
| 1285 | + //set new values |
|
| 1286 | + foreach ($TKT_values as $field => $value) { |
|
| 1287 | + if ($field == 'TKT_qty') { |
|
| 1288 | + $TKT->set_qty($value); |
|
| 1289 | + } else { |
|
| 1290 | + $TKT->set($field, $value); |
|
| 1291 | + } |
|
| 1292 | + } |
|
| 1293 | + $update_prices = true; |
|
| 1294 | + } |
|
| 1295 | + } |
|
| 1296 | + // cap ticket qty by datetime reg limits |
|
| 1297 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
| 1298 | + //update ticket. |
|
| 1299 | + $TKT->save(); |
|
| 1300 | + //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
|
| 1301 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
| 1302 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
| 1303 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
| 1304 | + $TKT->save(); |
|
| 1305 | + } |
|
| 1306 | + //initially let's add the ticket to the dtt |
|
| 1307 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
| 1308 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
| 1309 | + //add prices to ticket |
|
| 1310 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
| 1311 | + } |
|
| 1312 | + //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
|
| 1313 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
| 1314 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
| 1315 | + foreach ($tickets_removed as $id) { |
|
| 1316 | + $id = absint($id); |
|
| 1317 | + //get the ticket for this id |
|
| 1318 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
| 1319 | + //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
|
| 1320 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
| 1321 | + foreach ($dtts as $dtt) { |
|
| 1322 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
| 1323 | + } |
|
| 1324 | + //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
|
| 1325 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
| 1326 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
| 1327 | + $tkt_to_remove->delete_permanently(); |
|
| 1328 | + } |
|
| 1329 | + return array($saved_dtt, $saved_tickets); |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + |
|
| 1333 | + |
|
| 1334 | + /** |
|
| 1335 | + * This attaches a list of given prices to a ticket. |
|
| 1336 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
| 1337 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
| 1338 | + * price info and prices are automatically "archived" via the ticket. |
|
| 1339 | + * |
|
| 1340 | + * @access private |
|
| 1341 | + * @param array $prices Array of prices from the form. |
|
| 1342 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
| 1343 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
| 1344 | + * @return void |
|
| 1345 | + */ |
|
| 1346 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
| 1347 | + { |
|
| 1348 | + foreach ($prices as $row => $prc) { |
|
| 1349 | + $PRC_values = array( |
|
| 1350 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
| 1351 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
| 1352 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
| 1353 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
| 1354 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
| 1355 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
| 1356 | + 'PRC_order' => $row, |
|
| 1357 | + ); |
|
| 1358 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
| 1359 | + $PRC_values['PRC_ID'] = 0; |
|
| 1360 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
| 1361 | + } else { |
|
| 1362 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
| 1363 | + //update this price with new values |
|
| 1364 | + foreach ($PRC_values as $field => $newprc) { |
|
| 1365 | + $PRC->set($field, $newprc); |
|
| 1366 | + } |
|
| 1367 | + $PRC->save(); |
|
| 1368 | + } |
|
| 1369 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
| 1370 | + } |
|
| 1371 | + } |
|
| 1372 | + |
|
| 1373 | + |
|
| 1374 | + |
|
| 1375 | + /** |
|
| 1376 | + * Add in our autosave ajax handlers |
|
| 1377 | + * |
|
| 1378 | + */ |
|
| 1379 | + protected function _ee_autosave_create_new() |
|
| 1380 | + { |
|
| 1381 | + } |
|
| 1382 | + |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * More autosave handlers. |
|
| 1386 | + */ |
|
| 1387 | + protected function _ee_autosave_edit() |
|
| 1388 | + { |
|
| 1389 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + |
|
| 1393 | + |
|
| 1394 | + /** |
|
| 1395 | + * _generate_publish_box_extra_content |
|
| 1396 | + */ |
|
| 1397 | + private function _generate_publish_box_extra_content() |
|
| 1398 | + { |
|
| 1399 | + //load formatter helper |
|
| 1400 | + //args for getting related registrations |
|
| 1401 | + $approved_query_args = array( |
|
| 1402 | + array( |
|
| 1403 | + 'REG_deleted' => 0, |
|
| 1404 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1405 | + ), |
|
| 1406 | + ); |
|
| 1407 | + $not_approved_query_args = array( |
|
| 1408 | + array( |
|
| 1409 | + 'REG_deleted' => 0, |
|
| 1410 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
| 1411 | + ), |
|
| 1412 | + ); |
|
| 1413 | + $pending_payment_query_args = array( |
|
| 1414 | + array( |
|
| 1415 | + 'REG_deleted' => 0, |
|
| 1416 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
| 1417 | + ), |
|
| 1418 | + ); |
|
| 1419 | + // publish box |
|
| 1420 | + $publish_box_extra_args = array( |
|
| 1421 | + 'view_approved_reg_url' => add_query_arg( |
|
| 1422 | + array( |
|
| 1423 | + 'action' => 'default', |
|
| 1424 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1425 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
| 1426 | + ), |
|
| 1427 | + REG_ADMIN_URL |
|
| 1428 | + ), |
|
| 1429 | + 'view_not_approved_reg_url' => add_query_arg( |
|
| 1430 | + array( |
|
| 1431 | + 'action' => 'default', |
|
| 1432 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1433 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
| 1434 | + ), |
|
| 1435 | + REG_ADMIN_URL |
|
| 1436 | + ), |
|
| 1437 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
| 1438 | + array( |
|
| 1439 | + 'action' => 'default', |
|
| 1440 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
| 1441 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
| 1442 | + ), |
|
| 1443 | + REG_ADMIN_URL |
|
| 1444 | + ), |
|
| 1445 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1446 | + 'Registration', |
|
| 1447 | + $approved_query_args |
|
| 1448 | + ), |
|
| 1449 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
| 1450 | + 'Registration', |
|
| 1451 | + $not_approved_query_args |
|
| 1452 | + ), |
|
| 1453 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
| 1454 | + 'Registration', |
|
| 1455 | + $pending_payment_query_args |
|
| 1456 | + ), |
|
| 1457 | + 'misc_pub_section_class' => apply_filters( |
|
| 1458 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
| 1459 | + 'misc-pub-section' |
|
| 1460 | + ), |
|
| 1461 | + ); |
|
| 1462 | + ob_start(); |
|
| 1463 | + do_action( |
|
| 1464 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
| 1465 | + $this->_cpt_model_obj |
|
| 1466 | + ); |
|
| 1467 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
| 1468 | + // load template |
|
| 1469 | + EEH_Template::display_template( |
|
| 1470 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1471 | + $publish_box_extra_args |
|
| 1472 | + ); |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + |
|
| 1476 | + |
|
| 1477 | + /** |
|
| 1478 | + * @return EE_Event |
|
| 1479 | + */ |
|
| 1480 | + public function get_event_object() |
|
| 1481 | + { |
|
| 1482 | + return $this->_cpt_model_obj; |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + |
|
| 1486 | + |
|
| 1487 | + |
|
| 1488 | + /** METABOXES * */ |
|
| 1489 | + /** |
|
| 1490 | + * _register_event_editor_meta_boxes |
|
| 1491 | + * add all metaboxes related to the event_editor |
|
| 1492 | + * |
|
| 1493 | + * @return void |
|
| 1494 | + */ |
|
| 1495 | + protected function _register_event_editor_meta_boxes() |
|
| 1496 | + { |
|
| 1497 | + $this->verify_cpt_object(); |
|
| 1498 | + add_meta_box( |
|
| 1499 | + 'espresso_event_editor_tickets', |
|
| 1500 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
| 1501 | + array($this, 'ticket_metabox'), |
|
| 1502 | + $this->page_slug, |
|
| 1503 | + 'normal', |
|
| 1504 | + 'high' |
|
| 1505 | + ); |
|
| 1506 | + add_meta_box( |
|
| 1507 | + 'espresso_event_editor_event_options', |
|
| 1508 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
| 1509 | + array($this, 'registration_options_meta_box'), |
|
| 1510 | + $this->page_slug, |
|
| 1511 | + 'side', |
|
| 1512 | + 'default' |
|
| 1513 | + ); |
|
| 1514 | + // NOTE: if you're looking for other metaboxes in here, |
|
| 1515 | + // where a metabox has a related management page in the admin |
|
| 1516 | + // you will find it setup in the related management page's "_Hooks" file. |
|
| 1517 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + |
|
| 1521 | + /** |
|
| 1522 | + * @throws DomainException |
|
| 1523 | + * @throws EE_Error |
|
| 1524 | + */ |
|
| 1525 | + public function ticket_metabox() |
|
| 1526 | + { |
|
| 1527 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
| 1528 | + //defaults for template args |
|
| 1529 | + $template_args = array( |
|
| 1530 | + 'existing_datetime_ids' => '', |
|
| 1531 | + 'event_datetime_help_link' => '', |
|
| 1532 | + 'ticket_options_help_link' => '', |
|
| 1533 | + 'time' => null, |
|
| 1534 | + 'ticket_rows' => '', |
|
| 1535 | + 'existing_ticket_ids' => '', |
|
| 1536 | + 'total_ticket_rows' => 1, |
|
| 1537 | + 'ticket_js_structure' => '', |
|
| 1538 | + 'trash_icon' => 'ee-lock-icon', |
|
| 1539 | + 'disabled' => '', |
|
| 1540 | + ); |
|
| 1541 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
| 1542 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1543 | + /** |
|
| 1544 | + * 1. Start with retrieving Datetimes |
|
| 1545 | + * 2. Fore each datetime get related tickets |
|
| 1546 | + * 3. For each ticket get related prices |
|
| 1547 | + */ |
|
| 1548 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
| 1549 | + /** @type EE_Datetime $first_datetime */ |
|
| 1550 | + $first_datetime = reset($times); |
|
| 1551 | + //do we get related tickets? |
|
| 1552 | + if ($first_datetime instanceof EE_Datetime |
|
| 1553 | + && $first_datetime->ID() !== 0 |
|
| 1554 | + ) { |
|
| 1555 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
| 1556 | + $template_args['time'] = $first_datetime; |
|
| 1557 | + $related_tickets = $first_datetime->tickets( |
|
| 1558 | + array( |
|
| 1559 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
| 1560 | + 'default_where_conditions' => 'none', |
|
| 1561 | + ) |
|
| 1562 | + ); |
|
| 1563 | + if ( ! empty($related_tickets)) { |
|
| 1564 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
| 1565 | + $row = 0; |
|
| 1566 | + foreach ($related_tickets as $ticket) { |
|
| 1567 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
| 1568 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
| 1569 | + $row++; |
|
| 1570 | + } |
|
| 1571 | + } else { |
|
| 1572 | + $template_args['total_ticket_rows'] = 1; |
|
| 1573 | + /** @type EE_Ticket $ticket */ |
|
| 1574 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
| 1575 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
| 1576 | + } |
|
| 1577 | + } else { |
|
| 1578 | + $template_args['time'] = $times[0]; |
|
| 1579 | + /** @type EE_Ticket $ticket */ |
|
| 1580 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
| 1581 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
| 1582 | + // NOTE: we're just sending the first default row |
|
| 1583 | + // (decaf can't manage default tickets so this should be sufficient); |
|
| 1584 | + } |
|
| 1585 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
| 1586 | + 'event_editor_event_datetimes_help_tab' |
|
| 1587 | + ); |
|
| 1588 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
| 1589 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
| 1590 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
| 1591 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
| 1592 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
| 1593 | + true |
|
| 1594 | + ); |
|
| 1595 | + $template = apply_filters( |
|
| 1596 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
| 1597 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1598 | + ); |
|
| 1599 | + EEH_Template::display_template($template, $template_args); |
|
| 1600 | + } |
|
| 1601 | + |
|
| 1602 | + |
|
| 1603 | + |
|
| 1604 | + /** |
|
| 1605 | + * Setup an individual ticket form for the decaf event editor page |
|
| 1606 | + * |
|
| 1607 | + * @access private |
|
| 1608 | + * @param EE_Ticket $ticket the ticket object |
|
| 1609 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
| 1610 | + * @param int $row |
|
| 1611 | + * @return string generated html for the ticket row. |
|
| 1612 | + */ |
|
| 1613 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
| 1614 | + { |
|
| 1615 | + $template_args = array( |
|
| 1616 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1617 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
| 1618 | + : '', |
|
| 1619 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
| 1620 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
| 1621 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
| 1622 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
| 1623 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
| 1624 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
| 1625 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
| 1626 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
| 1627 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
| 1628 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
| 1629 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
| 1630 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
| 1631 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
| 1632 | + : ' disabled=disabled', |
|
| 1633 | + ); |
|
| 1634 | + $price = $ticket->ID() !== 0 |
|
| 1635 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
| 1636 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
| 1637 | + $price_args = array( |
|
| 1638 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
| 1639 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
| 1640 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
| 1641 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
| 1642 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
| 1643 | + ); |
|
| 1644 | + //make sure we have default start and end dates if skeleton |
|
| 1645 | + //handle rows that should NOT be empty |
|
| 1646 | + if (empty($template_args['TKT_start_date'])) { |
|
| 1647 | + //if empty then the start date will be now. |
|
| 1648 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
| 1649 | + } |
|
| 1650 | + if (empty($template_args['TKT_end_date'])) { |
|
| 1651 | + //get the earliest datetime (if present); |
|
| 1652 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
| 1653 | + ? $this->_cpt_model_obj->get_first_related( |
|
| 1654 | + 'Datetime', |
|
| 1655 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
| 1656 | + ) |
|
| 1657 | + : null; |
|
| 1658 | + if ( ! empty($earliest_dtt)) { |
|
| 1659 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
| 1660 | + } else { |
|
| 1661 | + $template_args['TKT_end_date'] = date( |
|
| 1662 | + 'Y-m-d h:i a', |
|
| 1663 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
| 1664 | + ); |
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1667 | + $template_args = array_merge($template_args, $price_args); |
|
| 1668 | + $template = apply_filters( |
|
| 1669 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
| 1670 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1671 | + $ticket |
|
| 1672 | + ); |
|
| 1673 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 1674 | + } |
|
| 1675 | + |
|
| 1676 | + |
|
| 1677 | + /** |
|
| 1678 | + * @throws DomainException |
|
| 1679 | + */ |
|
| 1680 | + public function registration_options_meta_box() |
|
| 1681 | + { |
|
| 1682 | + $yes_no_values = array( |
|
| 1683 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 1684 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 1685 | + ); |
|
| 1686 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 1687 | + array( |
|
| 1688 | + EEM_Registration::status_id_cancelled, |
|
| 1689 | + EEM_Registration::status_id_declined, |
|
| 1690 | + EEM_Registration::status_id_incomplete, |
|
| 1691 | + ), |
|
| 1692 | + true |
|
| 1693 | + ); |
|
| 1694 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
| 1695 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
| 1696 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 1697 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 1698 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 1699 | + 'default_reg_status', |
|
| 1700 | + $default_reg_status_values, |
|
| 1701 | + $this->_cpt_model_obj->default_registration_status() |
|
| 1702 | + ); |
|
| 1703 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 1704 | + 'display_desc', |
|
| 1705 | + $yes_no_values, |
|
| 1706 | + $this->_cpt_model_obj->display_description() |
|
| 1707 | + ); |
|
| 1708 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 1709 | + 'display_ticket_selector', |
|
| 1710 | + $yes_no_values, |
|
| 1711 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
| 1712 | + '', |
|
| 1713 | + '', |
|
| 1714 | + false |
|
| 1715 | + ); |
|
| 1716 | + $template_args['additional_registration_options'] = apply_filters( |
|
| 1717 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 1718 | + '', |
|
| 1719 | + $template_args, |
|
| 1720 | + $yes_no_values, |
|
| 1721 | + $default_reg_status_values |
|
| 1722 | + ); |
|
| 1723 | + EEH_Template::display_template( |
|
| 1724 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1725 | + $template_args |
|
| 1726 | + ); |
|
| 1727 | + } |
|
| 1728 | + |
|
| 1729 | + |
|
| 1730 | + |
|
| 1731 | + /** |
|
| 1732 | + * _get_events() |
|
| 1733 | + * This method simply returns all the events (for the given _view and paging) |
|
| 1734 | + * |
|
| 1735 | + * @access public |
|
| 1736 | + * @param int $per_page count of items per page (20 default); |
|
| 1737 | + * @param int $current_page what is the current page being viewed. |
|
| 1738 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
| 1739 | + * If FALSE then we return an array of event objects |
|
| 1740 | + * that match the given _view and paging parameters. |
|
| 1741 | + * @return array an array of event objects. |
|
| 1742 | + */ |
|
| 1743 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
| 1744 | + { |
|
| 1745 | + $EEME = $this->_event_model(); |
|
| 1746 | + $offset = ($current_page - 1) * $per_page; |
|
| 1747 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1748 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
| 1749 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
| 1750 | + if (isset($this->_req_data['month_range'])) { |
|
| 1751 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
| 1752 | + //simulate the FIRST day of the month, that fixes issues for months like February |
|
| 1753 | + //where PHP doesn't know what to assume for date. |
|
| 1754 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10437 |
|
| 1755 | + $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; |
|
| 1756 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
| 1757 | + } |
|
| 1758 | + $where = array(); |
|
| 1759 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 1760 | + //determine what post_status our condition will have for the query. |
|
| 1761 | + switch ($status) { |
|
| 1762 | + case 'month' : |
|
| 1763 | + case 'today' : |
|
| 1764 | + case null : |
|
| 1765 | + case 'all' : |
|
| 1766 | + break; |
|
| 1767 | + case 'draft' : |
|
| 1768 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
| 1769 | + break; |
|
| 1770 | + default : |
|
| 1771 | + $where['status'] = $status; |
|
| 1772 | + } |
|
| 1773 | + //categories? |
|
| 1774 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 1775 | + ? $this->_req_data['EVT_CAT'] : null; |
|
| 1776 | + if ( ! empty ($category)) { |
|
| 1777 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 1778 | + $where['Term_Taxonomy.term_id'] = $category; |
|
| 1779 | + } |
|
| 1780 | + //date where conditions |
|
| 1781 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
| 1782 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
| 1783 | + $DateTime = new DateTime( |
|
| 1784 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1785 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
| 1786 | + ); |
|
| 1787 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
| 1788 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
| 1789 | + ->format('t'))->setTime(23, 59, 59) |
|
| 1790 | + ->format(implode(' ', $start_formats)); |
|
| 1791 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1792 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
| 1793 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1794 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1795 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
| 1796 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1797 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
| 1798 | + $now = date('Y-m-01'); |
|
| 1799 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
| 1800 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
| 1801 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
| 1802 | + ->setTime(23, 59, 59) |
|
| 1803 | + ->format(implode(' ', $start_formats)); |
|
| 1804 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
| 1805 | + } |
|
| 1806 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 1807 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
| 1808 | + } else { |
|
| 1809 | + if ( ! isset($where['status'])) { |
|
| 1810 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 1811 | + $where['OR'] = array( |
|
| 1812 | + 'status*restrict_private' => array('!=', 'private'), |
|
| 1813 | + 'AND' => array( |
|
| 1814 | + 'status*inclusive' => array('=', 'private'), |
|
| 1815 | + 'EVT_wp_user' => get_current_user_id(), |
|
| 1816 | + ), |
|
| 1817 | + ); |
|
| 1818 | + } |
|
| 1819 | + } |
|
| 1820 | + } |
|
| 1821 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
| 1822 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
| 1823 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
| 1824 | + ) { |
|
| 1825 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
| 1826 | + } |
|
| 1827 | + } |
|
| 1828 | + //search query handling |
|
| 1829 | + if (isset($this->_req_data['s'])) { |
|
| 1830 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1831 | + $where['OR'] = array( |
|
| 1832 | + 'EVT_name' => array('LIKE', $search_string), |
|
| 1833 | + 'EVT_desc' => array('LIKE', $search_string), |
|
| 1834 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
| 1835 | + ); |
|
| 1836 | + } |
|
| 1837 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
| 1838 | + $query_params = apply_filters( |
|
| 1839 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
| 1840 | + array( |
|
| 1841 | + $where, |
|
| 1842 | + 'limit' => $limit, |
|
| 1843 | + 'order_by' => $orderby, |
|
| 1844 | + 'order' => $order, |
|
| 1845 | + 'group_by' => 'EVT_ID', |
|
| 1846 | + ), |
|
| 1847 | + $this->_req_data |
|
| 1848 | + ); |
|
| 1849 | + //let's first check if we have special requests coming in. |
|
| 1850 | + if (isset($this->_req_data['active_status'])) { |
|
| 1851 | + switch ($this->_req_data['active_status']) { |
|
| 1852 | + case 'upcoming' : |
|
| 1853 | + return $EEME->get_upcoming_events($query_params, $count); |
|
| 1854 | + break; |
|
| 1855 | + case 'expired' : |
|
| 1856 | + return $EEME->get_expired_events($query_params, $count); |
|
| 1857 | + break; |
|
| 1858 | + case 'active' : |
|
| 1859 | + return $EEME->get_active_events($query_params, $count); |
|
| 1860 | + break; |
|
| 1861 | + case 'inactive' : |
|
| 1862 | + return $EEME->get_inactive_events($query_params, $count); |
|
| 1863 | + break; |
|
| 1864 | + } |
|
| 1865 | + } |
|
| 1866 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
| 1867 | + return $events; |
|
| 1868 | + } |
|
| 1869 | + |
|
| 1870 | + |
|
| 1871 | + |
|
| 1872 | + /** |
|
| 1873 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
| 1874 | + * |
|
| 1875 | + * @param string $post_id |
|
| 1876 | + */ |
|
| 1877 | + public function trash_cpt_item($post_id) |
|
| 1878 | + { |
|
| 1879 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1880 | + $this->_trash_or_restore_event('trash', false); |
|
| 1881 | + } |
|
| 1882 | + |
|
| 1883 | + |
|
| 1884 | + |
|
| 1885 | + /** |
|
| 1886 | + * @param string $post_id |
|
| 1887 | + */ |
|
| 1888 | + public function restore_cpt_item($post_id) |
|
| 1889 | + { |
|
| 1890 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1891 | + $this->_trash_or_restore_event('draft', false); |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + |
|
| 1895 | + |
|
| 1896 | + /** |
|
| 1897 | + * @param string $post_id |
|
| 1898 | + */ |
|
| 1899 | + public function delete_cpt_item($post_id) |
|
| 1900 | + { |
|
| 1901 | + $this->_req_data['EVT_ID'] = $post_id; |
|
| 1902 | + $this->_delete_event(false); |
|
| 1903 | + } |
|
| 1904 | + |
|
| 1905 | + |
|
| 1906 | + |
|
| 1907 | + /** |
|
| 1908 | + * _trash_or_restore_event |
|
| 1909 | + * |
|
| 1910 | + * @access protected |
|
| 1911 | + * @param string $event_status |
|
| 1912 | + * @param bool $redirect_after |
|
| 1913 | + */ |
|
| 1914 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
| 1915 | + { |
|
| 1916 | + //determine the event id and set to array. |
|
| 1917 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
| 1918 | + // loop thru events |
|
| 1919 | + if ($EVT_ID) { |
|
| 1920 | + // clean status |
|
| 1921 | + $event_status = sanitize_key($event_status); |
|
| 1922 | + // grab status |
|
| 1923 | + if ( ! empty($event_status)) { |
|
| 1924 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1925 | + } else { |
|
| 1926 | + $success = false; |
|
| 1927 | + $msg = esc_html__( |
|
| 1928 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1929 | + 'event_espresso' |
|
| 1930 | + ); |
|
| 1931 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1932 | + } |
|
| 1933 | + } else { |
|
| 1934 | + $success = false; |
|
| 1935 | + $msg = esc_html__( |
|
| 1936 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1937 | + 'event_espresso' |
|
| 1938 | + ); |
|
| 1939 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1940 | + } |
|
| 1941 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1942 | + if ($redirect_after) { |
|
| 1943 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
| 1944 | + } |
|
| 1945 | + } |
|
| 1946 | + |
|
| 1947 | + |
|
| 1948 | + |
|
| 1949 | + /** |
|
| 1950 | + * _trash_or_restore_events |
|
| 1951 | + * |
|
| 1952 | + * @access protected |
|
| 1953 | + * @param string $event_status |
|
| 1954 | + * @return void |
|
| 1955 | + */ |
|
| 1956 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
| 1957 | + { |
|
| 1958 | + // clean status |
|
| 1959 | + $event_status = sanitize_key($event_status); |
|
| 1960 | + // grab status |
|
| 1961 | + if ( ! empty($event_status)) { |
|
| 1962 | + $success = true; |
|
| 1963 | + //determine the event id and set to array. |
|
| 1964 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1965 | + // loop thru events |
|
| 1966 | + foreach ($EVT_IDs as $EVT_ID) { |
|
| 1967 | + if ($EVT_ID = absint($EVT_ID)) { |
|
| 1968 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
| 1969 | + $success = $results !== false ? $success : false; |
|
| 1970 | + } else { |
|
| 1971 | + $msg = sprintf( |
|
| 1972 | + esc_html__( |
|
| 1973 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
| 1974 | + 'event_espresso' |
|
| 1975 | + ), |
|
| 1976 | + $EVT_ID |
|
| 1977 | + ); |
|
| 1978 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1979 | + $success = false; |
|
| 1980 | + } |
|
| 1981 | + } |
|
| 1982 | + } else { |
|
| 1983 | + $success = false; |
|
| 1984 | + $msg = esc_html__( |
|
| 1985 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
| 1986 | + 'event_espresso' |
|
| 1987 | + ); |
|
| 1988 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1989 | + } |
|
| 1990 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 1991 | + $success = $success ? 2 : false; |
|
| 1992 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
| 1993 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
| 1994 | + } |
|
| 1995 | + |
|
| 1996 | + |
|
| 1997 | + |
|
| 1998 | + /** |
|
| 1999 | + * _trash_or_restore_events |
|
| 2000 | + * |
|
| 2001 | + * @access private |
|
| 2002 | + * @param int $EVT_ID |
|
| 2003 | + * @param string $event_status |
|
| 2004 | + * @return bool |
|
| 2005 | + */ |
|
| 2006 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
| 2007 | + { |
|
| 2008 | + // grab event id |
|
| 2009 | + if ( ! $EVT_ID) { |
|
| 2010 | + $msg = esc_html__( |
|
| 2011 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2012 | + 'event_espresso' |
|
| 2013 | + ); |
|
| 2014 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2015 | + return false; |
|
| 2016 | + } |
|
| 2017 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2018 | + // clean status |
|
| 2019 | + $event_status = sanitize_key($event_status); |
|
| 2020 | + // grab status |
|
| 2021 | + if (empty($event_status)) { |
|
| 2022 | + $msg = esc_html__( |
|
| 2023 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
| 2024 | + 'event_espresso' |
|
| 2025 | + ); |
|
| 2026 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2027 | + return false; |
|
| 2028 | + } |
|
| 2029 | + // was event trashed or restored ? |
|
| 2030 | + switch ($event_status) { |
|
| 2031 | + case 'draft' : |
|
| 2032 | + $action = 'restored from the trash'; |
|
| 2033 | + $hook = 'AHEE_event_restored_from_trash'; |
|
| 2034 | + break; |
|
| 2035 | + case 'trash' : |
|
| 2036 | + $action = 'moved to the trash'; |
|
| 2037 | + $hook = 'AHEE_event_moved_to_trash'; |
|
| 2038 | + break; |
|
| 2039 | + default : |
|
| 2040 | + $action = 'updated'; |
|
| 2041 | + $hook = false; |
|
| 2042 | + } |
|
| 2043 | + //use class to change status |
|
| 2044 | + $this->_cpt_model_obj->set_status($event_status); |
|
| 2045 | + $success = $this->_cpt_model_obj->save(); |
|
| 2046 | + if ($success === false) { |
|
| 2047 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
| 2048 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2049 | + return false; |
|
| 2050 | + } |
|
| 2051 | + if ($hook) { |
|
| 2052 | + do_action($hook); |
|
| 2053 | + } |
|
| 2054 | + return true; |
|
| 2055 | + } |
|
| 2056 | + |
|
| 2057 | + |
|
| 2058 | + |
|
| 2059 | + /** |
|
| 2060 | + * _delete_event |
|
| 2061 | + * |
|
| 2062 | + * @access protected |
|
| 2063 | + * @param bool $redirect_after |
|
| 2064 | + */ |
|
| 2065 | + protected function _delete_event($redirect_after = true) |
|
| 2066 | + { |
|
| 2067 | + //determine the event id and set to array. |
|
| 2068 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
| 2069 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
| 2070 | + // loop thru events |
|
| 2071 | + if ($EVT_ID) { |
|
| 2072 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
| 2073 | + // get list of events with no prices |
|
| 2074 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2075 | + // remove this event from the list of events with no prices |
|
| 2076 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
| 2077 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2078 | + } |
|
| 2079 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2080 | + } else { |
|
| 2081 | + $success = false; |
|
| 2082 | + $msg = esc_html__( |
|
| 2083 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2084 | + 'event_espresso' |
|
| 2085 | + ); |
|
| 2086 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2087 | + } |
|
| 2088 | + if ($redirect_after) { |
|
| 2089 | + $this->_redirect_after_action( |
|
| 2090 | + $success, |
|
| 2091 | + 'Event', |
|
| 2092 | + 'deleted', |
|
| 2093 | + array('action' => 'default', 'status' => 'trash') |
|
| 2094 | + ); |
|
| 2095 | + } |
|
| 2096 | + } |
|
| 2097 | + |
|
| 2098 | + |
|
| 2099 | + |
|
| 2100 | + /** |
|
| 2101 | + * _delete_events |
|
| 2102 | + * |
|
| 2103 | + * @access protected |
|
| 2104 | + * @return void |
|
| 2105 | + */ |
|
| 2106 | + protected function _delete_events() |
|
| 2107 | + { |
|
| 2108 | + $success = true; |
|
| 2109 | + // get list of events with no prices |
|
| 2110 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
| 2111 | + //determine the event id and set to array. |
|
| 2112 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2113 | + // loop thru events |
|
| 2114 | + foreach ($EVT_IDs as $EVT_ID) { |
|
| 2115 | + $EVT_ID = absint($EVT_ID); |
|
| 2116 | + if ($EVT_ID) { |
|
| 2117 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
| 2118 | + $success = $results !== false ? $success : false; |
|
| 2119 | + // remove this event from the list of events with no prices |
|
| 2120 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
| 2121 | + } else { |
|
| 2122 | + $success = false; |
|
| 2123 | + $msg = esc_html__( |
|
| 2124 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
| 2125 | + 'event_espresso' |
|
| 2126 | + ); |
|
| 2127 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2128 | + } |
|
| 2129 | + } |
|
| 2130 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
| 2131 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
| 2132 | + $success = $success ? 2 : false; |
|
| 2133 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
| 2134 | + } |
|
| 2135 | + |
|
| 2136 | + |
|
| 2137 | + |
|
| 2138 | + /** |
|
| 2139 | + * _permanently_delete_event |
|
| 2140 | + * |
|
| 2141 | + * @access private |
|
| 2142 | + * @param int $EVT_ID |
|
| 2143 | + * @return bool |
|
| 2144 | + */ |
|
| 2145 | + private function _permanently_delete_event($EVT_ID = 0) |
|
| 2146 | + { |
|
| 2147 | + // grab event id |
|
| 2148 | + if ( ! $EVT_ID) { |
|
| 2149 | + $msg = esc_html__( |
|
| 2150 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
| 2151 | + 'event_espresso' |
|
| 2152 | + ); |
|
| 2153 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2154 | + return false; |
|
| 2155 | + } |
|
| 2156 | + if ( |
|
| 2157 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
| 2158 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
| 2159 | + ) { |
|
| 2160 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
| 2161 | + } |
|
| 2162 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
| 2163 | + return false; |
|
| 2164 | + } |
|
| 2165 | + //need to delete related tickets and prices first. |
|
| 2166 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
| 2167 | + foreach ($datetimes as $datetime) { |
|
| 2168 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
| 2169 | + $tickets = $datetime->get_many_related('Ticket'); |
|
| 2170 | + foreach ($tickets as $ticket) { |
|
| 2171 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
| 2172 | + $ticket->delete_related_permanently('Price'); |
|
| 2173 | + $ticket->delete_permanently(); |
|
| 2174 | + } |
|
| 2175 | + $datetime->delete(); |
|
| 2176 | + } |
|
| 2177 | + //what about related venues or terms? |
|
| 2178 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
| 2179 | + foreach ($venues as $venue) { |
|
| 2180 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
| 2181 | + } |
|
| 2182 | + //any attached question groups? |
|
| 2183 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
| 2184 | + if ( ! empty($question_groups)) { |
|
| 2185 | + foreach ($question_groups as $question_group) { |
|
| 2186 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
| 2187 | + } |
|
| 2188 | + } |
|
| 2189 | + //Message Template Groups |
|
| 2190 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
| 2191 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
| 2192 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
| 2193 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
| 2194 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
| 2195 | + } |
|
| 2196 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
| 2197 | + // did it all go as planned ? |
|
| 2198 | + if ($success) { |
|
| 2199 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
| 2200 | + EE_Error::add_success($msg); |
|
| 2201 | + } else { |
|
| 2202 | + $msg = sprintf( |
|
| 2203 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
| 2204 | + $EVT_ID |
|
| 2205 | + ); |
|
| 2206 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2207 | + return false; |
|
| 2208 | + } |
|
| 2209 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
| 2210 | + return true; |
|
| 2211 | + } |
|
| 2212 | + |
|
| 2213 | + |
|
| 2214 | + |
|
| 2215 | + /** |
|
| 2216 | + * get total number of events |
|
| 2217 | + * |
|
| 2218 | + * @access public |
|
| 2219 | + * @return int |
|
| 2220 | + */ |
|
| 2221 | + public function total_events() |
|
| 2222 | + { |
|
| 2223 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2224 | + return $count; |
|
| 2225 | + } |
|
| 2226 | + |
|
| 2227 | + |
|
| 2228 | + |
|
| 2229 | + /** |
|
| 2230 | + * get total number of draft events |
|
| 2231 | + * |
|
| 2232 | + * @access public |
|
| 2233 | + * @return int |
|
| 2234 | + */ |
|
| 2235 | + public function total_events_draft() |
|
| 2236 | + { |
|
| 2237 | + $where = array( |
|
| 2238 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
| 2239 | + ); |
|
| 2240 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2241 | + return $count; |
|
| 2242 | + } |
|
| 2243 | + |
|
| 2244 | + |
|
| 2245 | + |
|
| 2246 | + /** |
|
| 2247 | + * get total number of trashed events |
|
| 2248 | + * |
|
| 2249 | + * @access public |
|
| 2250 | + * @return int |
|
| 2251 | + */ |
|
| 2252 | + public function total_trashed_events() |
|
| 2253 | + { |
|
| 2254 | + $where = array( |
|
| 2255 | + 'status' => 'trash', |
|
| 2256 | + ); |
|
| 2257 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 2258 | + return $count; |
|
| 2259 | + } |
|
| 2260 | + |
|
| 2261 | + |
|
| 2262 | + /** |
|
| 2263 | + * _default_event_settings |
|
| 2264 | + * This generates the Default Settings Tab |
|
| 2265 | + * |
|
| 2266 | + * @return void |
|
| 2267 | + * @throws EE_Error |
|
| 2268 | + */ |
|
| 2269 | + protected function _default_event_settings() |
|
| 2270 | + { |
|
| 2271 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
| 2272 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 2273 | + $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html(); |
|
| 2274 | + $this->display_admin_page_with_sidebar(); |
|
| 2275 | + } |
|
| 2276 | + |
|
| 2277 | + |
|
| 2278 | + /** |
|
| 2279 | + * Return the form for event settings. |
|
| 2280 | + * @return EE_Form_Section_Proper |
|
| 2281 | + */ |
|
| 2282 | + protected function _default_event_settings_form() |
|
| 2283 | + { |
|
| 2284 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2285 | + $registration_stati_for_selection = EEM_Registration::reg_status_array( |
|
| 2286 | + //exclude |
|
| 2287 | + array( |
|
| 2288 | + EEM_Registration::status_id_cancelled, |
|
| 2289 | + EEM_Registration::status_id_declined, |
|
| 2290 | + EEM_Registration::status_id_incomplete, |
|
| 2291 | + EEM_Registration::status_id_wait_list, |
|
| 2292 | + ), |
|
| 2293 | + true |
|
| 2294 | + ); |
|
| 2295 | + return new EE_Form_Section_Proper( |
|
| 2296 | + array( |
|
| 2297 | + 'name' => 'update_default_event_settings', |
|
| 2298 | + 'html_id' => 'update_default_event_settings', |
|
| 2299 | + 'html_class' => 'form-table', |
|
| 2300 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
| 2301 | + 'subsections' => apply_filters( |
|
| 2302 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections', |
|
| 2303 | + array( |
|
| 2304 | + 'default_reg_status' => new EE_Select_Input( |
|
| 2305 | + $registration_stati_for_selection, |
|
| 2306 | + array( |
|
| 2307 | + 'default' => isset($registration_config->default_STS_ID) |
|
| 2308 | + && array_key_exists( |
|
| 2309 | + $registration_config->default_STS_ID, |
|
| 2310 | + $registration_stati_for_selection |
|
| 2311 | + ) |
|
| 2312 | + ? sanitize_text_field($registration_config->default_STS_ID) |
|
| 2313 | + : EEM_Registration::status_id_pending_payment, |
|
| 2314 | + 'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') |
|
| 2315 | + . EEH_Template::get_help_tab_link( |
|
| 2316 | + 'default_settings_status_help_tab' |
|
| 2317 | + ), |
|
| 2318 | + 'html_help_text' => esc_html__( |
|
| 2319 | + 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.', |
|
| 2320 | + 'event_espresso' |
|
| 2321 | + ) |
|
| 2322 | + ) |
|
| 2323 | + ), |
|
| 2324 | + 'default_max_tickets' => new EE_Integer_Input( |
|
| 2325 | + array( |
|
| 2326 | + 'default' => isset($registration_config->default_maximum_number_of_tickets) |
|
| 2327 | + ? $registration_config->default_maximum_number_of_tickets |
|
| 2328 | + : EEM_Event::get_default_additional_limit(), |
|
| 2329 | + 'html_label_text' => esc_html__( |
|
| 2330 | + 'Default Maximum Tickets Allowed Per Order:', |
|
| 2331 | + 'event_espresso' |
|
| 2332 | + ) . EEH_Template::get_help_tab_link( |
|
| 2333 | + 'default_maximum_tickets_help_tab"' |
|
| 2334 | + ), |
|
| 2335 | + 'html_help_text' => esc_html__( |
|
| 2336 | + 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.', |
|
| 2337 | + 'event_espresso' |
|
| 2338 | + ) |
|
| 2339 | + ) |
|
| 2340 | + ) |
|
| 2341 | + ) |
|
| 2342 | + ) |
|
| 2343 | + ) |
|
| 2344 | + ); |
|
| 2345 | + } |
|
| 2346 | + |
|
| 2347 | + |
|
| 2348 | + /** |
|
| 2349 | + * _update_default_event_settings |
|
| 2350 | + * |
|
| 2351 | + * @access protected |
|
| 2352 | + * @return void |
|
| 2353 | + * @throws EE_Error |
|
| 2354 | + */ |
|
| 2355 | + protected function _update_default_event_settings() |
|
| 2356 | + { |
|
| 2357 | + $registration_config = EE_Registry::instance()->CFG->registration; |
|
| 2358 | + $form = $this->_default_event_settings_form(); |
|
| 2359 | + if ($form->was_submitted()) { |
|
| 2360 | + $form->receive_form_submission(); |
|
| 2361 | + if ($form->is_valid()) { |
|
| 2362 | + $valid_data = $form->valid_data(); |
|
| 2363 | + if (isset($valid_data['default_reg_status'])) { |
|
| 2364 | + $registration_config->default_STS_ID = $valid_data['default_reg_status']; |
|
| 2365 | + } |
|
| 2366 | + if (isset($valid_data['default_max_tickets'])) { |
|
| 2367 | + $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets']; |
|
| 2368 | + } |
|
| 2369 | + //update because data was valid! |
|
| 2370 | + EE_Registry::instance()->CFG->update_espresso_config(); |
|
| 2371 | + EE_Error::overwrite_success(); |
|
| 2372 | + EE_Error::add_success( |
|
| 2373 | + __('Default Event Settings were updated', 'event_espresso') |
|
| 2374 | + ); |
|
| 2375 | + } |
|
| 2376 | + } |
|
| 2377 | + $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); |
|
| 2378 | + } |
|
| 2379 | + |
|
| 2380 | + |
|
| 2381 | + |
|
| 2382 | + /************* Templates *************/ |
|
| 2383 | + protected function _template_settings() |
|
| 2384 | + { |
|
| 2385 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
| 2386 | + $this->_template_args['preview_img'] = '<img src="' |
|
| 2387 | + . EVENTS_ASSETS_URL |
|
| 2388 | + . DS |
|
| 2389 | + . 'images' |
|
| 2390 | + . DS |
|
| 2391 | + . 'caffeinated_template_features.jpg" alt="' |
|
| 2392 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
| 2393 | + . '" />'; |
|
| 2394 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2395 | + 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
|
| 2396 | + 'event_espresso' |
|
| 2397 | + ) . '</strong>'; |
|
| 2398 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
| 2399 | + } |
|
| 2400 | + |
|
| 2401 | + |
|
| 2402 | + /** Event Category Stuff **/ |
|
| 2403 | + /** |
|
| 2404 | + * set the _category property with the category object for the loaded page. |
|
| 2405 | + * |
|
| 2406 | + * @access private |
|
| 2407 | + * @return void |
|
| 2408 | + */ |
|
| 2409 | + private function _set_category_object() |
|
| 2410 | + { |
|
| 2411 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
| 2412 | + return; |
|
| 2413 | + } //already have the category object so get out. |
|
| 2414 | + //set default category object |
|
| 2415 | + $this->_set_empty_category_object(); |
|
| 2416 | + //only set if we've got an id |
|
| 2417 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
| 2418 | + return; |
|
| 2419 | + } |
|
| 2420 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
| 2421 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
| 2422 | + if ( ! empty($term)) { |
|
| 2423 | + $this->_category->category_name = $term->name; |
|
| 2424 | + $this->_category->category_identifier = $term->slug; |
|
| 2425 | + $this->_category->category_desc = $term->description; |
|
| 2426 | + $this->_category->id = $term->term_id; |
|
| 2427 | + $this->_category->parent = $term->parent; |
|
| 2428 | + } |
|
| 2429 | + } |
|
| 2430 | + |
|
| 2431 | + |
|
| 2432 | + /** |
|
| 2433 | + * Clears out category properties. |
|
| 2434 | + */ |
|
| 2435 | + private function _set_empty_category_object() |
|
| 2436 | + { |
|
| 2437 | + $this->_category = new stdClass(); |
|
| 2438 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
| 2439 | + $this->_category->id = $this->_category->parent = 0; |
|
| 2440 | + } |
|
| 2441 | + |
|
| 2442 | + |
|
| 2443 | + /** |
|
| 2444 | + * @throws EE_Error |
|
| 2445 | + */ |
|
| 2446 | + protected function _category_list_table() |
|
| 2447 | + { |
|
| 2448 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2449 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
| 2450 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2451 | + 'add_category', |
|
| 2452 | + 'add_category', |
|
| 2453 | + array(), |
|
| 2454 | + 'add-new-h2' |
|
| 2455 | + ); |
|
| 2456 | + $this->display_admin_list_table_page_with_sidebar(); |
|
| 2457 | + } |
|
| 2458 | + |
|
| 2459 | + |
|
| 2460 | + |
|
| 2461 | + /** |
|
| 2462 | + * Output category details view. |
|
| 2463 | + */ |
|
| 2464 | + protected function _category_details($view) |
|
| 2465 | + { |
|
| 2466 | + //load formatter helper |
|
| 2467 | + //load field generator helper |
|
| 2468 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
| 2469 | + $this->_set_add_edit_form_tags($route); |
|
| 2470 | + $this->_set_category_object(); |
|
| 2471 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
| 2472 | + $delete_action = 'delete_category'; |
|
| 2473 | + //custom redirect |
|
| 2474 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
| 2475 | + array('action' => 'category_list'), |
|
| 2476 | + $this->_admin_base_url |
|
| 2477 | + ); |
|
| 2478 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
| 2479 | + //take care of contents |
|
| 2480 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
| 2481 | + $this->display_admin_page_with_sidebar(); |
|
| 2482 | + } |
|
| 2483 | + |
|
| 2484 | + |
|
| 2485 | + |
|
| 2486 | + /** |
|
| 2487 | + * Output category details content. |
|
| 2488 | + */ |
|
| 2489 | + protected function _category_details_content() |
|
| 2490 | + { |
|
| 2491 | + $editor_args['category_desc'] = array( |
|
| 2492 | + 'type' => 'wp_editor', |
|
| 2493 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
| 2494 | + 'class' => 'my_editor_custom', |
|
| 2495 | + 'wpeditor_args' => array('media_buttons' => false), |
|
| 2496 | + ); |
|
| 2497 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
| 2498 | + $all_terms = get_terms( |
|
| 2499 | + array('espresso_event_categories'), |
|
| 2500 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
| 2501 | + ); |
|
| 2502 | + //setup category select for term parents. |
|
| 2503 | + $category_select_values[] = array( |
|
| 2504 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
| 2505 | + 'id' => 0, |
|
| 2506 | + ); |
|
| 2507 | + foreach ($all_terms as $term) { |
|
| 2508 | + $category_select_values[] = array( |
|
| 2509 | + 'text' => $term->name, |
|
| 2510 | + 'id' => $term->term_id, |
|
| 2511 | + ); |
|
| 2512 | + } |
|
| 2513 | + $category_select = EEH_Form_Fields::select_input( |
|
| 2514 | + 'category_parent', |
|
| 2515 | + $category_select_values, |
|
| 2516 | + $this->_category->parent |
|
| 2517 | + ); |
|
| 2518 | + $template_args = array( |
|
| 2519 | + 'category' => $this->_category, |
|
| 2520 | + 'category_select' => $category_select, |
|
| 2521 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
| 2522 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
| 2523 | + 'disable' => '', |
|
| 2524 | + 'disabled_message' => false, |
|
| 2525 | + ); |
|
| 2526 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2527 | + return EEH_Template::display_template($template, $template_args, true); |
|
| 2528 | + } |
|
| 2529 | + |
|
| 2530 | + |
|
| 2531 | + /** |
|
| 2532 | + * Handles deleting categories. |
|
| 2533 | + */ |
|
| 2534 | + protected function _delete_categories() |
|
| 2535 | + { |
|
| 2536 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2537 | + : (array)$this->_req_data['category_id']; |
|
| 2538 | + foreach ($cat_ids as $cat_id) { |
|
| 2539 | + $this->_delete_category($cat_id); |
|
| 2540 | + } |
|
| 2541 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
| 2542 | + $query_args = array( |
|
| 2543 | + 'action' => 'category_list', |
|
| 2544 | + ); |
|
| 2545 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
| 2546 | + } |
|
| 2547 | + |
|
| 2548 | + |
|
| 2549 | + |
|
| 2550 | + /** |
|
| 2551 | + * Handles deleting specific category. |
|
| 2552 | + * @param int $cat_id |
|
| 2553 | + */ |
|
| 2554 | + protected function _delete_category($cat_id) |
|
| 2555 | + { |
|
| 2556 | + $cat_id = absint($cat_id); |
|
| 2557 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
| 2558 | + } |
|
| 2559 | + |
|
| 2560 | + |
|
| 2561 | + |
|
| 2562 | + /** |
|
| 2563 | + * Handles triggering the update or insertion of a new category. |
|
| 2564 | + * @param bool $new_category true means we're triggering the insert of a new category. |
|
| 2565 | + */ |
|
| 2566 | + protected function _insert_or_update_category($new_category) |
|
| 2567 | + { |
|
| 2568 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
| 2569 | + $success = 0; //we already have a success message so lets not send another. |
|
| 2570 | + if ($cat_id) { |
|
| 2571 | + $query_args = array( |
|
| 2572 | + 'action' => 'edit_category', |
|
| 2573 | + 'EVT_CAT_ID' => $cat_id, |
|
| 2574 | + ); |
|
| 2575 | + } else { |
|
| 2576 | + $query_args = array('action' => 'add_category'); |
|
| 2577 | + } |
|
| 2578 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
| 2579 | + } |
|
| 2580 | + |
|
| 2581 | + |
|
| 2582 | + |
|
| 2583 | + /** |
|
| 2584 | + * Inserts or updates category |
|
| 2585 | + * @param bool $update (true indicates we're updating a category). |
|
| 2586 | + * @return bool|mixed|string |
|
| 2587 | + */ |
|
| 2588 | + private function _insert_category($update = false) |
|
| 2589 | + { |
|
| 2590 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
| 2591 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
| 2592 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
| 2593 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
| 2594 | + if (empty($category_name)) { |
|
| 2595 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
| 2596 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2597 | + return false; |
|
| 2598 | + } |
|
| 2599 | + $term_args = array( |
|
| 2600 | + 'name' => $category_name, |
|
| 2601 | + 'description' => $category_desc, |
|
| 2602 | + 'parent' => $category_parent, |
|
| 2603 | + ); |
|
| 2604 | + //was the category_identifier input disabled? |
|
| 2605 | + if (isset($this->_req_data['category_identifier'])) { |
|
| 2606 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
| 2607 | + } |
|
| 2608 | + $insert_ids = $update |
|
| 2609 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
| 2610 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
| 2611 | + if ( ! is_array($insert_ids)) { |
|
| 2612 | + $msg = esc_html__( |
|
| 2613 | + 'An error occurred and the category has not been saved to the database.', |
|
| 2614 | + 'event_espresso' |
|
| 2615 | + ); |
|
| 2616 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2617 | + } else { |
|
| 2618 | + $cat_id = $insert_ids['term_id']; |
|
| 2619 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
| 2620 | + EE_Error::add_success($msg); |
|
| 2621 | + } |
|
| 2622 | + return $cat_id; |
|
| 2623 | + } |
|
| 2624 | + |
|
| 2625 | + |
|
| 2626 | + |
|
| 2627 | + /** |
|
| 2628 | + * Gets categories or count of categories matching the arguments in the request. |
|
| 2629 | + * @param int $per_page |
|
| 2630 | + * @param int $current_page |
|
| 2631 | + * @param bool $count |
|
| 2632 | + * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int |
|
| 2633 | + */ |
|
| 2634 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
| 2635 | + { |
|
| 2636 | + //testing term stuff |
|
| 2637 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
| 2638 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
| 2639 | + $limit = ($current_page - 1) * $per_page; |
|
| 2640 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
| 2641 | + if (isset($this->_req_data['s'])) { |
|
| 2642 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2643 | + $where['OR'] = array( |
|
| 2644 | + 'Term.name' => array('LIKE', $sstr), |
|
| 2645 | + 'description' => array('LIKE', $sstr), |
|
| 2646 | + ); |
|
| 2647 | + } |
|
| 2648 | + $query_params = array( |
|
| 2649 | + $where, |
|
| 2650 | + 'order_by' => array($orderby => $order), |
|
| 2651 | + 'limit' => $limit . ',' . $per_page, |
|
| 2652 | + 'force_join' => array('Term'), |
|
| 2653 | + ); |
|
| 2654 | + $categories = $count |
|
| 2655 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
| 2656 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
| 2657 | + return $categories; |
|
| 2658 | + } |
|
| 2659 | + |
|
| 2660 | + /* end category stuff */ |
|
| 2661 | + /**************/ |
|
| 2662 | + |
|
| 2663 | + |
|
| 2664 | + /** |
|
| 2665 | + * Callback for the `ee_save_timezone_setting` ajax action. |
|
| 2666 | + * @throws EE_Error |
|
| 2667 | + */ |
|
| 2668 | + public function save_timezonestring_setting() |
|
| 2669 | + { |
|
| 2670 | + $timezone_string = isset($this->_req_data['timezone_selected']) |
|
| 2671 | + ? $this->_req_data['timezone_selected'] |
|
| 2672 | + : ''; |
|
| 2673 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2674 | + { |
|
| 2675 | + EE_Error::add_error( |
|
| 2676 | + esc_html('An invalid timezone string submitted.', 'event_espresso'), |
|
| 2677 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2678 | + ); |
|
| 2679 | + $this->_template_args['error'] = true; |
|
| 2680 | + $this->_return_json(); |
|
| 2681 | + } |
|
| 2682 | + |
|
| 2683 | + update_option('timezone_string', $timezone_string); |
|
| 2684 | + EE_Error::add_success( |
|
| 2685 | + esc_html__('Your timezone string was updated.', 'event_espresso') |
|
| 2686 | + ); |
|
| 2687 | + $this->_template_args['success'] = true; |
|
| 2688 | + $this->_return_json(true, array('action' => 'create_new')); |
|
| 2689 | + } |
|
| 2690 | 2690 | } |
| 2691 | 2691 | //end class Events_Admin_Page |
@@ -553,11 +553,11 @@ discard block |
||
| 553 | 553 | { |
| 554 | 554 | wp_register_style( |
| 555 | 555 | 'events-admin-css', |
| 556 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
| 556 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
| 557 | 557 | array(), |
| 558 | 558 | EVENT_ESPRESSO_VERSION |
| 559 | 559 | ); |
| 560 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 560 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 561 | 561 | wp_enqueue_style('events-admin-css'); |
| 562 | 562 | wp_enqueue_style('ee-cat-admin'); |
| 563 | 563 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | //scripts |
| 566 | 566 | wp_register_script( |
| 567 | 567 | 'event_editor_js', |
| 568 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
| 568 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
| 569 | 569 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
| 570 | 570 | EVENT_ESPRESSO_VERSION, |
| 571 | 571 | true |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | wp_enqueue_style('espresso-ui-theme'); |
| 594 | 594 | wp_register_style( |
| 595 | 595 | 'event-editor-css', |
| 596 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
| 596 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
| 597 | 597 | array('ee-admin-css'), |
| 598 | 598 | EVENT_ESPRESSO_VERSION |
| 599 | 599 | ); |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | //scripts |
| 602 | 602 | wp_register_script( |
| 603 | 603 | 'event-datetime-metabox', |
| 604 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
| 604 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
| 605 | 605 | array('event_editor_js', 'ee-datepicker'), |
| 606 | 606 | EVENT_ESPRESSO_VERSION |
| 607 | 607 | ); |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $event = $this->_cpt_model_obj; |
| 674 | 674 | } |
| 675 | 675 | // STILL no event? |
| 676 | - if (! $event instanceof EE_Event) { |
|
| 676 | + if ( ! $event instanceof EE_Event) { |
|
| 677 | 677 | return; |
| 678 | 678 | } |
| 679 | 679 | $orig_status = $event->status(); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | { |
| 756 | 756 | $has_timezone_string = get_option('timezone_string'); |
| 757 | 757 | //only nag them about setting their timezone if it's their first event, and they haven't already done it |
| 758 | - if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 758 | + if ( ! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { |
|
| 759 | 759 | EE_Error::add_attention( |
| 760 | 760 | sprintf( |
| 761 | 761 | __( |
@@ -839,31 +839,31 @@ discard block |
||
| 839 | 839 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
| 840 | 840 | $statuses = array( |
| 841 | 841 | 'sold_out_status' => array( |
| 842 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
| 842 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
| 843 | 843 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
| 844 | 844 | ), |
| 845 | 845 | 'active_status' => array( |
| 846 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
| 846 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
| 847 | 847 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
| 848 | 848 | ), |
| 849 | 849 | 'upcoming_status' => array( |
| 850 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
| 850 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
| 851 | 851 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
| 852 | 852 | ), |
| 853 | 853 | 'postponed_status' => array( |
| 854 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
| 854 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
| 855 | 855 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
| 856 | 856 | ), |
| 857 | 857 | 'cancelled_status' => array( |
| 858 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
| 858 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
| 859 | 859 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
| 860 | 860 | ), |
| 861 | 861 | 'expired_status' => array( |
| 862 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
| 862 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
| 863 | 863 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
| 864 | 864 | ), |
| 865 | 865 | 'inactive_status' => array( |
| 866 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
| 866 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
| 867 | 867 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
| 868 | 868 | ), |
| 869 | 869 | ); |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | { |
| 926 | 926 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 927 | 927 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
| 928 | - ? (array)$this->_template_args['after_list_table'] |
|
| 928 | + ? (array) $this->_template_args['after_list_table'] |
|
| 929 | 929 | : array(); |
| 930 | 930 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
| 931 | 931 | . EEH_Template::get_button_or_link( |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | 'button' |
| 935 | 935 | ); |
| 936 | 936 | $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
| 937 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 937 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 938 | 938 | 'create_new', |
| 939 | 939 | 'add', |
| 940 | 940 | array(), |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | */ |
| 1065 | 1065 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
| 1066 | 1066 | { |
| 1067 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
| 1067 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
| 1068 | 1068 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
| 1069 | 1069 | $rows_affected = null; |
| 1070 | 1070 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | if (empty($tkt['TKT_start_date'])) { |
| 1189 | 1189 | //let's use now in the set timezone. |
| 1190 | 1190 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
| 1191 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
| 1191 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
| 1192 | 1192 | } |
| 1193 | 1193 | if (empty($tkt['TKT_end_date'])) { |
| 1194 | 1194 | //use the start date of the first datetime |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
| 1468 | 1468 | // load template |
| 1469 | 1469 | EEH_Template::display_template( |
| 1470 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
| 1470 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
| 1471 | 1471 | $publish_box_extra_args |
| 1472 | 1472 | ); |
| 1473 | 1473 | } |
@@ -1594,7 +1594,7 @@ discard block |
||
| 1594 | 1594 | ); |
| 1595 | 1595 | $template = apply_filters( |
| 1596 | 1596 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
| 1597 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
| 1597 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
| 1598 | 1598 | ); |
| 1599 | 1599 | EEH_Template::display_template($template, $template_args); |
| 1600 | 1600 | } |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
| 1614 | 1614 | { |
| 1615 | 1615 | $template_args = array( |
| 1616 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
| 1616 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
| 1617 | 1617 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
| 1618 | 1618 | : '', |
| 1619 | 1619 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1667,7 +1667,7 @@ discard block |
||
| 1667 | 1667 | $template_args = array_merge($template_args, $price_args); |
| 1668 | 1668 | $template = apply_filters( |
| 1669 | 1669 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
| 1670 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
| 1670 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
| 1671 | 1671 | $ticket |
| 1672 | 1672 | ); |
| 1673 | 1673 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1721,7 +1721,7 @@ discard block |
||
| 1721 | 1721 | $default_reg_status_values |
| 1722 | 1722 | ); |
| 1723 | 1723 | EEH_Template::display_template( |
| 1724 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 1724 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
| 1725 | 1725 | $template_args |
| 1726 | 1726 | ); |
| 1727 | 1727 | } |
@@ -1744,7 +1744,7 @@ discard block |
||
| 1744 | 1744 | { |
| 1745 | 1745 | $EEME = $this->_event_model(); |
| 1746 | 1746 | $offset = ($current_page - 1) * $per_page; |
| 1747 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
| 1747 | + $limit = $count ? null : $offset.','.$per_page; |
|
| 1748 | 1748 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
| 1749 | 1749 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
| 1750 | 1750 | if (isset($this->_req_data['month_range'])) { |
@@ -1781,7 +1781,7 @@ discard block |
||
| 1781 | 1781 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
| 1782 | 1782 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
| 1783 | 1783 | $DateTime = new DateTime( |
| 1784 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
| 1784 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
| 1785 | 1785 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
| 1786 | 1786 | ); |
| 1787 | 1787 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1827,7 +1827,7 @@ discard block |
||
| 1827 | 1827 | } |
| 1828 | 1828 | //search query handling |
| 1829 | 1829 | if (isset($this->_req_data['s'])) { |
| 1830 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
| 1830 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
| 1831 | 1831 | $where['OR'] = array( |
| 1832 | 1832 | 'EVT_name' => array('LIKE', $search_string), |
| 1833 | 1833 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1961,7 +1961,7 @@ discard block |
||
| 1961 | 1961 | if ( ! empty($event_status)) { |
| 1962 | 1962 | $success = true; |
| 1963 | 1963 | //determine the event id and set to array. |
| 1964 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 1964 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
| 1965 | 1965 | // loop thru events |
| 1966 | 1966 | foreach ($EVT_IDs as $EVT_ID) { |
| 1967 | 1967 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2109,7 +2109,7 @@ discard block |
||
| 2109 | 2109 | // get list of events with no prices |
| 2110 | 2110 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
| 2111 | 2111 | //determine the event id and set to array. |
| 2112 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
| 2112 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
| 2113 | 2113 | // loop thru events |
| 2114 | 2114 | foreach ($EVT_IDs as $EVT_ID) { |
| 2115 | 2115 | $EVT_ID = absint($EVT_ID); |
@@ -2329,7 +2329,7 @@ discard block |
||
| 2329 | 2329 | 'html_label_text' => esc_html__( |
| 2330 | 2330 | 'Default Maximum Tickets Allowed Per Order:', |
| 2331 | 2331 | 'event_espresso' |
| 2332 | - ) . EEH_Template::get_help_tab_link( |
|
| 2332 | + ).EEH_Template::get_help_tab_link( |
|
| 2333 | 2333 | 'default_maximum_tickets_help_tab"' |
| 2334 | 2334 | ), |
| 2335 | 2335 | 'html_help_text' => esc_html__( |
@@ -2391,10 +2391,10 @@ discard block |
||
| 2391 | 2391 | . 'caffeinated_template_features.jpg" alt="' |
| 2392 | 2392 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
| 2393 | 2393 | . '" />'; |
| 2394 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
| 2394 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
| 2395 | 2395 | 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
| 2396 | 2396 | 'event_espresso' |
| 2397 | - ) . '</strong>'; |
|
| 2397 | + ).'</strong>'; |
|
| 2398 | 2398 | $this->display_admin_caf_preview_page('template_settings_tab'); |
| 2399 | 2399 | } |
| 2400 | 2400 | |
@@ -2447,7 +2447,7 @@ discard block |
||
| 2447 | 2447 | { |
| 2448 | 2448 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
| 2449 | 2449 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
| 2450 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 2450 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 2451 | 2451 | 'add_category', |
| 2452 | 2452 | 'add_category', |
| 2453 | 2453 | array(), |
@@ -2523,7 +2523,7 @@ discard block |
||
| 2523 | 2523 | 'disable' => '', |
| 2524 | 2524 | 'disabled_message' => false, |
| 2525 | 2525 | ); |
| 2526 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
| 2526 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
| 2527 | 2527 | return EEH_Template::display_template($template, $template_args, true); |
| 2528 | 2528 | } |
| 2529 | 2529 | |
@@ -2533,8 +2533,8 @@ discard block |
||
| 2533 | 2533 | */ |
| 2534 | 2534 | protected function _delete_categories() |
| 2535 | 2535 | { |
| 2536 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
| 2537 | - : (array)$this->_req_data['category_id']; |
|
| 2536 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
| 2537 | + : (array) $this->_req_data['category_id']; |
|
| 2538 | 2538 | foreach ($cat_ids as $cat_id) { |
| 2539 | 2539 | $this->_delete_category($cat_id); |
| 2540 | 2540 | } |
@@ -2639,7 +2639,7 @@ discard block |
||
| 2639 | 2639 | $limit = ($current_page - 1) * $per_page; |
| 2640 | 2640 | $where = array('taxonomy' => 'espresso_event_categories'); |
| 2641 | 2641 | if (isset($this->_req_data['s'])) { |
| 2642 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 2642 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 2643 | 2643 | $where['OR'] = array( |
| 2644 | 2644 | 'Term.name' => array('LIKE', $sstr), |
| 2645 | 2645 | 'description' => array('LIKE', $sstr), |
@@ -2648,7 +2648,7 @@ discard block |
||
| 2648 | 2648 | $query_params = array( |
| 2649 | 2649 | $where, |
| 2650 | 2650 | 'order_by' => array($orderby => $order), |
| 2651 | - 'limit' => $limit . ',' . $per_page, |
|
| 2651 | + 'limit' => $limit.','.$per_page, |
|
| 2652 | 2652 | 'force_join' => array('Term'), |
| 2653 | 2653 | ); |
| 2654 | 2654 | $categories = $count |
@@ -2670,7 +2670,7 @@ discard block |
||
| 2670 | 2670 | $timezone_string = isset($this->_req_data['timezone_selected']) |
| 2671 | 2671 | ? $this->_req_data['timezone_selected'] |
| 2672 | 2672 | : ''; |
| 2673 | - if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2673 | + if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) |
|
| 2674 | 2674 | { |
| 2675 | 2675 | EE_Error::add_error( |
| 2676 | 2676 | esc_html('An invalid timezone string submitted.', 'event_espresso'), |