@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
| 5 | - exit( 'No direct script access allowed' ); |
|
| 5 | + exit( 'No direct script access allowed' ); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -18,338 +18,338 @@ discard block |
||
| 18 | 18 | class Iframe |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /* |
|
| 21 | + /* |
|
| 22 | 22 | * HTML for notices and ajax gif |
| 23 | 23 | * @var string $title |
| 24 | 24 | */ |
| 25 | - protected $title = ''; |
|
| 25 | + protected $title = ''; |
|
| 26 | 26 | |
| 27 | - /* |
|
| 27 | + /* |
|
| 28 | 28 | * HTML for the content being displayed |
| 29 | 29 | * @var string $content |
| 30 | 30 | */ |
| 31 | - protected $content = ''; |
|
| 31 | + protected $content = ''; |
|
| 32 | 32 | |
| 33 | - /* |
|
| 33 | + /* |
|
| 34 | 34 | * whether or not to call wp_head() and wp_footer() |
| 35 | 35 | * @var boolean $enqueue_wp_assets |
| 36 | 36 | */ |
| 37 | - protected $enqueue_wp_assets = false; |
|
| 37 | + protected $enqueue_wp_assets = false; |
|
| 38 | 38 | |
| 39 | - /* |
|
| 39 | + /* |
|
| 40 | 40 | * an array of CSS URLs |
| 41 | 41 | * @var array $css |
| 42 | 42 | */ |
| 43 | - protected $css = array(); |
|
| 43 | + protected $css = array(); |
|
| 44 | 44 | |
| 45 | - /* |
|
| 45 | + /* |
|
| 46 | 46 | * an array of JS URLs to be set in the HTML header. |
| 47 | 47 | * @var array $header_js |
| 48 | 48 | */ |
| 49 | - protected $header_js = array(); |
|
| 49 | + protected $header_js = array(); |
|
| 50 | 50 | |
| 51 | - /* |
|
| 51 | + /* |
|
| 52 | 52 | * an array of JS URLs to be displayed before the HTML </body> tag |
| 53 | 53 | * @var array $footer_js |
| 54 | 54 | */ |
| 55 | - protected $footer_js = array(); |
|
| 55 | + protected $footer_js = array(); |
|
| 56 | 56 | |
| 57 | - /* |
|
| 57 | + /* |
|
| 58 | 58 | * an array of JSON vars to be set in the HTML header. |
| 59 | 59 | * @var array $localized_vars |
| 60 | 60 | */ |
| 61 | - protected $localized_vars = array(); |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Iframe constructor |
|
| 67 | - * |
|
| 68 | - * @param string $title |
|
| 69 | - * @param string $content |
|
| 70 | - * @throws \DomainException |
|
| 71 | - */ |
|
| 72 | - public function __construct( $title, $content ) |
|
| 73 | - { |
|
| 74 | - global $wp_version; |
|
| 75 | - if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
| 76 | - define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
| 77 | - } |
|
| 78 | - $this->setContent( $content ); |
|
| 79 | - $this->setTitle( $title ); |
|
| 80 | - $this->addStylesheets( |
|
| 81 | - apply_filters( |
|
| 82 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
| 83 | - array( |
|
| 84 | - 'site_theme' => get_stylesheet_directory_uri() . DS |
|
| 85 | - . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 86 | - 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
| 87 | - 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
| 88 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 89 | - ), |
|
| 90 | - $this |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 93 | - $this->addScripts( |
|
| 94 | - apply_filters( |
|
| 95 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
| 96 | - array( |
|
| 97 | - 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
| 98 | - 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
| 99 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 100 | - ), |
|
| 101 | - $this |
|
| 102 | - ) |
|
| 103 | - ); |
|
| 104 | - if ( |
|
| 105 | - apply_filters( |
|
| 106 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
| 107 | - false |
|
| 108 | - ) |
|
| 109 | - ) { |
|
| 110 | - $this->addStylesheets( |
|
| 111 | - apply_filters( |
|
| 112 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
| 113 | - array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
| 114 | - $this |
|
| 115 | - ) |
|
| 116 | - ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @param string $title |
|
| 124 | - * @throws \DomainException |
|
| 125 | - */ |
|
| 126 | - public function setTitle( $title ) |
|
| 127 | - { |
|
| 128 | - if ( empty( $title ) ) { |
|
| 129 | - throw new \DomainException( |
|
| 130 | - esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
| 131 | - ); |
|
| 132 | - } |
|
| 133 | - $this->title = $title; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param string $content |
|
| 140 | - * @throws \DomainException |
|
| 141 | - */ |
|
| 142 | - public function setContent( $content ) |
|
| 143 | - { |
|
| 144 | - if ( empty( $content ) ) { |
|
| 145 | - throw new \DomainException( |
|
| 146 | - esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - $this->content = $content; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * @param boolean $enqueue_wp_assets |
|
| 156 | - */ |
|
| 157 | - public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
| 158 | - { |
|
| 159 | - $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param array $stylesheets |
|
| 166 | - * @throws \DomainException |
|
| 167 | - */ |
|
| 168 | - public function addStylesheets( array $stylesheets ) |
|
| 169 | - { |
|
| 170 | - if ( empty( $stylesheets ) ) { |
|
| 171 | - throw new \DomainException( |
|
| 172 | - esc_html__( |
|
| 173 | - 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
| 174 | - 'event_espresso' |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - } |
|
| 178 | - foreach ( $stylesheets as $handle => $stylesheet ) { |
|
| 179 | - $this->css[ $handle ] = $stylesheet; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @param array $scripts |
|
| 187 | - * @param bool $add_to_header |
|
| 188 | - * @throws \DomainException |
|
| 189 | - */ |
|
| 190 | - public function addScripts( array $scripts, $add_to_header = false ) |
|
| 191 | - { |
|
| 192 | - if ( empty( $scripts ) ) { |
|
| 193 | - throw new \DomainException( |
|
| 194 | - esc_html__( |
|
| 195 | - 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
| 196 | - 'event_espresso' |
|
| 197 | - ) |
|
| 198 | - ); |
|
| 199 | - } |
|
| 200 | - foreach ( $scripts as $handle => $script ) { |
|
| 201 | - if ( $add_to_header ) { |
|
| 202 | - $this->header_js[ $handle ] = $script; |
|
| 203 | - } else { |
|
| 204 | - $this->footer_js[ $handle ] = $script; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * @param array $vars |
|
| 213 | - * @param string $var_name |
|
| 214 | - * @throws \DomainException |
|
| 215 | - */ |
|
| 216 | - public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
| 217 | - { |
|
| 218 | - if ( empty( $vars ) ) { |
|
| 219 | - throw new \DomainException( |
|
| 220 | - esc_html__( |
|
| 221 | - 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
| 222 | - 'event_espresso' |
|
| 223 | - ) |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - foreach ( $vars as $handle => $var ) { |
|
| 227 | - if ( $var_name === 'eei18n' ) { |
|
| 228 | - \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
| 229 | - } else { |
|
| 230 | - if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
| 231 | - $this->localized_vars[ $var_name ] = array(); |
|
| 232 | - } |
|
| 233 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
| 234 | - } |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @param string $utm_content |
|
| 242 | - * @throws \DomainException |
|
| 243 | - */ |
|
| 244 | - public function display($utm_content = '') |
|
| 245 | - { |
|
| 246 | - $this->content .= \EEH_Template::powered_by_event_espresso( |
|
| 247 | - '', |
|
| 248 | - '', |
|
| 249 | - ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
| 250 | - ); |
|
| 251 | - \EE_System::do_not_cache(); |
|
| 252 | - echo $this->getTemplate(); |
|
| 253 | - exit; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * @return string |
|
| 260 | - * @throws \DomainException |
|
| 261 | - */ |
|
| 262 | - public function getTemplate() |
|
| 263 | - { |
|
| 264 | - return \EEH_Template::display_template( |
|
| 265 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
| 266 | - array( |
|
| 267 | - 'title' => apply_filters( |
|
| 268 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
| 269 | - $this->title, |
|
| 270 | - $this |
|
| 271 | - ), |
|
| 272 | - 'content' => apply_filters( |
|
| 273 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
| 274 | - $this->content, |
|
| 275 | - $this |
|
| 276 | - ), |
|
| 277 | - 'enqueue_wp_assets' => apply_filters( |
|
| 278 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
| 279 | - $this->enqueue_wp_assets, |
|
| 280 | - $this |
|
| 281 | - ), |
|
| 282 | - 'css' => (array)apply_filters( |
|
| 283 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
| 284 | - $this->css, |
|
| 285 | - $this |
|
| 286 | - ), |
|
| 287 | - 'header_js' => (array)apply_filters( |
|
| 288 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
| 289 | - $this->header_js, |
|
| 290 | - $this |
|
| 291 | - ), |
|
| 292 | - 'footer_js' => (array)apply_filters( |
|
| 293 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
| 294 | - $this->footer_js, |
|
| 295 | - $this |
|
| 296 | - ), |
|
| 297 | - 'eei18n' => apply_filters( |
|
| 298 | - 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
| 299 | - \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
| 300 | - $this |
|
| 301 | - ), |
|
| 302 | - 'notices' => \EEH_Template::display_template( |
|
| 303 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
| 304 | - array(), |
|
| 305 | - true |
|
| 306 | - ), |
|
| 307 | - ), |
|
| 308 | - true, |
|
| 309 | - true |
|
| 310 | - ); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * localizeJsonVars |
|
| 317 | - * |
|
| 318 | - * @return string |
|
| 319 | - */ |
|
| 320 | - public function localizeJsonVars() |
|
| 321 | - { |
|
| 322 | - $JSON = ''; |
|
| 323 | - foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
| 324 | - foreach ( (array)$vars as $key => $value ) { |
|
| 325 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
| 326 | - } |
|
| 327 | - $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
| 328 | - $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
| 329 | - $JSON .= '; /* ]]> */'; |
|
| 330 | - } |
|
| 331 | - return $JSON; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @param bool|int|float|string|array $var |
|
| 338 | - * @return array |
|
| 339 | - */ |
|
| 340 | - public function encodeJsonVars( $var ) |
|
| 341 | - { |
|
| 342 | - if ( is_array( $var ) ) { |
|
| 343 | - $localized_vars = array(); |
|
| 344 | - foreach ( (array)$var as $key => $value ) { |
|
| 345 | - $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
| 346 | - } |
|
| 347 | - return $localized_vars; |
|
| 348 | - } else if ( is_scalar( $var ) ) { |
|
| 349 | - return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
| 350 | - } |
|
| 351 | - return null; |
|
| 352 | - } |
|
| 61 | + protected $localized_vars = array(); |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Iframe constructor |
|
| 67 | + * |
|
| 68 | + * @param string $title |
|
| 69 | + * @param string $content |
|
| 70 | + * @throws \DomainException |
|
| 71 | + */ |
|
| 72 | + public function __construct( $title, $content ) |
|
| 73 | + { |
|
| 74 | + global $wp_version; |
|
| 75 | + if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
| 76 | + define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
| 77 | + } |
|
| 78 | + $this->setContent( $content ); |
|
| 79 | + $this->setTitle( $title ); |
|
| 80 | + $this->addStylesheets( |
|
| 81 | + apply_filters( |
|
| 82 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
|
| 83 | + array( |
|
| 84 | + 'site_theme' => get_stylesheet_directory_uri() . DS |
|
| 85 | + . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 86 | + 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
| 87 | + 'espresso_default' => EE_GLOBAL_ASSETS_URL |
|
| 88 | + . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 89 | + ), |
|
| 90 | + $this |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | + $this->addScripts( |
|
| 94 | + apply_filters( |
|
| 95 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
|
| 96 | + array( |
|
| 97 | + 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
| 98 | + 'espresso_core' => EE_GLOBAL_ASSETS_URL |
|
| 99 | + . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 100 | + ), |
|
| 101 | + $this |
|
| 102 | + ) |
|
| 103 | + ); |
|
| 104 | + if ( |
|
| 105 | + apply_filters( |
|
| 106 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__load_default_theme_stylesheet', |
|
| 107 | + false |
|
| 108 | + ) |
|
| 109 | + ) { |
|
| 110 | + $this->addStylesheets( |
|
| 111 | + apply_filters( |
|
| 112 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_theme_stylesheet', |
|
| 113 | + array('default_theme_stylesheet' => get_stylesheet_uri()), |
|
| 114 | + $this |
|
| 115 | + ) |
|
| 116 | + ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @param string $title |
|
| 124 | + * @throws \DomainException |
|
| 125 | + */ |
|
| 126 | + public function setTitle( $title ) |
|
| 127 | + { |
|
| 128 | + if ( empty( $title ) ) { |
|
| 129 | + throw new \DomainException( |
|
| 130 | + esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | + $this->title = $title; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param string $content |
|
| 140 | + * @throws \DomainException |
|
| 141 | + */ |
|
| 142 | + public function setContent( $content ) |
|
| 143 | + { |
|
| 144 | + if ( empty( $content ) ) { |
|
| 145 | + throw new \DomainException( |
|
| 146 | + esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + $this->content = $content; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * @param boolean $enqueue_wp_assets |
|
| 156 | + */ |
|
| 157 | + public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
| 158 | + { |
|
| 159 | + $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param array $stylesheets |
|
| 166 | + * @throws \DomainException |
|
| 167 | + */ |
|
| 168 | + public function addStylesheets( array $stylesheets ) |
|
| 169 | + { |
|
| 170 | + if ( empty( $stylesheets ) ) { |
|
| 171 | + throw new \DomainException( |
|
| 172 | + esc_html__( |
|
| 173 | + 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
|
| 174 | + 'event_espresso' |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + } |
|
| 178 | + foreach ( $stylesheets as $handle => $stylesheet ) { |
|
| 179 | + $this->css[ $handle ] = $stylesheet; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @param array $scripts |
|
| 187 | + * @param bool $add_to_header |
|
| 188 | + * @throws \DomainException |
|
| 189 | + */ |
|
| 190 | + public function addScripts( array $scripts, $add_to_header = false ) |
|
| 191 | + { |
|
| 192 | + if ( empty( $scripts ) ) { |
|
| 193 | + throw new \DomainException( |
|
| 194 | + esc_html__( |
|
| 195 | + 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
|
| 196 | + 'event_espresso' |
|
| 197 | + ) |
|
| 198 | + ); |
|
| 199 | + } |
|
| 200 | + foreach ( $scripts as $handle => $script ) { |
|
| 201 | + if ( $add_to_header ) { |
|
| 202 | + $this->header_js[ $handle ] = $script; |
|
| 203 | + } else { |
|
| 204 | + $this->footer_js[ $handle ] = $script; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * @param array $vars |
|
| 213 | + * @param string $var_name |
|
| 214 | + * @throws \DomainException |
|
| 215 | + */ |
|
| 216 | + public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
| 217 | + { |
|
| 218 | + if ( empty( $vars ) ) { |
|
| 219 | + throw new \DomainException( |
|
| 220 | + esc_html__( |
|
| 221 | + 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
|
| 222 | + 'event_espresso' |
|
| 223 | + ) |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + foreach ( $vars as $handle => $var ) { |
|
| 227 | + if ( $var_name === 'eei18n' ) { |
|
| 228 | + \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
| 229 | + } else { |
|
| 230 | + if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
| 231 | + $this->localized_vars[ $var_name ] = array(); |
|
| 232 | + } |
|
| 233 | + $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @param string $utm_content |
|
| 242 | + * @throws \DomainException |
|
| 243 | + */ |
|
| 244 | + public function display($utm_content = '') |
|
| 245 | + { |
|
| 246 | + $this->content .= \EEH_Template::powered_by_event_espresso( |
|
| 247 | + '', |
|
| 248 | + '', |
|
| 249 | + ! empty($utm_content) ? array('utm_content' => $utm_content) : array() |
|
| 250 | + ); |
|
| 251 | + \EE_System::do_not_cache(); |
|
| 252 | + echo $this->getTemplate(); |
|
| 253 | + exit; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * @return string |
|
| 260 | + * @throws \DomainException |
|
| 261 | + */ |
|
| 262 | + public function getTemplate() |
|
| 263 | + { |
|
| 264 | + return \EEH_Template::display_template( |
|
| 265 | + __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
| 266 | + array( |
|
| 267 | + 'title' => apply_filters( |
|
| 268 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
|
| 269 | + $this->title, |
|
| 270 | + $this |
|
| 271 | + ), |
|
| 272 | + 'content' => apply_filters( |
|
| 273 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__content', |
|
| 274 | + $this->content, |
|
| 275 | + $this |
|
| 276 | + ), |
|
| 277 | + 'enqueue_wp_assets' => apply_filters( |
|
| 278 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__enqueue_wp_assets', |
|
| 279 | + $this->enqueue_wp_assets, |
|
| 280 | + $this |
|
| 281 | + ), |
|
| 282 | + 'css' => (array)apply_filters( |
|
| 283 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
|
| 284 | + $this->css, |
|
| 285 | + $this |
|
| 286 | + ), |
|
| 287 | + 'header_js' => (array)apply_filters( |
|
| 288 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
|
| 289 | + $this->header_js, |
|
| 290 | + $this |
|
| 291 | + ), |
|
| 292 | + 'footer_js' => (array)apply_filters( |
|
| 293 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
|
| 294 | + $this->footer_js, |
|
| 295 | + $this |
|
| 296 | + ), |
|
| 297 | + 'eei18n' => apply_filters( |
|
| 298 | + 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
|
| 299 | + \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
| 300 | + $this |
|
| 301 | + ), |
|
| 302 | + 'notices' => \EEH_Template::display_template( |
|
| 303 | + EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
| 304 | + array(), |
|
| 305 | + true |
|
| 306 | + ), |
|
| 307 | + ), |
|
| 308 | + true, |
|
| 309 | + true |
|
| 310 | + ); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * localizeJsonVars |
|
| 317 | + * |
|
| 318 | + * @return string |
|
| 319 | + */ |
|
| 320 | + public function localizeJsonVars() |
|
| 321 | + { |
|
| 322 | + $JSON = ''; |
|
| 323 | + foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
| 324 | + foreach ( (array)$vars as $key => $value ) { |
|
| 325 | + $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
| 326 | + } |
|
| 327 | + $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
|
| 328 | + $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
| 329 | + $JSON .= '; /* ]]> */'; |
|
| 330 | + } |
|
| 331 | + return $JSON; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @param bool|int|float|string|array $var |
|
| 338 | + * @return array |
|
| 339 | + */ |
|
| 340 | + public function encodeJsonVars( $var ) |
|
| 341 | + { |
|
| 342 | + if ( is_array( $var ) ) { |
|
| 343 | + $localized_vars = array(); |
|
| 344 | + foreach ( (array)$var as $key => $value ) { |
|
| 345 | + $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
| 346 | + } |
|
| 347 | + return $localized_vars; |
|
| 348 | + } else if ( is_scalar( $var ) ) { |
|
| 349 | + return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
| 350 | + } |
|
| 351 | + return null; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | |
| 355 | 355 | |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
| 3 | 3 | |
| 4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | * @param string $content |
| 70 | 70 | * @throws \DomainException |
| 71 | 71 | */ |
| 72 | - public function __construct( $title, $content ) |
|
| 72 | + public function __construct($title, $content) |
|
| 73 | 73 | { |
| 74 | 74 | global $wp_version; |
| 75 | - if ( ! defined( 'EE_IFRAME_DIR_URL' ) ) { |
|
| 76 | - define( 'EE_IFRAME_DIR_URL', plugin_dir_url( __FILE__ ) ); |
|
| 75 | + if ( ! defined('EE_IFRAME_DIR_URL')) { |
|
| 76 | + define('EE_IFRAME_DIR_URL', plugin_dir_url(__FILE__)); |
|
| 77 | 77 | } |
| 78 | - $this->setContent( $content ); |
|
| 79 | - $this->setTitle( $title ); |
|
| 78 | + $this->setContent($content); |
|
| 79 | + $this->setTitle($title); |
|
| 80 | 80 | $this->addStylesheets( |
| 81 | 81 | apply_filters( |
| 82 | 82 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_css', |
| 83 | 83 | array( |
| 84 | - 'site_theme' => get_stylesheet_directory_uri() . DS |
|
| 85 | - . 'style.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 86 | - 'dashicons' => includes_url( 'css/dashicons.min.css?ver=' . $wp_version ), |
|
| 84 | + 'site_theme' => get_stylesheet_directory_uri().DS |
|
| 85 | + . 'style.css?ver='.EVENT_ESPRESSO_VERSION, |
|
| 86 | + 'dashicons' => includes_url('css/dashicons.min.css?ver='.$wp_version), |
|
| 87 | 87 | 'espresso_default' => EE_GLOBAL_ASSETS_URL |
| 88 | - . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 88 | + . 'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION, |
|
| 89 | 89 | ), |
| 90 | 90 | $this |
| 91 | 91 | ) |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | apply_filters( |
| 95 | 95 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__construct__default_js', |
| 96 | 96 | array( |
| 97 | - 'jquery' => includes_url( 'js/jquery/jquery.js?ver=' . $wp_version ), |
|
| 97 | + 'jquery' => includes_url('js/jquery/jquery.js?ver='.$wp_version), |
|
| 98 | 98 | 'espresso_core' => EE_GLOBAL_ASSETS_URL |
| 99 | - . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
| 99 | + . 'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
| 100 | 100 | ), |
| 101 | 101 | $this |
| 102 | 102 | ) |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | * @param string $title |
| 124 | 124 | * @throws \DomainException |
| 125 | 125 | */ |
| 126 | - public function setTitle( $title ) |
|
| 126 | + public function setTitle($title) |
|
| 127 | 127 | { |
| 128 | - if ( empty( $title ) ) { |
|
| 128 | + if (empty($title)) { |
|
| 129 | 129 | throw new \DomainException( |
| 130 | - esc_html__( 'You must provide a page title in order to create an iframe.', 'event_espresso' ) |
|
| 130 | + esc_html__('You must provide a page title in order to create an iframe.', 'event_espresso') |
|
| 131 | 131 | ); |
| 132 | 132 | } |
| 133 | 133 | $this->title = $title; |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | * @param string $content |
| 140 | 140 | * @throws \DomainException |
| 141 | 141 | */ |
| 142 | - public function setContent( $content ) |
|
| 142 | + public function setContent($content) |
|
| 143 | 143 | { |
| 144 | - if ( empty( $content ) ) { |
|
| 144 | + if (empty($content)) { |
|
| 145 | 145 | throw new \DomainException( |
| 146 | - esc_html__( 'You must provide content in order to create an iframe.', 'event_espresso' ) |
|
| 146 | + esc_html__('You must provide content in order to create an iframe.', 'event_espresso') |
|
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | $this->content = $content; |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * @param boolean $enqueue_wp_assets |
| 156 | 156 | */ |
| 157 | - public function setEnqueueWpAssets( $enqueue_wp_assets ) |
|
| 157 | + public function setEnqueueWpAssets($enqueue_wp_assets) |
|
| 158 | 158 | { |
| 159 | - $this->enqueue_wp_assets = filter_var( $enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN ); |
|
| 159 | + $this->enqueue_wp_assets = filter_var($enqueue_wp_assets, FILTER_VALIDATE_BOOLEAN); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
@@ -165,9 +165,9 @@ discard block |
||
| 165 | 165 | * @param array $stylesheets |
| 166 | 166 | * @throws \DomainException |
| 167 | 167 | */ |
| 168 | - public function addStylesheets( array $stylesheets ) |
|
| 168 | + public function addStylesheets(array $stylesheets) |
|
| 169 | 169 | { |
| 170 | - if ( empty( $stylesheets ) ) { |
|
| 170 | + if (empty($stylesheets)) { |
|
| 171 | 171 | throw new \DomainException( |
| 172 | 172 | esc_html__( |
| 173 | 173 | 'A non-empty array of URLs, is required to add a CSS stylesheet to an iframe.', |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | ) |
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | - foreach ( $stylesheets as $handle => $stylesheet ) { |
|
| 179 | - $this->css[ $handle ] = $stylesheet; |
|
| 178 | + foreach ($stylesheets as $handle => $stylesheet) { |
|
| 179 | + $this->css[$handle] = $stylesheet; |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | * @param bool $add_to_header |
| 188 | 188 | * @throws \DomainException |
| 189 | 189 | */ |
| 190 | - public function addScripts( array $scripts, $add_to_header = false ) |
|
| 190 | + public function addScripts(array $scripts, $add_to_header = false) |
|
| 191 | 191 | { |
| 192 | - if ( empty( $scripts ) ) { |
|
| 192 | + if (empty($scripts)) { |
|
| 193 | 193 | throw new \DomainException( |
| 194 | 194 | esc_html__( |
| 195 | 195 | 'A non-empty array of URLs, is required to add Javascript to an iframe.', |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | ) |
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | - foreach ( $scripts as $handle => $script ) { |
|
| 201 | - if ( $add_to_header ) { |
|
| 202 | - $this->header_js[ $handle ] = $script; |
|
| 200 | + foreach ($scripts as $handle => $script) { |
|
| 201 | + if ($add_to_header) { |
|
| 202 | + $this->header_js[$handle] = $script; |
|
| 203 | 203 | } else { |
| 204 | - $this->footer_js[ $handle ] = $script; |
|
| 204 | + $this->footer_js[$handle] = $script; |
|
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | } |
@@ -213,9 +213,9 @@ discard block |
||
| 213 | 213 | * @param string $var_name |
| 214 | 214 | * @throws \DomainException |
| 215 | 215 | */ |
| 216 | - public function addLocalizedVars( array $vars, $var_name = 'eei18n' ) |
|
| 216 | + public function addLocalizedVars(array $vars, $var_name = 'eei18n') |
|
| 217 | 217 | { |
| 218 | - if ( empty( $vars ) ) { |
|
| 218 | + if (empty($vars)) { |
|
| 219 | 219 | throw new \DomainException( |
| 220 | 220 | esc_html__( |
| 221 | 221 | 'A non-empty array of vars, is required to add localized Javascript vars to an iframe.', |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | ) |
| 224 | 224 | ); |
| 225 | 225 | } |
| 226 | - foreach ( $vars as $handle => $var ) { |
|
| 227 | - if ( $var_name === 'eei18n' ) { |
|
| 228 | - \EE_Registry::$i18n_js_strings[ $handle ] = $var; |
|
| 226 | + foreach ($vars as $handle => $var) { |
|
| 227 | + if ($var_name === 'eei18n') { |
|
| 228 | + \EE_Registry::$i18n_js_strings[$handle] = $var; |
|
| 229 | 229 | } else { |
| 230 | - if ( ! isset( $this->localized_vars[ $var_name ] ) ) { |
|
| 231 | - $this->localized_vars[ $var_name ] = array(); |
|
| 230 | + if ( ! isset($this->localized_vars[$var_name])) { |
|
| 231 | + $this->localized_vars[$var_name] = array(); |
|
| 232 | 232 | } |
| 233 | - $this->localized_vars[ $var_name ][ $handle ] = $var; |
|
| 233 | + $this->localized_vars[$var_name][$handle] = $var; |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | public function getTemplate() |
| 263 | 263 | { |
| 264 | 264 | return \EEH_Template::display_template( |
| 265 | - __DIR__ . DIRECTORY_SEPARATOR . 'iframe_wrapper.template.php', |
|
| 265 | + __DIR__.DIRECTORY_SEPARATOR.'iframe_wrapper.template.php', |
|
| 266 | 266 | array( |
| 267 | 267 | 'title' => apply_filters( |
| 268 | 268 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__title', |
@@ -279,28 +279,28 @@ discard block |
||
| 279 | 279 | $this->enqueue_wp_assets, |
| 280 | 280 | $this |
| 281 | 281 | ), |
| 282 | - 'css' => (array)apply_filters( |
|
| 282 | + 'css' => (array) apply_filters( |
|
| 283 | 283 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__css_urls', |
| 284 | 284 | $this->css, |
| 285 | 285 | $this |
| 286 | 286 | ), |
| 287 | - 'header_js' => (array)apply_filters( |
|
| 287 | + 'header_js' => (array) apply_filters( |
|
| 288 | 288 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__header_js_urls', |
| 289 | 289 | $this->header_js, |
| 290 | 290 | $this |
| 291 | 291 | ), |
| 292 | - 'footer_js' => (array)apply_filters( |
|
| 292 | + 'footer_js' => (array) apply_filters( |
|
| 293 | 293 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__footer_js_urls', |
| 294 | 294 | $this->footer_js, |
| 295 | 295 | $this |
| 296 | 296 | ), |
| 297 | 297 | 'eei18n' => apply_filters( |
| 298 | 298 | 'FHEE___EventEspresso_core_libraries_iframe_display_Iframe__getTemplate__eei18n_js_strings', |
| 299 | - \EE_Registry::localize_i18n_js_strings() . $this->localizeJsonVars(), |
|
| 299 | + \EE_Registry::localize_i18n_js_strings().$this->localizeJsonVars(), |
|
| 300 | 300 | $this |
| 301 | 301 | ), |
| 302 | 302 | 'notices' => \EEH_Template::display_template( |
| 303 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
| 303 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
| 304 | 304 | array(), |
| 305 | 305 | true |
| 306 | 306 | ), |
@@ -320,12 +320,12 @@ discard block |
||
| 320 | 320 | public function localizeJsonVars() |
| 321 | 321 | { |
| 322 | 322 | $JSON = ''; |
| 323 | - foreach ( (array)$this->localized_vars as $var_name => $vars ) { |
|
| 324 | - foreach ( (array)$vars as $key => $value ) { |
|
| 325 | - $this->localized_vars[ $var_name ] = $this->encodeJsonVars( $value ); |
|
| 323 | + foreach ((array) $this->localized_vars as $var_name => $vars) { |
|
| 324 | + foreach ((array) $vars as $key => $value) { |
|
| 325 | + $this->localized_vars[$var_name] = $this->encodeJsonVars($value); |
|
| 326 | 326 | } |
| 327 | 327 | $JSON .= "/* <![CDATA[ */ var {$var_name} = "; |
| 328 | - $JSON .= wp_json_encode( $this->localized_vars[ $var_name ] ); |
|
| 328 | + $JSON .= wp_json_encode($this->localized_vars[$var_name]); |
|
| 329 | 329 | $JSON .= '; /* ]]> */'; |
| 330 | 330 | } |
| 331 | 331 | return $JSON; |
@@ -337,16 +337,16 @@ discard block |
||
| 337 | 337 | * @param bool|int|float|string|array $var |
| 338 | 338 | * @return array |
| 339 | 339 | */ |
| 340 | - public function encodeJsonVars( $var ) |
|
| 340 | + public function encodeJsonVars($var) |
|
| 341 | 341 | { |
| 342 | - if ( is_array( $var ) ) { |
|
| 342 | + if (is_array($var)) { |
|
| 343 | 343 | $localized_vars = array(); |
| 344 | - foreach ( (array)$var as $key => $value ) { |
|
| 345 | - $localized_vars[ $key ] = $this->encodeJsonVars( $value ); |
|
| 344 | + foreach ((array) $var as $key => $value) { |
|
| 345 | + $localized_vars[$key] = $this->encodeJsonVars($value); |
|
| 346 | 346 | } |
| 347 | 347 | return $localized_vars; |
| 348 | - } else if ( is_scalar( $var ) ) { |
|
| 349 | - return html_entity_decode( (string)$var, ENT_QUOTES, 'UTF-8' ); |
|
| 348 | + } else if (is_scalar($var)) { |
|
| 349 | + return html_entity_decode((string) $var, ENT_QUOTES, 'UTF-8'); |
|
| 350 | 350 | } |
| 351 | 351 | return null; |
| 352 | 352 | } |
@@ -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 | |
@@ -17,65 +17,65 @@ discard block |
||
| 17 | 17 | class EE_Checkbox_Dropdown_Selector_Input extends EE_Form_Input_With_Options_Base |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string text to display on the select button itself |
|
| 22 | - */ |
|
| 23 | - protected $_select_button_text; |
|
| 20 | + /** |
|
| 21 | + * @var string text to display on the select button itself |
|
| 22 | + */ |
|
| 23 | + protected $_select_button_text; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param array $answer_options |
|
| 27 | - * @param array $input_settings |
|
| 28 | - */ |
|
| 29 | - public function __construct($answer_options, $input_settings = array()) |
|
| 30 | - { |
|
| 31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
| 32 | - esc_html__('Select', 'event_espresso')); |
|
| 33 | - $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
| 34 | - $this->_set_display_strategy($display_strategy); |
|
| 35 | - $this->load_iframe_assets($display_strategy); |
|
| 36 | - $this->_add_validation_strategy( |
|
| 37 | - new EE_Many_Valued_Validation_Strategy( |
|
| 38 | - array( |
|
| 39 | - new EE_Enum_Validation_Strategy( |
|
| 40 | - isset($input_settings['validation_error_message']) |
|
| 41 | - ? $input_settings['validation_error_message'] |
|
| 42 | - : null |
|
| 43 | - ), |
|
| 44 | - ) |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - $this->_multiple_selections = true; |
|
| 48 | - parent::__construct($answer_options, $input_settings); |
|
| 49 | - } |
|
| 25 | + /** |
|
| 26 | + * @param array $answer_options |
|
| 27 | + * @param array $input_settings |
|
| 28 | + */ |
|
| 29 | + public function __construct($answer_options, $input_settings = array()) |
|
| 30 | + { |
|
| 31 | + $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
| 32 | + esc_html__('Select', 'event_espresso')); |
|
| 33 | + $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
| 34 | + $this->_set_display_strategy($display_strategy); |
|
| 35 | + $this->load_iframe_assets($display_strategy); |
|
| 36 | + $this->_add_validation_strategy( |
|
| 37 | + new EE_Many_Valued_Validation_Strategy( |
|
| 38 | + array( |
|
| 39 | + new EE_Enum_Validation_Strategy( |
|
| 40 | + isset($input_settings['validation_error_message']) |
|
| 41 | + ? $input_settings['validation_error_message'] |
|
| 42 | + : null |
|
| 43 | + ), |
|
| 44 | + ) |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + $this->_multiple_selections = true; |
|
| 48 | + parent::__construct($answer_options, $input_settings); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /* |
|
| 51 | + /* |
|
| 52 | 52 | * Returns the text to display in the select button |
| 53 | 53 | */ |
| 54 | - public function select_button_text(){ |
|
| 55 | - return $this->_select_button_text; |
|
| 56 | - } |
|
| 54 | + public function select_button_text(){ |
|
| 55 | + return $this->_select_button_text; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /* |
|
| 58 | + /* |
|
| 59 | 59 | * add css and js for iframes |
| 60 | 60 | */ |
| 61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
| 62 | - add_filter( |
|
| 63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 64 | - array($display_strategy, 'iframe_css') |
|
| 65 | - ); |
|
| 66 | - add_filter( |
|
| 67 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 68 | - array($display_strategy, 'iframe_js') |
|
| 69 | - ); |
|
| 70 | - add_filter( |
|
| 71 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 72 | - array($display_strategy, 'iframe_css') |
|
| 73 | - ); |
|
| 74 | - add_filter( |
|
| 75 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 76 | - array($display_strategy, 'iframe_js') |
|
| 77 | - ); |
|
| 78 | - } |
|
| 61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
| 62 | + add_filter( |
|
| 63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
| 64 | + array($display_strategy, 'iframe_css') |
|
| 65 | + ); |
|
| 66 | + add_filter( |
|
| 67 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 68 | + array($display_strategy, 'iframe_js') |
|
| 69 | + ); |
|
| 70 | + add_filter( |
|
| 71 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
| 72 | + array($display_strategy, 'iframe_css') |
|
| 73 | + ); |
|
| 74 | + add_filter( |
|
| 75 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
| 76 | + array($display_strategy, 'iframe_js') |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function __construct($answer_options, $input_settings = array()) |
| 30 | 30 | { |
| 31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
| 31 | + $this->_select_button_text = EEH_Array::is_set($input_settings, 'select_button_text', |
|
| 32 | 32 | esc_html__('Select', 'event_espresso')); |
| 33 | 33 | $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
| 34 | 34 | $this->_set_display_strategy($display_strategy); |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | /* |
| 52 | 52 | * Returns the text to display in the select button |
| 53 | 53 | */ |
| 54 | - public function select_button_text(){ |
|
| 54 | + public function select_button_text() { |
|
| 55 | 55 | return $this->_select_button_text; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /* |
| 59 | 59 | * add css and js for iframes |
| 60 | 60 | */ |
| 61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
| 61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy) { |
|
| 62 | 62 | add_filter( |
| 63 | 63 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
| 64 | 64 | array($display_strategy, 'iframe_css') |
@@ -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 | * Event Espresso |
@@ -28,2120 +28,2120 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - //set in _init_page_props() |
|
| 32 | - public $page_slug; |
|
| 31 | + //set in _init_page_props() |
|
| 32 | + public $page_slug; |
|
| 33 | 33 | |
| 34 | - public $page_label; |
|
| 34 | + public $page_label; |
|
| 35 | 35 | |
| 36 | - public $page_folder; |
|
| 36 | + public $page_folder; |
|
| 37 | 37 | |
| 38 | - //set in define_page_props() |
|
| 39 | - protected $_admin_base_url; |
|
| 38 | + //set in define_page_props() |
|
| 39 | + protected $_admin_base_url; |
|
| 40 | 40 | |
| 41 | - protected $_admin_base_path; |
|
| 41 | + protected $_admin_base_path; |
|
| 42 | 42 | |
| 43 | - protected $_admin_page_title; |
|
| 43 | + protected $_admin_page_title; |
|
| 44 | 44 | |
| 45 | - protected $_labels; |
|
| 45 | + protected $_labels; |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - //set early within EE_Admin_Init |
|
| 49 | - protected $_wp_page_slug; |
|
| 48 | + //set early within EE_Admin_Init |
|
| 49 | + protected $_wp_page_slug; |
|
| 50 | 50 | |
| 51 | - //navtabs |
|
| 52 | - protected $_nav_tabs; |
|
| 51 | + //navtabs |
|
| 52 | + protected $_nav_tabs; |
|
| 53 | 53 | |
| 54 | - protected $_default_nav_tab_name; |
|
| 54 | + protected $_default_nav_tab_name; |
|
| 55 | 55 | |
| 56 | - //helptourstops |
|
| 57 | - protected $_help_tour = array(); |
|
| 56 | + //helptourstops |
|
| 57 | + protected $_help_tour = array(); |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - //template variables (used by templates) |
|
| 61 | - protected $_template_path; |
|
| 60 | + //template variables (used by templates) |
|
| 61 | + protected $_template_path; |
|
| 62 | 62 | |
| 63 | - protected $_column_template_path; |
|
| 63 | + protected $_column_template_path; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @var array $_template_args |
|
| 67 | - */ |
|
| 68 | - protected $_template_args = array(); |
|
| 65 | + /** |
|
| 66 | + * @var array $_template_args |
|
| 67 | + */ |
|
| 68 | + protected $_template_args = array(); |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * this will hold the list table object for a given view. |
|
| 72 | - * |
|
| 73 | - * @var EE_Admin_List_Table $_list_table_object |
|
| 74 | - */ |
|
| 75 | - protected $_list_table_object; |
|
| 70 | + /** |
|
| 71 | + * this will hold the list table object for a given view. |
|
| 72 | + * |
|
| 73 | + * @var EE_Admin_List_Table $_list_table_object |
|
| 74 | + */ |
|
| 75 | + protected $_list_table_object; |
|
| 76 | 76 | |
| 77 | - //bools |
|
| 78 | - protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states. |
|
| 77 | + //bools |
|
| 78 | + protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states. |
|
| 79 | 79 | |
| 80 | - protected $_routing; |
|
| 80 | + protected $_routing; |
|
| 81 | 81 | |
| 82 | - //list table args |
|
| 83 | - protected $_view; |
|
| 82 | + //list table args |
|
| 83 | + protected $_view; |
|
| 84 | 84 | |
| 85 | - protected $_views; |
|
| 85 | + protected $_views; |
|
| 86 | 86 | |
| 87 | 87 | |
| 88 | - //action => method pairs used for routing incoming requests |
|
| 89 | - protected $_page_routes; |
|
| 88 | + //action => method pairs used for routing incoming requests |
|
| 89 | + protected $_page_routes; |
|
| 90 | 90 | |
| 91 | - protected $_page_config; |
|
| 91 | + protected $_page_config; |
|
| 92 | 92 | |
| 93 | - //the current page route and route config |
|
| 94 | - protected $_route; |
|
| 93 | + //the current page route and route config |
|
| 94 | + protected $_route; |
|
| 95 | 95 | |
| 96 | - protected $_route_config; |
|
| 96 | + protected $_route_config; |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out |
|
| 100 | - * actions. |
|
| 101 | - * |
|
| 102 | - * @since 4.6.x |
|
| 103 | - * @var array. |
|
| 104 | - */ |
|
| 105 | - protected $_default_route_query_args; |
|
| 98 | + /** |
|
| 99 | + * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out |
|
| 100 | + * actions. |
|
| 101 | + * |
|
| 102 | + * @since 4.6.x |
|
| 103 | + * @var array. |
|
| 104 | + */ |
|
| 105 | + protected $_default_route_query_args; |
|
| 106 | 106 | |
| 107 | - //set via request page and action args. |
|
| 108 | - protected $_current_page; |
|
| 107 | + //set via request page and action args. |
|
| 108 | + protected $_current_page; |
|
| 109 | 109 | |
| 110 | - protected $_current_view; |
|
| 110 | + protected $_current_view; |
|
| 111 | 111 | |
| 112 | - protected $_current_page_view_url; |
|
| 112 | + protected $_current_page_view_url; |
|
| 113 | 113 | |
| 114 | - //sanitized request action (and nonce) |
|
| 115 | - /** |
|
| 116 | - * @var string $_req_action |
|
| 117 | - */ |
|
| 118 | - protected $_req_action; |
|
| 114 | + //sanitized request action (and nonce) |
|
| 115 | + /** |
|
| 116 | + * @var string $_req_action |
|
| 117 | + */ |
|
| 118 | + protected $_req_action; |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * @var string $_req_nonce |
|
| 122 | - */ |
|
| 123 | - protected $_req_nonce; |
|
| 120 | + /** |
|
| 121 | + * @var string $_req_nonce |
|
| 122 | + */ |
|
| 123 | + protected $_req_nonce; |
|
| 124 | 124 | |
| 125 | - //search related |
|
| 126 | - protected $_search_btn_label; |
|
| 125 | + //search related |
|
| 126 | + protected $_search_btn_label; |
|
| 127 | 127 | |
| 128 | - protected $_search_box_callback; |
|
| 128 | + protected $_search_box_callback; |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * WP Current Screen object |
|
| 132 | - * |
|
| 133 | - * @var WP_Screen |
|
| 134 | - */ |
|
| 135 | - protected $_current_screen; |
|
| 130 | + /** |
|
| 131 | + * WP Current Screen object |
|
| 132 | + * |
|
| 133 | + * @var WP_Screen |
|
| 134 | + */ |
|
| 135 | + protected $_current_screen; |
|
| 136 | 136 | |
| 137 | - //for holding EE_Admin_Hooks object when needed (set via set_hook_object()) |
|
| 138 | - protected $_hook_obj; |
|
| 137 | + //for holding EE_Admin_Hooks object when needed (set via set_hook_object()) |
|
| 138 | + protected $_hook_obj; |
|
| 139 | 139 | |
| 140 | - //for holding incoming request data |
|
| 141 | - protected $_req_data; |
|
| 140 | + //for holding incoming request data |
|
| 141 | + protected $_req_data; |
|
| 142 | 142 | |
| 143 | - // yes / no array for admin form fields |
|
| 144 | - protected $_yes_no_values = array(); |
|
| 145 | - |
|
| 146 | - //some default things shared by all child classes |
|
| 147 | - protected $_default_espresso_metaboxes; |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * EE_Registry Object |
|
| 151 | - * |
|
| 152 | - * @var EE_Registry |
|
| 153 | - * @access protected |
|
| 154 | - */ |
|
| 155 | - protected $EE = null; |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * This is just a property that flags whether the given route is a caffeinated route or not. |
|
| 161 | - * |
|
| 162 | - * @var boolean |
|
| 163 | - */ |
|
| 164 | - protected $_is_caf = false; |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @Constructor |
|
| 170 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
| 171 | - * @access public |
|
| 172 | - */ |
|
| 173 | - public function __construct($routing = true) |
|
| 174 | - { |
|
| 175 | - if (strpos($this->_get_dir(), 'caffeinated') !== false) { |
|
| 176 | - $this->_is_caf = true; |
|
| 177 | - } |
|
| 178 | - $this->_yes_no_values = array( |
|
| 179 | - array('id' => true, 'text' => __('Yes', 'event_espresso')), |
|
| 180 | - array('id' => false, 'text' => __('No', 'event_espresso')), |
|
| 181 | - ); |
|
| 182 | - //set the _req_data property. |
|
| 183 | - $this->_req_data = array_merge($_GET, $_POST); |
|
| 184 | - //routing enabled? |
|
| 185 | - $this->_routing = $routing; |
|
| 186 | - //set initial page props (child method) |
|
| 187 | - $this->_init_page_props(); |
|
| 188 | - //set global defaults |
|
| 189 | - $this->_set_defaults(); |
|
| 190 | - //set early because incoming requests could be ajax related and we need to register those hooks. |
|
| 191 | - $this->_global_ajax_hooks(); |
|
| 192 | - $this->_ajax_hooks(); |
|
| 193 | - //other_page_hooks have to be early too. |
|
| 194 | - $this->_do_other_page_hooks(); |
|
| 195 | - //This just allows us to have extending classes do something specific |
|
| 196 | - // before the parent constructor runs _page_setup(). |
|
| 197 | - if (method_exists($this, '_before_page_setup')) { |
|
| 198 | - $this->_before_page_setup(); |
|
| 199 | - } |
|
| 200 | - //set up page dependencies |
|
| 201 | - $this->_page_setup(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * _init_page_props |
|
| 208 | - * Child classes use to set at least the following properties: |
|
| 209 | - * $page_slug. |
|
| 210 | - * $page_label. |
|
| 211 | - * |
|
| 212 | - * @abstract |
|
| 213 | - * @access protected |
|
| 214 | - * @return void |
|
| 215 | - */ |
|
| 216 | - abstract protected function _init_page_props(); |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * _ajax_hooks |
|
| 222 | - * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
| 223 | - * Note: within the ajax callback methods. |
|
| 224 | - * |
|
| 225 | - * @abstract |
|
| 226 | - * @access protected |
|
| 227 | - * @return void |
|
| 228 | - */ |
|
| 229 | - abstract protected function _ajax_hooks(); |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * _define_page_props |
|
| 235 | - * child classes define page properties in here. Must include at least: |
|
| 236 | - * $_admin_base_url = base_url for all admin pages |
|
| 237 | - * $_admin_page_title = default admin_page_title for admin pages |
|
| 238 | - * $_labels = array of default labels for various automatically generated elements: |
|
| 239 | - * array( |
|
| 240 | - * 'buttons' => array( |
|
| 241 | - * 'add' => __('label for add new button'), |
|
| 242 | - * 'edit' => __('label for edit button'), |
|
| 243 | - * 'delete' => __('label for delete button') |
|
| 244 | - * ) |
|
| 245 | - * ) |
|
| 246 | - * |
|
| 247 | - * @abstract |
|
| 248 | - * @access protected |
|
| 249 | - * @return void |
|
| 250 | - */ |
|
| 251 | - abstract protected function _define_page_props(); |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * _set_page_routes |
|
| 257 | - * child classes use this to define the page routes for all subpages handled by the class. Page routes are assigned to a action => method pairs in an array and to the $_page_routes property. Each page route must also have a 'default' |
|
| 258 | - * route. Here's the format |
|
| 259 | - * $this->_page_routes = array( |
|
| 260 | - * 'default' => array( |
|
| 261 | - * 'func' => '_default_method_handling_route', |
|
| 262 | - * 'args' => array('array','of','args'), |
|
| 263 | - * 'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing) |
|
| 264 | - * 'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after. The string you enter here should match the defined route reference for a headers sent route. |
|
| 265 | - * 'capability' => 'route_capability', //indicate a string for minimum capability required to access this route. |
|
| 266 | - * 'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks). |
|
| 267 | - * ), |
|
| 268 | - * 'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method. |
|
| 269 | - * ) |
|
| 270 | - * ) |
|
| 271 | - * |
|
| 272 | - * @abstract |
|
| 273 | - * @access protected |
|
| 274 | - * @return void |
|
| 275 | - */ |
|
| 276 | - abstract protected function _set_page_routes(); |
|
| 277 | - |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * _set_page_config |
|
| 282 | - * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page. |
|
| 283 | - * Format: |
|
| 284 | - * $this->_page_config = array( |
|
| 285 | - * 'default' => array( |
|
| 286 | - * 'labels' => array( |
|
| 287 | - * 'buttons' => array( |
|
| 288 | - * 'add' => __('label for adding item'), |
|
| 289 | - * 'edit' => __('label for editing item'), |
|
| 290 | - * 'delete' => __('label for deleting item') |
|
| 291 | - * ), |
|
| 292 | - * 'publishbox' => __('Localized Title for Publish metabox', 'event_espresso') |
|
| 293 | - * ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method |
|
| 294 | - * 'nav' => array( |
|
| 295 | - * 'label' => __('Label for Tab', 'event_espresso'). |
|
| 296 | - * 'url' => 'http://someurl', //automatically generated UNLESS you define |
|
| 297 | - * 'css_class' => 'css-class', //automatically generated UNLESS you define |
|
| 298 | - * 'order' => 10, //required to indicate tab position. |
|
| 299 | - * 'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter. |
|
| 300 | - * 'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page. |
|
| 301 | - * 'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages. |
|
| 302 | - * 'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes. Typically this is used if the 'metaboxes' index is not used because metaboxes are added later. We just use |
|
| 303 | - * this flag to make sure the necessary js gets enqueued on page load. |
|
| 304 | - * 'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued. |
|
| 305 | - * 'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes). The array indicates the max number of columns (4) and the default number of columns on page load (2). There is an option |
|
| 306 | - * in the "screen_options" dropdown that is setup so users can pick what columns they want to display. |
|
| 307 | - * 'help_tabs' => array( //this is used for adding help tabs to a page |
|
| 308 | - * 'tab_id' => array( |
|
| 309 | - * 'title' => 'tab_title', |
|
| 310 | - * 'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content. The fallback if it isn't present is to try a the callback. Filename should match a file in the admin |
|
| 311 | - * folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php) |
|
| 312 | - * 'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class |
|
| 313 | - * ), |
|
| 314 | - * 'tab2_id' => array( |
|
| 315 | - * 'title' => 'tab2 title', |
|
| 316 | - * 'filename' => 'file_name_2' |
|
| 317 | - * 'callback' => 'callback_method_for_content', |
|
| 318 | - * ), |
|
| 319 | - * 'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/ |
|
| 320 | - * 'help_tour' => array( |
|
| 321 | - * 'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here |
|
| 322 | - * (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class) |
|
| 323 | - * ), |
|
| 324 | - * 'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present). To remove the requirement for a nonce check when this route is visited just set |
|
| 325 | - * 'require_nonce' to FALSE |
|
| 326 | - * ) |
|
| 327 | - * ) |
|
| 328 | - * |
|
| 329 | - * @abstract |
|
| 330 | - * @access protected |
|
| 331 | - * @return void |
|
| 332 | - */ |
|
| 333 | - abstract protected function _set_page_config(); |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** end sample help_tour methods **/ |
|
| 340 | - /** |
|
| 341 | - * _add_screen_options |
|
| 342 | - * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
| 343 | - * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view. |
|
| 344 | - * |
|
| 345 | - * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
| 346 | - * see also WP_Screen object documents... |
|
| 347 | - * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
| 348 | - * @abstract |
|
| 349 | - * @access protected |
|
| 350 | - * @return void |
|
| 351 | - */ |
|
| 352 | - abstract protected function _add_screen_options(); |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * _add_feature_pointers |
|
| 358 | - * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js). |
|
| 359 | - * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view. |
|
| 360 | - * Note: this is just a placeholder for now. Implementation will come down the road |
|
| 361 | - * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
| 362 | - * |
|
| 363 | - * @link http://eamann.com/tech/wordpress-portland/ |
|
| 364 | - * @abstract |
|
| 365 | - * @access protected |
|
| 366 | - * @return void |
|
| 367 | - */ |
|
| 368 | - abstract protected function _add_feature_pointers(); |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * load_scripts_styles |
|
| 374 | - * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages. Note this is for all pages/subpages of the system. You can also load only specific scripts/styles |
|
| 375 | - * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg) |
|
| 376 | - * |
|
| 377 | - * @abstract |
|
| 378 | - * @access public |
|
| 379 | - * @return void |
|
| 380 | - */ |
|
| 381 | - abstract public function load_scripts_styles(); |
|
| 382 | - |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * admin_init |
|
| 387 | - * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here. This will apply to all pages/views loaded by child class. |
|
| 388 | - * |
|
| 389 | - * @abstract |
|
| 390 | - * @access public |
|
| 391 | - * @return void |
|
| 392 | - */ |
|
| 393 | - abstract public function admin_init(); |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * admin_notices |
|
| 399 | - * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
| 400 | - * |
|
| 401 | - * @abstract |
|
| 402 | - * @access public |
|
| 403 | - * @return void |
|
| 404 | - */ |
|
| 405 | - abstract public function admin_notices(); |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * admin_footer_scripts |
|
| 411 | - * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
| 412 | - * |
|
| 413 | - * @access public |
|
| 414 | - * @return void |
|
| 415 | - */ |
|
| 416 | - abstract public function admin_footer_scripts(); |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * admin_footer |
|
| 422 | - * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class. |
|
| 423 | - * |
|
| 424 | - * @access public |
|
| 425 | - * @return void |
|
| 426 | - */ |
|
| 427 | - public function admin_footer() |
|
| 428 | - { |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * _global_ajax_hooks |
|
| 435 | - * all global add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
| 436 | - * Note: within the ajax callback methods. |
|
| 437 | - * |
|
| 438 | - * @abstract |
|
| 439 | - * @access protected |
|
| 440 | - * @return void |
|
| 441 | - */ |
|
| 442 | - protected function _global_ajax_hooks() |
|
| 443 | - { |
|
| 444 | - //for lazy loading of metabox content |
|
| 445 | - add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - public function ajax_metabox_content() |
|
| 451 | - { |
|
| 452 | - $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
| 453 | - $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
| 454 | - self::cached_rss_display($contentid, $url); |
|
| 455 | - wp_die(); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - |
|
| 459 | - |
|
| 460 | - /** |
|
| 461 | - * _page_setup |
|
| 462 | - * Makes sure any things that need to be loaded early get handled. We also escape early here if the page requested doesn't match the object. |
|
| 463 | - * |
|
| 464 | - * @final |
|
| 465 | - * @access protected |
|
| 466 | - * @return void |
|
| 467 | - */ |
|
| 468 | - final protected function _page_setup() |
|
| 469 | - { |
|
| 470 | - //requires? |
|
| 471 | - //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
|
| 472 | - add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
| 473 | - //next verify if we need to load anything... |
|
| 474 | - $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
| 475 | - $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
| 476 | - global $ee_menu_slugs; |
|
| 477 | - $ee_menu_slugs = (array)$ee_menu_slugs; |
|
| 478 | - if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
|
| 479 | - return; |
|
| 480 | - } |
|
| 481 | - // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
|
| 482 | - if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
| 483 | - $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
| 484 | - } |
|
| 485 | - // then set blank or -1 action values to 'default' |
|
| 486 | - $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
| 487 | - //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
|
| 488 | - $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
| 489 | - //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
|
| 490 | - $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
| 491 | - $this->_current_view = $this->_req_action; |
|
| 492 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
| 493 | - $this->_define_page_props(); |
|
| 494 | - $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
| 495 | - //default things |
|
| 496 | - $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
| 497 | - //set page configs |
|
| 498 | - $this->_set_page_routes(); |
|
| 499 | - $this->_set_page_config(); |
|
| 500 | - //let's include any referrer data in our default_query_args for this route for "stickiness". |
|
| 501 | - if (isset($this->_req_data['wp_referer'])) { |
|
| 502 | - $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
|
| 503 | - } |
|
| 504 | - //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
|
| 505 | - if (method_exists($this, '_extend_page_config')) { |
|
| 506 | - $this->_extend_page_config(); |
|
| 507 | - } |
|
| 508 | - //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
|
| 509 | - if (method_exists($this, '_extend_page_config_for_cpt')) { |
|
| 510 | - $this->_extend_page_config_for_cpt(); |
|
| 511 | - } |
|
| 512 | - //filter routes and page_config so addons can add their stuff. Filtering done per class |
|
| 513 | - $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
| 514 | - $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
| 515 | - //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
|
| 516 | - if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
| 517 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
| 518 | - } |
|
| 519 | - //next route only if routing enabled |
|
| 520 | - if ($this->_routing && ! defined('DOING_AJAX')) { |
|
| 521 | - $this->_verify_routes(); |
|
| 522 | - //next let's just check user_access and kill if no access |
|
| 523 | - $this->check_user_access(); |
|
| 524 | - if ($this->_is_UI_request) { |
|
| 525 | - //admin_init stuff - global, all views for this page class, specific view |
|
| 526 | - add_action('admin_init', array($this, 'admin_init'), 10); |
|
| 527 | - if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
| 528 | - add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
| 529 | - } |
|
| 530 | - } else { |
|
| 531 | - //hijack regular WP loading and route admin request immediately |
|
| 532 | - @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 533 | - $this->route_admin_request(); |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * Provides a way for related child admin pages to load stuff on the loaded admin page. |
|
| 542 | - * |
|
| 543 | - * @access private |
|
| 544 | - * @return void |
|
| 545 | - */ |
|
| 546 | - private function _do_other_page_hooks() |
|
| 547 | - { |
|
| 548 | - $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
| 549 | - foreach ($registered_pages as $page) { |
|
| 550 | - //now let's setup the file name and class that should be present |
|
| 551 | - $classname = str_replace('.class.php', '', $page); |
|
| 552 | - //autoloaders should take care of loading file |
|
| 553 | - if ( ! class_exists($classname)) { |
|
| 554 | - $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
| 555 | - $error_msg[] = $error_msg[0] |
|
| 556 | - . "\r\n" |
|
| 557 | - . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
| 558 | - 'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>'); |
|
| 559 | - throw new EE_Error(implode('||', $error_msg)); |
|
| 560 | - } |
|
| 561 | - $a = new ReflectionClass($classname); |
|
| 562 | - //notice we are passing the instance of this class to the hook object. |
|
| 563 | - $hookobj[] = $a->newInstance($this); |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - public function load_page_dependencies() |
|
| 570 | - { |
|
| 571 | - try { |
|
| 572 | - $this->_load_page_dependencies(); |
|
| 573 | - } catch (EE_Error $e) { |
|
| 574 | - $e->get_error(); |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - |
|
| 579 | - |
|
| 580 | - /** |
|
| 581 | - * load_page_dependencies |
|
| 582 | - * loads things specific to this page class when its loaded. Really helps with efficiency. |
|
| 583 | - * |
|
| 584 | - * @access public |
|
| 585 | - * @return void |
|
| 586 | - */ |
|
| 587 | - protected function _load_page_dependencies() |
|
| 588 | - { |
|
| 589 | - //let's set the current_screen and screen options to override what WP set |
|
| 590 | - $this->_current_screen = get_current_screen(); |
|
| 591 | - //load admin_notices - global, page class, and view specific |
|
| 592 | - add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
| 593 | - add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
| 594 | - if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
| 595 | - add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
| 596 | - } |
|
| 597 | - //load network admin_notices - global, page class, and view specific |
|
| 598 | - add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
| 599 | - if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
| 600 | - add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
| 601 | - } |
|
| 602 | - //this will save any per_page screen options if they are present |
|
| 603 | - $this->_set_per_page_screen_options(); |
|
| 604 | - //setup list table properties |
|
| 605 | - $this->_set_list_table(); |
|
| 606 | - // child classes can "register" a metabox to be automatically handled via the _page_config array property. However in some cases the metaboxes will need to be added within a route handling callback. |
|
| 607 | - $this->_add_registered_meta_boxes(); |
|
| 608 | - $this->_add_screen_columns(); |
|
| 609 | - //add screen options - global, page child class, and view specific |
|
| 610 | - $this->_add_global_screen_options(); |
|
| 611 | - $this->_add_screen_options(); |
|
| 612 | - if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
| 613 | - call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
| 614 | - } |
|
| 615 | - //add help tab(s) and tours- set via page_config and qtips. |
|
| 616 | - $this->_add_help_tour(); |
|
| 617 | - $this->_add_help_tabs(); |
|
| 618 | - $this->_add_qtips(); |
|
| 619 | - //add feature_pointers - global, page child class, and view specific |
|
| 620 | - $this->_add_feature_pointers(); |
|
| 621 | - $this->_add_global_feature_pointers(); |
|
| 622 | - if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
| 623 | - call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
| 624 | - } |
|
| 625 | - //enqueue scripts/styles - global, page class, and view specific |
|
| 626 | - add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
| 627 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
| 628 | - if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
| 629 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
| 630 | - } |
|
| 631 | - add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
| 632 | - //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
|
| 633 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
| 634 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
| 635 | - if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
| 636 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
| 637 | - } |
|
| 638 | - //admin footer scripts |
|
| 639 | - add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
| 640 | - add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
| 641 | - if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
| 642 | - add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
| 643 | - } |
|
| 644 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
| 645 | - //targeted hook |
|
| 646 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * _set_defaults |
|
| 653 | - * This sets some global defaults for class properties. |
|
| 654 | - */ |
|
| 655 | - private function _set_defaults() |
|
| 656 | - { |
|
| 657 | - $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null; |
|
| 658 | - $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
| 659 | - $this->default_nav_tab_name = 'overview'; |
|
| 660 | - //init template args |
|
| 661 | - $this->_template_args = array( |
|
| 662 | - 'admin_page_header' => '', |
|
| 663 | - 'admin_page_content' => '', |
|
| 664 | - 'post_body_content' => '', |
|
| 665 | - 'before_list_table' => '', |
|
| 666 | - 'after_list_table' => '', |
|
| 667 | - ); |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * route_admin_request |
|
| 674 | - * |
|
| 675 | - * @see _route_admin_request() |
|
| 676 | - * @access public |
|
| 677 | - * @return void|exception error |
|
| 678 | - */ |
|
| 679 | - public function route_admin_request() |
|
| 680 | - { |
|
| 681 | - try { |
|
| 682 | - $this->_route_admin_request(); |
|
| 683 | - } catch (EE_Error $e) { |
|
| 684 | - $e->get_error(); |
|
| 685 | - } |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - |
|
| 689 | - |
|
| 690 | - public function set_wp_page_slug($wp_page_slug) |
|
| 691 | - { |
|
| 692 | - $this->_wp_page_slug = $wp_page_slug; |
|
| 693 | - //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
|
| 694 | - if (is_network_admin()) { |
|
| 695 | - $this->_wp_page_slug .= '-network'; |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * _verify_routes |
|
| 703 | - * All this method does is verify the incoming request and make sure that routes exist for it. We do this early so we know if we need to drop out. |
|
| 704 | - * |
|
| 705 | - * @access protected |
|
| 706 | - * @return void |
|
| 707 | - */ |
|
| 708 | - protected function _verify_routes() |
|
| 709 | - { |
|
| 710 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 711 | - if ( ! $this->_current_page && ! defined('DOING_AJAX')) { |
|
| 712 | - return false; |
|
| 713 | - } |
|
| 714 | - $this->_route = false; |
|
| 715 | - $func = false; |
|
| 716 | - $args = array(); |
|
| 717 | - // check that the page_routes array is not empty |
|
| 718 | - if (empty($this->_page_routes)) { |
|
| 719 | - // user error msg |
|
| 720 | - $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 721 | - // developer error msg |
|
| 722 | - $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
| 723 | - throw new EE_Error($error_msg); |
|
| 724 | - } |
|
| 725 | - // and that the requested page route exists |
|
| 726 | - if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 727 | - $this->_route = $this->_page_routes[$this->_req_action]; |
|
| 728 | - $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
|
| 729 | - } else { |
|
| 730 | - // user error msg |
|
| 731 | - $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 732 | - // developer error msg |
|
| 733 | - $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
| 734 | - throw new EE_Error($error_msg); |
|
| 735 | - } |
|
| 736 | - // and that a default route exists |
|
| 737 | - if ( ! array_key_exists('default', $this->_page_routes)) { |
|
| 738 | - // user error msg |
|
| 739 | - $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 740 | - // developer error msg |
|
| 741 | - $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
| 742 | - throw new EE_Error($error_msg); |
|
| 743 | - } |
|
| 744 | - //first lets' catch if the UI request has EVER been set. |
|
| 745 | - if ($this->_is_UI_request === null) { |
|
| 746 | - //lets set if this is a UI request or not. |
|
| 747 | - $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false; |
|
| 748 | - //wait a minute... we might have a noheader in the route array |
|
| 749 | - $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request; |
|
| 750 | - } |
|
| 751 | - $this->_set_current_labels(); |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * this method simply verifies a given route and makes sure its an actual route available for the loaded page |
|
| 758 | - * |
|
| 759 | - * @param string $route the route name we're verifying |
|
| 760 | - * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
| 761 | - */ |
|
| 762 | - protected function _verify_route($route) |
|
| 763 | - { |
|
| 764 | - if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 765 | - return true; |
|
| 766 | - } else { |
|
| 767 | - // user error msg |
|
| 768 | - $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 769 | - // developer error msg |
|
| 770 | - $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
| 771 | - throw new EE_Error($error_msg); |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - |
|
| 776 | - |
|
| 777 | - /** |
|
| 778 | - * perform nonce verification |
|
| 779 | - * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!) |
|
| 780 | - * |
|
| 781 | - * @param string $nonce The nonce sent |
|
| 782 | - * @param string $nonce_ref The nonce reference string (name0) |
|
| 783 | - * @return mixed (bool|die) |
|
| 784 | - */ |
|
| 785 | - protected function _verify_nonce($nonce, $nonce_ref) |
|
| 786 | - { |
|
| 787 | - // verify nonce against expected value |
|
| 788 | - if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
| 789 | - // these are not the droids you are looking for !!! |
|
| 790 | - $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
| 791 | - if (WP_DEBUG) { |
|
| 792 | - $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
| 793 | - } |
|
| 794 | - if ( ! defined('DOING_AJAX')) { |
|
| 795 | - wp_die($msg); |
|
| 796 | - } else { |
|
| 797 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 798 | - $this->_return_json(); |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * _route_admin_request() |
|
| 807 | - * Meat and potatoes of the class. Basically, this dude checks out what's being requested and sees if theres are |
|
| 808 | - * some doodads to work the magic and handle the flingjangy. Translation: Checks if the requested action is listed |
|
| 809 | - * in the page routes and then will try to load the corresponding method. |
|
| 810 | - * |
|
| 811 | - * @access protected |
|
| 812 | - * @return void |
|
| 813 | - * @throws \EE_Error |
|
| 814 | - */ |
|
| 815 | - protected function _route_admin_request() |
|
| 816 | - { |
|
| 817 | - if ( ! $this->_is_UI_request) { |
|
| 818 | - $this->_verify_routes(); |
|
| 819 | - } |
|
| 820 | - $nonce_check = isset($this->_route_config['require_nonce']) |
|
| 821 | - ? $this->_route_config['require_nonce'] |
|
| 822 | - : true; |
|
| 823 | - if ($this->_req_action !== 'default' && $nonce_check) { |
|
| 824 | - // set nonce from post data |
|
| 825 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 826 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) |
|
| 827 | - : ''; |
|
| 828 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 829 | - } |
|
| 830 | - //set the nav_tabs array but ONLY if this is UI_request |
|
| 831 | - if ($this->_is_UI_request) { |
|
| 832 | - $this->_set_nav_tabs(); |
|
| 833 | - } |
|
| 834 | - // grab callback function |
|
| 835 | - $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
| 836 | - // check if callback has args |
|
| 837 | - $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
| 838 | - $error_msg = ''; |
|
| 839 | - // action right before calling route |
|
| 840 | - // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
|
| 841 | - if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
| 842 | - do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
| 843 | - } |
|
| 844 | - // right before calling the route, let's remove _wp_http_referer from the |
|
| 845 | - // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
|
| 846 | - $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
| 847 | - if ( ! empty($func)) { |
|
| 848 | - if (is_array($func)) { |
|
| 849 | - list($class, $method) = $func; |
|
| 850 | - } else if (strpos($func, '::') !== false) { |
|
| 851 | - list($class, $method) = explode('::', $func); |
|
| 852 | - } else { |
|
| 853 | - $class = $this; |
|
| 854 | - $method = $func; |
|
| 855 | - } |
|
| 856 | - if ( ! (is_object($class) && $class === $this)) { |
|
| 857 | - // send along this admin page object for access by addons. |
|
| 858 | - $args['admin_page_object'] = $this; |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - if ( |
|
| 862 | - //is it a method on a class that doesn't work? |
|
| 863 | - ( |
|
| 864 | - ( |
|
| 865 | - method_exists($class, $method) |
|
| 866 | - && call_user_func_array(array($class, $method), $args) === false |
|
| 867 | - ) |
|
| 868 | - && ( |
|
| 869 | - //is it a standalone function that doesn't work? |
|
| 870 | - function_exists($method) |
|
| 871 | - && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false |
|
| 872 | - ) |
|
| 873 | - ) |
|
| 874 | - || ( |
|
| 875 | - //is it neither a class method NOR a standalone function? |
|
| 876 | - ! method_exists($class, $method) |
|
| 877 | - && ! function_exists($method) |
|
| 878 | - ) |
|
| 879 | - ) { |
|
| 880 | - // user error msg |
|
| 881 | - $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
| 882 | - // developer error msg |
|
| 883 | - $error_msg .= '||'; |
|
| 884 | - $error_msg .= sprintf( |
|
| 885 | - __( |
|
| 886 | - 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', |
|
| 887 | - 'event_espresso' |
|
| 888 | - ), |
|
| 889 | - $method |
|
| 890 | - ); |
|
| 891 | - } |
|
| 892 | - if ( ! empty($error_msg)) { |
|
| 893 | - throw new EE_Error($error_msg); |
|
| 894 | - } |
|
| 895 | - } |
|
| 896 | - //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
|
| 897 | - //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
|
| 898 | - if ($this->_is_UI_request === false |
|
| 899 | - && is_array($this->_route) |
|
| 900 | - && ! empty($this->_route['headers_sent_route']) |
|
| 901 | - ) { |
|
| 902 | - $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
| 903 | - } |
|
| 904 | - } |
|
| 905 | - |
|
| 906 | - |
|
| 907 | - |
|
| 908 | - /** |
|
| 909 | - * This method just allows the resetting of page properties in the case where a no headers |
|
| 910 | - * route redirects to a headers route in its route config. |
|
| 911 | - * |
|
| 912 | - * @since 4.3.0 |
|
| 913 | - * @param string $new_route New (non header) route to redirect to. |
|
| 914 | - * @return void |
|
| 915 | - */ |
|
| 916 | - protected function _reset_routing_properties($new_route) |
|
| 917 | - { |
|
| 918 | - $this->_is_UI_request = true; |
|
| 919 | - //now we set the current route to whatever the headers_sent_route is set at |
|
| 920 | - $this->_req_data['action'] = $new_route; |
|
| 921 | - //rerun page setup |
|
| 922 | - $this->_page_setup(); |
|
| 923 | - } |
|
| 924 | - |
|
| 925 | - |
|
| 926 | - |
|
| 927 | - /** |
|
| 928 | - * _add_query_arg |
|
| 929 | - * adds nonce to array of arguments then calls WP add_query_arg function |
|
| 930 | - *(internally just uses EEH_URL's function with the same name) |
|
| 931 | - * |
|
| 932 | - * @access public |
|
| 933 | - * @param array $args |
|
| 934 | - * @param string $url |
|
| 935 | - * @param bool $sticky if true, then the existing Request params will be appended to the generated |
|
| 936 | - * url in an associative array indexed by the key 'wp_referer'; |
|
| 937 | - * Example usage: |
|
| 938 | - * If the current page is: |
|
| 939 | - * http://mydomain.com/wp-admin/admin.php?page=espresso_registrations |
|
| 940 | - * &action=default&event_id=20&month_range=March%202015 |
|
| 941 | - * &_wpnonce=5467821 |
|
| 942 | - * and you call: |
|
| 943 | - * EE_Admin_Page::add_query_args_and_nonce( |
|
| 944 | - * array( |
|
| 945 | - * 'action' => 'resend_something', |
|
| 946 | - * 'page=>espresso_registrations' |
|
| 947 | - * ), |
|
| 948 | - * $some_url, |
|
| 949 | - * true |
|
| 950 | - * ); |
|
| 951 | - * It will produce a url in this structure: |
|
| 952 | - * http://{$some_url}/?page=espresso_registrations&action=resend_something |
|
| 953 | - * &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[ |
|
| 954 | - * month_range]=March%202015 |
|
| 955 | - * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
|
| 956 | - * @return string |
|
| 957 | - */ |
|
| 958 | - public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) |
|
| 959 | - { |
|
| 960 | - //if there is a _wp_http_referer include the values from the request but only if sticky = true |
|
| 961 | - if ($sticky) { |
|
| 962 | - $request = $_REQUEST; |
|
| 963 | - unset($request['_wp_http_referer']); |
|
| 964 | - unset($request['wp_referer']); |
|
| 965 | - foreach ($request as $key => $value) { |
|
| 966 | - //do not add nonces |
|
| 967 | - if (strpos($key, 'nonce') !== false) { |
|
| 968 | - continue; |
|
| 969 | - } |
|
| 970 | - $args['wp_referer[' . $key . ']'] = $value; |
|
| 971 | - } |
|
| 972 | - } |
|
| 973 | - return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - |
|
| 977 | - |
|
| 978 | - /** |
|
| 979 | - * This returns a generated link that will load the related help tab. |
|
| 980 | - * |
|
| 981 | - * @param string $help_tab_id the id for the connected help tab |
|
| 982 | - * @param string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
| 983 | - * @param string $help_text (optional) send help text you want to use for the link if default not to be used |
|
| 984 | - * @uses EEH_Template::get_help_tab_link() |
|
| 985 | - * @return string generated link |
|
| 986 | - */ |
|
| 987 | - protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false) |
|
| 988 | - { |
|
| 989 | - return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
| 990 | - } |
|
| 991 | - |
|
| 992 | - |
|
| 993 | - |
|
| 994 | - /** |
|
| 995 | - * _add_help_tabs |
|
| 996 | - * Note child classes define their help tabs within the page_config array. |
|
| 997 | - * |
|
| 998 | - * @link http://codex.wordpress.org/Function_Reference/add_help_tab |
|
| 999 | - * @access protected |
|
| 1000 | - * @return void |
|
| 1001 | - */ |
|
| 1002 | - protected function _add_help_tabs() |
|
| 1003 | - { |
|
| 1004 | - $tour_buttons = ''; |
|
| 1005 | - if (isset($this->_page_config[$this->_req_action])) { |
|
| 1006 | - $config = $this->_page_config[$this->_req_action]; |
|
| 1007 | - //is there a help tour for the current route? if there is let's setup the tour buttons |
|
| 1008 | - if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1009 | - $tb = array(); |
|
| 1010 | - $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
|
| 1011 | - foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1012 | - //if this is the end tour then we don't need to setup a button |
|
| 1013 | - if ($tour instanceof EE_Help_Tour_final_stop) { |
|
| 1014 | - continue; |
|
| 1015 | - } |
|
| 1016 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
| 1017 | - } |
|
| 1018 | - $tour_buttons .= implode('<br />', $tb); |
|
| 1019 | - $tour_buttons .= '</div></div>'; |
|
| 1020 | - } |
|
| 1021 | - // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
|
| 1022 | - if (is_array($config) && isset($config['help_sidebar'])) { |
|
| 1023 | - //check that the callback given is valid |
|
| 1024 | - if ( ! method_exists($this, $config['help_sidebar'])) { |
|
| 1025 | - throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
|
| 1026 | - 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
| 1027 | - } |
|
| 1028 | - $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
| 1029 | - $content .= $tour_buttons; //add help tour buttons. |
|
| 1030 | - //do we have any help tours setup? Cause if we do we want to add the buttons |
|
| 1031 | - $this->_current_screen->set_help_sidebar($content); |
|
| 1032 | - } |
|
| 1033 | - //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
|
| 1034 | - if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
| 1035 | - $this->_current_screen->set_help_sidebar($tour_buttons); |
|
| 1036 | - } |
|
| 1037 | - //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
|
| 1038 | - if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
| 1039 | - $_ht['id'] = $this->page_slug; |
|
| 1040 | - $_ht['title'] = __('Help Tours', 'event_espresso'); |
|
| 1041 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
| 1042 | - $this->_current_screen->add_help_tab($_ht); |
|
| 1043 | - }/**/ |
|
| 1044 | - if ( ! isset($config['help_tabs'])) { |
|
| 1045 | - return; |
|
| 1046 | - } //no help tabs for this route |
|
| 1047 | - foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
| 1048 | - //we're here so there ARE help tabs! |
|
| 1049 | - //make sure we've got what we need |
|
| 1050 | - if ( ! isset($cfg['title'])) { |
|
| 1051 | - throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
| 1052 | - } |
|
| 1053 | - if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) { |
|
| 1054 | - throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', |
|
| 1055 | - 'event_espresso')); |
|
| 1056 | - } |
|
| 1057 | - //first priority goes to content. |
|
| 1058 | - if ( ! empty($cfg['content'])) { |
|
| 1059 | - $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
|
| 1060 | - //second priority goes to filename |
|
| 1061 | - } else if ( ! empty($cfg['filename'])) { |
|
| 1062 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
| 1063 | - //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
|
| 1064 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
| 1065 | - //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
| 1066 | - if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
| 1067 | - EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
|
| 1068 | - 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
| 1069 | - return; |
|
| 1070 | - } |
|
| 1071 | - $template_args['admin_page_obj'] = $this; |
|
| 1072 | - $content = EEH_Template::display_template($file_path, $template_args, true); |
|
| 1073 | - } else { |
|
| 1074 | - $content = ''; |
|
| 1075 | - } |
|
| 1076 | - //check if callback is valid |
|
| 1077 | - if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
| 1078 | - EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', |
|
| 1079 | - 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
| 1080 | - return; |
|
| 1081 | - } |
|
| 1082 | - //setup config array for help tab method |
|
| 1083 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
| 1084 | - $_ht = array( |
|
| 1085 | - 'id' => $id, |
|
| 1086 | - 'title' => $cfg['title'], |
|
| 1087 | - 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null, |
|
| 1088 | - 'content' => $content, |
|
| 1089 | - ); |
|
| 1090 | - $this->_current_screen->add_help_tab($_ht); |
|
| 1091 | - } |
|
| 1092 | - } |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - |
|
| 1096 | - |
|
| 1097 | - /** |
|
| 1098 | - * This basically checks loaded $_page_config property to see if there are any help_tours defined. "help_tours" is an array with properties for setting up usage of the joyride plugin |
|
| 1099 | - * |
|
| 1100 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
| 1101 | - * @see instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments |
|
| 1102 | - * @access protected |
|
| 1103 | - * @return void |
|
| 1104 | - */ |
|
| 1105 | - protected function _add_help_tour() |
|
| 1106 | - { |
|
| 1107 | - $tours = array(); |
|
| 1108 | - $this->_help_tour = array(); |
|
| 1109 | - //exit early if help tours are turned off globally |
|
| 1110 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) { |
|
| 1111 | - return; |
|
| 1112 | - } |
|
| 1113 | - //loop through _page_config to find any help_tour defined |
|
| 1114 | - foreach ($this->_page_config as $route => $config) { |
|
| 1115 | - //we're only going to set things up for this route |
|
| 1116 | - if ($route !== $this->_req_action) { |
|
| 1117 | - continue; |
|
| 1118 | - } |
|
| 1119 | - if (isset($config['help_tour'])) { |
|
| 1120 | - foreach ($config['help_tour'] as $tour) { |
|
| 1121 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
| 1122 | - //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
|
| 1123 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
| 1124 | - //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
| 1125 | - if ( ! is_readable($file_path)) { |
|
| 1126 | - EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
|
| 1127 | - $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
| 1128 | - return; |
|
| 1129 | - } |
|
| 1130 | - require_once $file_path; |
|
| 1131 | - if ( ! class_exists($tour)) { |
|
| 1132 | - $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
| 1133 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
| 1134 | - 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
| 1135 | - throw new EE_Error(implode('||', $error_msg)); |
|
| 1136 | - } |
|
| 1137 | - $a = new ReflectionClass($tour); |
|
| 1138 | - $tour_obj = $a->newInstance($this->_is_caf); |
|
| 1139 | - $tours[] = $tour_obj; |
|
| 1140 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
| 1141 | - } |
|
| 1142 | - //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
|
| 1143 | - $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
|
| 1144 | - $tours[] = $end_stop_tour; |
|
| 1145 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
| 1146 | - } |
|
| 1147 | - } |
|
| 1148 | - if ( ! empty($tours)) { |
|
| 1149 | - $this->_help_tour['tours'] = $tours; |
|
| 1150 | - } |
|
| 1151 | - //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
|
| 1152 | - } |
|
| 1153 | - |
|
| 1154 | - |
|
| 1155 | - |
|
| 1156 | - /** |
|
| 1157 | - * This simply sets up any qtips that have been defined in the page config |
|
| 1158 | - * |
|
| 1159 | - * @access protected |
|
| 1160 | - * @return void |
|
| 1161 | - */ |
|
| 1162 | - protected function _add_qtips() |
|
| 1163 | - { |
|
| 1164 | - if (isset($this->_route_config['qtips'])) { |
|
| 1165 | - $qtips = (array)$this->_route_config['qtips']; |
|
| 1166 | - //load qtip loader |
|
| 1167 | - $path = array( |
|
| 1168 | - $this->_get_dir() . '/qtips/', |
|
| 1169 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
| 1170 | - ); |
|
| 1171 | - EEH_Qtip_Loader::instance()->register($qtips, $path); |
|
| 1172 | - } |
|
| 1173 | - } |
|
| 1174 | - |
|
| 1175 | - |
|
| 1176 | - |
|
| 1177 | - /** |
|
| 1178 | - * _set_nav_tabs |
|
| 1179 | - * This sets up the nav tabs from the page_routes array. This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly. |
|
| 1180 | - * |
|
| 1181 | - * @access protected |
|
| 1182 | - * @return void |
|
| 1183 | - */ |
|
| 1184 | - protected function _set_nav_tabs() |
|
| 1185 | - { |
|
| 1186 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1187 | - $i = 0; |
|
| 1188 | - foreach ($this->_page_config as $slug => $config) { |
|
| 1189 | - if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) { |
|
| 1190 | - continue; |
|
| 1191 | - } //no nav tab for this config |
|
| 1192 | - //check for persistent flag |
|
| 1193 | - if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) { |
|
| 1194 | - continue; |
|
| 1195 | - } //nav tab is only to appear when route requested. |
|
| 1196 | - if ( ! $this->check_user_access($slug, true)) { |
|
| 1197 | - continue; |
|
| 1198 | - } //no nav tab becasue current user does not have access. |
|
| 1199 | - $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
| 1200 | - $this->_nav_tabs[$slug] = array( |
|
| 1201 | - 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
|
| 1202 | - 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
| 1203 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
| 1204 | - 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
|
| 1205 | - ); |
|
| 1206 | - $i++; |
|
| 1207 | - } |
|
| 1208 | - //if $this->_nav_tabs is empty then lets set the default |
|
| 1209 | - if (empty($this->_nav_tabs)) { |
|
| 1210 | - $this->_nav_tabs[$this->default_nav_tab_name] = array( |
|
| 1211 | - 'url' => $this->admin_base_url, |
|
| 1212 | - 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
| 1213 | - 'css_class' => 'nav-tab-active', |
|
| 1214 | - 'order' => 10, |
|
| 1215 | - ); |
|
| 1216 | - } |
|
| 1217 | - //now let's sort the tabs according to order |
|
| 1218 | - usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - |
|
| 1222 | - |
|
| 1223 | - /** |
|
| 1224 | - * _set_current_labels |
|
| 1225 | - * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array |
|
| 1226 | - * |
|
| 1227 | - * @access private |
|
| 1228 | - * @return void |
|
| 1229 | - */ |
|
| 1230 | - private function _set_current_labels() |
|
| 1231 | - { |
|
| 1232 | - if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
| 1233 | - foreach ($this->_route_config['labels'] as $label => $text) { |
|
| 1234 | - if (is_array($text)) { |
|
| 1235 | - foreach ($text as $sublabel => $subtext) { |
|
| 1236 | - $this->_labels[$label][$sublabel] = $subtext; |
|
| 1237 | - } |
|
| 1238 | - } else { |
|
| 1239 | - $this->_labels[$label] = $text; |
|
| 1240 | - } |
|
| 1241 | - } |
|
| 1242 | - } |
|
| 1243 | - } |
|
| 1244 | - |
|
| 1245 | - |
|
| 1246 | - |
|
| 1247 | - /** |
|
| 1248 | - * verifies user access for this admin page |
|
| 1249 | - * |
|
| 1250 | - * @param string $route_to_check if present then the capability for the route matching this string is checked. |
|
| 1251 | - * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
|
| 1252 | - * @return BOOL|wp_die() |
|
| 1253 | - */ |
|
| 1254 | - public function check_user_access($route_to_check = '', $verify_only = false) |
|
| 1255 | - { |
|
| 1256 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1257 | - $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
| 1258 | - $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) |
|
| 1259 | - ? $this->_page_routes[$route_to_check]['capability'] : null; |
|
| 1260 | - if (empty($capability) && empty($route_to_check)) { |
|
| 1261 | - $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
| 1262 | - } else { |
|
| 1263 | - $capability = empty($capability) ? 'manage_options' : $capability; |
|
| 1264 | - } |
|
| 1265 | - $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
| 1266 | - if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
| 1267 | - if ($verify_only) { |
|
| 1268 | - return false; |
|
| 1269 | - } else { |
|
| 1270 | - if ( is_user_logged_in() ) { |
|
| 1271 | - wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
| 1272 | - } else { |
|
| 1273 | - return false; |
|
| 1274 | - } |
|
| 1275 | - } |
|
| 1276 | - } |
|
| 1277 | - return true; |
|
| 1278 | - } |
|
| 1279 | - |
|
| 1280 | - |
|
| 1281 | - |
|
| 1282 | - /** |
|
| 1283 | - * admin_init_global |
|
| 1284 | - * This runs all the code that we want executed within the WP admin_init hook. |
|
| 1285 | - * This method executes for ALL EE Admin pages. |
|
| 1286 | - * |
|
| 1287 | - * @access public |
|
| 1288 | - * @return void |
|
| 1289 | - */ |
|
| 1290 | - public function admin_init_global() |
|
| 1291 | - { |
|
| 1292 | - } |
|
| 1293 | - |
|
| 1294 | - |
|
| 1295 | - |
|
| 1296 | - /** |
|
| 1297 | - * wp_loaded_global |
|
| 1298 | - * This runs all the code that we want executed within the WP wp_loaded hook. This method is optional for an EE_Admin page and will execute on every EE Admin Page load |
|
| 1299 | - * |
|
| 1300 | - * @access public |
|
| 1301 | - * @return void |
|
| 1302 | - */ |
|
| 1303 | - public function wp_loaded() |
|
| 1304 | - { |
|
| 1305 | - } |
|
| 1306 | - |
|
| 1307 | - |
|
| 1308 | - |
|
| 1309 | - /** |
|
| 1310 | - * admin_notices |
|
| 1311 | - * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
| 1312 | - * |
|
| 1313 | - * @access public |
|
| 1314 | - * @return void |
|
| 1315 | - */ |
|
| 1316 | - public function admin_notices_global() |
|
| 1317 | - { |
|
| 1318 | - $this->_display_no_javascript_warning(); |
|
| 1319 | - $this->_display_espresso_notices(); |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - |
|
| 1323 | - |
|
| 1324 | - public function network_admin_notices_global() |
|
| 1325 | - { |
|
| 1326 | - $this->_display_no_javascript_warning(); |
|
| 1327 | - $this->_display_espresso_notices(); |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - |
|
| 1331 | - |
|
| 1332 | - /** |
|
| 1333 | - * admin_footer_scripts_global |
|
| 1334 | - * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
| 1335 | - * |
|
| 1336 | - * @access public |
|
| 1337 | - * @return void |
|
| 1338 | - */ |
|
| 1339 | - public function admin_footer_scripts_global() |
|
| 1340 | - { |
|
| 1341 | - $this->_add_admin_page_ajax_loading_img(); |
|
| 1342 | - $this->_add_admin_page_overlay(); |
|
| 1343 | - //if metaboxes are present we need to add the nonce field |
|
| 1344 | - if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
| 1345 | - wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
| 1346 | - wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
| 1347 | - } |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - |
|
| 1351 | - |
|
| 1352 | - /** |
|
| 1353 | - * admin_footer_global |
|
| 1354 | - * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages. |
|
| 1355 | - * |
|
| 1356 | - * @access public |
|
| 1357 | - * @return void |
|
| 1358 | - */ |
|
| 1359 | - public function admin_footer_global() |
|
| 1360 | - { |
|
| 1361 | - //dialog container for dialog helper |
|
| 1362 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
| 1363 | - $d_cont .= '<div class="ee-notices"></div>'; |
|
| 1364 | - $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
|
| 1365 | - $d_cont .= '</div>'; |
|
| 1366 | - echo $d_cont; |
|
| 1367 | - //help tour stuff? |
|
| 1368 | - if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1369 | - echo implode('<br />', $this->_help_tour[$this->_req_action]); |
|
| 1370 | - } |
|
| 1371 | - //current set timezone for timezone js |
|
| 1372 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
| 1373 | - } |
|
| 1374 | - |
|
| 1375 | - |
|
| 1376 | - |
|
| 1377 | - /** |
|
| 1378 | - * This function sees if there is a method for help popup content existing for the given route. If there is then we'll use the retrieved array to output the content using the template. |
|
| 1379 | - * For child classes: |
|
| 1380 | - * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for |
|
| 1381 | - * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()" So if you are setting help content for the |
|
| 1382 | - * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method. You must prepare and return an array in the following format array( |
|
| 1383 | - * 'help_trigger_id' => array( |
|
| 1384 | - * 'title' => __('localized title for popup', 'event_espresso'), |
|
| 1385 | - * 'content' => __('localized content for popup', 'event_espresso') |
|
| 1386 | - * ) |
|
| 1387 | - * ); |
|
| 1388 | - * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route. |
|
| 1389 | - * |
|
| 1390 | - * @access protected |
|
| 1391 | - * @return string content |
|
| 1392 | - */ |
|
| 1393 | - protected function _set_help_popup_content($help_array = array(), $display = false) |
|
| 1394 | - { |
|
| 1395 | - $content = ''; |
|
| 1396 | - $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
| 1397 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
| 1398 | - //loop through the array and setup content |
|
| 1399 | - foreach ($help_array as $trigger => $help) { |
|
| 1400 | - //make sure the array is setup properly |
|
| 1401 | - if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
| 1402 | - throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', |
|
| 1403 | - 'event_espresso')); |
|
| 1404 | - } |
|
| 1405 | - //we're good so let'd setup the template vars and then assign parsed template content to our content. |
|
| 1406 | - $template_args = array( |
|
| 1407 | - 'help_popup_id' => $trigger, |
|
| 1408 | - 'help_popup_title' => $help['title'], |
|
| 1409 | - 'help_popup_content' => $help['content'], |
|
| 1410 | - ); |
|
| 1411 | - $content .= EEH_Template::display_template($template_path, $template_args, true); |
|
| 1412 | - } |
|
| 1413 | - if ($display) { |
|
| 1414 | - echo $content; |
|
| 1415 | - } else { |
|
| 1416 | - return $content; |
|
| 1417 | - } |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - |
|
| 1421 | - |
|
| 1422 | - /** |
|
| 1423 | - * All this does is retrive the help content array if set by the EE_Admin_Page child |
|
| 1424 | - * |
|
| 1425 | - * @access private |
|
| 1426 | - * @return array properly formatted array for help popup content |
|
| 1427 | - */ |
|
| 1428 | - private function _get_help_content() |
|
| 1429 | - { |
|
| 1430 | - //what is the method we're looking for? |
|
| 1431 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
| 1432 | - //if method doesn't exist let's get out. |
|
| 1433 | - if ( ! method_exists($this, $method_name)) { |
|
| 1434 | - return array(); |
|
| 1435 | - } |
|
| 1436 | - //k we're good to go let's retrieve the help array |
|
| 1437 | - $help_array = call_user_func(array($this, $method_name)); |
|
| 1438 | - //make sure we've got an array! |
|
| 1439 | - if ( ! is_array($help_array)) { |
|
| 1440 | - throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
| 1441 | - } |
|
| 1442 | - return $help_array; |
|
| 1443 | - } |
|
| 1444 | - |
|
| 1445 | - |
|
| 1446 | - |
|
| 1447 | - /** |
|
| 1448 | - * EE Admin Pages can use this to set a properly formatted trigger for a help popup. |
|
| 1449 | - * By default the trigger html is printed. Otherwise it can be returned if the $display flag is set "false" |
|
| 1450 | - * See comments made on the _set_help_content method for understanding other parts to the help popup tool. |
|
| 1451 | - * |
|
| 1452 | - * @access protected |
|
| 1453 | - * @param string $trigger_id reference for retrieving the trigger content for the popup |
|
| 1454 | - * @param boolean $display if false then we return the trigger string |
|
| 1455 | - * @param array $dimensions an array of dimensions for the box (array(h,w)) |
|
| 1456 | - * @return string |
|
| 1457 | - */ |
|
| 1458 | - protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640')) |
|
| 1459 | - { |
|
| 1460 | - if (defined('DOING_AJAX')) { |
|
| 1461 | - return; |
|
| 1462 | - } |
|
| 1463 | - //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
|
| 1464 | - $help_array = $this->_get_help_content(); |
|
| 1465 | - $help_content = ''; |
|
| 1466 | - if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
| 1467 | - $help_array[$trigger_id] = array( |
|
| 1468 | - 'title' => __('Missing Content', 'event_espresso'), |
|
| 1469 | - 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', |
|
| 1470 | - 'event_espresso'), |
|
| 1471 | - ); |
|
| 1472 | - $help_content = $this->_set_help_popup_content($help_array, false); |
|
| 1473 | - } |
|
| 1474 | - //let's setup the trigger |
|
| 1475 | - $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1476 | - $content = $content . $help_content; |
|
| 1477 | - if ($display) { |
|
| 1478 | - echo $content; |
|
| 1479 | - } else { |
|
| 1480 | - return $content; |
|
| 1481 | - } |
|
| 1482 | - } |
|
| 1483 | - |
|
| 1484 | - |
|
| 1485 | - |
|
| 1486 | - /** |
|
| 1487 | - * _add_global_screen_options |
|
| 1488 | - * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
| 1489 | - * This particular method will add_screen_options on ALL EE_Admin Pages |
|
| 1490 | - * |
|
| 1491 | - * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
| 1492 | - * see also WP_Screen object documents... |
|
| 1493 | - * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
| 1494 | - * @abstract |
|
| 1495 | - * @access private |
|
| 1496 | - * @return void |
|
| 1497 | - */ |
|
| 1498 | - private function _add_global_screen_options() |
|
| 1499 | - { |
|
| 1500 | - } |
|
| 1501 | - |
|
| 1502 | - |
|
| 1503 | - |
|
| 1504 | - /** |
|
| 1505 | - * _add_global_feature_pointers |
|
| 1506 | - * This method is used for implementing any "feature pointers" (using built-in WP styling js). |
|
| 1507 | - * This particular method will implement feature pointers for ALL EE_Admin pages. |
|
| 1508 | - * Note: this is just a placeholder for now. Implementation will come down the road |
|
| 1509 | - * |
|
| 1510 | - * @see WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
| 1511 | - * @link http://eamann.com/tech/wordpress-portland/ |
|
| 1512 | - * @abstract |
|
| 1513 | - * @access protected |
|
| 1514 | - * @return void |
|
| 1515 | - */ |
|
| 1516 | - private function _add_global_feature_pointers() |
|
| 1517 | - { |
|
| 1518 | - } |
|
| 1519 | - |
|
| 1520 | - |
|
| 1521 | - |
|
| 1522 | - /** |
|
| 1523 | - * load_global_scripts_styles |
|
| 1524 | - * The scripts and styles enqueued in here will be loaded on every EE Admin page |
|
| 1525 | - * |
|
| 1526 | - * @return void |
|
| 1527 | - */ |
|
| 1528 | - public function load_global_scripts_styles() |
|
| 1529 | - { |
|
| 1530 | - /** STYLES **/ |
|
| 1531 | - // add debugging styles |
|
| 1532 | - if (WP_DEBUG) { |
|
| 1533 | - add_action('admin_head', array($this, 'add_xdebug_style')); |
|
| 1534 | - } |
|
| 1535 | - //register all styles |
|
| 1536 | - wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1537 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1538 | - //helpers styles |
|
| 1539 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1540 | - //enqueue global styles |
|
| 1541 | - wp_enqueue_style('ee-admin-css'); |
|
| 1542 | - /** SCRIPTS **/ |
|
| 1543 | - //register all scripts |
|
| 1544 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1545 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1546 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
| 1547 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
| 1548 | - // register jQuery Validate - see /includes/functions/wp_hooks.php |
|
| 1549 | - add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 1550 | - add_filter('FHEE_load_joyride', '__return_true'); |
|
| 1551 | - //script for sorting tables |
|
| 1552 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1553 | - //script for parsing uri's |
|
| 1554 | - wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1555 | - //and parsing associative serialized form elements |
|
| 1556 | - wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1557 | - //helpers scripts |
|
| 1558 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1559 | - wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1560 | - wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
| 1561 | - wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
| 1562 | - //google charts |
|
| 1563 | - wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
| 1564 | - //enqueue global scripts |
|
| 1565 | - //taking care of metaboxes |
|
| 1566 | - if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
| 1567 | - wp_enqueue_script('dashboard'); |
|
| 1568 | - } |
|
| 1569 | - //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
|
| 1570 | - if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
| 1571 | - wp_enqueue_script('ee_admin_js'); |
|
| 1572 | - wp_enqueue_style('ee-admin-css'); |
|
| 1573 | - } |
|
| 1574 | - //localize script for ajax lazy loading |
|
| 1575 | - $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
| 1576 | - wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
| 1577 | - /** |
|
| 1578 | - * help tour stuff |
|
| 1579 | - */ |
|
| 1580 | - if ( ! empty($this->_help_tour)) { |
|
| 1581 | - //register the js for kicking things off |
|
| 1582 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
| 1583 | - //setup tours for the js tour object |
|
| 1584 | - foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1585 | - $tours[] = array( |
|
| 1586 | - 'id' => $tour->get_slug(), |
|
| 1587 | - 'options' => $tour->get_options(), |
|
| 1588 | - ); |
|
| 1589 | - } |
|
| 1590 | - wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
| 1591 | - //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
|
| 1592 | - } |
|
| 1593 | - } |
|
| 1594 | - |
|
| 1595 | - |
|
| 1596 | - |
|
| 1597 | - /** |
|
| 1598 | - * admin_footer_scripts_eei18n_js_strings |
|
| 1599 | - * |
|
| 1600 | - * @access public |
|
| 1601 | - * @return void |
|
| 1602 | - */ |
|
| 1603 | - public function admin_footer_scripts_eei18n_js_strings() |
|
| 1604 | - { |
|
| 1605 | - EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
|
| 1606 | - EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
| 1607 | - EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
| 1608 | - EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
| 1609 | - EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
| 1610 | - EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
| 1611 | - EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1612 | - EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
| 1613 | - EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
| 1614 | - EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
| 1615 | - EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
| 1616 | - EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
| 1617 | - EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
| 1618 | - EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
| 1619 | - EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
| 1620 | - EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
| 1621 | - EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
| 1622 | - EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
| 1623 | - EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1624 | - EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
| 1625 | - EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
| 1626 | - EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
| 1627 | - EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
| 1628 | - EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
| 1629 | - EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
| 1630 | - EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
| 1631 | - EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
| 1632 | - EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
| 1633 | - EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
| 1634 | - EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
| 1635 | - EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
| 1636 | - EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
| 1637 | - EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
| 1638 | - EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
| 1639 | - EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
| 1640 | - EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
| 1641 | - EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
| 1642 | - EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
| 1643 | - EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
| 1644 | - EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
| 1645 | - //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
|
| 1646 | - //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
|
| 1647 | - //espresso_core is listed as a dependency of ee_admin_js. |
|
| 1648 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
| 1649 | - } |
|
| 1650 | - |
|
| 1651 | - |
|
| 1652 | - |
|
| 1653 | - /** |
|
| 1654 | - * load enhanced xdebug styles for ppl with failing eyesight |
|
| 1655 | - * |
|
| 1656 | - * @access public |
|
| 1657 | - * @return void |
|
| 1658 | - */ |
|
| 1659 | - public function add_xdebug_style() |
|
| 1660 | - { |
|
| 1661 | - echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
|
| 1662 | - } |
|
| 1663 | - |
|
| 1664 | - |
|
| 1665 | - /************************/ |
|
| 1666 | - /** LIST TABLE METHODS **/ |
|
| 1667 | - /************************/ |
|
| 1668 | - /** |
|
| 1669 | - * this sets up the list table if the current view requires it. |
|
| 1670 | - * |
|
| 1671 | - * @access protected |
|
| 1672 | - * @return void |
|
| 1673 | - */ |
|
| 1674 | - protected function _set_list_table() |
|
| 1675 | - { |
|
| 1676 | - //first is this a list_table view? |
|
| 1677 | - if ( ! isset($this->_route_config['list_table'])) { |
|
| 1678 | - return; |
|
| 1679 | - } //not a list_table view so get out. |
|
| 1680 | - //list table functions are per view specific (because some admin pages might have more than one listtable!) |
|
| 1681 | - if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
| 1682 | - //user error msg |
|
| 1683 | - $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
| 1684 | - //developer error msg |
|
| 1685 | - $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
| 1686 | - $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
| 1687 | - throw new EE_Error($error_msg); |
|
| 1688 | - } |
|
| 1689 | - //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
|
| 1690 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
| 1691 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
| 1692 | - $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
| 1693 | - $this->_set_list_table_view(); |
|
| 1694 | - $this->_set_list_table_object(); |
|
| 1695 | - } |
|
| 1696 | - |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - /** |
|
| 1700 | - * set current view for List Table |
|
| 1701 | - * |
|
| 1702 | - * @access public |
|
| 1703 | - * @return array |
|
| 1704 | - */ |
|
| 1705 | - protected function _set_list_table_view() |
|
| 1706 | - { |
|
| 1707 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1708 | - // looking at active items or dumpster diving ? |
|
| 1709 | - if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
| 1710 | - $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
| 1711 | - } else { |
|
| 1712 | - $this->_view = sanitize_key($this->_req_data['status']); |
|
| 1713 | - } |
|
| 1714 | - } |
|
| 1715 | - |
|
| 1716 | - |
|
| 1717 | - |
|
| 1718 | - /** |
|
| 1719 | - * _set_list_table_object |
|
| 1720 | - * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of. |
|
| 1721 | - * |
|
| 1722 | - * @throws \EE_Error |
|
| 1723 | - */ |
|
| 1724 | - protected function _set_list_table_object() |
|
| 1725 | - { |
|
| 1726 | - if (isset($this->_route_config['list_table'])) { |
|
| 1727 | - if ( ! class_exists($this->_route_config['list_table'])) { |
|
| 1728 | - throw new EE_Error( |
|
| 1729 | - sprintf( |
|
| 1730 | - __( |
|
| 1731 | - 'The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', |
|
| 1732 | - 'event_espresso' |
|
| 1733 | - ), |
|
| 1734 | - $this->_route_config['list_table'], |
|
| 1735 | - get_class($this) |
|
| 1736 | - ) |
|
| 1737 | - ); |
|
| 1738 | - } |
|
| 1739 | - $list_table = $this->_route_config['list_table']; |
|
| 1740 | - $this->_list_table_object = new $list_table($this); |
|
| 1741 | - } |
|
| 1742 | - } |
|
| 1743 | - |
|
| 1744 | - |
|
| 1745 | - |
|
| 1746 | - /** |
|
| 1747 | - * get_list_table_view_RLs - get it? View RL ?? VU-RL??? URL ?? |
|
| 1748 | - * |
|
| 1749 | - * @param array $extra_query_args Optional. An array of extra query args to add to the generated |
|
| 1750 | - * urls. The array should be indexed by the view it is being |
|
| 1751 | - * added to. |
|
| 1752 | - * @return array |
|
| 1753 | - */ |
|
| 1754 | - public function get_list_table_view_RLs($extra_query_args = array()) |
|
| 1755 | - { |
|
| 1756 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1757 | - if (empty($this->_views)) { |
|
| 1758 | - $this->_views = array(); |
|
| 1759 | - } |
|
| 1760 | - // cycle thru views |
|
| 1761 | - foreach ($this->_views as $key => $view) { |
|
| 1762 | - $query_args = array(); |
|
| 1763 | - // check for current view |
|
| 1764 | - $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
| 1765 | - $query_args['action'] = $this->_req_action; |
|
| 1766 | - $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 1767 | - $query_args['status'] = $view['slug']; |
|
| 1768 | - //merge any other arguments sent in. |
|
| 1769 | - if (isset($extra_query_args[$view['slug']])) { |
|
| 1770 | - $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
| 1771 | - } |
|
| 1772 | - $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
| 1773 | - } |
|
| 1774 | - return $this->_views; |
|
| 1775 | - } |
|
| 1776 | - |
|
| 1777 | - |
|
| 1778 | - |
|
| 1779 | - /** |
|
| 1780 | - * _entries_per_page_dropdown |
|
| 1781 | - * generates a drop down box for selecting the number of visiable rows in an admin page list table |
|
| 1782 | - * |
|
| 1783 | - * @todo : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it. |
|
| 1784 | - * @access protected |
|
| 1785 | - * @param int $max_entries total number of rows in the table |
|
| 1786 | - * @return string |
|
| 1787 | - */ |
|
| 1788 | - protected function _entries_per_page_dropdown($max_entries = false) |
|
| 1789 | - { |
|
| 1790 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1791 | - $values = array(10, 25, 50, 100); |
|
| 1792 | - $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
| 1793 | - if ($max_entries) { |
|
| 1794 | - $values[] = $max_entries; |
|
| 1795 | - sort($values); |
|
| 1796 | - } |
|
| 1797 | - $entries_per_page_dropdown = ' |
|
| 143 | + // yes / no array for admin form fields |
|
| 144 | + protected $_yes_no_values = array(); |
|
| 145 | + |
|
| 146 | + //some default things shared by all child classes |
|
| 147 | + protected $_default_espresso_metaboxes; |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * EE_Registry Object |
|
| 151 | + * |
|
| 152 | + * @var EE_Registry |
|
| 153 | + * @access protected |
|
| 154 | + */ |
|
| 155 | + protected $EE = null; |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * This is just a property that flags whether the given route is a caffeinated route or not. |
|
| 161 | + * |
|
| 162 | + * @var boolean |
|
| 163 | + */ |
|
| 164 | + protected $_is_caf = false; |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @Constructor |
|
| 170 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
| 171 | + * @access public |
|
| 172 | + */ |
|
| 173 | + public function __construct($routing = true) |
|
| 174 | + { |
|
| 175 | + if (strpos($this->_get_dir(), 'caffeinated') !== false) { |
|
| 176 | + $this->_is_caf = true; |
|
| 177 | + } |
|
| 178 | + $this->_yes_no_values = array( |
|
| 179 | + array('id' => true, 'text' => __('Yes', 'event_espresso')), |
|
| 180 | + array('id' => false, 'text' => __('No', 'event_espresso')), |
|
| 181 | + ); |
|
| 182 | + //set the _req_data property. |
|
| 183 | + $this->_req_data = array_merge($_GET, $_POST); |
|
| 184 | + //routing enabled? |
|
| 185 | + $this->_routing = $routing; |
|
| 186 | + //set initial page props (child method) |
|
| 187 | + $this->_init_page_props(); |
|
| 188 | + //set global defaults |
|
| 189 | + $this->_set_defaults(); |
|
| 190 | + //set early because incoming requests could be ajax related and we need to register those hooks. |
|
| 191 | + $this->_global_ajax_hooks(); |
|
| 192 | + $this->_ajax_hooks(); |
|
| 193 | + //other_page_hooks have to be early too. |
|
| 194 | + $this->_do_other_page_hooks(); |
|
| 195 | + //This just allows us to have extending classes do something specific |
|
| 196 | + // before the parent constructor runs _page_setup(). |
|
| 197 | + if (method_exists($this, '_before_page_setup')) { |
|
| 198 | + $this->_before_page_setup(); |
|
| 199 | + } |
|
| 200 | + //set up page dependencies |
|
| 201 | + $this->_page_setup(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * _init_page_props |
|
| 208 | + * Child classes use to set at least the following properties: |
|
| 209 | + * $page_slug. |
|
| 210 | + * $page_label. |
|
| 211 | + * |
|
| 212 | + * @abstract |
|
| 213 | + * @access protected |
|
| 214 | + * @return void |
|
| 215 | + */ |
|
| 216 | + abstract protected function _init_page_props(); |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * _ajax_hooks |
|
| 222 | + * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
| 223 | + * Note: within the ajax callback methods. |
|
| 224 | + * |
|
| 225 | + * @abstract |
|
| 226 | + * @access protected |
|
| 227 | + * @return void |
|
| 228 | + */ |
|
| 229 | + abstract protected function _ajax_hooks(); |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * _define_page_props |
|
| 235 | + * child classes define page properties in here. Must include at least: |
|
| 236 | + * $_admin_base_url = base_url for all admin pages |
|
| 237 | + * $_admin_page_title = default admin_page_title for admin pages |
|
| 238 | + * $_labels = array of default labels for various automatically generated elements: |
|
| 239 | + * array( |
|
| 240 | + * 'buttons' => array( |
|
| 241 | + * 'add' => __('label for add new button'), |
|
| 242 | + * 'edit' => __('label for edit button'), |
|
| 243 | + * 'delete' => __('label for delete button') |
|
| 244 | + * ) |
|
| 245 | + * ) |
|
| 246 | + * |
|
| 247 | + * @abstract |
|
| 248 | + * @access protected |
|
| 249 | + * @return void |
|
| 250 | + */ |
|
| 251 | + abstract protected function _define_page_props(); |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * _set_page_routes |
|
| 257 | + * child classes use this to define the page routes for all subpages handled by the class. Page routes are assigned to a action => method pairs in an array and to the $_page_routes property. Each page route must also have a 'default' |
|
| 258 | + * route. Here's the format |
|
| 259 | + * $this->_page_routes = array( |
|
| 260 | + * 'default' => array( |
|
| 261 | + * 'func' => '_default_method_handling_route', |
|
| 262 | + * 'args' => array('array','of','args'), |
|
| 263 | + * 'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing) |
|
| 264 | + * 'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after. The string you enter here should match the defined route reference for a headers sent route. |
|
| 265 | + * 'capability' => 'route_capability', //indicate a string for minimum capability required to access this route. |
|
| 266 | + * 'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks). |
|
| 267 | + * ), |
|
| 268 | + * 'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method. |
|
| 269 | + * ) |
|
| 270 | + * ) |
|
| 271 | + * |
|
| 272 | + * @abstract |
|
| 273 | + * @access protected |
|
| 274 | + * @return void |
|
| 275 | + */ |
|
| 276 | + abstract protected function _set_page_routes(); |
|
| 277 | + |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * _set_page_config |
|
| 282 | + * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page. |
|
| 283 | + * Format: |
|
| 284 | + * $this->_page_config = array( |
|
| 285 | + * 'default' => array( |
|
| 286 | + * 'labels' => array( |
|
| 287 | + * 'buttons' => array( |
|
| 288 | + * 'add' => __('label for adding item'), |
|
| 289 | + * 'edit' => __('label for editing item'), |
|
| 290 | + * 'delete' => __('label for deleting item') |
|
| 291 | + * ), |
|
| 292 | + * 'publishbox' => __('Localized Title for Publish metabox', 'event_espresso') |
|
| 293 | + * ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method |
|
| 294 | + * 'nav' => array( |
|
| 295 | + * 'label' => __('Label for Tab', 'event_espresso'). |
|
| 296 | + * 'url' => 'http://someurl', //automatically generated UNLESS you define |
|
| 297 | + * 'css_class' => 'css-class', //automatically generated UNLESS you define |
|
| 298 | + * 'order' => 10, //required to indicate tab position. |
|
| 299 | + * 'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter. |
|
| 300 | + * 'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page. |
|
| 301 | + * 'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages. |
|
| 302 | + * 'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes. Typically this is used if the 'metaboxes' index is not used because metaboxes are added later. We just use |
|
| 303 | + * this flag to make sure the necessary js gets enqueued on page load. |
|
| 304 | + * 'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued. |
|
| 305 | + * 'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes). The array indicates the max number of columns (4) and the default number of columns on page load (2). There is an option |
|
| 306 | + * in the "screen_options" dropdown that is setup so users can pick what columns they want to display. |
|
| 307 | + * 'help_tabs' => array( //this is used for adding help tabs to a page |
|
| 308 | + * 'tab_id' => array( |
|
| 309 | + * 'title' => 'tab_title', |
|
| 310 | + * 'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content. The fallback if it isn't present is to try a the callback. Filename should match a file in the admin |
|
| 311 | + * folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php) |
|
| 312 | + * 'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class |
|
| 313 | + * ), |
|
| 314 | + * 'tab2_id' => array( |
|
| 315 | + * 'title' => 'tab2 title', |
|
| 316 | + * 'filename' => 'file_name_2' |
|
| 317 | + * 'callback' => 'callback_method_for_content', |
|
| 318 | + * ), |
|
| 319 | + * 'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/ |
|
| 320 | + * 'help_tour' => array( |
|
| 321 | + * 'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here |
|
| 322 | + * (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class) |
|
| 323 | + * ), |
|
| 324 | + * 'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present). To remove the requirement for a nonce check when this route is visited just set |
|
| 325 | + * 'require_nonce' to FALSE |
|
| 326 | + * ) |
|
| 327 | + * ) |
|
| 328 | + * |
|
| 329 | + * @abstract |
|
| 330 | + * @access protected |
|
| 331 | + * @return void |
|
| 332 | + */ |
|
| 333 | + abstract protected function _set_page_config(); |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** end sample help_tour methods **/ |
|
| 340 | + /** |
|
| 341 | + * _add_screen_options |
|
| 342 | + * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
| 343 | + * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view. |
|
| 344 | + * |
|
| 345 | + * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
| 346 | + * see also WP_Screen object documents... |
|
| 347 | + * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
| 348 | + * @abstract |
|
| 349 | + * @access protected |
|
| 350 | + * @return void |
|
| 351 | + */ |
|
| 352 | + abstract protected function _add_screen_options(); |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * _add_feature_pointers |
|
| 358 | + * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js). |
|
| 359 | + * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view. |
|
| 360 | + * Note: this is just a placeholder for now. Implementation will come down the road |
|
| 361 | + * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
| 362 | + * |
|
| 363 | + * @link http://eamann.com/tech/wordpress-portland/ |
|
| 364 | + * @abstract |
|
| 365 | + * @access protected |
|
| 366 | + * @return void |
|
| 367 | + */ |
|
| 368 | + abstract protected function _add_feature_pointers(); |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * load_scripts_styles |
|
| 374 | + * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages. Note this is for all pages/subpages of the system. You can also load only specific scripts/styles |
|
| 375 | + * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg) |
|
| 376 | + * |
|
| 377 | + * @abstract |
|
| 378 | + * @access public |
|
| 379 | + * @return void |
|
| 380 | + */ |
|
| 381 | + abstract public function load_scripts_styles(); |
|
| 382 | + |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * admin_init |
|
| 387 | + * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here. This will apply to all pages/views loaded by child class. |
|
| 388 | + * |
|
| 389 | + * @abstract |
|
| 390 | + * @access public |
|
| 391 | + * @return void |
|
| 392 | + */ |
|
| 393 | + abstract public function admin_init(); |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * admin_notices |
|
| 399 | + * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
| 400 | + * |
|
| 401 | + * @abstract |
|
| 402 | + * @access public |
|
| 403 | + * @return void |
|
| 404 | + */ |
|
| 405 | + abstract public function admin_notices(); |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * admin_footer_scripts |
|
| 411 | + * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
| 412 | + * |
|
| 413 | + * @access public |
|
| 414 | + * @return void |
|
| 415 | + */ |
|
| 416 | + abstract public function admin_footer_scripts(); |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * admin_footer |
|
| 422 | + * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class. |
|
| 423 | + * |
|
| 424 | + * @access public |
|
| 425 | + * @return void |
|
| 426 | + */ |
|
| 427 | + public function admin_footer() |
|
| 428 | + { |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * _global_ajax_hooks |
|
| 435 | + * all global add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
| 436 | + * Note: within the ajax callback methods. |
|
| 437 | + * |
|
| 438 | + * @abstract |
|
| 439 | + * @access protected |
|
| 440 | + * @return void |
|
| 441 | + */ |
|
| 442 | + protected function _global_ajax_hooks() |
|
| 443 | + { |
|
| 444 | + //for lazy loading of metabox content |
|
| 445 | + add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + public function ajax_metabox_content() |
|
| 451 | + { |
|
| 452 | + $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
| 453 | + $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
| 454 | + self::cached_rss_display($contentid, $url); |
|
| 455 | + wp_die(); |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + |
|
| 459 | + |
|
| 460 | + /** |
|
| 461 | + * _page_setup |
|
| 462 | + * Makes sure any things that need to be loaded early get handled. We also escape early here if the page requested doesn't match the object. |
|
| 463 | + * |
|
| 464 | + * @final |
|
| 465 | + * @access protected |
|
| 466 | + * @return void |
|
| 467 | + */ |
|
| 468 | + final protected function _page_setup() |
|
| 469 | + { |
|
| 470 | + //requires? |
|
| 471 | + //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
|
| 472 | + add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
| 473 | + //next verify if we need to load anything... |
|
| 474 | + $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
| 475 | + $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
| 476 | + global $ee_menu_slugs; |
|
| 477 | + $ee_menu_slugs = (array)$ee_menu_slugs; |
|
| 478 | + if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
|
| 479 | + return; |
|
| 480 | + } |
|
| 481 | + // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
|
| 482 | + if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
| 483 | + $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
| 484 | + } |
|
| 485 | + // then set blank or -1 action values to 'default' |
|
| 486 | + $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
| 487 | + //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
|
| 488 | + $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
| 489 | + //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
|
| 490 | + $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
| 491 | + $this->_current_view = $this->_req_action; |
|
| 492 | + $this->_req_nonce = $this->_req_action . '_nonce'; |
|
| 493 | + $this->_define_page_props(); |
|
| 494 | + $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
| 495 | + //default things |
|
| 496 | + $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
| 497 | + //set page configs |
|
| 498 | + $this->_set_page_routes(); |
|
| 499 | + $this->_set_page_config(); |
|
| 500 | + //let's include any referrer data in our default_query_args for this route for "stickiness". |
|
| 501 | + if (isset($this->_req_data['wp_referer'])) { |
|
| 502 | + $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
|
| 503 | + } |
|
| 504 | + //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
|
| 505 | + if (method_exists($this, '_extend_page_config')) { |
|
| 506 | + $this->_extend_page_config(); |
|
| 507 | + } |
|
| 508 | + //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
|
| 509 | + if (method_exists($this, '_extend_page_config_for_cpt')) { |
|
| 510 | + $this->_extend_page_config_for_cpt(); |
|
| 511 | + } |
|
| 512 | + //filter routes and page_config so addons can add their stuff. Filtering done per class |
|
| 513 | + $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
| 514 | + $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
| 515 | + //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
|
| 516 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
| 517 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
| 518 | + } |
|
| 519 | + //next route only if routing enabled |
|
| 520 | + if ($this->_routing && ! defined('DOING_AJAX')) { |
|
| 521 | + $this->_verify_routes(); |
|
| 522 | + //next let's just check user_access and kill if no access |
|
| 523 | + $this->check_user_access(); |
|
| 524 | + if ($this->_is_UI_request) { |
|
| 525 | + //admin_init stuff - global, all views for this page class, specific view |
|
| 526 | + add_action('admin_init', array($this, 'admin_init'), 10); |
|
| 527 | + if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
| 528 | + add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
| 529 | + } |
|
| 530 | + } else { |
|
| 531 | + //hijack regular WP loading and route admin request immediately |
|
| 532 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
| 533 | + $this->route_admin_request(); |
|
| 534 | + } |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * Provides a way for related child admin pages to load stuff on the loaded admin page. |
|
| 542 | + * |
|
| 543 | + * @access private |
|
| 544 | + * @return void |
|
| 545 | + */ |
|
| 546 | + private function _do_other_page_hooks() |
|
| 547 | + { |
|
| 548 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
| 549 | + foreach ($registered_pages as $page) { |
|
| 550 | + //now let's setup the file name and class that should be present |
|
| 551 | + $classname = str_replace('.class.php', '', $page); |
|
| 552 | + //autoloaders should take care of loading file |
|
| 553 | + if ( ! class_exists($classname)) { |
|
| 554 | + $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
| 555 | + $error_msg[] = $error_msg[0] |
|
| 556 | + . "\r\n" |
|
| 557 | + . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
| 558 | + 'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>'); |
|
| 559 | + throw new EE_Error(implode('||', $error_msg)); |
|
| 560 | + } |
|
| 561 | + $a = new ReflectionClass($classname); |
|
| 562 | + //notice we are passing the instance of this class to the hook object. |
|
| 563 | + $hookobj[] = $a->newInstance($this); |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + public function load_page_dependencies() |
|
| 570 | + { |
|
| 571 | + try { |
|
| 572 | + $this->_load_page_dependencies(); |
|
| 573 | + } catch (EE_Error $e) { |
|
| 574 | + $e->get_error(); |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + |
|
| 579 | + |
|
| 580 | + /** |
|
| 581 | + * load_page_dependencies |
|
| 582 | + * loads things specific to this page class when its loaded. Really helps with efficiency. |
|
| 583 | + * |
|
| 584 | + * @access public |
|
| 585 | + * @return void |
|
| 586 | + */ |
|
| 587 | + protected function _load_page_dependencies() |
|
| 588 | + { |
|
| 589 | + //let's set the current_screen and screen options to override what WP set |
|
| 590 | + $this->_current_screen = get_current_screen(); |
|
| 591 | + //load admin_notices - global, page class, and view specific |
|
| 592 | + add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
| 593 | + add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
| 594 | + if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
| 595 | + add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
| 596 | + } |
|
| 597 | + //load network admin_notices - global, page class, and view specific |
|
| 598 | + add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
| 599 | + if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
| 600 | + add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
| 601 | + } |
|
| 602 | + //this will save any per_page screen options if they are present |
|
| 603 | + $this->_set_per_page_screen_options(); |
|
| 604 | + //setup list table properties |
|
| 605 | + $this->_set_list_table(); |
|
| 606 | + // child classes can "register" a metabox to be automatically handled via the _page_config array property. However in some cases the metaboxes will need to be added within a route handling callback. |
|
| 607 | + $this->_add_registered_meta_boxes(); |
|
| 608 | + $this->_add_screen_columns(); |
|
| 609 | + //add screen options - global, page child class, and view specific |
|
| 610 | + $this->_add_global_screen_options(); |
|
| 611 | + $this->_add_screen_options(); |
|
| 612 | + if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
| 613 | + call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
| 614 | + } |
|
| 615 | + //add help tab(s) and tours- set via page_config and qtips. |
|
| 616 | + $this->_add_help_tour(); |
|
| 617 | + $this->_add_help_tabs(); |
|
| 618 | + $this->_add_qtips(); |
|
| 619 | + //add feature_pointers - global, page child class, and view specific |
|
| 620 | + $this->_add_feature_pointers(); |
|
| 621 | + $this->_add_global_feature_pointers(); |
|
| 622 | + if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
| 623 | + call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
| 624 | + } |
|
| 625 | + //enqueue scripts/styles - global, page class, and view specific |
|
| 626 | + add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
| 627 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
| 628 | + if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
| 629 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
| 630 | + } |
|
| 631 | + add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
| 632 | + //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
|
| 633 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
| 634 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
| 635 | + if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
| 636 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
| 637 | + } |
|
| 638 | + //admin footer scripts |
|
| 639 | + add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
| 640 | + add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
| 641 | + if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
| 642 | + add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
| 643 | + } |
|
| 644 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
| 645 | + //targeted hook |
|
| 646 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * _set_defaults |
|
| 653 | + * This sets some global defaults for class properties. |
|
| 654 | + */ |
|
| 655 | + private function _set_defaults() |
|
| 656 | + { |
|
| 657 | + $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null; |
|
| 658 | + $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
| 659 | + $this->default_nav_tab_name = 'overview'; |
|
| 660 | + //init template args |
|
| 661 | + $this->_template_args = array( |
|
| 662 | + 'admin_page_header' => '', |
|
| 663 | + 'admin_page_content' => '', |
|
| 664 | + 'post_body_content' => '', |
|
| 665 | + 'before_list_table' => '', |
|
| 666 | + 'after_list_table' => '', |
|
| 667 | + ); |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * route_admin_request |
|
| 674 | + * |
|
| 675 | + * @see _route_admin_request() |
|
| 676 | + * @access public |
|
| 677 | + * @return void|exception error |
|
| 678 | + */ |
|
| 679 | + public function route_admin_request() |
|
| 680 | + { |
|
| 681 | + try { |
|
| 682 | + $this->_route_admin_request(); |
|
| 683 | + } catch (EE_Error $e) { |
|
| 684 | + $e->get_error(); |
|
| 685 | + } |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + |
|
| 689 | + |
|
| 690 | + public function set_wp_page_slug($wp_page_slug) |
|
| 691 | + { |
|
| 692 | + $this->_wp_page_slug = $wp_page_slug; |
|
| 693 | + //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
|
| 694 | + if (is_network_admin()) { |
|
| 695 | + $this->_wp_page_slug .= '-network'; |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * _verify_routes |
|
| 703 | + * All this method does is verify the incoming request and make sure that routes exist for it. We do this early so we know if we need to drop out. |
|
| 704 | + * |
|
| 705 | + * @access protected |
|
| 706 | + * @return void |
|
| 707 | + */ |
|
| 708 | + protected function _verify_routes() |
|
| 709 | + { |
|
| 710 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 711 | + if ( ! $this->_current_page && ! defined('DOING_AJAX')) { |
|
| 712 | + return false; |
|
| 713 | + } |
|
| 714 | + $this->_route = false; |
|
| 715 | + $func = false; |
|
| 716 | + $args = array(); |
|
| 717 | + // check that the page_routes array is not empty |
|
| 718 | + if (empty($this->_page_routes)) { |
|
| 719 | + // user error msg |
|
| 720 | + $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 721 | + // developer error msg |
|
| 722 | + $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
| 723 | + throw new EE_Error($error_msg); |
|
| 724 | + } |
|
| 725 | + // and that the requested page route exists |
|
| 726 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 727 | + $this->_route = $this->_page_routes[$this->_req_action]; |
|
| 728 | + $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
|
| 729 | + } else { |
|
| 730 | + // user error msg |
|
| 731 | + $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 732 | + // developer error msg |
|
| 733 | + $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
| 734 | + throw new EE_Error($error_msg); |
|
| 735 | + } |
|
| 736 | + // and that a default route exists |
|
| 737 | + if ( ! array_key_exists('default', $this->_page_routes)) { |
|
| 738 | + // user error msg |
|
| 739 | + $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 740 | + // developer error msg |
|
| 741 | + $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
| 742 | + throw new EE_Error($error_msg); |
|
| 743 | + } |
|
| 744 | + //first lets' catch if the UI request has EVER been set. |
|
| 745 | + if ($this->_is_UI_request === null) { |
|
| 746 | + //lets set if this is a UI request or not. |
|
| 747 | + $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false; |
|
| 748 | + //wait a minute... we might have a noheader in the route array |
|
| 749 | + $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request; |
|
| 750 | + } |
|
| 751 | + $this->_set_current_labels(); |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * this method simply verifies a given route and makes sure its an actual route available for the loaded page |
|
| 758 | + * |
|
| 759 | + * @param string $route the route name we're verifying |
|
| 760 | + * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
| 761 | + */ |
|
| 762 | + protected function _verify_route($route) |
|
| 763 | + { |
|
| 764 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
| 765 | + return true; |
|
| 766 | + } else { |
|
| 767 | + // user error msg |
|
| 768 | + $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
| 769 | + // developer error msg |
|
| 770 | + $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
| 771 | + throw new EE_Error($error_msg); |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + |
|
| 776 | + |
|
| 777 | + /** |
|
| 778 | + * perform nonce verification |
|
| 779 | + * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!) |
|
| 780 | + * |
|
| 781 | + * @param string $nonce The nonce sent |
|
| 782 | + * @param string $nonce_ref The nonce reference string (name0) |
|
| 783 | + * @return mixed (bool|die) |
|
| 784 | + */ |
|
| 785 | + protected function _verify_nonce($nonce, $nonce_ref) |
|
| 786 | + { |
|
| 787 | + // verify nonce against expected value |
|
| 788 | + if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
| 789 | + // these are not the droids you are looking for !!! |
|
| 790 | + $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
| 791 | + if (WP_DEBUG) { |
|
| 792 | + $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
| 793 | + } |
|
| 794 | + if ( ! defined('DOING_AJAX')) { |
|
| 795 | + wp_die($msg); |
|
| 796 | + } else { |
|
| 797 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 798 | + $this->_return_json(); |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * _route_admin_request() |
|
| 807 | + * Meat and potatoes of the class. Basically, this dude checks out what's being requested and sees if theres are |
|
| 808 | + * some doodads to work the magic and handle the flingjangy. Translation: Checks if the requested action is listed |
|
| 809 | + * in the page routes and then will try to load the corresponding method. |
|
| 810 | + * |
|
| 811 | + * @access protected |
|
| 812 | + * @return void |
|
| 813 | + * @throws \EE_Error |
|
| 814 | + */ |
|
| 815 | + protected function _route_admin_request() |
|
| 816 | + { |
|
| 817 | + if ( ! $this->_is_UI_request) { |
|
| 818 | + $this->_verify_routes(); |
|
| 819 | + } |
|
| 820 | + $nonce_check = isset($this->_route_config['require_nonce']) |
|
| 821 | + ? $this->_route_config['require_nonce'] |
|
| 822 | + : true; |
|
| 823 | + if ($this->_req_action !== 'default' && $nonce_check) { |
|
| 824 | + // set nonce from post data |
|
| 825 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
| 826 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) |
|
| 827 | + : ''; |
|
| 828 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
| 829 | + } |
|
| 830 | + //set the nav_tabs array but ONLY if this is UI_request |
|
| 831 | + if ($this->_is_UI_request) { |
|
| 832 | + $this->_set_nav_tabs(); |
|
| 833 | + } |
|
| 834 | + // grab callback function |
|
| 835 | + $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
| 836 | + // check if callback has args |
|
| 837 | + $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
| 838 | + $error_msg = ''; |
|
| 839 | + // action right before calling route |
|
| 840 | + // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
|
| 841 | + if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
| 842 | + do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
| 843 | + } |
|
| 844 | + // right before calling the route, let's remove _wp_http_referer from the |
|
| 845 | + // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
|
| 846 | + $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
| 847 | + if ( ! empty($func)) { |
|
| 848 | + if (is_array($func)) { |
|
| 849 | + list($class, $method) = $func; |
|
| 850 | + } else if (strpos($func, '::') !== false) { |
|
| 851 | + list($class, $method) = explode('::', $func); |
|
| 852 | + } else { |
|
| 853 | + $class = $this; |
|
| 854 | + $method = $func; |
|
| 855 | + } |
|
| 856 | + if ( ! (is_object($class) && $class === $this)) { |
|
| 857 | + // send along this admin page object for access by addons. |
|
| 858 | + $args['admin_page_object'] = $this; |
|
| 859 | + } |
|
| 860 | + |
|
| 861 | + if ( |
|
| 862 | + //is it a method on a class that doesn't work? |
|
| 863 | + ( |
|
| 864 | + ( |
|
| 865 | + method_exists($class, $method) |
|
| 866 | + && call_user_func_array(array($class, $method), $args) === false |
|
| 867 | + ) |
|
| 868 | + && ( |
|
| 869 | + //is it a standalone function that doesn't work? |
|
| 870 | + function_exists($method) |
|
| 871 | + && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false |
|
| 872 | + ) |
|
| 873 | + ) |
|
| 874 | + || ( |
|
| 875 | + //is it neither a class method NOR a standalone function? |
|
| 876 | + ! method_exists($class, $method) |
|
| 877 | + && ! function_exists($method) |
|
| 878 | + ) |
|
| 879 | + ) { |
|
| 880 | + // user error msg |
|
| 881 | + $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
| 882 | + // developer error msg |
|
| 883 | + $error_msg .= '||'; |
|
| 884 | + $error_msg .= sprintf( |
|
| 885 | + __( |
|
| 886 | + 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', |
|
| 887 | + 'event_espresso' |
|
| 888 | + ), |
|
| 889 | + $method |
|
| 890 | + ); |
|
| 891 | + } |
|
| 892 | + if ( ! empty($error_msg)) { |
|
| 893 | + throw new EE_Error($error_msg); |
|
| 894 | + } |
|
| 895 | + } |
|
| 896 | + //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
|
| 897 | + //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
|
| 898 | + if ($this->_is_UI_request === false |
|
| 899 | + && is_array($this->_route) |
|
| 900 | + && ! empty($this->_route['headers_sent_route']) |
|
| 901 | + ) { |
|
| 902 | + $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
| 903 | + } |
|
| 904 | + } |
|
| 905 | + |
|
| 906 | + |
|
| 907 | + |
|
| 908 | + /** |
|
| 909 | + * This method just allows the resetting of page properties in the case where a no headers |
|
| 910 | + * route redirects to a headers route in its route config. |
|
| 911 | + * |
|
| 912 | + * @since 4.3.0 |
|
| 913 | + * @param string $new_route New (non header) route to redirect to. |
|
| 914 | + * @return void |
|
| 915 | + */ |
|
| 916 | + protected function _reset_routing_properties($new_route) |
|
| 917 | + { |
|
| 918 | + $this->_is_UI_request = true; |
|
| 919 | + //now we set the current route to whatever the headers_sent_route is set at |
|
| 920 | + $this->_req_data['action'] = $new_route; |
|
| 921 | + //rerun page setup |
|
| 922 | + $this->_page_setup(); |
|
| 923 | + } |
|
| 924 | + |
|
| 925 | + |
|
| 926 | + |
|
| 927 | + /** |
|
| 928 | + * _add_query_arg |
|
| 929 | + * adds nonce to array of arguments then calls WP add_query_arg function |
|
| 930 | + *(internally just uses EEH_URL's function with the same name) |
|
| 931 | + * |
|
| 932 | + * @access public |
|
| 933 | + * @param array $args |
|
| 934 | + * @param string $url |
|
| 935 | + * @param bool $sticky if true, then the existing Request params will be appended to the generated |
|
| 936 | + * url in an associative array indexed by the key 'wp_referer'; |
|
| 937 | + * Example usage: |
|
| 938 | + * If the current page is: |
|
| 939 | + * http://mydomain.com/wp-admin/admin.php?page=espresso_registrations |
|
| 940 | + * &action=default&event_id=20&month_range=March%202015 |
|
| 941 | + * &_wpnonce=5467821 |
|
| 942 | + * and you call: |
|
| 943 | + * EE_Admin_Page::add_query_args_and_nonce( |
|
| 944 | + * array( |
|
| 945 | + * 'action' => 'resend_something', |
|
| 946 | + * 'page=>espresso_registrations' |
|
| 947 | + * ), |
|
| 948 | + * $some_url, |
|
| 949 | + * true |
|
| 950 | + * ); |
|
| 951 | + * It will produce a url in this structure: |
|
| 952 | + * http://{$some_url}/?page=espresso_registrations&action=resend_something |
|
| 953 | + * &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[ |
|
| 954 | + * month_range]=March%202015 |
|
| 955 | + * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
|
| 956 | + * @return string |
|
| 957 | + */ |
|
| 958 | + public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) |
|
| 959 | + { |
|
| 960 | + //if there is a _wp_http_referer include the values from the request but only if sticky = true |
|
| 961 | + if ($sticky) { |
|
| 962 | + $request = $_REQUEST; |
|
| 963 | + unset($request['_wp_http_referer']); |
|
| 964 | + unset($request['wp_referer']); |
|
| 965 | + foreach ($request as $key => $value) { |
|
| 966 | + //do not add nonces |
|
| 967 | + if (strpos($key, 'nonce') !== false) { |
|
| 968 | + continue; |
|
| 969 | + } |
|
| 970 | + $args['wp_referer[' . $key . ']'] = $value; |
|
| 971 | + } |
|
| 972 | + } |
|
| 973 | + return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + |
|
| 977 | + |
|
| 978 | + /** |
|
| 979 | + * This returns a generated link that will load the related help tab. |
|
| 980 | + * |
|
| 981 | + * @param string $help_tab_id the id for the connected help tab |
|
| 982 | + * @param string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
| 983 | + * @param string $help_text (optional) send help text you want to use for the link if default not to be used |
|
| 984 | + * @uses EEH_Template::get_help_tab_link() |
|
| 985 | + * @return string generated link |
|
| 986 | + */ |
|
| 987 | + protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false) |
|
| 988 | + { |
|
| 989 | + return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
| 990 | + } |
|
| 991 | + |
|
| 992 | + |
|
| 993 | + |
|
| 994 | + /** |
|
| 995 | + * _add_help_tabs |
|
| 996 | + * Note child classes define their help tabs within the page_config array. |
|
| 997 | + * |
|
| 998 | + * @link http://codex.wordpress.org/Function_Reference/add_help_tab |
|
| 999 | + * @access protected |
|
| 1000 | + * @return void |
|
| 1001 | + */ |
|
| 1002 | + protected function _add_help_tabs() |
|
| 1003 | + { |
|
| 1004 | + $tour_buttons = ''; |
|
| 1005 | + if (isset($this->_page_config[$this->_req_action])) { |
|
| 1006 | + $config = $this->_page_config[$this->_req_action]; |
|
| 1007 | + //is there a help tour for the current route? if there is let's setup the tour buttons |
|
| 1008 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1009 | + $tb = array(); |
|
| 1010 | + $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
|
| 1011 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1012 | + //if this is the end tour then we don't need to setup a button |
|
| 1013 | + if ($tour instanceof EE_Help_Tour_final_stop) { |
|
| 1014 | + continue; |
|
| 1015 | + } |
|
| 1016 | + $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
| 1017 | + } |
|
| 1018 | + $tour_buttons .= implode('<br />', $tb); |
|
| 1019 | + $tour_buttons .= '</div></div>'; |
|
| 1020 | + } |
|
| 1021 | + // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
|
| 1022 | + if (is_array($config) && isset($config['help_sidebar'])) { |
|
| 1023 | + //check that the callback given is valid |
|
| 1024 | + if ( ! method_exists($this, $config['help_sidebar'])) { |
|
| 1025 | + throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
|
| 1026 | + 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
| 1027 | + } |
|
| 1028 | + $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
| 1029 | + $content .= $tour_buttons; //add help tour buttons. |
|
| 1030 | + //do we have any help tours setup? Cause if we do we want to add the buttons |
|
| 1031 | + $this->_current_screen->set_help_sidebar($content); |
|
| 1032 | + } |
|
| 1033 | + //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
|
| 1034 | + if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
| 1035 | + $this->_current_screen->set_help_sidebar($tour_buttons); |
|
| 1036 | + } |
|
| 1037 | + //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
|
| 1038 | + if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
| 1039 | + $_ht['id'] = $this->page_slug; |
|
| 1040 | + $_ht['title'] = __('Help Tours', 'event_espresso'); |
|
| 1041 | + $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
| 1042 | + $this->_current_screen->add_help_tab($_ht); |
|
| 1043 | + }/**/ |
|
| 1044 | + if ( ! isset($config['help_tabs'])) { |
|
| 1045 | + return; |
|
| 1046 | + } //no help tabs for this route |
|
| 1047 | + foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
| 1048 | + //we're here so there ARE help tabs! |
|
| 1049 | + //make sure we've got what we need |
|
| 1050 | + if ( ! isset($cfg['title'])) { |
|
| 1051 | + throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
| 1052 | + } |
|
| 1053 | + if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) { |
|
| 1054 | + throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', |
|
| 1055 | + 'event_espresso')); |
|
| 1056 | + } |
|
| 1057 | + //first priority goes to content. |
|
| 1058 | + if ( ! empty($cfg['content'])) { |
|
| 1059 | + $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
|
| 1060 | + //second priority goes to filename |
|
| 1061 | + } else if ( ! empty($cfg['filename'])) { |
|
| 1062 | + $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
| 1063 | + //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
|
| 1064 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
| 1065 | + //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
| 1066 | + if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
| 1067 | + EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
|
| 1068 | + 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
| 1069 | + return; |
|
| 1070 | + } |
|
| 1071 | + $template_args['admin_page_obj'] = $this; |
|
| 1072 | + $content = EEH_Template::display_template($file_path, $template_args, true); |
|
| 1073 | + } else { |
|
| 1074 | + $content = ''; |
|
| 1075 | + } |
|
| 1076 | + //check if callback is valid |
|
| 1077 | + if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
| 1078 | + EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', |
|
| 1079 | + 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
| 1080 | + return; |
|
| 1081 | + } |
|
| 1082 | + //setup config array for help tab method |
|
| 1083 | + $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
| 1084 | + $_ht = array( |
|
| 1085 | + 'id' => $id, |
|
| 1086 | + 'title' => $cfg['title'], |
|
| 1087 | + 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null, |
|
| 1088 | + 'content' => $content, |
|
| 1089 | + ); |
|
| 1090 | + $this->_current_screen->add_help_tab($_ht); |
|
| 1091 | + } |
|
| 1092 | + } |
|
| 1093 | + } |
|
| 1094 | + |
|
| 1095 | + |
|
| 1096 | + |
|
| 1097 | + /** |
|
| 1098 | + * This basically checks loaded $_page_config property to see if there are any help_tours defined. "help_tours" is an array with properties for setting up usage of the joyride plugin |
|
| 1099 | + * |
|
| 1100 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
| 1101 | + * @see instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments |
|
| 1102 | + * @access protected |
|
| 1103 | + * @return void |
|
| 1104 | + */ |
|
| 1105 | + protected function _add_help_tour() |
|
| 1106 | + { |
|
| 1107 | + $tours = array(); |
|
| 1108 | + $this->_help_tour = array(); |
|
| 1109 | + //exit early if help tours are turned off globally |
|
| 1110 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) { |
|
| 1111 | + return; |
|
| 1112 | + } |
|
| 1113 | + //loop through _page_config to find any help_tour defined |
|
| 1114 | + foreach ($this->_page_config as $route => $config) { |
|
| 1115 | + //we're only going to set things up for this route |
|
| 1116 | + if ($route !== $this->_req_action) { |
|
| 1117 | + continue; |
|
| 1118 | + } |
|
| 1119 | + if (isset($config['help_tour'])) { |
|
| 1120 | + foreach ($config['help_tour'] as $tour) { |
|
| 1121 | + $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
| 1122 | + //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
|
| 1123 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
| 1124 | + //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
| 1125 | + if ( ! is_readable($file_path)) { |
|
| 1126 | + EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
|
| 1127 | + $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
| 1128 | + return; |
|
| 1129 | + } |
|
| 1130 | + require_once $file_path; |
|
| 1131 | + if ( ! class_exists($tour)) { |
|
| 1132 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
| 1133 | + $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
| 1134 | + 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
| 1135 | + throw new EE_Error(implode('||', $error_msg)); |
|
| 1136 | + } |
|
| 1137 | + $a = new ReflectionClass($tour); |
|
| 1138 | + $tour_obj = $a->newInstance($this->_is_caf); |
|
| 1139 | + $tours[] = $tour_obj; |
|
| 1140 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
| 1141 | + } |
|
| 1142 | + //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
|
| 1143 | + $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
|
| 1144 | + $tours[] = $end_stop_tour; |
|
| 1145 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
| 1146 | + } |
|
| 1147 | + } |
|
| 1148 | + if ( ! empty($tours)) { |
|
| 1149 | + $this->_help_tour['tours'] = $tours; |
|
| 1150 | + } |
|
| 1151 | + //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
|
| 1152 | + } |
|
| 1153 | + |
|
| 1154 | + |
|
| 1155 | + |
|
| 1156 | + /** |
|
| 1157 | + * This simply sets up any qtips that have been defined in the page config |
|
| 1158 | + * |
|
| 1159 | + * @access protected |
|
| 1160 | + * @return void |
|
| 1161 | + */ |
|
| 1162 | + protected function _add_qtips() |
|
| 1163 | + { |
|
| 1164 | + if (isset($this->_route_config['qtips'])) { |
|
| 1165 | + $qtips = (array)$this->_route_config['qtips']; |
|
| 1166 | + //load qtip loader |
|
| 1167 | + $path = array( |
|
| 1168 | + $this->_get_dir() . '/qtips/', |
|
| 1169 | + EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
| 1170 | + ); |
|
| 1171 | + EEH_Qtip_Loader::instance()->register($qtips, $path); |
|
| 1172 | + } |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + |
|
| 1176 | + |
|
| 1177 | + /** |
|
| 1178 | + * _set_nav_tabs |
|
| 1179 | + * This sets up the nav tabs from the page_routes array. This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly. |
|
| 1180 | + * |
|
| 1181 | + * @access protected |
|
| 1182 | + * @return void |
|
| 1183 | + */ |
|
| 1184 | + protected function _set_nav_tabs() |
|
| 1185 | + { |
|
| 1186 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1187 | + $i = 0; |
|
| 1188 | + foreach ($this->_page_config as $slug => $config) { |
|
| 1189 | + if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) { |
|
| 1190 | + continue; |
|
| 1191 | + } //no nav tab for this config |
|
| 1192 | + //check for persistent flag |
|
| 1193 | + if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) { |
|
| 1194 | + continue; |
|
| 1195 | + } //nav tab is only to appear when route requested. |
|
| 1196 | + if ( ! $this->check_user_access($slug, true)) { |
|
| 1197 | + continue; |
|
| 1198 | + } //no nav tab becasue current user does not have access. |
|
| 1199 | + $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
| 1200 | + $this->_nav_tabs[$slug] = array( |
|
| 1201 | + 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
|
| 1202 | + 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
| 1203 | + 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
| 1204 | + 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
|
| 1205 | + ); |
|
| 1206 | + $i++; |
|
| 1207 | + } |
|
| 1208 | + //if $this->_nav_tabs is empty then lets set the default |
|
| 1209 | + if (empty($this->_nav_tabs)) { |
|
| 1210 | + $this->_nav_tabs[$this->default_nav_tab_name] = array( |
|
| 1211 | + 'url' => $this->admin_base_url, |
|
| 1212 | + 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
| 1213 | + 'css_class' => 'nav-tab-active', |
|
| 1214 | + 'order' => 10, |
|
| 1215 | + ); |
|
| 1216 | + } |
|
| 1217 | + //now let's sort the tabs according to order |
|
| 1218 | + usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + |
|
| 1222 | + |
|
| 1223 | + /** |
|
| 1224 | + * _set_current_labels |
|
| 1225 | + * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array |
|
| 1226 | + * |
|
| 1227 | + * @access private |
|
| 1228 | + * @return void |
|
| 1229 | + */ |
|
| 1230 | + private function _set_current_labels() |
|
| 1231 | + { |
|
| 1232 | + if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
| 1233 | + foreach ($this->_route_config['labels'] as $label => $text) { |
|
| 1234 | + if (is_array($text)) { |
|
| 1235 | + foreach ($text as $sublabel => $subtext) { |
|
| 1236 | + $this->_labels[$label][$sublabel] = $subtext; |
|
| 1237 | + } |
|
| 1238 | + } else { |
|
| 1239 | + $this->_labels[$label] = $text; |
|
| 1240 | + } |
|
| 1241 | + } |
|
| 1242 | + } |
|
| 1243 | + } |
|
| 1244 | + |
|
| 1245 | + |
|
| 1246 | + |
|
| 1247 | + /** |
|
| 1248 | + * verifies user access for this admin page |
|
| 1249 | + * |
|
| 1250 | + * @param string $route_to_check if present then the capability for the route matching this string is checked. |
|
| 1251 | + * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
|
| 1252 | + * @return BOOL|wp_die() |
|
| 1253 | + */ |
|
| 1254 | + public function check_user_access($route_to_check = '', $verify_only = false) |
|
| 1255 | + { |
|
| 1256 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1257 | + $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
| 1258 | + $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) |
|
| 1259 | + ? $this->_page_routes[$route_to_check]['capability'] : null; |
|
| 1260 | + if (empty($capability) && empty($route_to_check)) { |
|
| 1261 | + $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
| 1262 | + } else { |
|
| 1263 | + $capability = empty($capability) ? 'manage_options' : $capability; |
|
| 1264 | + } |
|
| 1265 | + $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
| 1266 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
| 1267 | + if ($verify_only) { |
|
| 1268 | + return false; |
|
| 1269 | + } else { |
|
| 1270 | + if ( is_user_logged_in() ) { |
|
| 1271 | + wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
| 1272 | + } else { |
|
| 1273 | + return false; |
|
| 1274 | + } |
|
| 1275 | + } |
|
| 1276 | + } |
|
| 1277 | + return true; |
|
| 1278 | + } |
|
| 1279 | + |
|
| 1280 | + |
|
| 1281 | + |
|
| 1282 | + /** |
|
| 1283 | + * admin_init_global |
|
| 1284 | + * This runs all the code that we want executed within the WP admin_init hook. |
|
| 1285 | + * This method executes for ALL EE Admin pages. |
|
| 1286 | + * |
|
| 1287 | + * @access public |
|
| 1288 | + * @return void |
|
| 1289 | + */ |
|
| 1290 | + public function admin_init_global() |
|
| 1291 | + { |
|
| 1292 | + } |
|
| 1293 | + |
|
| 1294 | + |
|
| 1295 | + |
|
| 1296 | + /** |
|
| 1297 | + * wp_loaded_global |
|
| 1298 | + * This runs all the code that we want executed within the WP wp_loaded hook. This method is optional for an EE_Admin page and will execute on every EE Admin Page load |
|
| 1299 | + * |
|
| 1300 | + * @access public |
|
| 1301 | + * @return void |
|
| 1302 | + */ |
|
| 1303 | + public function wp_loaded() |
|
| 1304 | + { |
|
| 1305 | + } |
|
| 1306 | + |
|
| 1307 | + |
|
| 1308 | + |
|
| 1309 | + /** |
|
| 1310 | + * admin_notices |
|
| 1311 | + * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
| 1312 | + * |
|
| 1313 | + * @access public |
|
| 1314 | + * @return void |
|
| 1315 | + */ |
|
| 1316 | + public function admin_notices_global() |
|
| 1317 | + { |
|
| 1318 | + $this->_display_no_javascript_warning(); |
|
| 1319 | + $this->_display_espresso_notices(); |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + |
|
| 1323 | + |
|
| 1324 | + public function network_admin_notices_global() |
|
| 1325 | + { |
|
| 1326 | + $this->_display_no_javascript_warning(); |
|
| 1327 | + $this->_display_espresso_notices(); |
|
| 1328 | + } |
|
| 1329 | + |
|
| 1330 | + |
|
| 1331 | + |
|
| 1332 | + /** |
|
| 1333 | + * admin_footer_scripts_global |
|
| 1334 | + * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
| 1335 | + * |
|
| 1336 | + * @access public |
|
| 1337 | + * @return void |
|
| 1338 | + */ |
|
| 1339 | + public function admin_footer_scripts_global() |
|
| 1340 | + { |
|
| 1341 | + $this->_add_admin_page_ajax_loading_img(); |
|
| 1342 | + $this->_add_admin_page_overlay(); |
|
| 1343 | + //if metaboxes are present we need to add the nonce field |
|
| 1344 | + if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
| 1345 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
| 1346 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
| 1347 | + } |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + |
|
| 1351 | + |
|
| 1352 | + /** |
|
| 1353 | + * admin_footer_global |
|
| 1354 | + * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages. |
|
| 1355 | + * |
|
| 1356 | + * @access public |
|
| 1357 | + * @return void |
|
| 1358 | + */ |
|
| 1359 | + public function admin_footer_global() |
|
| 1360 | + { |
|
| 1361 | + //dialog container for dialog helper |
|
| 1362 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
| 1363 | + $d_cont .= '<div class="ee-notices"></div>'; |
|
| 1364 | + $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
|
| 1365 | + $d_cont .= '</div>'; |
|
| 1366 | + echo $d_cont; |
|
| 1367 | + //help tour stuff? |
|
| 1368 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
| 1369 | + echo implode('<br />', $this->_help_tour[$this->_req_action]); |
|
| 1370 | + } |
|
| 1371 | + //current set timezone for timezone js |
|
| 1372 | + echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
| 1373 | + } |
|
| 1374 | + |
|
| 1375 | + |
|
| 1376 | + |
|
| 1377 | + /** |
|
| 1378 | + * This function sees if there is a method for help popup content existing for the given route. If there is then we'll use the retrieved array to output the content using the template. |
|
| 1379 | + * For child classes: |
|
| 1380 | + * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for |
|
| 1381 | + * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()" So if you are setting help content for the |
|
| 1382 | + * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method. You must prepare and return an array in the following format array( |
|
| 1383 | + * 'help_trigger_id' => array( |
|
| 1384 | + * 'title' => __('localized title for popup', 'event_espresso'), |
|
| 1385 | + * 'content' => __('localized content for popup', 'event_espresso') |
|
| 1386 | + * ) |
|
| 1387 | + * ); |
|
| 1388 | + * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route. |
|
| 1389 | + * |
|
| 1390 | + * @access protected |
|
| 1391 | + * @return string content |
|
| 1392 | + */ |
|
| 1393 | + protected function _set_help_popup_content($help_array = array(), $display = false) |
|
| 1394 | + { |
|
| 1395 | + $content = ''; |
|
| 1396 | + $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
| 1397 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
| 1398 | + //loop through the array and setup content |
|
| 1399 | + foreach ($help_array as $trigger => $help) { |
|
| 1400 | + //make sure the array is setup properly |
|
| 1401 | + if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
| 1402 | + throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', |
|
| 1403 | + 'event_espresso')); |
|
| 1404 | + } |
|
| 1405 | + //we're good so let'd setup the template vars and then assign parsed template content to our content. |
|
| 1406 | + $template_args = array( |
|
| 1407 | + 'help_popup_id' => $trigger, |
|
| 1408 | + 'help_popup_title' => $help['title'], |
|
| 1409 | + 'help_popup_content' => $help['content'], |
|
| 1410 | + ); |
|
| 1411 | + $content .= EEH_Template::display_template($template_path, $template_args, true); |
|
| 1412 | + } |
|
| 1413 | + if ($display) { |
|
| 1414 | + echo $content; |
|
| 1415 | + } else { |
|
| 1416 | + return $content; |
|
| 1417 | + } |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + |
|
| 1421 | + |
|
| 1422 | + /** |
|
| 1423 | + * All this does is retrive the help content array if set by the EE_Admin_Page child |
|
| 1424 | + * |
|
| 1425 | + * @access private |
|
| 1426 | + * @return array properly formatted array for help popup content |
|
| 1427 | + */ |
|
| 1428 | + private function _get_help_content() |
|
| 1429 | + { |
|
| 1430 | + //what is the method we're looking for? |
|
| 1431 | + $method_name = '_help_popup_content_' . $this->_req_action; |
|
| 1432 | + //if method doesn't exist let's get out. |
|
| 1433 | + if ( ! method_exists($this, $method_name)) { |
|
| 1434 | + return array(); |
|
| 1435 | + } |
|
| 1436 | + //k we're good to go let's retrieve the help array |
|
| 1437 | + $help_array = call_user_func(array($this, $method_name)); |
|
| 1438 | + //make sure we've got an array! |
|
| 1439 | + if ( ! is_array($help_array)) { |
|
| 1440 | + throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
| 1441 | + } |
|
| 1442 | + return $help_array; |
|
| 1443 | + } |
|
| 1444 | + |
|
| 1445 | + |
|
| 1446 | + |
|
| 1447 | + /** |
|
| 1448 | + * EE Admin Pages can use this to set a properly formatted trigger for a help popup. |
|
| 1449 | + * By default the trigger html is printed. Otherwise it can be returned if the $display flag is set "false" |
|
| 1450 | + * See comments made on the _set_help_content method for understanding other parts to the help popup tool. |
|
| 1451 | + * |
|
| 1452 | + * @access protected |
|
| 1453 | + * @param string $trigger_id reference for retrieving the trigger content for the popup |
|
| 1454 | + * @param boolean $display if false then we return the trigger string |
|
| 1455 | + * @param array $dimensions an array of dimensions for the box (array(h,w)) |
|
| 1456 | + * @return string |
|
| 1457 | + */ |
|
| 1458 | + protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640')) |
|
| 1459 | + { |
|
| 1460 | + if (defined('DOING_AJAX')) { |
|
| 1461 | + return; |
|
| 1462 | + } |
|
| 1463 | + //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
|
| 1464 | + $help_array = $this->_get_help_content(); |
|
| 1465 | + $help_content = ''; |
|
| 1466 | + if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
| 1467 | + $help_array[$trigger_id] = array( |
|
| 1468 | + 'title' => __('Missing Content', 'event_espresso'), |
|
| 1469 | + 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', |
|
| 1470 | + 'event_espresso'), |
|
| 1471 | + ); |
|
| 1472 | + $help_content = $this->_set_help_popup_content($help_array, false); |
|
| 1473 | + } |
|
| 1474 | + //let's setup the trigger |
|
| 1475 | + $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1476 | + $content = $content . $help_content; |
|
| 1477 | + if ($display) { |
|
| 1478 | + echo $content; |
|
| 1479 | + } else { |
|
| 1480 | + return $content; |
|
| 1481 | + } |
|
| 1482 | + } |
|
| 1483 | + |
|
| 1484 | + |
|
| 1485 | + |
|
| 1486 | + /** |
|
| 1487 | + * _add_global_screen_options |
|
| 1488 | + * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
| 1489 | + * This particular method will add_screen_options on ALL EE_Admin Pages |
|
| 1490 | + * |
|
| 1491 | + * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
| 1492 | + * see also WP_Screen object documents... |
|
| 1493 | + * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
| 1494 | + * @abstract |
|
| 1495 | + * @access private |
|
| 1496 | + * @return void |
|
| 1497 | + */ |
|
| 1498 | + private function _add_global_screen_options() |
|
| 1499 | + { |
|
| 1500 | + } |
|
| 1501 | + |
|
| 1502 | + |
|
| 1503 | + |
|
| 1504 | + /** |
|
| 1505 | + * _add_global_feature_pointers |
|
| 1506 | + * This method is used for implementing any "feature pointers" (using built-in WP styling js). |
|
| 1507 | + * This particular method will implement feature pointers for ALL EE_Admin pages. |
|
| 1508 | + * Note: this is just a placeholder for now. Implementation will come down the road |
|
| 1509 | + * |
|
| 1510 | + * @see WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
| 1511 | + * @link http://eamann.com/tech/wordpress-portland/ |
|
| 1512 | + * @abstract |
|
| 1513 | + * @access protected |
|
| 1514 | + * @return void |
|
| 1515 | + */ |
|
| 1516 | + private function _add_global_feature_pointers() |
|
| 1517 | + { |
|
| 1518 | + } |
|
| 1519 | + |
|
| 1520 | + |
|
| 1521 | + |
|
| 1522 | + /** |
|
| 1523 | + * load_global_scripts_styles |
|
| 1524 | + * The scripts and styles enqueued in here will be loaded on every EE Admin page |
|
| 1525 | + * |
|
| 1526 | + * @return void |
|
| 1527 | + */ |
|
| 1528 | + public function load_global_scripts_styles() |
|
| 1529 | + { |
|
| 1530 | + /** STYLES **/ |
|
| 1531 | + // add debugging styles |
|
| 1532 | + if (WP_DEBUG) { |
|
| 1533 | + add_action('admin_head', array($this, 'add_xdebug_style')); |
|
| 1534 | + } |
|
| 1535 | + //register all styles |
|
| 1536 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1537 | + wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1538 | + //helpers styles |
|
| 1539 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1540 | + //enqueue global styles |
|
| 1541 | + wp_enqueue_style('ee-admin-css'); |
|
| 1542 | + /** SCRIPTS **/ |
|
| 1543 | + //register all scripts |
|
| 1544 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1545 | + wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1546 | + wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
| 1547 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
| 1548 | + // register jQuery Validate - see /includes/functions/wp_hooks.php |
|
| 1549 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 1550 | + add_filter('FHEE_load_joyride', '__return_true'); |
|
| 1551 | + //script for sorting tables |
|
| 1552 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1553 | + //script for parsing uri's |
|
| 1554 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1555 | + //and parsing associative serialized form elements |
|
| 1556 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1557 | + //helpers scripts |
|
| 1558 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1559 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1560 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
| 1561 | + wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
| 1562 | + //google charts |
|
| 1563 | + wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
| 1564 | + //enqueue global scripts |
|
| 1565 | + //taking care of metaboxes |
|
| 1566 | + if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
| 1567 | + wp_enqueue_script('dashboard'); |
|
| 1568 | + } |
|
| 1569 | + //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
|
| 1570 | + if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
| 1571 | + wp_enqueue_script('ee_admin_js'); |
|
| 1572 | + wp_enqueue_style('ee-admin-css'); |
|
| 1573 | + } |
|
| 1574 | + //localize script for ajax lazy loading |
|
| 1575 | + $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
| 1576 | + wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
| 1577 | + /** |
|
| 1578 | + * help tour stuff |
|
| 1579 | + */ |
|
| 1580 | + if ( ! empty($this->_help_tour)) { |
|
| 1581 | + //register the js for kicking things off |
|
| 1582 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
| 1583 | + //setup tours for the js tour object |
|
| 1584 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
| 1585 | + $tours[] = array( |
|
| 1586 | + 'id' => $tour->get_slug(), |
|
| 1587 | + 'options' => $tour->get_options(), |
|
| 1588 | + ); |
|
| 1589 | + } |
|
| 1590 | + wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
| 1591 | + //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
|
| 1592 | + } |
|
| 1593 | + } |
|
| 1594 | + |
|
| 1595 | + |
|
| 1596 | + |
|
| 1597 | + /** |
|
| 1598 | + * admin_footer_scripts_eei18n_js_strings |
|
| 1599 | + * |
|
| 1600 | + * @access public |
|
| 1601 | + * @return void |
|
| 1602 | + */ |
|
| 1603 | + public function admin_footer_scripts_eei18n_js_strings() |
|
| 1604 | + { |
|
| 1605 | + EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
|
| 1606 | + EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
| 1607 | + EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
| 1608 | + EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
| 1609 | + EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
| 1610 | + EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
| 1611 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1612 | + EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
| 1613 | + EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
| 1614 | + EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
| 1615 | + EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
| 1616 | + EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
| 1617 | + EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
| 1618 | + EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
| 1619 | + EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
| 1620 | + EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
| 1621 | + EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
| 1622 | + EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
| 1623 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
| 1624 | + EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
| 1625 | + EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
| 1626 | + EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
| 1627 | + EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
| 1628 | + EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
| 1629 | + EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
| 1630 | + EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
| 1631 | + EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
| 1632 | + EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
| 1633 | + EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
| 1634 | + EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
| 1635 | + EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
| 1636 | + EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
| 1637 | + EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
| 1638 | + EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
| 1639 | + EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
| 1640 | + EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
| 1641 | + EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
| 1642 | + EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
| 1643 | + EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
| 1644 | + EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
| 1645 | + //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
|
| 1646 | + //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
|
| 1647 | + //espresso_core is listed as a dependency of ee_admin_js. |
|
| 1648 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
| 1649 | + } |
|
| 1650 | + |
|
| 1651 | + |
|
| 1652 | + |
|
| 1653 | + /** |
|
| 1654 | + * load enhanced xdebug styles for ppl with failing eyesight |
|
| 1655 | + * |
|
| 1656 | + * @access public |
|
| 1657 | + * @return void |
|
| 1658 | + */ |
|
| 1659 | + public function add_xdebug_style() |
|
| 1660 | + { |
|
| 1661 | + echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
|
| 1662 | + } |
|
| 1663 | + |
|
| 1664 | + |
|
| 1665 | + /************************/ |
|
| 1666 | + /** LIST TABLE METHODS **/ |
|
| 1667 | + /************************/ |
|
| 1668 | + /** |
|
| 1669 | + * this sets up the list table if the current view requires it. |
|
| 1670 | + * |
|
| 1671 | + * @access protected |
|
| 1672 | + * @return void |
|
| 1673 | + */ |
|
| 1674 | + protected function _set_list_table() |
|
| 1675 | + { |
|
| 1676 | + //first is this a list_table view? |
|
| 1677 | + if ( ! isset($this->_route_config['list_table'])) { |
|
| 1678 | + return; |
|
| 1679 | + } //not a list_table view so get out. |
|
| 1680 | + //list table functions are per view specific (because some admin pages might have more than one listtable!) |
|
| 1681 | + if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
| 1682 | + //user error msg |
|
| 1683 | + $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
| 1684 | + //developer error msg |
|
| 1685 | + $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
| 1686 | + $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
| 1687 | + throw new EE_Error($error_msg); |
|
| 1688 | + } |
|
| 1689 | + //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
|
| 1690 | + $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
| 1691 | + $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
| 1692 | + $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
| 1693 | + $this->_set_list_table_view(); |
|
| 1694 | + $this->_set_list_table_object(); |
|
| 1695 | + } |
|
| 1696 | + |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + /** |
|
| 1700 | + * set current view for List Table |
|
| 1701 | + * |
|
| 1702 | + * @access public |
|
| 1703 | + * @return array |
|
| 1704 | + */ |
|
| 1705 | + protected function _set_list_table_view() |
|
| 1706 | + { |
|
| 1707 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1708 | + // looking at active items or dumpster diving ? |
|
| 1709 | + if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
| 1710 | + $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
| 1711 | + } else { |
|
| 1712 | + $this->_view = sanitize_key($this->_req_data['status']); |
|
| 1713 | + } |
|
| 1714 | + } |
|
| 1715 | + |
|
| 1716 | + |
|
| 1717 | + |
|
| 1718 | + /** |
|
| 1719 | + * _set_list_table_object |
|
| 1720 | + * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of. |
|
| 1721 | + * |
|
| 1722 | + * @throws \EE_Error |
|
| 1723 | + */ |
|
| 1724 | + protected function _set_list_table_object() |
|
| 1725 | + { |
|
| 1726 | + if (isset($this->_route_config['list_table'])) { |
|
| 1727 | + if ( ! class_exists($this->_route_config['list_table'])) { |
|
| 1728 | + throw new EE_Error( |
|
| 1729 | + sprintf( |
|
| 1730 | + __( |
|
| 1731 | + 'The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', |
|
| 1732 | + 'event_espresso' |
|
| 1733 | + ), |
|
| 1734 | + $this->_route_config['list_table'], |
|
| 1735 | + get_class($this) |
|
| 1736 | + ) |
|
| 1737 | + ); |
|
| 1738 | + } |
|
| 1739 | + $list_table = $this->_route_config['list_table']; |
|
| 1740 | + $this->_list_table_object = new $list_table($this); |
|
| 1741 | + } |
|
| 1742 | + } |
|
| 1743 | + |
|
| 1744 | + |
|
| 1745 | + |
|
| 1746 | + /** |
|
| 1747 | + * get_list_table_view_RLs - get it? View RL ?? VU-RL??? URL ?? |
|
| 1748 | + * |
|
| 1749 | + * @param array $extra_query_args Optional. An array of extra query args to add to the generated |
|
| 1750 | + * urls. The array should be indexed by the view it is being |
|
| 1751 | + * added to. |
|
| 1752 | + * @return array |
|
| 1753 | + */ |
|
| 1754 | + public function get_list_table_view_RLs($extra_query_args = array()) |
|
| 1755 | + { |
|
| 1756 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1757 | + if (empty($this->_views)) { |
|
| 1758 | + $this->_views = array(); |
|
| 1759 | + } |
|
| 1760 | + // cycle thru views |
|
| 1761 | + foreach ($this->_views as $key => $view) { |
|
| 1762 | + $query_args = array(); |
|
| 1763 | + // check for current view |
|
| 1764 | + $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
| 1765 | + $query_args['action'] = $this->_req_action; |
|
| 1766 | + $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 1767 | + $query_args['status'] = $view['slug']; |
|
| 1768 | + //merge any other arguments sent in. |
|
| 1769 | + if (isset($extra_query_args[$view['slug']])) { |
|
| 1770 | + $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
| 1771 | + } |
|
| 1772 | + $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
| 1773 | + } |
|
| 1774 | + return $this->_views; |
|
| 1775 | + } |
|
| 1776 | + |
|
| 1777 | + |
|
| 1778 | + |
|
| 1779 | + /** |
|
| 1780 | + * _entries_per_page_dropdown |
|
| 1781 | + * generates a drop down box for selecting the number of visiable rows in an admin page list table |
|
| 1782 | + * |
|
| 1783 | + * @todo : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it. |
|
| 1784 | + * @access protected |
|
| 1785 | + * @param int $max_entries total number of rows in the table |
|
| 1786 | + * @return string |
|
| 1787 | + */ |
|
| 1788 | + protected function _entries_per_page_dropdown($max_entries = false) |
|
| 1789 | + { |
|
| 1790 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1791 | + $values = array(10, 25, 50, 100); |
|
| 1792 | + $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
| 1793 | + if ($max_entries) { |
|
| 1794 | + $values[] = $max_entries; |
|
| 1795 | + sort($values); |
|
| 1796 | + } |
|
| 1797 | + $entries_per_page_dropdown = ' |
|
| 1798 | 1798 | <div id="entries-per-page-dv" class="alignleft actions"> |
| 1799 | 1799 | <label class="hide-if-no-js"> |
| 1800 | 1800 | Show |
| 1801 | 1801 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
| 1802 | - foreach ($values as $value) { |
|
| 1803 | - if ($value < $max_entries) { |
|
| 1804 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1805 | - $entries_per_page_dropdown .= ' |
|
| 1802 | + foreach ($values as $value) { |
|
| 1803 | + if ($value < $max_entries) { |
|
| 1804 | + $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1805 | + $entries_per_page_dropdown .= ' |
|
| 1806 | 1806 | <option value="' . $value . '"' . $selected . '>' . $value . ' </option>'; |
| 1807 | - } |
|
| 1808 | - } |
|
| 1809 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1810 | - $entries_per_page_dropdown .= ' |
|
| 1807 | + } |
|
| 1808 | + } |
|
| 1809 | + $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1810 | + $entries_per_page_dropdown .= ' |
|
| 1811 | 1811 | <option value="' . $max_entries . '"' . $selected . '>All </option>'; |
| 1812 | - $entries_per_page_dropdown .= ' |
|
| 1812 | + $entries_per_page_dropdown .= ' |
|
| 1813 | 1813 | </select> |
| 1814 | 1814 | entries |
| 1815 | 1815 | </label> |
| 1816 | 1816 | <input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" > |
| 1817 | 1817 | </div> |
| 1818 | 1818 | '; |
| 1819 | - return $entries_per_page_dropdown; |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - |
|
| 1823 | - |
|
| 1824 | - /** |
|
| 1825 | - * _set_search_attributes |
|
| 1826 | - * |
|
| 1827 | - * @access protected |
|
| 1828 | - * @return void |
|
| 1829 | - */ |
|
| 1830 | - public function _set_search_attributes() |
|
| 1831 | - { |
|
| 1832 | - $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
| 1833 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
| 1834 | - } |
|
| 1835 | - |
|
| 1836 | - /*** END LIST TABLE METHODS **/ |
|
| 1837 | - /*****************************/ |
|
| 1838 | - /** |
|
| 1839 | - * _add_registered_metaboxes |
|
| 1840 | - * this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array. |
|
| 1841 | - * |
|
| 1842 | - * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
|
| 1843 | - * @access private |
|
| 1844 | - * @return void |
|
| 1845 | - */ |
|
| 1846 | - private function _add_registered_meta_boxes() |
|
| 1847 | - { |
|
| 1848 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1849 | - //we only add meta boxes if the page_route calls for it |
|
| 1850 | - if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
| 1851 | - && is_array( |
|
| 1852 | - $this->_route_config['metaboxes'] |
|
| 1853 | - ) |
|
| 1854 | - ) { |
|
| 1855 | - // this simply loops through the callbacks provided |
|
| 1856 | - // and checks if there is a corresponding callback registered by the child |
|
| 1857 | - // if there is then we go ahead and process the metabox loader. |
|
| 1858 | - foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
| 1859 | - // first check for Closures |
|
| 1860 | - if ($metabox_callback instanceof Closure) { |
|
| 1861 | - $result = $metabox_callback(); |
|
| 1862 | - } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
| 1863 | - $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
| 1864 | - } else { |
|
| 1865 | - $result = call_user_func(array($this, &$metabox_callback)); |
|
| 1866 | - } |
|
| 1867 | - if ($result === false) { |
|
| 1868 | - // user error msg |
|
| 1869 | - $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
| 1870 | - // developer error msg |
|
| 1871 | - $error_msg .= '||' . sprintf( |
|
| 1872 | - __( |
|
| 1873 | - 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
|
| 1874 | - 'event_espresso' |
|
| 1875 | - ), |
|
| 1876 | - $metabox_callback |
|
| 1877 | - ); |
|
| 1878 | - throw new EE_Error($error_msg); |
|
| 1879 | - } |
|
| 1880 | - } |
|
| 1881 | - } |
|
| 1882 | - } |
|
| 1883 | - |
|
| 1884 | - |
|
| 1885 | - |
|
| 1886 | - /** |
|
| 1887 | - * _add_screen_columns |
|
| 1888 | - * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page. |
|
| 1889 | - * |
|
| 1890 | - * @access private |
|
| 1891 | - * @return void |
|
| 1892 | - */ |
|
| 1893 | - private function _add_screen_columns() |
|
| 1894 | - { |
|
| 1895 | - if ( |
|
| 1896 | - is_array($this->_route_config) |
|
| 1897 | - && isset($this->_route_config['columns']) |
|
| 1898 | - && is_array($this->_route_config['columns']) |
|
| 1899 | - && count($this->_route_config['columns']) === 2 |
|
| 1900 | - ) { |
|
| 1901 | - add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
| 1902 | - $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
|
| 1903 | - $screen_id = $this->_current_screen->id; |
|
| 1904 | - $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
| 1905 | - $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
| 1906 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
| 1907 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 1908 | - $this->_template_args['screen'] = $this->_current_screen; |
|
| 1909 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
| 1910 | - //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
|
| 1911 | - $this->_route_config['has_metaboxes'] = true; |
|
| 1912 | - } |
|
| 1913 | - } |
|
| 1914 | - |
|
| 1915 | - |
|
| 1916 | - |
|
| 1917 | - /**********************************/ |
|
| 1918 | - /** GLOBALLY AVAILABLE METABOXES **/ |
|
| 1919 | - /** |
|
| 1920 | - * In this section we put any globally available EE metaboxes for all EE Admin pages. They are called by simply referencing the callback in the _page_config array property. This way you can be very specific about what pages these get |
|
| 1921 | - * loaded on. |
|
| 1922 | - */ |
|
| 1923 | - private function _espresso_news_post_box() |
|
| 1924 | - { |
|
| 1925 | - $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
| 1926 | - add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
| 1927 | - $this, |
|
| 1928 | - 'espresso_news_post_box', |
|
| 1929 | - ), $this->_wp_page_slug, 'side'); |
|
| 1930 | - } |
|
| 1931 | - |
|
| 1932 | - |
|
| 1933 | - |
|
| 1934 | - /** |
|
| 1935 | - * Code for setting up espresso ratings request metabox. |
|
| 1936 | - */ |
|
| 1937 | - protected function _espresso_ratings_request() |
|
| 1938 | - { |
|
| 1939 | - if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
| 1940 | - return ''; |
|
| 1941 | - } |
|
| 1942 | - $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
| 1943 | - add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
| 1944 | - $this, |
|
| 1945 | - 'espresso_ratings_request', |
|
| 1946 | - ), $this->_wp_page_slug, 'side'); |
|
| 1947 | - } |
|
| 1948 | - |
|
| 1949 | - |
|
| 1950 | - |
|
| 1951 | - /** |
|
| 1952 | - * Code for setting up espresso ratings request metabox content. |
|
| 1953 | - */ |
|
| 1954 | - public function espresso_ratings_request() |
|
| 1955 | - { |
|
| 1956 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
| 1957 | - EEH_Template::display_template($template_path, array()); |
|
| 1958 | - } |
|
| 1959 | - |
|
| 1960 | - |
|
| 1961 | - |
|
| 1962 | - public static function cached_rss_display($rss_id, $url) |
|
| 1963 | - { |
|
| 1964 | - $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
| 1965 | - $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 1966 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
| 1967 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
| 1968 | - $post = '</div>' . "\n"; |
|
| 1969 | - $cache_key = 'ee_rss_' . md5($rss_id); |
|
| 1970 | - if (false != ($output = get_transient($cache_key))) { |
|
| 1971 | - echo $pre . $output . $post; |
|
| 1972 | - return true; |
|
| 1973 | - } |
|
| 1974 | - if ( ! $doing_ajax) { |
|
| 1975 | - echo $pre . $loading . $post; |
|
| 1976 | - return false; |
|
| 1977 | - } |
|
| 1978 | - ob_start(); |
|
| 1979 | - wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
| 1980 | - set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
| 1981 | - return true; |
|
| 1982 | - } |
|
| 1983 | - |
|
| 1984 | - |
|
| 1985 | - |
|
| 1986 | - public function espresso_news_post_box() |
|
| 1987 | - { |
|
| 1988 | - ?> |
|
| 1819 | + return $entries_per_page_dropdown; |
|
| 1820 | + } |
|
| 1821 | + |
|
| 1822 | + |
|
| 1823 | + |
|
| 1824 | + /** |
|
| 1825 | + * _set_search_attributes |
|
| 1826 | + * |
|
| 1827 | + * @access protected |
|
| 1828 | + * @return void |
|
| 1829 | + */ |
|
| 1830 | + public function _set_search_attributes() |
|
| 1831 | + { |
|
| 1832 | + $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
| 1833 | + $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
| 1834 | + } |
|
| 1835 | + |
|
| 1836 | + /*** END LIST TABLE METHODS **/ |
|
| 1837 | + /*****************************/ |
|
| 1838 | + /** |
|
| 1839 | + * _add_registered_metaboxes |
|
| 1840 | + * this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array. |
|
| 1841 | + * |
|
| 1842 | + * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
|
| 1843 | + * @access private |
|
| 1844 | + * @return void |
|
| 1845 | + */ |
|
| 1846 | + private function _add_registered_meta_boxes() |
|
| 1847 | + { |
|
| 1848 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1849 | + //we only add meta boxes if the page_route calls for it |
|
| 1850 | + if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
| 1851 | + && is_array( |
|
| 1852 | + $this->_route_config['metaboxes'] |
|
| 1853 | + ) |
|
| 1854 | + ) { |
|
| 1855 | + // this simply loops through the callbacks provided |
|
| 1856 | + // and checks if there is a corresponding callback registered by the child |
|
| 1857 | + // if there is then we go ahead and process the metabox loader. |
|
| 1858 | + foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
| 1859 | + // first check for Closures |
|
| 1860 | + if ($metabox_callback instanceof Closure) { |
|
| 1861 | + $result = $metabox_callback(); |
|
| 1862 | + } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
| 1863 | + $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
| 1864 | + } else { |
|
| 1865 | + $result = call_user_func(array($this, &$metabox_callback)); |
|
| 1866 | + } |
|
| 1867 | + if ($result === false) { |
|
| 1868 | + // user error msg |
|
| 1869 | + $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
| 1870 | + // developer error msg |
|
| 1871 | + $error_msg .= '||' . sprintf( |
|
| 1872 | + __( |
|
| 1873 | + 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
|
| 1874 | + 'event_espresso' |
|
| 1875 | + ), |
|
| 1876 | + $metabox_callback |
|
| 1877 | + ); |
|
| 1878 | + throw new EE_Error($error_msg); |
|
| 1879 | + } |
|
| 1880 | + } |
|
| 1881 | + } |
|
| 1882 | + } |
|
| 1883 | + |
|
| 1884 | + |
|
| 1885 | + |
|
| 1886 | + /** |
|
| 1887 | + * _add_screen_columns |
|
| 1888 | + * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page. |
|
| 1889 | + * |
|
| 1890 | + * @access private |
|
| 1891 | + * @return void |
|
| 1892 | + */ |
|
| 1893 | + private function _add_screen_columns() |
|
| 1894 | + { |
|
| 1895 | + if ( |
|
| 1896 | + is_array($this->_route_config) |
|
| 1897 | + && isset($this->_route_config['columns']) |
|
| 1898 | + && is_array($this->_route_config['columns']) |
|
| 1899 | + && count($this->_route_config['columns']) === 2 |
|
| 1900 | + ) { |
|
| 1901 | + add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
| 1902 | + $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
|
| 1903 | + $screen_id = $this->_current_screen->id; |
|
| 1904 | + $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
| 1905 | + $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
| 1906 | + $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
| 1907 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 1908 | + $this->_template_args['screen'] = $this->_current_screen; |
|
| 1909 | + $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
| 1910 | + //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
|
| 1911 | + $this->_route_config['has_metaboxes'] = true; |
|
| 1912 | + } |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + |
|
| 1916 | + |
|
| 1917 | + /**********************************/ |
|
| 1918 | + /** GLOBALLY AVAILABLE METABOXES **/ |
|
| 1919 | + /** |
|
| 1920 | + * In this section we put any globally available EE metaboxes for all EE Admin pages. They are called by simply referencing the callback in the _page_config array property. This way you can be very specific about what pages these get |
|
| 1921 | + * loaded on. |
|
| 1922 | + */ |
|
| 1923 | + private function _espresso_news_post_box() |
|
| 1924 | + { |
|
| 1925 | + $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
| 1926 | + add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
| 1927 | + $this, |
|
| 1928 | + 'espresso_news_post_box', |
|
| 1929 | + ), $this->_wp_page_slug, 'side'); |
|
| 1930 | + } |
|
| 1931 | + |
|
| 1932 | + |
|
| 1933 | + |
|
| 1934 | + /** |
|
| 1935 | + * Code for setting up espresso ratings request metabox. |
|
| 1936 | + */ |
|
| 1937 | + protected function _espresso_ratings_request() |
|
| 1938 | + { |
|
| 1939 | + if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
| 1940 | + return ''; |
|
| 1941 | + } |
|
| 1942 | + $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
| 1943 | + add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
| 1944 | + $this, |
|
| 1945 | + 'espresso_ratings_request', |
|
| 1946 | + ), $this->_wp_page_slug, 'side'); |
|
| 1947 | + } |
|
| 1948 | + |
|
| 1949 | + |
|
| 1950 | + |
|
| 1951 | + /** |
|
| 1952 | + * Code for setting up espresso ratings request metabox content. |
|
| 1953 | + */ |
|
| 1954 | + public function espresso_ratings_request() |
|
| 1955 | + { |
|
| 1956 | + $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
| 1957 | + EEH_Template::display_template($template_path, array()); |
|
| 1958 | + } |
|
| 1959 | + |
|
| 1960 | + |
|
| 1961 | + |
|
| 1962 | + public static function cached_rss_display($rss_id, $url) |
|
| 1963 | + { |
|
| 1964 | + $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
| 1965 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 1966 | + $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
| 1967 | + $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
| 1968 | + $post = '</div>' . "\n"; |
|
| 1969 | + $cache_key = 'ee_rss_' . md5($rss_id); |
|
| 1970 | + if (false != ($output = get_transient($cache_key))) { |
|
| 1971 | + echo $pre . $output . $post; |
|
| 1972 | + return true; |
|
| 1973 | + } |
|
| 1974 | + if ( ! $doing_ajax) { |
|
| 1975 | + echo $pre . $loading . $post; |
|
| 1976 | + return false; |
|
| 1977 | + } |
|
| 1978 | + ob_start(); |
|
| 1979 | + wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
| 1980 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
| 1981 | + return true; |
|
| 1982 | + } |
|
| 1983 | + |
|
| 1984 | + |
|
| 1985 | + |
|
| 1986 | + public function espresso_news_post_box() |
|
| 1987 | + { |
|
| 1988 | + ?> |
|
| 1989 | 1989 | <div class="padding"> |
| 1990 | 1990 | <div id="espresso_news_post_box_content" class="infolinks"> |
| 1991 | 1991 | <?php |
| 1992 | - // Get RSS Feed(s) |
|
| 1993 | - $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
| 1994 | - $url = urlencode($feed_url); |
|
| 1995 | - self::cached_rss_display('espresso_news_post_box_content', $url); |
|
| 1996 | - ?> |
|
| 1992 | + // Get RSS Feed(s) |
|
| 1993 | + $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
| 1994 | + $url = urlencode($feed_url); |
|
| 1995 | + self::cached_rss_display('espresso_news_post_box_content', $url); |
|
| 1996 | + ?> |
|
| 1997 | 1997 | </div> |
| 1998 | 1998 | <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
| 1999 | 1999 | </div> |
| 2000 | 2000 | <?php |
| 2001 | - } |
|
| 2002 | - |
|
| 2003 | - |
|
| 2004 | - |
|
| 2005 | - private function _espresso_links_post_box() |
|
| 2006 | - { |
|
| 2007 | - //Hiding until we actually have content to put in here... |
|
| 2008 | - //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2009 | - } |
|
| 2010 | - |
|
| 2011 | - |
|
| 2012 | - |
|
| 2013 | - public function espresso_links_post_box() |
|
| 2014 | - { |
|
| 2015 | - //Hiding until we actually have content to put in here... |
|
| 2016 | - //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'; |
|
| 2017 | - //EEH_Template::display_template( $templatepath ); |
|
| 2018 | - } |
|
| 2019 | - |
|
| 2020 | - |
|
| 2021 | - |
|
| 2022 | - protected function _espresso_sponsors_post_box() |
|
| 2023 | - { |
|
| 2024 | - $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true); |
|
| 2025 | - if ($show_sponsors) { |
|
| 2026 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2027 | - } |
|
| 2028 | - } |
|
| 2029 | - |
|
| 2030 | - |
|
| 2031 | - |
|
| 2032 | - public function espresso_sponsors_post_box() |
|
| 2033 | - { |
|
| 2034 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2035 | - EEH_Template::display_template($templatepath); |
|
| 2036 | - } |
|
| 2037 | - |
|
| 2038 | - |
|
| 2039 | - |
|
| 2040 | - private function _publish_post_box() |
|
| 2041 | - { |
|
| 2042 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
| 2043 | - //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
|
| 2044 | - if ( ! empty($this->_labels['publishbox'])) { |
|
| 2045 | - $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 2046 | - } else { |
|
| 2047 | - $box_label = __('Publish', 'event_espresso'); |
|
| 2048 | - } |
|
| 2049 | - $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
| 2050 | - add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
| 2051 | - } |
|
| 2052 | - |
|
| 2053 | - |
|
| 2054 | - |
|
| 2055 | - public function editor_overview() |
|
| 2056 | - { |
|
| 2057 | - //if we have extra content set let's add it in if not make sure its empty |
|
| 2058 | - $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2059 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
| 2060 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2061 | - } |
|
| 2062 | - |
|
| 2063 | - |
|
| 2064 | - /** end of globally available metaboxes section **/ |
|
| 2065 | - /*************************************************/ |
|
| 2066 | - /** |
|
| 2067 | - * Public wrapper for the protected method. Allows plugins/addons to externally call the |
|
| 2068 | - * protected method. |
|
| 2069 | - * |
|
| 2070 | - * @see $this->_set_publish_post_box_vars for param details |
|
| 2071 | - * @since 4.6.0 |
|
| 2072 | - */ |
|
| 2073 | - public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) |
|
| 2074 | - { |
|
| 2075 | - $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
| 2076 | - } |
|
| 2077 | - |
|
| 2078 | - |
|
| 2079 | - |
|
| 2080 | - /** |
|
| 2081 | - * Sets the _template_args arguments used by the _publish_post_box shortcut |
|
| 2082 | - * Note: currently there is no validation for this. However if you want the delete button, the |
|
| 2083 | - * save, and save and close buttons to work properly, then you will want to include a |
|
| 2084 | - * values for the name and id arguments. |
|
| 2085 | - * |
|
| 2086 | - * @todo Add in validation for name/id arguments. |
|
| 2087 | - * @param string $name key used for the action ID (i.e. event_id) |
|
| 2088 | - * @param int $id id attached to the item published |
|
| 2089 | - * @param string $delete page route callback for the delete action |
|
| 2090 | - * @param string $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed |
|
| 2091 | - * @param boolean $both_btns whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button |
|
| 2092 | - * @throws \EE_Error |
|
| 2093 | - */ |
|
| 2094 | - protected function _set_publish_post_box_vars( |
|
| 2095 | - $name = '', |
|
| 2096 | - $id = 0, |
|
| 2097 | - $delete = '', |
|
| 2098 | - $save_close_redirect_URL = '', |
|
| 2099 | - $both_btns = true |
|
| 2100 | - ) { |
|
| 2101 | - // if Save & Close, use a custom redirect URL or default to the main page? |
|
| 2102 | - $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
| 2103 | - // create the Save & Close and Save buttons |
|
| 2104 | - $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
| 2105 | - //if we have extra content set let's add it in if not make sure its empty |
|
| 2106 | - $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2107 | - if ($delete && ! empty($id)) { |
|
| 2108 | - //make sure we have a default if just true is sent. |
|
| 2109 | - $delete = ! empty($delete) ? $delete : 'delete'; |
|
| 2110 | - $delete_link_args = array($name => $id); |
|
| 2111 | - $delete = $this->get_action_link_or_button( |
|
| 2112 | - $delete, |
|
| 2113 | - $delete, |
|
| 2114 | - $delete_link_args, |
|
| 2115 | - 'submitdelete deletion', |
|
| 2116 | - '', |
|
| 2117 | - false |
|
| 2118 | - ); |
|
| 2119 | - } |
|
| 2120 | - $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
| 2121 | - if ( ! empty($name) && ! empty($id)) { |
|
| 2122 | - $hidden_field_arr[$name] = array( |
|
| 2123 | - 'type' => 'hidden', |
|
| 2124 | - 'value' => $id, |
|
| 2125 | - ); |
|
| 2126 | - $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array'); |
|
| 2127 | - } else { |
|
| 2128 | - $hf = ''; |
|
| 2129 | - } |
|
| 2130 | - // add hidden field |
|
| 2131 | - $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
| 2132 | - } |
|
| 2133 | - |
|
| 2134 | - |
|
| 2135 | - |
|
| 2136 | - /** |
|
| 2137 | - * displays an error message to ppl who have javascript disabled |
|
| 2138 | - * |
|
| 2139 | - * @access private |
|
| 2140 | - * @return string |
|
| 2141 | - */ |
|
| 2142 | - private function _display_no_javascript_warning() |
|
| 2143 | - { |
|
| 2144 | - ?> |
|
| 2001 | + } |
|
| 2002 | + |
|
| 2003 | + |
|
| 2004 | + |
|
| 2005 | + private function _espresso_links_post_box() |
|
| 2006 | + { |
|
| 2007 | + //Hiding until we actually have content to put in here... |
|
| 2008 | + //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2009 | + } |
|
| 2010 | + |
|
| 2011 | + |
|
| 2012 | + |
|
| 2013 | + public function espresso_links_post_box() |
|
| 2014 | + { |
|
| 2015 | + //Hiding until we actually have content to put in here... |
|
| 2016 | + //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'; |
|
| 2017 | + //EEH_Template::display_template( $templatepath ); |
|
| 2018 | + } |
|
| 2019 | + |
|
| 2020 | + |
|
| 2021 | + |
|
| 2022 | + protected function _espresso_sponsors_post_box() |
|
| 2023 | + { |
|
| 2024 | + $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true); |
|
| 2025 | + if ($show_sponsors) { |
|
| 2026 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
| 2027 | + } |
|
| 2028 | + } |
|
| 2029 | + |
|
| 2030 | + |
|
| 2031 | + |
|
| 2032 | + public function espresso_sponsors_post_box() |
|
| 2033 | + { |
|
| 2034 | + $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2035 | + EEH_Template::display_template($templatepath); |
|
| 2036 | + } |
|
| 2037 | + |
|
| 2038 | + |
|
| 2039 | + |
|
| 2040 | + private function _publish_post_box() |
|
| 2041 | + { |
|
| 2042 | + $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
| 2043 | + //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
|
| 2044 | + if ( ! empty($this->_labels['publishbox'])) { |
|
| 2045 | + $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
| 2046 | + } else { |
|
| 2047 | + $box_label = __('Publish', 'event_espresso'); |
|
| 2048 | + } |
|
| 2049 | + $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
| 2050 | + add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
| 2051 | + } |
|
| 2052 | + |
|
| 2053 | + |
|
| 2054 | + |
|
| 2055 | + public function editor_overview() |
|
| 2056 | + { |
|
| 2057 | + //if we have extra content set let's add it in if not make sure its empty |
|
| 2058 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2059 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
| 2060 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2061 | + } |
|
| 2062 | + |
|
| 2063 | + |
|
| 2064 | + /** end of globally available metaboxes section **/ |
|
| 2065 | + /*************************************************/ |
|
| 2066 | + /** |
|
| 2067 | + * Public wrapper for the protected method. Allows plugins/addons to externally call the |
|
| 2068 | + * protected method. |
|
| 2069 | + * |
|
| 2070 | + * @see $this->_set_publish_post_box_vars for param details |
|
| 2071 | + * @since 4.6.0 |
|
| 2072 | + */ |
|
| 2073 | + public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) |
|
| 2074 | + { |
|
| 2075 | + $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
| 2076 | + } |
|
| 2077 | + |
|
| 2078 | + |
|
| 2079 | + |
|
| 2080 | + /** |
|
| 2081 | + * Sets the _template_args arguments used by the _publish_post_box shortcut |
|
| 2082 | + * Note: currently there is no validation for this. However if you want the delete button, the |
|
| 2083 | + * save, and save and close buttons to work properly, then you will want to include a |
|
| 2084 | + * values for the name and id arguments. |
|
| 2085 | + * |
|
| 2086 | + * @todo Add in validation for name/id arguments. |
|
| 2087 | + * @param string $name key used for the action ID (i.e. event_id) |
|
| 2088 | + * @param int $id id attached to the item published |
|
| 2089 | + * @param string $delete page route callback for the delete action |
|
| 2090 | + * @param string $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed |
|
| 2091 | + * @param boolean $both_btns whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button |
|
| 2092 | + * @throws \EE_Error |
|
| 2093 | + */ |
|
| 2094 | + protected function _set_publish_post_box_vars( |
|
| 2095 | + $name = '', |
|
| 2096 | + $id = 0, |
|
| 2097 | + $delete = '', |
|
| 2098 | + $save_close_redirect_URL = '', |
|
| 2099 | + $both_btns = true |
|
| 2100 | + ) { |
|
| 2101 | + // if Save & Close, use a custom redirect URL or default to the main page? |
|
| 2102 | + $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
| 2103 | + // create the Save & Close and Save buttons |
|
| 2104 | + $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
| 2105 | + //if we have extra content set let's add it in if not make sure its empty |
|
| 2106 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
| 2107 | + if ($delete && ! empty($id)) { |
|
| 2108 | + //make sure we have a default if just true is sent. |
|
| 2109 | + $delete = ! empty($delete) ? $delete : 'delete'; |
|
| 2110 | + $delete_link_args = array($name => $id); |
|
| 2111 | + $delete = $this->get_action_link_or_button( |
|
| 2112 | + $delete, |
|
| 2113 | + $delete, |
|
| 2114 | + $delete_link_args, |
|
| 2115 | + 'submitdelete deletion', |
|
| 2116 | + '', |
|
| 2117 | + false |
|
| 2118 | + ); |
|
| 2119 | + } |
|
| 2120 | + $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
| 2121 | + if ( ! empty($name) && ! empty($id)) { |
|
| 2122 | + $hidden_field_arr[$name] = array( |
|
| 2123 | + 'type' => 'hidden', |
|
| 2124 | + 'value' => $id, |
|
| 2125 | + ); |
|
| 2126 | + $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array'); |
|
| 2127 | + } else { |
|
| 2128 | + $hf = ''; |
|
| 2129 | + } |
|
| 2130 | + // add hidden field |
|
| 2131 | + $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
| 2132 | + } |
|
| 2133 | + |
|
| 2134 | + |
|
| 2135 | + |
|
| 2136 | + /** |
|
| 2137 | + * displays an error message to ppl who have javascript disabled |
|
| 2138 | + * |
|
| 2139 | + * @access private |
|
| 2140 | + * @return string |
|
| 2141 | + */ |
|
| 2142 | + private function _display_no_javascript_warning() |
|
| 2143 | + { |
|
| 2144 | + ?> |
|
| 2145 | 2145 | <noscript> |
| 2146 | 2146 | <div id="no-js-message" class="error"> |
| 2147 | 2147 | <p style="font-size:1.3em;"> |
@@ -2151,1267 +2151,1267 @@ discard block |
||
| 2151 | 2151 | </div> |
| 2152 | 2152 | </noscript> |
| 2153 | 2153 | <?php |
| 2154 | - } |
|
| 2154 | + } |
|
| 2155 | 2155 | |
| 2156 | 2156 | |
| 2157 | 2157 | |
| 2158 | - /** |
|
| 2159 | - * displays espresso success and/or error notices |
|
| 2160 | - * |
|
| 2161 | - * @access private |
|
| 2162 | - * @return string |
|
| 2163 | - */ |
|
| 2164 | - private function _display_espresso_notices() |
|
| 2165 | - { |
|
| 2166 | - $notices = $this->_get_transient(true); |
|
| 2167 | - echo stripslashes($notices); |
|
| 2168 | - } |
|
| 2158 | + /** |
|
| 2159 | + * displays espresso success and/or error notices |
|
| 2160 | + * |
|
| 2161 | + * @access private |
|
| 2162 | + * @return string |
|
| 2163 | + */ |
|
| 2164 | + private function _display_espresso_notices() |
|
| 2165 | + { |
|
| 2166 | + $notices = $this->_get_transient(true); |
|
| 2167 | + echo stripslashes($notices); |
|
| 2168 | + } |
|
| 2169 | 2169 | |
| 2170 | 2170 | |
| 2171 | 2171 | |
| 2172 | - /** |
|
| 2173 | - * spinny things pacify the masses |
|
| 2174 | - * |
|
| 2175 | - * @access private |
|
| 2176 | - * @return string |
|
| 2177 | - */ |
|
| 2178 | - protected function _add_admin_page_ajax_loading_img() |
|
| 2179 | - { |
|
| 2180 | - ?> |
|
| 2172 | + /** |
|
| 2173 | + * spinny things pacify the masses |
|
| 2174 | + * |
|
| 2175 | + * @access private |
|
| 2176 | + * @return string |
|
| 2177 | + */ |
|
| 2178 | + protected function _add_admin_page_ajax_loading_img() |
|
| 2179 | + { |
|
| 2180 | + ?> |
|
| 2181 | 2181 | <div id="espresso-ajax-loading" class="ajax-loading-grey"> |
| 2182 | 2182 | <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e('loading...', 'event_espresso'); ?></span> |
| 2183 | 2183 | </div> |
| 2184 | 2184 | <?php |
| 2185 | - } |
|
| 2185 | + } |
|
| 2186 | 2186 | |
| 2187 | 2187 | |
| 2188 | 2188 | |
| 2189 | - /** |
|
| 2190 | - * add admin page overlay for modal boxes |
|
| 2191 | - * |
|
| 2192 | - * @access private |
|
| 2193 | - * @return string |
|
| 2194 | - */ |
|
| 2195 | - protected function _add_admin_page_overlay() |
|
| 2196 | - { |
|
| 2197 | - ?> |
|
| 2189 | + /** |
|
| 2190 | + * add admin page overlay for modal boxes |
|
| 2191 | + * |
|
| 2192 | + * @access private |
|
| 2193 | + * @return string |
|
| 2194 | + */ |
|
| 2195 | + protected function _add_admin_page_overlay() |
|
| 2196 | + { |
|
| 2197 | + ?> |
|
| 2198 | 2198 | <div id="espresso-admin-page-overlay-dv" class=""></div> |
| 2199 | 2199 | <?php |
| 2200 | - } |
|
| 2201 | - |
|
| 2202 | - |
|
| 2203 | - |
|
| 2204 | - /** |
|
| 2205 | - * facade for add_meta_box |
|
| 2206 | - * |
|
| 2207 | - * @param string $action where the metabox get's displayed |
|
| 2208 | - * @param string $title Title of Metabox (output in metabox header) |
|
| 2209 | - * @param string $callback If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here. |
|
| 2210 | - * @param array $callback_args an array of args supplied for the metabox |
|
| 2211 | - * @param string $column what metabox column |
|
| 2212 | - * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
|
| 2213 | - * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
|
| 2214 | - */ |
|
| 2215 | - public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) |
|
| 2216 | - { |
|
| 2217 | - do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
| 2218 | - //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
|
| 2219 | - if (empty($callback_args) && $create_func) { |
|
| 2220 | - $callback_args = array( |
|
| 2221 | - 'template_path' => $this->_template_path, |
|
| 2222 | - 'template_args' => $this->_template_args, |
|
| 2223 | - ); |
|
| 2224 | - } |
|
| 2225 | - //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
|
| 2226 | - $call_back_func = $create_func ? create_function('$post, $metabox', |
|
| 2227 | - 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
|
| 2228 | - add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
| 2229 | - } |
|
| 2230 | - |
|
| 2231 | - |
|
| 2232 | - |
|
| 2233 | - /** |
|
| 2234 | - * generates HTML wrapper for and admin details page that contains metaboxes in columns |
|
| 2235 | - * |
|
| 2236 | - * @return [type] [description] |
|
| 2237 | - */ |
|
| 2238 | - public function display_admin_page_with_metabox_columns() |
|
| 2239 | - { |
|
| 2240 | - $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
|
| 2241 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true); |
|
| 2242 | - //the final wrapper |
|
| 2243 | - $this->admin_page_wrapper(); |
|
| 2244 | - } |
|
| 2245 | - |
|
| 2246 | - |
|
| 2247 | - |
|
| 2248 | - /** |
|
| 2249 | - * generates HTML wrapper for an admin details page |
|
| 2250 | - * |
|
| 2251 | - * @access public |
|
| 2252 | - * @return void |
|
| 2253 | - */ |
|
| 2254 | - public function display_admin_page_with_sidebar() |
|
| 2255 | - { |
|
| 2256 | - $this->_display_admin_page(true); |
|
| 2257 | - } |
|
| 2258 | - |
|
| 2259 | - |
|
| 2260 | - |
|
| 2261 | - /** |
|
| 2262 | - * generates HTML wrapper for an admin details page (except no sidebar) |
|
| 2263 | - * |
|
| 2264 | - * @access public |
|
| 2265 | - * @return void |
|
| 2266 | - */ |
|
| 2267 | - public function display_admin_page_with_no_sidebar() |
|
| 2268 | - { |
|
| 2269 | - $this->_display_admin_page(); |
|
| 2270 | - } |
|
| 2271 | - |
|
| 2272 | - |
|
| 2273 | - |
|
| 2274 | - /** |
|
| 2275 | - * generates HTML wrapper for an EE about admin page (no sidebar) |
|
| 2276 | - * |
|
| 2277 | - * @access public |
|
| 2278 | - * @return void |
|
| 2279 | - */ |
|
| 2280 | - public function display_about_admin_page() |
|
| 2281 | - { |
|
| 2282 | - $this->_display_admin_page(false, true); |
|
| 2283 | - } |
|
| 2284 | - |
|
| 2285 | - |
|
| 2286 | - |
|
| 2287 | - /** |
|
| 2288 | - * display_admin_page |
|
| 2289 | - * contains the code for actually displaying an admin page |
|
| 2290 | - * |
|
| 2291 | - * @access private |
|
| 2292 | - * @param boolean $sidebar true with sidebar, false without |
|
| 2293 | - * @param boolean $about use the about admin wrapper instead of the default. |
|
| 2294 | - * @return void |
|
| 2295 | - */ |
|
| 2296 | - private function _display_admin_page($sidebar = false, $about = false) |
|
| 2297 | - { |
|
| 2298 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2299 | - //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
|
| 2300 | - do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
| 2301 | - // set current wp page slug - looks like: event-espresso_page_event_categories |
|
| 2302 | - // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
|
| 2303 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 2304 | - $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route |
|
| 2305 | - ? 'poststuff' |
|
| 2306 | - : 'espresso-default-admin'; |
|
| 2307 | - $template_path = $sidebar |
|
| 2308 | - ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
|
| 2309 | - : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2310 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2311 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2312 | - } |
|
| 2313 | - $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
| 2314 | - $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
| 2315 | - $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
|
| 2316 | - $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
|
| 2317 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2318 | - // the final template wrapper |
|
| 2319 | - $this->admin_page_wrapper($about); |
|
| 2320 | - } |
|
| 2321 | - |
|
| 2322 | - |
|
| 2323 | - |
|
| 2324 | - /** |
|
| 2325 | - * This is used to display caf preview pages. |
|
| 2326 | - * |
|
| 2327 | - * @since 4.3.2 |
|
| 2328 | - * @param string $utm_campaign_source what is the key used for google analytics link |
|
| 2329 | - * @param bool $display_sidebar whether to use the sidebar template or the full template for the page. TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar. |
|
| 2330 | - * @return void |
|
| 2331 | - * @throws \EE_Error |
|
| 2332 | - */ |
|
| 2333 | - public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true) |
|
| 2334 | - { |
|
| 2335 | - //let's generate a default preview action button if there isn't one already present. |
|
| 2336 | - $this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso'); |
|
| 2337 | - $buy_now_url = add_query_arg( |
|
| 2338 | - array( |
|
| 2339 | - 'ee_ver' => 'ee4', |
|
| 2340 | - 'utm_source' => 'ee4_plugin_admin', |
|
| 2341 | - 'utm_medium' => 'link', |
|
| 2342 | - 'utm_campaign' => $utm_campaign_source, |
|
| 2343 | - 'utm_content' => 'buy_now_button', |
|
| 2344 | - ), |
|
| 2345 | - 'http://eventespresso.com/pricing/' |
|
| 2346 | - ); |
|
| 2347 | - $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
| 2348 | - ? $this->get_action_link_or_button( |
|
| 2349 | - '', |
|
| 2350 | - 'buy_now', |
|
| 2351 | - array(), |
|
| 2352 | - 'button-primary button-large', |
|
| 2353 | - $buy_now_url, |
|
| 2354 | - true |
|
| 2355 | - ) |
|
| 2356 | - : $this->_template_args['preview_action_button']; |
|
| 2357 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
| 2358 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 2359 | - $template_path, |
|
| 2360 | - $this->_template_args, |
|
| 2361 | - true |
|
| 2362 | - ); |
|
| 2363 | - $this->_display_admin_page($display_sidebar); |
|
| 2364 | - } |
|
| 2365 | - |
|
| 2366 | - |
|
| 2367 | - |
|
| 2368 | - /** |
|
| 2369 | - * display_admin_list_table_page_with_sidebar |
|
| 2370 | - * generates HTML wrapper for an admin_page with list_table |
|
| 2371 | - * |
|
| 2372 | - * @access public |
|
| 2373 | - * @return void |
|
| 2374 | - */ |
|
| 2375 | - public function display_admin_list_table_page_with_sidebar() |
|
| 2376 | - { |
|
| 2377 | - $this->_display_admin_list_table_page(true); |
|
| 2378 | - } |
|
| 2379 | - |
|
| 2380 | - |
|
| 2381 | - |
|
| 2382 | - /** |
|
| 2383 | - * display_admin_list_table_page_with_no_sidebar |
|
| 2384 | - * generates HTML wrapper for an admin_page with list_table (but with no sidebar) |
|
| 2385 | - * |
|
| 2386 | - * @access public |
|
| 2387 | - * @return void |
|
| 2388 | - */ |
|
| 2389 | - public function display_admin_list_table_page_with_no_sidebar() |
|
| 2390 | - { |
|
| 2391 | - $this->_display_admin_list_table_page(); |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - |
|
| 2395 | - |
|
| 2396 | - /** |
|
| 2397 | - * generates html wrapper for an admin_list_table page |
|
| 2398 | - * |
|
| 2399 | - * @access private |
|
| 2400 | - * @param boolean $sidebar whether to display with sidebar or not. |
|
| 2401 | - * @return void |
|
| 2402 | - */ |
|
| 2403 | - private function _display_admin_list_table_page($sidebar = false) |
|
| 2404 | - { |
|
| 2405 | - //setup search attributes |
|
| 2406 | - $this->_set_search_attributes(); |
|
| 2407 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 2408 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
| 2409 | - $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
| 2410 | - ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
| 2411 | - : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
| 2412 | - $this->_template_args['list_table'] = $this->_list_table_object; |
|
| 2413 | - $this->_template_args['current_route'] = $this->_req_action; |
|
| 2414 | - $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
| 2415 | - $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
|
| 2416 | - if ( ! empty($ajax_sorting_callback)) { |
|
| 2417 | - $sortable_list_table_form_fields = wp_nonce_field( |
|
| 2418 | - $ajax_sorting_callback . '_nonce', |
|
| 2419 | - $ajax_sorting_callback . '_nonce', |
|
| 2420 | - false, |
|
| 2421 | - false |
|
| 2422 | - ); |
|
| 2423 | - // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
|
| 2424 | - // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
|
| 2425 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
| 2426 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
| 2427 | - } else { |
|
| 2428 | - $sortable_list_table_form_fields = ''; |
|
| 2429 | - } |
|
| 2430 | - $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
|
| 2431 | - $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
| 2432 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
| 2433 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
| 2434 | - $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
|
| 2435 | - //display message about search results? |
|
| 2436 | - $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s']) |
|
| 2437 | - ? '<p class="ee-search-results">' . sprintf( |
|
| 2438 | - esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'), |
|
| 2439 | - trim($this->_req_data['s'], '%') |
|
| 2440 | - ) . '</p>' |
|
| 2441 | - : ''; |
|
| 2442 | - // filter before_list_table template arg |
|
| 2443 | - $this->_template_args['before_list_table'] = apply_filters( |
|
| 2444 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
|
| 2445 | - $this->_template_args['before_list_table'], |
|
| 2446 | - $this->page_slug, |
|
| 2447 | - $this->_req_data, |
|
| 2448 | - $this->_req_action |
|
| 2449 | - ); |
|
| 2450 | - // convert to array and filter again |
|
| 2451 | - // arrays are easier to inject new items in a specific location, |
|
| 2452 | - // but would not be backwards compatible, so we have to add a new filter |
|
| 2453 | - $this->_template_args['before_list_table'] = implode( |
|
| 2454 | - " \n", |
|
| 2455 | - (array) apply_filters( |
|
| 2456 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array', |
|
| 2457 | - (array) $this->_template_args['before_list_table'], |
|
| 2458 | - $this->page_slug, |
|
| 2459 | - $this->_req_data, |
|
| 2460 | - $this->_req_action |
|
| 2461 | - ) |
|
| 2462 | - ); |
|
| 2463 | - // filter after_list_table template arg |
|
| 2464 | - $this->_template_args['after_list_table'] = apply_filters( |
|
| 2465 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg', |
|
| 2466 | - $this->_template_args['after_list_table'], |
|
| 2467 | - $this->page_slug, |
|
| 2468 | - $this->_req_data, |
|
| 2469 | - $this->_req_action |
|
| 2470 | - ); |
|
| 2471 | - // convert to array and filter again |
|
| 2472 | - // arrays are easier to inject new items in a specific location, |
|
| 2473 | - // but would not be backwards compatible, so we have to add a new filter |
|
| 2474 | - $this->_template_args['after_list_table'] = implode( |
|
| 2475 | - " \n", |
|
| 2476 | - (array) apply_filters( |
|
| 2477 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
| 2478 | - (array) $this->_template_args['after_list_table'], |
|
| 2479 | - $this->page_slug, |
|
| 2480 | - $this->_req_data, |
|
| 2481 | - $this->_req_action |
|
| 2482 | - ) |
|
| 2483 | - ); |
|
| 2484 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 2485 | - $template_path, |
|
| 2486 | - $this->_template_args, |
|
| 2487 | - true |
|
| 2488 | - ); |
|
| 2489 | - // the final template wrapper |
|
| 2490 | - if ($sidebar) { |
|
| 2491 | - $this->display_admin_page_with_sidebar(); |
|
| 2492 | - } else { |
|
| 2493 | - $this->display_admin_page_with_no_sidebar(); |
|
| 2494 | - } |
|
| 2495 | - } |
|
| 2496 | - |
|
| 2497 | - |
|
| 2498 | - |
|
| 2499 | - /** |
|
| 2500 | - * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend. |
|
| 2501 | - * $items are expected in an array in the following format: |
|
| 2502 | - * $legend_items = array( |
|
| 2503 | - * 'item_id' => array( |
|
| 2504 | - * 'icon' => 'http://url_to_icon_being_described.png', |
|
| 2505 | - * 'desc' => __('localized description of item'); |
|
| 2506 | - * ) |
|
| 2507 | - * ); |
|
| 2508 | - * |
|
| 2509 | - * @param array $items see above for format of array |
|
| 2510 | - * @return string html string of legend |
|
| 2511 | - */ |
|
| 2512 | - protected function _display_legend($items) |
|
| 2513 | - { |
|
| 2514 | - $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
| 2515 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
| 2516 | - return EEH_Template::display_template($legend_template, $this->_template_args, true); |
|
| 2517 | - } |
|
| 2518 | - |
|
| 2519 | - |
|
| 2520 | - |
|
| 2521 | - /** |
|
| 2522 | - * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect |
|
| 2523 | - * |
|
| 2524 | - * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed. |
|
| 2525 | - * The returned json object is created from an array in the following format: |
|
| 2526 | - * array( |
|
| 2527 | - * 'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early), |
|
| 2528 | - * 'success' => FALSE, //(default FALSE) - contains any special success message. |
|
| 2529 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
| 2530 | - * 'content' => 'string can be html', //this is a string of formatted content (can be html) |
|
| 2531 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any |
|
| 2532 | - * specific template args that might be included in here) |
|
| 2533 | - * ) |
|
| 2534 | - * The json object is populated by whatever is set in the $_template_args property. |
|
| 2535 | - * @return void |
|
| 2536 | - */ |
|
| 2537 | - protected function _return_json($sticky_notices = false) |
|
| 2538 | - { |
|
| 2539 | - //make sure any EE_Error notices have been handled. |
|
| 2540 | - $this->_process_notices(array(), true, $sticky_notices); |
|
| 2541 | - $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
| 2542 | - unset($this->_template_args['data']); |
|
| 2543 | - $json = array( |
|
| 2544 | - 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
| 2545 | - 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
| 2546 | - 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
| 2547 | - 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
| 2548 | - 'notices' => EE_Error::get_notices(), |
|
| 2549 | - 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
| 2550 | - 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
| 2551 | - 'isEEajax' => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
| 2552 | - ); |
|
| 2553 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
| 2554 | - if (null === error_get_last() || ! headers_sent()) { |
|
| 2555 | - header('Content-Type: application/json; charset=UTF-8'); |
|
| 2556 | - } |
|
| 2557 | - echo wp_json_encode($json); |
|
| 2558 | - |
|
| 2559 | - exit(); |
|
| 2560 | - } |
|
| 2561 | - |
|
| 2562 | - |
|
| 2563 | - |
|
| 2564 | - /** |
|
| 2565 | - * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax) |
|
| 2566 | - * |
|
| 2567 | - * @return void |
|
| 2568 | - * @throws EE_Error |
|
| 2569 | - */ |
|
| 2570 | - public function return_json() |
|
| 2571 | - { |
|
| 2572 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2573 | - $this->_return_json(); |
|
| 2574 | - } else { |
|
| 2575 | - throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
| 2576 | - } |
|
| 2577 | - } |
|
| 2578 | - |
|
| 2579 | - |
|
| 2580 | - |
|
| 2581 | - /** |
|
| 2582 | - * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property. |
|
| 2583 | - * |
|
| 2584 | - * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child |
|
| 2585 | - * @access public |
|
| 2586 | - */ |
|
| 2587 | - public function set_hook_object(EE_Admin_Hooks $hook_obj) |
|
| 2588 | - { |
|
| 2589 | - $this->_hook_obj = $hook_obj; |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - |
|
| 2593 | - |
|
| 2594 | - /** |
|
| 2595 | - * generates HTML wrapper with Tabbed nav for an admin page |
|
| 2596 | - * |
|
| 2597 | - * @access public |
|
| 2598 | - * @param boolean $about whether to use the special about page wrapper or default. |
|
| 2599 | - * @return void |
|
| 2600 | - */ |
|
| 2601 | - public function admin_page_wrapper($about = false) |
|
| 2602 | - { |
|
| 2603 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2604 | - $this->_nav_tabs = $this->_get_main_nav_tabs(); |
|
| 2605 | - $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
|
| 2606 | - $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
|
| 2607 | - $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2608 | - isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
| 2609 | - $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2610 | - isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
| 2611 | - $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
|
| 2612 | - // load settings page wrapper template |
|
| 2613 | - $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
| 2614 | - //about page? |
|
| 2615 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
| 2616 | - if (defined('DOING_AJAX')) { |
|
| 2617 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2618 | - $this->_return_json(); |
|
| 2619 | - } else { |
|
| 2620 | - EEH_Template::display_template($template_path, $this->_template_args); |
|
| 2621 | - } |
|
| 2622 | - } |
|
| 2623 | - |
|
| 2624 | - |
|
| 2625 | - |
|
| 2626 | - /** |
|
| 2627 | - * This returns the admin_nav tabs html using the configuration in the _nav_tabs property |
|
| 2628 | - * |
|
| 2629 | - * @return string html |
|
| 2630 | - */ |
|
| 2631 | - protected function _get_main_nav_tabs() |
|
| 2632 | - { |
|
| 2633 | - //let's generate the html using the EEH_Tabbed_Content helper. We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array) |
|
| 2634 | - return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs); |
|
| 2635 | - } |
|
| 2636 | - |
|
| 2637 | - |
|
| 2638 | - |
|
| 2639 | - /** |
|
| 2640 | - * sort nav tabs |
|
| 2641 | - * |
|
| 2642 | - * @access public |
|
| 2643 | - * @param $a |
|
| 2644 | - * @param $b |
|
| 2645 | - * @return int |
|
| 2646 | - */ |
|
| 2647 | - private function _sort_nav_tabs($a, $b) |
|
| 2648 | - { |
|
| 2649 | - if ($a['order'] == $b['order']) { |
|
| 2650 | - return 0; |
|
| 2651 | - } |
|
| 2652 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - |
|
| 2656 | - |
|
| 2657 | - /** |
|
| 2658 | - * generates HTML for the forms used on admin pages |
|
| 2659 | - * |
|
| 2660 | - * @access protected |
|
| 2661 | - * @param array $input_vars - array of input field details |
|
| 2662 | - * @param string $generator (options are 'string' or 'array', basically use this to indicate which generator to use) |
|
| 2663 | - * @return string |
|
| 2664 | - * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
|
| 2665 | - * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
|
| 2666 | - */ |
|
| 2667 | - protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false) |
|
| 2668 | - { |
|
| 2669 | - $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
|
| 2670 | - return $content; |
|
| 2671 | - } |
|
| 2672 | - |
|
| 2673 | - |
|
| 2674 | - |
|
| 2675 | - /** |
|
| 2676 | - * generates the "Save" and "Save & Close" buttons for edit forms |
|
| 2677 | - * |
|
| 2678 | - * @access protected |
|
| 2679 | - * @param bool $both if true then both buttons will be generated. If false then just the "Save & Close" button. |
|
| 2680 | - * @param array $text if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close') |
|
| 2681 | - * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
|
| 2682 | - * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
|
| 2683 | - */ |
|
| 2684 | - protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
|
| 2685 | - { |
|
| 2686 | - //make sure $text and $actions are in an array |
|
| 2687 | - $text = (array)$text; |
|
| 2688 | - $actions = (array)$actions; |
|
| 2689 | - $referrer_url = empty($referrer) ? '' : $referrer; |
|
| 2690 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
| 2691 | - : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
| 2692 | - $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
| 2693 | - $default_names = array('save', 'save_and_close'); |
|
| 2694 | - //add in a hidden index for the current page (so save and close redirects properly) |
|
| 2695 | - $this->_template_args['save_buttons'] = $referrer_url; |
|
| 2696 | - foreach ($button_text as $key => $button) { |
|
| 2697 | - $ref = $default_names[$key]; |
|
| 2698 | - $id = $this->_current_view . '_' . $ref; |
|
| 2699 | - $name = ! empty($actions) ? $actions[$key] : $ref; |
|
| 2700 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
| 2701 | - if ( ! $both) { |
|
| 2702 | - break; |
|
| 2703 | - } |
|
| 2704 | - } |
|
| 2705 | - } |
|
| 2706 | - |
|
| 2707 | - |
|
| 2708 | - |
|
| 2709 | - /** |
|
| 2710 | - * Wrapper for the protected function. Allows plugins/addons to call this to set the form tags. |
|
| 2711 | - * |
|
| 2712 | - * @see $this->_set_add_edit_form_tags() for details on params |
|
| 2713 | - * @since 4.6.0 |
|
| 2714 | - * @param string $route |
|
| 2715 | - * @param array $additional_hidden_fields |
|
| 2716 | - */ |
|
| 2717 | - public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
| 2718 | - { |
|
| 2719 | - $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
| 2720 | - } |
|
| 2721 | - |
|
| 2722 | - |
|
| 2723 | - |
|
| 2724 | - /** |
|
| 2725 | - * set form open and close tags on add/edit pages. |
|
| 2726 | - * |
|
| 2727 | - * @access protected |
|
| 2728 | - * @param string $route the route you want the form to direct to |
|
| 2729 | - * @param array $additional_hidden_fields any additional hidden fields required in the form header |
|
| 2730 | - * @return void |
|
| 2731 | - */ |
|
| 2732 | - protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
| 2733 | - { |
|
| 2734 | - if (empty($route)) { |
|
| 2735 | - $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
|
| 2736 | - $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
| 2737 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2738 | - } |
|
| 2739 | - // open form |
|
| 2740 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
| 2741 | - // add nonce |
|
| 2742 | - $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
| 2743 | - // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
|
| 2744 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
| 2745 | - // add REQUIRED form action |
|
| 2746 | - $hidden_fields = array( |
|
| 2747 | - 'action' => array('type' => 'hidden', 'value' => $route), |
|
| 2748 | - ); |
|
| 2749 | - // merge arrays |
|
| 2750 | - $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
| 2751 | - // generate form fields |
|
| 2752 | - $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
| 2753 | - // add fields to form |
|
| 2754 | - foreach ((array)$form_fields as $field_name => $form_field) { |
|
| 2755 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
| 2756 | - } |
|
| 2757 | - // close form |
|
| 2758 | - $this->_template_args['after_admin_page_content'] = '</form>'; |
|
| 2759 | - } |
|
| 2760 | - |
|
| 2761 | - |
|
| 2762 | - |
|
| 2763 | - /** |
|
| 2764 | - * Public Wrapper for _redirect_after_action() method since its |
|
| 2765 | - * discovered it would be useful for external code to have access. |
|
| 2766 | - * |
|
| 2767 | - * @see EE_Admin_Page::_redirect_after_action() for params. |
|
| 2768 | - * @since 4.5.0 |
|
| 2769 | - */ |
|
| 2770 | - public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
| 2771 | - { |
|
| 2772 | - $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
| 2773 | - } |
|
| 2774 | - |
|
| 2775 | - |
|
| 2776 | - |
|
| 2777 | - /** |
|
| 2778 | - * _redirect_after_action |
|
| 2779 | - * |
|
| 2780 | - * @param int $success - whether success was for two or more records, or just one, or none |
|
| 2781 | - * @param string $what - what the action was performed on |
|
| 2782 | - * @param string $action_desc - what was done ie: updated, deleted, etc |
|
| 2783 | - * @param array $query_args - an array of query_args to be added to the URL to redirect to after the admin action is completed |
|
| 2784 | - * @param BOOL $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show. |
|
| 2785 | - * @access protected |
|
| 2786 | - * @return void |
|
| 2787 | - */ |
|
| 2788 | - protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
| 2789 | - { |
|
| 2790 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2791 | - //class name for actions/filters. |
|
| 2792 | - $classname = get_class($this); |
|
| 2793 | - //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
|
| 2794 | - $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
| 2795 | - $notices = EE_Error::get_notices(false); |
|
| 2796 | - // overwrite default success messages //BUT ONLY if overwrite not overridden |
|
| 2797 | - if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
| 2798 | - EE_Error::overwrite_success(); |
|
| 2799 | - } |
|
| 2800 | - if ( ! empty($what) && ! empty($action_desc)) { |
|
| 2801 | - // how many records affected ? more than one record ? or just one ? |
|
| 2802 | - if ($success > 1 && empty($notices['errors'])) { |
|
| 2803 | - // set plural msg |
|
| 2804 | - EE_Error::add_success( |
|
| 2805 | - sprintf( |
|
| 2806 | - __('The "%s" have been successfully %s.', 'event_espresso'), |
|
| 2807 | - $what, |
|
| 2808 | - $action_desc |
|
| 2809 | - ), |
|
| 2810 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2811 | - ); |
|
| 2812 | - } else if ($success == 1 && empty($notices['errors'])) { |
|
| 2813 | - // set singular msg |
|
| 2814 | - EE_Error::add_success( |
|
| 2815 | - sprintf( |
|
| 2816 | - __('The "%s" has been successfully %s.', 'event_espresso'), |
|
| 2817 | - $what, |
|
| 2818 | - $action_desc |
|
| 2819 | - ), |
|
| 2820 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 2821 | - ); |
|
| 2822 | - } |
|
| 2823 | - } |
|
| 2824 | - // check that $query_args isn't something crazy |
|
| 2825 | - if ( ! is_array($query_args)) { |
|
| 2826 | - $query_args = array(); |
|
| 2827 | - } |
|
| 2828 | - /** |
|
| 2829 | - * Allow injecting actions before the query_args are modified for possible different |
|
| 2830 | - * redirections on save and close actions |
|
| 2831 | - * |
|
| 2832 | - * @since 4.2.0 |
|
| 2833 | - * @param array $query_args The original query_args array coming into the |
|
| 2834 | - * method. |
|
| 2835 | - */ |
|
| 2836 | - do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
| 2837 | - //calculate where we're going (if we have a "save and close" button pushed) |
|
| 2838 | - if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
| 2839 | - // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
|
| 2840 | - $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
| 2841 | - // regenerate query args array from referrer URL |
|
| 2842 | - parse_str($parsed_url['query'], $query_args); |
|
| 2843 | - // correct page and action will be in the query args now |
|
| 2844 | - $redirect_url = admin_url('admin.php'); |
|
| 2845 | - } |
|
| 2846 | - //merge any default query_args set in _default_route_query_args property |
|
| 2847 | - if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
| 2848 | - $args_to_merge = array(); |
|
| 2849 | - foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
| 2850 | - //is there a wp_referer array in our _default_route_query_args property? |
|
| 2851 | - if ($query_param == 'wp_referer') { |
|
| 2852 | - $query_value = (array)$query_value; |
|
| 2853 | - foreach ($query_value as $reference => $value) { |
|
| 2854 | - if (strpos($reference, 'nonce') !== false) { |
|
| 2855 | - continue; |
|
| 2856 | - } |
|
| 2857 | - //finally we will override any arguments in the referer with |
|
| 2858 | - //what might be set on the _default_route_query_args array. |
|
| 2859 | - if (isset($this->_default_route_query_args[$reference])) { |
|
| 2860 | - $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
| 2861 | - } else { |
|
| 2862 | - $args_to_merge[$reference] = urlencode($value); |
|
| 2863 | - } |
|
| 2864 | - } |
|
| 2865 | - continue; |
|
| 2866 | - } |
|
| 2867 | - $args_to_merge[$query_param] = $query_value; |
|
| 2868 | - } |
|
| 2869 | - //now let's merge these arguments but override with what was specifically sent in to the |
|
| 2870 | - //redirect. |
|
| 2871 | - $query_args = array_merge($args_to_merge, $query_args); |
|
| 2872 | - } |
|
| 2873 | - $this->_process_notices($query_args); |
|
| 2874 | - // generate redirect url |
|
| 2875 | - // if redirecting to anything other than the main page, add a nonce |
|
| 2876 | - if (isset($query_args['action'])) { |
|
| 2877 | - // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
|
| 2878 | - $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 2879 | - } |
|
| 2880 | - //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
|
| 2881 | - do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
| 2882 | - $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
| 2883 | - // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
|
| 2884 | - if (defined('DOING_AJAX')) { |
|
| 2885 | - $default_data = array( |
|
| 2886 | - 'close' => true, |
|
| 2887 | - 'redirect_url' => $redirect_url, |
|
| 2888 | - 'where' => 'main', |
|
| 2889 | - 'what' => 'append', |
|
| 2890 | - ); |
|
| 2891 | - $this->_template_args['success'] = $success; |
|
| 2892 | - $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
| 2893 | - $this->_return_json(); |
|
| 2894 | - } |
|
| 2895 | - wp_safe_redirect($redirect_url); |
|
| 2896 | - exit(); |
|
| 2897 | - } |
|
| 2898 | - |
|
| 2899 | - |
|
| 2900 | - |
|
| 2901 | - /** |
|
| 2902 | - * process any notices before redirecting (or returning ajax request) |
|
| 2903 | - * This method sets the $this->_template_args['notices'] attribute; |
|
| 2904 | - * |
|
| 2905 | - * @param array $query_args any query args that need to be used for notice transient ('action') |
|
| 2906 | - * @param bool $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet. |
|
| 2907 | - * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
|
| 2908 | - * @return void |
|
| 2909 | - */ |
|
| 2910 | - protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true) |
|
| 2911 | - { |
|
| 2912 | - //first let's set individual error properties if doing_ajax and the properties aren't already set. |
|
| 2913 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2914 | - $notices = EE_Error::get_notices(false); |
|
| 2915 | - if (empty($this->_template_args['success'])) { |
|
| 2916 | - $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
| 2917 | - } |
|
| 2918 | - if (empty($this->_template_args['errors'])) { |
|
| 2919 | - $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
| 2920 | - } |
|
| 2921 | - if (empty($this->_template_args['attention'])) { |
|
| 2922 | - $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
| 2923 | - } |
|
| 2924 | - } |
|
| 2925 | - $this->_template_args['notices'] = EE_Error::get_notices(); |
|
| 2926 | - //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
|
| 2927 | - if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
| 2928 | - $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
| 2929 | - $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify); |
|
| 2930 | - } |
|
| 2931 | - } |
|
| 2932 | - |
|
| 2933 | - |
|
| 2934 | - |
|
| 2935 | - /** |
|
| 2936 | - * get_action_link_or_button |
|
| 2937 | - * returns the button html for adding, editing, or deleting an item (depending on given type) |
|
| 2938 | - * |
|
| 2939 | - * @param string $action use this to indicate which action the url is generated with. |
|
| 2940 | - * @param string $type accepted strings must be defined in the $_labels['button'] array(as the key) property. |
|
| 2941 | - * @param array $extra_request if the button requires extra params you can include them in $key=>$value pairs. |
|
| 2942 | - * @param string $class Use this to give the class for the button. Defaults to 'button-primary' |
|
| 2943 | - * @param string $base_url If this is not provided |
|
| 2944 | - * the _admin_base_url will be used as the default for the button base_url. |
|
| 2945 | - * Otherwise this value will be used. |
|
| 2946 | - * @param bool $exclude_nonce If true then no nonce will be in the generated button link. |
|
| 2947 | - * @return string |
|
| 2948 | - * @throws \EE_Error |
|
| 2949 | - */ |
|
| 2950 | - public function get_action_link_or_button( |
|
| 2951 | - $action, |
|
| 2952 | - $type = 'add', |
|
| 2953 | - $extra_request = array(), |
|
| 2954 | - $class = 'button-primary', |
|
| 2955 | - $base_url = '', |
|
| 2956 | - $exclude_nonce = false |
|
| 2957 | - ) { |
|
| 2958 | - //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
|
| 2959 | - if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
| 2960 | - throw new EE_Error( |
|
| 2961 | - sprintf( |
|
| 2962 | - __( |
|
| 2963 | - 'There is no page route for given action for the button. This action was given: %s', |
|
| 2964 | - 'event_espresso' |
|
| 2965 | - ), |
|
| 2966 | - $action |
|
| 2967 | - ) |
|
| 2968 | - ); |
|
| 2969 | - } |
|
| 2970 | - if ( ! isset($this->_labels['buttons'][$type])) { |
|
| 2971 | - throw new EE_Error( |
|
| 2972 | - sprintf( |
|
| 2973 | - __( |
|
| 2974 | - 'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', |
|
| 2975 | - 'event_espresso' |
|
| 2976 | - ), |
|
| 2977 | - $type |
|
| 2978 | - ) |
|
| 2979 | - ); |
|
| 2980 | - } |
|
| 2981 | - //finally check user access for this button. |
|
| 2982 | - $has_access = $this->check_user_access($action, true); |
|
| 2983 | - if ( ! $has_access) { |
|
| 2984 | - return ''; |
|
| 2985 | - } |
|
| 2986 | - $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
|
| 2987 | - $query_args = array( |
|
| 2988 | - 'action' => $action, |
|
| 2989 | - ); |
|
| 2990 | - //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
|
| 2991 | - if ( ! empty($extra_request)) { |
|
| 2992 | - $query_args = array_merge($extra_request, $query_args); |
|
| 2993 | - } |
|
| 2994 | - $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
| 2995 | - return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
| 2996 | - } |
|
| 2997 | - |
|
| 2998 | - |
|
| 2999 | - |
|
| 3000 | - /** |
|
| 3001 | - * _per_page_screen_option |
|
| 3002 | - * Utility function for adding in a per_page_option in the screen_options_dropdown. |
|
| 3003 | - * |
|
| 3004 | - * @return void |
|
| 3005 | - */ |
|
| 3006 | - protected function _per_page_screen_option() |
|
| 3007 | - { |
|
| 3008 | - $option = 'per_page'; |
|
| 3009 | - $args = array( |
|
| 3010 | - 'label' => $this->_admin_page_title, |
|
| 3011 | - 'default' => 10, |
|
| 3012 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
| 3013 | - ); |
|
| 3014 | - //ONLY add the screen option if the user has access to it. |
|
| 3015 | - if ($this->check_user_access($this->_current_view, true)) { |
|
| 3016 | - add_screen_option($option, $args); |
|
| 3017 | - } |
|
| 3018 | - } |
|
| 3019 | - |
|
| 3020 | - |
|
| 3021 | - |
|
| 3022 | - /** |
|
| 3023 | - * set_per_page_screen_option |
|
| 3024 | - * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page. |
|
| 3025 | - * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu. |
|
| 3026 | - * |
|
| 3027 | - * @access private |
|
| 3028 | - * @return void |
|
| 3029 | - */ |
|
| 3030 | - private function _set_per_page_screen_options() |
|
| 3031 | - { |
|
| 3032 | - if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
| 3033 | - check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
| 3034 | - if ( ! $user = wp_get_current_user()) { |
|
| 3035 | - return; |
|
| 3036 | - } |
|
| 3037 | - $option = $_POST['wp_screen_options']['option']; |
|
| 3038 | - $value = $_POST['wp_screen_options']['value']; |
|
| 3039 | - if ($option != sanitize_key($option)) { |
|
| 3040 | - return; |
|
| 3041 | - } |
|
| 3042 | - $map_option = $option; |
|
| 3043 | - $option = str_replace('-', '_', $option); |
|
| 3044 | - switch ($map_option) { |
|
| 3045 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
| 3046 | - $value = (int)$value; |
|
| 3047 | - if ($value < 1 || $value > 999) { |
|
| 3048 | - return; |
|
| 3049 | - } |
|
| 3050 | - break; |
|
| 3051 | - default: |
|
| 3052 | - $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
| 3053 | - if (false === $value) { |
|
| 3054 | - return; |
|
| 3055 | - } |
|
| 3056 | - break; |
|
| 3057 | - } |
|
| 3058 | - update_user_meta($user->ID, $option, $value); |
|
| 3059 | - wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
| 3060 | - exit; |
|
| 3061 | - } |
|
| 3062 | - } |
|
| 3063 | - |
|
| 3064 | - |
|
| 3065 | - |
|
| 3066 | - /** |
|
| 3067 | - * This just allows for setting the $_template_args property if it needs to be set outside the object |
|
| 3068 | - * |
|
| 3069 | - * @param array $data array that will be assigned to template args. |
|
| 3070 | - */ |
|
| 3071 | - public function set_template_args($data) |
|
| 3072 | - { |
|
| 3073 | - $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
| 3074 | - } |
|
| 3075 | - |
|
| 3076 | - |
|
| 3077 | - |
|
| 3078 | - /** |
|
| 3079 | - * This makes available the WP transient system for temporarily moving data between routes |
|
| 3080 | - * |
|
| 3081 | - * @access protected |
|
| 3082 | - * @param string $route the route that should receive the transient |
|
| 3083 | - * @param array $data the data that gets sent |
|
| 3084 | - * @param bool $notices If this is for notices then we use this to indicate so, otherwise its just a normal route transient. |
|
| 3085 | - * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
|
| 3086 | - * @return void |
|
| 3087 | - */ |
|
| 3088 | - protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false) |
|
| 3089 | - { |
|
| 3090 | - $user_id = get_current_user_id(); |
|
| 3091 | - if ( ! $skip_route_verify) { |
|
| 3092 | - $this->_verify_route($route); |
|
| 3093 | - } |
|
| 3094 | - //now let's set the string for what kind of transient we're setting |
|
| 3095 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3096 | - $data = $notices ? array('notices' => $data) : $data; |
|
| 3097 | - //is there already a transient for this route? If there is then let's ADD to that transient |
|
| 3098 | - $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3099 | - if ($existing) { |
|
| 3100 | - $data = array_merge((array)$data, (array)$existing); |
|
| 3101 | - } |
|
| 3102 | - if (is_multisite() && is_network_admin()) { |
|
| 3103 | - set_site_transient($transient, $data, 8); |
|
| 3104 | - } else { |
|
| 3105 | - set_transient($transient, $data, 8); |
|
| 3106 | - } |
|
| 3107 | - } |
|
| 3108 | - |
|
| 3109 | - |
|
| 3110 | - |
|
| 3111 | - /** |
|
| 3112 | - * this retrieves the temporary transient that has been set for moving data between routes. |
|
| 3113 | - * |
|
| 3114 | - * @param bool $notices true we get notices transient. False we just return normal route transient |
|
| 3115 | - * @return mixed data |
|
| 3116 | - */ |
|
| 3117 | - protected function _get_transient($notices = false, $route = false) |
|
| 3118 | - { |
|
| 3119 | - $user_id = get_current_user_id(); |
|
| 3120 | - $route = ! $route ? $this->_req_action : $route; |
|
| 3121 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3122 | - $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3123 | - //delete transient after retrieval (just in case it hasn't expired); |
|
| 3124 | - if (is_multisite() && is_network_admin()) { |
|
| 3125 | - delete_site_transient($transient); |
|
| 3126 | - } else { |
|
| 3127 | - delete_transient($transient); |
|
| 3128 | - } |
|
| 3129 | - return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
| 3130 | - } |
|
| 3131 | - |
|
| 3132 | - |
|
| 3133 | - |
|
| 3134 | - /** |
|
| 3135 | - * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later. |
|
| 3136 | - * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.) |
|
| 3137 | - * |
|
| 3138 | - * @return void |
|
| 3139 | - */ |
|
| 3140 | - protected function _transient_garbage_collection() |
|
| 3141 | - { |
|
| 3142 | - global $wpdb; |
|
| 3143 | - //retrieve all existing transients |
|
| 3144 | - $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
|
| 3145 | - if ($results = $wpdb->get_results($query)) { |
|
| 3146 | - foreach ($results as $result) { |
|
| 3147 | - $transient = str_replace('_transient_', '', $result->option_name); |
|
| 3148 | - get_transient($transient); |
|
| 3149 | - if (is_multisite() && is_network_admin()) { |
|
| 3150 | - get_site_transient($transient); |
|
| 3151 | - } |
|
| 3152 | - } |
|
| 3153 | - } |
|
| 3154 | - } |
|
| 3155 | - |
|
| 3156 | - |
|
| 3157 | - |
|
| 3158 | - /** |
|
| 3159 | - * get_view |
|
| 3160 | - * |
|
| 3161 | - * @access public |
|
| 3162 | - * @return string content of _view property |
|
| 3163 | - */ |
|
| 3164 | - public function get_view() |
|
| 3165 | - { |
|
| 3166 | - return $this->_view; |
|
| 3167 | - } |
|
| 3168 | - |
|
| 3169 | - |
|
| 3170 | - |
|
| 3171 | - /** |
|
| 3172 | - * getter for the protected $_views property |
|
| 3173 | - * |
|
| 3174 | - * @return array |
|
| 3175 | - */ |
|
| 3176 | - public function get_views() |
|
| 3177 | - { |
|
| 3178 | - return $this->_views; |
|
| 3179 | - } |
|
| 3180 | - |
|
| 3181 | - |
|
| 3182 | - |
|
| 3183 | - /** |
|
| 3184 | - * get_current_page |
|
| 3185 | - * |
|
| 3186 | - * @access public |
|
| 3187 | - * @return string _current_page property value |
|
| 3188 | - */ |
|
| 3189 | - public function get_current_page() |
|
| 3190 | - { |
|
| 3191 | - return $this->_current_page; |
|
| 3192 | - } |
|
| 3193 | - |
|
| 3194 | - |
|
| 3195 | - |
|
| 3196 | - /** |
|
| 3197 | - * get_current_view |
|
| 3198 | - * |
|
| 3199 | - * @access public |
|
| 3200 | - * @return string _current_view property value |
|
| 3201 | - */ |
|
| 3202 | - public function get_current_view() |
|
| 3203 | - { |
|
| 3204 | - return $this->_current_view; |
|
| 3205 | - } |
|
| 3206 | - |
|
| 3207 | - |
|
| 3208 | - |
|
| 3209 | - /** |
|
| 3210 | - * get_current_screen |
|
| 3211 | - * |
|
| 3212 | - * @access public |
|
| 3213 | - * @return object The current WP_Screen object |
|
| 3214 | - */ |
|
| 3215 | - public function get_current_screen() |
|
| 3216 | - { |
|
| 3217 | - return $this->_current_screen; |
|
| 3218 | - } |
|
| 3219 | - |
|
| 3220 | - |
|
| 3221 | - |
|
| 3222 | - /** |
|
| 3223 | - * get_current_page_view_url |
|
| 3224 | - * |
|
| 3225 | - * @access public |
|
| 3226 | - * @return string This returns the url for the current_page_view. |
|
| 3227 | - */ |
|
| 3228 | - public function get_current_page_view_url() |
|
| 3229 | - { |
|
| 3230 | - return $this->_current_page_view_url; |
|
| 3231 | - } |
|
| 3232 | - |
|
| 3233 | - |
|
| 3234 | - |
|
| 3235 | - /** |
|
| 3236 | - * just returns the _req_data property |
|
| 3237 | - * |
|
| 3238 | - * @return array |
|
| 3239 | - */ |
|
| 3240 | - public function get_request_data() |
|
| 3241 | - { |
|
| 3242 | - return $this->_req_data; |
|
| 3243 | - } |
|
| 3244 | - |
|
| 3245 | - |
|
| 3246 | - |
|
| 3247 | - /** |
|
| 3248 | - * returns the _req_data protected property |
|
| 3249 | - * |
|
| 3250 | - * @return string |
|
| 3251 | - */ |
|
| 3252 | - public function get_req_action() |
|
| 3253 | - { |
|
| 3254 | - return $this->_req_action; |
|
| 3255 | - } |
|
| 3256 | - |
|
| 3257 | - |
|
| 3258 | - |
|
| 3259 | - /** |
|
| 3260 | - * @return bool value of $_is_caf property |
|
| 3261 | - */ |
|
| 3262 | - public function is_caf() |
|
| 3263 | - { |
|
| 3264 | - return $this->_is_caf; |
|
| 3265 | - } |
|
| 3266 | - |
|
| 3267 | - |
|
| 3268 | - |
|
| 3269 | - /** |
|
| 3270 | - * @return mixed |
|
| 3271 | - */ |
|
| 3272 | - public function default_espresso_metaboxes() |
|
| 3273 | - { |
|
| 3274 | - return $this->_default_espresso_metaboxes; |
|
| 3275 | - } |
|
| 3276 | - |
|
| 3277 | - |
|
| 3278 | - |
|
| 3279 | - /** |
|
| 3280 | - * @return mixed |
|
| 3281 | - */ |
|
| 3282 | - public function admin_base_url() |
|
| 3283 | - { |
|
| 3284 | - return $this->_admin_base_url; |
|
| 3285 | - } |
|
| 3286 | - |
|
| 3287 | - |
|
| 3288 | - |
|
| 3289 | - /** |
|
| 3290 | - * @return mixed |
|
| 3291 | - */ |
|
| 3292 | - public function wp_page_slug() |
|
| 3293 | - { |
|
| 3294 | - return $this->_wp_page_slug; |
|
| 3295 | - } |
|
| 3296 | - |
|
| 3297 | - |
|
| 3298 | - |
|
| 3299 | - /** |
|
| 3300 | - * updates espresso configuration settings |
|
| 3301 | - * |
|
| 3302 | - * @access protected |
|
| 3303 | - * @param string $tab |
|
| 3304 | - * @param EE_Config_Base|EE_Config $config |
|
| 3305 | - * @param string $file file where error occurred |
|
| 3306 | - * @param string $func function where error occurred |
|
| 3307 | - * @param string $line line no where error occurred |
|
| 3308 | - * @return boolean |
|
| 3309 | - */ |
|
| 3310 | - protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') |
|
| 3311 | - { |
|
| 3312 | - //remove any options that are NOT going to be saved with the config settings. |
|
| 3313 | - if (isset($config->core->ee_ueip_optin)) { |
|
| 3314 | - $config->core->ee_ueip_has_notified = true; |
|
| 3315 | - // TODO: remove the following two lines and make sure values are migrated from 3.1 |
|
| 3316 | - update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
| 3317 | - update_option('ee_ueip_has_notified', true); |
|
| 3318 | - } |
|
| 3319 | - // and save it (note we're also doing the network save here) |
|
| 3320 | - $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true; |
|
| 3321 | - $config_saved = EE_Config::instance()->update_espresso_config(false, false); |
|
| 3322 | - if ($config_saved && $net_saved) { |
|
| 3323 | - EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
| 3324 | - return true; |
|
| 3325 | - } else { |
|
| 3326 | - EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
| 3327 | - return false; |
|
| 3328 | - } |
|
| 3329 | - } |
|
| 3330 | - |
|
| 3331 | - |
|
| 3332 | - |
|
| 3333 | - /** |
|
| 3334 | - * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
|
| 3335 | - * |
|
| 3336 | - * @return array |
|
| 3337 | - */ |
|
| 3338 | - public function get_yes_no_values() |
|
| 3339 | - { |
|
| 3340 | - return $this->_yes_no_values; |
|
| 3341 | - } |
|
| 3342 | - |
|
| 3343 | - |
|
| 3344 | - |
|
| 3345 | - protected function _get_dir() |
|
| 3346 | - { |
|
| 3347 | - $reflector = new ReflectionClass(get_class($this)); |
|
| 3348 | - return dirname($reflector->getFileName()); |
|
| 3349 | - } |
|
| 3350 | - |
|
| 3351 | - |
|
| 3352 | - |
|
| 3353 | - /** |
|
| 3354 | - * A helper for getting a "next link". |
|
| 3355 | - * |
|
| 3356 | - * @param string $url The url to link to |
|
| 3357 | - * @param string $class The class to use. |
|
| 3358 | - * @return string |
|
| 3359 | - */ |
|
| 3360 | - protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
|
| 3361 | - { |
|
| 3362 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3363 | - } |
|
| 3364 | - |
|
| 3365 | - |
|
| 3366 | - |
|
| 3367 | - /** |
|
| 3368 | - * A helper for getting a "previous link". |
|
| 3369 | - * |
|
| 3370 | - * @param string $url The url to link to |
|
| 3371 | - * @param string $class The class to use. |
|
| 3372 | - * @return string |
|
| 3373 | - */ |
|
| 3374 | - protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
|
| 3375 | - { |
|
| 3376 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3377 | - } |
|
| 3378 | - |
|
| 3379 | - |
|
| 3380 | - |
|
| 3381 | - |
|
| 3382 | - |
|
| 3383 | - |
|
| 3384 | - |
|
| 3385 | - //below are some messages related methods that should be available across the EE_Admin system. Note, these methods are NOT page specific |
|
| 3386 | - /** |
|
| 3387 | - * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data |
|
| 3388 | - * array. |
|
| 3389 | - * |
|
| 3390 | - * @return bool success/fail |
|
| 3391 | - */ |
|
| 3392 | - protected function _process_resend_registration() |
|
| 3393 | - { |
|
| 3394 | - $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
| 3395 | - do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
| 3396 | - return $this->_template_args['success']; |
|
| 3397 | - } |
|
| 3398 | - |
|
| 3399 | - |
|
| 3400 | - |
|
| 3401 | - /** |
|
| 3402 | - * This automatically processes any payment message notifications when manual payment has been applied. |
|
| 3403 | - * |
|
| 3404 | - * @access protected |
|
| 3405 | - * @param \EE_Payment $payment |
|
| 3406 | - * @return bool success/fail |
|
| 3407 | - */ |
|
| 3408 | - protected function _process_payment_notification(EE_Payment $payment) |
|
| 3409 | - { |
|
| 3410 | - add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
| 3411 | - do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
| 3412 | - $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
| 3413 | - return $this->_template_args['success']; |
|
| 3414 | - } |
|
| 2200 | + } |
|
| 2201 | + |
|
| 2202 | + |
|
| 2203 | + |
|
| 2204 | + /** |
|
| 2205 | + * facade for add_meta_box |
|
| 2206 | + * |
|
| 2207 | + * @param string $action where the metabox get's displayed |
|
| 2208 | + * @param string $title Title of Metabox (output in metabox header) |
|
| 2209 | + * @param string $callback If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here. |
|
| 2210 | + * @param array $callback_args an array of args supplied for the metabox |
|
| 2211 | + * @param string $column what metabox column |
|
| 2212 | + * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
|
| 2213 | + * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
|
| 2214 | + */ |
|
| 2215 | + public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) |
|
| 2216 | + { |
|
| 2217 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
| 2218 | + //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
|
| 2219 | + if (empty($callback_args) && $create_func) { |
|
| 2220 | + $callback_args = array( |
|
| 2221 | + 'template_path' => $this->_template_path, |
|
| 2222 | + 'template_args' => $this->_template_args, |
|
| 2223 | + ); |
|
| 2224 | + } |
|
| 2225 | + //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
|
| 2226 | + $call_back_func = $create_func ? create_function('$post, $metabox', |
|
| 2227 | + 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
|
| 2228 | + add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
| 2229 | + } |
|
| 2230 | + |
|
| 2231 | + |
|
| 2232 | + |
|
| 2233 | + /** |
|
| 2234 | + * generates HTML wrapper for and admin details page that contains metaboxes in columns |
|
| 2235 | + * |
|
| 2236 | + * @return [type] [description] |
|
| 2237 | + */ |
|
| 2238 | + public function display_admin_page_with_metabox_columns() |
|
| 2239 | + { |
|
| 2240 | + $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
|
| 2241 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true); |
|
| 2242 | + //the final wrapper |
|
| 2243 | + $this->admin_page_wrapper(); |
|
| 2244 | + } |
|
| 2245 | + |
|
| 2246 | + |
|
| 2247 | + |
|
| 2248 | + /** |
|
| 2249 | + * generates HTML wrapper for an admin details page |
|
| 2250 | + * |
|
| 2251 | + * @access public |
|
| 2252 | + * @return void |
|
| 2253 | + */ |
|
| 2254 | + public function display_admin_page_with_sidebar() |
|
| 2255 | + { |
|
| 2256 | + $this->_display_admin_page(true); |
|
| 2257 | + } |
|
| 2258 | + |
|
| 2259 | + |
|
| 2260 | + |
|
| 2261 | + /** |
|
| 2262 | + * generates HTML wrapper for an admin details page (except no sidebar) |
|
| 2263 | + * |
|
| 2264 | + * @access public |
|
| 2265 | + * @return void |
|
| 2266 | + */ |
|
| 2267 | + public function display_admin_page_with_no_sidebar() |
|
| 2268 | + { |
|
| 2269 | + $this->_display_admin_page(); |
|
| 2270 | + } |
|
| 2271 | + |
|
| 2272 | + |
|
| 2273 | + |
|
| 2274 | + /** |
|
| 2275 | + * generates HTML wrapper for an EE about admin page (no sidebar) |
|
| 2276 | + * |
|
| 2277 | + * @access public |
|
| 2278 | + * @return void |
|
| 2279 | + */ |
|
| 2280 | + public function display_about_admin_page() |
|
| 2281 | + { |
|
| 2282 | + $this->_display_admin_page(false, true); |
|
| 2283 | + } |
|
| 2284 | + |
|
| 2285 | + |
|
| 2286 | + |
|
| 2287 | + /** |
|
| 2288 | + * display_admin_page |
|
| 2289 | + * contains the code for actually displaying an admin page |
|
| 2290 | + * |
|
| 2291 | + * @access private |
|
| 2292 | + * @param boolean $sidebar true with sidebar, false without |
|
| 2293 | + * @param boolean $about use the about admin wrapper instead of the default. |
|
| 2294 | + * @return void |
|
| 2295 | + */ |
|
| 2296 | + private function _display_admin_page($sidebar = false, $about = false) |
|
| 2297 | + { |
|
| 2298 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2299 | + //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
|
| 2300 | + do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
| 2301 | + // set current wp page slug - looks like: event-espresso_page_event_categories |
|
| 2302 | + // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
|
| 2303 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 2304 | + $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route |
|
| 2305 | + ? 'poststuff' |
|
| 2306 | + : 'espresso-default-admin'; |
|
| 2307 | + $template_path = $sidebar |
|
| 2308 | + ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
|
| 2309 | + : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2310 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2311 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2312 | + } |
|
| 2313 | + $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
| 2314 | + $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
| 2315 | + $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
|
| 2316 | + $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
|
| 2317 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2318 | + // the final template wrapper |
|
| 2319 | + $this->admin_page_wrapper($about); |
|
| 2320 | + } |
|
| 2321 | + |
|
| 2322 | + |
|
| 2323 | + |
|
| 2324 | + /** |
|
| 2325 | + * This is used to display caf preview pages. |
|
| 2326 | + * |
|
| 2327 | + * @since 4.3.2 |
|
| 2328 | + * @param string $utm_campaign_source what is the key used for google analytics link |
|
| 2329 | + * @param bool $display_sidebar whether to use the sidebar template or the full template for the page. TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar. |
|
| 2330 | + * @return void |
|
| 2331 | + * @throws \EE_Error |
|
| 2332 | + */ |
|
| 2333 | + public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true) |
|
| 2334 | + { |
|
| 2335 | + //let's generate a default preview action button if there isn't one already present. |
|
| 2336 | + $this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso'); |
|
| 2337 | + $buy_now_url = add_query_arg( |
|
| 2338 | + array( |
|
| 2339 | + 'ee_ver' => 'ee4', |
|
| 2340 | + 'utm_source' => 'ee4_plugin_admin', |
|
| 2341 | + 'utm_medium' => 'link', |
|
| 2342 | + 'utm_campaign' => $utm_campaign_source, |
|
| 2343 | + 'utm_content' => 'buy_now_button', |
|
| 2344 | + ), |
|
| 2345 | + 'http://eventespresso.com/pricing/' |
|
| 2346 | + ); |
|
| 2347 | + $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
| 2348 | + ? $this->get_action_link_or_button( |
|
| 2349 | + '', |
|
| 2350 | + 'buy_now', |
|
| 2351 | + array(), |
|
| 2352 | + 'button-primary button-large', |
|
| 2353 | + $buy_now_url, |
|
| 2354 | + true |
|
| 2355 | + ) |
|
| 2356 | + : $this->_template_args['preview_action_button']; |
|
| 2357 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
| 2358 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 2359 | + $template_path, |
|
| 2360 | + $this->_template_args, |
|
| 2361 | + true |
|
| 2362 | + ); |
|
| 2363 | + $this->_display_admin_page($display_sidebar); |
|
| 2364 | + } |
|
| 2365 | + |
|
| 2366 | + |
|
| 2367 | + |
|
| 2368 | + /** |
|
| 2369 | + * display_admin_list_table_page_with_sidebar |
|
| 2370 | + * generates HTML wrapper for an admin_page with list_table |
|
| 2371 | + * |
|
| 2372 | + * @access public |
|
| 2373 | + * @return void |
|
| 2374 | + */ |
|
| 2375 | + public function display_admin_list_table_page_with_sidebar() |
|
| 2376 | + { |
|
| 2377 | + $this->_display_admin_list_table_page(true); |
|
| 2378 | + } |
|
| 2379 | + |
|
| 2380 | + |
|
| 2381 | + |
|
| 2382 | + /** |
|
| 2383 | + * display_admin_list_table_page_with_no_sidebar |
|
| 2384 | + * generates HTML wrapper for an admin_page with list_table (but with no sidebar) |
|
| 2385 | + * |
|
| 2386 | + * @access public |
|
| 2387 | + * @return void |
|
| 2388 | + */ |
|
| 2389 | + public function display_admin_list_table_page_with_no_sidebar() |
|
| 2390 | + { |
|
| 2391 | + $this->_display_admin_list_table_page(); |
|
| 2392 | + } |
|
| 2393 | + |
|
| 2394 | + |
|
| 2395 | + |
|
| 2396 | + /** |
|
| 2397 | + * generates html wrapper for an admin_list_table page |
|
| 2398 | + * |
|
| 2399 | + * @access private |
|
| 2400 | + * @param boolean $sidebar whether to display with sidebar or not. |
|
| 2401 | + * @return void |
|
| 2402 | + */ |
|
| 2403 | + private function _display_admin_list_table_page($sidebar = false) |
|
| 2404 | + { |
|
| 2405 | + //setup search attributes |
|
| 2406 | + $this->_set_search_attributes(); |
|
| 2407 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
| 2408 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
| 2409 | + $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
| 2410 | + ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
| 2411 | + : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
| 2412 | + $this->_template_args['list_table'] = $this->_list_table_object; |
|
| 2413 | + $this->_template_args['current_route'] = $this->_req_action; |
|
| 2414 | + $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
| 2415 | + $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
|
| 2416 | + if ( ! empty($ajax_sorting_callback)) { |
|
| 2417 | + $sortable_list_table_form_fields = wp_nonce_field( |
|
| 2418 | + $ajax_sorting_callback . '_nonce', |
|
| 2419 | + $ajax_sorting_callback . '_nonce', |
|
| 2420 | + false, |
|
| 2421 | + false |
|
| 2422 | + ); |
|
| 2423 | + // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
|
| 2424 | + // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
|
| 2425 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
| 2426 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
| 2427 | + } else { |
|
| 2428 | + $sortable_list_table_form_fields = ''; |
|
| 2429 | + } |
|
| 2430 | + $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
|
| 2431 | + $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
| 2432 | + $nonce_ref = $this->_req_action . '_nonce'; |
|
| 2433 | + $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
| 2434 | + $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
|
| 2435 | + //display message about search results? |
|
| 2436 | + $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s']) |
|
| 2437 | + ? '<p class="ee-search-results">' . sprintf( |
|
| 2438 | + esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'), |
|
| 2439 | + trim($this->_req_data['s'], '%') |
|
| 2440 | + ) . '</p>' |
|
| 2441 | + : ''; |
|
| 2442 | + // filter before_list_table template arg |
|
| 2443 | + $this->_template_args['before_list_table'] = apply_filters( |
|
| 2444 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
|
| 2445 | + $this->_template_args['before_list_table'], |
|
| 2446 | + $this->page_slug, |
|
| 2447 | + $this->_req_data, |
|
| 2448 | + $this->_req_action |
|
| 2449 | + ); |
|
| 2450 | + // convert to array and filter again |
|
| 2451 | + // arrays are easier to inject new items in a specific location, |
|
| 2452 | + // but would not be backwards compatible, so we have to add a new filter |
|
| 2453 | + $this->_template_args['before_list_table'] = implode( |
|
| 2454 | + " \n", |
|
| 2455 | + (array) apply_filters( |
|
| 2456 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array', |
|
| 2457 | + (array) $this->_template_args['before_list_table'], |
|
| 2458 | + $this->page_slug, |
|
| 2459 | + $this->_req_data, |
|
| 2460 | + $this->_req_action |
|
| 2461 | + ) |
|
| 2462 | + ); |
|
| 2463 | + // filter after_list_table template arg |
|
| 2464 | + $this->_template_args['after_list_table'] = apply_filters( |
|
| 2465 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg', |
|
| 2466 | + $this->_template_args['after_list_table'], |
|
| 2467 | + $this->page_slug, |
|
| 2468 | + $this->_req_data, |
|
| 2469 | + $this->_req_action |
|
| 2470 | + ); |
|
| 2471 | + // convert to array and filter again |
|
| 2472 | + // arrays are easier to inject new items in a specific location, |
|
| 2473 | + // but would not be backwards compatible, so we have to add a new filter |
|
| 2474 | + $this->_template_args['after_list_table'] = implode( |
|
| 2475 | + " \n", |
|
| 2476 | + (array) apply_filters( |
|
| 2477 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
|
| 2478 | + (array) $this->_template_args['after_list_table'], |
|
| 2479 | + $this->page_slug, |
|
| 2480 | + $this->_req_data, |
|
| 2481 | + $this->_req_action |
|
| 2482 | + ) |
|
| 2483 | + ); |
|
| 2484 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 2485 | + $template_path, |
|
| 2486 | + $this->_template_args, |
|
| 2487 | + true |
|
| 2488 | + ); |
|
| 2489 | + // the final template wrapper |
|
| 2490 | + if ($sidebar) { |
|
| 2491 | + $this->display_admin_page_with_sidebar(); |
|
| 2492 | + } else { |
|
| 2493 | + $this->display_admin_page_with_no_sidebar(); |
|
| 2494 | + } |
|
| 2495 | + } |
|
| 2496 | + |
|
| 2497 | + |
|
| 2498 | + |
|
| 2499 | + /** |
|
| 2500 | + * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend. |
|
| 2501 | + * $items are expected in an array in the following format: |
|
| 2502 | + * $legend_items = array( |
|
| 2503 | + * 'item_id' => array( |
|
| 2504 | + * 'icon' => 'http://url_to_icon_being_described.png', |
|
| 2505 | + * 'desc' => __('localized description of item'); |
|
| 2506 | + * ) |
|
| 2507 | + * ); |
|
| 2508 | + * |
|
| 2509 | + * @param array $items see above for format of array |
|
| 2510 | + * @return string html string of legend |
|
| 2511 | + */ |
|
| 2512 | + protected function _display_legend($items) |
|
| 2513 | + { |
|
| 2514 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
| 2515 | + $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
| 2516 | + return EEH_Template::display_template($legend_template, $this->_template_args, true); |
|
| 2517 | + } |
|
| 2518 | + |
|
| 2519 | + |
|
| 2520 | + |
|
| 2521 | + /** |
|
| 2522 | + * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect |
|
| 2523 | + * |
|
| 2524 | + * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed. |
|
| 2525 | + * The returned json object is created from an array in the following format: |
|
| 2526 | + * array( |
|
| 2527 | + * 'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early), |
|
| 2528 | + * 'success' => FALSE, //(default FALSE) - contains any special success message. |
|
| 2529 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
| 2530 | + * 'content' => 'string can be html', //this is a string of formatted content (can be html) |
|
| 2531 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any |
|
| 2532 | + * specific template args that might be included in here) |
|
| 2533 | + * ) |
|
| 2534 | + * The json object is populated by whatever is set in the $_template_args property. |
|
| 2535 | + * @return void |
|
| 2536 | + */ |
|
| 2537 | + protected function _return_json($sticky_notices = false) |
|
| 2538 | + { |
|
| 2539 | + //make sure any EE_Error notices have been handled. |
|
| 2540 | + $this->_process_notices(array(), true, $sticky_notices); |
|
| 2541 | + $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
| 2542 | + unset($this->_template_args['data']); |
|
| 2543 | + $json = array( |
|
| 2544 | + 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
| 2545 | + 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
| 2546 | + 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
| 2547 | + 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
| 2548 | + 'notices' => EE_Error::get_notices(), |
|
| 2549 | + 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
| 2550 | + 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
| 2551 | + 'isEEajax' => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
| 2552 | + ); |
|
| 2553 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
| 2554 | + if (null === error_get_last() || ! headers_sent()) { |
|
| 2555 | + header('Content-Type: application/json; charset=UTF-8'); |
|
| 2556 | + } |
|
| 2557 | + echo wp_json_encode($json); |
|
| 2558 | + |
|
| 2559 | + exit(); |
|
| 2560 | + } |
|
| 2561 | + |
|
| 2562 | + |
|
| 2563 | + |
|
| 2564 | + /** |
|
| 2565 | + * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax) |
|
| 2566 | + * |
|
| 2567 | + * @return void |
|
| 2568 | + * @throws EE_Error |
|
| 2569 | + */ |
|
| 2570 | + public function return_json() |
|
| 2571 | + { |
|
| 2572 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2573 | + $this->_return_json(); |
|
| 2574 | + } else { |
|
| 2575 | + throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
| 2576 | + } |
|
| 2577 | + } |
|
| 2578 | + |
|
| 2579 | + |
|
| 2580 | + |
|
| 2581 | + /** |
|
| 2582 | + * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property. |
|
| 2583 | + * |
|
| 2584 | + * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child |
|
| 2585 | + * @access public |
|
| 2586 | + */ |
|
| 2587 | + public function set_hook_object(EE_Admin_Hooks $hook_obj) |
|
| 2588 | + { |
|
| 2589 | + $this->_hook_obj = $hook_obj; |
|
| 2590 | + } |
|
| 2591 | + |
|
| 2592 | + |
|
| 2593 | + |
|
| 2594 | + /** |
|
| 2595 | + * generates HTML wrapper with Tabbed nav for an admin page |
|
| 2596 | + * |
|
| 2597 | + * @access public |
|
| 2598 | + * @param boolean $about whether to use the special about page wrapper or default. |
|
| 2599 | + * @return void |
|
| 2600 | + */ |
|
| 2601 | + public function admin_page_wrapper($about = false) |
|
| 2602 | + { |
|
| 2603 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2604 | + $this->_nav_tabs = $this->_get_main_nav_tabs(); |
|
| 2605 | + $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
|
| 2606 | + $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
|
| 2607 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2608 | + isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
| 2609 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2610 | + isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
| 2611 | + $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
|
| 2612 | + // load settings page wrapper template |
|
| 2613 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
| 2614 | + //about page? |
|
| 2615 | + $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
| 2616 | + if (defined('DOING_AJAX')) { |
|
| 2617 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
| 2618 | + $this->_return_json(); |
|
| 2619 | + } else { |
|
| 2620 | + EEH_Template::display_template($template_path, $this->_template_args); |
|
| 2621 | + } |
|
| 2622 | + } |
|
| 2623 | + |
|
| 2624 | + |
|
| 2625 | + |
|
| 2626 | + /** |
|
| 2627 | + * This returns the admin_nav tabs html using the configuration in the _nav_tabs property |
|
| 2628 | + * |
|
| 2629 | + * @return string html |
|
| 2630 | + */ |
|
| 2631 | + protected function _get_main_nav_tabs() |
|
| 2632 | + { |
|
| 2633 | + //let's generate the html using the EEH_Tabbed_Content helper. We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array) |
|
| 2634 | + return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs); |
|
| 2635 | + } |
|
| 2636 | + |
|
| 2637 | + |
|
| 2638 | + |
|
| 2639 | + /** |
|
| 2640 | + * sort nav tabs |
|
| 2641 | + * |
|
| 2642 | + * @access public |
|
| 2643 | + * @param $a |
|
| 2644 | + * @param $b |
|
| 2645 | + * @return int |
|
| 2646 | + */ |
|
| 2647 | + private function _sort_nav_tabs($a, $b) |
|
| 2648 | + { |
|
| 2649 | + if ($a['order'] == $b['order']) { |
|
| 2650 | + return 0; |
|
| 2651 | + } |
|
| 2652 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
| 2653 | + } |
|
| 2654 | + |
|
| 2655 | + |
|
| 2656 | + |
|
| 2657 | + /** |
|
| 2658 | + * generates HTML for the forms used on admin pages |
|
| 2659 | + * |
|
| 2660 | + * @access protected |
|
| 2661 | + * @param array $input_vars - array of input field details |
|
| 2662 | + * @param string $generator (options are 'string' or 'array', basically use this to indicate which generator to use) |
|
| 2663 | + * @return string |
|
| 2664 | + * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
|
| 2665 | + * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
|
| 2666 | + */ |
|
| 2667 | + protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false) |
|
| 2668 | + { |
|
| 2669 | + $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
|
| 2670 | + return $content; |
|
| 2671 | + } |
|
| 2672 | + |
|
| 2673 | + |
|
| 2674 | + |
|
| 2675 | + /** |
|
| 2676 | + * generates the "Save" and "Save & Close" buttons for edit forms |
|
| 2677 | + * |
|
| 2678 | + * @access protected |
|
| 2679 | + * @param bool $both if true then both buttons will be generated. If false then just the "Save & Close" button. |
|
| 2680 | + * @param array $text if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close') |
|
| 2681 | + * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
|
| 2682 | + * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
|
| 2683 | + */ |
|
| 2684 | + protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
|
| 2685 | + { |
|
| 2686 | + //make sure $text and $actions are in an array |
|
| 2687 | + $text = (array)$text; |
|
| 2688 | + $actions = (array)$actions; |
|
| 2689 | + $referrer_url = empty($referrer) ? '' : $referrer; |
|
| 2690 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
| 2691 | + : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
| 2692 | + $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
| 2693 | + $default_names = array('save', 'save_and_close'); |
|
| 2694 | + //add in a hidden index for the current page (so save and close redirects properly) |
|
| 2695 | + $this->_template_args['save_buttons'] = $referrer_url; |
|
| 2696 | + foreach ($button_text as $key => $button) { |
|
| 2697 | + $ref = $default_names[$key]; |
|
| 2698 | + $id = $this->_current_view . '_' . $ref; |
|
| 2699 | + $name = ! empty($actions) ? $actions[$key] : $ref; |
|
| 2700 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
| 2701 | + if ( ! $both) { |
|
| 2702 | + break; |
|
| 2703 | + } |
|
| 2704 | + } |
|
| 2705 | + } |
|
| 2706 | + |
|
| 2707 | + |
|
| 2708 | + |
|
| 2709 | + /** |
|
| 2710 | + * Wrapper for the protected function. Allows plugins/addons to call this to set the form tags. |
|
| 2711 | + * |
|
| 2712 | + * @see $this->_set_add_edit_form_tags() for details on params |
|
| 2713 | + * @since 4.6.0 |
|
| 2714 | + * @param string $route |
|
| 2715 | + * @param array $additional_hidden_fields |
|
| 2716 | + */ |
|
| 2717 | + public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
| 2718 | + { |
|
| 2719 | + $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
| 2720 | + } |
|
| 2721 | + |
|
| 2722 | + |
|
| 2723 | + |
|
| 2724 | + /** |
|
| 2725 | + * set form open and close tags on add/edit pages. |
|
| 2726 | + * |
|
| 2727 | + * @access protected |
|
| 2728 | + * @param string $route the route you want the form to direct to |
|
| 2729 | + * @param array $additional_hidden_fields any additional hidden fields required in the form header |
|
| 2730 | + * @return void |
|
| 2731 | + */ |
|
| 2732 | + protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
| 2733 | + { |
|
| 2734 | + if (empty($route)) { |
|
| 2735 | + $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
|
| 2736 | + $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
| 2737 | + EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2738 | + } |
|
| 2739 | + // open form |
|
| 2740 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
| 2741 | + // add nonce |
|
| 2742 | + $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
| 2743 | + // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
|
| 2744 | + $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
| 2745 | + // add REQUIRED form action |
|
| 2746 | + $hidden_fields = array( |
|
| 2747 | + 'action' => array('type' => 'hidden', 'value' => $route), |
|
| 2748 | + ); |
|
| 2749 | + // merge arrays |
|
| 2750 | + $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
| 2751 | + // generate form fields |
|
| 2752 | + $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
| 2753 | + // add fields to form |
|
| 2754 | + foreach ((array)$form_fields as $field_name => $form_field) { |
|
| 2755 | + $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
| 2756 | + } |
|
| 2757 | + // close form |
|
| 2758 | + $this->_template_args['after_admin_page_content'] = '</form>'; |
|
| 2759 | + } |
|
| 2760 | + |
|
| 2761 | + |
|
| 2762 | + |
|
| 2763 | + /** |
|
| 2764 | + * Public Wrapper for _redirect_after_action() method since its |
|
| 2765 | + * discovered it would be useful for external code to have access. |
|
| 2766 | + * |
|
| 2767 | + * @see EE_Admin_Page::_redirect_after_action() for params. |
|
| 2768 | + * @since 4.5.0 |
|
| 2769 | + */ |
|
| 2770 | + public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
| 2771 | + { |
|
| 2772 | + $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
| 2773 | + } |
|
| 2774 | + |
|
| 2775 | + |
|
| 2776 | + |
|
| 2777 | + /** |
|
| 2778 | + * _redirect_after_action |
|
| 2779 | + * |
|
| 2780 | + * @param int $success - whether success was for two or more records, or just one, or none |
|
| 2781 | + * @param string $what - what the action was performed on |
|
| 2782 | + * @param string $action_desc - what was done ie: updated, deleted, etc |
|
| 2783 | + * @param array $query_args - an array of query_args to be added to the URL to redirect to after the admin action is completed |
|
| 2784 | + * @param BOOL $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show. |
|
| 2785 | + * @access protected |
|
| 2786 | + * @return void |
|
| 2787 | + */ |
|
| 2788 | + protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
| 2789 | + { |
|
| 2790 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 2791 | + //class name for actions/filters. |
|
| 2792 | + $classname = get_class($this); |
|
| 2793 | + //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
|
| 2794 | + $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
| 2795 | + $notices = EE_Error::get_notices(false); |
|
| 2796 | + // overwrite default success messages //BUT ONLY if overwrite not overridden |
|
| 2797 | + if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
| 2798 | + EE_Error::overwrite_success(); |
|
| 2799 | + } |
|
| 2800 | + if ( ! empty($what) && ! empty($action_desc)) { |
|
| 2801 | + // how many records affected ? more than one record ? or just one ? |
|
| 2802 | + if ($success > 1 && empty($notices['errors'])) { |
|
| 2803 | + // set plural msg |
|
| 2804 | + EE_Error::add_success( |
|
| 2805 | + sprintf( |
|
| 2806 | + __('The "%s" have been successfully %s.', 'event_espresso'), |
|
| 2807 | + $what, |
|
| 2808 | + $action_desc |
|
| 2809 | + ), |
|
| 2810 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2811 | + ); |
|
| 2812 | + } else if ($success == 1 && empty($notices['errors'])) { |
|
| 2813 | + // set singular msg |
|
| 2814 | + EE_Error::add_success( |
|
| 2815 | + sprintf( |
|
| 2816 | + __('The "%s" has been successfully %s.', 'event_espresso'), |
|
| 2817 | + $what, |
|
| 2818 | + $action_desc |
|
| 2819 | + ), |
|
| 2820 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 2821 | + ); |
|
| 2822 | + } |
|
| 2823 | + } |
|
| 2824 | + // check that $query_args isn't something crazy |
|
| 2825 | + if ( ! is_array($query_args)) { |
|
| 2826 | + $query_args = array(); |
|
| 2827 | + } |
|
| 2828 | + /** |
|
| 2829 | + * Allow injecting actions before the query_args are modified for possible different |
|
| 2830 | + * redirections on save and close actions |
|
| 2831 | + * |
|
| 2832 | + * @since 4.2.0 |
|
| 2833 | + * @param array $query_args The original query_args array coming into the |
|
| 2834 | + * method. |
|
| 2835 | + */ |
|
| 2836 | + do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
| 2837 | + //calculate where we're going (if we have a "save and close" button pushed) |
|
| 2838 | + if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
| 2839 | + // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
|
| 2840 | + $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
| 2841 | + // regenerate query args array from referrer URL |
|
| 2842 | + parse_str($parsed_url['query'], $query_args); |
|
| 2843 | + // correct page and action will be in the query args now |
|
| 2844 | + $redirect_url = admin_url('admin.php'); |
|
| 2845 | + } |
|
| 2846 | + //merge any default query_args set in _default_route_query_args property |
|
| 2847 | + if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
| 2848 | + $args_to_merge = array(); |
|
| 2849 | + foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
| 2850 | + //is there a wp_referer array in our _default_route_query_args property? |
|
| 2851 | + if ($query_param == 'wp_referer') { |
|
| 2852 | + $query_value = (array)$query_value; |
|
| 2853 | + foreach ($query_value as $reference => $value) { |
|
| 2854 | + if (strpos($reference, 'nonce') !== false) { |
|
| 2855 | + continue; |
|
| 2856 | + } |
|
| 2857 | + //finally we will override any arguments in the referer with |
|
| 2858 | + //what might be set on the _default_route_query_args array. |
|
| 2859 | + if (isset($this->_default_route_query_args[$reference])) { |
|
| 2860 | + $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
| 2861 | + } else { |
|
| 2862 | + $args_to_merge[$reference] = urlencode($value); |
|
| 2863 | + } |
|
| 2864 | + } |
|
| 2865 | + continue; |
|
| 2866 | + } |
|
| 2867 | + $args_to_merge[$query_param] = $query_value; |
|
| 2868 | + } |
|
| 2869 | + //now let's merge these arguments but override with what was specifically sent in to the |
|
| 2870 | + //redirect. |
|
| 2871 | + $query_args = array_merge($args_to_merge, $query_args); |
|
| 2872 | + } |
|
| 2873 | + $this->_process_notices($query_args); |
|
| 2874 | + // generate redirect url |
|
| 2875 | + // if redirecting to anything other than the main page, add a nonce |
|
| 2876 | + if (isset($query_args['action'])) { |
|
| 2877 | + // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
|
| 2878 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 2879 | + } |
|
| 2880 | + //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
|
| 2881 | + do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
| 2882 | + $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
| 2883 | + // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
|
| 2884 | + if (defined('DOING_AJAX')) { |
|
| 2885 | + $default_data = array( |
|
| 2886 | + 'close' => true, |
|
| 2887 | + 'redirect_url' => $redirect_url, |
|
| 2888 | + 'where' => 'main', |
|
| 2889 | + 'what' => 'append', |
|
| 2890 | + ); |
|
| 2891 | + $this->_template_args['success'] = $success; |
|
| 2892 | + $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
| 2893 | + $this->_return_json(); |
|
| 2894 | + } |
|
| 2895 | + wp_safe_redirect($redirect_url); |
|
| 2896 | + exit(); |
|
| 2897 | + } |
|
| 2898 | + |
|
| 2899 | + |
|
| 2900 | + |
|
| 2901 | + /** |
|
| 2902 | + * process any notices before redirecting (or returning ajax request) |
|
| 2903 | + * This method sets the $this->_template_args['notices'] attribute; |
|
| 2904 | + * |
|
| 2905 | + * @param array $query_args any query args that need to be used for notice transient ('action') |
|
| 2906 | + * @param bool $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet. |
|
| 2907 | + * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
|
| 2908 | + * @return void |
|
| 2909 | + */ |
|
| 2910 | + protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true) |
|
| 2911 | + { |
|
| 2912 | + //first let's set individual error properties if doing_ajax and the properties aren't already set. |
|
| 2913 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 2914 | + $notices = EE_Error::get_notices(false); |
|
| 2915 | + if (empty($this->_template_args['success'])) { |
|
| 2916 | + $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
| 2917 | + } |
|
| 2918 | + if (empty($this->_template_args['errors'])) { |
|
| 2919 | + $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
| 2920 | + } |
|
| 2921 | + if (empty($this->_template_args['attention'])) { |
|
| 2922 | + $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
| 2923 | + } |
|
| 2924 | + } |
|
| 2925 | + $this->_template_args['notices'] = EE_Error::get_notices(); |
|
| 2926 | + //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
|
| 2927 | + if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
| 2928 | + $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
| 2929 | + $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify); |
|
| 2930 | + } |
|
| 2931 | + } |
|
| 2932 | + |
|
| 2933 | + |
|
| 2934 | + |
|
| 2935 | + /** |
|
| 2936 | + * get_action_link_or_button |
|
| 2937 | + * returns the button html for adding, editing, or deleting an item (depending on given type) |
|
| 2938 | + * |
|
| 2939 | + * @param string $action use this to indicate which action the url is generated with. |
|
| 2940 | + * @param string $type accepted strings must be defined in the $_labels['button'] array(as the key) property. |
|
| 2941 | + * @param array $extra_request if the button requires extra params you can include them in $key=>$value pairs. |
|
| 2942 | + * @param string $class Use this to give the class for the button. Defaults to 'button-primary' |
|
| 2943 | + * @param string $base_url If this is not provided |
|
| 2944 | + * the _admin_base_url will be used as the default for the button base_url. |
|
| 2945 | + * Otherwise this value will be used. |
|
| 2946 | + * @param bool $exclude_nonce If true then no nonce will be in the generated button link. |
|
| 2947 | + * @return string |
|
| 2948 | + * @throws \EE_Error |
|
| 2949 | + */ |
|
| 2950 | + public function get_action_link_or_button( |
|
| 2951 | + $action, |
|
| 2952 | + $type = 'add', |
|
| 2953 | + $extra_request = array(), |
|
| 2954 | + $class = 'button-primary', |
|
| 2955 | + $base_url = '', |
|
| 2956 | + $exclude_nonce = false |
|
| 2957 | + ) { |
|
| 2958 | + //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
|
| 2959 | + if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
| 2960 | + throw new EE_Error( |
|
| 2961 | + sprintf( |
|
| 2962 | + __( |
|
| 2963 | + 'There is no page route for given action for the button. This action was given: %s', |
|
| 2964 | + 'event_espresso' |
|
| 2965 | + ), |
|
| 2966 | + $action |
|
| 2967 | + ) |
|
| 2968 | + ); |
|
| 2969 | + } |
|
| 2970 | + if ( ! isset($this->_labels['buttons'][$type])) { |
|
| 2971 | + throw new EE_Error( |
|
| 2972 | + sprintf( |
|
| 2973 | + __( |
|
| 2974 | + 'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', |
|
| 2975 | + 'event_espresso' |
|
| 2976 | + ), |
|
| 2977 | + $type |
|
| 2978 | + ) |
|
| 2979 | + ); |
|
| 2980 | + } |
|
| 2981 | + //finally check user access for this button. |
|
| 2982 | + $has_access = $this->check_user_access($action, true); |
|
| 2983 | + if ( ! $has_access) { |
|
| 2984 | + return ''; |
|
| 2985 | + } |
|
| 2986 | + $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
|
| 2987 | + $query_args = array( |
|
| 2988 | + 'action' => $action, |
|
| 2989 | + ); |
|
| 2990 | + //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
|
| 2991 | + if ( ! empty($extra_request)) { |
|
| 2992 | + $query_args = array_merge($extra_request, $query_args); |
|
| 2993 | + } |
|
| 2994 | + $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
| 2995 | + return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
| 2996 | + } |
|
| 2997 | + |
|
| 2998 | + |
|
| 2999 | + |
|
| 3000 | + /** |
|
| 3001 | + * _per_page_screen_option |
|
| 3002 | + * Utility function for adding in a per_page_option in the screen_options_dropdown. |
|
| 3003 | + * |
|
| 3004 | + * @return void |
|
| 3005 | + */ |
|
| 3006 | + protected function _per_page_screen_option() |
|
| 3007 | + { |
|
| 3008 | + $option = 'per_page'; |
|
| 3009 | + $args = array( |
|
| 3010 | + 'label' => $this->_admin_page_title, |
|
| 3011 | + 'default' => 10, |
|
| 3012 | + 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
| 3013 | + ); |
|
| 3014 | + //ONLY add the screen option if the user has access to it. |
|
| 3015 | + if ($this->check_user_access($this->_current_view, true)) { |
|
| 3016 | + add_screen_option($option, $args); |
|
| 3017 | + } |
|
| 3018 | + } |
|
| 3019 | + |
|
| 3020 | + |
|
| 3021 | + |
|
| 3022 | + /** |
|
| 3023 | + * set_per_page_screen_option |
|
| 3024 | + * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page. |
|
| 3025 | + * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu. |
|
| 3026 | + * |
|
| 3027 | + * @access private |
|
| 3028 | + * @return void |
|
| 3029 | + */ |
|
| 3030 | + private function _set_per_page_screen_options() |
|
| 3031 | + { |
|
| 3032 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
| 3033 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
| 3034 | + if ( ! $user = wp_get_current_user()) { |
|
| 3035 | + return; |
|
| 3036 | + } |
|
| 3037 | + $option = $_POST['wp_screen_options']['option']; |
|
| 3038 | + $value = $_POST['wp_screen_options']['value']; |
|
| 3039 | + if ($option != sanitize_key($option)) { |
|
| 3040 | + return; |
|
| 3041 | + } |
|
| 3042 | + $map_option = $option; |
|
| 3043 | + $option = str_replace('-', '_', $option); |
|
| 3044 | + switch ($map_option) { |
|
| 3045 | + case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
| 3046 | + $value = (int)$value; |
|
| 3047 | + if ($value < 1 || $value > 999) { |
|
| 3048 | + return; |
|
| 3049 | + } |
|
| 3050 | + break; |
|
| 3051 | + default: |
|
| 3052 | + $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
| 3053 | + if (false === $value) { |
|
| 3054 | + return; |
|
| 3055 | + } |
|
| 3056 | + break; |
|
| 3057 | + } |
|
| 3058 | + update_user_meta($user->ID, $option, $value); |
|
| 3059 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
| 3060 | + exit; |
|
| 3061 | + } |
|
| 3062 | + } |
|
| 3063 | + |
|
| 3064 | + |
|
| 3065 | + |
|
| 3066 | + /** |
|
| 3067 | + * This just allows for setting the $_template_args property if it needs to be set outside the object |
|
| 3068 | + * |
|
| 3069 | + * @param array $data array that will be assigned to template args. |
|
| 3070 | + */ |
|
| 3071 | + public function set_template_args($data) |
|
| 3072 | + { |
|
| 3073 | + $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
| 3074 | + } |
|
| 3075 | + |
|
| 3076 | + |
|
| 3077 | + |
|
| 3078 | + /** |
|
| 3079 | + * This makes available the WP transient system for temporarily moving data between routes |
|
| 3080 | + * |
|
| 3081 | + * @access protected |
|
| 3082 | + * @param string $route the route that should receive the transient |
|
| 3083 | + * @param array $data the data that gets sent |
|
| 3084 | + * @param bool $notices If this is for notices then we use this to indicate so, otherwise its just a normal route transient. |
|
| 3085 | + * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
|
| 3086 | + * @return void |
|
| 3087 | + */ |
|
| 3088 | + protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false) |
|
| 3089 | + { |
|
| 3090 | + $user_id = get_current_user_id(); |
|
| 3091 | + if ( ! $skip_route_verify) { |
|
| 3092 | + $this->_verify_route($route); |
|
| 3093 | + } |
|
| 3094 | + //now let's set the string for what kind of transient we're setting |
|
| 3095 | + $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3096 | + $data = $notices ? array('notices' => $data) : $data; |
|
| 3097 | + //is there already a transient for this route? If there is then let's ADD to that transient |
|
| 3098 | + $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3099 | + if ($existing) { |
|
| 3100 | + $data = array_merge((array)$data, (array)$existing); |
|
| 3101 | + } |
|
| 3102 | + if (is_multisite() && is_network_admin()) { |
|
| 3103 | + set_site_transient($transient, $data, 8); |
|
| 3104 | + } else { |
|
| 3105 | + set_transient($transient, $data, 8); |
|
| 3106 | + } |
|
| 3107 | + } |
|
| 3108 | + |
|
| 3109 | + |
|
| 3110 | + |
|
| 3111 | + /** |
|
| 3112 | + * this retrieves the temporary transient that has been set for moving data between routes. |
|
| 3113 | + * |
|
| 3114 | + * @param bool $notices true we get notices transient. False we just return normal route transient |
|
| 3115 | + * @return mixed data |
|
| 3116 | + */ |
|
| 3117 | + protected function _get_transient($notices = false, $route = false) |
|
| 3118 | + { |
|
| 3119 | + $user_id = get_current_user_id(); |
|
| 3120 | + $route = ! $route ? $this->_req_action : $route; |
|
| 3121 | + $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3122 | + $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
| 3123 | + //delete transient after retrieval (just in case it hasn't expired); |
|
| 3124 | + if (is_multisite() && is_network_admin()) { |
|
| 3125 | + delete_site_transient($transient); |
|
| 3126 | + } else { |
|
| 3127 | + delete_transient($transient); |
|
| 3128 | + } |
|
| 3129 | + return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
| 3130 | + } |
|
| 3131 | + |
|
| 3132 | + |
|
| 3133 | + |
|
| 3134 | + /** |
|
| 3135 | + * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later. |
|
| 3136 | + * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.) |
|
| 3137 | + * |
|
| 3138 | + * @return void |
|
| 3139 | + */ |
|
| 3140 | + protected function _transient_garbage_collection() |
|
| 3141 | + { |
|
| 3142 | + global $wpdb; |
|
| 3143 | + //retrieve all existing transients |
|
| 3144 | + $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
|
| 3145 | + if ($results = $wpdb->get_results($query)) { |
|
| 3146 | + foreach ($results as $result) { |
|
| 3147 | + $transient = str_replace('_transient_', '', $result->option_name); |
|
| 3148 | + get_transient($transient); |
|
| 3149 | + if (is_multisite() && is_network_admin()) { |
|
| 3150 | + get_site_transient($transient); |
|
| 3151 | + } |
|
| 3152 | + } |
|
| 3153 | + } |
|
| 3154 | + } |
|
| 3155 | + |
|
| 3156 | + |
|
| 3157 | + |
|
| 3158 | + /** |
|
| 3159 | + * get_view |
|
| 3160 | + * |
|
| 3161 | + * @access public |
|
| 3162 | + * @return string content of _view property |
|
| 3163 | + */ |
|
| 3164 | + public function get_view() |
|
| 3165 | + { |
|
| 3166 | + return $this->_view; |
|
| 3167 | + } |
|
| 3168 | + |
|
| 3169 | + |
|
| 3170 | + |
|
| 3171 | + /** |
|
| 3172 | + * getter for the protected $_views property |
|
| 3173 | + * |
|
| 3174 | + * @return array |
|
| 3175 | + */ |
|
| 3176 | + public function get_views() |
|
| 3177 | + { |
|
| 3178 | + return $this->_views; |
|
| 3179 | + } |
|
| 3180 | + |
|
| 3181 | + |
|
| 3182 | + |
|
| 3183 | + /** |
|
| 3184 | + * get_current_page |
|
| 3185 | + * |
|
| 3186 | + * @access public |
|
| 3187 | + * @return string _current_page property value |
|
| 3188 | + */ |
|
| 3189 | + public function get_current_page() |
|
| 3190 | + { |
|
| 3191 | + return $this->_current_page; |
|
| 3192 | + } |
|
| 3193 | + |
|
| 3194 | + |
|
| 3195 | + |
|
| 3196 | + /** |
|
| 3197 | + * get_current_view |
|
| 3198 | + * |
|
| 3199 | + * @access public |
|
| 3200 | + * @return string _current_view property value |
|
| 3201 | + */ |
|
| 3202 | + public function get_current_view() |
|
| 3203 | + { |
|
| 3204 | + return $this->_current_view; |
|
| 3205 | + } |
|
| 3206 | + |
|
| 3207 | + |
|
| 3208 | + |
|
| 3209 | + /** |
|
| 3210 | + * get_current_screen |
|
| 3211 | + * |
|
| 3212 | + * @access public |
|
| 3213 | + * @return object The current WP_Screen object |
|
| 3214 | + */ |
|
| 3215 | + public function get_current_screen() |
|
| 3216 | + { |
|
| 3217 | + return $this->_current_screen; |
|
| 3218 | + } |
|
| 3219 | + |
|
| 3220 | + |
|
| 3221 | + |
|
| 3222 | + /** |
|
| 3223 | + * get_current_page_view_url |
|
| 3224 | + * |
|
| 3225 | + * @access public |
|
| 3226 | + * @return string This returns the url for the current_page_view. |
|
| 3227 | + */ |
|
| 3228 | + public function get_current_page_view_url() |
|
| 3229 | + { |
|
| 3230 | + return $this->_current_page_view_url; |
|
| 3231 | + } |
|
| 3232 | + |
|
| 3233 | + |
|
| 3234 | + |
|
| 3235 | + /** |
|
| 3236 | + * just returns the _req_data property |
|
| 3237 | + * |
|
| 3238 | + * @return array |
|
| 3239 | + */ |
|
| 3240 | + public function get_request_data() |
|
| 3241 | + { |
|
| 3242 | + return $this->_req_data; |
|
| 3243 | + } |
|
| 3244 | + |
|
| 3245 | + |
|
| 3246 | + |
|
| 3247 | + /** |
|
| 3248 | + * returns the _req_data protected property |
|
| 3249 | + * |
|
| 3250 | + * @return string |
|
| 3251 | + */ |
|
| 3252 | + public function get_req_action() |
|
| 3253 | + { |
|
| 3254 | + return $this->_req_action; |
|
| 3255 | + } |
|
| 3256 | + |
|
| 3257 | + |
|
| 3258 | + |
|
| 3259 | + /** |
|
| 3260 | + * @return bool value of $_is_caf property |
|
| 3261 | + */ |
|
| 3262 | + public function is_caf() |
|
| 3263 | + { |
|
| 3264 | + return $this->_is_caf; |
|
| 3265 | + } |
|
| 3266 | + |
|
| 3267 | + |
|
| 3268 | + |
|
| 3269 | + /** |
|
| 3270 | + * @return mixed |
|
| 3271 | + */ |
|
| 3272 | + public function default_espresso_metaboxes() |
|
| 3273 | + { |
|
| 3274 | + return $this->_default_espresso_metaboxes; |
|
| 3275 | + } |
|
| 3276 | + |
|
| 3277 | + |
|
| 3278 | + |
|
| 3279 | + /** |
|
| 3280 | + * @return mixed |
|
| 3281 | + */ |
|
| 3282 | + public function admin_base_url() |
|
| 3283 | + { |
|
| 3284 | + return $this->_admin_base_url; |
|
| 3285 | + } |
|
| 3286 | + |
|
| 3287 | + |
|
| 3288 | + |
|
| 3289 | + /** |
|
| 3290 | + * @return mixed |
|
| 3291 | + */ |
|
| 3292 | + public function wp_page_slug() |
|
| 3293 | + { |
|
| 3294 | + return $this->_wp_page_slug; |
|
| 3295 | + } |
|
| 3296 | + |
|
| 3297 | + |
|
| 3298 | + |
|
| 3299 | + /** |
|
| 3300 | + * updates espresso configuration settings |
|
| 3301 | + * |
|
| 3302 | + * @access protected |
|
| 3303 | + * @param string $tab |
|
| 3304 | + * @param EE_Config_Base|EE_Config $config |
|
| 3305 | + * @param string $file file where error occurred |
|
| 3306 | + * @param string $func function where error occurred |
|
| 3307 | + * @param string $line line no where error occurred |
|
| 3308 | + * @return boolean |
|
| 3309 | + */ |
|
| 3310 | + protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') |
|
| 3311 | + { |
|
| 3312 | + //remove any options that are NOT going to be saved with the config settings. |
|
| 3313 | + if (isset($config->core->ee_ueip_optin)) { |
|
| 3314 | + $config->core->ee_ueip_has_notified = true; |
|
| 3315 | + // TODO: remove the following two lines and make sure values are migrated from 3.1 |
|
| 3316 | + update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
| 3317 | + update_option('ee_ueip_has_notified', true); |
|
| 3318 | + } |
|
| 3319 | + // and save it (note we're also doing the network save here) |
|
| 3320 | + $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true; |
|
| 3321 | + $config_saved = EE_Config::instance()->update_espresso_config(false, false); |
|
| 3322 | + if ($config_saved && $net_saved) { |
|
| 3323 | + EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
| 3324 | + return true; |
|
| 3325 | + } else { |
|
| 3326 | + EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
| 3327 | + return false; |
|
| 3328 | + } |
|
| 3329 | + } |
|
| 3330 | + |
|
| 3331 | + |
|
| 3332 | + |
|
| 3333 | + /** |
|
| 3334 | + * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
|
| 3335 | + * |
|
| 3336 | + * @return array |
|
| 3337 | + */ |
|
| 3338 | + public function get_yes_no_values() |
|
| 3339 | + { |
|
| 3340 | + return $this->_yes_no_values; |
|
| 3341 | + } |
|
| 3342 | + |
|
| 3343 | + |
|
| 3344 | + |
|
| 3345 | + protected function _get_dir() |
|
| 3346 | + { |
|
| 3347 | + $reflector = new ReflectionClass(get_class($this)); |
|
| 3348 | + return dirname($reflector->getFileName()); |
|
| 3349 | + } |
|
| 3350 | + |
|
| 3351 | + |
|
| 3352 | + |
|
| 3353 | + /** |
|
| 3354 | + * A helper for getting a "next link". |
|
| 3355 | + * |
|
| 3356 | + * @param string $url The url to link to |
|
| 3357 | + * @param string $class The class to use. |
|
| 3358 | + * @return string |
|
| 3359 | + */ |
|
| 3360 | + protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
|
| 3361 | + { |
|
| 3362 | + return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3363 | + } |
|
| 3364 | + |
|
| 3365 | + |
|
| 3366 | + |
|
| 3367 | + /** |
|
| 3368 | + * A helper for getting a "previous link". |
|
| 3369 | + * |
|
| 3370 | + * @param string $url The url to link to |
|
| 3371 | + * @param string $class The class to use. |
|
| 3372 | + * @return string |
|
| 3373 | + */ |
|
| 3374 | + protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
|
| 3375 | + { |
|
| 3376 | + return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3377 | + } |
|
| 3378 | + |
|
| 3379 | + |
|
| 3380 | + |
|
| 3381 | + |
|
| 3382 | + |
|
| 3383 | + |
|
| 3384 | + |
|
| 3385 | + //below are some messages related methods that should be available across the EE_Admin system. Note, these methods are NOT page specific |
|
| 3386 | + /** |
|
| 3387 | + * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data |
|
| 3388 | + * array. |
|
| 3389 | + * |
|
| 3390 | + * @return bool success/fail |
|
| 3391 | + */ |
|
| 3392 | + protected function _process_resend_registration() |
|
| 3393 | + { |
|
| 3394 | + $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
| 3395 | + do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
| 3396 | + return $this->_template_args['success']; |
|
| 3397 | + } |
|
| 3398 | + |
|
| 3399 | + |
|
| 3400 | + |
|
| 3401 | + /** |
|
| 3402 | + * This automatically processes any payment message notifications when manual payment has been applied. |
|
| 3403 | + * |
|
| 3404 | + * @access protected |
|
| 3405 | + * @param \EE_Payment $payment |
|
| 3406 | + * @return bool success/fail |
|
| 3407 | + */ |
|
| 3408 | + protected function _process_payment_notification(EE_Payment $payment) |
|
| 3409 | + { |
|
| 3410 | + add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
| 3411 | + do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
| 3412 | + $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
| 3413 | + return $this->_template_args['success']; |
|
| 3414 | + } |
|
| 3415 | 3415 | |
| 3416 | 3416 | |
| 3417 | 3417 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $this->_columns = array_merge( $columns, $this->_columns ); |
| 88 | 88 | $this->_primary_column = '_REG_att_checked_in'; |
| 89 | 89 | if ( ! empty( $evt_id ) |
| 90 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 90 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 91 | 91 | 'ee_read_registrations', |
| 92 | 92 | 'espresso_registrations_registrations_reports', |
| 93 | 93 | $evt_id |
@@ -104,44 +104,44 @@ discard block |
||
| 104 | 104 | ), |
| 105 | 105 | ); |
| 106 | 106 | } |
| 107 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 108 | - 'route' => 'registrations_checkin_report', |
|
| 109 | - 'extra_request' => array( |
|
| 110 | - 'use_filters' => true, |
|
| 111 | - 'filters' => array_merge( |
|
| 112 | - array( |
|
| 113 | - 'EVT_ID' => $evt_id, |
|
| 114 | - ), |
|
| 115 | - array_diff_key( |
|
| 116 | - $this->_req_data, |
|
| 117 | - array_flip( |
|
| 118 | - array( |
|
| 119 | - 'page', |
|
| 120 | - 'action', |
|
| 121 | - 'default_nonce', |
|
| 122 | - ) |
|
| 123 | - ) |
|
| 124 | - ) |
|
| 125 | - ), |
|
| 126 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 127 | - ), |
|
| 128 | - ); |
|
| 107 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 108 | + 'route' => 'registrations_checkin_report', |
|
| 109 | + 'extra_request' => array( |
|
| 110 | + 'use_filters' => true, |
|
| 111 | + 'filters' => array_merge( |
|
| 112 | + array( |
|
| 113 | + 'EVT_ID' => $evt_id, |
|
| 114 | + ), |
|
| 115 | + array_diff_key( |
|
| 116 | + $this->_req_data, |
|
| 117 | + array_flip( |
|
| 118 | + array( |
|
| 119 | + 'page', |
|
| 120 | + 'action', |
|
| 121 | + 'default_nonce', |
|
| 122 | + ) |
|
| 123 | + ) |
|
| 124 | + ) |
|
| 125 | + ), |
|
| 126 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 127 | + ), |
|
| 128 | + ); |
|
| 129 | 129 | $this->_sortable_columns = array( |
| 130 | - /** |
|
| 131 | - * Allows users to change the default sort if they wish. |
|
| 132 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 133 | - * |
|
| 134 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 135 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 136 | - * for a specific list table you can use the provided reference to this object instance. |
|
| 137 | - */ |
|
| 130 | + /** |
|
| 131 | + * Allows users to change the default sort if they wish. |
|
| 132 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 133 | + * |
|
| 134 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
| 135 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
| 136 | + * for a specific list table you can use the provided reference to this object instance. |
|
| 137 | + */ |
|
| 138 | 138 | 'ATT_name' => array( |
| 139 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 140 | - true, |
|
| 141 | - $this |
|
| 142 | - ) |
|
| 143 | - ? array( 'ATT_lname' => true ) |
|
| 144 | - : array( 'ATT_fname' => true ), |
|
| 139 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 140 | + true, |
|
| 141 | + $this |
|
| 142 | + ) |
|
| 143 | + ? array( 'ATT_lname' => true ) |
|
| 144 | + : array( 'ATT_fname' => true ), |
|
| 145 | 145 | 'Event' => array( 'Event.EVT.Name' => false ), |
| 146 | 146 | ); |
| 147 | 147 | $this->_hidden_columns = array(); |
@@ -224,8 +224,8 @@ discard block |
||
| 224 | 224 | if ( count( $this->_dtts_for_event ) > 1 ) { |
| 225 | 225 | $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
| 226 | 226 | foreach ( $this->_dtts_for_event as $dtt ) { |
| 227 | - $datetime_string = $dtt->name(); |
|
| 228 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 227 | + $datetime_string = $dtt->name(); |
|
| 228 | + $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 229 | 229 | $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
| 230 | 230 | $dtts[ $dtt->ID() ] = $datetime_string; |
| 231 | 231 | } |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
| 320 | 320 | $nonce = wp_create_nonce( 'checkin_nonce' ); |
| 321 | 321 | $toggle_active = ! empty ( $this->_cur_dtt_id ) |
| 322 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 322 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 323 | 323 | 'ee_edit_checkin', |
| 324 | 324 | 'espresso_registrations_toggle_checkin_status', |
| 325 | 325 | $item->ID() |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | : ''; |
| 329 | 329 | $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
| 330 | 330 | return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
| 331 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 332 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 333 | - . ' data-nonce="' . $nonce . '">' |
|
| 334 | - . '</span>' |
|
| 335 | - . $mobile_view_content; |
|
| 331 | + . ' data-_regid="' . $item->ID() . '"' |
|
| 332 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 333 | + . ' data-nonce="' . $nonce . '">' |
|
| 334 | + . '</span>' |
|
| 335 | + . $mobile_view_content; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | 'espresso_registrations_edit_attendee' |
| 358 | 358 | ) |
| 359 | 359 | ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
| 360 | - . $item->attendee()->full_name() |
|
| 361 | - . '</a>' |
|
| 360 | + . $item->attendee()->full_name() |
|
| 361 | + . '</a>' |
|
| 362 | 362 | : $item->attendee()->full_name(); |
| 363 | 363 | $name_link .= $item->count() === 1 |
| 364 | 364 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | ? $latest_related_datetime->ID() |
| 394 | 394 | : $DTT_ID; |
| 395 | 395 | if ( ! empty( $DTT_ID ) |
| 396 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 396 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 397 | 397 | 'ee_read_checkins', |
| 398 | 398 | 'espresso_registrations_registration_checkins' |
| 399 | 399 | ) |
@@ -493,15 +493,15 @@ discard block |
||
| 493 | 493 | ) ? ' |
| 494 | 494 | <span class="reg-pad-rght"> |
| 495 | 495 | <a class="status-' |
| 496 | - . $item->transaction()->status_ID() |
|
| 497 | - . '" href="' |
|
| 498 | - . $view_txn_lnk_url |
|
| 499 | - . '" title="' |
|
| 500 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 501 | - . '"> |
|
| 496 | + . $item->transaction()->status_ID() |
|
| 497 | + . '" href="' |
|
| 498 | + . $view_txn_lnk_url |
|
| 499 | + . '" title="' |
|
| 500 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 501 | + . '"> |
|
| 502 | 502 | ' |
| 503 | - . $item->transaction()->pretty_paid() |
|
| 504 | - . ' |
|
| 503 | + . $item->transaction()->pretty_paid() |
|
| 504 | + . ' |
|
| 505 | 505 | </a> |
| 506 | 506 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
| 507 | 507 | } |
@@ -534,12 +534,12 @@ discard block |
||
| 534 | 534 | 'ee_read_transaction', |
| 535 | 535 | 'espresso_transactions_view_transaction' |
| 536 | 536 | ) ? '<a href="' |
| 537 | - . $view_txn_url |
|
| 538 | - . '" title="' |
|
| 539 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 540 | - . '"><span class="reg-pad-rght">' |
|
| 541 | - . $txn_total |
|
| 542 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 537 | + . $view_txn_url |
|
| 538 | + . '" title="' |
|
| 539 | + . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 540 | + . '"><span class="reg-pad-rght">' |
|
| 541 | + . $txn_total |
|
| 542 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 543 | 543 | } else { |
| 544 | 544 | return '<span class="reg-pad-rght"></span>'; |
| 545 | 545 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -42,51 +42,51 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param \Registrations_Admin_Page $admin_page |
| 44 | 44 | */ |
| 45 | - public function __construct( $admin_page ) { |
|
| 46 | - parent::__construct( $admin_page ); |
|
| 45 | + public function __construct($admin_page) { |
|
| 46 | + parent::__construct($admin_page); |
|
| 47 | 47 | $this->_status = $this->_admin_page->get_registration_status_array(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | protected function _setup_data() { |
| 53 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( $this->_per_page ) |
|
| 54 | - : $this->_admin_page->get_event_attendees( $this->_per_page, false, true ); |
|
| 53 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
| 54 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
| 55 | 55 | $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
| 56 | 56 | $this->_per_page, |
| 57 | 57 | true |
| 58 | - ) : $this->_admin_page->get_event_attendees( $this->_per_page, true, true ); |
|
| 58 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | protected function _set_properties() { |
| 64 | - $evt_id = isset( $this->_req_data['event_id'] ) ? $this->_req_data['event_id'] : null; |
|
| 64 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 65 | 65 | $this->_wp_list_args = array( |
| 66 | - 'singular' => __( 'registrant', 'event_espresso' ), |
|
| 67 | - 'plural' => __( 'registrants', 'event_espresso' ), |
|
| 66 | + 'singular' => __('registrant', 'event_espresso'), |
|
| 67 | + 'plural' => __('registrants', 'event_espresso'), |
|
| 68 | 68 | 'ajax' => true, |
| 69 | 69 | 'screen' => $this->_admin_page->get_current_screen()->id, |
| 70 | 70 | ); |
| 71 | 71 | $columns = array(); |
| 72 | 72 | //$columns['_Reg_Status'] = ''; |
| 73 | - if ( ! empty( $evt_id ) ) { |
|
| 73 | + if ( ! empty($evt_id)) { |
|
| 74 | 74 | $columns['cb'] = '<input type="checkbox" />'; //Render a checkbox instead of text |
| 75 | 75 | $this->_has_checkbox_column = true; |
| 76 | 76 | } |
| 77 | 77 | $this->_columns = array( |
| 78 | 78 | '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
| 79 | - 'ATT_name' => __( 'Registrant', 'event_espresso' ), |
|
| 80 | - 'ATT_email' => __( 'Email Address', 'event_espresso' ), |
|
| 81 | - 'Event' => __( 'Event', 'event_espresso' ), |
|
| 82 | - 'PRC_name' => __( 'TKT Option', 'event_espresso' ), |
|
| 83 | - '_REG_final_price' => __( 'Price', 'event_espresso' ), |
|
| 84 | - 'TXN_paid' => __( 'Paid', 'event_espresso' ), |
|
| 85 | - 'TXN_total' => __( 'Total', 'event_espresso' ), |
|
| 79 | + 'ATT_name' => __('Registrant', 'event_espresso'), |
|
| 80 | + 'ATT_email' => __('Email Address', 'event_espresso'), |
|
| 81 | + 'Event' => __('Event', 'event_espresso'), |
|
| 82 | + 'PRC_name' => __('TKT Option', 'event_espresso'), |
|
| 83 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 84 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 85 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
| 86 | 86 | ); |
| 87 | - $this->_columns = array_merge( $columns, $this->_columns ); |
|
| 87 | + $this->_columns = array_merge($columns, $this->_columns); |
|
| 88 | 88 | $this->_primary_column = '_REG_att_checked_in'; |
| 89 | - if ( ! empty( $evt_id ) |
|
| 89 | + if ( ! empty($evt_id) |
|
| 90 | 90 | && EE_Registry::instance()->CAP->current_user_can( |
| 91 | 91 | 'ee_read_registrations', |
| 92 | 92 | 'espresso_registrations_registrations_reports', |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | 'extra_request' => |
| 100 | 100 | array( |
| 101 | 101 | 'EVT_ID' => $evt_id, |
| 102 | - 'return_url' => urlencode( "//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}" ), |
|
| 102 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 103 | 103 | ), |
| 104 | 104 | ), |
| 105 | 105 | ); |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | true, |
| 141 | 141 | $this |
| 142 | 142 | ) |
| 143 | - ? array( 'ATT_lname' => true ) |
|
| 144 | - : array( 'ATT_fname' => true ), |
|
| 145 | - 'Event' => array( 'Event.EVT.Name' => false ), |
|
| 143 | + ? array('ATT_lname' => true) |
|
| 144 | + : array('ATT_fname' => true), |
|
| 145 | + 'Event' => array('Event.EVT.Name' => false), |
|
| 146 | 146 | ); |
| 147 | 147 | $this->_hidden_columns = array(); |
| 148 | - $this->_evt = EEM_Event::instance()->get_one_by_ID( $evt_id ); |
|
| 148 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
| 149 | 149 | $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @param \EE_Registration $item |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - protected function _get_row_class( $item ) { |
|
| 159 | - $class = parent::_get_row_class( $item ); |
|
| 158 | + protected function _get_row_class($item) { |
|
| 159 | + $class = parent::_get_row_class($item); |
|
| 160 | 160 | //add status class |
| 161 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 162 | - if ( $this->_has_checkbox_column ) { |
|
| 161 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
| 162 | + if ($this->_has_checkbox_column) { |
|
| 163 | 163 | $class .= ' has-checkbox-column'; |
| 164 | 164 | } |
| 165 | 165 | return $class; |
@@ -173,61 +173,61 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | protected function _get_table_filters() { |
| 175 | 175 | $filters = $where = array(); |
| 176 | - $current_EVT_ID = isset( $this->_req_data['event_id'] ) ? (int) $this->_req_data['event_id'] : 0; |
|
| 177 | - if ( empty( $this->_dtts_for_event ) || count( $this->_dtts_for_event ) === 1 ) { |
|
| 176 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
| 177 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
| 178 | 178 | //this means we don't have an event so let's setup a filter dropdown for all the events to select |
| 179 | 179 | //note possible capability restrictions |
| 180 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
| 181 | - $where['status**'] = array( '!=', 'private' ); |
|
| 180 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
| 181 | + $where['status**'] = array('!=', 'private'); |
|
| 182 | 182 | } |
| 183 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
| 183 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
| 184 | 184 | $where['EVT_wp_user'] = get_current_user_id(); |
| 185 | 185 | } |
| 186 | 186 | $events = EEM_Event::instance()->get_all( |
| 187 | 187 | array( |
| 188 | 188 | $where, |
| 189 | - 'order_by' => array( 'Datetime.DTT_EVT_start' => 'DESC' ), |
|
| 189 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
| 190 | 190 | ) |
| 191 | 191 | ); |
| 192 | 192 | $evts[] = array( |
| 193 | 193 | 'id' => 0, |
| 194 | - 'text' => __( 'To toggle Check-in status, select an event', 'event_espresso' ), |
|
| 194 | + 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
| 195 | 195 | ); |
| 196 | 196 | $checked = 'checked'; |
| 197 | 197 | /** @var EE_Event $evt */ |
| 198 | - foreach ( $events as $evt ) { |
|
| 198 | + foreach ($events as $evt) { |
|
| 199 | 199 | //any registrations for this event? |
| 200 | - if ( ! $evt->get_count_of_all_registrations() ) { |
|
| 200 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
| 201 | 201 | continue; |
| 202 | 202 | } |
| 203 | 203 | $evts[] = array( |
| 204 | 204 | 'id' => $evt->ID(), |
| 205 | - 'text' => $evt->get( 'EVT_name' ), |
|
| 205 | + 'text' => $evt->get('EVT_name'), |
|
| 206 | 206 | 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
| 207 | 207 | ); |
| 208 | - if ( $evt->ID() === $current_EVT_ID && $evt->is_expired() ) { |
|
| 208 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
| 209 | 209 | $checked = ''; |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | $event_filter = '<div class="ee-event-filter">'; |
| 213 | - $event_filter .= EEH_Form_Fields::select_input( 'event_id', $evts, $current_EVT_ID ); |
|
| 213 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
| 214 | 214 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
| 215 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
| 216 | - $event_filter .= __( 'Hide Expired Events', 'event_espresso' ); |
|
| 215 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
| 216 | + $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
| 217 | 217 | $event_filter .= '</span>'; |
| 218 | 218 | $event_filter .= '</div>'; |
| 219 | 219 | $filters[] = $event_filter; |
| 220 | 220 | } |
| 221 | - if ( ! empty( $this->_dtts_for_event ) ) { |
|
| 221 | + if ( ! empty($this->_dtts_for_event)) { |
|
| 222 | 222 | //DTT datetimes filter |
| 223 | - $this->_cur_dtt_id = isset( $this->_req_data['DTT_ID'] ) ? $this->_req_data['DTT_ID'] : 0; |
|
| 224 | - if ( count( $this->_dtts_for_event ) > 1 ) { |
|
| 225 | - $dtts[0] = __( 'To toggle check-in status, select a datetime.', 'event_espresso' ); |
|
| 226 | - foreach ( $this->_dtts_for_event as $dtt ) { |
|
| 223 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
| 224 | + if (count($this->_dtts_for_event) > 1) { |
|
| 225 | + $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
| 226 | + foreach ($this->_dtts_for_event as $dtt) { |
|
| 227 | 227 | $datetime_string = $dtt->name(); |
| 228 | - $datetime_string = ! empty($datetime_string ) ? ' (' . $datetime_string . ')' : ''; |
|
| 229 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
| 230 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
| 228 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
| 229 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
| 230 | + $dtts[$dtt->ID()] = $datetime_string; |
|
| 231 | 231 | } |
| 232 | 232 | $input = new EE_Select_Input( |
| 233 | 233 | $dtts, |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | ) |
| 239 | 239 | ); |
| 240 | 240 | $filters[] = $input->get_html_for_input(); |
| 241 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
| 241 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | return $filters; |
@@ -257,22 +257,22 @@ discard block |
||
| 257 | 257 | * @throws \EE_Error |
| 258 | 258 | */ |
| 259 | 259 | protected function _get_total_event_attendees() { |
| 260 | - $EVT_ID = isset( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : false; |
|
| 260 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 261 | 261 | $DTT_ID = $this->_cur_dtt_id; |
| 262 | 262 | $query_params = array(); |
| 263 | - if ( $EVT_ID ) { |
|
| 263 | + if ($EVT_ID) { |
|
| 264 | 264 | $query_params[0]['EVT_ID'] = $EVT_ID; |
| 265 | 265 | } |
| 266 | 266 | //if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
| 267 | - if ( $DTT_ID ) { |
|
| 267 | + if ($DTT_ID) { |
|
| 268 | 268 | $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
| 269 | 269 | } |
| 270 | 270 | $status_ids_array = apply_filters( |
| 271 | 271 | 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
| 272 | - array( EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved ) |
|
| 272 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 273 | 273 | ); |
| 274 | - $query_params[0]['STS_ID'] = array( 'IN', $status_ids_array ); |
|
| 275 | - return EEM_Registration::instance()->count( $query_params ); |
|
| 274 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 275 | + return EEM_Registration::instance()->count($query_params); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * @param \EE_Registration $item |
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | - public function column__Reg_Status( EE_Registration $item ) { |
|
| 285 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
| 284 | + public function column__Reg_Status(EE_Registration $item) { |
|
| 285 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | * @return string |
| 293 | 293 | * @throws \EE_Error |
| 294 | 294 | */ |
| 295 | - public function column_cb( $item ) { |
|
| 296 | - return sprintf( '<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID() ); |
|
| 295 | + public function column_cb($item) { |
|
| 296 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | 299 | |
@@ -305,20 +305,20 @@ discard block |
||
| 305 | 305 | * @return string |
| 306 | 306 | * @throws \EE_Error |
| 307 | 307 | */ |
| 308 | - public function column__REG_att_checked_in( EE_Registration $item ) { |
|
| 308 | + public function column__REG_att_checked_in(EE_Registration $item) { |
|
| 309 | 309 | $attendee = $item->attendee(); |
| 310 | 310 | $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
| 311 | 311 | |
| 312 | - if ( $this->_cur_dtt_id === 0 && count( $this->_dtts_for_event ) === 1 ) { |
|
| 312 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
| 313 | 313 | $latest_related_datetime = $item->get_latest_related_datetime(); |
| 314 | - if ( $latest_related_datetime instanceof EE_Datetime ) { |
|
| 314 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
| 315 | 315 | $this->_cur_dtt_id = $latest_related_datetime->ID(); |
| 316 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - $checkinstatus = $item->check_in_status_for_datetime( $this->_cur_dtt_id ); |
|
| 320 | - $nonce = wp_create_nonce( 'checkin_nonce' ); |
|
| 321 | - $toggle_active = ! empty ( $this->_cur_dtt_id ) |
|
| 319 | + $checkinstatus = $item->check_in_status_for_datetime($this->_cur_dtt_id); |
|
| 320 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
| 321 | + $toggle_active = ! empty ($this->_cur_dtt_id) |
|
| 322 | 322 | && EE_Registry::instance()->CAP->current_user_can( |
| 323 | 323 | 'ee_edit_checkin', |
| 324 | 324 | 'espresso_registrations_toggle_checkin_status', |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | ) |
| 327 | 327 | ? ' clickable trigger-checkin' |
| 328 | 328 | : ''; |
| 329 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
| 330 | - return '<span class="checkin-icons checkedin-status-' . $checkinstatus . $toggle_active . '"' |
|
| 331 | - . ' data-_regid="' . $item->ID() . '"' |
|
| 332 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
| 333 | - . ' data-nonce="' . $nonce . '">' |
|
| 329 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
| 330 | + return '<span class="checkin-icons checkedin-status-'.$checkinstatus.$toggle_active.'"' |
|
| 331 | + . ' data-_regid="'.$item->ID().'"' |
|
| 332 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
| 333 | + . ' data-nonce="'.$nonce.'">' |
|
| 334 | 334 | . '</span>' |
| 335 | 335 | . $mobile_view_content; |
| 336 | 336 | } |
@@ -342,21 +342,21 @@ discard block |
||
| 342 | 342 | * @return mixed|string|void |
| 343 | 343 | * @throws \EE_Error |
| 344 | 344 | */ |
| 345 | - public function column_ATT_name( EE_Registration $item ) { |
|
| 345 | + public function column_ATT_name(EE_Registration $item) { |
|
| 346 | 346 | $attendee = $item->attendee(); |
| 347 | - if ( ! $attendee instanceof EE_Attendee ) { |
|
| 348 | - return __( 'No contact record for this registration.', 'event_espresso' ); |
|
| 347 | + if ( ! $attendee instanceof EE_Attendee) { |
|
| 348 | + return __('No contact record for this registration.', 'event_espresso'); |
|
| 349 | 349 | } |
| 350 | 350 | // edit attendee link |
| 351 | 351 | $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 352 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
| 352 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 353 | 353 | REG_ADMIN_URL |
| 354 | 354 | ); |
| 355 | 355 | $name_link = EE_Registry::instance()->CAP->current_user_can( |
| 356 | 356 | 'ee_edit_contacts', |
| 357 | 357 | 'espresso_registrations_edit_attendee' |
| 358 | 358 | ) |
| 359 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
| 359 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 360 | 360 | . $item->attendee()->full_name() |
| 361 | 361 | . '</a>' |
| 362 | 362 | : $item->attendee()->full_name(); |
@@ -364,10 +364,10 @@ discard block |
||
| 364 | 364 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
| 365 | 365 | : ''; |
| 366 | 366 | //add group details |
| 367 | - $name_link .= ' ' . sprintf( __( '(%s of %s)', 'event_espresso' ), $item->count(), $item->group_size() ); |
|
| 367 | + $name_link .= ' '.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 368 | 368 | //add regcode |
| 369 | 369 | $link = EE_Admin_Page::add_query_args_and_nonce( |
| 370 | - array( 'action' => 'view_registration', '_REG_ID' => $item->ID() ), |
|
| 370 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
| 371 | 371 | REG_ADMIN_URL |
| 372 | 372 | ); |
| 373 | 373 | $name_link .= '<br>'; |
@@ -376,37 +376,37 @@ discard block |
||
| 376 | 376 | 'view_registration', |
| 377 | 377 | $item->ID() |
| 378 | 378 | ) |
| 379 | - ? '<a href="' . $link . '" title="' . esc_attr__( 'View Registration Details', 'event_espresso' ) . '">' |
|
| 379 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
| 380 | 380 | . $item->reg_code() |
| 381 | 381 | . '</a>' |
| 382 | 382 | : $item->reg_code(); |
| 383 | 383 | //status |
| 384 | 384 | $name_link .= '<br><span class="ee-status-text-small">'; |
| 385 | - $name_link .= EEH_Template::pretty_status( $item->status_ID(), false, 'sentence' ); |
|
| 385 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
| 386 | 386 | $name_link .= '</span>'; |
| 387 | 387 | $actions = array(); |
| 388 | 388 | $DTT_ID = $this->_cur_dtt_id; |
| 389 | - $latest_related_datetime = empty( $DTT_ID ) && ! empty( $this->_req_data['event_id'] ) && $item instanceof EE_Registration |
|
| 389 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
| 390 | 390 | ? $item->get_latest_related_datetime() |
| 391 | 391 | : null; |
| 392 | 392 | $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
| 393 | 393 | ? $latest_related_datetime->ID() |
| 394 | 394 | : $DTT_ID; |
| 395 | - if ( ! empty( $DTT_ID ) |
|
| 395 | + if ( ! empty($DTT_ID) |
|
| 396 | 396 | && EE_Registry::instance()->CAP->current_user_can( |
| 397 | 397 | 'ee_read_checkins', |
| 398 | 398 | 'espresso_registrations_registration_checkins' |
| 399 | 399 | ) |
| 400 | 400 | ) { |
| 401 | 401 | $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
| 402 | - array( 'action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID ) |
|
| 402 | + array('action' => 'registration_checkins', '_REGID' => $item->ID(), 'DTT_ID' => $DTT_ID) |
|
| 403 | 403 | ); |
| 404 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' . esc_attr__( |
|
| 404 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="'.esc_attr__( |
|
| 405 | 405 | 'View all the check-ins/checkouts for this registrant', |
| 406 | 406 | 'event_espresso' |
| 407 | - ) . '">' . __( 'View', 'event_espresso' ) . '</a>'; |
|
| 407 | + ).'">'.__('View', 'event_espresso').'</a>'; |
|
| 408 | 408 | } |
| 409 | - return ! empty( $DTT_ID ) ? sprintf( '%1$s %2$s', $name_link, $this->row_actions( $actions ) ) : $name_link; |
|
| 409 | + return ! empty($DTT_ID) ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions)) : $name_link; |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * @param \EE_Registration $item |
| 416 | 416 | * @return string |
| 417 | 417 | */ |
| 418 | - public function column_ATT_email( EE_Registration $item ) { |
|
| 418 | + public function column_ATT_email(EE_Registration $item) { |
|
| 419 | 419 | $attendee = $item->attendee(); |
| 420 | 420 | return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
| 421 | 421 | } |
@@ -427,22 +427,22 @@ discard block |
||
| 427 | 427 | * @return bool|string |
| 428 | 428 | * @throws \EE_Error |
| 429 | 429 | */ |
| 430 | - public function column_Event( EE_Registration $item ) { |
|
| 430 | + public function column_Event(EE_Registration $item) { |
|
| 431 | 431 | try { |
| 432 | 432 | $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
| 433 | 433 | $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 434 | - array( 'action' => 'event_registrations', 'event_id' => $event->ID() ), |
|
| 434 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
| 435 | 435 | REG_ADMIN_URL |
| 436 | 436 | ); |
| 437 | 437 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
| 438 | 438 | 'ee_read_checkins', |
| 439 | 439 | 'espresso_registrations_registration_checkins' |
| 440 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' . esc_attr__( |
|
| 440 | + ) ? '<a href="'.$chkin_lnk_url.'" title="'.esc_attr__( |
|
| 441 | 441 | 'View Checkins for this Event', |
| 442 | 442 | 'event_espresso' |
| 443 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
| 444 | - } catch ( \EventEspresso\core\exceptions\EntityNotFoundException $e ) { |
|
| 445 | - $event_label = esc_html__( 'Unknown', 'event_espresso' ); |
|
| 443 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
| 444 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 445 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
| 446 | 446 | } |
| 447 | 447 | return $event_label; |
| 448 | 448 | } |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | * @param \EE_Registration $item |
| 454 | 454 | * @return mixed|string|void |
| 455 | 455 | */ |
| 456 | - public function column_PRC_name( EE_Registration $item ) { |
|
| 457 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __( "Unknown", "event_espresso" ); |
|
| 456 | + public function column_PRC_name(EE_Registration $item) { |
|
| 457 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | * @param \EE_Registration $item |
| 466 | 466 | * @return string |
| 467 | 467 | */ |
| 468 | - public function column__REG_final_price( EE_Registration $item ) { |
|
| 469 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
| 468 | + public function column__REG_final_price(EE_Registration $item) { |
|
| 469 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | * @return string |
| 479 | 479 | * @throws \EE_Error |
| 480 | 480 | */ |
| 481 | - public function column_TXN_paid( EE_Registration $item ) { |
|
| 482 | - if ( $item->count() === 1 ) { |
|
| 483 | - if ( $item->transaction()->paid() >= $item->transaction()->total() ) { |
|
| 481 | + public function column_TXN_paid(EE_Registration $item) { |
|
| 482 | + if ($item->count() === 1) { |
|
| 483 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
| 484 | 484 | return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
| 485 | 485 | } else { |
| 486 | 486 | $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
| 487 | - array( 'action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID() ), |
|
| 487 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
| 488 | 488 | TXN_ADMIN_URL |
| 489 | 489 | ); |
| 490 | 490 | return EE_Registry::instance()->CAP->current_user_can( |
@@ -497,13 +497,13 @@ discard block |
||
| 497 | 497 | . '" href="' |
| 498 | 498 | . $view_txn_lnk_url |
| 499 | 499 | . '" title="' |
| 500 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 500 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 501 | 501 | . '"> |
| 502 | 502 | ' |
| 503 | 503 | . $item->transaction()->pretty_paid() |
| 504 | 504 | . ' |
| 505 | 505 | </a> |
| 506 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 506 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
| 507 | 507 | } |
| 508 | 508 | } else { |
| 509 | 509 | return '<span class="reg-pad-rght"></span>'; |
@@ -519,13 +519,13 @@ discard block |
||
| 519 | 519 | * @return string |
| 520 | 520 | * @throws \EE_Error |
| 521 | 521 | */ |
| 522 | - public function column_TXN_total( EE_Registration $item ) { |
|
| 522 | + public function column_TXN_total(EE_Registration $item) { |
|
| 523 | 523 | $txn = $item->transaction(); |
| 524 | - $view_txn_url = add_query_arg( array( 'action' => 'view_transaction', 'TXN_ID' => $txn->ID() ), TXN_ADMIN_URL ); |
|
| 525 | - if ( $item->get( 'REG_count' ) === 1 ) { |
|
| 524 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
| 525 | + if ($item->get('REG_count') === 1) { |
|
| 526 | 526 | $line_total_obj = $txn->total_line_item(); |
| 527 | 527 | $txn_total = $line_total_obj instanceof EE_Line_Item |
| 528 | - ? $line_total_obj->get_pretty( 'LIN_total' ) |
|
| 528 | + ? $line_total_obj->get_pretty('LIN_total') |
|
| 529 | 529 | : __( |
| 530 | 530 | 'View Transaction', |
| 531 | 531 | 'event_espresso' |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | ) ? '<a href="' |
| 537 | 537 | . $view_txn_url |
| 538 | 538 | . '" title="' |
| 539 | - . esc_attr__( 'View Transaction', 'event_espresso' ) |
|
| 539 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 540 | 540 | . '"><span class="reg-pad-rght">' |
| 541 | 541 | . $txn_total |
| 542 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
| 542 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
| 543 | 543 | } else { |
| 544 | 544 | return '<span class="reg-pad-rght"></span>'; |
| 545 | 545 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -17,1145 +17,1145 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | - * |
|
| 23 | - * @type array |
|
| 24 | - */ |
|
| 25 | - protected $_reports_template_data = array(); |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Extend_Registrations_Admin_Page constructor. |
|
| 31 | - * |
|
| 32 | - * @param bool $routing |
|
| 33 | - */ |
|
| 34 | - public function __construct($routing = true) |
|
| 35 | - { |
|
| 36 | - parent::__construct($routing); |
|
| 37 | - if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - protected function _extend_page_config() |
|
| 47 | - { |
|
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | - ? $this->_req_data['_REG_ID'] |
|
| 51 | - : 0; |
|
| 52 | - // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | - // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | - // ? $this->_req_data['post'] : $att_id; |
|
| 55 | - $new_page_routes = array( |
|
| 56 | - 'reports' => array( |
|
| 57 | - 'func' => '_registration_reports', |
|
| 58 | - 'capability' => 'ee_read_registrations', |
|
| 59 | - ), |
|
| 60 | - 'registration_checkins' => array( |
|
| 61 | - 'func' => '_registration_checkin_list_table', |
|
| 62 | - 'capability' => 'ee_read_checkins', |
|
| 63 | - ), |
|
| 64 | - 'newsletter_selected_send' => array( |
|
| 65 | - 'func' => '_newsletter_selected_send', |
|
| 66 | - 'noheader' => true, |
|
| 67 | - 'capability' => 'ee_send_message', |
|
| 68 | - ), |
|
| 69 | - 'delete_checkin_rows' => array( |
|
| 70 | - 'func' => '_delete_checkin_rows', |
|
| 71 | - 'noheader' => true, |
|
| 72 | - 'capability' => 'ee_delete_checkins', |
|
| 73 | - ), |
|
| 74 | - 'delete_checkin_row' => array( |
|
| 75 | - 'func' => '_delete_checkin_row', |
|
| 76 | - 'noheader' => true, |
|
| 77 | - 'capability' => 'ee_delete_checkin', |
|
| 78 | - 'obj_id' => $reg_id, |
|
| 79 | - ), |
|
| 80 | - 'toggle_checkin_status' => array( |
|
| 81 | - 'func' => '_toggle_checkin_status', |
|
| 82 | - 'noheader' => true, |
|
| 83 | - 'capability' => 'ee_edit_checkin', |
|
| 84 | - 'obj_id' => $reg_id, |
|
| 85 | - ), |
|
| 86 | - 'event_registrations' => array( |
|
| 87 | - 'func' => '_event_registrations_list_table', |
|
| 88 | - 'capability' => 'ee_read_checkins', |
|
| 89 | - ), |
|
| 90 | - 'registrations_checkin_report' => array( |
|
| 91 | - 'func' => '_registrations_checkin_report', |
|
| 92 | - 'noheader' => true, |
|
| 93 | - 'capability' => 'ee_read_registrations', |
|
| 94 | - ), |
|
| 95 | - ); |
|
| 96 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 97 | - $new_page_config = array( |
|
| 98 | - 'reports' => array( |
|
| 99 | - 'nav' => array( |
|
| 100 | - 'label' => __('Reports', 'event_espresso'), |
|
| 101 | - 'order' => 30, |
|
| 102 | - ), |
|
| 103 | - 'help_tabs' => array( |
|
| 104 | - 'registrations_reports_help_tab' => array( |
|
| 105 | - 'title' => __('Registration Reports', 'event_espresso'), |
|
| 106 | - 'filename' => 'registrations_reports', |
|
| 107 | - ), |
|
| 108 | - ), |
|
| 109 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 110 | - 'require_nonce' => false, |
|
| 111 | - ), |
|
| 112 | - 'event_registrations' => array( |
|
| 113 | - 'nav' => array( |
|
| 114 | - 'label' => __('Event Check-In', 'event_espresso'), |
|
| 115 | - 'order' => 10, |
|
| 116 | - 'persistent' => true, |
|
| 117 | - ), |
|
| 118 | - 'help_tabs' => array( |
|
| 119 | - 'registrations_event_checkin_help_tab' => array( |
|
| 120 | - 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 121 | - 'filename' => 'registrations_event_checkin', |
|
| 122 | - ), |
|
| 123 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 124 | - 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 125 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 126 | - ), |
|
| 127 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
| 128 | - 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 129 | - 'filename' => 'registrations_event_checkin_filters', |
|
| 130 | - ), |
|
| 131 | - 'registrations_event_checkin_views_help_tab' => array( |
|
| 132 | - 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 133 | - 'filename' => 'registrations_event_checkin_views', |
|
| 134 | - ), |
|
| 135 | - 'registrations_event_checkin_other_help_tab' => array( |
|
| 136 | - 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 137 | - 'filename' => 'registrations_event_checkin_other', |
|
| 138 | - ), |
|
| 139 | - ), |
|
| 140 | - 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 141 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 142 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 143 | - 'metaboxes' => array(), |
|
| 144 | - 'require_nonce' => false, |
|
| 145 | - ), |
|
| 146 | - 'registration_checkins' => array( |
|
| 147 | - 'nav' => array( |
|
| 148 | - 'label' => __('Check-In Records', 'event_espresso'), |
|
| 149 | - 'order' => 15, |
|
| 150 | - 'persistent' => false, |
|
| 151 | - ), |
|
| 152 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 153 | - //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 154 | - 'metaboxes' => array(), |
|
| 155 | - 'require_nonce' => false, |
|
| 156 | - ), |
|
| 157 | - ); |
|
| 158 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 159 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 160 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - protected function _ajax_hooks() |
|
| 166 | - { |
|
| 167 | - parent::_ajax_hooks(); |
|
| 168 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - public function load_scripts_styles() |
|
| 174 | - { |
|
| 175 | - parent::load_scripts_styles(); |
|
| 176 | - //if newsletter message type is active then let's add filter and load js for it. |
|
| 177 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 178 | - //enqueue newsletter js |
|
| 179 | - wp_enqueue_script( |
|
| 180 | - 'ee-newsletter-trigger', |
|
| 181 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 182 | - array('ee-dialog'), |
|
| 183 | - EVENT_ESPRESSO_VERSION, |
|
| 184 | - true |
|
| 185 | - ); |
|
| 186 | - wp_enqueue_style( |
|
| 187 | - 'ee-newsletter-trigger-css', |
|
| 188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 189 | - array(), |
|
| 190 | - EVENT_ESPRESSO_VERSION |
|
| 191 | - ); |
|
| 192 | - //hook in buttons for newsletter message type trigger. |
|
| 193 | - add_action( |
|
| 194 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 195 | - array($this, 'add_newsletter_action_buttons'), |
|
| 196 | - 10 |
|
| 197 | - ); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - public function load_scripts_styles_reports() |
|
| 204 | - { |
|
| 205 | - wp_register_script( |
|
| 206 | - 'ee-reg-reports-js', |
|
| 207 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 208 | - array('google-charts'), |
|
| 209 | - EVENT_ESPRESSO_VERSION, |
|
| 210 | - true |
|
| 211 | - ); |
|
| 212 | - wp_enqueue_script('ee-reg-reports-js'); |
|
| 213 | - $this->_registration_reports_js_setup(); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - protected function _add_screen_options_event_registrations() |
|
| 219 | - { |
|
| 220 | - $this->_per_page_screen_option(); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - protected function _add_screen_options_registration_checkins() |
|
| 226 | - { |
|
| 227 | - $page_title = $this->_admin_page_title; |
|
| 228 | - $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 229 | - $this->_per_page_screen_option(); |
|
| 230 | - $this->_admin_page_title = $page_title; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - protected function _set_list_table_views_event_registrations() |
|
| 236 | - { |
|
| 237 | - $this->_views = array( |
|
| 238 | - 'all' => array( |
|
| 239 | - 'slug' => 'all', |
|
| 240 | - 'label' => __('All', 'event_espresso'), |
|
| 241 | - 'count' => 0, |
|
| 242 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 243 | - ? array() |
|
| 244 | - : array( |
|
| 245 | - 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
|
| 246 | - //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
|
| 247 | - ), |
|
| 248 | - ), |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - protected function _set_list_table_views_registration_checkins() |
|
| 255 | - { |
|
| 256 | - $this->_views = array( |
|
| 257 | - 'all' => array( |
|
| 258 | - 'slug' => 'all', |
|
| 259 | - 'label' => __('All', 'event_espresso'), |
|
| 260 | - 'count' => 0, |
|
| 261 | - 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 262 | - ), |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * callback for ajax action. |
|
| 270 | - * |
|
| 271 | - * @since 4.3.0 |
|
| 272 | - * @return void (JSON) |
|
| 273 | - * @throws \EE_Error |
|
| 274 | - */ |
|
| 275 | - public function get_newsletter_form_content() |
|
| 276 | - { |
|
| 277 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 278 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 279 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 280 | - ) : ''; |
|
| 281 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 282 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 283 | - //let's get the mtp for the incoming MTP_ ID |
|
| 284 | - if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 285 | - EE_Error::add_error( |
|
| 286 | - __( |
|
| 287 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 288 | - 'event_espresso' |
|
| 289 | - ), |
|
| 290 | - __FILE__, |
|
| 291 | - __FUNCTION__, |
|
| 292 | - __LINE__ |
|
| 293 | - ); |
|
| 294 | - $this->_template_args['success'] = false; |
|
| 295 | - $this->_template_args['error'] = true; |
|
| 296 | - $this->_return_json(); |
|
| 297 | - } |
|
| 298 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 299 | - if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 300 | - EE_Error::add_error( |
|
| 301 | - sprintf( |
|
| 302 | - __( |
|
| 303 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 304 | - 'event_espresso' |
|
| 305 | - ), |
|
| 306 | - $this->_req_data['GRP_ID'] |
|
| 307 | - ), |
|
| 308 | - __FILE__, |
|
| 309 | - __FUNCTION__, |
|
| 310 | - __LINE__ |
|
| 311 | - ); |
|
| 312 | - $this->_template_args['success'] = false; |
|
| 313 | - $this->_template_args['error'] = true; |
|
| 314 | - $this->_return_json(); |
|
| 315 | - } |
|
| 316 | - $MTPs = $MTPG->context_templates(); |
|
| 317 | - $MTPs = $MTPs['attendee']; |
|
| 318 | - $template_fields = array(); |
|
| 319 | - /** @var EE_Message_Template $MTP */ |
|
| 320 | - foreach ($MTPs as $MTP) { |
|
| 321 | - $field = $MTP->get('MTP_template_field'); |
|
| 322 | - if ($field === 'content') { |
|
| 323 | - $content = $MTP->get('MTP_content'); |
|
| 324 | - if ( ! empty($content['newsletter_content'])) { |
|
| 325 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 326 | - } |
|
| 327 | - continue; |
|
| 328 | - } |
|
| 329 | - $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 330 | - } |
|
| 331 | - $this->_template_args['success'] = true; |
|
| 332 | - $this->_template_args['error'] = false; |
|
| 333 | - $this->_template_args['data'] = array( |
|
| 334 | - 'batch_message_from' => isset($template_fields['from']) |
|
| 335 | - ? $template_fields['from'] |
|
| 336 | - : '', |
|
| 337 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
| 338 | - ? $template_fields['subject'] |
|
| 339 | - : '', |
|
| 340 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 341 | - ? $template_fields['newsletter_content'] |
|
| 342 | - : '', |
|
| 343 | - ); |
|
| 344 | - $this->_return_json(); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 351 | - * |
|
| 352 | - * @since 4.3.0 |
|
| 353 | - * @param EE_Admin_List_Table $list_table |
|
| 354 | - * @return void |
|
| 355 | - */ |
|
| 356 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 357 | - { |
|
| 358 | - if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | - 'ee_send_message', |
|
| 360 | - 'espresso_registrations_newsletter_selected_send' |
|
| 361 | - ) |
|
| 362 | - ) { |
|
| 363 | - return; |
|
| 364 | - } |
|
| 365 | - $routes_to_add_to = array( |
|
| 366 | - 'contact_list', |
|
| 367 | - 'event_registrations', |
|
| 368 | - 'default', |
|
| 369 | - ); |
|
| 370 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 371 | - if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 372 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 373 | - ) { |
|
| 374 | - echo ''; |
|
| 375 | - } else { |
|
| 376 | - $button_text = sprintf( |
|
| 377 | - __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 378 | - '<span class="send-selected-newsletter-count">0</span>' |
|
| 379 | - ); |
|
| 380 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 381 | - . $button_text |
|
| 382 | - . '</button>'; |
|
| 383 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 384 | - } |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - |
|
| 390 | - public function newsletter_send_form_skeleton() |
|
| 391 | - { |
|
| 392 | - $list_table = $this->_list_table_object; |
|
| 393 | - $codes = array(); |
|
| 394 | - //need to templates for the newsletter message type for the template selector. |
|
| 395 | - $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 396 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 397 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 398 | - ); |
|
| 399 | - foreach ($mtps as $mtp) { |
|
| 400 | - $name = $mtp->name(); |
|
| 401 | - $values[] = array( |
|
| 402 | - 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 403 | - 'id' => $mtp->ID(), |
|
| 404 | - ); |
|
| 405 | - } |
|
| 406 | - //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 407 | - $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 408 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
| 409 | - $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 410 | - } |
|
| 411 | - $shortcodes = $codes; |
|
| 412 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 413 | - $form_template_args = array( |
|
| 414 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 415 | - 'form_route' => 'newsletter_selected_send', |
|
| 416 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 417 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 418 | - 'redirect_back_to' => $this->_req_action, |
|
| 419 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 420 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 421 | - 'shortcodes' => $shortcodes, |
|
| 422 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 423 | - ); |
|
| 424 | - EEH_Template::display_template($form_template, $form_template_args); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Handles sending selected registrations/contacts a newsletter. |
|
| 431 | - * |
|
| 432 | - * @since 4.3.0 |
|
| 433 | - * @return void |
|
| 434 | - * @throws \EE_Error |
|
| 435 | - */ |
|
| 436 | - protected function _newsletter_selected_send() |
|
| 437 | - { |
|
| 438 | - $success = true; |
|
| 439 | - //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 440 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 441 | - EE_Error::add_error( |
|
| 442 | - __( |
|
| 443 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 444 | - 'event_espresso' |
|
| 445 | - ), |
|
| 446 | - __FILE__, |
|
| 447 | - __FUNCTION__, |
|
| 448 | - __LINE__ |
|
| 449 | - ); |
|
| 450 | - $success = false; |
|
| 451 | - } |
|
| 452 | - if ($success) { |
|
| 453 | - //update Message template in case there are any changes |
|
| 454 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 455 | - $this->_req_data['newsletter_mtp_selected'] |
|
| 456 | - ); |
|
| 457 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 458 | - ? $Message_Template_Group->context_templates() |
|
| 459 | - : array(); |
|
| 460 | - if (empty($Message_Templates)) { |
|
| 461 | - EE_Error::add_error( |
|
| 462 | - __( |
|
| 463 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 464 | - 'event_espresso' |
|
| 465 | - ), |
|
| 466 | - __FILE__, |
|
| 467 | - __FUNCTION__, |
|
| 468 | - __LINE__ |
|
| 469 | - ); |
|
| 470 | - } |
|
| 471 | - //let's just update the specific fields |
|
| 472 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 473 | - if ($Message_Template instanceof EE_Message_Template) { |
|
| 474 | - $field = $Message_Template->get('MTP_template_field'); |
|
| 475 | - $content = $Message_Template->get('MTP_content'); |
|
| 476 | - $new_content = $content; |
|
| 477 | - switch ($field) { |
|
| 478 | - case 'from' : |
|
| 479 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 480 | - ? $this->_req_data['batch_message']['from'] |
|
| 481 | - : $content; |
|
| 482 | - break; |
|
| 483 | - case 'subject' : |
|
| 484 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 485 | - ? $this->_req_data['batch_message']['subject'] |
|
| 486 | - : $content; |
|
| 487 | - break; |
|
| 488 | - case 'content' : |
|
| 489 | - $new_content = $content; |
|
| 490 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 491 | - ? $this->_req_data['batch_message']['content'] |
|
| 492 | - : $content['newsletter_content']; |
|
| 493 | - break; |
|
| 494 | - default : |
|
| 495 | - //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 496 | - continue 2; |
|
| 497 | - } |
|
| 498 | - $Message_Template->set('MTP_content', $new_content); |
|
| 499 | - $Message_Template->save(); |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 503 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 504 | - ? $this->_req_data['batch_message']['id_type'] |
|
| 505 | - : 'registration'; |
|
| 506 | - //id_type will affect how we assemble the ids. |
|
| 507 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 508 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 509 | - : array(); |
|
| 510 | - $registrations_used_for_contact_data = array(); |
|
| 511 | - //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 512 | - switch ($id_type) { |
|
| 513 | - case 'registration' : |
|
| 514 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 515 | - array( |
|
| 516 | - array( |
|
| 517 | - 'REG_ID' => array('IN', $ids), |
|
| 518 | - ), |
|
| 519 | - ) |
|
| 520 | - ); |
|
| 521 | - break; |
|
| 522 | - case 'contact' : |
|
| 523 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 524 | - ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - do_action( |
|
| 528 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 529 | - $registrations_used_for_contact_data, |
|
| 530 | - $Message_Template_Group->ID() |
|
| 531 | - ); |
|
| 532 | - //kept for backward compat, internally we no longer use this action. |
|
| 533 | - //@deprecated 4.8.36.rc.002 |
|
| 534 | - $contacts = $id_type === 'registration' |
|
| 535 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 536 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 537 | - do_action( |
|
| 538 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 539 | - $contacts, |
|
| 540 | - $Message_Template_Group->ID() |
|
| 541 | - ); |
|
| 542 | - } |
|
| 543 | - $query_args = array( |
|
| 544 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 545 | - ? $this->_req_data['redirect_back_to'] |
|
| 546 | - : 'default', |
|
| 547 | - ); |
|
| 548 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - |
|
| 552 | - |
|
| 553 | - /** |
|
| 554 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 555 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 556 | - */ |
|
| 557 | - protected function _registration_reports_js_setup() |
|
| 558 | - { |
|
| 559 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 560 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - |
|
| 564 | - |
|
| 565 | - /** |
|
| 566 | - * generates Business Reports regarding Registrations |
|
| 567 | - * |
|
| 568 | - * @access protected |
|
| 569 | - * @return void |
|
| 570 | - */ |
|
| 571 | - protected function _registration_reports() |
|
| 572 | - { |
|
| 573 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 574 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 575 | - $template_path, |
|
| 576 | - $this->_reports_template_data, |
|
| 577 | - true |
|
| 578 | - ); |
|
| 579 | - // the final template wrapper |
|
| 580 | - $this->display_admin_page_with_no_sidebar(); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - |
|
| 584 | - |
|
| 585 | - /** |
|
| 586 | - * Generates Business Report showing total registrations per day. |
|
| 587 | - * |
|
| 588 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 589 | - * @return string |
|
| 590 | - */ |
|
| 591 | - private function _registrations_per_day_report($period = '-1 month') |
|
| 592 | - { |
|
| 593 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 594 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 595 | - $results = (array)$results; |
|
| 596 | - $regs = array(); |
|
| 597 | - $subtitle = ''; |
|
| 598 | - if ($results) { |
|
| 599 | - $column_titles = array(); |
|
| 600 | - $tracker = 0; |
|
| 601 | - foreach ($results as $result) { |
|
| 602 | - $report_column_values = array(); |
|
| 603 | - foreach ($result as $property_name => $property_value) { |
|
| 604 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 605 | - : (int)$property_value; |
|
| 606 | - $report_column_values[] = $property_value; |
|
| 607 | - if ($tracker === 0) { |
|
| 608 | - if ($property_name === 'Registration_REG_date') { |
|
| 609 | - $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 610 | - } else { |
|
| 611 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 612 | - } |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - $tracker++; |
|
| 616 | - $regs[] = $report_column_values; |
|
| 617 | - } |
|
| 618 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 619 | - array_unshift($regs, $column_titles); |
|
| 620 | - //setup the date range. |
|
| 621 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 622 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 623 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 624 | - $subtitle = sprintf( |
|
| 625 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 626 | - $beginning_date->format('Y-m-d'), |
|
| 627 | - $ending_date->format('Y-m-d') |
|
| 628 | - ); |
|
| 629 | - } |
|
| 630 | - $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 631 | - $report_params = array( |
|
| 632 | - 'title' => $report_title, |
|
| 633 | - 'subtitle' => $subtitle, |
|
| 634 | - 'id' => $report_ID, |
|
| 635 | - 'regs' => $regs, |
|
| 636 | - 'noResults' => empty($regs), |
|
| 637 | - 'noRegsMsg' => sprintf( |
|
| 638 | - __( |
|
| 639 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 640 | - 'event_espresso' |
|
| 641 | - ), |
|
| 642 | - '<h2>' . $report_title . '</h2><p>', |
|
| 643 | - '</p>' |
|
| 644 | - ), |
|
| 645 | - ); |
|
| 646 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 647 | - return $report_ID; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - |
|
| 652 | - /** |
|
| 653 | - * Generates Business Report showing total registrations per event. |
|
| 654 | - * |
|
| 655 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 656 | - * @return string |
|
| 657 | - */ |
|
| 658 | - private function _registrations_per_event_report($period = '-1 month') |
|
| 659 | - { |
|
| 660 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 661 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 662 | - $results = (array)$results; |
|
| 663 | - $regs = array(); |
|
| 664 | - $subtitle = ''; |
|
| 665 | - if ($results) { |
|
| 666 | - $column_titles = array(); |
|
| 667 | - $tracker = 0; |
|
| 668 | - foreach ($results as $result) { |
|
| 669 | - $report_column_values = array(); |
|
| 670 | - foreach ($result as $property_name => $property_value) { |
|
| 671 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 672 | - $property_value, |
|
| 673 | - 4, |
|
| 674 | - '...' |
|
| 675 | - ) : (int)$property_value; |
|
| 676 | - $report_column_values[] = $property_value; |
|
| 677 | - if ($tracker === 0) { |
|
| 678 | - if ($property_name === 'Registration_Event') { |
|
| 679 | - $column_titles[] = __('Event', 'event_espresso'); |
|
| 680 | - } else { |
|
| 681 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - $tracker++; |
|
| 686 | - $regs[] = $report_column_values; |
|
| 687 | - } |
|
| 688 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 689 | - array_unshift($regs, $column_titles); |
|
| 690 | - //setup the date range. |
|
| 691 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 692 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 693 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 694 | - $subtitle = sprintf( |
|
| 695 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 696 | - $beginning_date->format('Y-m-d'), |
|
| 697 | - $ending_date->format('Y-m-d') |
|
| 698 | - ); |
|
| 699 | - } |
|
| 700 | - $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 701 | - $report_params = array( |
|
| 702 | - 'title' => $report_title, |
|
| 703 | - 'subtitle' => $subtitle, |
|
| 704 | - 'id' => $report_ID, |
|
| 705 | - 'regs' => $regs, |
|
| 706 | - 'noResults' => empty($regs), |
|
| 707 | - 'noRegsMsg' => sprintf( |
|
| 708 | - __( |
|
| 709 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 710 | - 'event_espresso' |
|
| 711 | - ), |
|
| 712 | - '<h2>' . $report_title . '</h2><p>', |
|
| 713 | - '</p>' |
|
| 714 | - ), |
|
| 715 | - ); |
|
| 716 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 717 | - return $report_ID; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 724 | - * |
|
| 725 | - * @access protected |
|
| 726 | - * @return void |
|
| 727 | - * @throws \EE_Error |
|
| 728 | - */ |
|
| 729 | - protected function _registration_checkin_list_table() |
|
| 730 | - { |
|
| 731 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 732 | - $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 733 | - /** @var EE_Registration $reg */ |
|
| 734 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 735 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 736 | - 'new_registration', |
|
| 737 | - 'add-registrant', |
|
| 738 | - array('event_id' => $reg->event_ID()), |
|
| 739 | - 'add-new-h2' |
|
| 740 | - ); |
|
| 741 | - $legend_items = array( |
|
| 742 | - 'checkin' => array( |
|
| 743 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 744 | - 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 745 | - ), |
|
| 746 | - 'checkout' => array( |
|
| 747 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 748 | - 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 749 | - ), |
|
| 750 | - ); |
|
| 751 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 752 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 753 | - $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 754 | - array( |
|
| 755 | - 'action' => 'event_registrations', |
|
| 756 | - 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), |
|
| 757 | - 'DTT_ID' => $dtt_id, |
|
| 758 | - ), |
|
| 759 | - $this->_admin_base_url |
|
| 760 | - ) : ''; |
|
| 761 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 762 | - ? '<h2>' . sprintf( |
|
| 763 | - __("%s's check in records for %s at the event, %s", 'event_espresso'), |
|
| 764 | - '<span id="checkin-attendee-name">' |
|
| 765 | - . EEM_Registration::instance() |
|
| 766 | - ->get_one_by_ID($reg_id) |
|
| 767 | - ->get_first_related('Attendee') |
|
| 768 | - ->full_name() . '</span>', |
|
| 769 | - '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 770 | - . EEM_Datetime::instance() |
|
| 771 | - ->get_one_by_ID($dtt_id) |
|
| 772 | - ->start_date_and_time() . ' - ' |
|
| 773 | - . EEM_Datetime::instance() |
|
| 774 | - ->get_one_by_ID($dtt_id) |
|
| 775 | - ->end_date_and_time() . '</a></span>', |
|
| 776 | - '<span id="checkin-event-name">' |
|
| 777 | - . EEM_Datetime::instance() |
|
| 778 | - ->get_one_by_ID($dtt_id) |
|
| 779 | - ->get_first_related('Event') |
|
| 780 | - ->get('EVT_name') . '</span>' |
|
| 781 | - ) . '</h2>' |
|
| 782 | - : ''; |
|
| 783 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 784 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 785 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 786 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 787 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - |
|
| 791 | - |
|
| 792 | - /** |
|
| 793 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
| 794 | - * |
|
| 795 | - * @return void (JSON) |
|
| 796 | - */ |
|
| 797 | - public function toggle_checkin_status() |
|
| 798 | - { |
|
| 799 | - //first make sure we have the necessary data |
|
| 800 | - if ( ! isset($this->_req_data['_regid'])) { |
|
| 801 | - EE_Error::add_error( |
|
| 802 | - __( |
|
| 803 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 804 | - 'event_espresso' |
|
| 805 | - ), |
|
| 806 | - __FILE__, |
|
| 807 | - __FUNCTION__, |
|
| 808 | - __LINE__ |
|
| 809 | - ); |
|
| 810 | - $this->_template_args['success'] = false; |
|
| 811 | - $this->_template_args['error'] = true; |
|
| 812 | - $this->_return_json(); |
|
| 813 | - }; |
|
| 814 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 815 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 816 | - : ''; |
|
| 817 | - $nonce_ref = 'checkin_nonce'; |
|
| 818 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 819 | - //beautiful! Made it this far so let's get the status. |
|
| 820 | - $new_status = $this->_toggle_checkin_status(); |
|
| 821 | - //setup new class to return via ajax |
|
| 822 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 823 | - . $new_status; |
|
| 824 | - $this->_template_args['success'] = true; |
|
| 825 | - $this->_return_json(); |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * handles toggling the checkin status for the registration, |
|
| 832 | - * |
|
| 833 | - * @access protected |
|
| 834 | - * @return int|void |
|
| 835 | - */ |
|
| 836 | - protected function _toggle_checkin_status() |
|
| 837 | - { |
|
| 838 | - //first let's get the query args out of the way for the redirect |
|
| 839 | - $query_args = array( |
|
| 840 | - 'action' => 'event_registrations', |
|
| 841 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 842 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 843 | - ); |
|
| 844 | - $new_status = false; |
|
| 845 | - // bulk action check in toggle |
|
| 846 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 847 | - // cycle thru checkboxes |
|
| 848 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 849 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 850 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 851 | - } |
|
| 852 | - } elseif (isset($this->_req_data['_regid'])) { |
|
| 853 | - //coming from ajax request |
|
| 854 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 855 | - $query_args['DTT_ID'] = $DTT_ID; |
|
| 856 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 857 | - } else { |
|
| 858 | - EE_Error::add_error( |
|
| 859 | - __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 860 | - __FILE__, |
|
| 861 | - __FUNCTION__, |
|
| 862 | - __LINE__ |
|
| 863 | - ); |
|
| 864 | - } |
|
| 865 | - if (defined('DOING_AJAX')) { |
|
| 866 | - return $new_status; |
|
| 867 | - } |
|
| 868 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - |
|
| 872 | - |
|
| 873 | - /** |
|
| 874 | - * This is toggles a single Check-in for the given registration and datetime. |
|
| 875 | - * |
|
| 876 | - * @param int $REG_ID The registration we're toggling |
|
| 877 | - * @param int $DTT_ID The datetime we're toggling |
|
| 878 | - * @return int The new status toggled to. |
|
| 879 | - * @throws \EE_Error |
|
| 880 | - */ |
|
| 881 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 882 | - { |
|
| 883 | - /** @var EE_Registration $REG */ |
|
| 884 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 885 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 886 | - if ($new_status !== false) { |
|
| 887 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 888 | - } else { |
|
| 889 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 890 | - $new_status = false; |
|
| 891 | - } |
|
| 892 | - return $new_status; |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - |
|
| 896 | - |
|
| 897 | - /** |
|
| 898 | - * Takes care of deleting multiple EE_Checkin table rows |
|
| 899 | - * |
|
| 900 | - * @access protected |
|
| 901 | - * @return void |
|
| 902 | - * @throws \EE_Error |
|
| 903 | - */ |
|
| 904 | - protected function _delete_checkin_rows() |
|
| 905 | - { |
|
| 906 | - $query_args = array( |
|
| 907 | - 'action' => 'registration_checkins', |
|
| 908 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 909 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 910 | - ); |
|
| 911 | - $errors = 0; |
|
| 912 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 913 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 914 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 915 | - $errors++; |
|
| 916 | - } |
|
| 917 | - } |
|
| 918 | - } else { |
|
| 919 | - EE_Error::add_error( |
|
| 920 | - __( |
|
| 921 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 922 | - 'event_espresso' |
|
| 923 | - ), |
|
| 924 | - __FILE__, |
|
| 925 | - __FUNCTION__, |
|
| 926 | - __LINE__ |
|
| 927 | - ); |
|
| 928 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 929 | - } |
|
| 930 | - if ($errors > 0) { |
|
| 931 | - EE_Error::add_error( |
|
| 932 | - sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 933 | - __FILE__, |
|
| 934 | - __FUNCTION__, |
|
| 935 | - __LINE__ |
|
| 936 | - ); |
|
| 937 | - } else { |
|
| 938 | - EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 939 | - } |
|
| 940 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 941 | - } |
|
| 942 | - |
|
| 943 | - |
|
| 944 | - |
|
| 945 | - /** |
|
| 946 | - * Deletes a single EE_Checkin row |
|
| 947 | - * |
|
| 948 | - * @return void |
|
| 949 | - * @throws \EE_Error |
|
| 950 | - */ |
|
| 951 | - protected function _delete_checkin_row() |
|
| 952 | - { |
|
| 953 | - $query_args = array( |
|
| 954 | - 'action' => 'registration_checkins', |
|
| 955 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 956 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 957 | - ); |
|
| 958 | - if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 959 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 960 | - EE_Error::add_error( |
|
| 961 | - __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 962 | - __FILE__, |
|
| 963 | - __FUNCTION__, |
|
| 964 | - __LINE__ |
|
| 965 | - ); |
|
| 966 | - } else { |
|
| 967 | - EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 968 | - } |
|
| 969 | - } else { |
|
| 970 | - EE_Error::add_error( |
|
| 971 | - __( |
|
| 972 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 973 | - 'event_espresso' |
|
| 974 | - ), |
|
| 975 | - __FILE__, |
|
| 976 | - __FUNCTION__, |
|
| 977 | - __LINE__ |
|
| 978 | - ); |
|
| 979 | - } |
|
| 980 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * generates HTML for the Event Registrations List Table |
|
| 987 | - * |
|
| 988 | - * @access protected |
|
| 989 | - * @return void |
|
| 990 | - * @throws \EE_Error |
|
| 991 | - */ |
|
| 992 | - protected function _event_registrations_list_table() |
|
| 993 | - { |
|
| 994 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 995 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 996 | - ? $this->get_action_link_or_button( |
|
| 997 | - 'new_registration', |
|
| 998 | - 'add-registrant', |
|
| 999 | - array('event_id' => $this->_req_data['event_id']), |
|
| 1000 | - 'add-new-h2', |
|
| 1001 | - '', |
|
| 1002 | - false |
|
| 1003 | - ) |
|
| 1004 | - : ''; |
|
| 1005 | - $legend_items = array( |
|
| 1006 | - 'star-icon' => array( |
|
| 1007 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1008 | - 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1009 | - ), |
|
| 1010 | - 'checkin' => array( |
|
| 1011 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 1012 | - 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1013 | - ), |
|
| 1014 | - 'checkout' => array( |
|
| 1015 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 1016 | - 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1017 | - ), |
|
| 1018 | - 'nocheckinrecord' => array( |
|
| 1019 | - 'class' => 'dashicons dashicons-no', |
|
| 1020 | - 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1021 | - ), |
|
| 1022 | - 'view_details' => array( |
|
| 1023 | - 'class' => 'dashicons dashicons-search', |
|
| 1024 | - 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1025 | - ), |
|
| 1026 | - 'approved_status' => array( |
|
| 1027 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1028 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1029 | - ), |
|
| 1030 | - 'cancelled_status' => array( |
|
| 1031 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1032 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1033 | - ), |
|
| 1034 | - 'declined_status' => array( |
|
| 1035 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1036 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1037 | - ), |
|
| 1038 | - 'not_approved' => array( |
|
| 1039 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1040 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1041 | - ), |
|
| 1042 | - 'pending_status' => array( |
|
| 1043 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1044 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1045 | - ), |
|
| 1046 | - 'wait_list' => array( |
|
| 1047 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1048 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1049 | - ), |
|
| 1050 | - ); |
|
| 1051 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1052 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1053 | - $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1054 | - ? '<h2>' . sprintf( |
|
| 1055 | - __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1056 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1057 | - ) . '</h2>' |
|
| 1058 | - : ''; |
|
| 1059 | - //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1060 | - /** @var EE_Event $event */ |
|
| 1061 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1062 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1063 | - $datetime = null; |
|
| 1064 | - if ($event instanceof EE_Event) { |
|
| 1065 | - $datetimes_on_event = $event->datetimes(); |
|
| 1066 | - if (count($datetimes_on_event) === 1) { |
|
| 1067 | - $datetime = reset($datetimes_on_event); |
|
| 1068 | - } |
|
| 1069 | - } |
|
| 1070 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1071 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1072 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1073 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1074 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1075 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1076 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1077 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1078 | - } |
|
| 1079 | - //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1080 | - //represents |
|
| 1081 | - if ( ! $datetime instanceof EE_Datetime) { |
|
| 1082 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1083 | - . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1084 | - 'event_espresso') |
|
| 1085 | - . '</p>'; |
|
| 1086 | - } |
|
| 1087 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1092 | - * conditions) |
|
| 1093 | - * |
|
| 1094 | - * @return void ends the request by a redirect or download |
|
| 1095 | - */ |
|
| 1096 | - public function _registrations_checkin_report() |
|
| 1097 | - { |
|
| 1098 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1099 | - } |
|
| 1100 | - |
|
| 1101 | - /** |
|
| 1102 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1103 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1104 | - * |
|
| 1105 | - * @param array $request |
|
| 1106 | - * @param int $per_page |
|
| 1107 | - * @param bool $count |
|
| 1108 | - * @return array |
|
| 1109 | - */ |
|
| 1110 | - protected function _get_checkin_query_params_from_request( |
|
| 1111 | - $request, |
|
| 1112 | - $per_page = 10, |
|
| 1113 | - $count = false |
|
| 1114 | - ) { |
|
| 1115 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1116 | - //unlike the regular registrations list table, |
|
| 1117 | - $status_ids_array = apply_filters( |
|
| 1118 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1119 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1120 | - ); |
|
| 1121 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1122 | - return $query_params; |
|
| 1123 | - } |
|
| 1124 | - |
|
| 1125 | - |
|
| 1126 | - |
|
| 1127 | - |
|
| 1128 | - /** |
|
| 1129 | - * Gets registrations for an event |
|
| 1130 | - * |
|
| 1131 | - * @param int $per_page |
|
| 1132 | - * @param bool $count whether to return count or data. |
|
| 1133 | - * @param bool $trash |
|
| 1134 | - * @param string $orderby |
|
| 1135 | - * @return EE_Registration[]|int |
|
| 1136 | - * @throws \EE_Error |
|
| 1137 | - */ |
|
| 1138 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1139 | - { |
|
| 1140 | - //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1141 | - $request = $this->_req_data; |
|
| 1142 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1143 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | - if($trash){ |
|
| 1145 | - $request['status'] = 'trash'; |
|
| 1146 | - } |
|
| 1147 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1148 | - /** |
|
| 1149 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1150 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1151 | - * @see EEM_Base::get_all() |
|
| 1152 | - */ |
|
| 1153 | - $query_params['group_by'] = ''; |
|
| 1154 | - |
|
| 1155 | - return $count |
|
| 1156 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1157 | - /** @type EE_Registration[] */ |
|
| 1158 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1159 | - } |
|
| 20 | + /** |
|
| 21 | + * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | + * |
|
| 23 | + * @type array |
|
| 24 | + */ |
|
| 25 | + protected $_reports_template_data = array(); |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Extend_Registrations_Admin_Page constructor. |
|
| 31 | + * |
|
| 32 | + * @param bool $routing |
|
| 33 | + */ |
|
| 34 | + public function __construct($routing = true) |
|
| 35 | + { |
|
| 36 | + parent::__construct($routing); |
|
| 37 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + protected function _extend_page_config() |
|
| 47 | + { |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | + ? $this->_req_data['_REG_ID'] |
|
| 51 | + : 0; |
|
| 52 | + // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | + // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | + // ? $this->_req_data['post'] : $att_id; |
|
| 55 | + $new_page_routes = array( |
|
| 56 | + 'reports' => array( |
|
| 57 | + 'func' => '_registration_reports', |
|
| 58 | + 'capability' => 'ee_read_registrations', |
|
| 59 | + ), |
|
| 60 | + 'registration_checkins' => array( |
|
| 61 | + 'func' => '_registration_checkin_list_table', |
|
| 62 | + 'capability' => 'ee_read_checkins', |
|
| 63 | + ), |
|
| 64 | + 'newsletter_selected_send' => array( |
|
| 65 | + 'func' => '_newsletter_selected_send', |
|
| 66 | + 'noheader' => true, |
|
| 67 | + 'capability' => 'ee_send_message', |
|
| 68 | + ), |
|
| 69 | + 'delete_checkin_rows' => array( |
|
| 70 | + 'func' => '_delete_checkin_rows', |
|
| 71 | + 'noheader' => true, |
|
| 72 | + 'capability' => 'ee_delete_checkins', |
|
| 73 | + ), |
|
| 74 | + 'delete_checkin_row' => array( |
|
| 75 | + 'func' => '_delete_checkin_row', |
|
| 76 | + 'noheader' => true, |
|
| 77 | + 'capability' => 'ee_delete_checkin', |
|
| 78 | + 'obj_id' => $reg_id, |
|
| 79 | + ), |
|
| 80 | + 'toggle_checkin_status' => array( |
|
| 81 | + 'func' => '_toggle_checkin_status', |
|
| 82 | + 'noheader' => true, |
|
| 83 | + 'capability' => 'ee_edit_checkin', |
|
| 84 | + 'obj_id' => $reg_id, |
|
| 85 | + ), |
|
| 86 | + 'event_registrations' => array( |
|
| 87 | + 'func' => '_event_registrations_list_table', |
|
| 88 | + 'capability' => 'ee_read_checkins', |
|
| 89 | + ), |
|
| 90 | + 'registrations_checkin_report' => array( |
|
| 91 | + 'func' => '_registrations_checkin_report', |
|
| 92 | + 'noheader' => true, |
|
| 93 | + 'capability' => 'ee_read_registrations', |
|
| 94 | + ), |
|
| 95 | + ); |
|
| 96 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 97 | + $new_page_config = array( |
|
| 98 | + 'reports' => array( |
|
| 99 | + 'nav' => array( |
|
| 100 | + 'label' => __('Reports', 'event_espresso'), |
|
| 101 | + 'order' => 30, |
|
| 102 | + ), |
|
| 103 | + 'help_tabs' => array( |
|
| 104 | + 'registrations_reports_help_tab' => array( |
|
| 105 | + 'title' => __('Registration Reports', 'event_espresso'), |
|
| 106 | + 'filename' => 'registrations_reports', |
|
| 107 | + ), |
|
| 108 | + ), |
|
| 109 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 110 | + 'require_nonce' => false, |
|
| 111 | + ), |
|
| 112 | + 'event_registrations' => array( |
|
| 113 | + 'nav' => array( |
|
| 114 | + 'label' => __('Event Check-In', 'event_espresso'), |
|
| 115 | + 'order' => 10, |
|
| 116 | + 'persistent' => true, |
|
| 117 | + ), |
|
| 118 | + 'help_tabs' => array( |
|
| 119 | + 'registrations_event_checkin_help_tab' => array( |
|
| 120 | + 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 121 | + 'filename' => 'registrations_event_checkin', |
|
| 122 | + ), |
|
| 123 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 124 | + 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 125 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 126 | + ), |
|
| 127 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
| 128 | + 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 129 | + 'filename' => 'registrations_event_checkin_filters', |
|
| 130 | + ), |
|
| 131 | + 'registrations_event_checkin_views_help_tab' => array( |
|
| 132 | + 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 133 | + 'filename' => 'registrations_event_checkin_views', |
|
| 134 | + ), |
|
| 135 | + 'registrations_event_checkin_other_help_tab' => array( |
|
| 136 | + 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 137 | + 'filename' => 'registrations_event_checkin_other', |
|
| 138 | + ), |
|
| 139 | + ), |
|
| 140 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 141 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 142 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 143 | + 'metaboxes' => array(), |
|
| 144 | + 'require_nonce' => false, |
|
| 145 | + ), |
|
| 146 | + 'registration_checkins' => array( |
|
| 147 | + 'nav' => array( |
|
| 148 | + 'label' => __('Check-In Records', 'event_espresso'), |
|
| 149 | + 'order' => 15, |
|
| 150 | + 'persistent' => false, |
|
| 151 | + ), |
|
| 152 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 153 | + //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 154 | + 'metaboxes' => array(), |
|
| 155 | + 'require_nonce' => false, |
|
| 156 | + ), |
|
| 157 | + ); |
|
| 158 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 159 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 160 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + protected function _ajax_hooks() |
|
| 166 | + { |
|
| 167 | + parent::_ajax_hooks(); |
|
| 168 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + public function load_scripts_styles() |
|
| 174 | + { |
|
| 175 | + parent::load_scripts_styles(); |
|
| 176 | + //if newsletter message type is active then let's add filter and load js for it. |
|
| 177 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 178 | + //enqueue newsletter js |
|
| 179 | + wp_enqueue_script( |
|
| 180 | + 'ee-newsletter-trigger', |
|
| 181 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 182 | + array('ee-dialog'), |
|
| 183 | + EVENT_ESPRESSO_VERSION, |
|
| 184 | + true |
|
| 185 | + ); |
|
| 186 | + wp_enqueue_style( |
|
| 187 | + 'ee-newsletter-trigger-css', |
|
| 188 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 189 | + array(), |
|
| 190 | + EVENT_ESPRESSO_VERSION |
|
| 191 | + ); |
|
| 192 | + //hook in buttons for newsletter message type trigger. |
|
| 193 | + add_action( |
|
| 194 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 195 | + array($this, 'add_newsletter_action_buttons'), |
|
| 196 | + 10 |
|
| 197 | + ); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + public function load_scripts_styles_reports() |
|
| 204 | + { |
|
| 205 | + wp_register_script( |
|
| 206 | + 'ee-reg-reports-js', |
|
| 207 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 208 | + array('google-charts'), |
|
| 209 | + EVENT_ESPRESSO_VERSION, |
|
| 210 | + true |
|
| 211 | + ); |
|
| 212 | + wp_enqueue_script('ee-reg-reports-js'); |
|
| 213 | + $this->_registration_reports_js_setup(); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + protected function _add_screen_options_event_registrations() |
|
| 219 | + { |
|
| 220 | + $this->_per_page_screen_option(); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + protected function _add_screen_options_registration_checkins() |
|
| 226 | + { |
|
| 227 | + $page_title = $this->_admin_page_title; |
|
| 228 | + $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 229 | + $this->_per_page_screen_option(); |
|
| 230 | + $this->_admin_page_title = $page_title; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + protected function _set_list_table_views_event_registrations() |
|
| 236 | + { |
|
| 237 | + $this->_views = array( |
|
| 238 | + 'all' => array( |
|
| 239 | + 'slug' => 'all', |
|
| 240 | + 'label' => __('All', 'event_espresso'), |
|
| 241 | + 'count' => 0, |
|
| 242 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 243 | + ? array() |
|
| 244 | + : array( |
|
| 245 | + 'toggle_checkin_status' => __('Toggle Check-In', 'event_espresso'), |
|
| 246 | + //'trash_registrations' => __('Trash Registrations', 'event_espresso') |
|
| 247 | + ), |
|
| 248 | + ), |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + protected function _set_list_table_views_registration_checkins() |
|
| 255 | + { |
|
| 256 | + $this->_views = array( |
|
| 257 | + 'all' => array( |
|
| 258 | + 'slug' => 'all', |
|
| 259 | + 'label' => __('All', 'event_espresso'), |
|
| 260 | + 'count' => 0, |
|
| 261 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 262 | + ), |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * callback for ajax action. |
|
| 270 | + * |
|
| 271 | + * @since 4.3.0 |
|
| 272 | + * @return void (JSON) |
|
| 273 | + * @throws \EE_Error |
|
| 274 | + */ |
|
| 275 | + public function get_newsletter_form_content() |
|
| 276 | + { |
|
| 277 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 278 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 279 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 280 | + ) : ''; |
|
| 281 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 282 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 283 | + //let's get the mtp for the incoming MTP_ ID |
|
| 284 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 285 | + EE_Error::add_error( |
|
| 286 | + __( |
|
| 287 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 288 | + 'event_espresso' |
|
| 289 | + ), |
|
| 290 | + __FILE__, |
|
| 291 | + __FUNCTION__, |
|
| 292 | + __LINE__ |
|
| 293 | + ); |
|
| 294 | + $this->_template_args['success'] = false; |
|
| 295 | + $this->_template_args['error'] = true; |
|
| 296 | + $this->_return_json(); |
|
| 297 | + } |
|
| 298 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 299 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 300 | + EE_Error::add_error( |
|
| 301 | + sprintf( |
|
| 302 | + __( |
|
| 303 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 304 | + 'event_espresso' |
|
| 305 | + ), |
|
| 306 | + $this->_req_data['GRP_ID'] |
|
| 307 | + ), |
|
| 308 | + __FILE__, |
|
| 309 | + __FUNCTION__, |
|
| 310 | + __LINE__ |
|
| 311 | + ); |
|
| 312 | + $this->_template_args['success'] = false; |
|
| 313 | + $this->_template_args['error'] = true; |
|
| 314 | + $this->_return_json(); |
|
| 315 | + } |
|
| 316 | + $MTPs = $MTPG->context_templates(); |
|
| 317 | + $MTPs = $MTPs['attendee']; |
|
| 318 | + $template_fields = array(); |
|
| 319 | + /** @var EE_Message_Template $MTP */ |
|
| 320 | + foreach ($MTPs as $MTP) { |
|
| 321 | + $field = $MTP->get('MTP_template_field'); |
|
| 322 | + if ($field === 'content') { |
|
| 323 | + $content = $MTP->get('MTP_content'); |
|
| 324 | + if ( ! empty($content['newsletter_content'])) { |
|
| 325 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 326 | + } |
|
| 327 | + continue; |
|
| 328 | + } |
|
| 329 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 330 | + } |
|
| 331 | + $this->_template_args['success'] = true; |
|
| 332 | + $this->_template_args['error'] = false; |
|
| 333 | + $this->_template_args['data'] = array( |
|
| 334 | + 'batch_message_from' => isset($template_fields['from']) |
|
| 335 | + ? $template_fields['from'] |
|
| 336 | + : '', |
|
| 337 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
| 338 | + ? $template_fields['subject'] |
|
| 339 | + : '', |
|
| 340 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 341 | + ? $template_fields['newsletter_content'] |
|
| 342 | + : '', |
|
| 343 | + ); |
|
| 344 | + $this->_return_json(); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 351 | + * |
|
| 352 | + * @since 4.3.0 |
|
| 353 | + * @param EE_Admin_List_Table $list_table |
|
| 354 | + * @return void |
|
| 355 | + */ |
|
| 356 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 357 | + { |
|
| 358 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 359 | + 'ee_send_message', |
|
| 360 | + 'espresso_registrations_newsletter_selected_send' |
|
| 361 | + ) |
|
| 362 | + ) { |
|
| 363 | + return; |
|
| 364 | + } |
|
| 365 | + $routes_to_add_to = array( |
|
| 366 | + 'contact_list', |
|
| 367 | + 'event_registrations', |
|
| 368 | + 'default', |
|
| 369 | + ); |
|
| 370 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 371 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 372 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 373 | + ) { |
|
| 374 | + echo ''; |
|
| 375 | + } else { |
|
| 376 | + $button_text = sprintf( |
|
| 377 | + __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 378 | + '<span class="send-selected-newsletter-count">0</span>' |
|
| 379 | + ); |
|
| 380 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 381 | + . $button_text |
|
| 382 | + . '</button>'; |
|
| 383 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + |
|
| 390 | + public function newsletter_send_form_skeleton() |
|
| 391 | + { |
|
| 392 | + $list_table = $this->_list_table_object; |
|
| 393 | + $codes = array(); |
|
| 394 | + //need to templates for the newsletter message type for the template selector. |
|
| 395 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 396 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 397 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 398 | + ); |
|
| 399 | + foreach ($mtps as $mtp) { |
|
| 400 | + $name = $mtp->name(); |
|
| 401 | + $values[] = array( |
|
| 402 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 403 | + 'id' => $mtp->ID(), |
|
| 404 | + ); |
|
| 405 | + } |
|
| 406 | + //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 407 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 408 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
| 409 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 410 | + } |
|
| 411 | + $shortcodes = $codes; |
|
| 412 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 413 | + $form_template_args = array( |
|
| 414 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 415 | + 'form_route' => 'newsletter_selected_send', |
|
| 416 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 417 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 418 | + 'redirect_back_to' => $this->_req_action, |
|
| 419 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 420 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 421 | + 'shortcodes' => $shortcodes, |
|
| 422 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 423 | + ); |
|
| 424 | + EEH_Template::display_template($form_template, $form_template_args); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * Handles sending selected registrations/contacts a newsletter. |
|
| 431 | + * |
|
| 432 | + * @since 4.3.0 |
|
| 433 | + * @return void |
|
| 434 | + * @throws \EE_Error |
|
| 435 | + */ |
|
| 436 | + protected function _newsletter_selected_send() |
|
| 437 | + { |
|
| 438 | + $success = true; |
|
| 439 | + //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 440 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 441 | + EE_Error::add_error( |
|
| 442 | + __( |
|
| 443 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 444 | + 'event_espresso' |
|
| 445 | + ), |
|
| 446 | + __FILE__, |
|
| 447 | + __FUNCTION__, |
|
| 448 | + __LINE__ |
|
| 449 | + ); |
|
| 450 | + $success = false; |
|
| 451 | + } |
|
| 452 | + if ($success) { |
|
| 453 | + //update Message template in case there are any changes |
|
| 454 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 455 | + $this->_req_data['newsletter_mtp_selected'] |
|
| 456 | + ); |
|
| 457 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 458 | + ? $Message_Template_Group->context_templates() |
|
| 459 | + : array(); |
|
| 460 | + if (empty($Message_Templates)) { |
|
| 461 | + EE_Error::add_error( |
|
| 462 | + __( |
|
| 463 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 464 | + 'event_espresso' |
|
| 465 | + ), |
|
| 466 | + __FILE__, |
|
| 467 | + __FUNCTION__, |
|
| 468 | + __LINE__ |
|
| 469 | + ); |
|
| 470 | + } |
|
| 471 | + //let's just update the specific fields |
|
| 472 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 473 | + if ($Message_Template instanceof EE_Message_Template) { |
|
| 474 | + $field = $Message_Template->get('MTP_template_field'); |
|
| 475 | + $content = $Message_Template->get('MTP_content'); |
|
| 476 | + $new_content = $content; |
|
| 477 | + switch ($field) { |
|
| 478 | + case 'from' : |
|
| 479 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 480 | + ? $this->_req_data['batch_message']['from'] |
|
| 481 | + : $content; |
|
| 482 | + break; |
|
| 483 | + case 'subject' : |
|
| 484 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 485 | + ? $this->_req_data['batch_message']['subject'] |
|
| 486 | + : $content; |
|
| 487 | + break; |
|
| 488 | + case 'content' : |
|
| 489 | + $new_content = $content; |
|
| 490 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 491 | + ? $this->_req_data['batch_message']['content'] |
|
| 492 | + : $content['newsletter_content']; |
|
| 493 | + break; |
|
| 494 | + default : |
|
| 495 | + //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 496 | + continue 2; |
|
| 497 | + } |
|
| 498 | + $Message_Template->set('MTP_content', $new_content); |
|
| 499 | + $Message_Template->save(); |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 503 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 504 | + ? $this->_req_data['batch_message']['id_type'] |
|
| 505 | + : 'registration'; |
|
| 506 | + //id_type will affect how we assemble the ids. |
|
| 507 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 508 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 509 | + : array(); |
|
| 510 | + $registrations_used_for_contact_data = array(); |
|
| 511 | + //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 512 | + switch ($id_type) { |
|
| 513 | + case 'registration' : |
|
| 514 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 515 | + array( |
|
| 516 | + array( |
|
| 517 | + 'REG_ID' => array('IN', $ids), |
|
| 518 | + ), |
|
| 519 | + ) |
|
| 520 | + ); |
|
| 521 | + break; |
|
| 522 | + case 'contact' : |
|
| 523 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 524 | + ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + do_action( |
|
| 528 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 529 | + $registrations_used_for_contact_data, |
|
| 530 | + $Message_Template_Group->ID() |
|
| 531 | + ); |
|
| 532 | + //kept for backward compat, internally we no longer use this action. |
|
| 533 | + //@deprecated 4.8.36.rc.002 |
|
| 534 | + $contacts = $id_type === 'registration' |
|
| 535 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 536 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 537 | + do_action( |
|
| 538 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 539 | + $contacts, |
|
| 540 | + $Message_Template_Group->ID() |
|
| 541 | + ); |
|
| 542 | + } |
|
| 543 | + $query_args = array( |
|
| 544 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 545 | + ? $this->_req_data['redirect_back_to'] |
|
| 546 | + : 'default', |
|
| 547 | + ); |
|
| 548 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 555 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 556 | + */ |
|
| 557 | + protected function _registration_reports_js_setup() |
|
| 558 | + { |
|
| 559 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 560 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * generates Business Reports regarding Registrations |
|
| 567 | + * |
|
| 568 | + * @access protected |
|
| 569 | + * @return void |
|
| 570 | + */ |
|
| 571 | + protected function _registration_reports() |
|
| 572 | + { |
|
| 573 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 574 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 575 | + $template_path, |
|
| 576 | + $this->_reports_template_data, |
|
| 577 | + true |
|
| 578 | + ); |
|
| 579 | + // the final template wrapper |
|
| 580 | + $this->display_admin_page_with_no_sidebar(); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + |
|
| 584 | + |
|
| 585 | + /** |
|
| 586 | + * Generates Business Report showing total registrations per day. |
|
| 587 | + * |
|
| 588 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 589 | + * @return string |
|
| 590 | + */ |
|
| 591 | + private function _registrations_per_day_report($period = '-1 month') |
|
| 592 | + { |
|
| 593 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 594 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 595 | + $results = (array)$results; |
|
| 596 | + $regs = array(); |
|
| 597 | + $subtitle = ''; |
|
| 598 | + if ($results) { |
|
| 599 | + $column_titles = array(); |
|
| 600 | + $tracker = 0; |
|
| 601 | + foreach ($results as $result) { |
|
| 602 | + $report_column_values = array(); |
|
| 603 | + foreach ($result as $property_name => $property_value) { |
|
| 604 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 605 | + : (int)$property_value; |
|
| 606 | + $report_column_values[] = $property_value; |
|
| 607 | + if ($tracker === 0) { |
|
| 608 | + if ($property_name === 'Registration_REG_date') { |
|
| 609 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 610 | + } else { |
|
| 611 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 612 | + } |
|
| 613 | + } |
|
| 614 | + } |
|
| 615 | + $tracker++; |
|
| 616 | + $regs[] = $report_column_values; |
|
| 617 | + } |
|
| 618 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 619 | + array_unshift($regs, $column_titles); |
|
| 620 | + //setup the date range. |
|
| 621 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 622 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 623 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 624 | + $subtitle = sprintf( |
|
| 625 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 626 | + $beginning_date->format('Y-m-d'), |
|
| 627 | + $ending_date->format('Y-m-d') |
|
| 628 | + ); |
|
| 629 | + } |
|
| 630 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 631 | + $report_params = array( |
|
| 632 | + 'title' => $report_title, |
|
| 633 | + 'subtitle' => $subtitle, |
|
| 634 | + 'id' => $report_ID, |
|
| 635 | + 'regs' => $regs, |
|
| 636 | + 'noResults' => empty($regs), |
|
| 637 | + 'noRegsMsg' => sprintf( |
|
| 638 | + __( |
|
| 639 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 640 | + 'event_espresso' |
|
| 641 | + ), |
|
| 642 | + '<h2>' . $report_title . '</h2><p>', |
|
| 643 | + '</p>' |
|
| 644 | + ), |
|
| 645 | + ); |
|
| 646 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 647 | + return $report_ID; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * Generates Business Report showing total registrations per event. |
|
| 654 | + * |
|
| 655 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 656 | + * @return string |
|
| 657 | + */ |
|
| 658 | + private function _registrations_per_event_report($period = '-1 month') |
|
| 659 | + { |
|
| 660 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 661 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 662 | + $results = (array)$results; |
|
| 663 | + $regs = array(); |
|
| 664 | + $subtitle = ''; |
|
| 665 | + if ($results) { |
|
| 666 | + $column_titles = array(); |
|
| 667 | + $tracker = 0; |
|
| 668 | + foreach ($results as $result) { |
|
| 669 | + $report_column_values = array(); |
|
| 670 | + foreach ($result as $property_name => $property_value) { |
|
| 671 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 672 | + $property_value, |
|
| 673 | + 4, |
|
| 674 | + '...' |
|
| 675 | + ) : (int)$property_value; |
|
| 676 | + $report_column_values[] = $property_value; |
|
| 677 | + if ($tracker === 0) { |
|
| 678 | + if ($property_name === 'Registration_Event') { |
|
| 679 | + $column_titles[] = __('Event', 'event_espresso'); |
|
| 680 | + } else { |
|
| 681 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + $tracker++; |
|
| 686 | + $regs[] = $report_column_values; |
|
| 687 | + } |
|
| 688 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 689 | + array_unshift($regs, $column_titles); |
|
| 690 | + //setup the date range. |
|
| 691 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 692 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 693 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 694 | + $subtitle = sprintf( |
|
| 695 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 696 | + $beginning_date->format('Y-m-d'), |
|
| 697 | + $ending_date->format('Y-m-d') |
|
| 698 | + ); |
|
| 699 | + } |
|
| 700 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 701 | + $report_params = array( |
|
| 702 | + 'title' => $report_title, |
|
| 703 | + 'subtitle' => $subtitle, |
|
| 704 | + 'id' => $report_ID, |
|
| 705 | + 'regs' => $regs, |
|
| 706 | + 'noResults' => empty($regs), |
|
| 707 | + 'noRegsMsg' => sprintf( |
|
| 708 | + __( |
|
| 709 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 710 | + 'event_espresso' |
|
| 711 | + ), |
|
| 712 | + '<h2>' . $report_title . '</h2><p>', |
|
| 713 | + '</p>' |
|
| 714 | + ), |
|
| 715 | + ); |
|
| 716 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 717 | + return $report_ID; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 724 | + * |
|
| 725 | + * @access protected |
|
| 726 | + * @return void |
|
| 727 | + * @throws \EE_Error |
|
| 728 | + */ |
|
| 729 | + protected function _registration_checkin_list_table() |
|
| 730 | + { |
|
| 731 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 732 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 733 | + /** @var EE_Registration $reg */ |
|
| 734 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 735 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 736 | + 'new_registration', |
|
| 737 | + 'add-registrant', |
|
| 738 | + array('event_id' => $reg->event_ID()), |
|
| 739 | + 'add-new-h2' |
|
| 740 | + ); |
|
| 741 | + $legend_items = array( |
|
| 742 | + 'checkin' => array( |
|
| 743 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 744 | + 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 745 | + ), |
|
| 746 | + 'checkout' => array( |
|
| 747 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 748 | + 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 749 | + ), |
|
| 750 | + ); |
|
| 751 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 752 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 753 | + $go_back_url = ! empty($reg_id) ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 754 | + array( |
|
| 755 | + 'action' => 'event_registrations', |
|
| 756 | + 'event_id' => EEM_Registration::instance()->get_one_by_ID($reg_id)->get_first_related('Event')->ID(), |
|
| 757 | + 'DTT_ID' => $dtt_id, |
|
| 758 | + ), |
|
| 759 | + $this->_admin_base_url |
|
| 760 | + ) : ''; |
|
| 761 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 762 | + ? '<h2>' . sprintf( |
|
| 763 | + __("%s's check in records for %s at the event, %s", 'event_espresso'), |
|
| 764 | + '<span id="checkin-attendee-name">' |
|
| 765 | + . EEM_Registration::instance() |
|
| 766 | + ->get_one_by_ID($reg_id) |
|
| 767 | + ->get_first_related('Attendee') |
|
| 768 | + ->full_name() . '</span>', |
|
| 769 | + '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 770 | + . EEM_Datetime::instance() |
|
| 771 | + ->get_one_by_ID($dtt_id) |
|
| 772 | + ->start_date_and_time() . ' - ' |
|
| 773 | + . EEM_Datetime::instance() |
|
| 774 | + ->get_one_by_ID($dtt_id) |
|
| 775 | + ->end_date_and_time() . '</a></span>', |
|
| 776 | + '<span id="checkin-event-name">' |
|
| 777 | + . EEM_Datetime::instance() |
|
| 778 | + ->get_one_by_ID($dtt_id) |
|
| 779 | + ->get_first_related('Event') |
|
| 780 | + ->get('EVT_name') . '</span>' |
|
| 781 | + ) . '</h2>' |
|
| 782 | + : ''; |
|
| 783 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 784 | + ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 785 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 786 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 787 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + |
|
| 791 | + |
|
| 792 | + /** |
|
| 793 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
| 794 | + * |
|
| 795 | + * @return void (JSON) |
|
| 796 | + */ |
|
| 797 | + public function toggle_checkin_status() |
|
| 798 | + { |
|
| 799 | + //first make sure we have the necessary data |
|
| 800 | + if ( ! isset($this->_req_data['_regid'])) { |
|
| 801 | + EE_Error::add_error( |
|
| 802 | + __( |
|
| 803 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 804 | + 'event_espresso' |
|
| 805 | + ), |
|
| 806 | + __FILE__, |
|
| 807 | + __FUNCTION__, |
|
| 808 | + __LINE__ |
|
| 809 | + ); |
|
| 810 | + $this->_template_args['success'] = false; |
|
| 811 | + $this->_template_args['error'] = true; |
|
| 812 | + $this->_return_json(); |
|
| 813 | + }; |
|
| 814 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 815 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 816 | + : ''; |
|
| 817 | + $nonce_ref = 'checkin_nonce'; |
|
| 818 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 819 | + //beautiful! Made it this far so let's get the status. |
|
| 820 | + $new_status = $this->_toggle_checkin_status(); |
|
| 821 | + //setup new class to return via ajax |
|
| 822 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 823 | + . $new_status; |
|
| 824 | + $this->_template_args['success'] = true; |
|
| 825 | + $this->_return_json(); |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * handles toggling the checkin status for the registration, |
|
| 832 | + * |
|
| 833 | + * @access protected |
|
| 834 | + * @return int|void |
|
| 835 | + */ |
|
| 836 | + protected function _toggle_checkin_status() |
|
| 837 | + { |
|
| 838 | + //first let's get the query args out of the way for the redirect |
|
| 839 | + $query_args = array( |
|
| 840 | + 'action' => 'event_registrations', |
|
| 841 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 842 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 843 | + ); |
|
| 844 | + $new_status = false; |
|
| 845 | + // bulk action check in toggle |
|
| 846 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 847 | + // cycle thru checkboxes |
|
| 848 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 849 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 850 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 851 | + } |
|
| 852 | + } elseif (isset($this->_req_data['_regid'])) { |
|
| 853 | + //coming from ajax request |
|
| 854 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 855 | + $query_args['DTT_ID'] = $DTT_ID; |
|
| 856 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 857 | + } else { |
|
| 858 | + EE_Error::add_error( |
|
| 859 | + __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 860 | + __FILE__, |
|
| 861 | + __FUNCTION__, |
|
| 862 | + __LINE__ |
|
| 863 | + ); |
|
| 864 | + } |
|
| 865 | + if (defined('DOING_AJAX')) { |
|
| 866 | + return $new_status; |
|
| 867 | + } |
|
| 868 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + |
|
| 872 | + |
|
| 873 | + /** |
|
| 874 | + * This is toggles a single Check-in for the given registration and datetime. |
|
| 875 | + * |
|
| 876 | + * @param int $REG_ID The registration we're toggling |
|
| 877 | + * @param int $DTT_ID The datetime we're toggling |
|
| 878 | + * @return int The new status toggled to. |
|
| 879 | + * @throws \EE_Error |
|
| 880 | + */ |
|
| 881 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 882 | + { |
|
| 883 | + /** @var EE_Registration $REG */ |
|
| 884 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 885 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 886 | + if ($new_status !== false) { |
|
| 887 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 888 | + } else { |
|
| 889 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 890 | + $new_status = false; |
|
| 891 | + } |
|
| 892 | + return $new_status; |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + |
|
| 896 | + |
|
| 897 | + /** |
|
| 898 | + * Takes care of deleting multiple EE_Checkin table rows |
|
| 899 | + * |
|
| 900 | + * @access protected |
|
| 901 | + * @return void |
|
| 902 | + * @throws \EE_Error |
|
| 903 | + */ |
|
| 904 | + protected function _delete_checkin_rows() |
|
| 905 | + { |
|
| 906 | + $query_args = array( |
|
| 907 | + 'action' => 'registration_checkins', |
|
| 908 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 909 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 910 | + ); |
|
| 911 | + $errors = 0; |
|
| 912 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 913 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 914 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 915 | + $errors++; |
|
| 916 | + } |
|
| 917 | + } |
|
| 918 | + } else { |
|
| 919 | + EE_Error::add_error( |
|
| 920 | + __( |
|
| 921 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 922 | + 'event_espresso' |
|
| 923 | + ), |
|
| 924 | + __FILE__, |
|
| 925 | + __FUNCTION__, |
|
| 926 | + __LINE__ |
|
| 927 | + ); |
|
| 928 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 929 | + } |
|
| 930 | + if ($errors > 0) { |
|
| 931 | + EE_Error::add_error( |
|
| 932 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 933 | + __FILE__, |
|
| 934 | + __FUNCTION__, |
|
| 935 | + __LINE__ |
|
| 936 | + ); |
|
| 937 | + } else { |
|
| 938 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 939 | + } |
|
| 940 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + |
|
| 944 | + |
|
| 945 | + /** |
|
| 946 | + * Deletes a single EE_Checkin row |
|
| 947 | + * |
|
| 948 | + * @return void |
|
| 949 | + * @throws \EE_Error |
|
| 950 | + */ |
|
| 951 | + protected function _delete_checkin_row() |
|
| 952 | + { |
|
| 953 | + $query_args = array( |
|
| 954 | + 'action' => 'registration_checkins', |
|
| 955 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 956 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 957 | + ); |
|
| 958 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 959 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 960 | + EE_Error::add_error( |
|
| 961 | + __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 962 | + __FILE__, |
|
| 963 | + __FUNCTION__, |
|
| 964 | + __LINE__ |
|
| 965 | + ); |
|
| 966 | + } else { |
|
| 967 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 968 | + } |
|
| 969 | + } else { |
|
| 970 | + EE_Error::add_error( |
|
| 971 | + __( |
|
| 972 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 973 | + 'event_espresso' |
|
| 974 | + ), |
|
| 975 | + __FILE__, |
|
| 976 | + __FUNCTION__, |
|
| 977 | + __LINE__ |
|
| 978 | + ); |
|
| 979 | + } |
|
| 980 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * generates HTML for the Event Registrations List Table |
|
| 987 | + * |
|
| 988 | + * @access protected |
|
| 989 | + * @return void |
|
| 990 | + * @throws \EE_Error |
|
| 991 | + */ |
|
| 992 | + protected function _event_registrations_list_table() |
|
| 993 | + { |
|
| 994 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 995 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 996 | + ? $this->get_action_link_or_button( |
|
| 997 | + 'new_registration', |
|
| 998 | + 'add-registrant', |
|
| 999 | + array('event_id' => $this->_req_data['event_id']), |
|
| 1000 | + 'add-new-h2', |
|
| 1001 | + '', |
|
| 1002 | + false |
|
| 1003 | + ) |
|
| 1004 | + : ''; |
|
| 1005 | + $legend_items = array( |
|
| 1006 | + 'star-icon' => array( |
|
| 1007 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1008 | + 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1009 | + ), |
|
| 1010 | + 'checkin' => array( |
|
| 1011 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 1012 | + 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1013 | + ), |
|
| 1014 | + 'checkout' => array( |
|
| 1015 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 1016 | + 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1017 | + ), |
|
| 1018 | + 'nocheckinrecord' => array( |
|
| 1019 | + 'class' => 'dashicons dashicons-no', |
|
| 1020 | + 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1021 | + ), |
|
| 1022 | + 'view_details' => array( |
|
| 1023 | + 'class' => 'dashicons dashicons-search', |
|
| 1024 | + 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1025 | + ), |
|
| 1026 | + 'approved_status' => array( |
|
| 1027 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1028 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1029 | + ), |
|
| 1030 | + 'cancelled_status' => array( |
|
| 1031 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1032 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1033 | + ), |
|
| 1034 | + 'declined_status' => array( |
|
| 1035 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1036 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1037 | + ), |
|
| 1038 | + 'not_approved' => array( |
|
| 1039 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1040 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1041 | + ), |
|
| 1042 | + 'pending_status' => array( |
|
| 1043 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1044 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1045 | + ), |
|
| 1046 | + 'wait_list' => array( |
|
| 1047 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1048 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1049 | + ), |
|
| 1050 | + ); |
|
| 1051 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1052 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1053 | + $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1054 | + ? '<h2>' . sprintf( |
|
| 1055 | + __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1056 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1057 | + ) . '</h2>' |
|
| 1058 | + : ''; |
|
| 1059 | + //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1060 | + /** @var EE_Event $event */ |
|
| 1061 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1062 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1063 | + $datetime = null; |
|
| 1064 | + if ($event instanceof EE_Event) { |
|
| 1065 | + $datetimes_on_event = $event->datetimes(); |
|
| 1066 | + if (count($datetimes_on_event) === 1) { |
|
| 1067 | + $datetime = reset($datetimes_on_event); |
|
| 1068 | + } |
|
| 1069 | + } |
|
| 1070 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1071 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1072 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1073 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1074 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1075 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1076 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1077 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1078 | + } |
|
| 1079 | + //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1080 | + //represents |
|
| 1081 | + if ( ! $datetime instanceof EE_Datetime) { |
|
| 1082 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1083 | + . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1084 | + 'event_espresso') |
|
| 1085 | + . '</p>'; |
|
| 1086 | + } |
|
| 1087 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1088 | + } |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1092 | + * conditions) |
|
| 1093 | + * |
|
| 1094 | + * @return void ends the request by a redirect or download |
|
| 1095 | + */ |
|
| 1096 | + public function _registrations_checkin_report() |
|
| 1097 | + { |
|
| 1098 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1099 | + } |
|
| 1100 | + |
|
| 1101 | + /** |
|
| 1102 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1103 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1104 | + * |
|
| 1105 | + * @param array $request |
|
| 1106 | + * @param int $per_page |
|
| 1107 | + * @param bool $count |
|
| 1108 | + * @return array |
|
| 1109 | + */ |
|
| 1110 | + protected function _get_checkin_query_params_from_request( |
|
| 1111 | + $request, |
|
| 1112 | + $per_page = 10, |
|
| 1113 | + $count = false |
|
| 1114 | + ) { |
|
| 1115 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1116 | + //unlike the regular registrations list table, |
|
| 1117 | + $status_ids_array = apply_filters( |
|
| 1118 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1119 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1120 | + ); |
|
| 1121 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1122 | + return $query_params; |
|
| 1123 | + } |
|
| 1124 | + |
|
| 1125 | + |
|
| 1126 | + |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * Gets registrations for an event |
|
| 1130 | + * |
|
| 1131 | + * @param int $per_page |
|
| 1132 | + * @param bool $count whether to return count or data. |
|
| 1133 | + * @param bool $trash |
|
| 1134 | + * @param string $orderby |
|
| 1135 | + * @return EE_Registration[]|int |
|
| 1136 | + * @throws \EE_Error |
|
| 1137 | + */ |
|
| 1138 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1139 | + { |
|
| 1140 | + //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1141 | + $request = $this->_req_data; |
|
| 1142 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1143 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | + if($trash){ |
|
| 1145 | + $request['status'] = 'trash'; |
|
| 1146 | + } |
|
| 1147 | + $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1148 | + /** |
|
| 1149 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1150 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1151 | + * @see EEM_Base::get_all() |
|
| 1152 | + */ |
|
| 1153 | + $query_params['group_by'] = ''; |
|
| 1154 | + |
|
| 1155 | + return $count |
|
| 1156 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1157 | + /** @type EE_Registration[] */ |
|
| 1158 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | 1161 | } //end class Registrations Admin Page |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | { |
| 36 | 36 | parent::__construct($routing); |
| 37 | 37 | if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
| 38 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 38 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'registrations/templates/'); |
|
| 39 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'registrations/assets/'); |
|
| 40 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registrations/assets/'); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function _extend_page_config() |
| 47 | 47 | { |
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'registrations'; |
|
| 49 | 49 | $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
| 50 | 50 | ? $this->_req_data['_REG_ID'] |
| 51 | 51 | : 0; |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | //enqueue newsletter js |
| 179 | 179 | wp_enqueue_script( |
| 180 | 180 | 'ee-newsletter-trigger', |
| 181 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 181 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.js', |
|
| 182 | 182 | array('ee-dialog'), |
| 183 | 183 | EVENT_ESPRESSO_VERSION, |
| 184 | 184 | true |
| 185 | 185 | ); |
| 186 | 186 | wp_enqueue_style( |
| 187 | 187 | 'ee-newsletter-trigger-css', |
| 188 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 188 | + REG_CAF_ASSETS_URL.'ee-newsletter-trigger.css', |
|
| 189 | 189 | array(), |
| 190 | 190 | EVENT_ESPRESSO_VERSION |
| 191 | 191 | ); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | wp_register_script( |
| 206 | 206 | 'ee-reg-reports-js', |
| 207 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 207 | + REG_CAF_ASSETS_URL.'ee-registration-admin-reports.js', |
|
| 208 | 208 | array('google-charts'), |
| 209 | 209 | EVENT_ESPRESSO_VERSION, |
| 210 | 210 | true |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | $codes[$field] = implode(', ', array_keys($shortcode_array)); |
| 410 | 410 | } |
| 411 | 411 | $shortcodes = $codes; |
| 412 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 412 | + $form_template = REG_CAF_TEMPLATE_PATH.'newsletter-send-form.template.php'; |
|
| 413 | 413 | $form_template_args = array( |
| 414 | 414 | 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
| 415 | 415 | 'form_route' => 'newsletter_selected_send', |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | protected function _registration_reports() |
| 572 | 572 | { |
| 573 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 573 | + $template_path = EE_ADMIN_TEMPLATE.'admin_reports.template.php'; |
|
| 574 | 574 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 575 | 575 | $template_path, |
| 576 | 576 | $this->_reports_template_data, |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | { |
| 593 | 593 | $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
| 594 | 594 | $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
| 595 | - $results = (array)$results; |
|
| 595 | + $results = (array) $results; |
|
| 596 | 596 | $regs = array(); |
| 597 | 597 | $subtitle = ''; |
| 598 | 598 | if ($results) { |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | $report_column_values = array(); |
| 603 | 603 | foreach ($result as $property_name => $property_value) { |
| 604 | 604 | $property_value = $property_name === 'Registration_REG_date' ? $property_value |
| 605 | - : (int)$property_value; |
|
| 605 | + : (int) $property_value; |
|
| 606 | 606 | $report_column_values[] = $property_value; |
| 607 | 607 | if ($tracker === 0) { |
| 608 | 608 | if ($property_name === 'Registration_REG_date') { |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | array_unshift($regs, $column_titles); |
| 620 | 620 | //setup the date range. |
| 621 | 621 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 622 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 622 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 623 | 623 | $ending_date = new DateTime("now", $DateTimeZone); |
| 624 | 624 | $subtitle = sprintf( |
| 625 | 625 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -639,7 +639,7 @@ discard block |
||
| 639 | 639 | '%sThere are currently no registration records in the last month for this report.%s', |
| 640 | 640 | 'event_espresso' |
| 641 | 641 | ), |
| 642 | - '<h2>' . $report_title . '</h2><p>', |
|
| 642 | + '<h2>'.$report_title.'</h2><p>', |
|
| 643 | 643 | '</p>' |
| 644 | 644 | ), |
| 645 | 645 | ); |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | { |
| 660 | 660 | $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
| 661 | 661 | $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
| 662 | - $results = (array)$results; |
|
| 662 | + $results = (array) $results; |
|
| 663 | 663 | $regs = array(); |
| 664 | 664 | $subtitle = ''; |
| 665 | 665 | if ($results) { |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | $property_value, |
| 673 | 673 | 4, |
| 674 | 674 | '...' |
| 675 | - ) : (int)$property_value; |
|
| 675 | + ) : (int) $property_value; |
|
| 676 | 676 | $report_column_values[] = $property_value; |
| 677 | 677 | if ($tracker === 0) { |
| 678 | 678 | if ($property_name === 'Registration_Event') { |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | array_unshift($regs, $column_titles); |
| 690 | 690 | //setup the date range. |
| 691 | 691 | $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
| 692 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 692 | + $beginning_date = new DateTime("now ".$period, $DateTimeZone); |
|
| 693 | 693 | $ending_date = new DateTime("now", $DateTimeZone); |
| 694 | 694 | $subtitle = sprintf( |
| 695 | 695 | _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | '%sThere are currently no registration records in the last month for this report.%s', |
| 710 | 710 | 'event_espresso' |
| 711 | 711 | ), |
| 712 | - '<h2>' . $report_title . '</h2><p>', |
|
| 712 | + '<h2>'.$report_title.'</h2><p>', |
|
| 713 | 713 | '</p>' |
| 714 | 714 | ), |
| 715 | 715 | ); |
@@ -759,31 +759,31 @@ discard block |
||
| 759 | 759 | $this->_admin_base_url |
| 760 | 760 | ) : ''; |
| 761 | 761 | $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
| 762 | - ? '<h2>' . sprintf( |
|
| 762 | + ? '<h2>'.sprintf( |
|
| 763 | 763 | __("%s's check in records for %s at the event, %s", 'event_espresso'), |
| 764 | 764 | '<span id="checkin-attendee-name">' |
| 765 | 765 | . EEM_Registration::instance() |
| 766 | 766 | ->get_one_by_ID($reg_id) |
| 767 | 767 | ->get_first_related('Attendee') |
| 768 | - ->full_name() . '</span>', |
|
| 769 | - '<span id="checkin-dtt"><a href="' . $go_back_url . '">' |
|
| 768 | + ->full_name().'</span>', |
|
| 769 | + '<span id="checkin-dtt"><a href="'.$go_back_url.'">' |
|
| 770 | 770 | . EEM_Datetime::instance() |
| 771 | 771 | ->get_one_by_ID($dtt_id) |
| 772 | - ->start_date_and_time() . ' - ' |
|
| 772 | + ->start_date_and_time().' - ' |
|
| 773 | 773 | . EEM_Datetime::instance() |
| 774 | 774 | ->get_one_by_ID($dtt_id) |
| 775 | - ->end_date_and_time() . '</a></span>', |
|
| 775 | + ->end_date_and_time().'</a></span>', |
|
| 776 | 776 | '<span id="checkin-event-name">' |
| 777 | 777 | . EEM_Datetime::instance() |
| 778 | 778 | ->get_one_by_ID($dtt_id) |
| 779 | 779 | ->get_first_related('Event') |
| 780 | - ->get('EVT_name') . '</span>' |
|
| 781 | - ) . '</h2>' |
|
| 780 | + ->get('EVT_name').'</span>' |
|
| 781 | + ).'</h2>' |
|
| 782 | 782 | : ''; |
| 783 | 783 | $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
| 784 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 784 | + ? '<input type="hidden" name="_REGID" value="'.$reg_id.'">' : ''; |
|
| 785 | 785 | $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
| 786 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 786 | + ? '<input type="hidden" name="DTT_ID" value="'.$dtt_id.'">' : ''; |
|
| 787 | 787 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 788 | 788 | } |
| 789 | 789 | |
@@ -1024,37 +1024,37 @@ discard block |
||
| 1024 | 1024 | 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
| 1025 | 1025 | ), |
| 1026 | 1026 | 'approved_status' => array( |
| 1027 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1027 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
| 1028 | 1028 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
| 1029 | 1029 | ), |
| 1030 | 1030 | 'cancelled_status' => array( |
| 1031 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1031 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
| 1032 | 1032 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
| 1033 | 1033 | ), |
| 1034 | 1034 | 'declined_status' => array( |
| 1035 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1035 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
| 1036 | 1036 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
| 1037 | 1037 | ), |
| 1038 | 1038 | 'not_approved' => array( |
| 1039 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1039 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
| 1040 | 1040 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
| 1041 | 1041 | ), |
| 1042 | 1042 | 'pending_status' => array( |
| 1043 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1043 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
| 1044 | 1044 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
| 1045 | 1045 | ), |
| 1046 | 1046 | 'wait_list' => array( |
| 1047 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1047 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
| 1048 | 1048 | 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
| 1049 | 1049 | ), |
| 1050 | 1050 | ); |
| 1051 | 1051 | $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
| 1052 | 1052 | $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
| 1053 | 1053 | $this->_template_args['before_list_table'] = ! empty($event_id) |
| 1054 | - ? '<h2>' . sprintf( |
|
| 1054 | + ? '<h2>'.sprintf( |
|
| 1055 | 1055 | __('Viewing Registrations for Event: %s', 'event_espresso'), |
| 1056 | 1056 | EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
| 1057 | - ) . '</h2>' |
|
| 1057 | + ).'</h2>' |
|
| 1058 | 1058 | : ''; |
| 1059 | 1059 | //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
| 1060 | 1060 | /** @var EE_Event $event */ |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
| 1074 | 1074 | $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
| 1075 | 1075 | $this->_template_args['before_list_table'] .= $datetime->name(); |
| 1076 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1076 | + $this->_template_args['before_list_table'] .= ' ( '.$datetime->date_and_time_range().' )'; |
|
| 1077 | 1077 | $this->_template_args['before_list_table'] .= '</span></h2>'; |
| 1078 | 1078 | } |
| 1079 | 1079 | //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
@@ -1140,11 +1140,11 @@ discard block |
||
| 1140 | 1140 | //normalize some request params that get setup by the parent `get_registrations` method. |
| 1141 | 1141 | $request = $this->_req_data; |
| 1142 | 1142 | $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
| 1143 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | - if($trash){ |
|
| 1143 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1144 | + if ($trash) { |
|
| 1145 | 1145 | $request['status'] = 'trash'; |
| 1146 | 1146 | } |
| 1147 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1147 | + $query_params = $this->_get_checkin_query_params_from_request($request, $per_page, $count); |
|
| 1148 | 1148 | /** |
| 1149 | 1149 | * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
| 1150 | 1150 | * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
@@ -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 | |
@@ -26,869 +26,869 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | - private $_status; |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * An array of transaction details for the related transaction to the registration being processed. |
|
| 35 | - * This is set via the _set_related_details method. |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected $_transaction_details = array(); |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * An array of event details for the related event to the registration being processed. |
|
| 45 | - * This is set via the _set_related_details method. |
|
| 46 | - * |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 49 | - protected $_event_details = array(); |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param \Registrations_Admin_Page $admin_page |
|
| 55 | - */ |
|
| 56 | - public function __construct(Registrations_Admin_Page $admin_page) |
|
| 57 | - { |
|
| 58 | - if ( ! empty($_GET['event_id'])) { |
|
| 59 | - $extra_query_args = array(); |
|
| 60 | - foreach ($admin_page->get_views() as $key => $view_details) { |
|
| 61 | - $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
| 62 | - } |
|
| 63 | - $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 64 | - } |
|
| 65 | - parent::__construct($admin_page); |
|
| 66 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * _setup_data |
|
| 73 | - * |
|
| 74 | - * @access protected |
|
| 75 | - * @return void |
|
| 76 | - */ |
|
| 77 | - protected function _setup_data() |
|
| 78 | - { |
|
| 79 | - $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 80 | - $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * _set_properties |
|
| 87 | - * |
|
| 88 | - * @access protected |
|
| 89 | - * @return void |
|
| 90 | - */ |
|
| 91 | - protected function _set_properties() |
|
| 92 | - { |
|
| 93 | - $this->_wp_list_args = array( |
|
| 94 | - 'singular' => __('registration', 'event_espresso'), |
|
| 95 | - 'plural' => __('registrations', 'event_espresso'), |
|
| 96 | - 'ajax' => true, |
|
| 97 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 98 | - ); |
|
| 99 | - $ID_column_name = __('ID', 'event_espresso'); |
|
| 100 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 101 | - $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
| 102 | - $ID_column_name .= '</span> '; |
|
| 103 | - if (isset($_GET['event_id'])) { |
|
| 104 | - $this->_columns = array( |
|
| 105 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 106 | - '_REG_ID' => $ID_column_name, |
|
| 107 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 108 | - 'ATT_email' => __('Email', 'event_espresso'), |
|
| 109 | - '_REG_date' => __('Reg Date', 'event_espresso'), |
|
| 110 | - 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
| 111 | - '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
| 112 | - 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
| 113 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 114 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 115 | - ); |
|
| 116 | - $this->_bottom_buttons = array( |
|
| 117 | - 'report' => array( |
|
| 118 | - 'route' => 'registrations_report', |
|
| 119 | - 'extra_request' => array( |
|
| 120 | - 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 121 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 122 | - ), |
|
| 123 | - ), |
|
| 124 | - ); |
|
| 125 | - } else { |
|
| 126 | - $this->_columns = array( |
|
| 127 | - 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 128 | - '_REG_ID' => $ID_column_name, |
|
| 129 | - 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 130 | - '_REG_date' => __('TXN Date', 'event_espresso'), |
|
| 131 | - 'event_name' => __('Event', 'event_espresso'), |
|
| 132 | - 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
| 133 | - '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 134 | - '_REG_paid' => __('Paid', 'event_espresso'), |
|
| 135 | - 'actions' => __('Actions', 'event_espresso'), |
|
| 136 | - ); |
|
| 137 | - $this->_bottom_buttons = array( |
|
| 138 | - 'report_all' => array( |
|
| 139 | - 'route' => 'registrations_report', |
|
| 140 | - 'extra_request' => array( |
|
| 141 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 142 | - ), |
|
| 143 | - ), |
|
| 144 | - ); |
|
| 145 | - } |
|
| 146 | - $this->_bottom_buttons['report_filtered'] = array( |
|
| 147 | - 'route' => 'registrations_report', |
|
| 148 | - 'extra_request' => array( |
|
| 149 | - 'use_filters' => true, |
|
| 150 | - 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
| 151 | - 'page', |
|
| 152 | - 'action', |
|
| 153 | - 'default_nonce', |
|
| 154 | - ))), |
|
| 155 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 156 | - ), |
|
| 157 | - ); |
|
| 158 | - $this->_primary_column = '_REG_ID'; |
|
| 159 | - $this->_sortable_columns = array( |
|
| 160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 161 | - /** |
|
| 162 | - * Allows users to change the default sort if they wish. |
|
| 163 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 164 | - */ |
|
| 165 | - 'ATT_fname' => array( |
|
| 166 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 167 | - true, |
|
| 168 | - $this |
|
| 169 | - ) |
|
| 170 | - ? array('ATT_lname' => false) |
|
| 171 | - : array('ATT_fname' => false), |
|
| 172 | - 'event_name' => array('event_name' => false), |
|
| 173 | - 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
| 174 | - '_REG_ID' => array('_REG_ID' => false), |
|
| 175 | - ); |
|
| 176 | - $this->_hidden_columns = array(); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * This simply sets up the row class for the table rows. |
|
| 183 | - * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | - * |
|
| 185 | - * @param EE_Registration $item the current item |
|
| 186 | - * @return string |
|
| 187 | - */ |
|
| 188 | - protected function _get_row_class($item) |
|
| 189 | - { |
|
| 190 | - $class = parent::_get_row_class($item); |
|
| 191 | - //add status class |
|
| 192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | - if ($this->_has_checkbox_column) { |
|
| 194 | - $class .= ' has-checkbox-column'; |
|
| 195 | - } |
|
| 196 | - return $class; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Set the $_transaction_details property if not set yet. |
|
| 203 | - * |
|
| 204 | - * @param EE_Registration $registration |
|
| 205 | - * @throws \EE_Error |
|
| 206 | - */ |
|
| 207 | - protected function _set_related_details(EE_Registration $registration) |
|
| 208 | - { |
|
| 209 | - $transaction = $registration->get_first_related('Transaction'); |
|
| 210 | - $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
| 211 | - : EEM_Transaction::failed_status_code; |
|
| 212 | - $this->_transaction_details = array( |
|
| 213 | - 'transaction' => $transaction, |
|
| 214 | - 'status' => $status, |
|
| 215 | - 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
| 216 | - 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
| 217 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 218 | - ); |
|
| 219 | - try { |
|
| 220 | - $event = $registration->event(); |
|
| 221 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 222 | - $event = null; |
|
| 223 | - } |
|
| 224 | - $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
| 225 | - $this->_event_details = array( |
|
| 226 | - 'event' => $event, |
|
| 227 | - 'status' => $status, |
|
| 228 | - 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
| 229 | - 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
| 230 | - EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 231 | - ); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * _get_table_filters |
|
| 238 | - * |
|
| 239 | - * @access protected |
|
| 240 | - * @return array |
|
| 241 | - */ |
|
| 242 | - protected function _get_table_filters() |
|
| 243 | - { |
|
| 244 | - $filters = array(); |
|
| 245 | - //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
| 246 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 247 | - $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 248 | - $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
| 249 | - $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 250 | - $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 251 | - $status = array(); |
|
| 252 | - $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
| 253 | - foreach ($this->_status as $key => $value) { |
|
| 254 | - $status[] = array('id' => $key, 'text' => $value); |
|
| 255 | - } |
|
| 256 | - if ($this->_view !== 'incomplete') { |
|
| 257 | - $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
| 258 | - isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 259 | - : ''); |
|
| 260 | - } |
|
| 261 | - if (isset($this->_req_data['event_id'])) { |
|
| 262 | - $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 263 | - } |
|
| 264 | - return $filters; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * _add_view_counts |
|
| 271 | - * |
|
| 272 | - * @access protected |
|
| 273 | - * @return void |
|
| 274 | - * @throws \EE_Error |
|
| 275 | - */ |
|
| 276 | - protected function _add_view_counts() |
|
| 277 | - { |
|
| 278 | - $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 279 | - $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 280 | - $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 281 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 282 | - 'espresso_registrations_trash_registrations') |
|
| 283 | - ) { |
|
| 284 | - $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 285 | - $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * _total_registrations |
|
| 293 | - * |
|
| 294 | - * @access protected |
|
| 295 | - * @param string $view |
|
| 296 | - * @return int |
|
| 297 | - * @throws \EE_Error |
|
| 298 | - */ |
|
| 299 | - protected function _total_registrations($view = '') |
|
| 300 | - { |
|
| 301 | - $_where = array(); |
|
| 302 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 303 | - if ($EVT_ID) { |
|
| 304 | - $_where['EVT_ID'] = $EVT_ID; |
|
| 305 | - } |
|
| 306 | - switch ($view) { |
|
| 307 | - case 'trash' : |
|
| 308 | - return EEM_Registration::instance()->count_deleted(array($_where)); |
|
| 309 | - break; |
|
| 310 | - case 'incomplete' : |
|
| 311 | - $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 312 | - break; |
|
| 313 | - default : |
|
| 314 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 315 | - } |
|
| 316 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * _total_registrations_this_month |
|
| 323 | - * |
|
| 324 | - * @access protected |
|
| 325 | - * @return int |
|
| 326 | - * @throws \EE_Error |
|
| 327 | - */ |
|
| 328 | - protected function _total_registrations_this_month() |
|
| 329 | - { |
|
| 330 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 331 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 332 | - $this_year_r = date('Y', current_time('timestamp')); |
|
| 333 | - $time_start = ' 00:00:00'; |
|
| 334 | - $time_end = ' 23:59:59'; |
|
| 335 | - $this_month_r = date('m', current_time('timestamp')); |
|
| 336 | - $days_this_month = date('t', current_time('timestamp')); |
|
| 337 | - //setup date query. |
|
| 338 | - $beginning_string = EEM_Registration::instance() |
|
| 339 | - ->convert_datetime_for_query('REG_date', |
|
| 340 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 341 | - 'Y-m-d H:i:s'); |
|
| 342 | - $end_string = EEM_Registration::instance() |
|
| 343 | - ->convert_datetime_for_query('REG_date', |
|
| 344 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 345 | - 'Y-m-d H:i:s'); |
|
| 346 | - $_where['REG_date'] = array( |
|
| 347 | - 'BETWEEN', |
|
| 348 | - array( |
|
| 349 | - $beginning_string, |
|
| 350 | - $end_string, |
|
| 351 | - ), |
|
| 352 | - ); |
|
| 353 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 354 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * _total_registrations_today |
|
| 361 | - * |
|
| 362 | - * @access protected |
|
| 363 | - * @return int |
|
| 364 | - * @throws \EE_Error |
|
| 365 | - */ |
|
| 366 | - protected function _total_registrations_today() |
|
| 367 | - { |
|
| 368 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 369 | - $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 370 | - $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 371 | - $time_start = ' 00:00:00'; |
|
| 372 | - $time_end = ' 23:59:59'; |
|
| 373 | - $_where['REG_date'] = array( |
|
| 374 | - 'BETWEEN', |
|
| 375 | - array( |
|
| 376 | - EEM_Registration::instance() |
|
| 377 | - ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
| 378 | - EEM_Registration::instance() |
|
| 379 | - ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
| 380 | - ), |
|
| 381 | - ); |
|
| 382 | - $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 383 | - return EEM_Registration::instance()->count(array($_where)); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * column_cb |
|
| 390 | - * |
|
| 391 | - * @access public |
|
| 392 | - * @param \EE_Registration $item |
|
| 393 | - * @return string |
|
| 394 | - * @throws \EE_Error |
|
| 395 | - */ |
|
| 396 | - public function column_cb($item) |
|
| 397 | - { |
|
| 398 | - /** checkbox/lock **/ |
|
| 399 | - $transaction = $item->get_first_related('Transaction'); |
|
| 400 | - $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
| 401 | - return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()) |
|
| 402 | - . '<span class="ee-lock-icon"></span>' |
|
| 403 | - : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * column__REG_ID |
|
| 410 | - * |
|
| 411 | - * @access public |
|
| 412 | - * @param \EE_Registration $item |
|
| 413 | - * @return string |
|
| 414 | - * @throws \EE_Error |
|
| 415 | - */ |
|
| 416 | - public function column__REG_ID(EE_Registration $item) |
|
| 417 | - { |
|
| 418 | - $attendee = $item->attendee(); |
|
| 419 | - $content = $item->ID(); |
|
| 420 | - $content .= '<div class="show-on-mobile-view-only">'; |
|
| 421 | - $content .= '<br>'; |
|
| 422 | - $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 423 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 424 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 425 | - $content .= '</div>'; |
|
| 426 | - return $content; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * column__REG_date |
|
| 433 | - * |
|
| 434 | - * @access public |
|
| 435 | - * @param \EE_Registration $item |
|
| 436 | - * @return string |
|
| 437 | - * @throws \EE_Error |
|
| 438 | - */ |
|
| 439 | - public function column__REG_date(EE_Registration $item) |
|
| 440 | - { |
|
| 441 | - $this->_set_related_details($item); |
|
| 442 | - //Build row actions |
|
| 443 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 444 | - 'action' => 'view_transaction', |
|
| 445 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 446 | - ), TXN_ADMIN_URL); |
|
| 447 | - $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 448 | - 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
| 449 | - . $this->_transaction_details['status'] |
|
| 450 | - . '" href="' |
|
| 451 | - . $view_lnk_url |
|
| 452 | - . '" title="' |
|
| 453 | - . esc_attr($this->_transaction_details['title_attr']) |
|
| 454 | - . '">' |
|
| 455 | - . $item->get_i18n_datetime('REG_date') |
|
| 456 | - . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
| 457 | - $view_link .= '<br><span class="ee-status-text-small">' |
|
| 458 | - . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 459 | - . '</span>'; |
|
| 460 | - return $view_link; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - /** |
|
| 466 | - * column_event_name |
|
| 467 | - * |
|
| 468 | - * @access public |
|
| 469 | - * @param \EE_Registration $item |
|
| 470 | - * @return string |
|
| 471 | - * @throws \EE_Error |
|
| 472 | - */ |
|
| 473 | - public function column_event_name(EE_Registration $item) |
|
| 474 | - { |
|
| 475 | - $this->_set_related_details($item); |
|
| 476 | - // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 477 | - $EVT_ID = $item->event_ID(); |
|
| 478 | - $event_name = $item->event_name(); |
|
| 479 | - $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
| 480 | - $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 481 | - if ($EVT_ID) { |
|
| 482 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
| 483 | - EVENTS_ADMIN_URL); |
|
| 484 | - $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 485 | - ? '<a class="ee-status-color-' |
|
| 486 | - . $this->_event_details['status'] |
|
| 487 | - . '" href="' |
|
| 488 | - . $edit_event_url |
|
| 489 | - . '" title="' |
|
| 490 | - . esc_attr($this->_event_details['title_attr']) |
|
| 491 | - . '">' |
|
| 492 | - . $event_name |
|
| 493 | - . '</a>' : $event_name; |
|
| 494 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
| 495 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 496 | - $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
| 497 | - 'event_espresso'), $event_name); |
|
| 498 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
| 499 | - } else { |
|
| 500 | - $edit_event = $event_name; |
|
| 501 | - $actions['event_filter'] = ''; |
|
| 502 | - } |
|
| 503 | - return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * column_DTT_EVT_start |
|
| 510 | - * |
|
| 511 | - * @access public |
|
| 512 | - * @param \EE_Registration $item |
|
| 513 | - * @return string |
|
| 514 | - * @throws \EE_Error |
|
| 515 | - */ |
|
| 516 | - public function column_DTT_EVT_start(EE_Registration $item) |
|
| 517 | - { |
|
| 518 | - $datetime_strings = array(); |
|
| 519 | - $ticket = $item->ticket(true); |
|
| 520 | - if ($ticket instanceof EE_Ticket) { |
|
| 521 | - $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 522 | - $datetimes = $ticket->datetimes($remove_defaults); |
|
| 523 | - foreach ($datetimes as $datetime) { |
|
| 524 | - $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 525 | - } |
|
| 526 | - return implode("<br />", $datetime_strings); |
|
| 527 | - } else { |
|
| 528 | - return __('There is no ticket on this registration', 'event_espresso'); |
|
| 529 | - } |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * column_ATT_fname |
|
| 536 | - * |
|
| 537 | - * @access public |
|
| 538 | - * @param \EE_Registration $item |
|
| 539 | - * @return string |
|
| 540 | - * @throws \EE_Error |
|
| 541 | - */ |
|
| 542 | - public function column_ATT_fname(EE_Registration $item) |
|
| 543 | - { |
|
| 544 | - $attendee = $item->attendee(); |
|
| 545 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 546 | - 'action' => 'view_registration', |
|
| 547 | - '_REG_ID' => $item->ID(), |
|
| 548 | - ), REG_ADMIN_URL); |
|
| 549 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 550 | - $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 551 | - 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
| 552 | - . $edit_lnk_url |
|
| 553 | - . '" title="' |
|
| 554 | - . esc_attr__('View Registration Details', |
|
| 555 | - 'event_espresso') |
|
| 556 | - . '">' |
|
| 557 | - . $attendee_name |
|
| 558 | - . '</a>' : $attendee_name; |
|
| 559 | - $link .= $item->count() === 1 |
|
| 560 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
| 561 | - $t = $item->get_first_related('Transaction'); |
|
| 562 | - $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
| 563 | - //append group count to name |
|
| 564 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 565 | - //append reg_code |
|
| 566 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 567 | - //reg status text for accessibility |
|
| 568 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 569 | - 'sentence') . '</span>'; |
|
| 570 | - //trash/restore/delete actions |
|
| 571 | - $actions = array(); |
|
| 572 | - if ($this->_view !== 'trash' |
|
| 573 | - && $payment_count === 0 |
|
| 574 | - && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 575 | - 'espresso_registrations_trash_registrations', $item->ID()) |
|
| 576 | - ) { |
|
| 577 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 578 | - 'action' => 'trash_registrations', |
|
| 579 | - '_REG_ID' => $item->ID(), |
|
| 580 | - ), REG_ADMIN_URL); |
|
| 581 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
| 582 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 583 | - } elseif ($this->_view === 'trash') { |
|
| 584 | - // restore registration link |
|
| 585 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 586 | - 'espresso_registrations_restore_registrations', $item->ID()) |
|
| 587 | - ) { |
|
| 588 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 589 | - 'action' => 'restore_registrations', |
|
| 590 | - '_REG_ID' => $item->ID(), |
|
| 591 | - ), REG_ADMIN_URL); |
|
| 592 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
| 593 | - 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
| 594 | - } |
|
| 595 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 596 | - 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
| 597 | - ) { |
|
| 598 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 599 | - 'action' => 'delete_registrations', |
|
| 600 | - '_REG_ID' => $item->ID(), |
|
| 601 | - ), REG_ADMIN_URL); |
|
| 602 | - $actions['delete'] = '<a href="' |
|
| 603 | - . $delete_lnk_url |
|
| 604 | - . '" title="' |
|
| 605 | - . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 606 | - . '">' |
|
| 607 | - . __('Delete', 'event_espresso') |
|
| 608 | - . '</a>'; |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - |
|
| 616 | - /** |
|
| 617 | - * column_ATT_email |
|
| 618 | - * |
|
| 619 | - * @access public |
|
| 620 | - * @param \EE_Registration $item |
|
| 621 | - * @return string |
|
| 622 | - * @throws \EE_Error |
|
| 623 | - */ |
|
| 624 | - public function column_ATT_email(EE_Registration $item) |
|
| 625 | - { |
|
| 626 | - $attendee = $item->get_first_related('Attendee'); |
|
| 627 | - return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
| 628 | - : $attendee->email(); |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * column__REG_count |
|
| 635 | - * |
|
| 636 | - * @access public |
|
| 637 | - * @param \EE_Registration $item |
|
| 638 | - * @return string |
|
| 639 | - */ |
|
| 640 | - public function column__REG_count(EE_Registration $item) |
|
| 641 | - { |
|
| 642 | - return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - |
|
| 646 | - |
|
| 647 | - /** |
|
| 648 | - * column_PRC_amount |
|
| 649 | - * |
|
| 650 | - * @access public |
|
| 651 | - * @param \EE_Registration $item |
|
| 652 | - * @return string |
|
| 653 | - */ |
|
| 654 | - public function column_PRC_amount(EE_Registration $item) |
|
| 655 | - { |
|
| 656 | - $ticket = $item->ticket(); |
|
| 657 | - $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
| 658 | - . $ticket->name() |
|
| 659 | - . '</span><br />' : ''; |
|
| 660 | - if ($item->final_price() > 0) { |
|
| 661 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 662 | - } else { |
|
| 663 | - // free event |
|
| 664 | - $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 665 | - . __('free', 'event_espresso') |
|
| 666 | - . '</span>'; |
|
| 667 | - } |
|
| 668 | - return $content; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - |
|
| 672 | - |
|
| 673 | - /** |
|
| 674 | - * column__REG_final_price |
|
| 675 | - * |
|
| 676 | - * @access public |
|
| 677 | - * @param \EE_Registration $item |
|
| 678 | - * @return string |
|
| 679 | - */ |
|
| 680 | - public function column__REG_final_price(EE_Registration $item) |
|
| 681 | - { |
|
| 682 | - $ticket = $item->ticket(); |
|
| 683 | - $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 684 | - ? '' |
|
| 685 | - : '<span class="TKT_name">' |
|
| 686 | - . $ticket->name() |
|
| 687 | - . '</span><br />'; |
|
| 688 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 689 | - return $content; |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - |
|
| 693 | - |
|
| 694 | - /** |
|
| 695 | - * column__REG_paid |
|
| 696 | - * |
|
| 697 | - * @access public |
|
| 698 | - * @param \EE_Registration $item |
|
| 699 | - * @return string |
|
| 700 | - */ |
|
| 701 | - public function column__REG_paid(EE_Registration $item) |
|
| 702 | - { |
|
| 703 | - $payment_method = $item->payment_method(); |
|
| 704 | - $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
| 705 | - : __('Unknown', 'event_espresso'); |
|
| 706 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 707 | - if ($item->paid() > 0) { |
|
| 708 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 709 | - $payment_method_name) . '</span>'; |
|
| 710 | - } |
|
| 711 | - return $content; |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - |
|
| 715 | - |
|
| 716 | - /** |
|
| 717 | - * column_TXN_total |
|
| 718 | - * |
|
| 719 | - * @access public |
|
| 720 | - * @param \EE_Registration $item |
|
| 721 | - * @return string |
|
| 722 | - * @throws \EE_Error |
|
| 723 | - */ |
|
| 724 | - public function column_TXN_total(EE_Registration $item) |
|
| 725 | - { |
|
| 726 | - if ($item->transaction()) { |
|
| 727 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 728 | - 'action' => 'view_transaction', |
|
| 729 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 730 | - ), TXN_ADMIN_URL); |
|
| 731 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 732 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 733 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 734 | - . $item->transaction()->status_ID() |
|
| 735 | - . '" href="' |
|
| 736 | - . $view_txn_lnk_url |
|
| 737 | - . '" title="' |
|
| 738 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 739 | - . '">' |
|
| 740 | - . $item->transaction()->pretty_total() |
|
| 741 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 742 | - } else { |
|
| 743 | - return __("None", "event_espresso"); |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - |
|
| 749 | - /** |
|
| 750 | - * column_TXN_paid |
|
| 751 | - * |
|
| 752 | - * @access public |
|
| 753 | - * @param \EE_Registration $item |
|
| 754 | - * @return string |
|
| 755 | - * @throws \EE_Error |
|
| 756 | - */ |
|
| 757 | - public function column_TXN_paid(EE_Registration $item) |
|
| 758 | - { |
|
| 759 | - if ($item->count() === 1) { |
|
| 760 | - $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
| 761 | - if ($transaction->paid() >= $transaction->total()) { |
|
| 762 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 763 | - } else { |
|
| 764 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 765 | - 'action' => 'view_transaction', |
|
| 766 | - 'TXN_ID' => $item->transaction_ID(), |
|
| 767 | - ), TXN_ADMIN_URL); |
|
| 768 | - return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 769 | - 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 770 | - ? '<span class="reg-pad-rght"><a class="status-' |
|
| 771 | - . $transaction->status_ID() |
|
| 772 | - . '" href="' |
|
| 773 | - . $view_txn_lnk_url |
|
| 774 | - . '" title="' |
|
| 775 | - . esc_attr__('View Transaction', 'event_espresso') |
|
| 776 | - . '">' |
|
| 777 | - . $item->transaction()->pretty_paid() |
|
| 778 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 779 | - } |
|
| 780 | - } |
|
| 781 | - return ' '; |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - |
|
| 785 | - |
|
| 786 | - /** |
|
| 787 | - * column_actions |
|
| 788 | - * |
|
| 789 | - * @access public |
|
| 790 | - * @param \EE_Registration $item |
|
| 791 | - * @return string |
|
| 792 | - * @throws \EE_Error |
|
| 793 | - */ |
|
| 794 | - public function column_actions(EE_Registration $item) |
|
| 795 | - { |
|
| 796 | - $actions = array(); |
|
| 797 | - $attendee = $item->attendee(); |
|
| 798 | - $this->_set_related_details($item); |
|
| 799 | - //Build row actions |
|
| 800 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 801 | - 'action' => 'view_registration', |
|
| 802 | - '_REG_ID' => $item->ID(), |
|
| 803 | - ), REG_ADMIN_URL); |
|
| 804 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 805 | - 'action' => 'edit_attendee', |
|
| 806 | - 'post' => $item->attendee_ID(), |
|
| 807 | - ), REG_ADMIN_URL); |
|
| 808 | - // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
| 809 | - //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
| 810 | - $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 811 | - 'action' => 'resend_registration', |
|
| 812 | - '_REG_ID' => $item->ID(), |
|
| 813 | - ), REG_ADMIN_URL, true); |
|
| 814 | - //Build row actions |
|
| 815 | - $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 816 | - 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
| 29 | + private $_status; |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * An array of transaction details for the related transaction to the registration being processed. |
|
| 35 | + * This is set via the _set_related_details method. |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected $_transaction_details = array(); |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * An array of event details for the related event to the registration being processed. |
|
| 45 | + * This is set via the _set_related_details method. |
|
| 46 | + * |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | + protected $_event_details = array(); |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param \Registrations_Admin_Page $admin_page |
|
| 55 | + */ |
|
| 56 | + public function __construct(Registrations_Admin_Page $admin_page) |
|
| 57 | + { |
|
| 58 | + if ( ! empty($_GET['event_id'])) { |
|
| 59 | + $extra_query_args = array(); |
|
| 60 | + foreach ($admin_page->get_views() as $key => $view_details) { |
|
| 61 | + $extra_query_args[$view_details['slug']] = array('event_id' => $_GET['event_id']); |
|
| 62 | + } |
|
| 63 | + $this->_views = $admin_page->get_list_table_view_RLs($extra_query_args); |
|
| 64 | + } |
|
| 65 | + parent::__construct($admin_page); |
|
| 66 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * _setup_data |
|
| 73 | + * |
|
| 74 | + * @access protected |
|
| 75 | + * @return void |
|
| 76 | + */ |
|
| 77 | + protected function _setup_data() |
|
| 78 | + { |
|
| 79 | + $this->_data = $this->_admin_page->get_registrations($this->_per_page); |
|
| 80 | + $this->_all_data_count = $this->_admin_page->get_registrations($this->_per_page, true, false, false); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * _set_properties |
|
| 87 | + * |
|
| 88 | + * @access protected |
|
| 89 | + * @return void |
|
| 90 | + */ |
|
| 91 | + protected function _set_properties() |
|
| 92 | + { |
|
| 93 | + $this->_wp_list_args = array( |
|
| 94 | + 'singular' => __('registration', 'event_espresso'), |
|
| 95 | + 'plural' => __('registrations', 'event_espresso'), |
|
| 96 | + 'ajax' => true, |
|
| 97 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 98 | + ); |
|
| 99 | + $ID_column_name = __('ID', 'event_espresso'); |
|
| 100 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
| 101 | + $ID_column_name .= __('Registrant Name', 'event_espresso'); |
|
| 102 | + $ID_column_name .= '</span> '; |
|
| 103 | + if (isset($_GET['event_id'])) { |
|
| 104 | + $this->_columns = array( |
|
| 105 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 106 | + '_REG_ID' => $ID_column_name, |
|
| 107 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 108 | + 'ATT_email' => __('Email', 'event_espresso'), |
|
| 109 | + '_REG_date' => __('Reg Date', 'event_espresso'), |
|
| 110 | + 'PRC_amount' => __('TKT Price', 'event_espresso'), |
|
| 111 | + '_REG_final_price' => __('Final Price', 'event_espresso'), |
|
| 112 | + 'TXN_total' => __('Total Txn', 'event_espresso'), |
|
| 113 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
| 114 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 115 | + ); |
|
| 116 | + $this->_bottom_buttons = array( |
|
| 117 | + 'report' => array( |
|
| 118 | + 'route' => 'registrations_report', |
|
| 119 | + 'extra_request' => array( |
|
| 120 | + 'EVT_ID' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 121 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 122 | + ), |
|
| 123 | + ), |
|
| 124 | + ); |
|
| 125 | + } else { |
|
| 126 | + $this->_columns = array( |
|
| 127 | + 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text |
|
| 128 | + '_REG_ID' => $ID_column_name, |
|
| 129 | + 'ATT_fname' => __('Name', 'event_espresso'), |
|
| 130 | + '_REG_date' => __('TXN Date', 'event_espresso'), |
|
| 131 | + 'event_name' => __('Event', 'event_espresso'), |
|
| 132 | + 'DTT_EVT_start' => __('Event Date', 'event_espresso'), |
|
| 133 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
| 134 | + '_REG_paid' => __('Paid', 'event_espresso'), |
|
| 135 | + 'actions' => __('Actions', 'event_espresso'), |
|
| 136 | + ); |
|
| 137 | + $this->_bottom_buttons = array( |
|
| 138 | + 'report_all' => array( |
|
| 139 | + 'route' => 'registrations_report', |
|
| 140 | + 'extra_request' => array( |
|
| 141 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 142 | + ), |
|
| 143 | + ), |
|
| 144 | + ); |
|
| 145 | + } |
|
| 146 | + $this->_bottom_buttons['report_filtered'] = array( |
|
| 147 | + 'route' => 'registrations_report', |
|
| 148 | + 'extra_request' => array( |
|
| 149 | + 'use_filters' => true, |
|
| 150 | + 'filters' => array_diff_key($this->_req_data, array_flip(array( |
|
| 151 | + 'page', |
|
| 152 | + 'action', |
|
| 153 | + 'default_nonce', |
|
| 154 | + ))), |
|
| 155 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
| 156 | + ), |
|
| 157 | + ); |
|
| 158 | + $this->_primary_column = '_REG_ID'; |
|
| 159 | + $this->_sortable_columns = array( |
|
| 160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 161 | + /** |
|
| 162 | + * Allows users to change the default sort if they wish. |
|
| 163 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
| 164 | + */ |
|
| 165 | + 'ATT_fname' => array( |
|
| 166 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
| 167 | + true, |
|
| 168 | + $this |
|
| 169 | + ) |
|
| 170 | + ? array('ATT_lname' => false) |
|
| 171 | + : array('ATT_fname' => false), |
|
| 172 | + 'event_name' => array('event_name' => false), |
|
| 173 | + 'DTT_EVT_start' => array('DTT_EVT_start' => false), |
|
| 174 | + '_REG_ID' => array('_REG_ID' => false), |
|
| 175 | + ); |
|
| 176 | + $this->_hidden_columns = array(); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * This simply sets up the row class for the table rows. |
|
| 183 | + * Allows for easier overriding of child methods for setting up sorting. |
|
| 184 | + * |
|
| 185 | + * @param EE_Registration $item the current item |
|
| 186 | + * @return string |
|
| 187 | + */ |
|
| 188 | + protected function _get_row_class($item) |
|
| 189 | + { |
|
| 190 | + $class = parent::_get_row_class($item); |
|
| 191 | + //add status class |
|
| 192 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 193 | + if ($this->_has_checkbox_column) { |
|
| 194 | + $class .= ' has-checkbox-column'; |
|
| 195 | + } |
|
| 196 | + return $class; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Set the $_transaction_details property if not set yet. |
|
| 203 | + * |
|
| 204 | + * @param EE_Registration $registration |
|
| 205 | + * @throws \EE_Error |
|
| 206 | + */ |
|
| 207 | + protected function _set_related_details(EE_Registration $registration) |
|
| 208 | + { |
|
| 209 | + $transaction = $registration->get_first_related('Transaction'); |
|
| 210 | + $status = $transaction instanceof EE_Transaction ? $transaction->status_ID() |
|
| 211 | + : EEM_Transaction::failed_status_code; |
|
| 212 | + $this->_transaction_details = array( |
|
| 213 | + 'transaction' => $transaction, |
|
| 214 | + 'status' => $status, |
|
| 215 | + 'id' => $transaction instanceof EE_Transaction ? $transaction->ID() : 0, |
|
| 216 | + 'title_attr' => sprintf(__('View Transaction Details (%s)', 'event_espresso'), |
|
| 217 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 218 | + ); |
|
| 219 | + try { |
|
| 220 | + $event = $registration->event(); |
|
| 221 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
| 222 | + $event = null; |
|
| 223 | + } |
|
| 224 | + $status = $event instanceof EE_Event ? $event->get_active_status() : EE_Datetime::inactive; |
|
| 225 | + $this->_event_details = array( |
|
| 226 | + 'event' => $event, |
|
| 227 | + 'status' => $status, |
|
| 228 | + 'id' => $event instanceof EE_Event ? $event->ID() : 0, |
|
| 229 | + 'title_attr' => sprintf(__('Edit Event (%s)', 'event_espresso'), |
|
| 230 | + EEH_Template::pretty_status($status, false, 'sentence')), |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * _get_table_filters |
|
| 238 | + * |
|
| 239 | + * @access protected |
|
| 240 | + * @return array |
|
| 241 | + */ |
|
| 242 | + protected function _get_table_filters() |
|
| 243 | + { |
|
| 244 | + $filters = array(); |
|
| 245 | + //todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods. |
|
| 246 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 247 | + $cur_category = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 248 | + $reg_status = isset($this->_req_data['_reg_status']) ? $this->_req_data['_reg_status'] : ''; |
|
| 249 | + $filters[] = EEH_Form_Fields::generate_registration_months_dropdown($cur_date, $reg_status, $cur_category); |
|
| 250 | + $filters[] = EEH_Form_Fields::generate_event_category_dropdown($cur_category); |
|
| 251 | + $status = array(); |
|
| 252 | + $status[] = array('id' => 0, 'text' => __('Select Status', 'event_espresso')); |
|
| 253 | + foreach ($this->_status as $key => $value) { |
|
| 254 | + $status[] = array('id' => $key, 'text' => $value); |
|
| 255 | + } |
|
| 256 | + if ($this->_view !== 'incomplete') { |
|
| 257 | + $filters[] = EEH_Form_Fields::select_input('_reg_status', $status, |
|
| 258 | + isset($this->_req_data['_reg_status']) ? strtoupper(sanitize_key($this->_req_data['_reg_status'])) |
|
| 259 | + : ''); |
|
| 260 | + } |
|
| 261 | + if (isset($this->_req_data['event_id'])) { |
|
| 262 | + $filters[] = EEH_Form_Fields::hidden_input('event_id', $this->_req_data['event_id'], 'reg_event_id'); |
|
| 263 | + } |
|
| 264 | + return $filters; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * _add_view_counts |
|
| 271 | + * |
|
| 272 | + * @access protected |
|
| 273 | + * @return void |
|
| 274 | + * @throws \EE_Error |
|
| 275 | + */ |
|
| 276 | + protected function _add_view_counts() |
|
| 277 | + { |
|
| 278 | + $this->_views['all']['count'] = $this->_total_registrations(); |
|
| 279 | + $this->_views['month']['count'] = $this->_total_registrations_this_month(); |
|
| 280 | + $this->_views['today']['count'] = $this->_total_registrations_today(); |
|
| 281 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', |
|
| 282 | + 'espresso_registrations_trash_registrations') |
|
| 283 | + ) { |
|
| 284 | + $this->_views['incomplete']['count'] = $this->_total_registrations('incomplete'); |
|
| 285 | + $this->_views['trash']['count'] = $this->_total_registrations('trash'); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * _total_registrations |
|
| 293 | + * |
|
| 294 | + * @access protected |
|
| 295 | + * @param string $view |
|
| 296 | + * @return int |
|
| 297 | + * @throws \EE_Error |
|
| 298 | + */ |
|
| 299 | + protected function _total_registrations($view = '') |
|
| 300 | + { |
|
| 301 | + $_where = array(); |
|
| 302 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 303 | + if ($EVT_ID) { |
|
| 304 | + $_where['EVT_ID'] = $EVT_ID; |
|
| 305 | + } |
|
| 306 | + switch ($view) { |
|
| 307 | + case 'trash' : |
|
| 308 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
| 309 | + break; |
|
| 310 | + case 'incomplete' : |
|
| 311 | + $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
|
| 312 | + break; |
|
| 313 | + default : |
|
| 314 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 315 | + } |
|
| 316 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * _total_registrations_this_month |
|
| 323 | + * |
|
| 324 | + * @access protected |
|
| 325 | + * @return int |
|
| 326 | + * @throws \EE_Error |
|
| 327 | + */ |
|
| 328 | + protected function _total_registrations_this_month() |
|
| 329 | + { |
|
| 330 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 331 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 332 | + $this_year_r = date('Y', current_time('timestamp')); |
|
| 333 | + $time_start = ' 00:00:00'; |
|
| 334 | + $time_end = ' 23:59:59'; |
|
| 335 | + $this_month_r = date('m', current_time('timestamp')); |
|
| 336 | + $days_this_month = date('t', current_time('timestamp')); |
|
| 337 | + //setup date query. |
|
| 338 | + $beginning_string = EEM_Registration::instance() |
|
| 339 | + ->convert_datetime_for_query('REG_date', |
|
| 340 | + $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 341 | + 'Y-m-d H:i:s'); |
|
| 342 | + $end_string = EEM_Registration::instance() |
|
| 343 | + ->convert_datetime_for_query('REG_date', |
|
| 344 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 345 | + 'Y-m-d H:i:s'); |
|
| 346 | + $_where['REG_date'] = array( |
|
| 347 | + 'BETWEEN', |
|
| 348 | + array( |
|
| 349 | + $beginning_string, |
|
| 350 | + $end_string, |
|
| 351 | + ), |
|
| 352 | + ); |
|
| 353 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 354 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * _total_registrations_today |
|
| 361 | + * |
|
| 362 | + * @access protected |
|
| 363 | + * @return int |
|
| 364 | + * @throws \EE_Error |
|
| 365 | + */ |
|
| 366 | + protected function _total_registrations_today() |
|
| 367 | + { |
|
| 368 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
| 369 | + $_where = $EVT_ID ? array('EVT_ID' => $EVT_ID) : array(); |
|
| 370 | + $current_date = date('Y-m-d', current_time('timestamp')); |
|
| 371 | + $time_start = ' 00:00:00'; |
|
| 372 | + $time_end = ' 23:59:59'; |
|
| 373 | + $_where['REG_date'] = array( |
|
| 374 | + 'BETWEEN', |
|
| 375 | + array( |
|
| 376 | + EEM_Registration::instance() |
|
| 377 | + ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
| 378 | + EEM_Registration::instance() |
|
| 379 | + ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
| 380 | + ), |
|
| 381 | + ); |
|
| 382 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
| 383 | + return EEM_Registration::instance()->count(array($_where)); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * column_cb |
|
| 390 | + * |
|
| 391 | + * @access public |
|
| 392 | + * @param \EE_Registration $item |
|
| 393 | + * @return string |
|
| 394 | + * @throws \EE_Error |
|
| 395 | + */ |
|
| 396 | + public function column_cb($item) |
|
| 397 | + { |
|
| 398 | + /** checkbox/lock **/ |
|
| 399 | + $transaction = $item->get_first_related('Transaction'); |
|
| 400 | + $payment_count = $transaction instanceof EE_Transaction ? $transaction->count_related('Payment') : 0; |
|
| 401 | + return $payment_count > 0 ? sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()) |
|
| 402 | + . '<span class="ee-lock-icon"></span>' |
|
| 403 | + : sprintf('<input type="checkbox" name="_REG_ID[]" value="%1$s" />', $item->ID()); |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * column__REG_ID |
|
| 410 | + * |
|
| 411 | + * @access public |
|
| 412 | + * @param \EE_Registration $item |
|
| 413 | + * @return string |
|
| 414 | + * @throws \EE_Error |
|
| 415 | + */ |
|
| 416 | + public function column__REG_ID(EE_Registration $item) |
|
| 417 | + { |
|
| 418 | + $attendee = $item->attendee(); |
|
| 419 | + $content = $item->ID(); |
|
| 420 | + $content .= '<div class="show-on-mobile-view-only">'; |
|
| 421 | + $content .= '<br>'; |
|
| 422 | + $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 423 | + $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 424 | + $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 425 | + $content .= '</div>'; |
|
| 426 | + return $content; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * column__REG_date |
|
| 433 | + * |
|
| 434 | + * @access public |
|
| 435 | + * @param \EE_Registration $item |
|
| 436 | + * @return string |
|
| 437 | + * @throws \EE_Error |
|
| 438 | + */ |
|
| 439 | + public function column__REG_date(EE_Registration $item) |
|
| 440 | + { |
|
| 441 | + $this->_set_related_details($item); |
|
| 442 | + //Build row actions |
|
| 443 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 444 | + 'action' => 'view_transaction', |
|
| 445 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 446 | + ), TXN_ADMIN_URL); |
|
| 447 | + $view_link = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 448 | + 'espresso_transactions_view_transaction') ? '<a class="ee-status-color-' |
|
| 449 | + . $this->_transaction_details['status'] |
|
| 450 | + . '" href="' |
|
| 451 | + . $view_lnk_url |
|
| 452 | + . '" title="' |
|
| 453 | + . esc_attr($this->_transaction_details['title_attr']) |
|
| 454 | + . '">' |
|
| 455 | + . $item->get_i18n_datetime('REG_date') |
|
| 456 | + . '</a>' : $item->get_i18n_datetime('REG_date'); |
|
| 457 | + $view_link .= '<br><span class="ee-status-text-small">' |
|
| 458 | + . EEH_Template::pretty_status($this->_transaction_details['status'], false, 'sentence') |
|
| 459 | + . '</span>'; |
|
| 460 | + return $view_link; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + /** |
|
| 466 | + * column_event_name |
|
| 467 | + * |
|
| 468 | + * @access public |
|
| 469 | + * @param \EE_Registration $item |
|
| 470 | + * @return string |
|
| 471 | + * @throws \EE_Error |
|
| 472 | + */ |
|
| 473 | + public function column_event_name(EE_Registration $item) |
|
| 474 | + { |
|
| 475 | + $this->_set_related_details($item); |
|
| 476 | + // page=espresso_events&action=edit_event&EVT_ID=2&edit_event_nonce=cf3a7e5b62 |
|
| 477 | + $EVT_ID = $item->event_ID(); |
|
| 478 | + $event_name = $item->event_name(); |
|
| 479 | + $event_name = $event_name ? $event_name : __("No Associated Event", 'event_espresso'); |
|
| 480 | + $event_name = wp_trim_words($event_name, 30, '...'); |
|
| 481 | + if ($EVT_ID) { |
|
| 482 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $EVT_ID), |
|
| 483 | + EVENTS_ADMIN_URL); |
|
| 484 | + $edit_event = EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'edit_event', $EVT_ID) |
|
| 485 | + ? '<a class="ee-status-color-' |
|
| 486 | + . $this->_event_details['status'] |
|
| 487 | + . '" href="' |
|
| 488 | + . $edit_event_url |
|
| 489 | + . '" title="' |
|
| 490 | + . esc_attr($this->_event_details['title_attr']) |
|
| 491 | + . '">' |
|
| 492 | + . $event_name |
|
| 493 | + . '</a>' : $event_name; |
|
| 494 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
|
| 495 | + $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 496 | + $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
|
| 497 | + 'event_espresso'), $event_name); |
|
| 498 | + $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
| 499 | + } else { |
|
| 500 | + $edit_event = $event_name; |
|
| 501 | + $actions['event_filter'] = ''; |
|
| 502 | + } |
|
| 503 | + return sprintf('%1$s %2$s', $edit_event, $this->row_actions($actions)); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + |
|
| 507 | + |
|
| 508 | + /** |
|
| 509 | + * column_DTT_EVT_start |
|
| 510 | + * |
|
| 511 | + * @access public |
|
| 512 | + * @param \EE_Registration $item |
|
| 513 | + * @return string |
|
| 514 | + * @throws \EE_Error |
|
| 515 | + */ |
|
| 516 | + public function column_DTT_EVT_start(EE_Registration $item) |
|
| 517 | + { |
|
| 518 | + $datetime_strings = array(); |
|
| 519 | + $ticket = $item->ticket(true); |
|
| 520 | + if ($ticket instanceof EE_Ticket) { |
|
| 521 | + $remove_defaults = array('default_where_conditions' => 'none'); |
|
| 522 | + $datetimes = $ticket->datetimes($remove_defaults); |
|
| 523 | + foreach ($datetimes as $datetime) { |
|
| 524 | + $datetime_strings[] = $datetime->get_i18n_datetime('DTT_EVT_start'); |
|
| 525 | + } |
|
| 526 | + return implode("<br />", $datetime_strings); |
|
| 527 | + } else { |
|
| 528 | + return __('There is no ticket on this registration', 'event_espresso'); |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * column_ATT_fname |
|
| 536 | + * |
|
| 537 | + * @access public |
|
| 538 | + * @param \EE_Registration $item |
|
| 539 | + * @return string |
|
| 540 | + * @throws \EE_Error |
|
| 541 | + */ |
|
| 542 | + public function column_ATT_fname(EE_Registration $item) |
|
| 543 | + { |
|
| 544 | + $attendee = $item->attendee(); |
|
| 545 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 546 | + 'action' => 'view_registration', |
|
| 547 | + '_REG_ID' => $item->ID(), |
|
| 548 | + ), REG_ADMIN_URL); |
|
| 549 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
| 550 | + $link = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 551 | + 'espresso_registrations_view_registration', $item->ID()) ? '<a href="' |
|
| 552 | + . $edit_lnk_url |
|
| 553 | + . '" title="' |
|
| 554 | + . esc_attr__('View Registration Details', |
|
| 555 | + 'event_espresso') |
|
| 556 | + . '">' |
|
| 557 | + . $attendee_name |
|
| 558 | + . '</a>' : $attendee_name; |
|
| 559 | + $link .= $item->count() === 1 |
|
| 560 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup>' : ''; |
|
| 561 | + $t = $item->get_first_related('Transaction'); |
|
| 562 | + $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
|
| 563 | + //append group count to name |
|
| 564 | + $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 565 | + //append reg_code |
|
| 566 | + $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 567 | + //reg status text for accessibility |
|
| 568 | + $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 569 | + 'sentence') . '</span>'; |
|
| 570 | + //trash/restore/delete actions |
|
| 571 | + $actions = array(); |
|
| 572 | + if ($this->_view !== 'trash' |
|
| 573 | + && $payment_count === 0 |
|
| 574 | + && EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 575 | + 'espresso_registrations_trash_registrations', $item->ID()) |
|
| 576 | + ) { |
|
| 577 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 578 | + 'action' => 'trash_registrations', |
|
| 579 | + '_REG_ID' => $item->ID(), |
|
| 580 | + ), REG_ADMIN_URL); |
|
| 581 | + $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
| 582 | + 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 583 | + } elseif ($this->_view === 'trash') { |
|
| 584 | + // restore registration link |
|
| 585 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 586 | + 'espresso_registrations_restore_registrations', $item->ID()) |
|
| 587 | + ) { |
|
| 588 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 589 | + 'action' => 'restore_registrations', |
|
| 590 | + '_REG_ID' => $item->ID(), |
|
| 591 | + ), REG_ADMIN_URL); |
|
| 592 | + $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
| 593 | + 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
| 594 | + } |
|
| 595 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
|
| 596 | + 'espresso_registrations_ee_delete_registrations', $item->ID()) |
|
| 597 | + ) { |
|
| 598 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 599 | + 'action' => 'delete_registrations', |
|
| 600 | + '_REG_ID' => $item->ID(), |
|
| 601 | + ), REG_ADMIN_URL); |
|
| 602 | + $actions['delete'] = '<a href="' |
|
| 603 | + . $delete_lnk_url |
|
| 604 | + . '" title="' |
|
| 605 | + . esc_attr__('Delete Registration Permanently', 'event_espresso') |
|
| 606 | + . '">' |
|
| 607 | + . __('Delete', 'event_espresso') |
|
| 608 | + . '</a>'; |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + return sprintf('%1$s %2$s', $link, $this->row_actions($actions)); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + |
|
| 616 | + /** |
|
| 617 | + * column_ATT_email |
|
| 618 | + * |
|
| 619 | + * @access public |
|
| 620 | + * @param \EE_Registration $item |
|
| 621 | + * @return string |
|
| 622 | + * @throws \EE_Error |
|
| 623 | + */ |
|
| 624 | + public function column_ATT_email(EE_Registration $item) |
|
| 625 | + { |
|
| 626 | + $attendee = $item->get_first_related('Attendee'); |
|
| 627 | + return ! $attendee instanceof EE_Attendee ? __('No attached contact record.', 'event_espresso') |
|
| 628 | + : $attendee->email(); |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * column__REG_count |
|
| 635 | + * |
|
| 636 | + * @access public |
|
| 637 | + * @param \EE_Registration $item |
|
| 638 | + * @return string |
|
| 639 | + */ |
|
| 640 | + public function column__REG_count(EE_Registration $item) |
|
| 641 | + { |
|
| 642 | + return sprintf(__('%1$s / %2$s', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + |
|
| 646 | + |
|
| 647 | + /** |
|
| 648 | + * column_PRC_amount |
|
| 649 | + * |
|
| 650 | + * @access public |
|
| 651 | + * @param \EE_Registration $item |
|
| 652 | + * @return string |
|
| 653 | + */ |
|
| 654 | + public function column_PRC_amount(EE_Registration $item) |
|
| 655 | + { |
|
| 656 | + $ticket = $item->ticket(); |
|
| 657 | + $content = isset($_GET['event_id']) && $ticket instanceof EE_Ticket ? '<span class="TKT_name">' |
|
| 658 | + . $ticket->name() |
|
| 659 | + . '</span><br />' : ''; |
|
| 660 | + if ($item->final_price() > 0) { |
|
| 661 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 662 | + } else { |
|
| 663 | + // free event |
|
| 664 | + $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
|
| 665 | + . __('free', 'event_espresso') |
|
| 666 | + . '</span>'; |
|
| 667 | + } |
|
| 668 | + return $content; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + |
|
| 672 | + |
|
| 673 | + /** |
|
| 674 | + * column__REG_final_price |
|
| 675 | + * |
|
| 676 | + * @access public |
|
| 677 | + * @param \EE_Registration $item |
|
| 678 | + * @return string |
|
| 679 | + */ |
|
| 680 | + public function column__REG_final_price(EE_Registration $item) |
|
| 681 | + { |
|
| 682 | + $ticket = $item->ticket(); |
|
| 683 | + $content = isset($_GET['event_id']) || ! $ticket instanceof EE_Ticket |
|
| 684 | + ? '' |
|
| 685 | + : '<span class="TKT_name">' |
|
| 686 | + . $ticket->name() |
|
| 687 | + . '</span><br />'; |
|
| 688 | + $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 689 | + return $content; |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + |
|
| 693 | + |
|
| 694 | + /** |
|
| 695 | + * column__REG_paid |
|
| 696 | + * |
|
| 697 | + * @access public |
|
| 698 | + * @param \EE_Registration $item |
|
| 699 | + * @return string |
|
| 700 | + */ |
|
| 701 | + public function column__REG_paid(EE_Registration $item) |
|
| 702 | + { |
|
| 703 | + $payment_method = $item->payment_method(); |
|
| 704 | + $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
|
| 705 | + : __('Unknown', 'event_espresso'); |
|
| 706 | + $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 707 | + if ($item->paid() > 0) { |
|
| 708 | + $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 709 | + $payment_method_name) . '</span>'; |
|
| 710 | + } |
|
| 711 | + return $content; |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * column_TXN_total |
|
| 718 | + * |
|
| 719 | + * @access public |
|
| 720 | + * @param \EE_Registration $item |
|
| 721 | + * @return string |
|
| 722 | + * @throws \EE_Error |
|
| 723 | + */ |
|
| 724 | + public function column_TXN_total(EE_Registration $item) |
|
| 725 | + { |
|
| 726 | + if ($item->transaction()) { |
|
| 727 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 728 | + 'action' => 'view_transaction', |
|
| 729 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 730 | + ), TXN_ADMIN_URL); |
|
| 731 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 732 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 733 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 734 | + . $item->transaction()->status_ID() |
|
| 735 | + . '" href="' |
|
| 736 | + . $view_txn_lnk_url |
|
| 737 | + . '" title="' |
|
| 738 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 739 | + . '">' |
|
| 740 | + . $item->transaction()->pretty_total() |
|
| 741 | + . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 742 | + } else { |
|
| 743 | + return __("None", "event_espresso"); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + |
|
| 749 | + /** |
|
| 750 | + * column_TXN_paid |
|
| 751 | + * |
|
| 752 | + * @access public |
|
| 753 | + * @param \EE_Registration $item |
|
| 754 | + * @return string |
|
| 755 | + * @throws \EE_Error |
|
| 756 | + */ |
|
| 757 | + public function column_TXN_paid(EE_Registration $item) |
|
| 758 | + { |
|
| 759 | + if ($item->count() === 1) { |
|
| 760 | + $transaction = $item->transaction() ? $item->transaction() : EE_Transaction::new_instance(); |
|
| 761 | + if ($transaction->paid() >= $transaction->total()) { |
|
| 762 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
| 763 | + } else { |
|
| 764 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 765 | + 'action' => 'view_transaction', |
|
| 766 | + 'TXN_ID' => $item->transaction_ID(), |
|
| 767 | + ), TXN_ADMIN_URL); |
|
| 768 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 769 | + 'espresso_transactions_view_transaction', $item->transaction_ID()) |
|
| 770 | + ? '<span class="reg-pad-rght"><a class="status-' |
|
| 771 | + . $transaction->status_ID() |
|
| 772 | + . '" href="' |
|
| 773 | + . $view_txn_lnk_url |
|
| 774 | + . '" title="' |
|
| 775 | + . esc_attr__('View Transaction', 'event_espresso') |
|
| 776 | + . '">' |
|
| 777 | + . $item->transaction()->pretty_paid() |
|
| 778 | + . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + return ' '; |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + |
|
| 785 | + |
|
| 786 | + /** |
|
| 787 | + * column_actions |
|
| 788 | + * |
|
| 789 | + * @access public |
|
| 790 | + * @param \EE_Registration $item |
|
| 791 | + * @return string |
|
| 792 | + * @throws \EE_Error |
|
| 793 | + */ |
|
| 794 | + public function column_actions(EE_Registration $item) |
|
| 795 | + { |
|
| 796 | + $actions = array(); |
|
| 797 | + $attendee = $item->attendee(); |
|
| 798 | + $this->_set_related_details($item); |
|
| 799 | + //Build row actions |
|
| 800 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 801 | + 'action' => 'view_registration', |
|
| 802 | + '_REG_ID' => $item->ID(), |
|
| 803 | + ), REG_ADMIN_URL); |
|
| 804 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 805 | + 'action' => 'edit_attendee', |
|
| 806 | + 'post' => $item->attendee_ID(), |
|
| 807 | + ), REG_ADMIN_URL); |
|
| 808 | + // page=attendees&event_admin_reports=resend_email®istration_id=43653465634&event_id=2&form_action=resend_email |
|
| 809 | + //$resend_reg_lnk_url_params = array( 'action'=>'resend_registration', '_REG_ID'=>$item->REG_ID ); |
|
| 810 | + $resend_reg_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 811 | + 'action' => 'resend_registration', |
|
| 812 | + '_REG_ID' => $item->ID(), |
|
| 813 | + ), REG_ADMIN_URL, true); |
|
| 814 | + //Build row actions |
|
| 815 | + $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
|
| 816 | + 'espresso_registrations_view_registration', $item->ID()) ? ' |
|
| 817 | 817 | <li> |
| 818 | 818 | <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
| 819 | 819 | <div class="dashicons dashicons-clipboard"></div> |
| 820 | 820 | </a> |
| 821 | 821 | </li>' : ''; |
| 822 | - $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
| 823 | - 'espresso_registrations_edit_attendee') |
|
| 824 | - && $attendee instanceof EE_Attendee ? ' |
|
| 822 | + $actions['edit_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_contacts', |
|
| 823 | + 'espresso_registrations_edit_attendee') |
|
| 824 | + && $attendee instanceof EE_Attendee ? ' |
|
| 825 | 825 | <li> |
| 826 | 826 | <a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
| 827 | 827 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
| 828 | 828 | </a> |
| 829 | 829 | </li>' : ''; |
| 830 | - $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
| 831 | - && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 832 | - 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
| 830 | + $actions['resend_reg_lnk'] = $attendee instanceof EE_Attendee |
|
| 831 | + && EE_Registry::instance()->CAP->current_user_can('ee_send_message', |
|
| 832 | + 'espresso_registrations_resend_registration', $item->ID()) ? ' |
|
| 833 | 833 | <li> |
| 834 | 834 | <a href="' |
| 835 | - . $resend_reg_lnk_url |
|
| 836 | - . '" title="' |
|
| 837 | - . esc_attr__('Resend Registration Details', |
|
| 838 | - 'event_espresso') |
|
| 839 | - . '" class="tiny-text"> |
|
| 835 | + . $resend_reg_lnk_url |
|
| 836 | + . '" title="' |
|
| 837 | + . esc_attr__('Resend Registration Details', |
|
| 838 | + 'event_espresso') |
|
| 839 | + . '" class="tiny-text"> |
|
| 840 | 840 | <div class="dashicons dashicons-email-alt"></div> |
| 841 | 841 | </a> |
| 842 | 842 | </li>' : ''; |
| 843 | - // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
| 844 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 845 | - 'action' => 'view_transaction', |
|
| 846 | - 'TXN_ID' => $this->_transaction_details['id'], |
|
| 847 | - ), TXN_ADMIN_URL); |
|
| 848 | - $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 849 | - 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
| 843 | + // page=transactions&action=view_transaction&txn=256&_wpnonce=6414da4dbb |
|
| 844 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
| 845 | + 'action' => 'view_transaction', |
|
| 846 | + 'TXN_ID' => $this->_transaction_details['id'], |
|
| 847 | + ), TXN_ADMIN_URL); |
|
| 848 | + $actions['view_txn_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', |
|
| 849 | + 'espresso_transactions_view_transaction', $this->_transaction_details['id']) ? ' |
|
| 850 | 850 | <li> |
| 851 | 851 | <a class="ee-status-color-' |
| 852 | - . $this->_transaction_details['status'] |
|
| 853 | - . ' tiny-text" href="' |
|
| 854 | - . $view_txn_lnk_url |
|
| 855 | - . '" title="' |
|
| 856 | - . $this->_transaction_details['title_attr'] |
|
| 857 | - . '"> |
|
| 852 | + . $this->_transaction_details['status'] |
|
| 853 | + . ' tiny-text" href="' |
|
| 854 | + . $view_txn_lnk_url |
|
| 855 | + . '" title="' |
|
| 856 | + . $this->_transaction_details['title_attr'] |
|
| 857 | + . '"> |
|
| 858 | 858 | <div class="dashicons dashicons-cart"></div> |
| 859 | 859 | </a> |
| 860 | 860 | </li>' : ''; |
| 861 | - //invoice link |
|
| 862 | - $actions['dl_invoice_lnk'] = ''; |
|
| 863 | - $dl_invoice_lnk_url = $item->invoice_url(); |
|
| 864 | - //only show invoice link if message type is active. |
|
| 865 | - if ($attendee instanceof EE_Attendee |
|
| 866 | - && $item->is_primary_registrant() |
|
| 867 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
| 868 | - ) { |
|
| 869 | - $actions['dl_invoice_lnk'] = ' |
|
| 861 | + //invoice link |
|
| 862 | + $actions['dl_invoice_lnk'] = ''; |
|
| 863 | + $dl_invoice_lnk_url = $item->invoice_url(); |
|
| 864 | + //only show invoice link if message type is active. |
|
| 865 | + if ($attendee instanceof EE_Attendee |
|
| 866 | + && $item->is_primary_registrant() |
|
| 867 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
| 868 | + ) { |
|
| 869 | + $actions['dl_invoice_lnk'] = ' |
|
| 870 | 870 | <li> |
| 871 | 871 | <a title="' |
| 872 | - . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
| 873 | - . '" target="_blank" href="' |
|
| 874 | - . $dl_invoice_lnk_url |
|
| 875 | - . '" class="tiny-text"> |
|
| 872 | + . esc_attr__('View Transaction Invoice', 'event_espresso') |
|
| 873 | + . '" target="_blank" href="' |
|
| 874 | + . $dl_invoice_lnk_url |
|
| 875 | + . '" class="tiny-text"> |
|
| 876 | 876 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
| 877 | 877 | </a> |
| 878 | 878 | </li>'; |
| 879 | - } |
|
| 880 | - $actions['filtered_messages_link'] = ''; |
|
| 881 | - //message list table link (filtered by REG_ID |
|
| 882 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 883 | - $actions['filtered_messages_link'] = '<li>' |
|
| 884 | - . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
| 885 | - null, array( |
|
| 886 | - '_REG_ID' => $item->ID(), |
|
| 887 | - )) |
|
| 888 | - . '</li>'; |
|
| 889 | - } |
|
| 890 | - $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 891 | - return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 892 | - } |
|
| 879 | + } |
|
| 880 | + $actions['filtered_messages_link'] = ''; |
|
| 881 | + //message list table link (filtered by REG_ID |
|
| 882 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 883 | + $actions['filtered_messages_link'] = '<li>' |
|
| 884 | + . EEH_MSG_Template::get_message_action_link('see_notifications_for', |
|
| 885 | + null, array( |
|
| 886 | + '_REG_ID' => $item->ID(), |
|
| 887 | + )) |
|
| 888 | + . '</li>'; |
|
| 889 | + } |
|
| 890 | + $actions = apply_filters('FHEE__EE_Registrations_List_Table__column_actions__actions', $actions, $item, $this); |
|
| 891 | + return $this->_action_string(implode('', $actions), $item, 'ul', 'reg-overview-actions-ul'); |
|
| 892 | + } |
|
| 893 | 893 | |
| 894 | 894 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | ); |
| 158 | 158 | $this->_primary_column = '_REG_ID'; |
| 159 | 159 | $this->_sortable_columns = array( |
| 160 | - '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 160 | + '_REG_date' => array('_REG_date' => true), //true means its already sorted |
|
| 161 | 161 | /** |
| 162 | 162 | * Allows users to change the default sort if they wish. |
| 163 | 163 | * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | { |
| 190 | 190 | $class = parent::_get_row_class($item); |
| 191 | 191 | //add status class |
| 192 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
| 192 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
| 193 | 193 | if ($this->_has_checkbox_column) { |
| 194 | 194 | $class .= ' has-checkbox-column'; |
| 195 | 195 | } |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | //setup date query. |
| 338 | 338 | $beginning_string = EEM_Registration::instance() |
| 339 | 339 | ->convert_datetime_for_query('REG_date', |
| 340 | - $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, |
|
| 340 | + $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, |
|
| 341 | 341 | 'Y-m-d H:i:s'); |
| 342 | 342 | $end_string = EEM_Registration::instance() |
| 343 | 343 | ->convert_datetime_for_query('REG_date', |
| 344 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, |
|
| 344 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, |
|
| 345 | 345 | 'Y-m-d H:i:s'); |
| 346 | 346 | $_where['REG_date'] = array( |
| 347 | 347 | 'BETWEEN', |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | 'BETWEEN', |
| 375 | 375 | array( |
| 376 | 376 | EEM_Registration::instance() |
| 377 | - ->convert_datetime_for_query('REG_date', $current_date . $time_start, 'Y-m-d H:i:s'), |
|
| 377 | + ->convert_datetime_for_query('REG_date', $current_date.$time_start, 'Y-m-d H:i:s'), |
|
| 378 | 378 | EEM_Registration::instance() |
| 379 | - ->convert_datetime_for_query('REG_date', $current_date . $time_end, 'Y-m-d H:i:s'), |
|
| 379 | + ->convert_datetime_for_query('REG_date', $current_date.$time_end, 'Y-m-d H:i:s'), |
|
| 380 | 380 | ), |
| 381 | 381 | ); |
| 382 | 382 | $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
@@ -420,8 +420,8 @@ discard block |
||
| 420 | 420 | $content .= '<div class="show-on-mobile-view-only">'; |
| 421 | 421 | $content .= '<br>'; |
| 422 | 422 | $content .= $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
| 423 | - $content .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 424 | - $content .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 423 | + $content .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 424 | + $content .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 425 | 425 | $content .= '</div>'; |
| 426 | 426 | return $content; |
| 427 | 427 | } |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | . $event_name |
| 493 | 493 | . '</a>' : $event_name; |
| 494 | 494 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(array('event_id' => $EVT_ID), REG_ADMIN_URL); |
| 495 | - $actions['event_filter'] = '<a href="' . $edit_event_url . '" title="'; |
|
| 495 | + $actions['event_filter'] = '<a href="'.$edit_event_url.'" title="'; |
|
| 496 | 496 | $actions['event_filter'] .= sprintf(esc_attr__('Filter this list to only show registrations for %s', |
| 497 | 497 | 'event_espresso'), $event_name); |
| 498 | - $actions['event_filter'] .= '">' . __('View Registrations', 'event_espresso') . '</a>'; |
|
| 498 | + $actions['event_filter'] .= '">'.__('View Registrations', 'event_espresso').'</a>'; |
|
| 499 | 499 | } else { |
| 500 | 500 | $edit_event = $event_name; |
| 501 | 501 | $actions['event_filter'] = ''; |
@@ -561,12 +561,12 @@ discard block |
||
| 561 | 561 | $t = $item->get_first_related('Transaction'); |
| 562 | 562 | $payment_count = $t instanceof EE_Transaction ? $t->count_related('Payment') : 0; |
| 563 | 563 | //append group count to name |
| 564 | - $link .= ' ' . sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 564 | + $link .= ' '.sprintf(__('(%1$s / %2$s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
| 565 | 565 | //append reg_code |
| 566 | - $link .= '<br>' . sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 566 | + $link .= '<br>'.sprintf(__('Reg Code: %s', 'event_espresso'), $item->get('REG_code')); |
|
| 567 | 567 | //reg status text for accessibility |
| 568 | - $link .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status($item->status_ID(), false, |
|
| 569 | - 'sentence') . '</span>'; |
|
| 568 | + $link .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->status_ID(), false, |
|
| 569 | + 'sentence').'</span>'; |
|
| 570 | 570 | //trash/restore/delete actions |
| 571 | 571 | $actions = array(); |
| 572 | 572 | if ($this->_view !== 'trash' |
@@ -578,8 +578,8 @@ discard block |
||
| 578 | 578 | 'action' => 'trash_registrations', |
| 579 | 579 | '_REG_ID' => $item->ID(), |
| 580 | 580 | ), REG_ADMIN_URL); |
| 581 | - $actions['trash'] = '<a href="' . $trash_lnk_url . '" title="' . esc_attr__('Trash Registration', |
|
| 582 | - 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
| 581 | + $actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Trash Registration', |
|
| 582 | + 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
| 583 | 583 | } elseif ($this->_view === 'trash') { |
| 584 | 584 | // restore registration link |
| 585 | 585 | if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
@@ -589,8 +589,8 @@ discard block |
||
| 589 | 589 | 'action' => 'restore_registrations', |
| 590 | 590 | '_REG_ID' => $item->ID(), |
| 591 | 591 | ), REG_ADMIN_URL); |
| 592 | - $actions['restore'] = '<a href="' . $restore_lnk_url . '" title="' . esc_attr__('Restore Registration', |
|
| 593 | - 'event_espresso') . '">' . __('Restore', 'event_espresso') . '</a>'; |
|
| 592 | + $actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Registration', |
|
| 593 | + 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>'; |
|
| 594 | 594 | } |
| 595 | 595 | if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registration', |
| 596 | 596 | 'espresso_registrations_ee_delete_registrations', $item->ID()) |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | . $ticket->name() |
| 659 | 659 | . '</span><br />' : ''; |
| 660 | 660 | if ($item->final_price() > 0) { |
| 661 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 661 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
| 662 | 662 | } else { |
| 663 | 663 | // free event |
| 664 | 664 | $content .= '<span class="reg-overview-free-event-spn reg-pad-rght">' |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | : '<span class="TKT_name">' |
| 686 | 686 | . $ticket->name() |
| 687 | 687 | . '</span><br />'; |
| 688 | - $content .= '<span class="reg-pad-rght">' . $item->pretty_final_price() . '</span>'; |
|
| 688 | + $content .= '<span class="reg-pad-rght">'.$item->pretty_final_price().'</span>'; |
|
| 689 | 689 | return $content; |
| 690 | 690 | } |
| 691 | 691 | |
@@ -703,10 +703,10 @@ discard block |
||
| 703 | 703 | $payment_method = $item->payment_method(); |
| 704 | 704 | $payment_method_name = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() |
| 705 | 705 | : __('Unknown', 'event_espresso'); |
| 706 | - $content = '<span class="reg-pad-rght">' . $item->pretty_paid() . '</span>'; |
|
| 706 | + $content = '<span class="reg-pad-rght">'.$item->pretty_paid().'</span>'; |
|
| 707 | 707 | if ($item->paid() > 0) { |
| 708 | - $content .= '<br><span class="ee-status-text-small">' . sprintf(__('...via %s', 'event_espresso'), |
|
| 709 | - $payment_method_name) . '</span>'; |
|
| 708 | + $content .= '<br><span class="ee-status-text-small">'.sprintf(__('...via %s', 'event_espresso'), |
|
| 709 | + $payment_method_name).'</span>'; |
|
| 710 | 710 | } |
| 711 | 711 | return $content; |
| 712 | 712 | } |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | . esc_attr__('View Transaction', 'event_espresso') |
| 739 | 739 | . '">' |
| 740 | 740 | . $item->transaction()->pretty_total() |
| 741 | - . '</a></span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_total() . '</span>'; |
|
| 741 | + . '</a></span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_total().'</span>'; |
|
| 742 | 742 | } else { |
| 743 | 743 | return __("None", "event_espresso"); |
| 744 | 744 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | . esc_attr__('View Transaction', 'event_espresso') |
| 776 | 776 | . '">' |
| 777 | 777 | . $item->transaction()->pretty_paid() |
| 778 | - . '</a><span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
| 778 | + . '</a><span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | return ' '; |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | $actions['view_lnk'] = EE_Registry::instance()->CAP->current_user_can('ee_read_registration', |
| 816 | 816 | 'espresso_registrations_view_registration', $item->ID()) ? ' |
| 817 | 817 | <li> |
| 818 | - <a href="' . $view_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
|
| 818 | + <a href="' . $view_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
| 819 | 819 | <div class="dashicons dashicons-clipboard"></div> |
| 820 | 820 | </a> |
| 821 | 821 | </li>' : ''; |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | 'espresso_registrations_edit_attendee') |
| 824 | 824 | && $attendee instanceof EE_Attendee ? ' |
| 825 | 825 | <li> |
| 826 | - <a href="' . $edit_lnk_url . '" title="' . esc_attr__('Edit Contact Details', 'event_espresso') . '" class="tiny-text"> |
|
| 826 | + <a href="' . $edit_lnk_url.'" title="'.esc_attr__('Edit Contact Details', 'event_espresso').'" class="tiny-text"> |
|
| 827 | 827 | <div class="ee-icon ee-icon-user-edit ee-icon-size-16"></div> |
| 828 | 828 | </a> |
| 829 | 829 | </li>' : ''; |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @param string $name |
| 492 | 492 | * @param string $config_class |
| 493 | 493 | * @param EE_Config_Base $config_obj |
| 494 | - * @param array $tests_to_run |
|
| 494 | + * @param integer[] $tests_to_run |
|
| 495 | 495 | * @param bool $display_errors |
| 496 | 496 | * @return bool TRUE on success, FALSE on fail |
| 497 | 497 | */ |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | |
| 1795 | 1795 | |
| 1796 | 1796 | /** |
| 1797 | - * @return array |
|
| 1797 | + * @return integer[] |
|
| 1798 | 1798 | */ |
| 1799 | 1799 | public function get_critical_pages_array() |
| 1800 | 1800 | { |
@@ -1808,7 +1808,7 @@ discard block |
||
| 1808 | 1808 | |
| 1809 | 1809 | |
| 1810 | 1810 | /** |
| 1811 | - * @return array |
|
| 1811 | + * @return string[] |
|
| 1812 | 1812 | */ |
| 1813 | 1813 | public function get_critical_pages_shortcodes_array() |
| 1814 | 1814 | { |
@@ -3088,7 +3088,7 @@ discard block |
||
| 3088 | 3088 | * according to max_input_vars |
| 3089 | 3089 | * |
| 3090 | 3090 | * @param int $input_count the count of input vars. |
| 3091 | - * @return array { |
|
| 3091 | + * @return string { |
|
| 3092 | 3092 | * An array that represents whether available space and if no available space the error |
| 3093 | 3093 | * message. |
| 3094 | 3094 | * @type bool $has_space whether more inputs can be added. |
@@ -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 | |
@@ -14,2504 +14,2504 @@ discard block |
||
| 14 | 14 | final class EE_Config |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - const OPTION_NAME = 'ee_config'; |
|
| 17 | + const OPTION_NAME = 'ee_config'; |
|
| 18 | + |
|
| 19 | + const LOG_NAME = 'ee_config_log'; |
|
| 20 | + |
|
| 21 | + const LOG_LENGTH = 100; |
|
| 22 | + |
|
| 23 | + const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * instance of the EE_Config object |
|
| 28 | + * |
|
| 29 | + * @var EE_Config $_instance |
|
| 30 | + * @access private |
|
| 31 | + */ |
|
| 32 | + private static $_instance; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var boolean $_logging_enabled |
|
| 36 | + */ |
|
| 37 | + private static $_logging_enabled = false; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * An StdClass whose property names are addon slugs, |
|
| 41 | + * and values are their config classes |
|
| 42 | + * |
|
| 43 | + * @var StdClass |
|
| 44 | + */ |
|
| 45 | + public $addons; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var EE_Admin_Config |
|
| 49 | + */ |
|
| 50 | + public $admin; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @var EE_Core_Config |
|
| 54 | + */ |
|
| 55 | + public $core; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @var EE_Currency_Config |
|
| 59 | + */ |
|
| 60 | + public $currency; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @var EE_Organization_Config |
|
| 64 | + */ |
|
| 65 | + public $organization; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @var EE_Registration_Config |
|
| 69 | + */ |
|
| 70 | + public $registration; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @var EE_Template_Config |
|
| 74 | + */ |
|
| 75 | + public $template_settings; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Holds EE environment values. |
|
| 79 | + * |
|
| 80 | + * @var EE_Environment_Config |
|
| 81 | + */ |
|
| 82 | + public $environment; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * settings pertaining to Google maps |
|
| 86 | + * |
|
| 87 | + * @var EE_Map_Config |
|
| 88 | + */ |
|
| 89 | + public $map_settings; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * settings pertaining to Taxes |
|
| 93 | + * |
|
| 94 | + * @var EE_Tax_Config |
|
| 95 | + */ |
|
| 96 | + public $tax_settings; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @deprecated |
|
| 100 | + * @var EE_Gateway_Config |
|
| 101 | + */ |
|
| 102 | + public $gateway; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @var array $_addon_option_names |
|
| 106 | + * @access private |
|
| 107 | + */ |
|
| 108 | + private $_addon_option_names = array(); |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @var array $_module_route_map |
|
| 112 | + * @access private |
|
| 113 | + */ |
|
| 114 | + private static $_module_route_map = array(); |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @var array $_module_forward_map |
|
| 118 | + * @access private |
|
| 119 | + */ |
|
| 120 | + private static $_module_forward_map = array(); |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @var array $_module_view_map |
|
| 124 | + * @access private |
|
| 125 | + */ |
|
| 126 | + private static $_module_view_map = array(); |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @singleton method used to instantiate class object |
|
| 132 | + * @access public |
|
| 133 | + * @return EE_Config instance |
|
| 134 | + */ |
|
| 135 | + public static function instance() |
|
| 136 | + { |
|
| 137 | + // check if class object is instantiated, and instantiated properly |
|
| 138 | + if ( ! self::$_instance instanceof EE_Config) { |
|
| 139 | + self::$_instance = new self(); |
|
| 140 | + } |
|
| 141 | + return self::$_instance; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Resets the config |
|
| 148 | + * |
|
| 149 | + * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 150 | + * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 151 | + * reflect its state in the database |
|
| 152 | + * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 153 | + * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 154 | + * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 155 | + * site was put into maintenance mode) |
|
| 156 | + * @return EE_Config |
|
| 157 | + */ |
|
| 158 | + public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 159 | + { |
|
| 160 | + if (self::$_instance instanceof EE_Config) { |
|
| 161 | + if ($hard_reset) { |
|
| 162 | + self::$_instance->_addon_option_names = array(); |
|
| 163 | + self::$_instance->_initialize_config(); |
|
| 164 | + self::$_instance->update_espresso_config(); |
|
| 165 | + } |
|
| 166 | + self::$_instance->update_addon_option_names(); |
|
| 167 | + } |
|
| 168 | + self::$_instance = null; |
|
| 169 | + //we don't need to reset the static properties imo because those should |
|
| 170 | + //only change when a module is added or removed. Currently we don't |
|
| 171 | + //support removing a module during a request when it previously existed |
|
| 172 | + if ($reinstantiate) { |
|
| 173 | + return self::instance(); |
|
| 174 | + } else { |
|
| 175 | + return null; |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * class constructor |
|
| 183 | + * |
|
| 184 | + * @access private |
|
| 185 | + */ |
|
| 186 | + private function __construct() |
|
| 187 | + { |
|
| 188 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 189 | + EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 190 | + // setup empty config classes |
|
| 191 | + $this->_initialize_config(); |
|
| 192 | + // load existing EE site settings |
|
| 193 | + $this->_load_core_config(); |
|
| 194 | + // confirm everything loaded correctly and set filtered defaults if not |
|
| 195 | + $this->_verify_config(); |
|
| 196 | + // register shortcodes and modules |
|
| 197 | + add_action( |
|
| 198 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 199 | + array($this, 'register_shortcodes_and_modules'), |
|
| 200 | + 999 |
|
| 201 | + ); |
|
| 202 | + // initialize shortcodes and modules |
|
| 203 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 204 | + // register widgets |
|
| 205 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 206 | + // shutdown |
|
| 207 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 208 | + // construct__end hook |
|
| 209 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
| 210 | + // hardcoded hack |
|
| 211 | + $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * @return boolean |
|
| 218 | + */ |
|
| 219 | + public static function logging_enabled() |
|
| 220 | + { |
|
| 221 | + return self::$_logging_enabled; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * use to get the current theme if needed from static context |
|
| 228 | + * |
|
| 229 | + * @return string current theme set. |
|
| 230 | + */ |
|
| 231 | + public static function get_current_theme() |
|
| 232 | + { |
|
| 233 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 234 | + ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * _initialize_config |
|
| 241 | + * |
|
| 242 | + * @access private |
|
| 243 | + * @return void |
|
| 244 | + */ |
|
| 245 | + private function _initialize_config() |
|
| 246 | + { |
|
| 247 | + EE_Config::trim_log(); |
|
| 248 | + //set defaults |
|
| 249 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 250 | + $this->addons = new stdClass(); |
|
| 251 | + // set _module_route_map |
|
| 252 | + EE_Config::$_module_route_map = array(); |
|
| 253 | + // set _module_forward_map |
|
| 254 | + EE_Config::$_module_forward_map = array(); |
|
| 255 | + // set _module_view_map |
|
| 256 | + EE_Config::$_module_view_map = array(); |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * load core plugin configuration |
|
| 263 | + * |
|
| 264 | + * @access private |
|
| 265 | + * @return void |
|
| 266 | + */ |
|
| 267 | + private function _load_core_config() |
|
| 268 | + { |
|
| 269 | + // load_core_config__start hook |
|
| 270 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 271 | + $espresso_config = $this->get_espresso_config(); |
|
| 272 | + foreach ($espresso_config as $config => $settings) { |
|
| 273 | + // load_core_config__start hook |
|
| 274 | + $settings = apply_filters( |
|
| 275 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 276 | + $settings, |
|
| 277 | + $config, |
|
| 278 | + $this |
|
| 279 | + ); |
|
| 280 | + if (is_object($settings) && property_exists($this, $config)) { |
|
| 281 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 282 | + //call configs populate method to ensure any defaults are set for empty values. |
|
| 283 | + if (method_exists($settings, 'populate')) { |
|
| 284 | + $this->{$config}->populate(); |
|
| 285 | + } |
|
| 286 | + if (method_exists($settings, 'do_hooks')) { |
|
| 287 | + $this->{$config}->do_hooks(); |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 292 | + $this->update_espresso_config(); |
|
| 293 | + } |
|
| 294 | + // load_core_config__end hook |
|
| 295 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * _verify_config |
|
| 302 | + * |
|
| 303 | + * @access protected |
|
| 304 | + * @return void |
|
| 305 | + */ |
|
| 306 | + protected function _verify_config() |
|
| 307 | + { |
|
| 308 | + $this->core = $this->core instanceof EE_Core_Config |
|
| 309 | + ? $this->core |
|
| 310 | + : new EE_Core_Config(); |
|
| 311 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 312 | + $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 313 | + ? $this->organization |
|
| 314 | + : new EE_Organization_Config(); |
|
| 315 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', |
|
| 316 | + $this->organization); |
|
| 317 | + $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 318 | + ? $this->currency |
|
| 319 | + : new EE_Currency_Config(); |
|
| 320 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 321 | + $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 322 | + ? $this->registration |
|
| 323 | + : new EE_Registration_Config(); |
|
| 324 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', |
|
| 325 | + $this->registration); |
|
| 326 | + $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 327 | + ? $this->admin |
|
| 328 | + : new EE_Admin_Config(); |
|
| 329 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 330 | + $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 331 | + ? $this->template_settings |
|
| 332 | + : new EE_Template_Config(); |
|
| 333 | + $this->template_settings = apply_filters( |
|
| 334 | + 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 335 | + $this->template_settings |
|
| 336 | + ); |
|
| 337 | + $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 338 | + ? $this->map_settings |
|
| 339 | + : new EE_Map_Config(); |
|
| 340 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 341 | + $this->map_settings); |
|
| 342 | + $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 343 | + ? $this->environment |
|
| 344 | + : new EE_Environment_Config(); |
|
| 345 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 346 | + $this->environment); |
|
| 347 | + $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 348 | + ? $this->tax_settings |
|
| 349 | + : new EE_Tax_Config(); |
|
| 350 | + $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 351 | + $this->tax_settings); |
|
| 352 | + $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 353 | + ? $this->gateway |
|
| 354 | + : new EE_Gateway_Config(); |
|
| 355 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * get_espresso_config |
|
| 362 | + * |
|
| 363 | + * @access public |
|
| 364 | + * @return array of espresso config stuff |
|
| 365 | + */ |
|
| 366 | + public function get_espresso_config() |
|
| 367 | + { |
|
| 368 | + // grab espresso configuration |
|
| 369 | + return apply_filters( |
|
| 370 | + 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 371 | + get_option(EE_Config::OPTION_NAME, array()) |
|
| 372 | + ); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * double_check_config_comparison |
|
| 379 | + * |
|
| 380 | + * @access public |
|
| 381 | + * @param string $option |
|
| 382 | + * @param $old_value |
|
| 383 | + * @param $value |
|
| 384 | + */ |
|
| 385 | + public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 386 | + { |
|
| 387 | + // make sure we're checking the ee config |
|
| 388 | + if ($option === EE_Config::OPTION_NAME) { |
|
| 389 | + // run a loose comparison of the old value against the new value for type and properties, |
|
| 390 | + // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 391 | + if ($value != $old_value) { |
|
| 392 | + // if they are NOT the same, then remove the hook, |
|
| 393 | + // which means the subsequent update results will be based solely on the update query results |
|
| 394 | + // the reason we do this is because, as stated above, |
|
| 395 | + // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 396 | + // this happens PRIOR to serialization and any subsequent update. |
|
| 397 | + // If values are found to match their previous old value, |
|
| 398 | + // then WP bails before performing any update. |
|
| 399 | + // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 400 | + // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 401 | + // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 402 | + // MySQL MAY ALSO NOT perform the update because |
|
| 403 | + // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 404 | + // This results in the query returning an "affected rows" value of ZERO, |
|
| 405 | + // which gets returned immediately by WP update_option and looks like an error. |
|
| 406 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * update_espresso_config |
|
| 415 | + * |
|
| 416 | + * @access public |
|
| 417 | + */ |
|
| 418 | + protected function _reset_espresso_addon_config() |
|
| 419 | + { |
|
| 420 | + $this->_addon_option_names = array(); |
|
| 421 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 422 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 423 | + $config_class = get_class($addon_config_obj); |
|
| 424 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
| 425 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 426 | + } |
|
| 427 | + $this->addons->{$addon_name} = null; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * update_espresso_config |
|
| 435 | + * |
|
| 436 | + * @access public |
|
| 437 | + * @param bool $add_success |
|
| 438 | + * @param bool $add_error |
|
| 439 | + * @return bool |
|
| 440 | + */ |
|
| 441 | + public function update_espresso_config($add_success = false, $add_error = true) |
|
| 442 | + { |
|
| 443 | + // don't allow config updates during WP heartbeats |
|
| 444 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 445 | + return false; |
|
| 446 | + } |
|
| 447 | + // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 448 | + //$clone = clone( self::$_instance ); |
|
| 449 | + //self::$_instance = NULL; |
|
| 450 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 451 | + $this->_reset_espresso_addon_config(); |
|
| 452 | + // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 453 | + // but BEFORE the actual update occurs |
|
| 454 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 455 | + // now update "ee_config" |
|
| 456 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 457 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
| 458 | + // if not saved... check if the hook we just added still exists; |
|
| 459 | + // if it does, it means one of two things: |
|
| 460 | + // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 461 | + // or... |
|
| 462 | + // the db update query returned 0 rows affected |
|
| 463 | + // (probably because the data value was the same from it's perspective) |
|
| 464 | + // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 465 | + // but just means no update occurred, so don't display an error to the user. |
|
| 466 | + // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 467 | + // then it means that something truly went wrong |
|
| 468 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 469 | + // remove our action since we don't want it in the system anymore |
|
| 470 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 471 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 472 | + //self::$_instance = $clone; |
|
| 473 | + //unset( $clone ); |
|
| 474 | + // if config remains the same or was updated successfully |
|
| 475 | + if ($saved) { |
|
| 476 | + if ($add_success) { |
|
| 477 | + EE_Error::add_success( |
|
| 478 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 479 | + __FILE__, |
|
| 480 | + __FUNCTION__, |
|
| 481 | + __LINE__ |
|
| 482 | + ); |
|
| 483 | + } |
|
| 484 | + return true; |
|
| 485 | + } else { |
|
| 486 | + if ($add_error) { |
|
| 487 | + EE_Error::add_error( |
|
| 488 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 489 | + __FILE__, |
|
| 490 | + __FUNCTION__, |
|
| 491 | + __LINE__ |
|
| 492 | + ); |
|
| 493 | + } |
|
| 494 | + return false; |
|
| 495 | + } |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * _verify_config_params |
|
| 502 | + * |
|
| 503 | + * @access private |
|
| 504 | + * @param string $section |
|
| 505 | + * @param string $name |
|
| 506 | + * @param string $config_class |
|
| 507 | + * @param EE_Config_Base $config_obj |
|
| 508 | + * @param array $tests_to_run |
|
| 509 | + * @param bool $display_errors |
|
| 510 | + * @return bool TRUE on success, FALSE on fail |
|
| 511 | + */ |
|
| 512 | + private function _verify_config_params( |
|
| 513 | + $section = '', |
|
| 514 | + $name = '', |
|
| 515 | + $config_class = '', |
|
| 516 | + $config_obj = null, |
|
| 517 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 518 | + $display_errors = true |
|
| 519 | + ) { |
|
| 520 | + try { |
|
| 521 | + foreach ($tests_to_run as $test) { |
|
| 522 | + switch ($test) { |
|
| 523 | + // TEST #1 : check that section was set |
|
| 524 | + case 1 : |
|
| 525 | + if (empty($section)) { |
|
| 526 | + if ($display_errors) { |
|
| 527 | + throw new EE_Error( |
|
| 528 | + sprintf( |
|
| 529 | + __( |
|
| 530 | + 'No configuration section has been provided while attempting to save "%s".', |
|
| 531 | + 'event_espresso' |
|
| 532 | + ), |
|
| 533 | + $config_class |
|
| 534 | + ) |
|
| 535 | + ); |
|
| 536 | + } |
|
| 537 | + return false; |
|
| 538 | + } |
|
| 539 | + break; |
|
| 540 | + // TEST #2 : check that settings section exists |
|
| 541 | + case 2 : |
|
| 542 | + if ( ! isset($this->{$section})) { |
|
| 543 | + if ($display_errors) { |
|
| 544 | + throw new EE_Error( |
|
| 545 | + sprintf( |
|
| 546 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 547 | + $section |
|
| 548 | + ) |
|
| 549 | + ); |
|
| 550 | + } |
|
| 551 | + return false; |
|
| 552 | + } |
|
| 553 | + break; |
|
| 554 | + // TEST #3 : check that section is the proper format |
|
| 555 | + case 3 : |
|
| 556 | + if ( |
|
| 557 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 558 | + ) { |
|
| 559 | + if ($display_errors) { |
|
| 560 | + throw new EE_Error( |
|
| 561 | + sprintf( |
|
| 562 | + __( |
|
| 563 | + 'The "%s" configuration settings have not been formatted correctly.', |
|
| 564 | + 'event_espresso' |
|
| 565 | + ), |
|
| 566 | + $section |
|
| 567 | + ) |
|
| 568 | + ); |
|
| 569 | + } |
|
| 570 | + return false; |
|
| 571 | + } |
|
| 572 | + break; |
|
| 573 | + // TEST #4 : check that config section name has been set |
|
| 574 | + case 4 : |
|
| 575 | + if (empty($name)) { |
|
| 576 | + if ($display_errors) { |
|
| 577 | + throw new EE_Error( |
|
| 578 | + __( |
|
| 579 | + 'No name has been provided for the specific configuration section.', |
|
| 580 | + 'event_espresso' |
|
| 581 | + ) |
|
| 582 | + ); |
|
| 583 | + } |
|
| 584 | + return false; |
|
| 585 | + } |
|
| 586 | + break; |
|
| 587 | + // TEST #5 : check that a config class name has been set |
|
| 588 | + case 5 : |
|
| 589 | + if (empty($config_class)) { |
|
| 590 | + if ($display_errors) { |
|
| 591 | + throw new EE_Error( |
|
| 592 | + __( |
|
| 593 | + 'No class name has been provided for the specific configuration section.', |
|
| 594 | + 'event_espresso' |
|
| 595 | + ) |
|
| 596 | + ); |
|
| 597 | + } |
|
| 598 | + return false; |
|
| 599 | + } |
|
| 600 | + break; |
|
| 601 | + // TEST #6 : verify config class is accessible |
|
| 602 | + case 6 : |
|
| 603 | + if ( ! class_exists($config_class)) { |
|
| 604 | + if ($display_errors) { |
|
| 605 | + throw new EE_Error( |
|
| 606 | + sprintf( |
|
| 607 | + __( |
|
| 608 | + 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 609 | + 'event_espresso' |
|
| 610 | + ), |
|
| 611 | + $config_class |
|
| 612 | + ) |
|
| 613 | + ); |
|
| 614 | + } |
|
| 615 | + return false; |
|
| 616 | + } |
|
| 617 | + break; |
|
| 618 | + // TEST #7 : check that config has even been set |
|
| 619 | + case 7 : |
|
| 620 | + if ( ! isset($this->{$section}->{$name})) { |
|
| 621 | + if ($display_errors) { |
|
| 622 | + throw new EE_Error( |
|
| 623 | + sprintf( |
|
| 624 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 625 | + $section, |
|
| 626 | + $name |
|
| 627 | + ) |
|
| 628 | + ); |
|
| 629 | + } |
|
| 630 | + return false; |
|
| 631 | + } else { |
|
| 632 | + // and make sure it's not serialized |
|
| 633 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 634 | + } |
|
| 635 | + break; |
|
| 636 | + // TEST #8 : check that config is the requested type |
|
| 637 | + case 8 : |
|
| 638 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
| 639 | + if ($display_errors) { |
|
| 640 | + throw new EE_Error( |
|
| 641 | + sprintf( |
|
| 642 | + __( |
|
| 643 | + 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 644 | + 'event_espresso' |
|
| 645 | + ), |
|
| 646 | + $section, |
|
| 647 | + $name, |
|
| 648 | + $config_class |
|
| 649 | + ) |
|
| 650 | + ); |
|
| 651 | + } |
|
| 652 | + return false; |
|
| 653 | + } |
|
| 654 | + break; |
|
| 655 | + // TEST #9 : verify config object |
|
| 656 | + case 9 : |
|
| 657 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
| 658 | + if ($display_errors) { |
|
| 659 | + throw new EE_Error( |
|
| 660 | + sprintf( |
|
| 661 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 662 | + print_r($config_obj, true) |
|
| 663 | + ) |
|
| 664 | + ); |
|
| 665 | + } |
|
| 666 | + return false; |
|
| 667 | + } |
|
| 668 | + break; |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + } catch (EE_Error $e) { |
|
| 672 | + $e->get_error(); |
|
| 673 | + } |
|
| 674 | + // you have successfully run the gauntlet |
|
| 675 | + return true; |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * _generate_config_option_name |
|
| 682 | + * |
|
| 683 | + * @access protected |
|
| 684 | + * @param string $section |
|
| 685 | + * @param string $name |
|
| 686 | + * @return string |
|
| 687 | + */ |
|
| 688 | + private function _generate_config_option_name($section = '', $name = '') |
|
| 689 | + { |
|
| 690 | + return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * _set_config_class |
|
| 697 | + * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 698 | + * |
|
| 699 | + * @access private |
|
| 700 | + * @param string $config_class |
|
| 701 | + * @param string $name |
|
| 702 | + * @return string |
|
| 703 | + */ |
|
| 704 | + private function _set_config_class($config_class = '', $name = '') |
|
| 705 | + { |
|
| 706 | + return ! empty($config_class) |
|
| 707 | + ? $config_class |
|
| 708 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + |
|
| 712 | + |
|
| 713 | + /** |
|
| 714 | + * set_config |
|
| 715 | + * |
|
| 716 | + * @access protected |
|
| 717 | + * @param string $section |
|
| 718 | + * @param string $name |
|
| 719 | + * @param string $config_class |
|
| 720 | + * @param EE_Config_Base $config_obj |
|
| 721 | + * @return EE_Config_Base |
|
| 722 | + */ |
|
| 723 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 724 | + { |
|
| 725 | + // ensure config class is set to something |
|
| 726 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 727 | + // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 728 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 729 | + return null; |
|
| 730 | + } |
|
| 731 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 732 | + // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 733 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 734 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 735 | + $this->update_addon_option_names(); |
|
| 736 | + } |
|
| 737 | + // verify the incoming config object but suppress errors |
|
| 738 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 739 | + $config_obj = new $config_class(); |
|
| 740 | + } |
|
| 741 | + if (get_option($config_option_name)) { |
|
| 742 | + EE_Config::log($config_option_name); |
|
| 743 | + update_option($config_option_name, $config_obj); |
|
| 744 | + $this->{$section}->{$name} = $config_obj; |
|
| 745 | + return $this->{$section}->{$name}; |
|
| 746 | + } else { |
|
| 747 | + // create a wp-option for this config |
|
| 748 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 749 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 750 | + return $this->{$section}->{$name}; |
|
| 751 | + } else { |
|
| 752 | + EE_Error::add_error( |
|
| 753 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 754 | + __FILE__, |
|
| 755 | + __FUNCTION__, |
|
| 756 | + __LINE__ |
|
| 757 | + ); |
|
| 758 | + return null; |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * update_config |
|
| 767 | + * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 768 | + * |
|
| 769 | + * @access public |
|
| 770 | + * @param string $section |
|
| 771 | + * @param string $name |
|
| 772 | + * @param EE_Config_Base|string $config_obj |
|
| 773 | + * @param bool $throw_errors |
|
| 774 | + * @return bool |
|
| 775 | + */ |
|
| 776 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 777 | + { |
|
| 778 | + // don't allow config updates during WP heartbeats |
|
| 779 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 780 | + return false; |
|
| 781 | + } |
|
| 782 | + $config_obj = maybe_unserialize($config_obj); |
|
| 783 | + // get class name of the incoming object |
|
| 784 | + $config_class = get_class($config_obj); |
|
| 785 | + // run tests 1-5 and 9 to verify config |
|
| 786 | + if ( ! $this->_verify_config_params( |
|
| 787 | + $section, |
|
| 788 | + $name, |
|
| 789 | + $config_class, |
|
| 790 | + $config_obj, |
|
| 791 | + array(1, 2, 3, 4, 7, 9) |
|
| 792 | + ) |
|
| 793 | + ) { |
|
| 794 | + return false; |
|
| 795 | + } |
|
| 796 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 797 | + // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 798 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 799 | + // save new config to db |
|
| 800 | + if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 801 | + return true; |
|
| 802 | + } |
|
| 803 | + } else { |
|
| 804 | + // first check if the record already exists |
|
| 805 | + $existing_config = get_option($config_option_name); |
|
| 806 | + $config_obj = serialize($config_obj); |
|
| 807 | + // just return if db record is already up to date (NOT type safe comparison) |
|
| 808 | + if ($existing_config == $config_obj) { |
|
| 809 | + $this->{$section}->{$name} = $config_obj; |
|
| 810 | + return true; |
|
| 811 | + } else if (update_option($config_option_name, $config_obj)) { |
|
| 812 | + EE_Config::log($config_option_name); |
|
| 813 | + // update wp-option for this config class |
|
| 814 | + $this->{$section}->{$name} = $config_obj; |
|
| 815 | + return true; |
|
| 816 | + } elseif ($throw_errors) { |
|
| 817 | + EE_Error::add_error( |
|
| 818 | + sprintf( |
|
| 819 | + __( |
|
| 820 | + 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 821 | + 'event_espresso' |
|
| 822 | + ), |
|
| 823 | + $config_class, |
|
| 824 | + 'EE_Config->' . $section . '->' . $name |
|
| 825 | + ), |
|
| 826 | + __FILE__, |
|
| 827 | + __FUNCTION__, |
|
| 828 | + __LINE__ |
|
| 829 | + ); |
|
| 830 | + } |
|
| 831 | + } |
|
| 832 | + return false; |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + |
|
| 836 | + |
|
| 837 | + /** |
|
| 838 | + * get_config |
|
| 839 | + * |
|
| 840 | + * @access public |
|
| 841 | + * @param string $section |
|
| 842 | + * @param string $name |
|
| 843 | + * @param string $config_class |
|
| 844 | + * @return mixed EE_Config_Base | NULL |
|
| 845 | + */ |
|
| 846 | + public function get_config($section = '', $name = '', $config_class = '') |
|
| 847 | + { |
|
| 848 | + // ensure config class is set to something |
|
| 849 | + $config_class = $this->_set_config_class($config_class, $name); |
|
| 850 | + // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 851 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 852 | + return null; |
|
| 853 | + } |
|
| 854 | + // now test if the requested config object exists, but suppress errors |
|
| 855 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 856 | + // config already exists, so pass it back |
|
| 857 | + return $this->{$section}->{$name}; |
|
| 858 | + } |
|
| 859 | + // load config option from db if it exists |
|
| 860 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 861 | + // verify the newly retrieved config object, but suppress errors |
|
| 862 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 863 | + // config is good, so set it and pass it back |
|
| 864 | + $this->{$section}->{$name} = $config_obj; |
|
| 865 | + return $this->{$section}->{$name}; |
|
| 866 | + } |
|
| 867 | + // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 868 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
| 869 | + // verify the newly created config object |
|
| 870 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 871 | + return $this->{$section}->{$name}; |
|
| 872 | + } else { |
|
| 873 | + EE_Error::add_error( |
|
| 874 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 875 | + __FILE__, |
|
| 876 | + __FUNCTION__, |
|
| 877 | + __LINE__ |
|
| 878 | + ); |
|
| 879 | + } |
|
| 880 | + return null; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + |
|
| 884 | + |
|
| 885 | + /** |
|
| 886 | + * get_config_option |
|
| 887 | + * |
|
| 888 | + * @access public |
|
| 889 | + * @param string $config_option_name |
|
| 890 | + * @return mixed EE_Config_Base | FALSE |
|
| 891 | + */ |
|
| 892 | + public function get_config_option($config_option_name = '') |
|
| 893 | + { |
|
| 894 | + // retrieve the wp-option for this config class. |
|
| 895 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 896 | + if (empty($config_option)) { |
|
| 897 | + EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 898 | + } |
|
| 899 | + return $config_option; |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + |
|
| 903 | + |
|
| 904 | + /** |
|
| 905 | + * log |
|
| 906 | + * |
|
| 907 | + * @param string $config_option_name |
|
| 908 | + */ |
|
| 909 | + public static function log($config_option_name = '') |
|
| 910 | + { |
|
| 911 | + if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 912 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 913 | + //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 914 | + $_request = $_REQUEST; |
|
| 915 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 916 | + $config_log[(string)microtime(true)] = array( |
|
| 917 | + 'config_name' => $config_option_name, |
|
| 918 | + 'request' => $_request, |
|
| 919 | + ); |
|
| 920 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 921 | + } |
|
| 922 | + } |
|
| 923 | + |
|
| 924 | + |
|
| 925 | + |
|
| 926 | + /** |
|
| 927 | + * trim_log |
|
| 928 | + * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 929 | + */ |
|
| 930 | + public static function trim_log() |
|
| 931 | + { |
|
| 932 | + if ( ! EE_Config::logging_enabled()) { |
|
| 933 | + return; |
|
| 934 | + } |
|
| 935 | + $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 936 | + $log_length = count($config_log); |
|
| 937 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 938 | + ksort($config_log); |
|
| 939 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 940 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
| 941 | + } |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + |
|
| 945 | + |
|
| 946 | + /** |
|
| 947 | + * get_page_for_posts |
|
| 948 | + * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 949 | + * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 950 | + * |
|
| 951 | + * @access public |
|
| 952 | + * @return string |
|
| 953 | + */ |
|
| 954 | + public static function get_page_for_posts() |
|
| 955 | + { |
|
| 956 | + $page_for_posts = get_option('page_for_posts'); |
|
| 957 | + if ( ! $page_for_posts) { |
|
| 958 | + return 'posts'; |
|
| 959 | + } |
|
| 960 | + /** @type WPDB $wpdb */ |
|
| 961 | + global $wpdb; |
|
| 962 | + $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 963 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + |
|
| 967 | + |
|
| 968 | + /** |
|
| 969 | + * register_shortcodes_and_modules. |
|
| 970 | + * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 971 | + * In fact, this is where we give modules a chance to let core know they exist |
|
| 972 | + * so they can help trigger maintenance mode if it's needed |
|
| 973 | + * |
|
| 974 | + * @access public |
|
| 975 | + * @return void |
|
| 976 | + */ |
|
| 977 | + public function register_shortcodes_and_modules() |
|
| 978 | + { |
|
| 979 | + // allow shortcodes to register with WP and to set hooks for the rest of the system |
|
| 980 | + EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
| 981 | + // allow modules to set hooks for the rest of the system |
|
| 982 | + EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + |
|
| 986 | + |
|
| 987 | + /** |
|
| 988 | + * initialize_shortcodes_and_modules |
|
| 989 | + * meaning they can start adding their hooks to get stuff done |
|
| 990 | + * |
|
| 991 | + * @access public |
|
| 992 | + * @return void |
|
| 993 | + */ |
|
| 994 | + public function initialize_shortcodes_and_modules() |
|
| 995 | + { |
|
| 996 | + // allow shortcodes to set hooks for the rest of the system |
|
| 997 | + $this->_initialize_shortcodes(); |
|
| 998 | + // allow modules to set hooks for the rest of the system |
|
| 999 | + $this->_initialize_modules(); |
|
| 1000 | + } |
|
| 1001 | + |
|
| 1002 | + |
|
| 1003 | + |
|
| 1004 | + /** |
|
| 1005 | + * widgets_init |
|
| 1006 | + * |
|
| 1007 | + * @access private |
|
| 1008 | + * @return void |
|
| 1009 | + */ |
|
| 1010 | + public function widgets_init() |
|
| 1011 | + { |
|
| 1012 | + //only init widgets on admin pages when not in complete maintenance, and |
|
| 1013 | + //on frontend when not in any maintenance mode |
|
| 1014 | + if ( |
|
| 1015 | + ! EE_Maintenance_Mode::instance()->level() |
|
| 1016 | + || ( |
|
| 1017 | + is_admin() |
|
| 1018 | + && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1019 | + ) |
|
| 1020 | + ) { |
|
| 1021 | + // grab list of installed widgets |
|
| 1022 | + $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1023 | + // filter list of modules to register |
|
| 1024 | + $widgets_to_register = apply_filters( |
|
| 1025 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1026 | + $widgets_to_register |
|
| 1027 | + ); |
|
| 1028 | + if ( ! empty($widgets_to_register)) { |
|
| 1029 | + // cycle thru widget folders |
|
| 1030 | + foreach ($widgets_to_register as $widget_path) { |
|
| 1031 | + // add to list of installed widget modules |
|
| 1032 | + EE_Config::register_ee_widget($widget_path); |
|
| 1033 | + } |
|
| 1034 | + } |
|
| 1035 | + // filter list of installed modules |
|
| 1036 | + EE_Registry::instance()->widgets = apply_filters( |
|
| 1037 | + 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1038 | + EE_Registry::instance()->widgets |
|
| 1039 | + ); |
|
| 1040 | + } |
|
| 1041 | + } |
|
| 1042 | + |
|
| 1043 | + |
|
| 1044 | + |
|
| 1045 | + /** |
|
| 1046 | + * register_ee_widget - makes core aware of this widget |
|
| 1047 | + * |
|
| 1048 | + * @access public |
|
| 1049 | + * @param string $widget_path - full path up to and including widget folder |
|
| 1050 | + * @return void |
|
| 1051 | + */ |
|
| 1052 | + public static function register_ee_widget($widget_path = null) |
|
| 1053 | + { |
|
| 1054 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1055 | + $widget_ext = '.widget.php'; |
|
| 1056 | + // make all separators match |
|
| 1057 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1058 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1059 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1060 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1061 | + $file_name = explode('.', basename($widget_path)); |
|
| 1062 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 1063 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1064 | + // sanitize shortcode directory name |
|
| 1065 | + $widget = sanitize_key($widget); |
|
| 1066 | + // now we need to rebuild the shortcode path |
|
| 1067 | + $widget_path = explode(DS, $widget_path); |
|
| 1068 | + // remove last segment |
|
| 1069 | + array_pop($widget_path); |
|
| 1070 | + // glue it back together |
|
| 1071 | + $widget_path = implode(DS, $widget_path); |
|
| 1072 | + } else { |
|
| 1073 | + // grab and sanitize widget directory name |
|
| 1074 | + $widget = sanitize_key(basename($widget_path)); |
|
| 1075 | + } |
|
| 1076 | + // create classname from widget directory name |
|
| 1077 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1078 | + // add class prefix |
|
| 1079 | + $widget_class = 'EEW_' . $widget; |
|
| 1080 | + // does the widget exist ? |
|
| 1081 | + if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1082 | + $msg = sprintf( |
|
| 1083 | + __( |
|
| 1084 | + 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1085 | + 'event_espresso' |
|
| 1086 | + ), |
|
| 1087 | + $widget_class, |
|
| 1088 | + $widget_path . DS . $widget_class . $widget_ext |
|
| 1089 | + ); |
|
| 1090 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1091 | + return; |
|
| 1092 | + } |
|
| 1093 | + // load the widget class file |
|
| 1094 | + require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1095 | + // verify that class exists |
|
| 1096 | + if ( ! class_exists($widget_class)) { |
|
| 1097 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1098 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1099 | + return; |
|
| 1100 | + } |
|
| 1101 | + register_widget($widget_class); |
|
| 1102 | + // add to array of registered widgets |
|
| 1103 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + |
|
| 1107 | + |
|
| 1108 | + /** |
|
| 1109 | + * _register_shortcodes |
|
| 1110 | + * |
|
| 1111 | + * @access private |
|
| 1112 | + * @return array |
|
| 1113 | + */ |
|
| 1114 | + private function _register_shortcodes() |
|
| 1115 | + { |
|
| 1116 | + // grab list of installed shortcodes |
|
| 1117 | + $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
| 1118 | + // filter list of modules to register |
|
| 1119 | + $shortcodes_to_register = apply_filters( |
|
| 1120 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
| 1121 | + $shortcodes_to_register |
|
| 1122 | + ); |
|
| 1123 | + if ( ! empty($shortcodes_to_register)) { |
|
| 1124 | + // cycle thru shortcode folders |
|
| 1125 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
| 1126 | + // add to list of installed shortcode modules |
|
| 1127 | + EE_Config::register_shortcode($shortcode_path); |
|
| 1128 | + } |
|
| 1129 | + } |
|
| 1130 | + // filter list of installed modules |
|
| 1131 | + return apply_filters( |
|
| 1132 | + 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
| 1133 | + EE_Registry::instance()->shortcodes |
|
| 1134 | + ); |
|
| 1135 | + } |
|
| 1136 | + |
|
| 1137 | + |
|
| 1138 | + |
|
| 1139 | + /** |
|
| 1140 | + * register_shortcode - makes core aware of this shortcode |
|
| 1141 | + * |
|
| 1142 | + * @access public |
|
| 1143 | + * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1144 | + * @return bool |
|
| 1145 | + */ |
|
| 1146 | + public static function register_shortcode($shortcode_path = null) |
|
| 1147 | + { |
|
| 1148 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
| 1149 | + $shortcode_ext = '.shortcode.php'; |
|
| 1150 | + // make all separators match |
|
| 1151 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
| 1152 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1153 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
| 1154 | + // grab shortcode file name from directory name and break apart at dots |
|
| 1155 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
| 1156 | + // take first segment from file name pieces and remove class prefix if it exists |
|
| 1157 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
| 1158 | + ? substr($shortcode_file[0], 4) |
|
| 1159 | + : $shortcode_file[0]; |
|
| 1160 | + // sanitize shortcode directory name |
|
| 1161 | + $shortcode = sanitize_key($shortcode); |
|
| 1162 | + // now we need to rebuild the shortcode path |
|
| 1163 | + $shortcode_path = explode(DS, $shortcode_path); |
|
| 1164 | + // remove last segment |
|
| 1165 | + array_pop($shortcode_path); |
|
| 1166 | + // glue it back together |
|
| 1167 | + $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 1168 | + } else { |
|
| 1169 | + // we need to generate the filename based off of the folder name |
|
| 1170 | + // grab and sanitize shortcode directory name |
|
| 1171 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
| 1172 | + $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 1173 | + } |
|
| 1174 | + // create classname from shortcode directory or file name |
|
| 1175 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
| 1176 | + // add class prefix |
|
| 1177 | + $shortcode_class = 'EES_' . $shortcode; |
|
| 1178 | + // does the shortcode exist ? |
|
| 1179 | + if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 1180 | + $msg = sprintf( |
|
| 1181 | + __( |
|
| 1182 | + 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
| 1183 | + 'event_espresso' |
|
| 1184 | + ), |
|
| 1185 | + $shortcode_class, |
|
| 1186 | + $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 1187 | + ); |
|
| 1188 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1189 | + return false; |
|
| 1190 | + } |
|
| 1191 | + // load the shortcode class file |
|
| 1192 | + require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 1193 | + // verify that class exists |
|
| 1194 | + if ( ! class_exists($shortcode_class)) { |
|
| 1195 | + $msg = sprintf( |
|
| 1196 | + __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
| 1197 | + $shortcode_class |
|
| 1198 | + ); |
|
| 1199 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1200 | + return false; |
|
| 1201 | + } |
|
| 1202 | + $shortcode = strtoupper($shortcode); |
|
| 1203 | + // add to array of registered shortcodes |
|
| 1204 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 1205 | + return true; |
|
| 1206 | + } |
|
| 1207 | + |
|
| 1208 | + |
|
| 1209 | + |
|
| 1210 | + /** |
|
| 1211 | + * _register_modules |
|
| 1212 | + * |
|
| 1213 | + * @access private |
|
| 1214 | + * @return array |
|
| 1215 | + */ |
|
| 1216 | + private function _register_modules() |
|
| 1217 | + { |
|
| 1218 | + // grab list of installed modules |
|
| 1219 | + $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1220 | + // filter list of modules to register |
|
| 1221 | + $modules_to_register = apply_filters( |
|
| 1222 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1223 | + $modules_to_register |
|
| 1224 | + ); |
|
| 1225 | + if ( ! empty($modules_to_register)) { |
|
| 1226 | + // loop through folders |
|
| 1227 | + foreach ($modules_to_register as $module_path) { |
|
| 1228 | + /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1229 | + if ( |
|
| 1230 | + $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1231 | + && $module_path !== EE_MODULES . 'gateways' |
|
| 1232 | + ) { |
|
| 1233 | + // add to list of installed modules |
|
| 1234 | + EE_Config::register_module($module_path); |
|
| 1235 | + } |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + // filter list of installed modules |
|
| 1239 | + return apply_filters( |
|
| 1240 | + 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1241 | + EE_Registry::instance()->modules |
|
| 1242 | + ); |
|
| 1243 | + } |
|
| 1244 | + |
|
| 1245 | + |
|
| 1246 | + |
|
| 1247 | + /** |
|
| 1248 | + * register_module - makes core aware of this module |
|
| 1249 | + * |
|
| 1250 | + * @access public |
|
| 1251 | + * @param string $module_path - full path up to and including module folder |
|
| 1252 | + * @return bool |
|
| 1253 | + */ |
|
| 1254 | + public static function register_module($module_path = null) |
|
| 1255 | + { |
|
| 1256 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1257 | + $module_ext = '.module.php'; |
|
| 1258 | + // make all separators match |
|
| 1259 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1260 | + // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1261 | + if (strpos($module_path, $module_ext) !== false) { |
|
| 1262 | + // grab and shortcode file name from directory name and break apart at dots |
|
| 1263 | + $module_file = explode('.', basename($module_path)); |
|
| 1264 | + // now we need to rebuild the shortcode path |
|
| 1265 | + $module_path = explode(DS, $module_path); |
|
| 1266 | + // remove last segment |
|
| 1267 | + array_pop($module_path); |
|
| 1268 | + // glue it back together |
|
| 1269 | + $module_path = implode(DS, $module_path) . DS; |
|
| 1270 | + // take first segment from file name pieces and sanitize it |
|
| 1271 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1272 | + // ensure class prefix is added |
|
| 1273 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1274 | + } else { |
|
| 1275 | + // we need to generate the filename based off of the folder name |
|
| 1276 | + // grab and sanitize module name |
|
| 1277 | + $module = strtolower(basename($module_path)); |
|
| 1278 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1279 | + // like trailingslashit() |
|
| 1280 | + $module_path = rtrim($module_path, DS) . DS; |
|
| 1281 | + // create classname from module directory name |
|
| 1282 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1283 | + // add class prefix |
|
| 1284 | + $module_class = 'EED_' . $module; |
|
| 1285 | + } |
|
| 1286 | + // does the module exist ? |
|
| 1287 | + if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1288 | + $msg = sprintf( |
|
| 1289 | + __( |
|
| 1290 | + 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1291 | + 'event_espresso' |
|
| 1292 | + ), |
|
| 1293 | + $module |
|
| 1294 | + ); |
|
| 1295 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1296 | + return false; |
|
| 1297 | + } |
|
| 1298 | + // load the module class file |
|
| 1299 | + require_once($module_path . $module_class . $module_ext); |
|
| 1300 | + // verify that class exists |
|
| 1301 | + if ( ! class_exists($module_class)) { |
|
| 1302 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1303 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1304 | + return false; |
|
| 1305 | + } |
|
| 1306 | + // add to array of registered modules |
|
| 1307 | + EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1308 | + do_action( |
|
| 1309 | + 'AHEE__EE_Config__register_module__complete', |
|
| 1310 | + $module_class, |
|
| 1311 | + EE_Registry::instance()->modules->{$module_class} |
|
| 1312 | + ); |
|
| 1313 | + return true; |
|
| 1314 | + } |
|
| 1315 | + |
|
| 1316 | + |
|
| 1317 | + |
|
| 1318 | + /** |
|
| 1319 | + * _initialize_shortcodes |
|
| 1320 | + * allow shortcodes to set hooks for the rest of the system |
|
| 1321 | + * |
|
| 1322 | + * @access private |
|
| 1323 | + * @return void |
|
| 1324 | + */ |
|
| 1325 | + private function _initialize_shortcodes() |
|
| 1326 | + { |
|
| 1327 | + // cycle thru shortcode folders |
|
| 1328 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
| 1329 | + // add class prefix |
|
| 1330 | + $shortcode_class = 'EES_' . $shortcode; |
|
| 1331 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1332 | + // which set hooks ? |
|
| 1333 | + if (is_admin()) { |
|
| 1334 | + // fire immediately |
|
| 1335 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
| 1336 | + } else { |
|
| 1337 | + // delay until other systems are online |
|
| 1338 | + add_action( |
|
| 1339 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1340 | + array($shortcode_class, 'set_hooks') |
|
| 1341 | + ); |
|
| 1342 | + // convert classname to UPPERCASE and create WP shortcode. |
|
| 1343 | + $shortcode_tag = strtoupper($shortcode); |
|
| 1344 | + // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
|
| 1345 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
| 1346 | + // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
|
| 1347 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
| 1348 | + } |
|
| 1349 | + } |
|
| 1350 | + } |
|
| 1351 | + } |
|
| 1352 | + |
|
| 1353 | + |
|
| 1354 | + |
|
| 1355 | + /** |
|
| 1356 | + * _initialize_modules |
|
| 1357 | + * allow modules to set hooks for the rest of the system |
|
| 1358 | + * |
|
| 1359 | + * @access private |
|
| 1360 | + * @return void |
|
| 1361 | + */ |
|
| 1362 | + private function _initialize_modules() |
|
| 1363 | + { |
|
| 1364 | + // cycle thru shortcode folders |
|
| 1365 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1366 | + // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1367 | + // which set hooks ? |
|
| 1368 | + if (is_admin()) { |
|
| 1369 | + // fire immediately |
|
| 1370 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1371 | + } else { |
|
| 1372 | + // delay until other systems are online |
|
| 1373 | + add_action( |
|
| 1374 | + 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1375 | + array($module_class, 'set_hooks') |
|
| 1376 | + ); |
|
| 1377 | + } |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + |
|
| 1382 | + |
|
| 1383 | + /** |
|
| 1384 | + * register_route - adds module method routes to route_map |
|
| 1385 | + * |
|
| 1386 | + * @access public |
|
| 1387 | + * @param string $route - "pretty" public alias for module method |
|
| 1388 | + * @param string $module - module name (classname without EED_ prefix) |
|
| 1389 | + * @param string $method_name - the actual module method to be routed to |
|
| 1390 | + * @param string $key - url param key indicating a route is being called |
|
| 1391 | + * @return bool |
|
| 1392 | + */ |
|
| 1393 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1394 | + { |
|
| 1395 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1396 | + $module = str_replace('EED_', '', $module); |
|
| 1397 | + $module_class = 'EED_' . $module; |
|
| 1398 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1399 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1400 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1401 | + return false; |
|
| 1402 | + } |
|
| 1403 | + if (empty($route)) { |
|
| 1404 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1405 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1406 | + return false; |
|
| 1407 | + } |
|
| 1408 | + if ( ! method_exists('EED_' . $module, $method_name)) { |
|
| 1409 | + $msg = sprintf( |
|
| 1410 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1411 | + $route |
|
| 1412 | + ); |
|
| 1413 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1414 | + return false; |
|
| 1415 | + } |
|
| 1416 | + EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1417 | + return true; |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + |
|
| 1421 | + |
|
| 1422 | + /** |
|
| 1423 | + * get_route - get module method route |
|
| 1424 | + * |
|
| 1425 | + * @access public |
|
| 1426 | + * @param string $route - "pretty" public alias for module method |
|
| 1427 | + * @param string $key - url param key indicating a route is being called |
|
| 1428 | + * @return string |
|
| 1429 | + */ |
|
| 1430 | + public static function get_route($route = null, $key = 'ee') |
|
| 1431 | + { |
|
| 1432 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1433 | + $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1434 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1435 | + return EE_Config::$_module_route_map[$key][$route]; |
|
| 1436 | + } |
|
| 1437 | + return null; |
|
| 1438 | + } |
|
| 1439 | + |
|
| 1440 | + |
|
| 1441 | + |
|
| 1442 | + /** |
|
| 1443 | + * get_routes - get ALL module method routes |
|
| 1444 | + * |
|
| 1445 | + * @access public |
|
| 1446 | + * @return array |
|
| 1447 | + */ |
|
| 1448 | + public static function get_routes() |
|
| 1449 | + { |
|
| 1450 | + return EE_Config::$_module_route_map; |
|
| 1451 | + } |
|
| 1452 | + |
|
| 1453 | + |
|
| 1454 | + |
|
| 1455 | + /** |
|
| 1456 | + * register_forward - allows modules to forward request to another module for further processing |
|
| 1457 | + * |
|
| 1458 | + * @access public |
|
| 1459 | + * @param string $route - "pretty" public alias for module method |
|
| 1460 | + * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1461 | + * class, allows different forwards to be served based on status |
|
| 1462 | + * @param array|string $forward - function name or array( class, method ) |
|
| 1463 | + * @param string $key - url param key indicating a route is being called |
|
| 1464 | + * @return bool |
|
| 1465 | + */ |
|
| 1466 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1467 | + { |
|
| 1468 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1469 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1470 | + $msg = sprintf( |
|
| 1471 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1472 | + $route |
|
| 1473 | + ); |
|
| 1474 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1475 | + return false; |
|
| 1476 | + } |
|
| 1477 | + if (empty($forward)) { |
|
| 1478 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1479 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1480 | + return false; |
|
| 1481 | + } |
|
| 1482 | + if (is_array($forward)) { |
|
| 1483 | + if ( ! isset($forward[1])) { |
|
| 1484 | + $msg = sprintf( |
|
| 1485 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1486 | + $route |
|
| 1487 | + ); |
|
| 1488 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1489 | + return false; |
|
| 1490 | + } |
|
| 1491 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
| 1492 | + $msg = sprintf( |
|
| 1493 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1494 | + $forward[1], |
|
| 1495 | + $route |
|
| 1496 | + ); |
|
| 1497 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1498 | + return false; |
|
| 1499 | + } |
|
| 1500 | + } else if ( ! function_exists($forward)) { |
|
| 1501 | + $msg = sprintf( |
|
| 1502 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1503 | + $forward, |
|
| 1504 | + $route |
|
| 1505 | + ); |
|
| 1506 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1507 | + return false; |
|
| 1508 | + } |
|
| 1509 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1510 | + return true; |
|
| 1511 | + } |
|
| 1512 | + |
|
| 1513 | + |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * get_forward - get forwarding route |
|
| 1517 | + * |
|
| 1518 | + * @access public |
|
| 1519 | + * @param string $route - "pretty" public alias for module method |
|
| 1520 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1521 | + * allows different forwards to be served based on status |
|
| 1522 | + * @param string $key - url param key indicating a route is being called |
|
| 1523 | + * @return string |
|
| 1524 | + */ |
|
| 1525 | + public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1526 | + { |
|
| 1527 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1528 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1529 | + return apply_filters( |
|
| 1530 | + 'FHEE__EE_Config__get_forward', |
|
| 1531 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1532 | + $route, |
|
| 1533 | + $status |
|
| 1534 | + ); |
|
| 1535 | + } |
|
| 1536 | + return null; |
|
| 1537 | + } |
|
| 1538 | + |
|
| 1539 | + |
|
| 1540 | + |
|
| 1541 | + /** |
|
| 1542 | + * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1543 | + * results |
|
| 1544 | + * |
|
| 1545 | + * @access public |
|
| 1546 | + * @param string $route - "pretty" public alias for module method |
|
| 1547 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1548 | + * allows different views to be served based on status |
|
| 1549 | + * @param string $view |
|
| 1550 | + * @param string $key - url param key indicating a route is being called |
|
| 1551 | + * @return bool |
|
| 1552 | + */ |
|
| 1553 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1554 | + { |
|
| 1555 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1556 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1557 | + $msg = sprintf( |
|
| 1558 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1559 | + $route |
|
| 1560 | + ); |
|
| 1561 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1562 | + return false; |
|
| 1563 | + } |
|
| 1564 | + if ( ! is_readable($view)) { |
|
| 1565 | + $msg = sprintf( |
|
| 1566 | + __( |
|
| 1567 | + 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1568 | + 'event_espresso' |
|
| 1569 | + ), |
|
| 1570 | + $view |
|
| 1571 | + ); |
|
| 1572 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1573 | + return false; |
|
| 1574 | + } |
|
| 1575 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1576 | + return true; |
|
| 1577 | + } |
|
| 1578 | + |
|
| 1579 | + |
|
| 1580 | + |
|
| 1581 | + /** |
|
| 1582 | + * get_view - get view for route and status |
|
| 1583 | + * |
|
| 1584 | + * @access public |
|
| 1585 | + * @param string $route - "pretty" public alias for module method |
|
| 1586 | + * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1587 | + * allows different views to be served based on status |
|
| 1588 | + * @param string $key - url param key indicating a route is being called |
|
| 1589 | + * @return string |
|
| 1590 | + */ |
|
| 1591 | + public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1592 | + { |
|
| 1593 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1594 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1595 | + return apply_filters( |
|
| 1596 | + 'FHEE__EE_Config__get_view', |
|
| 1597 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1598 | + $route, |
|
| 1599 | + $status |
|
| 1600 | + ); |
|
| 1601 | + } |
|
| 1602 | + return null; |
|
| 1603 | + } |
|
| 1604 | + |
|
| 1605 | + |
|
| 1606 | + |
|
| 1607 | + public function update_addon_option_names() |
|
| 1608 | + { |
|
| 1609 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1610 | + } |
|
| 1611 | + |
|
| 1612 | + |
|
| 1613 | + |
|
| 1614 | + public function shutdown() |
|
| 1615 | + { |
|
| 1616 | + $this->update_addon_option_names(); |
|
| 1617 | + } |
|
| 18 | 1618 | |
| 19 | - const LOG_NAME = 'ee_config_log'; |
|
| 20 | 1619 | |
| 21 | - const LOG_LENGTH = 100; |
|
| 22 | - |
|
| 23 | - const ADDON_OPTION_NAMES = 'ee_config_option_names'; |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * instance of the EE_Config object |
|
| 28 | - * |
|
| 29 | - * @var EE_Config $_instance |
|
| 30 | - * @access private |
|
| 31 | - */ |
|
| 32 | - private static $_instance; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var boolean $_logging_enabled |
|
| 36 | - */ |
|
| 37 | - private static $_logging_enabled = false; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * An StdClass whose property names are addon slugs, |
|
| 41 | - * and values are their config classes |
|
| 42 | - * |
|
| 43 | - * @var StdClass |
|
| 44 | - */ |
|
| 45 | - public $addons; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var EE_Admin_Config |
|
| 49 | - */ |
|
| 50 | - public $admin; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @var EE_Core_Config |
|
| 54 | - */ |
|
| 55 | - public $core; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @var EE_Currency_Config |
|
| 59 | - */ |
|
| 60 | - public $currency; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @var EE_Organization_Config |
|
| 64 | - */ |
|
| 65 | - public $organization; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @var EE_Registration_Config |
|
| 69 | - */ |
|
| 70 | - public $registration; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @var EE_Template_Config |
|
| 74 | - */ |
|
| 75 | - public $template_settings; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Holds EE environment values. |
|
| 79 | - * |
|
| 80 | - * @var EE_Environment_Config |
|
| 81 | - */ |
|
| 82 | - public $environment; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * settings pertaining to Google maps |
|
| 86 | - * |
|
| 87 | - * @var EE_Map_Config |
|
| 88 | - */ |
|
| 89 | - public $map_settings; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * settings pertaining to Taxes |
|
| 93 | - * |
|
| 94 | - * @var EE_Tax_Config |
|
| 95 | - */ |
|
| 96 | - public $tax_settings; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @deprecated |
|
| 100 | - * @var EE_Gateway_Config |
|
| 101 | - */ |
|
| 102 | - public $gateway; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @var array $_addon_option_names |
|
| 106 | - * @access private |
|
| 107 | - */ |
|
| 108 | - private $_addon_option_names = array(); |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @var array $_module_route_map |
|
| 112 | - * @access private |
|
| 113 | - */ |
|
| 114 | - private static $_module_route_map = array(); |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @var array $_module_forward_map |
|
| 118 | - * @access private |
|
| 119 | - */ |
|
| 120 | - private static $_module_forward_map = array(); |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @var array $_module_view_map |
|
| 124 | - * @access private |
|
| 125 | - */ |
|
| 126 | - private static $_module_view_map = array(); |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @singleton method used to instantiate class object |
|
| 132 | - * @access public |
|
| 133 | - * @return EE_Config instance |
|
| 134 | - */ |
|
| 135 | - public static function instance() |
|
| 136 | - { |
|
| 137 | - // check if class object is instantiated, and instantiated properly |
|
| 138 | - if ( ! self::$_instance instanceof EE_Config) { |
|
| 139 | - self::$_instance = new self(); |
|
| 140 | - } |
|
| 141 | - return self::$_instance; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Resets the config |
|
| 148 | - * |
|
| 149 | - * @param bool $hard_reset if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE |
|
| 150 | - * (default) leaves the database alone, and merely resets the EE_Config object to |
|
| 151 | - * reflect its state in the database |
|
| 152 | - * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave |
|
| 153 | - * $_instance as NULL. Useful in case you want to forget about the old instance on |
|
| 154 | - * EE_Config, but might not be ready to instantiate EE_Config currently (eg if the |
|
| 155 | - * site was put into maintenance mode) |
|
| 156 | - * @return EE_Config |
|
| 157 | - */ |
|
| 158 | - public static function reset($hard_reset = false, $reinstantiate = true) |
|
| 159 | - { |
|
| 160 | - if (self::$_instance instanceof EE_Config) { |
|
| 161 | - if ($hard_reset) { |
|
| 162 | - self::$_instance->_addon_option_names = array(); |
|
| 163 | - self::$_instance->_initialize_config(); |
|
| 164 | - self::$_instance->update_espresso_config(); |
|
| 165 | - } |
|
| 166 | - self::$_instance->update_addon_option_names(); |
|
| 167 | - } |
|
| 168 | - self::$_instance = null; |
|
| 169 | - //we don't need to reset the static properties imo because those should |
|
| 170 | - //only change when a module is added or removed. Currently we don't |
|
| 171 | - //support removing a module during a request when it previously existed |
|
| 172 | - if ($reinstantiate) { |
|
| 173 | - return self::instance(); |
|
| 174 | - } else { |
|
| 175 | - return null; |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * class constructor |
|
| 183 | - * |
|
| 184 | - * @access private |
|
| 185 | - */ |
|
| 186 | - private function __construct() |
|
| 187 | - { |
|
| 188 | - do_action('AHEE__EE_Config__construct__begin', $this); |
|
| 189 | - EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false); |
|
| 190 | - // setup empty config classes |
|
| 191 | - $this->_initialize_config(); |
|
| 192 | - // load existing EE site settings |
|
| 193 | - $this->_load_core_config(); |
|
| 194 | - // confirm everything loaded correctly and set filtered defaults if not |
|
| 195 | - $this->_verify_config(); |
|
| 196 | - // register shortcodes and modules |
|
| 197 | - add_action( |
|
| 198 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 199 | - array($this, 'register_shortcodes_and_modules'), |
|
| 200 | - 999 |
|
| 201 | - ); |
|
| 202 | - // initialize shortcodes and modules |
|
| 203 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
| 204 | - // register widgets |
|
| 205 | - add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
| 206 | - // shutdown |
|
| 207 | - add_action('shutdown', array($this, 'shutdown'), 10); |
|
| 208 | - // construct__end hook |
|
| 209 | - do_action('AHEE__EE_Config__construct__end', $this); |
|
| 210 | - // hardcoded hack |
|
| 211 | - $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * @return boolean |
|
| 218 | - */ |
|
| 219 | - public static function logging_enabled() |
|
| 220 | - { |
|
| 221 | - return self::$_logging_enabled; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * use to get the current theme if needed from static context |
|
| 228 | - * |
|
| 229 | - * @return string current theme set. |
|
| 230 | - */ |
|
| 231 | - public static function get_current_theme() |
|
| 232 | - { |
|
| 233 | - return isset(self::$_instance->template_settings->current_espresso_theme) |
|
| 234 | - ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * _initialize_config |
|
| 241 | - * |
|
| 242 | - * @access private |
|
| 243 | - * @return void |
|
| 244 | - */ |
|
| 245 | - private function _initialize_config() |
|
| 246 | - { |
|
| 247 | - EE_Config::trim_log(); |
|
| 248 | - //set defaults |
|
| 249 | - $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
| 250 | - $this->addons = new stdClass(); |
|
| 251 | - // set _module_route_map |
|
| 252 | - EE_Config::$_module_route_map = array(); |
|
| 253 | - // set _module_forward_map |
|
| 254 | - EE_Config::$_module_forward_map = array(); |
|
| 255 | - // set _module_view_map |
|
| 256 | - EE_Config::$_module_view_map = array(); |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * load core plugin configuration |
|
| 263 | - * |
|
| 264 | - * @access private |
|
| 265 | - * @return void |
|
| 266 | - */ |
|
| 267 | - private function _load_core_config() |
|
| 268 | - { |
|
| 269 | - // load_core_config__start hook |
|
| 270 | - do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
| 271 | - $espresso_config = $this->get_espresso_config(); |
|
| 272 | - foreach ($espresso_config as $config => $settings) { |
|
| 273 | - // load_core_config__start hook |
|
| 274 | - $settings = apply_filters( |
|
| 275 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
| 276 | - $settings, |
|
| 277 | - $config, |
|
| 278 | - $this |
|
| 279 | - ); |
|
| 280 | - if (is_object($settings) && property_exists($this, $config)) { |
|
| 281 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 282 | - //call configs populate method to ensure any defaults are set for empty values. |
|
| 283 | - if (method_exists($settings, 'populate')) { |
|
| 284 | - $this->{$config}->populate(); |
|
| 285 | - } |
|
| 286 | - if (method_exists($settings, 'do_hooks')) { |
|
| 287 | - $this->{$config}->do_hooks(); |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
| 292 | - $this->update_espresso_config(); |
|
| 293 | - } |
|
| 294 | - // load_core_config__end hook |
|
| 295 | - do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * _verify_config |
|
| 302 | - * |
|
| 303 | - * @access protected |
|
| 304 | - * @return void |
|
| 305 | - */ |
|
| 306 | - protected function _verify_config() |
|
| 307 | - { |
|
| 308 | - $this->core = $this->core instanceof EE_Core_Config |
|
| 309 | - ? $this->core |
|
| 310 | - : new EE_Core_Config(); |
|
| 311 | - $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
| 312 | - $this->organization = $this->organization instanceof EE_Organization_Config |
|
| 313 | - ? $this->organization |
|
| 314 | - : new EE_Organization_Config(); |
|
| 315 | - $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', |
|
| 316 | - $this->organization); |
|
| 317 | - $this->currency = $this->currency instanceof EE_Currency_Config |
|
| 318 | - ? $this->currency |
|
| 319 | - : new EE_Currency_Config(); |
|
| 320 | - $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
| 321 | - $this->registration = $this->registration instanceof EE_Registration_Config |
|
| 322 | - ? $this->registration |
|
| 323 | - : new EE_Registration_Config(); |
|
| 324 | - $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', |
|
| 325 | - $this->registration); |
|
| 326 | - $this->admin = $this->admin instanceof EE_Admin_Config |
|
| 327 | - ? $this->admin |
|
| 328 | - : new EE_Admin_Config(); |
|
| 329 | - $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
| 330 | - $this->template_settings = $this->template_settings instanceof EE_Template_Config |
|
| 331 | - ? $this->template_settings |
|
| 332 | - : new EE_Template_Config(); |
|
| 333 | - $this->template_settings = apply_filters( |
|
| 334 | - 'FHEE__EE_Config___initialize_config__template_settings', |
|
| 335 | - $this->template_settings |
|
| 336 | - ); |
|
| 337 | - $this->map_settings = $this->map_settings instanceof EE_Map_Config |
|
| 338 | - ? $this->map_settings |
|
| 339 | - : new EE_Map_Config(); |
|
| 340 | - $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', |
|
| 341 | - $this->map_settings); |
|
| 342 | - $this->environment = $this->environment instanceof EE_Environment_Config |
|
| 343 | - ? $this->environment |
|
| 344 | - : new EE_Environment_Config(); |
|
| 345 | - $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', |
|
| 346 | - $this->environment); |
|
| 347 | - $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config |
|
| 348 | - ? $this->tax_settings |
|
| 349 | - : new EE_Tax_Config(); |
|
| 350 | - $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings', |
|
| 351 | - $this->tax_settings); |
|
| 352 | - $this->gateway = $this->gateway instanceof EE_Gateway_Config |
|
| 353 | - ? $this->gateway |
|
| 354 | - : new EE_Gateway_Config(); |
|
| 355 | - $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * get_espresso_config |
|
| 362 | - * |
|
| 363 | - * @access public |
|
| 364 | - * @return array of espresso config stuff |
|
| 365 | - */ |
|
| 366 | - public function get_espresso_config() |
|
| 367 | - { |
|
| 368 | - // grab espresso configuration |
|
| 369 | - return apply_filters( |
|
| 370 | - 'FHEE__EE_Config__get_espresso_config__CFG', |
|
| 371 | - get_option(EE_Config::OPTION_NAME, array()) |
|
| 372 | - ); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * double_check_config_comparison |
|
| 379 | - * |
|
| 380 | - * @access public |
|
| 381 | - * @param string $option |
|
| 382 | - * @param $old_value |
|
| 383 | - * @param $value |
|
| 384 | - */ |
|
| 385 | - public function double_check_config_comparison($option = '', $old_value, $value) |
|
| 386 | - { |
|
| 387 | - // make sure we're checking the ee config |
|
| 388 | - if ($option === EE_Config::OPTION_NAME) { |
|
| 389 | - // run a loose comparison of the old value against the new value for type and properties, |
|
| 390 | - // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
|
| 391 | - if ($value != $old_value) { |
|
| 392 | - // if they are NOT the same, then remove the hook, |
|
| 393 | - // which means the subsequent update results will be based solely on the update query results |
|
| 394 | - // the reason we do this is because, as stated above, |
|
| 395 | - // WP update_option performs an exact instance comparison (===) on any update values passed to it |
|
| 396 | - // this happens PRIOR to serialization and any subsequent update. |
|
| 397 | - // If values are found to match their previous old value, |
|
| 398 | - // then WP bails before performing any update. |
|
| 399 | - // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version |
|
| 400 | - // it just pulled from the db, with the one being passed to it (which will not match). |
|
| 401 | - // HOWEVER, once the object is serialized and passed off to MySQL to update, |
|
| 402 | - // MySQL MAY ALSO NOT perform the update because |
|
| 403 | - // the string it sees in the db looks the same as the new one it has been passed!!! |
|
| 404 | - // This results in the query returning an "affected rows" value of ZERO, |
|
| 405 | - // which gets returned immediately by WP update_option and looks like an error. |
|
| 406 | - remove_action('update_option', array($this, 'check_config_updated')); |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * update_espresso_config |
|
| 415 | - * |
|
| 416 | - * @access public |
|
| 417 | - */ |
|
| 418 | - protected function _reset_espresso_addon_config() |
|
| 419 | - { |
|
| 420 | - $this->_addon_option_names = array(); |
|
| 421 | - foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
| 422 | - $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
| 423 | - $config_class = get_class($addon_config_obj); |
|
| 424 | - if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
| 425 | - $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
| 426 | - } |
|
| 427 | - $this->addons->{$addon_name} = null; |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * update_espresso_config |
|
| 435 | - * |
|
| 436 | - * @access public |
|
| 437 | - * @param bool $add_success |
|
| 438 | - * @param bool $add_error |
|
| 439 | - * @return bool |
|
| 440 | - */ |
|
| 441 | - public function update_espresso_config($add_success = false, $add_error = true) |
|
| 442 | - { |
|
| 443 | - // don't allow config updates during WP heartbeats |
|
| 444 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 445 | - return false; |
|
| 446 | - } |
|
| 447 | - // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
|
| 448 | - //$clone = clone( self::$_instance ); |
|
| 449 | - //self::$_instance = NULL; |
|
| 450 | - do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
| 451 | - $this->_reset_espresso_addon_config(); |
|
| 452 | - // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
|
| 453 | - // but BEFORE the actual update occurs |
|
| 454 | - add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
| 455 | - // now update "ee_config" |
|
| 456 | - $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
| 457 | - EE_Config::log(EE_Config::OPTION_NAME); |
|
| 458 | - // if not saved... check if the hook we just added still exists; |
|
| 459 | - // if it does, it means one of two things: |
|
| 460 | - // that update_option bailed at the ( $value === $old_value ) conditional, |
|
| 461 | - // or... |
|
| 462 | - // the db update query returned 0 rows affected |
|
| 463 | - // (probably because the data value was the same from it's perspective) |
|
| 464 | - // so the existence of the hook means that a negative result from update_option is NOT an error, |
|
| 465 | - // but just means no update occurred, so don't display an error to the user. |
|
| 466 | - // BUT... if update_option returns FALSE, AND the hook is missing, |
|
| 467 | - // then it means that something truly went wrong |
|
| 468 | - $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
| 469 | - // remove our action since we don't want it in the system anymore |
|
| 470 | - remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
| 471 | - do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
| 472 | - //self::$_instance = $clone; |
|
| 473 | - //unset( $clone ); |
|
| 474 | - // if config remains the same or was updated successfully |
|
| 475 | - if ($saved) { |
|
| 476 | - if ($add_success) { |
|
| 477 | - EE_Error::add_success( |
|
| 478 | - __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
| 479 | - __FILE__, |
|
| 480 | - __FUNCTION__, |
|
| 481 | - __LINE__ |
|
| 482 | - ); |
|
| 483 | - } |
|
| 484 | - return true; |
|
| 485 | - } else { |
|
| 486 | - if ($add_error) { |
|
| 487 | - EE_Error::add_error( |
|
| 488 | - __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
| 489 | - __FILE__, |
|
| 490 | - __FUNCTION__, |
|
| 491 | - __LINE__ |
|
| 492 | - ); |
|
| 493 | - } |
|
| 494 | - return false; |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * _verify_config_params |
|
| 502 | - * |
|
| 503 | - * @access private |
|
| 504 | - * @param string $section |
|
| 505 | - * @param string $name |
|
| 506 | - * @param string $config_class |
|
| 507 | - * @param EE_Config_Base $config_obj |
|
| 508 | - * @param array $tests_to_run |
|
| 509 | - * @param bool $display_errors |
|
| 510 | - * @return bool TRUE on success, FALSE on fail |
|
| 511 | - */ |
|
| 512 | - private function _verify_config_params( |
|
| 513 | - $section = '', |
|
| 514 | - $name = '', |
|
| 515 | - $config_class = '', |
|
| 516 | - $config_obj = null, |
|
| 517 | - $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
| 518 | - $display_errors = true |
|
| 519 | - ) { |
|
| 520 | - try { |
|
| 521 | - foreach ($tests_to_run as $test) { |
|
| 522 | - switch ($test) { |
|
| 523 | - // TEST #1 : check that section was set |
|
| 524 | - case 1 : |
|
| 525 | - if (empty($section)) { |
|
| 526 | - if ($display_errors) { |
|
| 527 | - throw new EE_Error( |
|
| 528 | - sprintf( |
|
| 529 | - __( |
|
| 530 | - 'No configuration section has been provided while attempting to save "%s".', |
|
| 531 | - 'event_espresso' |
|
| 532 | - ), |
|
| 533 | - $config_class |
|
| 534 | - ) |
|
| 535 | - ); |
|
| 536 | - } |
|
| 537 | - return false; |
|
| 538 | - } |
|
| 539 | - break; |
|
| 540 | - // TEST #2 : check that settings section exists |
|
| 541 | - case 2 : |
|
| 542 | - if ( ! isset($this->{$section})) { |
|
| 543 | - if ($display_errors) { |
|
| 544 | - throw new EE_Error( |
|
| 545 | - sprintf( |
|
| 546 | - __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
| 547 | - $section |
|
| 548 | - ) |
|
| 549 | - ); |
|
| 550 | - } |
|
| 551 | - return false; |
|
| 552 | - } |
|
| 553 | - break; |
|
| 554 | - // TEST #3 : check that section is the proper format |
|
| 555 | - case 3 : |
|
| 556 | - if ( |
|
| 557 | - ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
| 558 | - ) { |
|
| 559 | - if ($display_errors) { |
|
| 560 | - throw new EE_Error( |
|
| 561 | - sprintf( |
|
| 562 | - __( |
|
| 563 | - 'The "%s" configuration settings have not been formatted correctly.', |
|
| 564 | - 'event_espresso' |
|
| 565 | - ), |
|
| 566 | - $section |
|
| 567 | - ) |
|
| 568 | - ); |
|
| 569 | - } |
|
| 570 | - return false; |
|
| 571 | - } |
|
| 572 | - break; |
|
| 573 | - // TEST #4 : check that config section name has been set |
|
| 574 | - case 4 : |
|
| 575 | - if (empty($name)) { |
|
| 576 | - if ($display_errors) { |
|
| 577 | - throw new EE_Error( |
|
| 578 | - __( |
|
| 579 | - 'No name has been provided for the specific configuration section.', |
|
| 580 | - 'event_espresso' |
|
| 581 | - ) |
|
| 582 | - ); |
|
| 583 | - } |
|
| 584 | - return false; |
|
| 585 | - } |
|
| 586 | - break; |
|
| 587 | - // TEST #5 : check that a config class name has been set |
|
| 588 | - case 5 : |
|
| 589 | - if (empty($config_class)) { |
|
| 590 | - if ($display_errors) { |
|
| 591 | - throw new EE_Error( |
|
| 592 | - __( |
|
| 593 | - 'No class name has been provided for the specific configuration section.', |
|
| 594 | - 'event_espresso' |
|
| 595 | - ) |
|
| 596 | - ); |
|
| 597 | - } |
|
| 598 | - return false; |
|
| 599 | - } |
|
| 600 | - break; |
|
| 601 | - // TEST #6 : verify config class is accessible |
|
| 602 | - case 6 : |
|
| 603 | - if ( ! class_exists($config_class)) { |
|
| 604 | - if ($display_errors) { |
|
| 605 | - throw new EE_Error( |
|
| 606 | - sprintf( |
|
| 607 | - __( |
|
| 608 | - 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', |
|
| 609 | - 'event_espresso' |
|
| 610 | - ), |
|
| 611 | - $config_class |
|
| 612 | - ) |
|
| 613 | - ); |
|
| 614 | - } |
|
| 615 | - return false; |
|
| 616 | - } |
|
| 617 | - break; |
|
| 618 | - // TEST #7 : check that config has even been set |
|
| 619 | - case 7 : |
|
| 620 | - if ( ! isset($this->{$section}->{$name})) { |
|
| 621 | - if ($display_errors) { |
|
| 622 | - throw new EE_Error( |
|
| 623 | - sprintf( |
|
| 624 | - __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
| 625 | - $section, |
|
| 626 | - $name |
|
| 627 | - ) |
|
| 628 | - ); |
|
| 629 | - } |
|
| 630 | - return false; |
|
| 631 | - } else { |
|
| 632 | - // and make sure it's not serialized |
|
| 633 | - $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name}); |
|
| 634 | - } |
|
| 635 | - break; |
|
| 636 | - // TEST #8 : check that config is the requested type |
|
| 637 | - case 8 : |
|
| 638 | - if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
| 639 | - if ($display_errors) { |
|
| 640 | - throw new EE_Error( |
|
| 641 | - sprintf( |
|
| 642 | - __( |
|
| 643 | - 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', |
|
| 644 | - 'event_espresso' |
|
| 645 | - ), |
|
| 646 | - $section, |
|
| 647 | - $name, |
|
| 648 | - $config_class |
|
| 649 | - ) |
|
| 650 | - ); |
|
| 651 | - } |
|
| 652 | - return false; |
|
| 653 | - } |
|
| 654 | - break; |
|
| 655 | - // TEST #9 : verify config object |
|
| 656 | - case 9 : |
|
| 657 | - if ( ! $config_obj instanceof EE_Config_Base) { |
|
| 658 | - if ($display_errors) { |
|
| 659 | - throw new EE_Error( |
|
| 660 | - sprintf( |
|
| 661 | - __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
| 662 | - print_r($config_obj, true) |
|
| 663 | - ) |
|
| 664 | - ); |
|
| 665 | - } |
|
| 666 | - return false; |
|
| 667 | - } |
|
| 668 | - break; |
|
| 669 | - } |
|
| 670 | - } |
|
| 671 | - } catch (EE_Error $e) { |
|
| 672 | - $e->get_error(); |
|
| 673 | - } |
|
| 674 | - // you have successfully run the gauntlet |
|
| 675 | - return true; |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * _generate_config_option_name |
|
| 682 | - * |
|
| 683 | - * @access protected |
|
| 684 | - * @param string $section |
|
| 685 | - * @param string $name |
|
| 686 | - * @return string |
|
| 687 | - */ |
|
| 688 | - private function _generate_config_option_name($section = '', $name = '') |
|
| 689 | - { |
|
| 690 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * _set_config_class |
|
| 697 | - * ensures that a config class is set, either from a passed config class or one generated from the config name |
|
| 698 | - * |
|
| 699 | - * @access private |
|
| 700 | - * @param string $config_class |
|
| 701 | - * @param string $name |
|
| 702 | - * @return string |
|
| 703 | - */ |
|
| 704 | - private function _set_config_class($config_class = '', $name = '') |
|
| 705 | - { |
|
| 706 | - return ! empty($config_class) |
|
| 707 | - ? $config_class |
|
| 708 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - |
|
| 712 | - |
|
| 713 | - /** |
|
| 714 | - * set_config |
|
| 715 | - * |
|
| 716 | - * @access protected |
|
| 717 | - * @param string $section |
|
| 718 | - * @param string $name |
|
| 719 | - * @param string $config_class |
|
| 720 | - * @param EE_Config_Base $config_obj |
|
| 721 | - * @return EE_Config_Base |
|
| 722 | - */ |
|
| 723 | - public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) |
|
| 724 | - { |
|
| 725 | - // ensure config class is set to something |
|
| 726 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 727 | - // run tests 1-4, 6, and 7 to verify all config params are set and valid |
|
| 728 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 729 | - return null; |
|
| 730 | - } |
|
| 731 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 732 | - // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
|
| 733 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 734 | - $this->_addon_option_names[$config_option_name] = $config_class; |
|
| 735 | - $this->update_addon_option_names(); |
|
| 736 | - } |
|
| 737 | - // verify the incoming config object but suppress errors |
|
| 738 | - if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 739 | - $config_obj = new $config_class(); |
|
| 740 | - } |
|
| 741 | - if (get_option($config_option_name)) { |
|
| 742 | - EE_Config::log($config_option_name); |
|
| 743 | - update_option($config_option_name, $config_obj); |
|
| 744 | - $this->{$section}->{$name} = $config_obj; |
|
| 745 | - return $this->{$section}->{$name}; |
|
| 746 | - } else { |
|
| 747 | - // create a wp-option for this config |
|
| 748 | - if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
| 749 | - $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
| 750 | - return $this->{$section}->{$name}; |
|
| 751 | - } else { |
|
| 752 | - EE_Error::add_error( |
|
| 753 | - sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
| 754 | - __FILE__, |
|
| 755 | - __FUNCTION__, |
|
| 756 | - __LINE__ |
|
| 757 | - ); |
|
| 758 | - return null; |
|
| 759 | - } |
|
| 760 | - } |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * update_config |
|
| 767 | - * Important: the config object must ALREADY be set, otherwise this will produce an error. |
|
| 768 | - * |
|
| 769 | - * @access public |
|
| 770 | - * @param string $section |
|
| 771 | - * @param string $name |
|
| 772 | - * @param EE_Config_Base|string $config_obj |
|
| 773 | - * @param bool $throw_errors |
|
| 774 | - * @return bool |
|
| 775 | - */ |
|
| 776 | - public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) |
|
| 777 | - { |
|
| 778 | - // don't allow config updates during WP heartbeats |
|
| 779 | - if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
| 780 | - return false; |
|
| 781 | - } |
|
| 782 | - $config_obj = maybe_unserialize($config_obj); |
|
| 783 | - // get class name of the incoming object |
|
| 784 | - $config_class = get_class($config_obj); |
|
| 785 | - // run tests 1-5 and 9 to verify config |
|
| 786 | - if ( ! $this->_verify_config_params( |
|
| 787 | - $section, |
|
| 788 | - $name, |
|
| 789 | - $config_class, |
|
| 790 | - $config_obj, |
|
| 791 | - array(1, 2, 3, 4, 7, 9) |
|
| 792 | - ) |
|
| 793 | - ) { |
|
| 794 | - return false; |
|
| 795 | - } |
|
| 796 | - $config_option_name = $this->_generate_config_option_name($section, $name); |
|
| 797 | - // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
|
| 798 | - if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
| 799 | - // save new config to db |
|
| 800 | - if ($this->set_config($section, $name, $config_class, $config_obj)) { |
|
| 801 | - return true; |
|
| 802 | - } |
|
| 803 | - } else { |
|
| 804 | - // first check if the record already exists |
|
| 805 | - $existing_config = get_option($config_option_name); |
|
| 806 | - $config_obj = serialize($config_obj); |
|
| 807 | - // just return if db record is already up to date (NOT type safe comparison) |
|
| 808 | - if ($existing_config == $config_obj) { |
|
| 809 | - $this->{$section}->{$name} = $config_obj; |
|
| 810 | - return true; |
|
| 811 | - } else if (update_option($config_option_name, $config_obj)) { |
|
| 812 | - EE_Config::log($config_option_name); |
|
| 813 | - // update wp-option for this config class |
|
| 814 | - $this->{$section}->{$name} = $config_obj; |
|
| 815 | - return true; |
|
| 816 | - } elseif ($throw_errors) { |
|
| 817 | - EE_Error::add_error( |
|
| 818 | - sprintf( |
|
| 819 | - __( |
|
| 820 | - 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', |
|
| 821 | - 'event_espresso' |
|
| 822 | - ), |
|
| 823 | - $config_class, |
|
| 824 | - 'EE_Config->' . $section . '->' . $name |
|
| 825 | - ), |
|
| 826 | - __FILE__, |
|
| 827 | - __FUNCTION__, |
|
| 828 | - __LINE__ |
|
| 829 | - ); |
|
| 830 | - } |
|
| 831 | - } |
|
| 832 | - return false; |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - |
|
| 836 | - |
|
| 837 | - /** |
|
| 838 | - * get_config |
|
| 839 | - * |
|
| 840 | - * @access public |
|
| 841 | - * @param string $section |
|
| 842 | - * @param string $name |
|
| 843 | - * @param string $config_class |
|
| 844 | - * @return mixed EE_Config_Base | NULL |
|
| 845 | - */ |
|
| 846 | - public function get_config($section = '', $name = '', $config_class = '') |
|
| 847 | - { |
|
| 848 | - // ensure config class is set to something |
|
| 849 | - $config_class = $this->_set_config_class($config_class, $name); |
|
| 850 | - // run tests 1-4, 6 and 7 to verify that all params have been set |
|
| 851 | - if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
| 852 | - return null; |
|
| 853 | - } |
|
| 854 | - // now test if the requested config object exists, but suppress errors |
|
| 855 | - if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
| 856 | - // config already exists, so pass it back |
|
| 857 | - return $this->{$section}->{$name}; |
|
| 858 | - } |
|
| 859 | - // load config option from db if it exists |
|
| 860 | - $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
| 861 | - // verify the newly retrieved config object, but suppress errors |
|
| 862 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
| 863 | - // config is good, so set it and pass it back |
|
| 864 | - $this->{$section}->{$name} = $config_obj; |
|
| 865 | - return $this->{$section}->{$name}; |
|
| 866 | - } |
|
| 867 | - // oops! $config_obj is not already set and does not exist in the db, so create a new one |
|
| 868 | - $config_obj = $this->set_config($section, $name, $config_class); |
|
| 869 | - // verify the newly created config object |
|
| 870 | - if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
| 871 | - return $this->{$section}->{$name}; |
|
| 872 | - } else { |
|
| 873 | - EE_Error::add_error( |
|
| 874 | - sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
| 875 | - __FILE__, |
|
| 876 | - __FUNCTION__, |
|
| 877 | - __LINE__ |
|
| 878 | - ); |
|
| 879 | - } |
|
| 880 | - return null; |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - |
|
| 884 | - |
|
| 885 | - /** |
|
| 886 | - * get_config_option |
|
| 887 | - * |
|
| 888 | - * @access public |
|
| 889 | - * @param string $config_option_name |
|
| 890 | - * @return mixed EE_Config_Base | FALSE |
|
| 891 | - */ |
|
| 892 | - public function get_config_option($config_option_name = '') |
|
| 893 | - { |
|
| 894 | - // retrieve the wp-option for this config class. |
|
| 895 | - $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
| 896 | - if (empty($config_option)) { |
|
| 897 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 898 | - } |
|
| 899 | - return $config_option; |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - |
|
| 903 | - |
|
| 904 | - /** |
|
| 905 | - * log |
|
| 906 | - * |
|
| 907 | - * @param string $config_option_name |
|
| 908 | - */ |
|
| 909 | - public static function log($config_option_name = '') |
|
| 910 | - { |
|
| 911 | - if (EE_Config::logging_enabled() && ! empty($config_option_name)) { |
|
| 912 | - $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
| 913 | - //copy incoming $_REQUEST and sanitize it so we can save it |
|
| 914 | - $_request = $_REQUEST; |
|
| 915 | - array_walk_recursive($_request, 'sanitize_text_field'); |
|
| 916 | - $config_log[(string)microtime(true)] = array( |
|
| 917 | - 'config_name' => $config_option_name, |
|
| 918 | - 'request' => $_request, |
|
| 919 | - ); |
|
| 920 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 921 | - } |
|
| 922 | - } |
|
| 923 | - |
|
| 924 | - |
|
| 925 | - |
|
| 926 | - /** |
|
| 927 | - * trim_log |
|
| 928 | - * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
|
| 929 | - */ |
|
| 930 | - public static function trim_log() |
|
| 931 | - { |
|
| 932 | - if ( ! EE_Config::logging_enabled()) { |
|
| 933 | - return; |
|
| 934 | - } |
|
| 935 | - $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array())); |
|
| 936 | - $log_length = count($config_log); |
|
| 937 | - if ($log_length > EE_Config::LOG_LENGTH) { |
|
| 938 | - ksort($config_log); |
|
| 939 | - $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
| 940 | - update_option(EE_Config::LOG_NAME, $config_log); |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - |
|
| 945 | - |
|
| 946 | - /** |
|
| 947 | - * get_page_for_posts |
|
| 948 | - * if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the |
|
| 949 | - * wp-option "page_for_posts", or "posts" if no page is selected |
|
| 950 | - * |
|
| 951 | - * @access public |
|
| 952 | - * @return string |
|
| 953 | - */ |
|
| 954 | - public static function get_page_for_posts() |
|
| 955 | - { |
|
| 956 | - $page_for_posts = get_option('page_for_posts'); |
|
| 957 | - if ( ! $page_for_posts) { |
|
| 958 | - return 'posts'; |
|
| 959 | - } |
|
| 960 | - /** @type WPDB $wpdb */ |
|
| 961 | - global $wpdb; |
|
| 962 | - $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
|
| 963 | - return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
| 964 | - } |
|
| 965 | - |
|
| 966 | - |
|
| 967 | - |
|
| 968 | - /** |
|
| 969 | - * register_shortcodes_and_modules. |
|
| 970 | - * At this point, it's too early to tell if we're maintenance mode or not. |
|
| 971 | - * In fact, this is where we give modules a chance to let core know they exist |
|
| 972 | - * so they can help trigger maintenance mode if it's needed |
|
| 973 | - * |
|
| 974 | - * @access public |
|
| 975 | - * @return void |
|
| 976 | - */ |
|
| 977 | - public function register_shortcodes_and_modules() |
|
| 978 | - { |
|
| 979 | - // allow shortcodes to register with WP and to set hooks for the rest of the system |
|
| 980 | - EE_Registry::instance()->shortcodes = $this->_register_shortcodes(); |
|
| 981 | - // allow modules to set hooks for the rest of the system |
|
| 982 | - EE_Registry::instance()->modules = $this->_register_modules(); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - |
|
| 986 | - |
|
| 987 | - /** |
|
| 988 | - * initialize_shortcodes_and_modules |
|
| 989 | - * meaning they can start adding their hooks to get stuff done |
|
| 990 | - * |
|
| 991 | - * @access public |
|
| 992 | - * @return void |
|
| 993 | - */ |
|
| 994 | - public function initialize_shortcodes_and_modules() |
|
| 995 | - { |
|
| 996 | - // allow shortcodes to set hooks for the rest of the system |
|
| 997 | - $this->_initialize_shortcodes(); |
|
| 998 | - // allow modules to set hooks for the rest of the system |
|
| 999 | - $this->_initialize_modules(); |
|
| 1000 | - } |
|
| 1001 | - |
|
| 1002 | - |
|
| 1003 | - |
|
| 1004 | - /** |
|
| 1005 | - * widgets_init |
|
| 1006 | - * |
|
| 1007 | - * @access private |
|
| 1008 | - * @return void |
|
| 1009 | - */ |
|
| 1010 | - public function widgets_init() |
|
| 1011 | - { |
|
| 1012 | - //only init widgets on admin pages when not in complete maintenance, and |
|
| 1013 | - //on frontend when not in any maintenance mode |
|
| 1014 | - if ( |
|
| 1015 | - ! EE_Maintenance_Mode::instance()->level() |
|
| 1016 | - || ( |
|
| 1017 | - is_admin() |
|
| 1018 | - && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance |
|
| 1019 | - ) |
|
| 1020 | - ) { |
|
| 1021 | - // grab list of installed widgets |
|
| 1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1023 | - // filter list of modules to register |
|
| 1024 | - $widgets_to_register = apply_filters( |
|
| 1025 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
| 1026 | - $widgets_to_register |
|
| 1027 | - ); |
|
| 1028 | - if ( ! empty($widgets_to_register)) { |
|
| 1029 | - // cycle thru widget folders |
|
| 1030 | - foreach ($widgets_to_register as $widget_path) { |
|
| 1031 | - // add to list of installed widget modules |
|
| 1032 | - EE_Config::register_ee_widget($widget_path); |
|
| 1033 | - } |
|
| 1034 | - } |
|
| 1035 | - // filter list of installed modules |
|
| 1036 | - EE_Registry::instance()->widgets = apply_filters( |
|
| 1037 | - 'FHEE__EE_Config__register_widgets__installed_widgets', |
|
| 1038 | - EE_Registry::instance()->widgets |
|
| 1039 | - ); |
|
| 1040 | - } |
|
| 1041 | - } |
|
| 1042 | - |
|
| 1043 | - |
|
| 1044 | - |
|
| 1045 | - /** |
|
| 1046 | - * register_ee_widget - makes core aware of this widget |
|
| 1047 | - * |
|
| 1048 | - * @access public |
|
| 1049 | - * @param string $widget_path - full path up to and including widget folder |
|
| 1050 | - * @return void |
|
| 1051 | - */ |
|
| 1052 | - public static function register_ee_widget($widget_path = null) |
|
| 1053 | - { |
|
| 1054 | - do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
| 1055 | - $widget_ext = '.widget.php'; |
|
| 1056 | - // make all separators match |
|
| 1057 | - $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
| 1058 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1059 | - if (strpos($widget_path, $widget_ext) !== false) { |
|
| 1060 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1061 | - $file_name = explode('.', basename($widget_path)); |
|
| 1062 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 1063 | - $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
| 1064 | - // sanitize shortcode directory name |
|
| 1065 | - $widget = sanitize_key($widget); |
|
| 1066 | - // now we need to rebuild the shortcode path |
|
| 1067 | - $widget_path = explode(DS, $widget_path); |
|
| 1068 | - // remove last segment |
|
| 1069 | - array_pop($widget_path); |
|
| 1070 | - // glue it back together |
|
| 1071 | - $widget_path = implode(DS, $widget_path); |
|
| 1072 | - } else { |
|
| 1073 | - // grab and sanitize widget directory name |
|
| 1074 | - $widget = sanitize_key(basename($widget_path)); |
|
| 1075 | - } |
|
| 1076 | - // create classname from widget directory name |
|
| 1077 | - $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
| 1078 | - // add class prefix |
|
| 1079 | - $widget_class = 'EEW_' . $widget; |
|
| 1080 | - // does the widget exist ? |
|
| 1081 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1082 | - $msg = sprintf( |
|
| 1083 | - __( |
|
| 1084 | - 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
|
| 1085 | - 'event_espresso' |
|
| 1086 | - ), |
|
| 1087 | - $widget_class, |
|
| 1088 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 1089 | - ); |
|
| 1090 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1091 | - return; |
|
| 1092 | - } |
|
| 1093 | - // load the widget class file |
|
| 1094 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1095 | - // verify that class exists |
|
| 1096 | - if ( ! class_exists($widget_class)) { |
|
| 1097 | - $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
| 1098 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1099 | - return; |
|
| 1100 | - } |
|
| 1101 | - register_widget($widget_class); |
|
| 1102 | - // add to array of registered widgets |
|
| 1103 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - |
|
| 1107 | - |
|
| 1108 | - /** |
|
| 1109 | - * _register_shortcodes |
|
| 1110 | - * |
|
| 1111 | - * @access private |
|
| 1112 | - * @return array |
|
| 1113 | - */ |
|
| 1114 | - private function _register_shortcodes() |
|
| 1115 | - { |
|
| 1116 | - // grab list of installed shortcodes |
|
| 1117 | - $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
| 1118 | - // filter list of modules to register |
|
| 1119 | - $shortcodes_to_register = apply_filters( |
|
| 1120 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
| 1121 | - $shortcodes_to_register |
|
| 1122 | - ); |
|
| 1123 | - if ( ! empty($shortcodes_to_register)) { |
|
| 1124 | - // cycle thru shortcode folders |
|
| 1125 | - foreach ($shortcodes_to_register as $shortcode_path) { |
|
| 1126 | - // add to list of installed shortcode modules |
|
| 1127 | - EE_Config::register_shortcode($shortcode_path); |
|
| 1128 | - } |
|
| 1129 | - } |
|
| 1130 | - // filter list of installed modules |
|
| 1131 | - return apply_filters( |
|
| 1132 | - 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', |
|
| 1133 | - EE_Registry::instance()->shortcodes |
|
| 1134 | - ); |
|
| 1135 | - } |
|
| 1136 | - |
|
| 1137 | - |
|
| 1138 | - |
|
| 1139 | - /** |
|
| 1140 | - * register_shortcode - makes core aware of this shortcode |
|
| 1141 | - * |
|
| 1142 | - * @access public |
|
| 1143 | - * @param string $shortcode_path - full path up to and including shortcode folder |
|
| 1144 | - * @return bool |
|
| 1145 | - */ |
|
| 1146 | - public static function register_shortcode($shortcode_path = null) |
|
| 1147 | - { |
|
| 1148 | - do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
| 1149 | - $shortcode_ext = '.shortcode.php'; |
|
| 1150 | - // make all separators match |
|
| 1151 | - $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
| 1152 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1153 | - if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
| 1154 | - // grab shortcode file name from directory name and break apart at dots |
|
| 1155 | - $shortcode_file = explode('.', basename($shortcode_path)); |
|
| 1156 | - // take first segment from file name pieces and remove class prefix if it exists |
|
| 1157 | - $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
| 1158 | - ? substr($shortcode_file[0], 4) |
|
| 1159 | - : $shortcode_file[0]; |
|
| 1160 | - // sanitize shortcode directory name |
|
| 1161 | - $shortcode = sanitize_key($shortcode); |
|
| 1162 | - // now we need to rebuild the shortcode path |
|
| 1163 | - $shortcode_path = explode(DS, $shortcode_path); |
|
| 1164 | - // remove last segment |
|
| 1165 | - array_pop($shortcode_path); |
|
| 1166 | - // glue it back together |
|
| 1167 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 1168 | - } else { |
|
| 1169 | - // we need to generate the filename based off of the folder name |
|
| 1170 | - // grab and sanitize shortcode directory name |
|
| 1171 | - $shortcode = sanitize_key(basename($shortcode_path)); |
|
| 1172 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 1173 | - } |
|
| 1174 | - // create classname from shortcode directory or file name |
|
| 1175 | - $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
| 1176 | - // add class prefix |
|
| 1177 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1178 | - // does the shortcode exist ? |
|
| 1179 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 1180 | - $msg = sprintf( |
|
| 1181 | - __( |
|
| 1182 | - 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
|
| 1183 | - 'event_espresso' |
|
| 1184 | - ), |
|
| 1185 | - $shortcode_class, |
|
| 1186 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 1187 | - ); |
|
| 1188 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1189 | - return false; |
|
| 1190 | - } |
|
| 1191 | - // load the shortcode class file |
|
| 1192 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 1193 | - // verify that class exists |
|
| 1194 | - if ( ! class_exists($shortcode_class)) { |
|
| 1195 | - $msg = sprintf( |
|
| 1196 | - __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
| 1197 | - $shortcode_class |
|
| 1198 | - ); |
|
| 1199 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1200 | - return false; |
|
| 1201 | - } |
|
| 1202 | - $shortcode = strtoupper($shortcode); |
|
| 1203 | - // add to array of registered shortcodes |
|
| 1204 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 1205 | - return true; |
|
| 1206 | - } |
|
| 1207 | - |
|
| 1208 | - |
|
| 1209 | - |
|
| 1210 | - /** |
|
| 1211 | - * _register_modules |
|
| 1212 | - * |
|
| 1213 | - * @access private |
|
| 1214 | - * @return array |
|
| 1215 | - */ |
|
| 1216 | - private function _register_modules() |
|
| 1217 | - { |
|
| 1218 | - // grab list of installed modules |
|
| 1219 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1220 | - // filter list of modules to register |
|
| 1221 | - $modules_to_register = apply_filters( |
|
| 1222 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
| 1223 | - $modules_to_register |
|
| 1224 | - ); |
|
| 1225 | - if ( ! empty($modules_to_register)) { |
|
| 1226 | - // loop through folders |
|
| 1227 | - foreach ($modules_to_register as $module_path) { |
|
| 1228 | - /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
|
| 1229 | - if ( |
|
| 1230 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1231 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1232 | - ) { |
|
| 1233 | - // add to list of installed modules |
|
| 1234 | - EE_Config::register_module($module_path); |
|
| 1235 | - } |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - // filter list of installed modules |
|
| 1239 | - return apply_filters( |
|
| 1240 | - 'FHEE__EE_Config___register_modules__installed_modules', |
|
| 1241 | - EE_Registry::instance()->modules |
|
| 1242 | - ); |
|
| 1243 | - } |
|
| 1244 | - |
|
| 1245 | - |
|
| 1246 | - |
|
| 1247 | - /** |
|
| 1248 | - * register_module - makes core aware of this module |
|
| 1249 | - * |
|
| 1250 | - * @access public |
|
| 1251 | - * @param string $module_path - full path up to and including module folder |
|
| 1252 | - * @return bool |
|
| 1253 | - */ |
|
| 1254 | - public static function register_module($module_path = null) |
|
| 1255 | - { |
|
| 1256 | - do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
| 1257 | - $module_ext = '.module.php'; |
|
| 1258 | - // make all separators match |
|
| 1259 | - $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
| 1260 | - // does the file path INCLUDE the actual file name as part of the path ? |
|
| 1261 | - if (strpos($module_path, $module_ext) !== false) { |
|
| 1262 | - // grab and shortcode file name from directory name and break apart at dots |
|
| 1263 | - $module_file = explode('.', basename($module_path)); |
|
| 1264 | - // now we need to rebuild the shortcode path |
|
| 1265 | - $module_path = explode(DS, $module_path); |
|
| 1266 | - // remove last segment |
|
| 1267 | - array_pop($module_path); |
|
| 1268 | - // glue it back together |
|
| 1269 | - $module_path = implode(DS, $module_path) . DS; |
|
| 1270 | - // take first segment from file name pieces and sanitize it |
|
| 1271 | - $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
| 1272 | - // ensure class prefix is added |
|
| 1273 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1274 | - } else { |
|
| 1275 | - // we need to generate the filename based off of the folder name |
|
| 1276 | - // grab and sanitize module name |
|
| 1277 | - $module = strtolower(basename($module_path)); |
|
| 1278 | - $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
| 1279 | - // like trailingslashit() |
|
| 1280 | - $module_path = rtrim($module_path, DS) . DS; |
|
| 1281 | - // create classname from module directory name |
|
| 1282 | - $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
| 1283 | - // add class prefix |
|
| 1284 | - $module_class = 'EED_' . $module; |
|
| 1285 | - } |
|
| 1286 | - // does the module exist ? |
|
| 1287 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1288 | - $msg = sprintf( |
|
| 1289 | - __( |
|
| 1290 | - 'The requested %s module file could not be found or is not readable due to file permissions.', |
|
| 1291 | - 'event_espresso' |
|
| 1292 | - ), |
|
| 1293 | - $module |
|
| 1294 | - ); |
|
| 1295 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1296 | - return false; |
|
| 1297 | - } |
|
| 1298 | - // load the module class file |
|
| 1299 | - require_once($module_path . $module_class . $module_ext); |
|
| 1300 | - // verify that class exists |
|
| 1301 | - if ( ! class_exists($module_class)) { |
|
| 1302 | - $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
| 1303 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1304 | - return false; |
|
| 1305 | - } |
|
| 1306 | - // add to array of registered modules |
|
| 1307 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1308 | - do_action( |
|
| 1309 | - 'AHEE__EE_Config__register_module__complete', |
|
| 1310 | - $module_class, |
|
| 1311 | - EE_Registry::instance()->modules->{$module_class} |
|
| 1312 | - ); |
|
| 1313 | - return true; |
|
| 1314 | - } |
|
| 1315 | - |
|
| 1316 | - |
|
| 1317 | - |
|
| 1318 | - /** |
|
| 1319 | - * _initialize_shortcodes |
|
| 1320 | - * allow shortcodes to set hooks for the rest of the system |
|
| 1321 | - * |
|
| 1322 | - * @access private |
|
| 1323 | - * @return void |
|
| 1324 | - */ |
|
| 1325 | - private function _initialize_shortcodes() |
|
| 1326 | - { |
|
| 1327 | - // cycle thru shortcode folders |
|
| 1328 | - foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
| 1329 | - // add class prefix |
|
| 1330 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1331 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1332 | - // which set hooks ? |
|
| 1333 | - if (is_admin()) { |
|
| 1334 | - // fire immediately |
|
| 1335 | - call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
| 1336 | - } else { |
|
| 1337 | - // delay until other systems are online |
|
| 1338 | - add_action( |
|
| 1339 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1340 | - array($shortcode_class, 'set_hooks') |
|
| 1341 | - ); |
|
| 1342 | - // convert classname to UPPERCASE and create WP shortcode. |
|
| 1343 | - $shortcode_tag = strtoupper($shortcode); |
|
| 1344 | - // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
|
| 1345 | - if ( ! shortcode_exists($shortcode_tag)) { |
|
| 1346 | - // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
|
| 1347 | - add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
| 1348 | - } |
|
| 1349 | - } |
|
| 1350 | - } |
|
| 1351 | - } |
|
| 1352 | - |
|
| 1353 | - |
|
| 1354 | - |
|
| 1355 | - /** |
|
| 1356 | - * _initialize_modules |
|
| 1357 | - * allow modules to set hooks for the rest of the system |
|
| 1358 | - * |
|
| 1359 | - * @access private |
|
| 1360 | - * @return void |
|
| 1361 | - */ |
|
| 1362 | - private function _initialize_modules() |
|
| 1363 | - { |
|
| 1364 | - // cycle thru shortcode folders |
|
| 1365 | - foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
| 1366 | - // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
|
| 1367 | - // which set hooks ? |
|
| 1368 | - if (is_admin()) { |
|
| 1369 | - // fire immediately |
|
| 1370 | - call_user_func(array($module_class, 'set_hooks_admin')); |
|
| 1371 | - } else { |
|
| 1372 | - // delay until other systems are online |
|
| 1373 | - add_action( |
|
| 1374 | - 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
|
| 1375 | - array($module_class, 'set_hooks') |
|
| 1376 | - ); |
|
| 1377 | - } |
|
| 1378 | - } |
|
| 1379 | - } |
|
| 1380 | - |
|
| 1381 | - |
|
| 1382 | - |
|
| 1383 | - /** |
|
| 1384 | - * register_route - adds module method routes to route_map |
|
| 1385 | - * |
|
| 1386 | - * @access public |
|
| 1387 | - * @param string $route - "pretty" public alias for module method |
|
| 1388 | - * @param string $module - module name (classname without EED_ prefix) |
|
| 1389 | - * @param string $method_name - the actual module method to be routed to |
|
| 1390 | - * @param string $key - url param key indicating a route is being called |
|
| 1391 | - * @return bool |
|
| 1392 | - */ |
|
| 1393 | - public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') |
|
| 1394 | - { |
|
| 1395 | - do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
| 1396 | - $module = str_replace('EED_', '', $module); |
|
| 1397 | - $module_class = 'EED_' . $module; |
|
| 1398 | - if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
|
| 1399 | - $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
| 1400 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1401 | - return false; |
|
| 1402 | - } |
|
| 1403 | - if (empty($route)) { |
|
| 1404 | - $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
| 1405 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1406 | - return false; |
|
| 1407 | - } |
|
| 1408 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
| 1409 | - $msg = sprintf( |
|
| 1410 | - __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
| 1411 | - $route |
|
| 1412 | - ); |
|
| 1413 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1414 | - return false; |
|
| 1415 | - } |
|
| 1416 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1417 | - return true; |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - |
|
| 1421 | - |
|
| 1422 | - /** |
|
| 1423 | - * get_route - get module method route |
|
| 1424 | - * |
|
| 1425 | - * @access public |
|
| 1426 | - * @param string $route - "pretty" public alias for module method |
|
| 1427 | - * @param string $key - url param key indicating a route is being called |
|
| 1428 | - * @return string |
|
| 1429 | - */ |
|
| 1430 | - public static function get_route($route = null, $key = 'ee') |
|
| 1431 | - { |
|
| 1432 | - do_action('AHEE__EE_Config__get_route__begin', $route); |
|
| 1433 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1434 | - if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
| 1435 | - return EE_Config::$_module_route_map[$key][$route]; |
|
| 1436 | - } |
|
| 1437 | - return null; |
|
| 1438 | - } |
|
| 1439 | - |
|
| 1440 | - |
|
| 1441 | - |
|
| 1442 | - /** |
|
| 1443 | - * get_routes - get ALL module method routes |
|
| 1444 | - * |
|
| 1445 | - * @access public |
|
| 1446 | - * @return array |
|
| 1447 | - */ |
|
| 1448 | - public static function get_routes() |
|
| 1449 | - { |
|
| 1450 | - return EE_Config::$_module_route_map; |
|
| 1451 | - } |
|
| 1452 | - |
|
| 1453 | - |
|
| 1454 | - |
|
| 1455 | - /** |
|
| 1456 | - * register_forward - allows modules to forward request to another module for further processing |
|
| 1457 | - * |
|
| 1458 | - * @access public |
|
| 1459 | - * @param string $route - "pretty" public alias for module method |
|
| 1460 | - * @param integer $status - integer value corresponding to status constant strings set in module parent |
|
| 1461 | - * class, allows different forwards to be served based on status |
|
| 1462 | - * @param array|string $forward - function name or array( class, method ) |
|
| 1463 | - * @param string $key - url param key indicating a route is being called |
|
| 1464 | - * @return bool |
|
| 1465 | - */ |
|
| 1466 | - public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') |
|
| 1467 | - { |
|
| 1468 | - do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
| 1469 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1470 | - $msg = sprintf( |
|
| 1471 | - __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
| 1472 | - $route |
|
| 1473 | - ); |
|
| 1474 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1475 | - return false; |
|
| 1476 | - } |
|
| 1477 | - if (empty($forward)) { |
|
| 1478 | - $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
| 1479 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1480 | - return false; |
|
| 1481 | - } |
|
| 1482 | - if (is_array($forward)) { |
|
| 1483 | - if ( ! isset($forward[1])) { |
|
| 1484 | - $msg = sprintf( |
|
| 1485 | - __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
| 1486 | - $route |
|
| 1487 | - ); |
|
| 1488 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1489 | - return false; |
|
| 1490 | - } |
|
| 1491 | - if ( ! method_exists($forward[0], $forward[1])) { |
|
| 1492 | - $msg = sprintf( |
|
| 1493 | - __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1494 | - $forward[1], |
|
| 1495 | - $route |
|
| 1496 | - ); |
|
| 1497 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1498 | - return false; |
|
| 1499 | - } |
|
| 1500 | - } else if ( ! function_exists($forward)) { |
|
| 1501 | - $msg = sprintf( |
|
| 1502 | - __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
| 1503 | - $forward, |
|
| 1504 | - $route |
|
| 1505 | - ); |
|
| 1506 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1507 | - return false; |
|
| 1508 | - } |
|
| 1509 | - EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
| 1510 | - return true; |
|
| 1511 | - } |
|
| 1512 | - |
|
| 1513 | - |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * get_forward - get forwarding route |
|
| 1517 | - * |
|
| 1518 | - * @access public |
|
| 1519 | - * @param string $route - "pretty" public alias for module method |
|
| 1520 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1521 | - * allows different forwards to be served based on status |
|
| 1522 | - * @param string $key - url param key indicating a route is being called |
|
| 1523 | - * @return string |
|
| 1524 | - */ |
|
| 1525 | - public static function get_forward($route = null, $status = 0, $key = 'ee') |
|
| 1526 | - { |
|
| 1527 | - do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
| 1528 | - if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
| 1529 | - return apply_filters( |
|
| 1530 | - 'FHEE__EE_Config__get_forward', |
|
| 1531 | - EE_Config::$_module_forward_map[$key][$route][$status], |
|
| 1532 | - $route, |
|
| 1533 | - $status |
|
| 1534 | - ); |
|
| 1535 | - } |
|
| 1536 | - return null; |
|
| 1537 | - } |
|
| 1538 | - |
|
| 1539 | - |
|
| 1540 | - |
|
| 1541 | - /** |
|
| 1542 | - * register_forward - allows modules to specify different view templates for different method routes and status |
|
| 1543 | - * results |
|
| 1544 | - * |
|
| 1545 | - * @access public |
|
| 1546 | - * @param string $route - "pretty" public alias for module method |
|
| 1547 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1548 | - * allows different views to be served based on status |
|
| 1549 | - * @param string $view |
|
| 1550 | - * @param string $key - url param key indicating a route is being called |
|
| 1551 | - * @return bool |
|
| 1552 | - */ |
|
| 1553 | - public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') |
|
| 1554 | - { |
|
| 1555 | - do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
| 1556 | - if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
| 1557 | - $msg = sprintf( |
|
| 1558 | - __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
| 1559 | - $route |
|
| 1560 | - ); |
|
| 1561 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1562 | - return false; |
|
| 1563 | - } |
|
| 1564 | - if ( ! is_readable($view)) { |
|
| 1565 | - $msg = sprintf( |
|
| 1566 | - __( |
|
| 1567 | - 'The %s view file could not be found or is not readable due to file permissions.', |
|
| 1568 | - 'event_espresso' |
|
| 1569 | - ), |
|
| 1570 | - $view |
|
| 1571 | - ); |
|
| 1572 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1573 | - return false; |
|
| 1574 | - } |
|
| 1575 | - EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
| 1576 | - return true; |
|
| 1577 | - } |
|
| 1578 | - |
|
| 1579 | - |
|
| 1580 | - |
|
| 1581 | - /** |
|
| 1582 | - * get_view - get view for route and status |
|
| 1583 | - * |
|
| 1584 | - * @access public |
|
| 1585 | - * @param string $route - "pretty" public alias for module method |
|
| 1586 | - * @param integer $status - integer value corresponding to status constant strings set in module parent class, |
|
| 1587 | - * allows different views to be served based on status |
|
| 1588 | - * @param string $key - url param key indicating a route is being called |
|
| 1589 | - * @return string |
|
| 1590 | - */ |
|
| 1591 | - public static function get_view($route = null, $status = 0, $key = 'ee') |
|
| 1592 | - { |
|
| 1593 | - do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
| 1594 | - if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
| 1595 | - return apply_filters( |
|
| 1596 | - 'FHEE__EE_Config__get_view', |
|
| 1597 | - EE_Config::$_module_view_map[$key][$route][$status], |
|
| 1598 | - $route, |
|
| 1599 | - $status |
|
| 1600 | - ); |
|
| 1601 | - } |
|
| 1602 | - return null; |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - |
|
| 1606 | - |
|
| 1607 | - public function update_addon_option_names() |
|
| 1608 | - { |
|
| 1609 | - update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
| 1610 | - } |
|
| 1611 | - |
|
| 1612 | - |
|
| 1613 | - |
|
| 1614 | - public function shutdown() |
|
| 1615 | - { |
|
| 1616 | - $this->update_addon_option_names(); |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - |
|
| 1620 | -} |
|
| 1621 | - |
|
| 1622 | - |
|
| 1623 | - |
|
| 1624 | -/** |
|
| 1625 | - * Base class used for config classes. These classes should generally not have |
|
| 1626 | - * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1627 | - * basically, they should just be well-defined stdClasses |
|
| 1628 | - */ |
|
| 1629 | -class EE_Config_Base |
|
| 1630 | -{ |
|
| 1631 | - |
|
| 1632 | - /** |
|
| 1633 | - * Utility function for escaping the value of a property and returning. |
|
| 1634 | - * |
|
| 1635 | - * @param string $property property name (checks to see if exists). |
|
| 1636 | - * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1637 | - * @throws \EE_Error |
|
| 1638 | - */ |
|
| 1639 | - public function get_pretty($property) |
|
| 1640 | - { |
|
| 1641 | - if ( ! property_exists($this, $property)) { |
|
| 1642 | - throw new EE_Error( |
|
| 1643 | - sprintf( |
|
| 1644 | - __( |
|
| 1645 | - '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1646 | - 'event_espresso' |
|
| 1647 | - ), |
|
| 1648 | - get_class($this), |
|
| 1649 | - $property |
|
| 1650 | - ) |
|
| 1651 | - ); |
|
| 1652 | - } |
|
| 1653 | - //just handling escaping of strings for now. |
|
| 1654 | - if (is_string($this->{$property})) { |
|
| 1655 | - return stripslashes($this->{$property}); |
|
| 1656 | - } |
|
| 1657 | - return $this->{$property}; |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - |
|
| 1661 | - |
|
| 1662 | - public function populate() |
|
| 1663 | - { |
|
| 1664 | - //grab defaults via a new instance of this class. |
|
| 1665 | - $class_name = get_class($this); |
|
| 1666 | - $defaults = new $class_name; |
|
| 1667 | - //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1668 | - //default from our $defaults object. |
|
| 1669 | - foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1670 | - if ($this->{$property} === null) { |
|
| 1671 | - $this->{$property} = $value; |
|
| 1672 | - } |
|
| 1673 | - } |
|
| 1674 | - //cleanup |
|
| 1675 | - unset($defaults); |
|
| 1676 | - } |
|
| 1677 | - |
|
| 1678 | - |
|
| 1679 | - /** |
|
| 1680 | - * @ override magic methods |
|
| 1681 | - * @ return void |
|
| 1682 | - */ |
|
| 1683 | - // public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); } |
|
| 1684 | - // public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); } |
|
| 1685 | - /** |
|
| 1686 | - * __isset |
|
| 1687 | - * |
|
| 1688 | - * @param $a |
|
| 1689 | - * @return bool |
|
| 1690 | - */ |
|
| 1691 | - public function __isset($a) |
|
| 1692 | - { |
|
| 1693 | - return false; |
|
| 1694 | - } |
|
| 1695 | - |
|
| 1696 | - |
|
| 1697 | - |
|
| 1698 | - /** |
|
| 1699 | - * __unset |
|
| 1700 | - * |
|
| 1701 | - * @param $a |
|
| 1702 | - * @return bool |
|
| 1703 | - */ |
|
| 1704 | - public function __unset($a) |
|
| 1705 | - { |
|
| 1706 | - return false; |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - |
|
| 1710 | - |
|
| 1711 | - /** |
|
| 1712 | - * __clone |
|
| 1713 | - */ |
|
| 1714 | - public function __clone() |
|
| 1715 | - { |
|
| 1716 | - } |
|
| 1717 | - |
|
| 1718 | - |
|
| 1719 | - |
|
| 1720 | - /** |
|
| 1721 | - * __wakeup |
|
| 1722 | - */ |
|
| 1723 | - public function __wakeup() |
|
| 1724 | - { |
|
| 1725 | - } |
|
| 1726 | - |
|
| 1727 | - |
|
| 1728 | - |
|
| 1729 | - /** |
|
| 1730 | - * __destruct |
|
| 1731 | - */ |
|
| 1732 | - public function __destruct() |
|
| 1733 | - { |
|
| 1734 | - } |
|
| 1735 | -} |
|
| 1736 | - |
|
| 1737 | - |
|
| 1738 | - |
|
| 1739 | -/** |
|
| 1740 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 1741 | - */ |
|
| 1742 | -class EE_Core_Config extends EE_Config_Base |
|
| 1743 | -{ |
|
| 1744 | - |
|
| 1745 | - public $current_blog_id; |
|
| 1746 | - |
|
| 1747 | - public $ee_ueip_optin; |
|
| 1748 | - |
|
| 1749 | - public $ee_ueip_has_notified; |
|
| 1750 | - |
|
| 1751 | - /** |
|
| 1752 | - * Not to be confused with the 4 critical page variables (See |
|
| 1753 | - * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1754 | - * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1755 | - * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1756 | - * |
|
| 1757 | - * @var array |
|
| 1758 | - */ |
|
| 1759 | - public $post_shortcodes; |
|
| 1760 | - |
|
| 1761 | - public $module_route_map; |
|
| 1762 | - |
|
| 1763 | - public $module_forward_map; |
|
| 1764 | - |
|
| 1765 | - public $module_view_map; |
|
| 1766 | - |
|
| 1767 | - /** |
|
| 1768 | - * The next 4 vars are the IDs of critical EE pages. |
|
| 1769 | - * |
|
| 1770 | - * @var int |
|
| 1771 | - */ |
|
| 1772 | - public $reg_page_id; |
|
| 1773 | - |
|
| 1774 | - public $txn_page_id; |
|
| 1775 | - |
|
| 1776 | - public $thank_you_page_id; |
|
| 1777 | - |
|
| 1778 | - public $cancel_page_id; |
|
| 1779 | - |
|
| 1780 | - /** |
|
| 1781 | - * The next 4 vars are the URLs of critical EE pages. |
|
| 1782 | - * |
|
| 1783 | - * @var int |
|
| 1784 | - */ |
|
| 1785 | - public $reg_page_url; |
|
| 1786 | - |
|
| 1787 | - public $txn_page_url; |
|
| 1788 | - |
|
| 1789 | - public $thank_you_page_url; |
|
| 1790 | - |
|
| 1791 | - public $cancel_page_url; |
|
| 1792 | - |
|
| 1793 | - /** |
|
| 1794 | - * The next vars relate to the custom slugs for EE CPT routes |
|
| 1795 | - */ |
|
| 1796 | - public $event_cpt_slug; |
|
| 1797 | - |
|
| 1798 | - |
|
| 1799 | - /** |
|
| 1800 | - * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1801 | - * request across blog switches in a multisite context. |
|
| 1802 | - * Avoids extra queries to the db for this option. |
|
| 1803 | - * |
|
| 1804 | - * @var bool |
|
| 1805 | - */ |
|
| 1806 | - public static $ee_ueip_option; |
|
| 1807 | - |
|
| 1808 | - |
|
| 1809 | - |
|
| 1810 | - /** |
|
| 1811 | - * class constructor |
|
| 1812 | - * |
|
| 1813 | - * @access public |
|
| 1814 | - */ |
|
| 1815 | - public function __construct() |
|
| 1816 | - { |
|
| 1817 | - // set default organization settings |
|
| 1818 | - $this->current_blog_id = get_current_blog_id(); |
|
| 1819 | - $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1820 | - $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1821 | - $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1822 | - $this->post_shortcodes = array(); |
|
| 1823 | - $this->module_route_map = array(); |
|
| 1824 | - $this->module_forward_map = array(); |
|
| 1825 | - $this->module_view_map = array(); |
|
| 1826 | - // critical EE page IDs |
|
| 1827 | - $this->reg_page_id = 0; |
|
| 1828 | - $this->txn_page_id = 0; |
|
| 1829 | - $this->thank_you_page_id = 0; |
|
| 1830 | - $this->cancel_page_id = 0; |
|
| 1831 | - // critical EE page URLs |
|
| 1832 | - $this->reg_page_url = ''; |
|
| 1833 | - $this->txn_page_url = ''; |
|
| 1834 | - $this->thank_you_page_url = ''; |
|
| 1835 | - $this->cancel_page_url = ''; |
|
| 1836 | - //cpt slugs |
|
| 1837 | - $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1838 | - //ueip constant check |
|
| 1839 | - if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1840 | - $this->ee_ueip_optin = false; |
|
| 1841 | - $this->ee_ueip_has_notified = true; |
|
| 1842 | - } |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - |
|
| 1846 | - |
|
| 1847 | - /** |
|
| 1848 | - * @return array |
|
| 1849 | - */ |
|
| 1850 | - public function get_critical_pages_array() |
|
| 1851 | - { |
|
| 1852 | - return array( |
|
| 1853 | - $this->reg_page_id, |
|
| 1854 | - $this->txn_page_id, |
|
| 1855 | - $this->thank_you_page_id, |
|
| 1856 | - $this->cancel_page_id, |
|
| 1857 | - ); |
|
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - |
|
| 1861 | - |
|
| 1862 | - /** |
|
| 1863 | - * @return array |
|
| 1864 | - */ |
|
| 1865 | - public function get_critical_pages_shortcodes_array() |
|
| 1866 | - { |
|
| 1867 | - return array( |
|
| 1868 | - $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1869 | - $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1870 | - $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1871 | - $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1872 | - ); |
|
| 1873 | - } |
|
| 1874 | - |
|
| 1875 | - |
|
| 1876 | - |
|
| 1877 | - /** |
|
| 1878 | - * gets/returns URL for EE reg_page |
|
| 1879 | - * |
|
| 1880 | - * @access public |
|
| 1881 | - * @return string |
|
| 1882 | - */ |
|
| 1883 | - public function reg_page_url() |
|
| 1884 | - { |
|
| 1885 | - if ( ! $this->reg_page_url) { |
|
| 1886 | - $this->reg_page_url = add_query_arg( |
|
| 1887 | - array('uts' => time()), |
|
| 1888 | - get_permalink($this->reg_page_id) |
|
| 1889 | - ) . '#checkout'; |
|
| 1890 | - } |
|
| 1891 | - return $this->reg_page_url; |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - |
|
| 1895 | - |
|
| 1896 | - /** |
|
| 1897 | - * gets/returns URL for EE txn_page |
|
| 1898 | - * |
|
| 1899 | - * @param array $query_args like what gets passed to |
|
| 1900 | - * add_query_arg() as the first argument |
|
| 1901 | - * @access public |
|
| 1902 | - * @return string |
|
| 1903 | - */ |
|
| 1904 | - public function txn_page_url($query_args = array()) |
|
| 1905 | - { |
|
| 1906 | - if ( ! $this->txn_page_url) { |
|
| 1907 | - $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1908 | - } |
|
| 1909 | - if ($query_args) { |
|
| 1910 | - return add_query_arg($query_args, $this->txn_page_url); |
|
| 1911 | - } else { |
|
| 1912 | - return $this->txn_page_url; |
|
| 1913 | - } |
|
| 1914 | - } |
|
| 1915 | - |
|
| 1916 | - |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * gets/returns URL for EE thank_you_page |
|
| 1920 | - * |
|
| 1921 | - * @param array $query_args like what gets passed to |
|
| 1922 | - * add_query_arg() as the first argument |
|
| 1923 | - * @access public |
|
| 1924 | - * @return string |
|
| 1925 | - */ |
|
| 1926 | - public function thank_you_page_url($query_args = array()) |
|
| 1927 | - { |
|
| 1928 | - if ( ! $this->thank_you_page_url) { |
|
| 1929 | - $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1930 | - } |
|
| 1931 | - if ($query_args) { |
|
| 1932 | - return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1933 | - } else { |
|
| 1934 | - return $this->thank_you_page_url; |
|
| 1935 | - } |
|
| 1936 | - } |
|
| 1937 | - |
|
| 1938 | - |
|
| 1939 | - |
|
| 1940 | - /** |
|
| 1941 | - * gets/returns URL for EE cancel_page |
|
| 1942 | - * |
|
| 1943 | - * @access public |
|
| 1944 | - * @return string |
|
| 1945 | - */ |
|
| 1946 | - public function cancel_page_url() |
|
| 1947 | - { |
|
| 1948 | - if ( ! $this->cancel_page_url) { |
|
| 1949 | - $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1950 | - } |
|
| 1951 | - return $this->cancel_page_url; |
|
| 1952 | - } |
|
| 1953 | - |
|
| 1954 | - |
|
| 1955 | - |
|
| 1956 | - /** |
|
| 1957 | - * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1958 | - * |
|
| 1959 | - * @since 4.7.5 |
|
| 1960 | - */ |
|
| 1961 | - protected function _reset_urls() |
|
| 1962 | - { |
|
| 1963 | - $this->reg_page_url = ''; |
|
| 1964 | - $this->txn_page_url = ''; |
|
| 1965 | - $this->cancel_page_url = ''; |
|
| 1966 | - $this->thank_you_page_url = ''; |
|
| 1967 | - } |
|
| 1968 | - |
|
| 1969 | - |
|
| 1970 | - |
|
| 1971 | - /** |
|
| 1972 | - * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1973 | - * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1974 | - * on the main site only. |
|
| 1975 | - * |
|
| 1976 | - * @return mixed|void |
|
| 1977 | - */ |
|
| 1978 | - protected function _get_main_ee_ueip_optin() |
|
| 1979 | - { |
|
| 1980 | - //if this is the main site then we can just bypass our direct query. |
|
| 1981 | - if (is_main_site()) { |
|
| 1982 | - return get_option('ee_ueip_optin', false); |
|
| 1983 | - } |
|
| 1984 | - //is this already cached for this request? If so use it. |
|
| 1985 | - if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1986 | - return EE_Core_Config::$ee_ueip_option; |
|
| 1987 | - } |
|
| 1988 | - global $wpdb; |
|
| 1989 | - $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1990 | - $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1991 | - $option = 'ee_ueip_optin'; |
|
| 1992 | - //set correct table for query |
|
| 1993 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1994 | - //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1995 | - //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1996 | - //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1997 | - //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1998 | - //for the purpose of caching. |
|
| 1999 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 2000 | - if (false !== $pre) { |
|
| 2001 | - EE_Core_Config::$ee_ueip_option = $pre; |
|
| 2002 | - return EE_Core_Config::$ee_ueip_option; |
|
| 2003 | - } |
|
| 2004 | - $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 2005 | - $option)); |
|
| 2006 | - if (is_object($row)) { |
|
| 2007 | - $value = $row->option_value; |
|
| 2008 | - } else { //option does not exist so use default. |
|
| 2009 | - return apply_filters('default_option_' . $option, false, $option); |
|
| 2010 | - } |
|
| 2011 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 2012 | - return EE_Core_Config::$ee_ueip_option; |
|
| 2013 | - } |
|
| 2014 | - |
|
| 2015 | - |
|
| 2016 | - |
|
| 2017 | - /** |
|
| 2018 | - * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 2019 | - * on the object. |
|
| 2020 | - * |
|
| 2021 | - * @return array |
|
| 2022 | - */ |
|
| 2023 | - public function __sleep() |
|
| 2024 | - { |
|
| 2025 | - //reset all url properties |
|
| 2026 | - $this->_reset_urls(); |
|
| 2027 | - //return what to save to db |
|
| 2028 | - return array_keys(get_object_vars($this)); |
|
| 2029 | - } |
|
| 2030 | - |
|
| 2031 | -} |
|
| 2032 | - |
|
| 2033 | - |
|
| 2034 | - |
|
| 2035 | -/** |
|
| 2036 | - * Config class for storing info on the Organization |
|
| 2037 | - */ |
|
| 2038 | -class EE_Organization_Config extends EE_Config_Base |
|
| 2039 | -{ |
|
| 2040 | - |
|
| 2041 | - /** |
|
| 2042 | - * @var string $name |
|
| 2043 | - * eg EE4.1 |
|
| 2044 | - */ |
|
| 2045 | - public $name; |
|
| 2046 | - |
|
| 2047 | - /** |
|
| 2048 | - * @var string $address_1 |
|
| 2049 | - * eg 123 Onna Road |
|
| 2050 | - */ |
|
| 2051 | - public $address_1; |
|
| 2052 | - |
|
| 2053 | - /** |
|
| 2054 | - * @var string $address_2 |
|
| 2055 | - * eg PO Box 123 |
|
| 2056 | - */ |
|
| 2057 | - public $address_2; |
|
| 2058 | - |
|
| 2059 | - /** |
|
| 2060 | - * @var string $city |
|
| 2061 | - * eg Inna City |
|
| 2062 | - */ |
|
| 2063 | - public $city; |
|
| 2064 | - |
|
| 2065 | - /** |
|
| 2066 | - * @var int $STA_ID |
|
| 2067 | - * eg 4 |
|
| 2068 | - */ |
|
| 2069 | - public $STA_ID; |
|
| 2070 | - |
|
| 2071 | - /** |
|
| 2072 | - * @var string $CNT_ISO |
|
| 2073 | - * eg US |
|
| 2074 | - */ |
|
| 2075 | - public $CNT_ISO; |
|
| 2076 | - |
|
| 2077 | - /** |
|
| 2078 | - * @var string $zip |
|
| 2079 | - * eg 12345 or V1A 2B3 |
|
| 2080 | - */ |
|
| 2081 | - public $zip; |
|
| 2082 | - |
|
| 2083 | - /** |
|
| 2084 | - * @var string $email |
|
| 2085 | - * eg [email protected] |
|
| 2086 | - */ |
|
| 2087 | - public $email; |
|
| 2088 | - |
|
| 2089 | - |
|
| 2090 | - /** |
|
| 2091 | - * @var string $phone |
|
| 2092 | - * eg. 111-111-1111 |
|
| 2093 | - */ |
|
| 2094 | - public $phone; |
|
| 2095 | - |
|
| 2096 | - |
|
| 2097 | - /** |
|
| 2098 | - * @var string $vat |
|
| 2099 | - * VAT/Tax Number |
|
| 2100 | - */ |
|
| 2101 | - public $vat; |
|
| 2102 | - |
|
| 2103 | - /** |
|
| 2104 | - * @var string $logo_url |
|
| 2105 | - * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2106 | - */ |
|
| 2107 | - public $logo_url; |
|
| 2108 | - |
|
| 2109 | - |
|
| 2110 | - /** |
|
| 2111 | - * The below are all various properties for holding links to organization social network profiles |
|
| 2112 | - * |
|
| 2113 | - * @var string |
|
| 2114 | - */ |
|
| 2115 | - /** |
|
| 2116 | - * facebook (facebook.com/profile.name) |
|
| 2117 | - * |
|
| 2118 | - * @var string |
|
| 2119 | - */ |
|
| 2120 | - public $facebook; |
|
| 2121 | - |
|
| 2122 | - |
|
| 2123 | - /** |
|
| 2124 | - * twitter (twitter.com/twitter_handle) |
|
| 2125 | - * |
|
| 2126 | - * @var string |
|
| 2127 | - */ |
|
| 2128 | - public $twitter; |
|
| 2129 | - |
|
| 2130 | - |
|
| 2131 | - /** |
|
| 2132 | - * linkedin (linkedin.com/in/profile_name) |
|
| 2133 | - * |
|
| 2134 | - * @var string |
|
| 2135 | - */ |
|
| 2136 | - public $linkedin; |
|
| 2137 | - |
|
| 2138 | - |
|
| 2139 | - /** |
|
| 2140 | - * pinterest (www.pinterest.com/profile_name) |
|
| 2141 | - * |
|
| 2142 | - * @var string |
|
| 2143 | - */ |
|
| 2144 | - public $pinterest; |
|
| 2145 | - |
|
| 2146 | - |
|
| 2147 | - /** |
|
| 2148 | - * google+ (google.com/+profileName) |
|
| 2149 | - * |
|
| 2150 | - * @var string |
|
| 2151 | - */ |
|
| 2152 | - public $google; |
|
| 2153 | - |
|
| 2154 | - |
|
| 2155 | - /** |
|
| 2156 | - * instagram (instagram.com/handle) |
|
| 2157 | - * |
|
| 2158 | - * @var string |
|
| 2159 | - */ |
|
| 2160 | - public $instagram; |
|
| 2161 | - |
|
| 2162 | - |
|
| 2163 | - |
|
| 2164 | - /** |
|
| 2165 | - * class constructor |
|
| 2166 | - * |
|
| 2167 | - * @access public |
|
| 2168 | - */ |
|
| 2169 | - public function __construct() |
|
| 2170 | - { |
|
| 2171 | - // set default organization settings |
|
| 2172 | - $this->name = get_bloginfo('name'); |
|
| 2173 | - $this->address_1 = '123 Onna Road'; |
|
| 2174 | - $this->address_2 = 'PO Box 123'; |
|
| 2175 | - $this->city = 'Inna City'; |
|
| 2176 | - $this->STA_ID = 4; |
|
| 2177 | - $this->CNT_ISO = 'US'; |
|
| 2178 | - $this->zip = '12345'; |
|
| 2179 | - $this->email = get_bloginfo('admin_email'); |
|
| 2180 | - $this->phone = ''; |
|
| 2181 | - $this->vat = '123456789'; |
|
| 2182 | - $this->logo_url = ''; |
|
| 2183 | - $this->facebook = ''; |
|
| 2184 | - $this->twitter = ''; |
|
| 2185 | - $this->linkedin = ''; |
|
| 2186 | - $this->pinterest = ''; |
|
| 2187 | - $this->google = ''; |
|
| 2188 | - $this->instagram = ''; |
|
| 2189 | - } |
|
| 2190 | - |
|
| 2191 | -} |
|
| 2192 | - |
|
| 2193 | - |
|
| 2194 | - |
|
| 2195 | -/** |
|
| 2196 | - * Class for defining what's in the EE_Config relating to currency |
|
| 2197 | - */ |
|
| 2198 | -class EE_Currency_Config extends EE_Config_Base |
|
| 2199 | -{ |
|
| 2200 | - |
|
| 2201 | - /** |
|
| 2202 | - * @var string $code |
|
| 2203 | - * eg 'US' |
|
| 2204 | - */ |
|
| 2205 | - public $code; |
|
| 2206 | - |
|
| 2207 | - /** |
|
| 2208 | - * @var string $name |
|
| 2209 | - * eg 'Dollar' |
|
| 2210 | - */ |
|
| 2211 | - public $name; |
|
| 2212 | - |
|
| 2213 | - /** |
|
| 2214 | - * plural name |
|
| 2215 | - * |
|
| 2216 | - * @var string $plural |
|
| 2217 | - * eg 'Dollars' |
|
| 2218 | - */ |
|
| 2219 | - public $plural; |
|
| 2220 | - |
|
| 2221 | - /** |
|
| 2222 | - * currency sign |
|
| 2223 | - * |
|
| 2224 | - * @var string $sign |
|
| 2225 | - * eg '$' |
|
| 2226 | - */ |
|
| 2227 | - public $sign; |
|
| 2228 | - |
|
| 2229 | - /** |
|
| 2230 | - * Whether the currency sign should come before the number or not |
|
| 2231 | - * |
|
| 2232 | - * @var boolean $sign_b4 |
|
| 2233 | - */ |
|
| 2234 | - public $sign_b4; |
|
| 2235 | - |
|
| 2236 | - /** |
|
| 2237 | - * How many digits should come after the decimal place |
|
| 2238 | - * |
|
| 2239 | - * @var int $dec_plc |
|
| 2240 | - */ |
|
| 2241 | - public $dec_plc; |
|
| 2242 | - |
|
| 2243 | - /** |
|
| 2244 | - * Symbol to use for decimal mark |
|
| 2245 | - * |
|
| 2246 | - * @var string $dec_mrk |
|
| 2247 | - * eg '.' |
|
| 2248 | - */ |
|
| 2249 | - public $dec_mrk; |
|
| 2250 | - |
|
| 2251 | - /** |
|
| 2252 | - * Symbol to use for thousands |
|
| 2253 | - * |
|
| 2254 | - * @var string $thsnds |
|
| 2255 | - * eg ',' |
|
| 2256 | - */ |
|
| 2257 | - public $thsnds; |
|
| 2258 | - |
|
| 2259 | - |
|
| 2260 | - |
|
| 2261 | - /** |
|
| 2262 | - * class constructor |
|
| 2263 | - * |
|
| 2264 | - * @access public |
|
| 2265 | - * @param string $CNT_ISO |
|
| 2266 | - * @throws \EE_Error |
|
| 2267 | - */ |
|
| 2268 | - public function __construct($CNT_ISO = '') |
|
| 2269 | - { |
|
| 2270 | - /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2271 | - $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2272 | - // get country code from organization settings or use default |
|
| 2273 | - $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2274 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2275 | - ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2276 | - : ''; |
|
| 2277 | - // but override if requested |
|
| 2278 | - $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2279 | - // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2280 | - if ( |
|
| 2281 | - ! empty($CNT_ISO) |
|
| 2282 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2283 | - && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2284 | - ) { |
|
| 2285 | - // retrieve the country settings from the db, just in case they have been customized |
|
| 2286 | - $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2287 | - if ($country instanceof EE_Country) { |
|
| 2288 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2289 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2290 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2291 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2292 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2293 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2294 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2295 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2296 | - } |
|
| 2297 | - } |
|
| 2298 | - // fallback to hardcoded defaults, in case the above failed |
|
| 2299 | - if (empty($this->code)) { |
|
| 2300 | - // set default currency settings |
|
| 2301 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2302 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2303 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2304 | - $this->sign = '$'; // currency sign: $ |
|
| 2305 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2306 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2307 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2308 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2309 | - } |
|
| 2310 | - } |
|
| 2311 | 1620 | } |
| 2312 | 1621 | |
| 2313 | 1622 | |
| 2314 | 1623 | |
| 2315 | 1624 | /** |
| 2316 | - * Class for defining what's in the EE_Config relating to registration settings |
|
| 1625 | + * Base class used for config classes. These classes should generally not have |
|
| 1626 | + * magic functions in use, except we'll allow them to magically set and get stuff... |
|
| 1627 | + * basically, they should just be well-defined stdClasses |
|
| 2317 | 1628 | */ |
| 2318 | -class EE_Registration_Config extends EE_Config_Base |
|
| 1629 | +class EE_Config_Base |
|
| 2319 | 1630 | { |
| 2320 | 1631 | |
| 2321 | - /** |
|
| 2322 | - * Default registration status |
|
| 2323 | - * |
|
| 2324 | - * @var string $default_STS_ID |
|
| 2325 | - * eg 'RPP' |
|
| 2326 | - */ |
|
| 2327 | - public $default_STS_ID; |
|
| 2328 | - |
|
| 2329 | - /** |
|
| 2330 | - * level of validation to apply to email addresses |
|
| 2331 | - * |
|
| 2332 | - * @var string $email_validation_level |
|
| 2333 | - * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2334 | - */ |
|
| 2335 | - public $email_validation_level; |
|
| 2336 | - |
|
| 2337 | - /** |
|
| 2338 | - * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2339 | - * |
|
| 2340 | - * @var boolean $show_pending_payment_options |
|
| 2341 | - */ |
|
| 2342 | - public $show_pending_payment_options; |
|
| 2343 | - |
|
| 2344 | - /** |
|
| 2345 | - * Whether to skip the registration confirmation page |
|
| 2346 | - * |
|
| 2347 | - * @var boolean $skip_reg_confirmation |
|
| 2348 | - */ |
|
| 2349 | - public $skip_reg_confirmation; |
|
| 2350 | - |
|
| 2351 | - /** |
|
| 2352 | - * an array of SPCO reg steps where: |
|
| 2353 | - * the keys denotes the reg step order |
|
| 2354 | - * each element consists of an array with the following elements: |
|
| 2355 | - * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2356 | - * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2357 | - * "slug" => the URL param used to trigger the reg step |
|
| 2358 | - * |
|
| 2359 | - * @var array $reg_steps |
|
| 2360 | - */ |
|
| 2361 | - public $reg_steps; |
|
| 2362 | - |
|
| 2363 | - /** |
|
| 2364 | - * Whether registration confirmation should be the last page of SPCO |
|
| 2365 | - * |
|
| 2366 | - * @var boolean $reg_confirmation_last |
|
| 2367 | - */ |
|
| 2368 | - public $reg_confirmation_last; |
|
| 2369 | - |
|
| 2370 | - /** |
|
| 2371 | - * Whether or not to enable the EE Bot Trap |
|
| 2372 | - * |
|
| 2373 | - * @var boolean $use_bot_trap |
|
| 2374 | - */ |
|
| 2375 | - public $use_bot_trap; |
|
| 2376 | - |
|
| 2377 | - /** |
|
| 2378 | - * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2379 | - * |
|
| 2380 | - * @var boolean $use_encryption |
|
| 2381 | - */ |
|
| 2382 | - public $use_encryption; |
|
| 2383 | - |
|
| 2384 | - /** |
|
| 2385 | - * Whether or not to use ReCaptcha |
|
| 2386 | - * |
|
| 2387 | - * @var boolean $use_captcha |
|
| 2388 | - */ |
|
| 2389 | - public $use_captcha; |
|
| 2390 | - |
|
| 2391 | - /** |
|
| 2392 | - * ReCaptcha Theme |
|
| 2393 | - * |
|
| 2394 | - * @var string $recaptcha_theme |
|
| 2395 | - * options: 'dark ', 'light' |
|
| 2396 | - */ |
|
| 2397 | - public $recaptcha_theme; |
|
| 1632 | + /** |
|
| 1633 | + * Utility function for escaping the value of a property and returning. |
|
| 1634 | + * |
|
| 1635 | + * @param string $property property name (checks to see if exists). |
|
| 1636 | + * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
|
| 1637 | + * @throws \EE_Error |
|
| 1638 | + */ |
|
| 1639 | + public function get_pretty($property) |
|
| 1640 | + { |
|
| 1641 | + if ( ! property_exists($this, $property)) { |
|
| 1642 | + throw new EE_Error( |
|
| 1643 | + sprintf( |
|
| 1644 | + __( |
|
| 1645 | + '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
|
| 1646 | + 'event_espresso' |
|
| 1647 | + ), |
|
| 1648 | + get_class($this), |
|
| 1649 | + $property |
|
| 1650 | + ) |
|
| 1651 | + ); |
|
| 1652 | + } |
|
| 1653 | + //just handling escaping of strings for now. |
|
| 1654 | + if (is_string($this->{$property})) { |
|
| 1655 | + return stripslashes($this->{$property}); |
|
| 1656 | + } |
|
| 1657 | + return $this->{$property}; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + |
|
| 1661 | + |
|
| 1662 | + public function populate() |
|
| 1663 | + { |
|
| 1664 | + //grab defaults via a new instance of this class. |
|
| 1665 | + $class_name = get_class($this); |
|
| 1666 | + $defaults = new $class_name; |
|
| 1667 | + //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
|
| 1668 | + //default from our $defaults object. |
|
| 1669 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
| 1670 | + if ($this->{$property} === null) { |
|
| 1671 | + $this->{$property} = $value; |
|
| 1672 | + } |
|
| 1673 | + } |
|
| 1674 | + //cleanup |
|
| 1675 | + unset($defaults); |
|
| 1676 | + } |
|
| 1677 | + |
|
| 1678 | + |
|
| 1679 | + /** |
|
| 1680 | + * @ override magic methods |
|
| 1681 | + * @ return void |
|
| 1682 | + */ |
|
| 1683 | + // public function __get($a) { return apply_filters('FHEE__'.get_class($this).'__get__'.$a,$this->{$a}); } |
|
| 1684 | + // public function __set($a,$b) { return apply_filters('FHEE__'.get_class($this).'__set__'.$a, $this->{$a} = $b ); } |
|
| 1685 | + /** |
|
| 1686 | + * __isset |
|
| 1687 | + * |
|
| 1688 | + * @param $a |
|
| 1689 | + * @return bool |
|
| 1690 | + */ |
|
| 1691 | + public function __isset($a) |
|
| 1692 | + { |
|
| 1693 | + return false; |
|
| 1694 | + } |
|
| 1695 | + |
|
| 1696 | + |
|
| 1697 | + |
|
| 1698 | + /** |
|
| 1699 | + * __unset |
|
| 1700 | + * |
|
| 1701 | + * @param $a |
|
| 1702 | + * @return bool |
|
| 1703 | + */ |
|
| 1704 | + public function __unset($a) |
|
| 1705 | + { |
|
| 1706 | + return false; |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + |
|
| 1710 | + |
|
| 1711 | + /** |
|
| 1712 | + * __clone |
|
| 1713 | + */ |
|
| 1714 | + public function __clone() |
|
| 1715 | + { |
|
| 1716 | + } |
|
| 1717 | + |
|
| 1718 | + |
|
| 1719 | + |
|
| 1720 | + /** |
|
| 1721 | + * __wakeup |
|
| 1722 | + */ |
|
| 1723 | + public function __wakeup() |
|
| 1724 | + { |
|
| 1725 | + } |
|
| 1726 | + |
|
| 1727 | + |
|
| 1728 | + |
|
| 1729 | + /** |
|
| 1730 | + * __destruct |
|
| 1731 | + */ |
|
| 1732 | + public function __destruct() |
|
| 1733 | + { |
|
| 1734 | + } |
|
| 1735 | +} |
|
| 2398 | 1736 | |
| 2399 | - /** |
|
| 2400 | - * ReCaptcha Type |
|
| 2401 | - * |
|
| 2402 | - * @var string $recaptcha_type |
|
| 2403 | - * options: 'audio', 'image' |
|
| 2404 | - */ |
|
| 2405 | - public $recaptcha_type; |
|
| 2406 | 1737 | |
| 2407 | - /** |
|
| 2408 | - * ReCaptcha language |
|
| 2409 | - * |
|
| 2410 | - * @var string $recaptcha_language |
|
| 2411 | - * eg 'en' |
|
| 2412 | - */ |
|
| 2413 | - public $recaptcha_language; |
|
| 2414 | 1738 | |
| 2415 | - /** |
|
| 2416 | - * ReCaptcha public key |
|
| 2417 | - * |
|
| 2418 | - * @var string $recaptcha_publickey |
|
| 2419 | - */ |
|
| 2420 | - public $recaptcha_publickey; |
|
| 1739 | +/** |
|
| 1740 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 1741 | + */ |
|
| 1742 | +class EE_Core_Config extends EE_Config_Base |
|
| 1743 | +{ |
|
| 2421 | 1744 | |
| 2422 | - /** |
|
| 2423 | - * ReCaptcha private key |
|
| 2424 | - * |
|
| 2425 | - * @var string $recaptcha_privatekey |
|
| 2426 | - */ |
|
| 2427 | - public $recaptcha_privatekey; |
|
| 1745 | + public $current_blog_id; |
|
| 1746 | + |
|
| 1747 | + public $ee_ueip_optin; |
|
| 1748 | + |
|
| 1749 | + public $ee_ueip_has_notified; |
|
| 1750 | + |
|
| 1751 | + /** |
|
| 1752 | + * Not to be confused with the 4 critical page variables (See |
|
| 1753 | + * get_critical_pages_array()), this is just an array of wp posts that have EE |
|
| 1754 | + * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode |
|
| 1755 | + * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array. |
|
| 1756 | + * |
|
| 1757 | + * @var array |
|
| 1758 | + */ |
|
| 1759 | + public $post_shortcodes; |
|
| 1760 | + |
|
| 1761 | + public $module_route_map; |
|
| 1762 | + |
|
| 1763 | + public $module_forward_map; |
|
| 1764 | + |
|
| 1765 | + public $module_view_map; |
|
| 1766 | + |
|
| 1767 | + /** |
|
| 1768 | + * The next 4 vars are the IDs of critical EE pages. |
|
| 1769 | + * |
|
| 1770 | + * @var int |
|
| 1771 | + */ |
|
| 1772 | + public $reg_page_id; |
|
| 1773 | + |
|
| 1774 | + public $txn_page_id; |
|
| 1775 | + |
|
| 1776 | + public $thank_you_page_id; |
|
| 1777 | + |
|
| 1778 | + public $cancel_page_id; |
|
| 1779 | + |
|
| 1780 | + /** |
|
| 1781 | + * The next 4 vars are the URLs of critical EE pages. |
|
| 1782 | + * |
|
| 1783 | + * @var int |
|
| 1784 | + */ |
|
| 1785 | + public $reg_page_url; |
|
| 1786 | + |
|
| 1787 | + public $txn_page_url; |
|
| 1788 | + |
|
| 1789 | + public $thank_you_page_url; |
|
| 1790 | + |
|
| 1791 | + public $cancel_page_url; |
|
| 1792 | + |
|
| 1793 | + /** |
|
| 1794 | + * The next vars relate to the custom slugs for EE CPT routes |
|
| 1795 | + */ |
|
| 1796 | + public $event_cpt_slug; |
|
| 1797 | + |
|
| 1798 | + |
|
| 1799 | + /** |
|
| 1800 | + * This caches the _ee_ueip_option in case this config is reset in the same |
|
| 1801 | + * request across blog switches in a multisite context. |
|
| 1802 | + * Avoids extra queries to the db for this option. |
|
| 1803 | + * |
|
| 1804 | + * @var bool |
|
| 1805 | + */ |
|
| 1806 | + public static $ee_ueip_option; |
|
| 1807 | + |
|
| 1808 | + |
|
| 1809 | + |
|
| 1810 | + /** |
|
| 1811 | + * class constructor |
|
| 1812 | + * |
|
| 1813 | + * @access public |
|
| 1814 | + */ |
|
| 1815 | + public function __construct() |
|
| 1816 | + { |
|
| 1817 | + // set default organization settings |
|
| 1818 | + $this->current_blog_id = get_current_blog_id(); |
|
| 1819 | + $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id; |
|
| 1820 | + $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
|
| 1821 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
| 1822 | + $this->post_shortcodes = array(); |
|
| 1823 | + $this->module_route_map = array(); |
|
| 1824 | + $this->module_forward_map = array(); |
|
| 1825 | + $this->module_view_map = array(); |
|
| 1826 | + // critical EE page IDs |
|
| 1827 | + $this->reg_page_id = 0; |
|
| 1828 | + $this->txn_page_id = 0; |
|
| 1829 | + $this->thank_you_page_id = 0; |
|
| 1830 | + $this->cancel_page_id = 0; |
|
| 1831 | + // critical EE page URLs |
|
| 1832 | + $this->reg_page_url = ''; |
|
| 1833 | + $this->txn_page_url = ''; |
|
| 1834 | + $this->thank_you_page_url = ''; |
|
| 1835 | + $this->cancel_page_url = ''; |
|
| 1836 | + //cpt slugs |
|
| 1837 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
| 1838 | + //ueip constant check |
|
| 1839 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
| 1840 | + $this->ee_ueip_optin = false; |
|
| 1841 | + $this->ee_ueip_has_notified = true; |
|
| 1842 | + } |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + |
|
| 1846 | + |
|
| 1847 | + /** |
|
| 1848 | + * @return array |
|
| 1849 | + */ |
|
| 1850 | + public function get_critical_pages_array() |
|
| 1851 | + { |
|
| 1852 | + return array( |
|
| 1853 | + $this->reg_page_id, |
|
| 1854 | + $this->txn_page_id, |
|
| 1855 | + $this->thank_you_page_id, |
|
| 1856 | + $this->cancel_page_id, |
|
| 1857 | + ); |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + |
|
| 1861 | + |
|
| 1862 | + /** |
|
| 1863 | + * @return array |
|
| 1864 | + */ |
|
| 1865 | + public function get_critical_pages_shortcodes_array() |
|
| 1866 | + { |
|
| 1867 | + return array( |
|
| 1868 | + $this->reg_page_id => 'ESPRESSO_CHECKOUT', |
|
| 1869 | + $this->txn_page_id => 'ESPRESSO_TXN_PAGE', |
|
| 1870 | + $this->thank_you_page_id => 'ESPRESSO_THANK_YOU', |
|
| 1871 | + $this->cancel_page_id => 'ESPRESSO_CANCELLED', |
|
| 1872 | + ); |
|
| 1873 | + } |
|
| 1874 | + |
|
| 1875 | + |
|
| 1876 | + |
|
| 1877 | + /** |
|
| 1878 | + * gets/returns URL for EE reg_page |
|
| 1879 | + * |
|
| 1880 | + * @access public |
|
| 1881 | + * @return string |
|
| 1882 | + */ |
|
| 1883 | + public function reg_page_url() |
|
| 1884 | + { |
|
| 1885 | + if ( ! $this->reg_page_url) { |
|
| 1886 | + $this->reg_page_url = add_query_arg( |
|
| 1887 | + array('uts' => time()), |
|
| 1888 | + get_permalink($this->reg_page_id) |
|
| 1889 | + ) . '#checkout'; |
|
| 1890 | + } |
|
| 1891 | + return $this->reg_page_url; |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + |
|
| 1895 | + |
|
| 1896 | + /** |
|
| 1897 | + * gets/returns URL for EE txn_page |
|
| 1898 | + * |
|
| 1899 | + * @param array $query_args like what gets passed to |
|
| 1900 | + * add_query_arg() as the first argument |
|
| 1901 | + * @access public |
|
| 1902 | + * @return string |
|
| 1903 | + */ |
|
| 1904 | + public function txn_page_url($query_args = array()) |
|
| 1905 | + { |
|
| 1906 | + if ( ! $this->txn_page_url) { |
|
| 1907 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
| 1908 | + } |
|
| 1909 | + if ($query_args) { |
|
| 1910 | + return add_query_arg($query_args, $this->txn_page_url); |
|
| 1911 | + } else { |
|
| 1912 | + return $this->txn_page_url; |
|
| 1913 | + } |
|
| 1914 | + } |
|
| 1915 | + |
|
| 1916 | + |
|
| 1917 | + |
|
| 1918 | + /** |
|
| 1919 | + * gets/returns URL for EE thank_you_page |
|
| 1920 | + * |
|
| 1921 | + * @param array $query_args like what gets passed to |
|
| 1922 | + * add_query_arg() as the first argument |
|
| 1923 | + * @access public |
|
| 1924 | + * @return string |
|
| 1925 | + */ |
|
| 1926 | + public function thank_you_page_url($query_args = array()) |
|
| 1927 | + { |
|
| 1928 | + if ( ! $this->thank_you_page_url) { |
|
| 1929 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
| 1930 | + } |
|
| 1931 | + if ($query_args) { |
|
| 1932 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
| 1933 | + } else { |
|
| 1934 | + return $this->thank_you_page_url; |
|
| 1935 | + } |
|
| 1936 | + } |
|
| 1937 | + |
|
| 1938 | + |
|
| 1939 | + |
|
| 1940 | + /** |
|
| 1941 | + * gets/returns URL for EE cancel_page |
|
| 1942 | + * |
|
| 1943 | + * @access public |
|
| 1944 | + * @return string |
|
| 1945 | + */ |
|
| 1946 | + public function cancel_page_url() |
|
| 1947 | + { |
|
| 1948 | + if ( ! $this->cancel_page_url) { |
|
| 1949 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
| 1950 | + } |
|
| 1951 | + return $this->cancel_page_url; |
|
| 1952 | + } |
|
| 1953 | + |
|
| 1954 | + |
|
| 1955 | + |
|
| 1956 | + /** |
|
| 1957 | + * Resets all critical page urls to their original state. Used primarily by the __sleep() magic method currently. |
|
| 1958 | + * |
|
| 1959 | + * @since 4.7.5 |
|
| 1960 | + */ |
|
| 1961 | + protected function _reset_urls() |
|
| 1962 | + { |
|
| 1963 | + $this->reg_page_url = ''; |
|
| 1964 | + $this->txn_page_url = ''; |
|
| 1965 | + $this->cancel_page_url = ''; |
|
| 1966 | + $this->thank_you_page_url = ''; |
|
| 1967 | + } |
|
| 1968 | + |
|
| 1969 | + |
|
| 1970 | + |
|
| 1971 | + /** |
|
| 1972 | + * Used to return what the optin value is set for the EE User Experience Program. |
|
| 1973 | + * This accounts for multisite and this value being requested for a subsite. In multisite, the value is set |
|
| 1974 | + * on the main site only. |
|
| 1975 | + * |
|
| 1976 | + * @return mixed|void |
|
| 1977 | + */ |
|
| 1978 | + protected function _get_main_ee_ueip_optin() |
|
| 1979 | + { |
|
| 1980 | + //if this is the main site then we can just bypass our direct query. |
|
| 1981 | + if (is_main_site()) { |
|
| 1982 | + return get_option('ee_ueip_optin', false); |
|
| 1983 | + } |
|
| 1984 | + //is this already cached for this request? If so use it. |
|
| 1985 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
| 1986 | + return EE_Core_Config::$ee_ueip_option; |
|
| 1987 | + } |
|
| 1988 | + global $wpdb; |
|
| 1989 | + $current_network_main_site = is_multisite() ? get_current_site() : null; |
|
| 1990 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
| 1991 | + $option = 'ee_ueip_optin'; |
|
| 1992 | + //set correct table for query |
|
| 1993 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1994 | + //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
|
| 1995 | + //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
|
| 1996 | + //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
|
| 1997 | + //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
|
| 1998 | + //for the purpose of caching. |
|
| 1999 | + $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 2000 | + if (false !== $pre) { |
|
| 2001 | + EE_Core_Config::$ee_ueip_option = $pre; |
|
| 2002 | + return EE_Core_Config::$ee_ueip_option; |
|
| 2003 | + } |
|
| 2004 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", |
|
| 2005 | + $option)); |
|
| 2006 | + if (is_object($row)) { |
|
| 2007 | + $value = $row->option_value; |
|
| 2008 | + } else { //option does not exist so use default. |
|
| 2009 | + return apply_filters('default_option_' . $option, false, $option); |
|
| 2010 | + } |
|
| 2011 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 2012 | + return EE_Core_Config::$ee_ueip_option; |
|
| 2013 | + } |
|
| 2014 | + |
|
| 2015 | + |
|
| 2016 | + |
|
| 2017 | + /** |
|
| 2018 | + * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values |
|
| 2019 | + * on the object. |
|
| 2020 | + * |
|
| 2021 | + * @return array |
|
| 2022 | + */ |
|
| 2023 | + public function __sleep() |
|
| 2024 | + { |
|
| 2025 | + //reset all url properties |
|
| 2026 | + $this->_reset_urls(); |
|
| 2027 | + //return what to save to db |
|
| 2028 | + return array_keys(get_object_vars($this)); |
|
| 2029 | + } |
|
| 2428 | 2030 | |
| 2429 | - /** |
|
| 2430 | - * ReCaptcha width |
|
| 2431 | - * |
|
| 2432 | - * @var int $recaptcha_width |
|
| 2433 | - * @deprecated |
|
| 2434 | - */ |
|
| 2435 | - public $recaptcha_width; |
|
| 2031 | +} |
|
| 2436 | 2032 | |
| 2437 | - /** |
|
| 2438 | - * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2439 | - * |
|
| 2440 | - * @var boolean $track_invalid_checkout_access |
|
| 2441 | - */ |
|
| 2442 | - protected $track_invalid_checkout_access = true; |
|
| 2443 | 2033 | |
| 2444 | 2034 | |
| 2035 | +/** |
|
| 2036 | + * Config class for storing info on the Organization |
|
| 2037 | + */ |
|
| 2038 | +class EE_Organization_Config extends EE_Config_Base |
|
| 2039 | +{ |
|
| 2445 | 2040 | |
| 2446 | - /** |
|
| 2447 | - * class constructor |
|
| 2448 | - * |
|
| 2449 | - * @access public |
|
| 2450 | - */ |
|
| 2451 | - public function __construct() |
|
| 2452 | - { |
|
| 2453 | - // set default registration settings |
|
| 2454 | - $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2455 | - $this->email_validation_level = 'wp_default'; |
|
| 2456 | - $this->show_pending_payment_options = true; |
|
| 2457 | - $this->skip_reg_confirmation = false; |
|
| 2458 | - $this->reg_steps = array(); |
|
| 2459 | - $this->reg_confirmation_last = false; |
|
| 2460 | - $this->use_bot_trap = true; |
|
| 2461 | - $this->use_encryption = true; |
|
| 2462 | - $this->use_captcha = false; |
|
| 2463 | - $this->recaptcha_theme = 'light'; |
|
| 2464 | - $this->recaptcha_type = 'image'; |
|
| 2465 | - $this->recaptcha_language = 'en'; |
|
| 2466 | - $this->recaptcha_publickey = null; |
|
| 2467 | - $this->recaptcha_privatekey = null; |
|
| 2468 | - $this->recaptcha_width = 500; |
|
| 2469 | - } |
|
| 2470 | - |
|
| 2471 | - |
|
| 2472 | - |
|
| 2473 | - /** |
|
| 2474 | - * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2475 | - * |
|
| 2476 | - * @since 4.8.8.rc.019 |
|
| 2477 | - */ |
|
| 2478 | - public function do_hooks() |
|
| 2479 | - { |
|
| 2480 | - add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2481 | - } |
|
| 2041 | + /** |
|
| 2042 | + * @var string $name |
|
| 2043 | + * eg EE4.1 |
|
| 2044 | + */ |
|
| 2045 | + public $name; |
|
| 2046 | + |
|
| 2047 | + /** |
|
| 2048 | + * @var string $address_1 |
|
| 2049 | + * eg 123 Onna Road |
|
| 2050 | + */ |
|
| 2051 | + public $address_1; |
|
| 2052 | + |
|
| 2053 | + /** |
|
| 2054 | + * @var string $address_2 |
|
| 2055 | + * eg PO Box 123 |
|
| 2056 | + */ |
|
| 2057 | + public $address_2; |
|
| 2058 | + |
|
| 2059 | + /** |
|
| 2060 | + * @var string $city |
|
| 2061 | + * eg Inna City |
|
| 2062 | + */ |
|
| 2063 | + public $city; |
|
| 2064 | + |
|
| 2065 | + /** |
|
| 2066 | + * @var int $STA_ID |
|
| 2067 | + * eg 4 |
|
| 2068 | + */ |
|
| 2069 | + public $STA_ID; |
|
| 2070 | + |
|
| 2071 | + /** |
|
| 2072 | + * @var string $CNT_ISO |
|
| 2073 | + * eg US |
|
| 2074 | + */ |
|
| 2075 | + public $CNT_ISO; |
|
| 2076 | + |
|
| 2077 | + /** |
|
| 2078 | + * @var string $zip |
|
| 2079 | + * eg 12345 or V1A 2B3 |
|
| 2080 | + */ |
|
| 2081 | + public $zip; |
|
| 2082 | + |
|
| 2083 | + /** |
|
| 2084 | + * @var string $email |
|
| 2085 | + * eg [email protected] |
|
| 2086 | + */ |
|
| 2087 | + public $email; |
|
| 2088 | + |
|
| 2089 | + |
|
| 2090 | + /** |
|
| 2091 | + * @var string $phone |
|
| 2092 | + * eg. 111-111-1111 |
|
| 2093 | + */ |
|
| 2094 | + public $phone; |
|
| 2095 | + |
|
| 2096 | + |
|
| 2097 | + /** |
|
| 2098 | + * @var string $vat |
|
| 2099 | + * VAT/Tax Number |
|
| 2100 | + */ |
|
| 2101 | + public $vat; |
|
| 2102 | + |
|
| 2103 | + /** |
|
| 2104 | + * @var string $logo_url |
|
| 2105 | + * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg |
|
| 2106 | + */ |
|
| 2107 | + public $logo_url; |
|
| 2108 | + |
|
| 2109 | + |
|
| 2110 | + /** |
|
| 2111 | + * The below are all various properties for holding links to organization social network profiles |
|
| 2112 | + * |
|
| 2113 | + * @var string |
|
| 2114 | + */ |
|
| 2115 | + /** |
|
| 2116 | + * facebook (facebook.com/profile.name) |
|
| 2117 | + * |
|
| 2118 | + * @var string |
|
| 2119 | + */ |
|
| 2120 | + public $facebook; |
|
| 2121 | + |
|
| 2122 | + |
|
| 2123 | + /** |
|
| 2124 | + * twitter (twitter.com/twitter_handle) |
|
| 2125 | + * |
|
| 2126 | + * @var string |
|
| 2127 | + */ |
|
| 2128 | + public $twitter; |
|
| 2129 | + |
|
| 2130 | + |
|
| 2131 | + /** |
|
| 2132 | + * linkedin (linkedin.com/in/profile_name) |
|
| 2133 | + * |
|
| 2134 | + * @var string |
|
| 2135 | + */ |
|
| 2136 | + public $linkedin; |
|
| 2137 | + |
|
| 2138 | + |
|
| 2139 | + /** |
|
| 2140 | + * pinterest (www.pinterest.com/profile_name) |
|
| 2141 | + * |
|
| 2142 | + * @var string |
|
| 2143 | + */ |
|
| 2144 | + public $pinterest; |
|
| 2145 | + |
|
| 2146 | + |
|
| 2147 | + /** |
|
| 2148 | + * google+ (google.com/+profileName) |
|
| 2149 | + * |
|
| 2150 | + * @var string |
|
| 2151 | + */ |
|
| 2152 | + public $google; |
|
| 2153 | + |
|
| 2154 | + |
|
| 2155 | + /** |
|
| 2156 | + * instagram (instagram.com/handle) |
|
| 2157 | + * |
|
| 2158 | + * @var string |
|
| 2159 | + */ |
|
| 2160 | + public $instagram; |
|
| 2161 | + |
|
| 2162 | + |
|
| 2163 | + |
|
| 2164 | + /** |
|
| 2165 | + * class constructor |
|
| 2166 | + * |
|
| 2167 | + * @access public |
|
| 2168 | + */ |
|
| 2169 | + public function __construct() |
|
| 2170 | + { |
|
| 2171 | + // set default organization settings |
|
| 2172 | + $this->name = get_bloginfo('name'); |
|
| 2173 | + $this->address_1 = '123 Onna Road'; |
|
| 2174 | + $this->address_2 = 'PO Box 123'; |
|
| 2175 | + $this->city = 'Inna City'; |
|
| 2176 | + $this->STA_ID = 4; |
|
| 2177 | + $this->CNT_ISO = 'US'; |
|
| 2178 | + $this->zip = '12345'; |
|
| 2179 | + $this->email = get_bloginfo('admin_email'); |
|
| 2180 | + $this->phone = ''; |
|
| 2181 | + $this->vat = '123456789'; |
|
| 2182 | + $this->logo_url = ''; |
|
| 2183 | + $this->facebook = ''; |
|
| 2184 | + $this->twitter = ''; |
|
| 2185 | + $this->linkedin = ''; |
|
| 2186 | + $this->pinterest = ''; |
|
| 2187 | + $this->google = ''; |
|
| 2188 | + $this->instagram = ''; |
|
| 2189 | + } |
|
| 2482 | 2190 | |
| 2191 | +} |
|
| 2483 | 2192 | |
| 2484 | 2193 | |
| 2485 | - /** |
|
| 2486 | - * @return void |
|
| 2487 | - */ |
|
| 2488 | - public function set_default_reg_status_on_EEM_Event() |
|
| 2489 | - { |
|
| 2490 | - EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2491 | - } |
|
| 2492 | 2194 | |
| 2195 | +/** |
|
| 2196 | + * Class for defining what's in the EE_Config relating to currency |
|
| 2197 | + */ |
|
| 2198 | +class EE_Currency_Config extends EE_Config_Base |
|
| 2199 | +{ |
|
| 2493 | 2200 | |
| 2201 | + /** |
|
| 2202 | + * @var string $code |
|
| 2203 | + * eg 'US' |
|
| 2204 | + */ |
|
| 2205 | + public $code; |
|
| 2206 | + |
|
| 2207 | + /** |
|
| 2208 | + * @var string $name |
|
| 2209 | + * eg 'Dollar' |
|
| 2210 | + */ |
|
| 2211 | + public $name; |
|
| 2212 | + |
|
| 2213 | + /** |
|
| 2214 | + * plural name |
|
| 2215 | + * |
|
| 2216 | + * @var string $plural |
|
| 2217 | + * eg 'Dollars' |
|
| 2218 | + */ |
|
| 2219 | + public $plural; |
|
| 2220 | + |
|
| 2221 | + /** |
|
| 2222 | + * currency sign |
|
| 2223 | + * |
|
| 2224 | + * @var string $sign |
|
| 2225 | + * eg '$' |
|
| 2226 | + */ |
|
| 2227 | + public $sign; |
|
| 2228 | + |
|
| 2229 | + /** |
|
| 2230 | + * Whether the currency sign should come before the number or not |
|
| 2231 | + * |
|
| 2232 | + * @var boolean $sign_b4 |
|
| 2233 | + */ |
|
| 2234 | + public $sign_b4; |
|
| 2235 | + |
|
| 2236 | + /** |
|
| 2237 | + * How many digits should come after the decimal place |
|
| 2238 | + * |
|
| 2239 | + * @var int $dec_plc |
|
| 2240 | + */ |
|
| 2241 | + public $dec_plc; |
|
| 2242 | + |
|
| 2243 | + /** |
|
| 2244 | + * Symbol to use for decimal mark |
|
| 2245 | + * |
|
| 2246 | + * @var string $dec_mrk |
|
| 2247 | + * eg '.' |
|
| 2248 | + */ |
|
| 2249 | + public $dec_mrk; |
|
| 2250 | + |
|
| 2251 | + /** |
|
| 2252 | + * Symbol to use for thousands |
|
| 2253 | + * |
|
| 2254 | + * @var string $thsnds |
|
| 2255 | + * eg ',' |
|
| 2256 | + */ |
|
| 2257 | + public $thsnds; |
|
| 2258 | + |
|
| 2259 | + |
|
| 2260 | + |
|
| 2261 | + /** |
|
| 2262 | + * class constructor |
|
| 2263 | + * |
|
| 2264 | + * @access public |
|
| 2265 | + * @param string $CNT_ISO |
|
| 2266 | + * @throws \EE_Error |
|
| 2267 | + */ |
|
| 2268 | + public function __construct($CNT_ISO = '') |
|
| 2269 | + { |
|
| 2270 | + /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */ |
|
| 2271 | + $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
| 2272 | + // get country code from organization settings or use default |
|
| 2273 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
| 2274 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
| 2275 | + ? EE_Registry::instance()->CFG->organization->CNT_ISO |
|
| 2276 | + : ''; |
|
| 2277 | + // but override if requested |
|
| 2278 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
| 2279 | + // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
|
| 2280 | + if ( |
|
| 2281 | + ! empty($CNT_ISO) |
|
| 2282 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
| 2283 | + && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table()) |
|
| 2284 | + ) { |
|
| 2285 | + // retrieve the country settings from the db, just in case they have been customized |
|
| 2286 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
| 2287 | + if ($country instanceof EE_Country) { |
|
| 2288 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2289 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2290 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2291 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2292 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2293 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2294 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2295 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2296 | + } |
|
| 2297 | + } |
|
| 2298 | + // fallback to hardcoded defaults, in case the above failed |
|
| 2299 | + if (empty($this->code)) { |
|
| 2300 | + // set default currency settings |
|
| 2301 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2302 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2303 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2304 | + $this->sign = '$'; // currency sign: $ |
|
| 2305 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2306 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2307 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2308 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2309 | + } |
|
| 2310 | + } |
|
| 2311 | +} |
|
| 2494 | 2312 | |
| 2495 | - /** |
|
| 2496 | - * @return boolean |
|
| 2497 | - */ |
|
| 2498 | - public function track_invalid_checkout_access() |
|
| 2499 | - { |
|
| 2500 | - return $this->track_invalid_checkout_access; |
|
| 2501 | - } |
|
| 2502 | 2313 | |
| 2503 | 2314 | |
| 2315 | +/** |
|
| 2316 | + * Class for defining what's in the EE_Config relating to registration settings |
|
| 2317 | + */ |
|
| 2318 | +class EE_Registration_Config extends EE_Config_Base |
|
| 2319 | +{ |
|
| 2504 | 2320 | |
| 2505 | - /** |
|
| 2506 | - * @param boolean $track_invalid_checkout_access |
|
| 2507 | - */ |
|
| 2508 | - public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2509 | - { |
|
| 2510 | - $this->track_invalid_checkout_access = filter_var( |
|
| 2511 | - $track_invalid_checkout_access, |
|
| 2512 | - FILTER_VALIDATE_BOOLEAN |
|
| 2513 | - ); |
|
| 2514 | - } |
|
| 2321 | + /** |
|
| 2322 | + * Default registration status |
|
| 2323 | + * |
|
| 2324 | + * @var string $default_STS_ID |
|
| 2325 | + * eg 'RPP' |
|
| 2326 | + */ |
|
| 2327 | + public $default_STS_ID; |
|
| 2328 | + |
|
| 2329 | + /** |
|
| 2330 | + * level of validation to apply to email addresses |
|
| 2331 | + * |
|
| 2332 | + * @var string $email_validation_level |
|
| 2333 | + * options: 'basic', 'wp_default', 'i18n', 'i18n_dns' |
|
| 2334 | + */ |
|
| 2335 | + public $email_validation_level; |
|
| 2336 | + |
|
| 2337 | + /** |
|
| 2338 | + * whether or not to show alternate payment options during the reg process if payment status is pending |
|
| 2339 | + * |
|
| 2340 | + * @var boolean $show_pending_payment_options |
|
| 2341 | + */ |
|
| 2342 | + public $show_pending_payment_options; |
|
| 2343 | + |
|
| 2344 | + /** |
|
| 2345 | + * Whether to skip the registration confirmation page |
|
| 2346 | + * |
|
| 2347 | + * @var boolean $skip_reg_confirmation |
|
| 2348 | + */ |
|
| 2349 | + public $skip_reg_confirmation; |
|
| 2350 | + |
|
| 2351 | + /** |
|
| 2352 | + * an array of SPCO reg steps where: |
|
| 2353 | + * the keys denotes the reg step order |
|
| 2354 | + * each element consists of an array with the following elements: |
|
| 2355 | + * "file_path" => the file path to the EE_SPCO_Reg_Step class |
|
| 2356 | + * "class_name" => the specific EE_SPCO_Reg_Step child class name |
|
| 2357 | + * "slug" => the URL param used to trigger the reg step |
|
| 2358 | + * |
|
| 2359 | + * @var array $reg_steps |
|
| 2360 | + */ |
|
| 2361 | + public $reg_steps; |
|
| 2362 | + |
|
| 2363 | + /** |
|
| 2364 | + * Whether registration confirmation should be the last page of SPCO |
|
| 2365 | + * |
|
| 2366 | + * @var boolean $reg_confirmation_last |
|
| 2367 | + */ |
|
| 2368 | + public $reg_confirmation_last; |
|
| 2369 | + |
|
| 2370 | + /** |
|
| 2371 | + * Whether or not to enable the EE Bot Trap |
|
| 2372 | + * |
|
| 2373 | + * @var boolean $use_bot_trap |
|
| 2374 | + */ |
|
| 2375 | + public $use_bot_trap; |
|
| 2376 | + |
|
| 2377 | + /** |
|
| 2378 | + * Whether or not to encrypt some data sent by the EE Bot Trap |
|
| 2379 | + * |
|
| 2380 | + * @var boolean $use_encryption |
|
| 2381 | + */ |
|
| 2382 | + public $use_encryption; |
|
| 2383 | + |
|
| 2384 | + /** |
|
| 2385 | + * Whether or not to use ReCaptcha |
|
| 2386 | + * |
|
| 2387 | + * @var boolean $use_captcha |
|
| 2388 | + */ |
|
| 2389 | + public $use_captcha; |
|
| 2390 | + |
|
| 2391 | + /** |
|
| 2392 | + * ReCaptcha Theme |
|
| 2393 | + * |
|
| 2394 | + * @var string $recaptcha_theme |
|
| 2395 | + * options: 'dark ', 'light' |
|
| 2396 | + */ |
|
| 2397 | + public $recaptcha_theme; |
|
| 2398 | + |
|
| 2399 | + /** |
|
| 2400 | + * ReCaptcha Type |
|
| 2401 | + * |
|
| 2402 | + * @var string $recaptcha_type |
|
| 2403 | + * options: 'audio', 'image' |
|
| 2404 | + */ |
|
| 2405 | + public $recaptcha_type; |
|
| 2406 | + |
|
| 2407 | + /** |
|
| 2408 | + * ReCaptcha language |
|
| 2409 | + * |
|
| 2410 | + * @var string $recaptcha_language |
|
| 2411 | + * eg 'en' |
|
| 2412 | + */ |
|
| 2413 | + public $recaptcha_language; |
|
| 2414 | + |
|
| 2415 | + /** |
|
| 2416 | + * ReCaptcha public key |
|
| 2417 | + * |
|
| 2418 | + * @var string $recaptcha_publickey |
|
| 2419 | + */ |
|
| 2420 | + public $recaptcha_publickey; |
|
| 2421 | + |
|
| 2422 | + /** |
|
| 2423 | + * ReCaptcha private key |
|
| 2424 | + * |
|
| 2425 | + * @var string $recaptcha_privatekey |
|
| 2426 | + */ |
|
| 2427 | + public $recaptcha_privatekey; |
|
| 2428 | + |
|
| 2429 | + /** |
|
| 2430 | + * ReCaptcha width |
|
| 2431 | + * |
|
| 2432 | + * @var int $recaptcha_width |
|
| 2433 | + * @deprecated |
|
| 2434 | + */ |
|
| 2435 | + public $recaptcha_width; |
|
| 2436 | + |
|
| 2437 | + /** |
|
| 2438 | + * Whether or not invalid attempts to directly access the registration checkout page should be tracked. |
|
| 2439 | + * |
|
| 2440 | + * @var boolean $track_invalid_checkout_access |
|
| 2441 | + */ |
|
| 2442 | + protected $track_invalid_checkout_access = true; |
|
| 2443 | + |
|
| 2444 | + |
|
| 2445 | + |
|
| 2446 | + /** |
|
| 2447 | + * class constructor |
|
| 2448 | + * |
|
| 2449 | + * @access public |
|
| 2450 | + */ |
|
| 2451 | + public function __construct() |
|
| 2452 | + { |
|
| 2453 | + // set default registration settings |
|
| 2454 | + $this->default_STS_ID = EEM_Registration::status_id_pending_payment; |
|
| 2455 | + $this->email_validation_level = 'wp_default'; |
|
| 2456 | + $this->show_pending_payment_options = true; |
|
| 2457 | + $this->skip_reg_confirmation = false; |
|
| 2458 | + $this->reg_steps = array(); |
|
| 2459 | + $this->reg_confirmation_last = false; |
|
| 2460 | + $this->use_bot_trap = true; |
|
| 2461 | + $this->use_encryption = true; |
|
| 2462 | + $this->use_captcha = false; |
|
| 2463 | + $this->recaptcha_theme = 'light'; |
|
| 2464 | + $this->recaptcha_type = 'image'; |
|
| 2465 | + $this->recaptcha_language = 'en'; |
|
| 2466 | + $this->recaptcha_publickey = null; |
|
| 2467 | + $this->recaptcha_privatekey = null; |
|
| 2468 | + $this->recaptcha_width = 500; |
|
| 2469 | + } |
|
| 2470 | + |
|
| 2471 | + |
|
| 2472 | + |
|
| 2473 | + /** |
|
| 2474 | + * This is called by the config loader and hooks are initialized AFTER the config has been populated. |
|
| 2475 | + * |
|
| 2476 | + * @since 4.8.8.rc.019 |
|
| 2477 | + */ |
|
| 2478 | + public function do_hooks() |
|
| 2479 | + { |
|
| 2480 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
| 2481 | + } |
|
| 2482 | + |
|
| 2483 | + |
|
| 2484 | + |
|
| 2485 | + /** |
|
| 2486 | + * @return void |
|
| 2487 | + */ |
|
| 2488 | + public function set_default_reg_status_on_EEM_Event() |
|
| 2489 | + { |
|
| 2490 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
| 2491 | + } |
|
| 2492 | + |
|
| 2493 | + |
|
| 2494 | + |
|
| 2495 | + /** |
|
| 2496 | + * @return boolean |
|
| 2497 | + */ |
|
| 2498 | + public function track_invalid_checkout_access() |
|
| 2499 | + { |
|
| 2500 | + return $this->track_invalid_checkout_access; |
|
| 2501 | + } |
|
| 2502 | + |
|
| 2503 | + |
|
| 2504 | + |
|
| 2505 | + /** |
|
| 2506 | + * @param boolean $track_invalid_checkout_access |
|
| 2507 | + */ |
|
| 2508 | + public function set_track_invalid_checkout_access($track_invalid_checkout_access) |
|
| 2509 | + { |
|
| 2510 | + $this->track_invalid_checkout_access = filter_var( |
|
| 2511 | + $track_invalid_checkout_access, |
|
| 2512 | + FILTER_VALIDATE_BOOLEAN |
|
| 2513 | + ); |
|
| 2514 | + } |
|
| 2515 | 2515 | |
| 2516 | 2516 | |
| 2517 | 2517 | } |
@@ -2524,160 +2524,160 @@ discard block |
||
| 2524 | 2524 | class EE_Admin_Config extends EE_Config_Base |
| 2525 | 2525 | { |
| 2526 | 2526 | |
| 2527 | - /** |
|
| 2528 | - * @var boolean $use_personnel_manager |
|
| 2529 | - */ |
|
| 2530 | - public $use_personnel_manager; |
|
| 2531 | - |
|
| 2532 | - /** |
|
| 2533 | - * @var boolean $use_dashboard_widget |
|
| 2534 | - */ |
|
| 2535 | - public $use_dashboard_widget; |
|
| 2536 | - |
|
| 2537 | - /** |
|
| 2538 | - * @var int $events_in_dashboard |
|
| 2539 | - */ |
|
| 2540 | - public $events_in_dashboard; |
|
| 2541 | - |
|
| 2542 | - /** |
|
| 2543 | - * @var boolean $use_event_timezones |
|
| 2544 | - */ |
|
| 2545 | - public $use_event_timezones; |
|
| 2546 | - |
|
| 2547 | - /** |
|
| 2548 | - * @var boolean $use_full_logging |
|
| 2549 | - */ |
|
| 2550 | - public $use_full_logging; |
|
| 2551 | - |
|
| 2552 | - /** |
|
| 2553 | - * @var string $log_file_name |
|
| 2554 | - */ |
|
| 2555 | - public $log_file_name; |
|
| 2556 | - |
|
| 2557 | - /** |
|
| 2558 | - * @var string $debug_file_name |
|
| 2559 | - */ |
|
| 2560 | - public $debug_file_name; |
|
| 2561 | - |
|
| 2562 | - /** |
|
| 2563 | - * @var boolean $use_remote_logging |
|
| 2564 | - */ |
|
| 2565 | - public $use_remote_logging; |
|
| 2566 | - |
|
| 2567 | - /** |
|
| 2568 | - * @var string $remote_logging_url |
|
| 2569 | - */ |
|
| 2570 | - public $remote_logging_url; |
|
| 2571 | - |
|
| 2572 | - /** |
|
| 2573 | - * @var boolean $show_reg_footer |
|
| 2574 | - */ |
|
| 2575 | - public $show_reg_footer; |
|
| 2576 | - |
|
| 2577 | - /** |
|
| 2578 | - * @var string $affiliate_id |
|
| 2579 | - */ |
|
| 2580 | - public $affiliate_id; |
|
| 2581 | - |
|
| 2582 | - /** |
|
| 2583 | - * help tours on or off (global setting) |
|
| 2584 | - * |
|
| 2585 | - * @var boolean |
|
| 2586 | - */ |
|
| 2587 | - public $help_tour_activation; |
|
| 2588 | - |
|
| 2589 | - /** |
|
| 2590 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2591 | - * but is incompatible with some server configuration errors |
|
| 2592 | - * if you get "500 internal server errors" during registration, try turning this on |
|
| 2593 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2594 | - * |
|
| 2595 | - * @var boolean $encode_session_data |
|
| 2596 | - */ |
|
| 2597 | - private $encode_session_data = false; |
|
| 2598 | - |
|
| 2599 | - |
|
| 2600 | - |
|
| 2601 | - /** |
|
| 2602 | - * class constructor |
|
| 2603 | - * |
|
| 2604 | - * @access public |
|
| 2605 | - */ |
|
| 2606 | - public function __construct() |
|
| 2607 | - { |
|
| 2608 | - // set default general admin settings |
|
| 2609 | - $this->use_personnel_manager = true; |
|
| 2610 | - $this->use_dashboard_widget = true; |
|
| 2611 | - $this->events_in_dashboard = 30; |
|
| 2612 | - $this->use_event_timezones = false; |
|
| 2613 | - $this->use_full_logging = false; |
|
| 2614 | - $this->use_remote_logging = false; |
|
| 2615 | - $this->remote_logging_url = null; |
|
| 2616 | - $this->show_reg_footer = true; |
|
| 2617 | - $this->affiliate_id = 'default'; |
|
| 2618 | - $this->help_tour_activation = true; |
|
| 2619 | - $this->encode_session_data = false; |
|
| 2620 | - } |
|
| 2621 | - |
|
| 2622 | - |
|
| 2623 | - |
|
| 2624 | - /** |
|
| 2625 | - * @param bool $reset |
|
| 2626 | - * @return string |
|
| 2627 | - */ |
|
| 2628 | - public function log_file_name($reset = false) |
|
| 2629 | - { |
|
| 2630 | - if (empty($this->log_file_name) || $reset) { |
|
| 2631 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2632 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2633 | - } |
|
| 2634 | - return $this->log_file_name; |
|
| 2635 | - } |
|
| 2636 | - |
|
| 2637 | - |
|
| 2638 | - |
|
| 2639 | - /** |
|
| 2640 | - * @param bool $reset |
|
| 2641 | - * @return string |
|
| 2642 | - */ |
|
| 2643 | - public function debug_file_name($reset = false) |
|
| 2644 | - { |
|
| 2645 | - if (empty($this->debug_file_name) || $reset) { |
|
| 2646 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2647 | - EE_Config::instance()->update_espresso_config(false, false); |
|
| 2648 | - } |
|
| 2649 | - return $this->debug_file_name; |
|
| 2650 | - } |
|
| 2651 | - |
|
| 2652 | - |
|
| 2653 | - |
|
| 2654 | - /** |
|
| 2655 | - * @return string |
|
| 2656 | - */ |
|
| 2657 | - public function affiliate_id() |
|
| 2658 | - { |
|
| 2659 | - return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2660 | - } |
|
| 2661 | - |
|
| 2662 | - |
|
| 2663 | - |
|
| 2664 | - /** |
|
| 2665 | - * @return boolean |
|
| 2666 | - */ |
|
| 2667 | - public function encode_session_data() |
|
| 2668 | - { |
|
| 2669 | - return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2670 | - } |
|
| 2671 | - |
|
| 2672 | - |
|
| 2673 | - |
|
| 2674 | - /** |
|
| 2675 | - * @param boolean $encode_session_data |
|
| 2676 | - */ |
|
| 2677 | - public function set_encode_session_data($encode_session_data) |
|
| 2678 | - { |
|
| 2679 | - $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2680 | - } |
|
| 2527 | + /** |
|
| 2528 | + * @var boolean $use_personnel_manager |
|
| 2529 | + */ |
|
| 2530 | + public $use_personnel_manager; |
|
| 2531 | + |
|
| 2532 | + /** |
|
| 2533 | + * @var boolean $use_dashboard_widget |
|
| 2534 | + */ |
|
| 2535 | + public $use_dashboard_widget; |
|
| 2536 | + |
|
| 2537 | + /** |
|
| 2538 | + * @var int $events_in_dashboard |
|
| 2539 | + */ |
|
| 2540 | + public $events_in_dashboard; |
|
| 2541 | + |
|
| 2542 | + /** |
|
| 2543 | + * @var boolean $use_event_timezones |
|
| 2544 | + */ |
|
| 2545 | + public $use_event_timezones; |
|
| 2546 | + |
|
| 2547 | + /** |
|
| 2548 | + * @var boolean $use_full_logging |
|
| 2549 | + */ |
|
| 2550 | + public $use_full_logging; |
|
| 2551 | + |
|
| 2552 | + /** |
|
| 2553 | + * @var string $log_file_name |
|
| 2554 | + */ |
|
| 2555 | + public $log_file_name; |
|
| 2556 | + |
|
| 2557 | + /** |
|
| 2558 | + * @var string $debug_file_name |
|
| 2559 | + */ |
|
| 2560 | + public $debug_file_name; |
|
| 2561 | + |
|
| 2562 | + /** |
|
| 2563 | + * @var boolean $use_remote_logging |
|
| 2564 | + */ |
|
| 2565 | + public $use_remote_logging; |
|
| 2566 | + |
|
| 2567 | + /** |
|
| 2568 | + * @var string $remote_logging_url |
|
| 2569 | + */ |
|
| 2570 | + public $remote_logging_url; |
|
| 2571 | + |
|
| 2572 | + /** |
|
| 2573 | + * @var boolean $show_reg_footer |
|
| 2574 | + */ |
|
| 2575 | + public $show_reg_footer; |
|
| 2576 | + |
|
| 2577 | + /** |
|
| 2578 | + * @var string $affiliate_id |
|
| 2579 | + */ |
|
| 2580 | + public $affiliate_id; |
|
| 2581 | + |
|
| 2582 | + /** |
|
| 2583 | + * help tours on or off (global setting) |
|
| 2584 | + * |
|
| 2585 | + * @var boolean |
|
| 2586 | + */ |
|
| 2587 | + public $help_tour_activation; |
|
| 2588 | + |
|
| 2589 | + /** |
|
| 2590 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
| 2591 | + * but is incompatible with some server configuration errors |
|
| 2592 | + * if you get "500 internal server errors" during registration, try turning this on |
|
| 2593 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
| 2594 | + * |
|
| 2595 | + * @var boolean $encode_session_data |
|
| 2596 | + */ |
|
| 2597 | + private $encode_session_data = false; |
|
| 2598 | + |
|
| 2599 | + |
|
| 2600 | + |
|
| 2601 | + /** |
|
| 2602 | + * class constructor |
|
| 2603 | + * |
|
| 2604 | + * @access public |
|
| 2605 | + */ |
|
| 2606 | + public function __construct() |
|
| 2607 | + { |
|
| 2608 | + // set default general admin settings |
|
| 2609 | + $this->use_personnel_manager = true; |
|
| 2610 | + $this->use_dashboard_widget = true; |
|
| 2611 | + $this->events_in_dashboard = 30; |
|
| 2612 | + $this->use_event_timezones = false; |
|
| 2613 | + $this->use_full_logging = false; |
|
| 2614 | + $this->use_remote_logging = false; |
|
| 2615 | + $this->remote_logging_url = null; |
|
| 2616 | + $this->show_reg_footer = true; |
|
| 2617 | + $this->affiliate_id = 'default'; |
|
| 2618 | + $this->help_tour_activation = true; |
|
| 2619 | + $this->encode_session_data = false; |
|
| 2620 | + } |
|
| 2621 | + |
|
| 2622 | + |
|
| 2623 | + |
|
| 2624 | + /** |
|
| 2625 | + * @param bool $reset |
|
| 2626 | + * @return string |
|
| 2627 | + */ |
|
| 2628 | + public function log_file_name($reset = false) |
|
| 2629 | + { |
|
| 2630 | + if (empty($this->log_file_name) || $reset) { |
|
| 2631 | + $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2632 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2633 | + } |
|
| 2634 | + return $this->log_file_name; |
|
| 2635 | + } |
|
| 2636 | + |
|
| 2637 | + |
|
| 2638 | + |
|
| 2639 | + /** |
|
| 2640 | + * @param bool $reset |
|
| 2641 | + * @return string |
|
| 2642 | + */ |
|
| 2643 | + public function debug_file_name($reset = false) |
|
| 2644 | + { |
|
| 2645 | + if (empty($this->debug_file_name) || $reset) { |
|
| 2646 | + $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2647 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 2648 | + } |
|
| 2649 | + return $this->debug_file_name; |
|
| 2650 | + } |
|
| 2651 | + |
|
| 2652 | + |
|
| 2653 | + |
|
| 2654 | + /** |
|
| 2655 | + * @return string |
|
| 2656 | + */ |
|
| 2657 | + public function affiliate_id() |
|
| 2658 | + { |
|
| 2659 | + return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default'; |
|
| 2660 | + } |
|
| 2661 | + |
|
| 2662 | + |
|
| 2663 | + |
|
| 2664 | + /** |
|
| 2665 | + * @return boolean |
|
| 2666 | + */ |
|
| 2667 | + public function encode_session_data() |
|
| 2668 | + { |
|
| 2669 | + return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2670 | + } |
|
| 2671 | + |
|
| 2672 | + |
|
| 2673 | + |
|
| 2674 | + /** |
|
| 2675 | + * @param boolean $encode_session_data |
|
| 2676 | + */ |
|
| 2677 | + public function set_encode_session_data($encode_session_data) |
|
| 2678 | + { |
|
| 2679 | + $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN); |
|
| 2680 | + } |
|
| 2681 | 2681 | |
| 2682 | 2682 | |
| 2683 | 2683 | } |
@@ -2690,71 +2690,71 @@ discard block |
||
| 2690 | 2690 | class EE_Template_Config extends EE_Config_Base |
| 2691 | 2691 | { |
| 2692 | 2692 | |
| 2693 | - /** |
|
| 2694 | - * @var boolean $enable_default_style |
|
| 2695 | - */ |
|
| 2696 | - public $enable_default_style; |
|
| 2697 | - |
|
| 2698 | - /** |
|
| 2699 | - * @var string $custom_style_sheet |
|
| 2700 | - */ |
|
| 2701 | - public $custom_style_sheet; |
|
| 2702 | - |
|
| 2703 | - /** |
|
| 2704 | - * @var boolean $display_address_in_regform |
|
| 2705 | - */ |
|
| 2706 | - public $display_address_in_regform; |
|
| 2707 | - |
|
| 2708 | - /** |
|
| 2709 | - * @var int $display_description_on_multi_reg_page |
|
| 2710 | - */ |
|
| 2711 | - public $display_description_on_multi_reg_page; |
|
| 2712 | - |
|
| 2713 | - /** |
|
| 2714 | - * @var boolean $use_custom_templates |
|
| 2715 | - */ |
|
| 2716 | - public $use_custom_templates; |
|
| 2717 | - |
|
| 2718 | - /** |
|
| 2719 | - * @var string $current_espresso_theme |
|
| 2720 | - */ |
|
| 2721 | - public $current_espresso_theme; |
|
| 2722 | - |
|
| 2723 | - /** |
|
| 2724 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2725 | - */ |
|
| 2726 | - public $EED_Ticket_Selector; |
|
| 2727 | - |
|
| 2728 | - /** |
|
| 2729 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2730 | - */ |
|
| 2731 | - public $EED_Event_Single; |
|
| 2732 | - |
|
| 2733 | - /** |
|
| 2734 | - * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2735 | - */ |
|
| 2736 | - public $EED_Events_Archive; |
|
| 2737 | - |
|
| 2738 | - |
|
| 2739 | - |
|
| 2740 | - /** |
|
| 2741 | - * class constructor |
|
| 2742 | - * |
|
| 2743 | - * @access public |
|
| 2744 | - */ |
|
| 2745 | - public function __construct() |
|
| 2746 | - { |
|
| 2747 | - // set default template settings |
|
| 2748 | - $this->enable_default_style = true; |
|
| 2749 | - $this->custom_style_sheet = null; |
|
| 2750 | - $this->display_address_in_regform = true; |
|
| 2751 | - $this->display_description_on_multi_reg_page = false; |
|
| 2752 | - $this->use_custom_templates = false; |
|
| 2753 | - $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2754 | - $this->EED_Event_Single = null; |
|
| 2755 | - $this->EED_Events_Archive = null; |
|
| 2756 | - $this->EED_Ticket_Selector = null; |
|
| 2757 | - } |
|
| 2693 | + /** |
|
| 2694 | + * @var boolean $enable_default_style |
|
| 2695 | + */ |
|
| 2696 | + public $enable_default_style; |
|
| 2697 | + |
|
| 2698 | + /** |
|
| 2699 | + * @var string $custom_style_sheet |
|
| 2700 | + */ |
|
| 2701 | + public $custom_style_sheet; |
|
| 2702 | + |
|
| 2703 | + /** |
|
| 2704 | + * @var boolean $display_address_in_regform |
|
| 2705 | + */ |
|
| 2706 | + public $display_address_in_regform; |
|
| 2707 | + |
|
| 2708 | + /** |
|
| 2709 | + * @var int $display_description_on_multi_reg_page |
|
| 2710 | + */ |
|
| 2711 | + public $display_description_on_multi_reg_page; |
|
| 2712 | + |
|
| 2713 | + /** |
|
| 2714 | + * @var boolean $use_custom_templates |
|
| 2715 | + */ |
|
| 2716 | + public $use_custom_templates; |
|
| 2717 | + |
|
| 2718 | + /** |
|
| 2719 | + * @var string $current_espresso_theme |
|
| 2720 | + */ |
|
| 2721 | + public $current_espresso_theme; |
|
| 2722 | + |
|
| 2723 | + /** |
|
| 2724 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
| 2725 | + */ |
|
| 2726 | + public $EED_Ticket_Selector; |
|
| 2727 | + |
|
| 2728 | + /** |
|
| 2729 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
| 2730 | + */ |
|
| 2731 | + public $EED_Event_Single; |
|
| 2732 | + |
|
| 2733 | + /** |
|
| 2734 | + * @var EE_Events_Archive_Config $EED_Events_Archive |
|
| 2735 | + */ |
|
| 2736 | + public $EED_Events_Archive; |
|
| 2737 | + |
|
| 2738 | + |
|
| 2739 | + |
|
| 2740 | + /** |
|
| 2741 | + * class constructor |
|
| 2742 | + * |
|
| 2743 | + * @access public |
|
| 2744 | + */ |
|
| 2745 | + public function __construct() |
|
| 2746 | + { |
|
| 2747 | + // set default template settings |
|
| 2748 | + $this->enable_default_style = true; |
|
| 2749 | + $this->custom_style_sheet = null; |
|
| 2750 | + $this->display_address_in_regform = true; |
|
| 2751 | + $this->display_description_on_multi_reg_page = false; |
|
| 2752 | + $this->use_custom_templates = false; |
|
| 2753 | + $this->current_espresso_theme = 'Espresso_Arabica_2014'; |
|
| 2754 | + $this->EED_Event_Single = null; |
|
| 2755 | + $this->EED_Events_Archive = null; |
|
| 2756 | + $this->EED_Ticket_Selector = null; |
|
| 2757 | + } |
|
| 2758 | 2758 | |
| 2759 | 2759 | } |
| 2760 | 2760 | |
@@ -2766,115 +2766,115 @@ discard block |
||
| 2766 | 2766 | class EE_Map_Config extends EE_Config_Base |
| 2767 | 2767 | { |
| 2768 | 2768 | |
| 2769 | - /** |
|
| 2770 | - * @var boolean $use_google_maps |
|
| 2771 | - */ |
|
| 2772 | - public $use_google_maps; |
|
| 2773 | - |
|
| 2774 | - /** |
|
| 2775 | - * @var string $api_key |
|
| 2776 | - */ |
|
| 2777 | - public $google_map_api_key; |
|
| 2778 | - |
|
| 2779 | - /** |
|
| 2780 | - * @var int $event_details_map_width |
|
| 2781 | - */ |
|
| 2782 | - public $event_details_map_width; |
|
| 2783 | - |
|
| 2784 | - /** |
|
| 2785 | - * @var int $event_details_map_height |
|
| 2786 | - */ |
|
| 2787 | - public $event_details_map_height; |
|
| 2788 | - |
|
| 2789 | - /** |
|
| 2790 | - * @var int $event_details_map_zoom |
|
| 2791 | - */ |
|
| 2792 | - public $event_details_map_zoom; |
|
| 2793 | - |
|
| 2794 | - /** |
|
| 2795 | - * @var boolean $event_details_display_nav |
|
| 2796 | - */ |
|
| 2797 | - public $event_details_display_nav; |
|
| 2798 | - |
|
| 2799 | - /** |
|
| 2800 | - * @var boolean $event_details_nav_size |
|
| 2801 | - */ |
|
| 2802 | - public $event_details_nav_size; |
|
| 2803 | - |
|
| 2804 | - /** |
|
| 2805 | - * @var string $event_details_control_type |
|
| 2806 | - */ |
|
| 2807 | - public $event_details_control_type; |
|
| 2808 | - |
|
| 2809 | - /** |
|
| 2810 | - * @var string $event_details_map_align |
|
| 2811 | - */ |
|
| 2812 | - public $event_details_map_align; |
|
| 2813 | - |
|
| 2814 | - /** |
|
| 2815 | - * @var int $event_list_map_width |
|
| 2816 | - */ |
|
| 2817 | - public $event_list_map_width; |
|
| 2818 | - |
|
| 2819 | - /** |
|
| 2820 | - * @var int $event_list_map_height |
|
| 2821 | - */ |
|
| 2822 | - public $event_list_map_height; |
|
| 2823 | - |
|
| 2824 | - /** |
|
| 2825 | - * @var int $event_list_map_zoom |
|
| 2826 | - */ |
|
| 2827 | - public $event_list_map_zoom; |
|
| 2828 | - |
|
| 2829 | - /** |
|
| 2830 | - * @var boolean $event_list_display_nav |
|
| 2831 | - */ |
|
| 2832 | - public $event_list_display_nav; |
|
| 2833 | - |
|
| 2834 | - /** |
|
| 2835 | - * @var boolean $event_list_nav_size |
|
| 2836 | - */ |
|
| 2837 | - public $event_list_nav_size; |
|
| 2838 | - |
|
| 2839 | - /** |
|
| 2840 | - * @var string $event_list_control_type |
|
| 2841 | - */ |
|
| 2842 | - public $event_list_control_type; |
|
| 2843 | - |
|
| 2844 | - /** |
|
| 2845 | - * @var string $event_list_map_align |
|
| 2846 | - */ |
|
| 2847 | - public $event_list_map_align; |
|
| 2848 | - |
|
| 2849 | - |
|
| 2850 | - |
|
| 2851 | - /** |
|
| 2852 | - * class constructor |
|
| 2853 | - * |
|
| 2854 | - * @access public |
|
| 2855 | - */ |
|
| 2856 | - public function __construct() |
|
| 2857 | - { |
|
| 2858 | - // set default map settings |
|
| 2859 | - $this->use_google_maps = true; |
|
| 2860 | - $this->google_map_api_key = ''; |
|
| 2861 | - // for event details pages (reg page) |
|
| 2862 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2863 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2864 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2865 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2866 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2867 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2868 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2869 | - // for event list pages |
|
| 2870 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2871 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2872 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2873 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2874 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2875 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2876 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2877 | - } |
|
| 2769 | + /** |
|
| 2770 | + * @var boolean $use_google_maps |
|
| 2771 | + */ |
|
| 2772 | + public $use_google_maps; |
|
| 2773 | + |
|
| 2774 | + /** |
|
| 2775 | + * @var string $api_key |
|
| 2776 | + */ |
|
| 2777 | + public $google_map_api_key; |
|
| 2778 | + |
|
| 2779 | + /** |
|
| 2780 | + * @var int $event_details_map_width |
|
| 2781 | + */ |
|
| 2782 | + public $event_details_map_width; |
|
| 2783 | + |
|
| 2784 | + /** |
|
| 2785 | + * @var int $event_details_map_height |
|
| 2786 | + */ |
|
| 2787 | + public $event_details_map_height; |
|
| 2788 | + |
|
| 2789 | + /** |
|
| 2790 | + * @var int $event_details_map_zoom |
|
| 2791 | + */ |
|
| 2792 | + public $event_details_map_zoom; |
|
| 2793 | + |
|
| 2794 | + /** |
|
| 2795 | + * @var boolean $event_details_display_nav |
|
| 2796 | + */ |
|
| 2797 | + public $event_details_display_nav; |
|
| 2798 | + |
|
| 2799 | + /** |
|
| 2800 | + * @var boolean $event_details_nav_size |
|
| 2801 | + */ |
|
| 2802 | + public $event_details_nav_size; |
|
| 2803 | + |
|
| 2804 | + /** |
|
| 2805 | + * @var string $event_details_control_type |
|
| 2806 | + */ |
|
| 2807 | + public $event_details_control_type; |
|
| 2808 | + |
|
| 2809 | + /** |
|
| 2810 | + * @var string $event_details_map_align |
|
| 2811 | + */ |
|
| 2812 | + public $event_details_map_align; |
|
| 2813 | + |
|
| 2814 | + /** |
|
| 2815 | + * @var int $event_list_map_width |
|
| 2816 | + */ |
|
| 2817 | + public $event_list_map_width; |
|
| 2818 | + |
|
| 2819 | + /** |
|
| 2820 | + * @var int $event_list_map_height |
|
| 2821 | + */ |
|
| 2822 | + public $event_list_map_height; |
|
| 2823 | + |
|
| 2824 | + /** |
|
| 2825 | + * @var int $event_list_map_zoom |
|
| 2826 | + */ |
|
| 2827 | + public $event_list_map_zoom; |
|
| 2828 | + |
|
| 2829 | + /** |
|
| 2830 | + * @var boolean $event_list_display_nav |
|
| 2831 | + */ |
|
| 2832 | + public $event_list_display_nav; |
|
| 2833 | + |
|
| 2834 | + /** |
|
| 2835 | + * @var boolean $event_list_nav_size |
|
| 2836 | + */ |
|
| 2837 | + public $event_list_nav_size; |
|
| 2838 | + |
|
| 2839 | + /** |
|
| 2840 | + * @var string $event_list_control_type |
|
| 2841 | + */ |
|
| 2842 | + public $event_list_control_type; |
|
| 2843 | + |
|
| 2844 | + /** |
|
| 2845 | + * @var string $event_list_map_align |
|
| 2846 | + */ |
|
| 2847 | + public $event_list_map_align; |
|
| 2848 | + |
|
| 2849 | + |
|
| 2850 | + |
|
| 2851 | + /** |
|
| 2852 | + * class constructor |
|
| 2853 | + * |
|
| 2854 | + * @access public |
|
| 2855 | + */ |
|
| 2856 | + public function __construct() |
|
| 2857 | + { |
|
| 2858 | + // set default map settings |
|
| 2859 | + $this->use_google_maps = true; |
|
| 2860 | + $this->google_map_api_key = ''; |
|
| 2861 | + // for event details pages (reg page) |
|
| 2862 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2863 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2864 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2865 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2866 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2867 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2868 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2869 | + // for event list pages |
|
| 2870 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2871 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2872 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2873 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2874 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2875 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2876 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2877 | + } |
|
| 2878 | 2878 | |
| 2879 | 2879 | } |
| 2880 | 2880 | |
@@ -2886,47 +2886,47 @@ discard block |
||
| 2886 | 2886 | class EE_Events_Archive_Config extends EE_Config_Base |
| 2887 | 2887 | { |
| 2888 | 2888 | |
| 2889 | - public $display_status_banner; |
|
| 2889 | + public $display_status_banner; |
|
| 2890 | 2890 | |
| 2891 | - public $display_description; |
|
| 2891 | + public $display_description; |
|
| 2892 | 2892 | |
| 2893 | - public $display_ticket_selector; |
|
| 2893 | + public $display_ticket_selector; |
|
| 2894 | 2894 | |
| 2895 | - public $display_datetimes; |
|
| 2895 | + public $display_datetimes; |
|
| 2896 | 2896 | |
| 2897 | - public $display_venue; |
|
| 2897 | + public $display_venue; |
|
| 2898 | 2898 | |
| 2899 | - public $display_expired_events; |
|
| 2899 | + public $display_expired_events; |
|
| 2900 | 2900 | |
| 2901 | - public $use_sortable_display_order; |
|
| 2901 | + public $use_sortable_display_order; |
|
| 2902 | 2902 | |
| 2903 | - public $display_order_tickets; |
|
| 2903 | + public $display_order_tickets; |
|
| 2904 | 2904 | |
| 2905 | - public $display_order_datetimes; |
|
| 2905 | + public $display_order_datetimes; |
|
| 2906 | 2906 | |
| 2907 | - public $display_order_event; |
|
| 2907 | + public $display_order_event; |
|
| 2908 | 2908 | |
| 2909 | - public $display_order_venue; |
|
| 2909 | + public $display_order_venue; |
|
| 2910 | 2910 | |
| 2911 | 2911 | |
| 2912 | 2912 | |
| 2913 | - /** |
|
| 2914 | - * class constructor |
|
| 2915 | - */ |
|
| 2916 | - public function __construct() |
|
| 2917 | - { |
|
| 2918 | - $this->display_status_banner = 0; |
|
| 2919 | - $this->display_description = 1; |
|
| 2920 | - $this->display_ticket_selector = 0; |
|
| 2921 | - $this->display_datetimes = 1; |
|
| 2922 | - $this->display_venue = 0; |
|
| 2923 | - $this->display_expired_events = 0; |
|
| 2924 | - $this->use_sortable_display_order = false; |
|
| 2925 | - $this->display_order_tickets = 100; |
|
| 2926 | - $this->display_order_datetimes = 110; |
|
| 2927 | - $this->display_order_event = 120; |
|
| 2928 | - $this->display_order_venue = 130; |
|
| 2929 | - } |
|
| 2913 | + /** |
|
| 2914 | + * class constructor |
|
| 2915 | + */ |
|
| 2916 | + public function __construct() |
|
| 2917 | + { |
|
| 2918 | + $this->display_status_banner = 0; |
|
| 2919 | + $this->display_description = 1; |
|
| 2920 | + $this->display_ticket_selector = 0; |
|
| 2921 | + $this->display_datetimes = 1; |
|
| 2922 | + $this->display_venue = 0; |
|
| 2923 | + $this->display_expired_events = 0; |
|
| 2924 | + $this->use_sortable_display_order = false; |
|
| 2925 | + $this->display_order_tickets = 100; |
|
| 2926 | + $this->display_order_datetimes = 110; |
|
| 2927 | + $this->display_order_event = 120; |
|
| 2928 | + $this->display_order_venue = 130; |
|
| 2929 | + } |
|
| 2930 | 2930 | } |
| 2931 | 2931 | |
| 2932 | 2932 | |
@@ -2937,35 +2937,35 @@ discard block |
||
| 2937 | 2937 | class EE_Event_Single_Config extends EE_Config_Base |
| 2938 | 2938 | { |
| 2939 | 2939 | |
| 2940 | - public $display_status_banner_single; |
|
| 2940 | + public $display_status_banner_single; |
|
| 2941 | 2941 | |
| 2942 | - public $display_venue; |
|
| 2942 | + public $display_venue; |
|
| 2943 | 2943 | |
| 2944 | - public $use_sortable_display_order; |
|
| 2944 | + public $use_sortable_display_order; |
|
| 2945 | 2945 | |
| 2946 | - public $display_order_tickets; |
|
| 2946 | + public $display_order_tickets; |
|
| 2947 | 2947 | |
| 2948 | - public $display_order_datetimes; |
|
| 2948 | + public $display_order_datetimes; |
|
| 2949 | 2949 | |
| 2950 | - public $display_order_event; |
|
| 2950 | + public $display_order_event; |
|
| 2951 | 2951 | |
| 2952 | - public $display_order_venue; |
|
| 2952 | + public $display_order_venue; |
|
| 2953 | 2953 | |
| 2954 | 2954 | |
| 2955 | 2955 | |
| 2956 | - /** |
|
| 2957 | - * class constructor |
|
| 2958 | - */ |
|
| 2959 | - public function __construct() |
|
| 2960 | - { |
|
| 2961 | - $this->display_status_banner_single = 0; |
|
| 2962 | - $this->display_venue = 1; |
|
| 2963 | - $this->use_sortable_display_order = false; |
|
| 2964 | - $this->display_order_tickets = 100; |
|
| 2965 | - $this->display_order_datetimes = 110; |
|
| 2966 | - $this->display_order_event = 120; |
|
| 2967 | - $this->display_order_venue = 130; |
|
| 2968 | - } |
|
| 2956 | + /** |
|
| 2957 | + * class constructor |
|
| 2958 | + */ |
|
| 2959 | + public function __construct() |
|
| 2960 | + { |
|
| 2961 | + $this->display_status_banner_single = 0; |
|
| 2962 | + $this->display_venue = 1; |
|
| 2963 | + $this->use_sortable_display_order = false; |
|
| 2964 | + $this->display_order_tickets = 100; |
|
| 2965 | + $this->display_order_datetimes = 110; |
|
| 2966 | + $this->display_order_event = 120; |
|
| 2967 | + $this->display_order_venue = 130; |
|
| 2968 | + } |
|
| 2969 | 2969 | } |
| 2970 | 2970 | |
| 2971 | 2971 | |
@@ -2976,151 +2976,151 @@ discard block |
||
| 2976 | 2976 | class EE_Ticket_Selector_Config extends EE_Config_Base |
| 2977 | 2977 | { |
| 2978 | 2978 | |
| 2979 | - /** |
|
| 2980 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2981 | - */ |
|
| 2982 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2983 | - |
|
| 2984 | - /** |
|
| 2985 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2986 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2987 | - */ |
|
| 2988 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2989 | - |
|
| 2990 | - /** |
|
| 2991 | - * @var boolean $show_ticket_sale_columns |
|
| 2992 | - */ |
|
| 2993 | - public $show_ticket_sale_columns; |
|
| 2994 | - |
|
| 2995 | - /** |
|
| 2996 | - * @var boolean $show_ticket_details |
|
| 2997 | - */ |
|
| 2998 | - public $show_ticket_details; |
|
| 2999 | - |
|
| 3000 | - /** |
|
| 3001 | - * @var boolean $show_expired_tickets |
|
| 3002 | - */ |
|
| 3003 | - public $show_expired_tickets; |
|
| 3004 | - |
|
| 3005 | - /** |
|
| 3006 | - * whether or not to display a dropdown box populated with event datetimes |
|
| 3007 | - * that toggles which tickets are displayed for a ticket selector. |
|
| 3008 | - * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 3009 | - * |
|
| 3010 | - * @var string $show_datetime_selector |
|
| 3011 | - */ |
|
| 3012 | - private $show_datetime_selector = 'no_datetime_selector'; |
|
| 3013 | - |
|
| 3014 | - /** |
|
| 3015 | - * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 3016 | - * |
|
| 3017 | - * @var int $datetime_selector_threshold |
|
| 3018 | - */ |
|
| 3019 | - private $datetime_selector_threshold = 3; |
|
| 3020 | - |
|
| 3021 | - |
|
| 3022 | - |
|
| 3023 | - /** |
|
| 3024 | - * class constructor |
|
| 3025 | - */ |
|
| 3026 | - public function __construct() |
|
| 3027 | - { |
|
| 3028 | - $this->show_ticket_sale_columns = true; |
|
| 3029 | - $this->show_ticket_details = true; |
|
| 3030 | - $this->show_expired_tickets = true; |
|
| 3031 | - $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3032 | - $this->datetime_selector_threshold = 3; |
|
| 3033 | - } |
|
| 3034 | - |
|
| 3035 | - |
|
| 3036 | - |
|
| 3037 | - /** |
|
| 3038 | - * returns true if a datetime selector should be displayed |
|
| 3039 | - * |
|
| 3040 | - * @param array $datetimes |
|
| 3041 | - * @return bool |
|
| 3042 | - */ |
|
| 3043 | - public function showDatetimeSelector(array $datetimes) |
|
| 3044 | - { |
|
| 3045 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3046 | - return ! ( |
|
| 3047 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3048 | - || ( |
|
| 3049 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3050 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3051 | - ) |
|
| 3052 | - ); |
|
| 3053 | - } |
|
| 3054 | - |
|
| 3055 | - |
|
| 3056 | - |
|
| 3057 | - /** |
|
| 3058 | - * @return string |
|
| 3059 | - */ |
|
| 3060 | - public function getShowDatetimeSelector() |
|
| 3061 | - { |
|
| 3062 | - return $this->show_datetime_selector; |
|
| 3063 | - } |
|
| 3064 | - |
|
| 3065 | - |
|
| 3066 | - |
|
| 3067 | - /** |
|
| 3068 | - * @param bool $keys_only |
|
| 3069 | - * @return array |
|
| 3070 | - */ |
|
| 3071 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3072 | - { |
|
| 3073 | - return $keys_only |
|
| 3074 | - ? array( |
|
| 3075 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3076 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3077 | - ) |
|
| 3078 | - : array( |
|
| 3079 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3080 | - 'Do not show date & time filter', 'event_espresso' |
|
| 3081 | - ), |
|
| 3082 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3083 | - 'Maybe show date & time filter', 'event_espresso' |
|
| 3084 | - ), |
|
| 3085 | - ); |
|
| 3086 | - } |
|
| 3087 | - |
|
| 3088 | - |
|
| 3089 | - |
|
| 3090 | - /** |
|
| 3091 | - * @param string $show_datetime_selector |
|
| 3092 | - */ |
|
| 3093 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3094 | - { |
|
| 3095 | - $this->show_datetime_selector = in_array( |
|
| 3096 | - $show_datetime_selector, |
|
| 3097 | - $this->getShowDatetimeSelectorOptions(), |
|
| 3098 | - true |
|
| 3099 | - ) |
|
| 3100 | - ? $show_datetime_selector |
|
| 3101 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3102 | - } |
|
| 3103 | - |
|
| 3104 | - |
|
| 3105 | - |
|
| 3106 | - /** |
|
| 3107 | - * @return int |
|
| 3108 | - */ |
|
| 3109 | - public function getDatetimeSelectorThreshold() |
|
| 3110 | - { |
|
| 3111 | - return $this->datetime_selector_threshold; |
|
| 3112 | - } |
|
| 3113 | - |
|
| 3114 | - |
|
| 3115 | - |
|
| 3116 | - /** |
|
| 3117 | - * @param int $datetime_selector_threshold |
|
| 3118 | - */ |
|
| 3119 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3120 | - { |
|
| 3121 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3122 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3123 | - } |
|
| 2979 | + /** |
|
| 2980 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
| 2981 | + */ |
|
| 2982 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
| 2983 | + |
|
| 2984 | + /** |
|
| 2985 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
| 2986 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
| 2987 | + */ |
|
| 2988 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
| 2989 | + |
|
| 2990 | + /** |
|
| 2991 | + * @var boolean $show_ticket_sale_columns |
|
| 2992 | + */ |
|
| 2993 | + public $show_ticket_sale_columns; |
|
| 2994 | + |
|
| 2995 | + /** |
|
| 2996 | + * @var boolean $show_ticket_details |
|
| 2997 | + */ |
|
| 2998 | + public $show_ticket_details; |
|
| 2999 | + |
|
| 3000 | + /** |
|
| 3001 | + * @var boolean $show_expired_tickets |
|
| 3002 | + */ |
|
| 3003 | + public $show_expired_tickets; |
|
| 3004 | + |
|
| 3005 | + /** |
|
| 3006 | + * whether or not to display a dropdown box populated with event datetimes |
|
| 3007 | + * that toggles which tickets are displayed for a ticket selector. |
|
| 3008 | + * uses one of the *_DATETIME_SELECTOR constants defined above |
|
| 3009 | + * |
|
| 3010 | + * @var string $show_datetime_selector |
|
| 3011 | + */ |
|
| 3012 | + private $show_datetime_selector = 'no_datetime_selector'; |
|
| 3013 | + |
|
| 3014 | + /** |
|
| 3015 | + * the number of datetimes an event has to have before conditionally displaying a datetime selector |
|
| 3016 | + * |
|
| 3017 | + * @var int $datetime_selector_threshold |
|
| 3018 | + */ |
|
| 3019 | + private $datetime_selector_threshold = 3; |
|
| 3020 | + |
|
| 3021 | + |
|
| 3022 | + |
|
| 3023 | + /** |
|
| 3024 | + * class constructor |
|
| 3025 | + */ |
|
| 3026 | + public function __construct() |
|
| 3027 | + { |
|
| 3028 | + $this->show_ticket_sale_columns = true; |
|
| 3029 | + $this->show_ticket_details = true; |
|
| 3030 | + $this->show_expired_tickets = true; |
|
| 3031 | + $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3032 | + $this->datetime_selector_threshold = 3; |
|
| 3033 | + } |
|
| 3034 | + |
|
| 3035 | + |
|
| 3036 | + |
|
| 3037 | + /** |
|
| 3038 | + * returns true if a datetime selector should be displayed |
|
| 3039 | + * |
|
| 3040 | + * @param array $datetimes |
|
| 3041 | + * @return bool |
|
| 3042 | + */ |
|
| 3043 | + public function showDatetimeSelector(array $datetimes) |
|
| 3044 | + { |
|
| 3045 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
| 3046 | + return ! ( |
|
| 3047 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
| 3048 | + || ( |
|
| 3049 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
| 3050 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
| 3051 | + ) |
|
| 3052 | + ); |
|
| 3053 | + } |
|
| 3054 | + |
|
| 3055 | + |
|
| 3056 | + |
|
| 3057 | + /** |
|
| 3058 | + * @return string |
|
| 3059 | + */ |
|
| 3060 | + public function getShowDatetimeSelector() |
|
| 3061 | + { |
|
| 3062 | + return $this->show_datetime_selector; |
|
| 3063 | + } |
|
| 3064 | + |
|
| 3065 | + |
|
| 3066 | + |
|
| 3067 | + /** |
|
| 3068 | + * @param bool $keys_only |
|
| 3069 | + * @return array |
|
| 3070 | + */ |
|
| 3071 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
| 3072 | + { |
|
| 3073 | + return $keys_only |
|
| 3074 | + ? array( |
|
| 3075 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
| 3076 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
| 3077 | + ) |
|
| 3078 | + : array( |
|
| 3079 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3080 | + 'Do not show date & time filter', 'event_espresso' |
|
| 3081 | + ), |
|
| 3082 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
| 3083 | + 'Maybe show date & time filter', 'event_espresso' |
|
| 3084 | + ), |
|
| 3085 | + ); |
|
| 3086 | + } |
|
| 3087 | + |
|
| 3088 | + |
|
| 3089 | + |
|
| 3090 | + /** |
|
| 3091 | + * @param string $show_datetime_selector |
|
| 3092 | + */ |
|
| 3093 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
| 3094 | + { |
|
| 3095 | + $this->show_datetime_selector = in_array( |
|
| 3096 | + $show_datetime_selector, |
|
| 3097 | + $this->getShowDatetimeSelectorOptions(), |
|
| 3098 | + true |
|
| 3099 | + ) |
|
| 3100 | + ? $show_datetime_selector |
|
| 3101 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
| 3102 | + } |
|
| 3103 | + |
|
| 3104 | + |
|
| 3105 | + |
|
| 3106 | + /** |
|
| 3107 | + * @return int |
|
| 3108 | + */ |
|
| 3109 | + public function getDatetimeSelectorThreshold() |
|
| 3110 | + { |
|
| 3111 | + return $this->datetime_selector_threshold; |
|
| 3112 | + } |
|
| 3113 | + |
|
| 3114 | + |
|
| 3115 | + |
|
| 3116 | + /** |
|
| 3117 | + * @param int $datetime_selector_threshold |
|
| 3118 | + */ |
|
| 3119 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
| 3120 | + { |
|
| 3121 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
| 3122 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
| 3123 | + } |
|
| 3124 | 3124 | |
| 3125 | 3125 | |
| 3126 | 3126 | } |
@@ -3137,85 +3137,85 @@ discard block |
||
| 3137 | 3137 | class EE_Environment_Config extends EE_Config_Base |
| 3138 | 3138 | { |
| 3139 | 3139 | |
| 3140 | - /** |
|
| 3141 | - * Hold any php environment variables that we want to track. |
|
| 3142 | - * |
|
| 3143 | - * @var stdClass; |
|
| 3144 | - */ |
|
| 3145 | - public $php; |
|
| 3146 | - |
|
| 3147 | - |
|
| 3148 | - |
|
| 3149 | - /** |
|
| 3150 | - * constructor |
|
| 3151 | - */ |
|
| 3152 | - public function __construct() |
|
| 3153 | - { |
|
| 3154 | - $this->php = new stdClass(); |
|
| 3155 | - $this->_set_php_values(); |
|
| 3156 | - } |
|
| 3157 | - |
|
| 3158 | - |
|
| 3159 | - |
|
| 3160 | - /** |
|
| 3161 | - * This sets the php environment variables. |
|
| 3162 | - * |
|
| 3163 | - * @since 4.4.0 |
|
| 3164 | - * @return void |
|
| 3165 | - */ |
|
| 3166 | - protected function _set_php_values() |
|
| 3167 | - { |
|
| 3168 | - $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3169 | - $this->php->version = phpversion(); |
|
| 3170 | - } |
|
| 3171 | - |
|
| 3172 | - |
|
| 3173 | - |
|
| 3174 | - /** |
|
| 3175 | - * helper method for determining whether input_count is |
|
| 3176 | - * reaching the potential maximum the server can handle |
|
| 3177 | - * according to max_input_vars |
|
| 3178 | - * |
|
| 3179 | - * @param int $input_count the count of input vars. |
|
| 3180 | - * @return array { |
|
| 3181 | - * An array that represents whether available space and if no available space the error |
|
| 3182 | - * message. |
|
| 3183 | - * @type bool $has_space whether more inputs can be added. |
|
| 3184 | - * @type string $msg Any message to be displayed. |
|
| 3185 | - * } |
|
| 3186 | - */ |
|
| 3187 | - public function max_input_vars_limit_check($input_count = 0) |
|
| 3188 | - { |
|
| 3189 | - if ( ! empty($this->php->max_input_vars) |
|
| 3190 | - && ($input_count >= $this->php->max_input_vars) |
|
| 3191 | - && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3192 | - ) { |
|
| 3193 | - return sprintf( |
|
| 3194 | - __( |
|
| 3195 | - 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3196 | - 'event_espresso' |
|
| 3197 | - ), |
|
| 3198 | - '<br>', |
|
| 3199 | - $input_count, |
|
| 3200 | - $this->php->max_input_vars |
|
| 3201 | - ); |
|
| 3202 | - } else { |
|
| 3203 | - return ''; |
|
| 3204 | - } |
|
| 3205 | - } |
|
| 3206 | - |
|
| 3207 | - |
|
| 3208 | - |
|
| 3209 | - /** |
|
| 3210 | - * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3211 | - * |
|
| 3212 | - * @since 4.4.1 |
|
| 3213 | - * @return void |
|
| 3214 | - */ |
|
| 3215 | - public function recheck_values() |
|
| 3216 | - { |
|
| 3217 | - $this->_set_php_values(); |
|
| 3218 | - } |
|
| 3140 | + /** |
|
| 3141 | + * Hold any php environment variables that we want to track. |
|
| 3142 | + * |
|
| 3143 | + * @var stdClass; |
|
| 3144 | + */ |
|
| 3145 | + public $php; |
|
| 3146 | + |
|
| 3147 | + |
|
| 3148 | + |
|
| 3149 | + /** |
|
| 3150 | + * constructor |
|
| 3151 | + */ |
|
| 3152 | + public function __construct() |
|
| 3153 | + { |
|
| 3154 | + $this->php = new stdClass(); |
|
| 3155 | + $this->_set_php_values(); |
|
| 3156 | + } |
|
| 3157 | + |
|
| 3158 | + |
|
| 3159 | + |
|
| 3160 | + /** |
|
| 3161 | + * This sets the php environment variables. |
|
| 3162 | + * |
|
| 3163 | + * @since 4.4.0 |
|
| 3164 | + * @return void |
|
| 3165 | + */ |
|
| 3166 | + protected function _set_php_values() |
|
| 3167 | + { |
|
| 3168 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
| 3169 | + $this->php->version = phpversion(); |
|
| 3170 | + } |
|
| 3171 | + |
|
| 3172 | + |
|
| 3173 | + |
|
| 3174 | + /** |
|
| 3175 | + * helper method for determining whether input_count is |
|
| 3176 | + * reaching the potential maximum the server can handle |
|
| 3177 | + * according to max_input_vars |
|
| 3178 | + * |
|
| 3179 | + * @param int $input_count the count of input vars. |
|
| 3180 | + * @return array { |
|
| 3181 | + * An array that represents whether available space and if no available space the error |
|
| 3182 | + * message. |
|
| 3183 | + * @type bool $has_space whether more inputs can be added. |
|
| 3184 | + * @type string $msg Any message to be displayed. |
|
| 3185 | + * } |
|
| 3186 | + */ |
|
| 3187 | + public function max_input_vars_limit_check($input_count = 0) |
|
| 3188 | + { |
|
| 3189 | + if ( ! empty($this->php->max_input_vars) |
|
| 3190 | + && ($input_count >= $this->php->max_input_vars) |
|
| 3191 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
| 3192 | + ) { |
|
| 3193 | + return sprintf( |
|
| 3194 | + __( |
|
| 3195 | + 'The maximum number of inputs on this page has been exceeded. You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', |
|
| 3196 | + 'event_espresso' |
|
| 3197 | + ), |
|
| 3198 | + '<br>', |
|
| 3199 | + $input_count, |
|
| 3200 | + $this->php->max_input_vars |
|
| 3201 | + ); |
|
| 3202 | + } else { |
|
| 3203 | + return ''; |
|
| 3204 | + } |
|
| 3205 | + } |
|
| 3206 | + |
|
| 3207 | + |
|
| 3208 | + |
|
| 3209 | + /** |
|
| 3210 | + * The purpose of this method is just to force rechecking php values so if they've changed, they get updated. |
|
| 3211 | + * |
|
| 3212 | + * @since 4.4.1 |
|
| 3213 | + * @return void |
|
| 3214 | + */ |
|
| 3215 | + public function recheck_values() |
|
| 3216 | + { |
|
| 3217 | + $this->_set_php_values(); |
|
| 3218 | + } |
|
| 3219 | 3219 | |
| 3220 | 3220 | |
| 3221 | 3221 | } |
@@ -3232,22 +3232,22 @@ discard block |
||
| 3232 | 3232 | class EE_Tax_Config extends EE_Config_Base |
| 3233 | 3233 | { |
| 3234 | 3234 | |
| 3235 | - /* |
|
| 3235 | + /* |
|
| 3236 | 3236 | * flag to indicate whether or not to display ticket prices with the taxes included |
| 3237 | 3237 | * |
| 3238 | 3238 | * @var boolean $prices_displayed_including_taxes |
| 3239 | 3239 | */ |
| 3240 | - public $prices_displayed_including_taxes; |
|
| 3240 | + public $prices_displayed_including_taxes; |
|
| 3241 | 3241 | |
| 3242 | 3242 | |
| 3243 | 3243 | |
| 3244 | - /** |
|
| 3245 | - * class constructor |
|
| 3246 | - */ |
|
| 3247 | - public function __construct() |
|
| 3248 | - { |
|
| 3249 | - $this->prices_displayed_including_taxes = true; |
|
| 3250 | - } |
|
| 3244 | + /** |
|
| 3245 | + * class constructor |
|
| 3246 | + */ |
|
| 3247 | + public function __construct() |
|
| 3248 | + { |
|
| 3249 | + $this->prices_displayed_including_taxes = true; |
|
| 3250 | + } |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | |
@@ -3260,34 +3260,34 @@ discard block |
||
| 3260 | 3260 | class EE_Gateway_Config extends EE_Config_Base |
| 3261 | 3261 | { |
| 3262 | 3262 | |
| 3263 | - /** |
|
| 3264 | - * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3265 | - * with any config info the gateway wants to store |
|
| 3266 | - * |
|
| 3267 | - * @var array |
|
| 3268 | - */ |
|
| 3269 | - public $payment_settings; |
|
| 3270 | - |
|
| 3271 | - /** |
|
| 3272 | - * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3273 | - * the gateway is stored in the uploads directory |
|
| 3274 | - * |
|
| 3275 | - * @var array |
|
| 3276 | - */ |
|
| 3277 | - public $active_gateways; |
|
| 3278 | - |
|
| 3279 | - |
|
| 3280 | - |
|
| 3281 | - /** |
|
| 3282 | - * class constructor |
|
| 3283 | - * |
|
| 3284 | - * @deprecated |
|
| 3285 | - */ |
|
| 3286 | - public function __construct() |
|
| 3287 | - { |
|
| 3288 | - $this->payment_settings = array(); |
|
| 3289 | - $this->active_gateways = array('Invoice' => false); |
|
| 3290 | - } |
|
| 3263 | + /** |
|
| 3264 | + * Array with keys that are payment gateways slugs, and values are arrays |
|
| 3265 | + * with any config info the gateway wants to store |
|
| 3266 | + * |
|
| 3267 | + * @var array |
|
| 3268 | + */ |
|
| 3269 | + public $payment_settings; |
|
| 3270 | + |
|
| 3271 | + /** |
|
| 3272 | + * Where keys are gateway slugs, and values are booleans indicating whether or not |
|
| 3273 | + * the gateway is stored in the uploads directory |
|
| 3274 | + * |
|
| 3275 | + * @var array |
|
| 3276 | + */ |
|
| 3277 | + public $active_gateways; |
|
| 3278 | + |
|
| 3279 | + |
|
| 3280 | + |
|
| 3281 | + /** |
|
| 3282 | + * class constructor |
|
| 3283 | + * |
|
| 3284 | + * @deprecated |
|
| 3285 | + */ |
|
| 3286 | + public function __construct() |
|
| 3287 | + { |
|
| 3288 | + $this->payment_settings = array(); |
|
| 3289 | + $this->active_gateways = array('Invoice' => false); |
|
| 3290 | + } |
|
| 3291 | 3291 | } |
| 3292 | 3292 | |
| 3293 | 3293 | // End of file EE_Config.core.php |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | $this |
| 279 | 279 | ); |
| 280 | 280 | if (is_object($settings) && property_exists($this, $config)) { |
| 281 | - $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings); |
|
| 281 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
| 282 | 282 | //call configs populate method to ensure any defaults are set for empty values. |
| 283 | 283 | if (method_exists($settings, 'populate')) { |
| 284 | 284 | $this->{$config}->populate(); |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | */ |
| 688 | 688 | private function _generate_config_option_name($section = '', $name = '') |
| 689 | 689 | { |
| 690 | - return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 690 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | { |
| 706 | 706 | return ! empty($config_class) |
| 707 | 707 | ? $config_class |
| 708 | - : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config'; |
|
| 708 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | 'event_espresso' |
| 822 | 822 | ), |
| 823 | 823 | $config_class, |
| 824 | - 'EE_Config->' . $section . '->' . $name |
|
| 824 | + 'EE_Config->'.$section.'->'.$name |
|
| 825 | 825 | ), |
| 826 | 826 | __FILE__, |
| 827 | 827 | __FUNCTION__, |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | // retrieve the wp-option for this config class. |
| 895 | 895 | $config_option = maybe_unserialize(get_option($config_option_name, array())); |
| 896 | 896 | if (empty($config_option)) { |
| 897 | - EE_Config::log($config_option_name . '-NOT-FOUND'); |
|
| 897 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
| 898 | 898 | } |
| 899 | 899 | return $config_option; |
| 900 | 900 | } |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | //copy incoming $_REQUEST and sanitize it so we can save it |
| 914 | 914 | $_request = $_REQUEST; |
| 915 | 915 | array_walk_recursive($_request, 'sanitize_text_field'); |
| 916 | - $config_log[(string)microtime(true)] = array( |
|
| 916 | + $config_log[(string) microtime(true)] = array( |
|
| 917 | 917 | 'config_name' => $config_option_name, |
| 918 | 918 | 'request' => $_request, |
| 919 | 919 | ); |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | ) |
| 1020 | 1020 | ) { |
| 1021 | 1021 | // grab list of installed widgets |
| 1022 | - $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR); |
|
| 1022 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
| 1023 | 1023 | // filter list of modules to register |
| 1024 | 1024 | $widgets_to_register = apply_filters( |
| 1025 | 1025 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
@@ -1076,31 +1076,31 @@ discard block |
||
| 1076 | 1076 | // create classname from widget directory name |
| 1077 | 1077 | $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
| 1078 | 1078 | // add class prefix |
| 1079 | - $widget_class = 'EEW_' . $widget; |
|
| 1079 | + $widget_class = 'EEW_'.$widget; |
|
| 1080 | 1080 | // does the widget exist ? |
| 1081 | - if ( ! is_readable($widget_path . DS . $widget_class . $widget_ext)) { |
|
| 1081 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
| 1082 | 1082 | $msg = sprintf( |
| 1083 | 1083 | __( |
| 1084 | 1084 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
| 1085 | 1085 | 'event_espresso' |
| 1086 | 1086 | ), |
| 1087 | 1087 | $widget_class, |
| 1088 | - $widget_path . DS . $widget_class . $widget_ext |
|
| 1088 | + $widget_path.DS.$widget_class.$widget_ext |
|
| 1089 | 1089 | ); |
| 1090 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1090 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1091 | 1091 | return; |
| 1092 | 1092 | } |
| 1093 | 1093 | // load the widget class file |
| 1094 | - require_once($widget_path . DS . $widget_class . $widget_ext); |
|
| 1094 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
| 1095 | 1095 | // verify that class exists |
| 1096 | 1096 | if ( ! class_exists($widget_class)) { |
| 1097 | 1097 | $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
| 1098 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1098 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1099 | 1099 | return; |
| 1100 | 1100 | } |
| 1101 | 1101 | register_widget($widget_class); |
| 1102 | 1102 | // add to array of registered widgets |
| 1103 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
| 1103 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | private function _register_shortcodes() |
| 1115 | 1115 | { |
| 1116 | 1116 | // grab list of installed shortcodes |
| 1117 | - $shortcodes_to_register = glob(EE_SHORTCODES . '*', GLOB_ONLYDIR); |
|
| 1117 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
| 1118 | 1118 | // filter list of modules to register |
| 1119 | 1119 | $shortcodes_to_register = apply_filters( |
| 1120 | 1120 | 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
@@ -1164,44 +1164,44 @@ discard block |
||
| 1164 | 1164 | // remove last segment |
| 1165 | 1165 | array_pop($shortcode_path); |
| 1166 | 1166 | // glue it back together |
| 1167 | - $shortcode_path = implode(DS, $shortcode_path) . DS; |
|
| 1167 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
| 1168 | 1168 | } else { |
| 1169 | 1169 | // we need to generate the filename based off of the folder name |
| 1170 | 1170 | // grab and sanitize shortcode directory name |
| 1171 | 1171 | $shortcode = sanitize_key(basename($shortcode_path)); |
| 1172 | - $shortcode_path = rtrim($shortcode_path, DS) . DS; |
|
| 1172 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | // create classname from shortcode directory or file name |
| 1175 | 1175 | $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
| 1176 | 1176 | // add class prefix |
| 1177 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1177 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 1178 | 1178 | // does the shortcode exist ? |
| 1179 | - if ( ! is_readable($shortcode_path . DS . $shortcode_class . $shortcode_ext)) { |
|
| 1179 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
| 1180 | 1180 | $msg = sprintf( |
| 1181 | 1181 | __( |
| 1182 | 1182 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
| 1183 | 1183 | 'event_espresso' |
| 1184 | 1184 | ), |
| 1185 | 1185 | $shortcode_class, |
| 1186 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
| 1186 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
| 1187 | 1187 | ); |
| 1188 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1188 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1189 | 1189 | return false; |
| 1190 | 1190 | } |
| 1191 | 1191 | // load the shortcode class file |
| 1192 | - require_once($shortcode_path . $shortcode_class . $shortcode_ext); |
|
| 1192 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
| 1193 | 1193 | // verify that class exists |
| 1194 | 1194 | if ( ! class_exists($shortcode_class)) { |
| 1195 | 1195 | $msg = sprintf( |
| 1196 | 1196 | __('The requested %s shortcode class does not exist.', 'event_espresso'), |
| 1197 | 1197 | $shortcode_class |
| 1198 | 1198 | ); |
| 1199 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1199 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1200 | 1200 | return false; |
| 1201 | 1201 | } |
| 1202 | 1202 | $shortcode = strtoupper($shortcode); |
| 1203 | 1203 | // add to array of registered shortcodes |
| 1204 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
| 1204 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
| 1205 | 1205 | return true; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | private function _register_modules() |
| 1217 | 1217 | { |
| 1218 | 1218 | // grab list of installed modules |
| 1219 | - $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR); |
|
| 1219 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
| 1220 | 1220 | // filter list of modules to register |
| 1221 | 1221 | $modules_to_register = apply_filters( |
| 1222 | 1222 | 'FHEE__EE_Config__register_modules__modules_to_register', |
@@ -1227,8 +1227,8 @@ discard block |
||
| 1227 | 1227 | foreach ($modules_to_register as $module_path) { |
| 1228 | 1228 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
| 1229 | 1229 | if ( |
| 1230 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
| 1231 | - && $module_path !== EE_MODULES . 'gateways' |
|
| 1230 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
| 1231 | + && $module_path !== EE_MODULES.'gateways' |
|
| 1232 | 1232 | ) { |
| 1233 | 1233 | // add to list of installed modules |
| 1234 | 1234 | EE_Config::register_module($module_path); |
@@ -1266,25 +1266,25 @@ discard block |
||
| 1266 | 1266 | // remove last segment |
| 1267 | 1267 | array_pop($module_path); |
| 1268 | 1268 | // glue it back together |
| 1269 | - $module_path = implode(DS, $module_path) . DS; |
|
| 1269 | + $module_path = implode(DS, $module_path).DS; |
|
| 1270 | 1270 | // take first segment from file name pieces and sanitize it |
| 1271 | 1271 | $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
| 1272 | 1272 | // ensure class prefix is added |
| 1273 | - $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module; |
|
| 1273 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
| 1274 | 1274 | } else { |
| 1275 | 1275 | // we need to generate the filename based off of the folder name |
| 1276 | 1276 | // grab and sanitize module name |
| 1277 | 1277 | $module = strtolower(basename($module_path)); |
| 1278 | 1278 | $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
| 1279 | 1279 | // like trailingslashit() |
| 1280 | - $module_path = rtrim($module_path, DS) . DS; |
|
| 1280 | + $module_path = rtrim($module_path, DS).DS; |
|
| 1281 | 1281 | // create classname from module directory name |
| 1282 | 1282 | $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
| 1283 | 1283 | // add class prefix |
| 1284 | - $module_class = 'EED_' . $module; |
|
| 1284 | + $module_class = 'EED_'.$module; |
|
| 1285 | 1285 | } |
| 1286 | 1286 | // does the module exist ? |
| 1287 | - if ( ! is_readable($module_path . DS . $module_class . $module_ext)) { |
|
| 1287 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
| 1288 | 1288 | $msg = sprintf( |
| 1289 | 1289 | __( |
| 1290 | 1290 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1292,19 +1292,19 @@ discard block |
||
| 1292 | 1292 | ), |
| 1293 | 1293 | $module |
| 1294 | 1294 | ); |
| 1295 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1295 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1296 | 1296 | return false; |
| 1297 | 1297 | } |
| 1298 | 1298 | // load the module class file |
| 1299 | - require_once($module_path . $module_class . $module_ext); |
|
| 1299 | + require_once($module_path.$module_class.$module_ext); |
|
| 1300 | 1300 | // verify that class exists |
| 1301 | 1301 | if ( ! class_exists($module_class)) { |
| 1302 | 1302 | $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
| 1303 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1303 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1304 | 1304 | return false; |
| 1305 | 1305 | } |
| 1306 | 1306 | // add to array of registered modules |
| 1307 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
| 1307 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
| 1308 | 1308 | do_action( |
| 1309 | 1309 | 'AHEE__EE_Config__register_module__complete', |
| 1310 | 1310 | $module_class, |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | // cycle thru shortcode folders |
| 1328 | 1328 | foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
| 1329 | 1329 | // add class prefix |
| 1330 | - $shortcode_class = 'EES_' . $shortcode; |
|
| 1330 | + $shortcode_class = 'EES_'.$shortcode; |
|
| 1331 | 1331 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
| 1332 | 1332 | // which set hooks ? |
| 1333 | 1333 | if (is_admin()) { |
@@ -1394,26 +1394,26 @@ discard block |
||
| 1394 | 1394 | { |
| 1395 | 1395 | do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
| 1396 | 1396 | $module = str_replace('EED_', '', $module); |
| 1397 | - $module_class = 'EED_' . $module; |
|
| 1397 | + $module_class = 'EED_'.$module; |
|
| 1398 | 1398 | if ( ! isset(EE_Registry::instance()->modules->{$module_class})) { |
| 1399 | 1399 | $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
| 1400 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1400 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1401 | 1401 | return false; |
| 1402 | 1402 | } |
| 1403 | 1403 | if (empty($route)) { |
| 1404 | 1404 | $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
| 1405 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1405 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1406 | 1406 | return false; |
| 1407 | 1407 | } |
| 1408 | - if ( ! method_exists('EED_' . $module, $method_name)) { |
|
| 1408 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
| 1409 | 1409 | $msg = sprintf( |
| 1410 | 1410 | __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
| 1411 | 1411 | $route |
| 1412 | 1412 | ); |
| 1413 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1413 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1414 | 1414 | return false; |
| 1415 | 1415 | } |
| 1416 | - EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name); |
|
| 1416 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
| 1417 | 1417 | return true; |
| 1418 | 1418 | } |
| 1419 | 1419 | |
@@ -1430,7 +1430,7 @@ discard block |
||
| 1430 | 1430 | public static function get_route($route = null, $key = 'ee') |
| 1431 | 1431 | { |
| 1432 | 1432 | do_action('AHEE__EE_Config__get_route__begin', $route); |
| 1433 | - $route = (string)apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1433 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
| 1434 | 1434 | if (isset(EE_Config::$_module_route_map[$key][$route])) { |
| 1435 | 1435 | return EE_Config::$_module_route_map[$key][$route]; |
| 1436 | 1436 | } |
@@ -1471,12 +1471,12 @@ discard block |
||
| 1471 | 1471 | __('The module route %s for this forward has not been registered.', 'event_espresso'), |
| 1472 | 1472 | $route |
| 1473 | 1473 | ); |
| 1474 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1474 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1475 | 1475 | return false; |
| 1476 | 1476 | } |
| 1477 | 1477 | if (empty($forward)) { |
| 1478 | 1478 | $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
| 1479 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1479 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1480 | 1480 | return false; |
| 1481 | 1481 | } |
| 1482 | 1482 | if (is_array($forward)) { |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
| 1486 | 1486 | $route |
| 1487 | 1487 | ); |
| 1488 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1488 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1489 | 1489 | return false; |
| 1490 | 1490 | } |
| 1491 | 1491 | if ( ! method_exists($forward[0], $forward[1])) { |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | $forward[1], |
| 1495 | 1495 | $route |
| 1496 | 1496 | ); |
| 1497 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1497 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1498 | 1498 | return false; |
| 1499 | 1499 | } |
| 1500 | 1500 | } else if ( ! function_exists($forward)) { |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | $forward, |
| 1504 | 1504 | $route |
| 1505 | 1505 | ); |
| 1506 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1506 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1507 | 1507 | return false; |
| 1508 | 1508 | } |
| 1509 | 1509 | EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
@@ -1558,7 +1558,7 @@ discard block |
||
| 1558 | 1558 | __('The module route %s for this view has not been registered.', 'event_espresso'), |
| 1559 | 1559 | $route |
| 1560 | 1560 | ); |
| 1561 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1561 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1562 | 1562 | return false; |
| 1563 | 1563 | } |
| 1564 | 1564 | if ( ! is_readable($view)) { |
@@ -1569,7 +1569,7 @@ discard block |
||
| 1569 | 1569 | ), |
| 1570 | 1570 | $view |
| 1571 | 1571 | ); |
| 1572 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1572 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1573 | 1573 | return false; |
| 1574 | 1574 | } |
| 1575 | 1575 | EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
@@ -1886,7 +1886,7 @@ discard block |
||
| 1886 | 1886 | $this->reg_page_url = add_query_arg( |
| 1887 | 1887 | array('uts' => time()), |
| 1888 | 1888 | get_permalink($this->reg_page_id) |
| 1889 | - ) . '#checkout'; |
|
| 1889 | + ).'#checkout'; |
|
| 1890 | 1890 | } |
| 1891 | 1891 | return $this->reg_page_url; |
| 1892 | 1892 | } |
@@ -1990,13 +1990,13 @@ discard block |
||
| 1990 | 1990 | $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
| 1991 | 1991 | $option = 'ee_ueip_optin'; |
| 1992 | 1992 | //set correct table for query |
| 1993 | - $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options'; |
|
| 1993 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
| 1994 | 1994 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
| 1995 | 1995 | //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be |
| 1996 | 1996 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
| 1997 | 1997 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
| 1998 | 1998 | //for the purpose of caching. |
| 1999 | - $pre = apply_filters('pre_option_' . $option, false, $option); |
|
| 1999 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
| 2000 | 2000 | if (false !== $pre) { |
| 2001 | 2001 | EE_Core_Config::$ee_ueip_option = $pre; |
| 2002 | 2002 | return EE_Core_Config::$ee_ueip_option; |
@@ -2006,9 +2006,9 @@ discard block |
||
| 2006 | 2006 | if (is_object($row)) { |
| 2007 | 2007 | $value = $row->option_value; |
| 2008 | 2008 | } else { //option does not exist so use default. |
| 2009 | - return apply_filters('default_option_' . $option, false, $option); |
|
| 2009 | + return apply_filters('default_option_'.$option, false, $option); |
|
| 2010 | 2010 | } |
| 2011 | - EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option); |
|
| 2011 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
| 2012 | 2012 | return EE_Core_Config::$ee_ueip_option; |
| 2013 | 2013 | } |
| 2014 | 2014 | |
@@ -2285,27 +2285,27 @@ discard block |
||
| 2285 | 2285 | // retrieve the country settings from the db, just in case they have been customized |
| 2286 | 2286 | $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
| 2287 | 2287 | if ($country instanceof EE_Country) { |
| 2288 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2289 | - $this->name = $country->currency_name_single(); // Dollar |
|
| 2290 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2291 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2292 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2293 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2294 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2295 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2288 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
| 2289 | + $this->name = $country->currency_name_single(); // Dollar |
|
| 2290 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
| 2291 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
| 2292 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
| 2293 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2294 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2295 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2296 | 2296 | } |
| 2297 | 2297 | } |
| 2298 | 2298 | // fallback to hardcoded defaults, in case the above failed |
| 2299 | 2299 | if (empty($this->code)) { |
| 2300 | 2300 | // set default currency settings |
| 2301 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2302 | - $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2303 | - $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2304 | - $this->sign = '$'; // currency sign: $ |
|
| 2305 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2306 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2307 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2308 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2301 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
| 2302 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
| 2303 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
| 2304 | + $this->sign = '$'; // currency sign: $ |
|
| 2305 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
| 2306 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
| 2307 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
| 2308 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
| 2309 | 2309 | } |
| 2310 | 2310 | } |
| 2311 | 2311 | } |
@@ -2628,7 +2628,7 @@ discard block |
||
| 2628 | 2628 | public function log_file_name($reset = false) |
| 2629 | 2629 | { |
| 2630 | 2630 | if (empty($this->log_file_name) || $reset) { |
| 2631 | - $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt'; |
|
| 2631 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
| 2632 | 2632 | EE_Config::instance()->update_espresso_config(false, false); |
| 2633 | 2633 | } |
| 2634 | 2634 | return $this->log_file_name; |
@@ -2643,7 +2643,7 @@ discard block |
||
| 2643 | 2643 | public function debug_file_name($reset = false) |
| 2644 | 2644 | { |
| 2645 | 2645 | if (empty($this->debug_file_name) || $reset) { |
| 2646 | - $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt'; |
|
| 2646 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
| 2647 | 2647 | EE_Config::instance()->update_espresso_config(false, false); |
| 2648 | 2648 | } |
| 2649 | 2649 | return $this->debug_file_name; |
@@ -2859,21 +2859,21 @@ discard block |
||
| 2859 | 2859 | $this->use_google_maps = true; |
| 2860 | 2860 | $this->google_map_api_key = ''; |
| 2861 | 2861 | // for event details pages (reg page) |
| 2862 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2863 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2864 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2865 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2866 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2867 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2868 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2862 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
| 2863 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
| 2864 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
| 2865 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
| 2866 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
| 2867 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
| 2868 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
| 2869 | 2869 | // for event list pages |
| 2870 | - $this->event_list_map_width = 300; // ee_map_width |
|
| 2871 | - $this->event_list_map_height = 185; // ee_map_height |
|
| 2872 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2873 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2874 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2875 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2876 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2870 | + $this->event_list_map_width = 300; // ee_map_width |
|
| 2871 | + $this->event_list_map_height = 185; // ee_map_height |
|
| 2872 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
| 2873 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
| 2874 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
| 2875 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
| 2876 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
| 2877 | 2877 | } |
| 2878 | 2878 | |
| 2879 | 2879 | } |
@@ -16,282 +16,282 @@ |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var string $iframe_name |
|
| 21 | - */ |
|
| 22 | - private $iframe_name; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var string $route_name |
|
| 26 | - */ |
|
| 27 | - private $route_name; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var string $slug |
|
| 31 | - */ |
|
| 32 | - private $slug; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var boolean $append_filterable_content |
|
| 36 | - */ |
|
| 37 | - private $append_filterable_content; |
|
| 38 | - |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * IframeEmbedButton constructor. |
|
| 43 | - * |
|
| 44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
| 45 | - * @param string $route_name the name of the registered route |
|
| 46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
| 47 | - * will most likely be "event" since that's the only usage atm |
|
| 48 | - */ |
|
| 49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
| 50 | - { |
|
| 51 | - $this->iframe_name = $iframe_name; |
|
| 52 | - $this->route_name = $route_name; |
|
| 53 | - $this->slug = $slug; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Adds an iframe embed code button to the Event editor. |
|
| 60 | - */ |
|
| 61 | - public function addEventEditorIframeEmbedButtonFilter() |
|
| 62 | - { |
|
| 63 | - // add button for iframe code to event editor. |
|
| 64 | - add_filter( |
|
| 65 | - 'get_sample_permalink_html', |
|
| 66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
| 67 | - 10, |
|
| 68 | - 2 |
|
| 69 | - ); |
|
| 70 | - add_action( |
|
| 71 | - 'admin_enqueue_scripts', |
|
| 72 | - array( $this, 'embedButtonAssets' ), |
|
| 73 | - 10 |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param $permalink_string |
|
| 81 | - * @param $id |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
| 85 | - { |
|
| 86 | - return $this->eventEditorIframeEmbedButton( |
|
| 87 | - $permalink_string, |
|
| 88 | - $id |
|
| 89 | - ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * iframe embed code button to the Event editor. |
|
| 96 | - * |
|
| 97 | - * @param string $permalink_string |
|
| 98 | - * @param int $id |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public function eventEditorIframeEmbedButton( |
|
| 102 | - $permalink_string, |
|
| 103 | - $id |
|
| 104 | - ) { |
|
| 105 | - //make sure this is ONLY when editing and the event id has been set. |
|
| 106 | - if ( ! empty( $id ) ) { |
|
| 107 | - $post = get_post( $id ); |
|
| 108 | - //if NOT event then let's get out. |
|
| 109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
| 110 | - return $permalink_string; |
|
| 111 | - } |
|
| 112 | - $permalink_string .= $this->embedButtonHtml( |
|
| 113 | - array( $this->slug => $id ), |
|
| 114 | - 'button-small' |
|
| 115 | - ); |
|
| 116 | - } |
|
| 117 | - return $permalink_string; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
| 124 | - * |
|
| 125 | - * @param string $action name of the WP do_action() to hook into |
|
| 126 | - */ |
|
| 127 | - public function addActionIframeEmbedButton( $action ) |
|
| 128 | - { |
|
| 129 | - // add button for iframe code to event editor. |
|
| 130 | - add_action( |
|
| 131 | - $action, |
|
| 132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
| 133 | - 10, 2 |
|
| 134 | - ); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return void |
|
| 141 | - */ |
|
| 142 | - public function addActionIframeEmbedButtonCallback() |
|
| 143 | - { |
|
| 144 | - echo $this->embedButtonHtml(); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
| 151 | - * |
|
| 152 | - * @param string $filter name of the WP apply_filters() to hook into |
|
| 153 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
| 154 | - * else if false, will add to the beginning of the content |
|
| 155 | - */ |
|
| 156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
| 157 | - { |
|
| 158 | - $this->append_filterable_content = $append; |
|
| 159 | - // add button for iframe code to event editor. |
|
| 160 | - add_filter( |
|
| 161 | - $filter, |
|
| 162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
| 163 | - 10 |
|
| 164 | - ); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @param array|string $filterable_content |
|
| 171 | - * @return array|string |
|
| 172 | - */ |
|
| 173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
| 174 | - { |
|
| 175 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
| 176 | - if ( is_array( $filterable_content ) ) { |
|
| 177 | - $filterable_content = $this->append_filterable_content |
|
| 178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
| 179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
| 180 | - } else { |
|
| 181 | - $filterable_content = $this->append_filterable_content |
|
| 182 | - ? $filterable_content . $embedButtonHtml |
|
| 183 | - : $embedButtonHtml . $filterable_content; |
|
| 184 | - } |
|
| 185 | - return $filterable_content; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * iframe_embed_html |
|
| 192 | - * |
|
| 193 | - * @param array $query_args |
|
| 194 | - * @param string $button_class |
|
| 195 | - * @return string |
|
| 196 | - */ |
|
| 197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
| 198 | - { |
|
| 199 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
| 200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
| 201 | - $query_args = (array)apply_filters( |
|
| 202 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
| 203 | - $query_args |
|
| 204 | - ); |
|
| 205 | - // add this route to our localized vars |
|
| 206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
| 207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
| 208 | - : array(); |
|
| 209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
| 210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
| 211 | - $iframe_embed_html = \EEH_HTML::link( |
|
| 212 | - '#', |
|
| 213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
| 214 | - sprintf( |
|
| 215 | - esc_html__( |
|
| 216 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
| 217 | - 'event_espresso' |
|
| 218 | - ), |
|
| 219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
| 220 | - ), |
|
| 221 | - "{$this->route_name}-iframe-embed-trigger-js", |
|
| 222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
| 223 | - '', |
|
| 224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
| 225 | - ); |
|
| 226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
| 227 | - 'display:none;' ); |
|
| 228 | - $iframe_embed_html .= esc_html( |
|
| 229 | - \EEH_HTML::div( |
|
| 230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
| 231 | - '', |
|
| 232 | - '', |
|
| 233 | - 'width:100%; height: 500px;' |
|
| 234 | - ) |
|
| 235 | - ); |
|
| 236 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
| 237 | - return $iframe_embed_html; |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * enqueue iframe button js |
|
| 244 | - */ |
|
| 245 | - public function embedButtonAssets() |
|
| 246 | - { |
|
| 247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
| 248 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
| 249 | - 'event_espresso' |
|
| 250 | - ); |
|
| 251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
| 252 | - 'click anywhere outside of this window to close it.', |
|
| 253 | - 'event_espresso' |
|
| 254 | - ); |
|
| 255 | - wp_register_script( |
|
| 256 | - 'iframe_embed_button', |
|
| 257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
| 258 | - array( 'ee-dialog' ), |
|
| 259 | - EVENT_ESPRESSO_VERSION, |
|
| 260 | - true |
|
| 261 | - ); |
|
| 262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * generates embed button sections for admin pages |
|
| 269 | - * |
|
| 270 | - * @param array $embed_buttons |
|
| 271 | - * @return string |
|
| 272 | - */ |
|
| 273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
| 274 | - { |
|
| 275 | - $embed_buttons = (array)apply_filters( |
|
| 276 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
| 277 | - $embed_buttons |
|
| 278 | - ); |
|
| 279 | - if ( empty($embed_buttons)) { |
|
| 280 | - return ''; |
|
| 281 | - } |
|
| 282 | - // add button for iframe code to event editor. |
|
| 283 | - $html = \EEH_HTML::br( 2 ); |
|
| 284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
| 285 | - $html .= \EEH_HTML::p( |
|
| 286 | - esc_html__( |
|
| 287 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
| 288 | - 'event_espresso' |
|
| 289 | - ) |
|
| 290 | - ); |
|
| 291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
| 292 | - $html .= \EEH_HTML::br( 2 ); |
|
| 293 | - return $html; |
|
| 294 | - } |
|
| 19 | + /** |
|
| 20 | + * @var string $iframe_name |
|
| 21 | + */ |
|
| 22 | + private $iframe_name; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var string $route_name |
|
| 26 | + */ |
|
| 27 | + private $route_name; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var string $slug |
|
| 31 | + */ |
|
| 32 | + private $slug; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var boolean $append_filterable_content |
|
| 36 | + */ |
|
| 37 | + private $append_filterable_content; |
|
| 38 | + |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * IframeEmbedButton constructor. |
|
| 43 | + * |
|
| 44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
| 45 | + * @param string $route_name the name of the registered route |
|
| 46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
| 47 | + * will most likely be "event" since that's the only usage atm |
|
| 48 | + */ |
|
| 49 | + public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
| 50 | + { |
|
| 51 | + $this->iframe_name = $iframe_name; |
|
| 52 | + $this->route_name = $route_name; |
|
| 53 | + $this->slug = $slug; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Adds an iframe embed code button to the Event editor. |
|
| 60 | + */ |
|
| 61 | + public function addEventEditorIframeEmbedButtonFilter() |
|
| 62 | + { |
|
| 63 | + // add button for iframe code to event editor. |
|
| 64 | + add_filter( |
|
| 65 | + 'get_sample_permalink_html', |
|
| 66 | + array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
| 67 | + 10, |
|
| 68 | + 2 |
|
| 69 | + ); |
|
| 70 | + add_action( |
|
| 71 | + 'admin_enqueue_scripts', |
|
| 72 | + array( $this, 'embedButtonAssets' ), |
|
| 73 | + 10 |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param $permalink_string |
|
| 81 | + * @param $id |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
| 85 | + { |
|
| 86 | + return $this->eventEditorIframeEmbedButton( |
|
| 87 | + $permalink_string, |
|
| 88 | + $id |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * iframe embed code button to the Event editor. |
|
| 96 | + * |
|
| 97 | + * @param string $permalink_string |
|
| 98 | + * @param int $id |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public function eventEditorIframeEmbedButton( |
|
| 102 | + $permalink_string, |
|
| 103 | + $id |
|
| 104 | + ) { |
|
| 105 | + //make sure this is ONLY when editing and the event id has been set. |
|
| 106 | + if ( ! empty( $id ) ) { |
|
| 107 | + $post = get_post( $id ); |
|
| 108 | + //if NOT event then let's get out. |
|
| 109 | + if ( $post->post_type !== 'espresso_events' ) { |
|
| 110 | + return $permalink_string; |
|
| 111 | + } |
|
| 112 | + $permalink_string .= $this->embedButtonHtml( |
|
| 113 | + array( $this->slug => $id ), |
|
| 114 | + 'button-small' |
|
| 115 | + ); |
|
| 116 | + } |
|
| 117 | + return $permalink_string; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
| 124 | + * |
|
| 125 | + * @param string $action name of the WP do_action() to hook into |
|
| 126 | + */ |
|
| 127 | + public function addActionIframeEmbedButton( $action ) |
|
| 128 | + { |
|
| 129 | + // add button for iframe code to event editor. |
|
| 130 | + add_action( |
|
| 131 | + $action, |
|
| 132 | + array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
| 133 | + 10, 2 |
|
| 134 | + ); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return void |
|
| 141 | + */ |
|
| 142 | + public function addActionIframeEmbedButtonCallback() |
|
| 143 | + { |
|
| 144 | + echo $this->embedButtonHtml(); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
| 151 | + * |
|
| 152 | + * @param string $filter name of the WP apply_filters() to hook into |
|
| 153 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
| 154 | + * else if false, will add to the beginning of the content |
|
| 155 | + */ |
|
| 156 | + public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
| 157 | + { |
|
| 158 | + $this->append_filterable_content = $append; |
|
| 159 | + // add button for iframe code to event editor. |
|
| 160 | + add_filter( |
|
| 161 | + $filter, |
|
| 162 | + array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
| 163 | + 10 |
|
| 164 | + ); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @param array|string $filterable_content |
|
| 171 | + * @return array|string |
|
| 172 | + */ |
|
| 173 | + public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
| 174 | + { |
|
| 175 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
| 176 | + if ( is_array( $filterable_content ) ) { |
|
| 177 | + $filterable_content = $this->append_filterable_content |
|
| 178 | + ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
| 179 | + : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
| 180 | + } else { |
|
| 181 | + $filterable_content = $this->append_filterable_content |
|
| 182 | + ? $filterable_content . $embedButtonHtml |
|
| 183 | + : $embedButtonHtml . $filterable_content; |
|
| 184 | + } |
|
| 185 | + return $filterable_content; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * iframe_embed_html |
|
| 192 | + * |
|
| 193 | + * @param array $query_args |
|
| 194 | + * @param string $button_class |
|
| 195 | + * @return string |
|
| 196 | + */ |
|
| 197 | + public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
| 198 | + { |
|
| 199 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
| 200 | + $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
| 201 | + $query_args = (array)apply_filters( |
|
| 202 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
| 203 | + $query_args |
|
| 204 | + ); |
|
| 205 | + // add this route to our localized vars |
|
| 206 | + $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
| 207 | + ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
| 208 | + : array(); |
|
| 209 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
| 210 | + \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
| 211 | + $iframe_embed_html = \EEH_HTML::link( |
|
| 212 | + '#', |
|
| 213 | + sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
| 214 | + sprintf( |
|
| 215 | + esc_html__( |
|
| 216 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
| 217 | + 'event_espresso' |
|
| 218 | + ), |
|
| 219 | + \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
| 220 | + ), |
|
| 221 | + "{$this->route_name}-iframe-embed-trigger-js", |
|
| 222 | + 'iframe-embed-trigger-js button ' . $button_class, |
|
| 223 | + '', |
|
| 224 | + ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
| 225 | + ); |
|
| 226 | + $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
| 227 | + 'display:none;' ); |
|
| 228 | + $iframe_embed_html .= esc_html( |
|
| 229 | + \EEH_HTML::div( |
|
| 230 | + '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
| 231 | + '', |
|
| 232 | + '', |
|
| 233 | + 'width:100%; height: 500px;' |
|
| 234 | + ) |
|
| 235 | + ); |
|
| 236 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
| 237 | + return $iframe_embed_html; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * enqueue iframe button js |
|
| 244 | + */ |
|
| 245 | + public function embedButtonAssets() |
|
| 246 | + { |
|
| 247 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
| 248 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
| 249 | + 'event_espresso' |
|
| 250 | + ); |
|
| 251 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
| 252 | + 'click anywhere outside of this window to close it.', |
|
| 253 | + 'event_espresso' |
|
| 254 | + ); |
|
| 255 | + wp_register_script( |
|
| 256 | + 'iframe_embed_button', |
|
| 257 | + plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
| 258 | + array( 'ee-dialog' ), |
|
| 259 | + EVENT_ESPRESSO_VERSION, |
|
| 260 | + true |
|
| 261 | + ); |
|
| 262 | + wp_enqueue_script( 'iframe_embed_button' ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * generates embed button sections for admin pages |
|
| 269 | + * |
|
| 270 | + * @param array $embed_buttons |
|
| 271 | + * @return string |
|
| 272 | + */ |
|
| 273 | + public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
| 274 | + { |
|
| 275 | + $embed_buttons = (array)apply_filters( |
|
| 276 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
| 277 | + $embed_buttons |
|
| 278 | + ); |
|
| 279 | + if ( empty($embed_buttons)) { |
|
| 280 | + return ''; |
|
| 281 | + } |
|
| 282 | + // add button for iframe code to event editor. |
|
| 283 | + $html = \EEH_HTML::br( 2 ); |
|
| 284 | + $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
| 285 | + $html .= \EEH_HTML::p( |
|
| 286 | + esc_html__( |
|
| 287 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
| 288 | + 'event_espresso' |
|
| 289 | + ) |
|
| 290 | + ); |
|
| 291 | + $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
| 292 | + $html .= \EEH_HTML::br( 2 ); |
|
| 293 | + return $html; |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | 296 | |
| 297 | 297 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
| 3 | 3 | |
| 4 | -defined( 'ABSPATH' ) || exit; |
|
| 4 | +defined('ABSPATH') || exit; |
|
| 5 | 5 | |
| 6 | 6 | |
| 7 | 7 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
| 47 | 47 | * will most likely be "event" since that's the only usage atm |
| 48 | 48 | */ |
| 49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
| 49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
| 50 | 50 | { |
| 51 | 51 | $this->iframe_name = $iframe_name; |
| 52 | 52 | $this->route_name = $route_name; |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | // add button for iframe code to event editor. |
| 64 | 64 | add_filter( |
| 65 | 65 | 'get_sample_permalink_html', |
| 66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
| 66 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
| 67 | 67 | 10, |
| 68 | 68 | 2 |
| 69 | 69 | ); |
| 70 | 70 | add_action( |
| 71 | 71 | 'admin_enqueue_scripts', |
| 72 | - array( $this, 'embedButtonAssets' ), |
|
| 72 | + array($this, 'embedButtonAssets'), |
|
| 73 | 73 | 10 |
| 74 | 74 | ); |
| 75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param $id |
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
| 84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
| 85 | 85 | { |
| 86 | 86 | return $this->eventEditorIframeEmbedButton( |
| 87 | 87 | $permalink_string, |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | $id |
| 104 | 104 | ) { |
| 105 | 105 | //make sure this is ONLY when editing and the event id has been set. |
| 106 | - if ( ! empty( $id ) ) { |
|
| 107 | - $post = get_post( $id ); |
|
| 106 | + if ( ! empty($id)) { |
|
| 107 | + $post = get_post($id); |
|
| 108 | 108 | //if NOT event then let's get out. |
| 109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
| 109 | + if ($post->post_type !== 'espresso_events') { |
|
| 110 | 110 | return $permalink_string; |
| 111 | 111 | } |
| 112 | 112 | $permalink_string .= $this->embedButtonHtml( |
| 113 | - array( $this->slug => $id ), |
|
| 113 | + array($this->slug => $id), |
|
| 114 | 114 | 'button-small' |
| 115 | 115 | ); |
| 116 | 116 | } |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param string $action name of the WP do_action() to hook into |
| 126 | 126 | */ |
| 127 | - public function addActionIframeEmbedButton( $action ) |
|
| 127 | + public function addActionIframeEmbedButton($action) |
|
| 128 | 128 | { |
| 129 | 129 | // add button for iframe code to event editor. |
| 130 | 130 | add_action( |
| 131 | 131 | $action, |
| 132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
| 132 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
| 133 | 133 | 10, 2 |
| 134 | 134 | ); |
| 135 | 135 | } |
@@ -153,13 +153,13 @@ discard block |
||
| 153 | 153 | * @param bool $append if true, will add iframe embed button to end of content, |
| 154 | 154 | * else if false, will add to the beginning of the content |
| 155 | 155 | */ |
| 156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
| 156 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
| 157 | 157 | { |
| 158 | 158 | $this->append_filterable_content = $append; |
| 159 | 159 | // add button for iframe code to event editor. |
| 160 | 160 | add_filter( |
| 161 | 161 | $filter, |
| 162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
| 162 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
| 163 | 163 | 10 |
| 164 | 164 | ); |
| 165 | 165 | } |
@@ -170,17 +170,17 @@ discard block |
||
| 170 | 170 | * @param array|string $filterable_content |
| 171 | 171 | * @return array|string |
| 172 | 172 | */ |
| 173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
| 173 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
| 174 | 174 | { |
| 175 | 175 | $embedButtonHtml = $this->embedButtonHtml(); |
| 176 | - if ( is_array( $filterable_content ) ) { |
|
| 176 | + if (is_array($filterable_content)) { |
|
| 177 | 177 | $filterable_content = $this->append_filterable_content |
| 178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
| 179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
| 178 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
| 179 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
| 180 | 180 | } else { |
| 181 | 181 | $filterable_content = $this->append_filterable_content |
| 182 | - ? $filterable_content . $embedButtonHtml |
|
| 183 | - : $embedButtonHtml . $filterable_content; |
|
| 182 | + ? $filterable_content.$embedButtonHtml |
|
| 183 | + : $embedButtonHtml.$filterable_content; |
|
| 184 | 184 | } |
| 185 | 185 | return $filterable_content; |
| 186 | 186 | } |
@@ -194,40 +194,40 @@ discard block |
||
| 194 | 194 | * @param string $button_class |
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
| 197 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
| 198 | 198 | { |
| 199 | 199 | // incoming args will replace the defaults listed here in the second array (union preserves first array) |
| 200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
| 201 | - $query_args = (array)apply_filters( |
|
| 200 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
| 201 | + $query_args = (array) apply_filters( |
|
| 202 | 202 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
| 203 | 203 | $query_args |
| 204 | 204 | ); |
| 205 | 205 | // add this route to our localized vars |
| 206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
| 207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
| 206 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
| 207 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
| 208 | 208 | : array(); |
| 209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
| 210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
| 209 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
| 210 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
| 211 | 211 | $iframe_embed_html = \EEH_HTML::link( |
| 212 | 212 | '#', |
| 213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
| 213 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
| 214 | 214 | sprintf( |
| 215 | 215 | esc_html__( |
| 216 | 216 | 'click here to generate code for embedding %1$s iframe into another site.', |
| 217 | 217 | 'event_espresso' |
| 218 | 218 | ), |
| 219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
| 219 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
| 220 | 220 | ), |
| 221 | 221 | "{$this->route_name}-iframe-embed-trigger-js", |
| 222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
| 222 | + 'iframe-embed-trigger-js button '.$button_class, |
|
| 223 | 223 | '', |
| 224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
| 224 | + ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"' |
|
| 225 | 225 | ); |
| 226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
| 227 | - 'display:none;' ); |
|
| 226 | + $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
| 227 | + 'display:none;'); |
|
| 228 | 228 | $iframe_embed_html .= esc_html( |
| 229 | 229 | \EEH_HTML::div( |
| 230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
| 230 | + '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>', |
|
| 231 | 231 | '', |
| 232 | 232 | '', |
| 233 | 233 | 'width:100%; height: 500px;' |
@@ -244,22 +244,22 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function embedButtonAssets() |
| 246 | 246 | { |
| 247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
| 247 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
| 248 | 248 | 'copy and paste the following into any other site\'s content to display this event:', |
| 249 | 249 | 'event_espresso' |
| 250 | 250 | ); |
| 251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
| 251 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
| 252 | 252 | 'click anywhere outside of this window to close it.', |
| 253 | 253 | 'event_espresso' |
| 254 | 254 | ); |
| 255 | 255 | wp_register_script( |
| 256 | 256 | 'iframe_embed_button', |
| 257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
| 258 | - array( 'ee-dialog' ), |
|
| 257 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
| 258 | + array('ee-dialog'), |
|
| 259 | 259 | EVENT_ESPRESSO_VERSION, |
| 260 | 260 | true |
| 261 | 261 | ); |
| 262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
| 262 | + wp_enqueue_script('iframe_embed_button'); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | |
@@ -270,26 +270,26 @@ discard block |
||
| 270 | 270 | * @param array $embed_buttons |
| 271 | 271 | * @return string |
| 272 | 272 | */ |
| 273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
| 273 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
| 274 | 274 | { |
| 275 | - $embed_buttons = (array)apply_filters( |
|
| 275 | + $embed_buttons = (array) apply_filters( |
|
| 276 | 276 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
| 277 | 277 | $embed_buttons |
| 278 | 278 | ); |
| 279 | - if ( empty($embed_buttons)) { |
|
| 279 | + if (empty($embed_buttons)) { |
|
| 280 | 280 | return ''; |
| 281 | 281 | } |
| 282 | 282 | // add button for iframe code to event editor. |
| 283 | - $html = \EEH_HTML::br( 2 ); |
|
| 284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
| 283 | + $html = \EEH_HTML::br(2); |
|
| 284 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
| 285 | 285 | $html .= \EEH_HTML::p( |
| 286 | 286 | esc_html__( |
| 287 | 287 | 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
| 288 | 288 | 'event_espresso' |
| 289 | 289 | ) |
| 290 | 290 | ); |
| 291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
| 292 | - $html .= \EEH_HTML::br( 2 ); |
|
| 291 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
| 292 | + $html .= \EEH_HTML::br(2); |
|
| 293 | 293 | return $html; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -15,21 +15,21 @@ discard block |
||
| 15 | 15 | class EventListIframeEmbedButton extends IframeEmbedButton |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * EventListIframeEmbedButton constructor. |
|
| 20 | - */ |
|
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - parent::__construct( |
|
| 24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
| 25 | - 'event_list' |
|
| 26 | - ); |
|
| 27 | - } |
|
| 18 | + /** |
|
| 19 | + * EventListIframeEmbedButton constructor. |
|
| 20 | + */ |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + parent::__construct( |
|
| 24 | + esc_html__( 'Event List', 'event_espresso' ), |
|
| 25 | + 'event_list' |
|
| 26 | + ); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | public function addEmbedButton() { |
| 32 | - add_filter( |
|
| 32 | + add_filter( |
|
| 33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
| 34 | 34 | array( $this, 'addEventListIframeEmbedButtonSection' ) |
| 35 | 35 | ); |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | * @param array $after_list_table |
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
| 53 | - { |
|
| 54 | - return \EEH_Array::insert_into_array( |
|
| 55 | - $after_list_table, |
|
| 56 | - array( |
|
| 57 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
| 58 | - array() |
|
| 59 | - // array( 'event_list' => $this->embedButtonHtml() ) |
|
| 60 | - ) |
|
| 61 | - ), |
|
| 62 | - 'legend' |
|
| 63 | - ); |
|
| 64 | - } |
|
| 52 | + public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
| 53 | + { |
|
| 54 | + return \EEH_Array::insert_into_array( |
|
| 55 | + $after_list_table, |
|
| 56 | + array( |
|
| 57 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
| 58 | + array() |
|
| 59 | + // array( 'event_list' => $this->embedButtonHtml() ) |
|
| 60 | + ) |
|
| 61 | + ), |
|
| 62 | + 'legend' |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
| 3 | 3 | |
| 4 | -defined( 'ABSPATH' ) || exit; |
|
| 4 | +defined('ABSPATH') || exit; |
|
| 5 | 5 | |
| 6 | 6 | |
| 7 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | 23 | parent::__construct( |
| 24 | - esc_html__( 'Event List', 'event_espresso' ), |
|
| 24 | + esc_html__('Event List', 'event_espresso'), |
|
| 25 | 25 | 'event_list' |
| 26 | 26 | ); |
| 27 | 27 | } |
@@ -31,11 +31,11 @@ discard block |
||
| 31 | 31 | public function addEmbedButton() { |
| 32 | 32 | add_filter( |
| 33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
| 34 | - array( $this, 'addEventListIframeEmbedButtonSection' ) |
|
| 34 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
| 35 | 35 | ); |
| 36 | 36 | add_action( |
| 37 | 37 | 'admin_enqueue_scripts', |
| 38 | - array( $this, 'embedButtonAssets' ), |
|
| 38 | + array($this, 'embedButtonAssets'), |
|
| 39 | 39 | 10 |
| 40 | 40 | ); |
| 41 | 41 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param array $after_list_table |
| 50 | 50 | * @return array |
| 51 | 51 | */ |
| 52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
| 52 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
| 53 | 53 | { |
| 54 | 54 | return \EEH_Array::insert_into_array( |
| 55 | 55 | $after_list_table, |