@@ -75,37 +75,37 @@ discard block |
||
| 75 | 75 | $this->Request_Handler = $Request_Handler; |
| 76 | 76 | $this->Module_Request_Router = $Module_Request_Router; |
| 77 | 77 | // make sure template tags are loaded immediately so that themes don't break |
| 78 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'load_espresso_template_tags' ), 10 ); |
|
| 78 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
| 79 | 79 | // determine how to integrate WP_Query with the EE models |
| 80 | - add_action( 'AHEE__EE_System__initialize', array( $this, 'employ_CPT_Strategy' )); |
|
| 80 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 81 | 81 | // load other resources and begin to actually run shortcodes and modules |
| 82 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 5 ); |
|
| 82 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 83 | 83 | // analyse the incoming WP request |
| 84 | - add_action( 'parse_request', array( $this, 'get_request' ), 1, 1 ); |
|
| 84 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 85 | 85 | // process any content shortcodes |
| 86 | - add_action( 'parse_request', array( $this, '_initialize_shortcodes' ), 5 ); |
|
| 86 | + add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
| 87 | 87 | // process request with module factory |
| 88 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10, 1 ); |
|
| 88 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 89 | 89 | // before headers sent |
| 90 | - add_action( 'wp', array( $this, 'wp' ), 5 ); |
|
| 90 | + add_action('wp', array($this, 'wp'), 5); |
|
| 91 | 91 | // load css and js |
| 92 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 1 ); |
|
| 92 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
| 93 | 93 | // header |
| 94 | - add_action('wp_head', array( $this, 'header_meta_tag' ), 5 ); |
|
| 95 | - add_filter( 'template_include', array( $this, 'template_include' ), 1 ); |
|
| 94 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 95 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
| 96 | 96 | // display errors |
| 97 | - add_action('loop_start', array( $this, 'display_errors' ), 2 ); |
|
| 97 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 98 | 98 | // the content |
| 99 | - add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 99 | + add_filter('the_content', array($this, 'the_content'), 5, 1); |
|
| 100 | 100 | //exclude our private cpt comments |
| 101 | - add_filter( 'comments_clauses', array( $this, 'filter_wp_comments'), 10, 1 ); |
|
| 101 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 102 | 102 | //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
| 103 | - add_filter( 'admin_url', array( $this, 'maybe_force_admin_ajax_ssl' ), 200, 1 ); |
|
| 103 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 104 | 104 | // action hook EE |
| 105 | - do_action( 'AHEE__EE_Front_Controller__construct__done',$this ); |
|
| 105 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 106 | 106 | // for checking that browser cookies are enabled |
| 107 | - if ( apply_filters( 'FHEE__EE_Front_Controller____construct__set_test_cookie', true )) { |
|
| 108 | - setcookie( 'ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/' ); |
|
| 107 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 108 | + setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | 143 | public function load_espresso_template_tags() { |
| 144 | - if ( is_readable( EE_PUBLIC . 'template_tags.php' )) { |
|
| 145 | - require_once( EE_PUBLIC . 'template_tags.php' ); |
|
| 144 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
| 145 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | |
@@ -157,12 +157,12 @@ discard block |
||
| 157 | 157 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
| 158 | 158 | * @return array array of comment clauses with modifications. |
| 159 | 159 | */ |
| 160 | - public function filter_wp_comments( $clauses ) { |
|
| 160 | + public function filter_wp_comments($clauses) { |
|
| 161 | 161 | global $wpdb; |
| 162 | - if ( strpos( $clauses['join'], $wpdb->posts ) !== FALSE ) { |
|
| 162 | + if (strpos($clauses['join'], $wpdb->posts) !== FALSE) { |
|
| 163 | 163 | $cpts = EE_Register_CPTs::get_private_CPTs(); |
| 164 | - foreach ( $cpts as $cpt => $details ) { |
|
| 165 | - $clauses['where'] .= $wpdb->prepare( " AND $wpdb->posts.post_type != %s", $cpt ); |
|
| 164 | + foreach ($cpts as $cpt => $details) { |
|
| 165 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | return $clauses; |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | * @return void |
| 180 | 180 | */ |
| 181 | 181 | public function employ_CPT_Strategy() { |
| 182 | - if ( apply_filters( 'FHEE__EE_Front_Controller__employ_CPT_Strategy',true) ){ |
|
| 183 | - $this->Registry->load_core( 'CPT_Strategy' ); |
|
| 182 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 183 | + $this->Registry->load_core('CPT_Strategy'); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | * @param string $url incoming url |
| 193 | 193 | * @return string final assembled url |
| 194 | 194 | */ |
| 195 | - public function maybe_force_admin_ajax_ssl( $url ) { |
|
| 196 | - if ( is_ssl() && preg_match( '/admin-ajax.php/', $url )) { |
|
| 197 | - $url = str_replace( 'http://', 'https://', $url ); |
|
| 195 | + public function maybe_force_admin_ajax_ssl($url) { |
|
| 196 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 197 | + $url = str_replace('http://', 'https://', $url); |
|
| 198 | 198 | } |
| 199 | 199 | return $url; |
| 200 | 200 | } |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | * @param WP $WP |
| 232 | 232 | * @return void |
| 233 | 233 | */ |
| 234 | - public function get_request( WP $WP ) { |
|
| 235 | - do_action( 'AHEE__EE_Front_Controller__get_request__start' ); |
|
| 236 | - $this->Request_Handler->parse_request( $WP ); |
|
| 237 | - do_action( 'AHEE__EE_Front_Controller__get_request__complete' ); |
|
| 234 | + public function get_request(WP $WP) { |
|
| 235 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 236 | + $this->Request_Handler->parse_request($WP); |
|
| 237 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
@@ -246,23 +246,23 @@ discard block |
||
| 246 | 246 | * @param WP $WP |
| 247 | 247 | * @return void |
| 248 | 248 | */ |
| 249 | - public function _initialize_shortcodes( WP $WP ) { |
|
| 250 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this ); |
|
| 251 | - $this->Request_Handler->set_request_vars( $WP ); |
|
| 249 | + public function _initialize_shortcodes(WP $WP) { |
|
| 250 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
| 251 | + $this->Request_Handler->set_request_vars($WP); |
|
| 252 | 252 | // grab post_name from request |
| 253 | - $current_post = apply_filters( 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', $this->Request_Handler->get( 'post_name' )); |
|
| 253 | + $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', $this->Request_Handler->get('post_name')); |
|
| 254 | 254 | // if it's not set, then check if frontpage is blog |
| 255 | - if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'posts' ) { |
|
| 255 | + if (empty($current_post) && get_option('show_on_front') == 'posts') { |
|
| 256 | 256 | // yup.. this is the posts page, prepare to load all shortcode modules |
| 257 | 257 | $current_post = 'posts'; |
| 258 | - } else if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'page' ) { |
|
| 258 | + } else if (empty($current_post) && get_option('show_on_front') == 'page') { |
|
| 259 | 259 | // some other page is set as the homepage |
| 260 | - $page_on_front = get_option( 'page_on_front' ); |
|
| 261 | - if ( $page_on_front ) { |
|
| 260 | + $page_on_front = get_option('page_on_front'); |
|
| 261 | + if ($page_on_front) { |
|
| 262 | 262 | // k now we need to find the post_name for this page |
| 263 | 263 | global $wpdb; |
| 264 | 264 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d"; |
| 265 | - $page_on_front = $wpdb->get_var( $wpdb->prepare( $SQL, $page_on_front )); |
|
| 265 | + $page_on_front = $wpdb->get_var($wpdb->prepare($SQL, $page_on_front)); |
|
| 266 | 266 | // set the current post slug to what it actually is |
| 267 | 267 | $current_post = $page_on_front ? $page_on_front : $current_post; |
| 268 | 268 | } |
@@ -270,57 +270,57 @@ discard block |
||
| 270 | 270 | // where are posts being displayed ? |
| 271 | 271 | $page_for_posts = EE_Config::get_page_for_posts(); |
| 272 | 272 | // in case $current_post is hierarchical like: /parent-page/current-page |
| 273 | - $current_post = basename( $current_post ); |
|
| 273 | + $current_post = basename($current_post); |
|
| 274 | 274 | // are we on a category page? |
| 275 | - $term_exists = is_array( term_exists( $current_post, 'category' )) || array_key_exists( 'category_name', $WP->query_vars ); |
|
| 275 | + $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', $WP->query_vars); |
|
| 276 | 276 | // make sure shortcodes are set |
| 277 | - if ( isset( $this->Registry->CFG->core->post_shortcodes )) { |
|
| 277 | + if (isset($this->Registry->CFG->core->post_shortcodes)) { |
|
| 278 | 278 | // cycle thru all posts with shortcodes set |
| 279 | - foreach ( $this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
| 279 | + foreach ($this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
| 280 | 280 | // filter shortcodes so |
| 281 | - $post_shortcodes = apply_filters( 'FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes ); |
|
| 281 | + $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes); |
|
| 282 | 282 | // now cycle thru shortcodes |
| 283 | - foreach ( $post_shortcodes as $shortcode_class => $post_id ) { |
|
| 283 | + foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
| 284 | 284 | // are we on this page, or on the blog page, or an EE CPT category page ? |
| 285 | - if ( $current_post == $post_name || $term_exists ) { |
|
| 285 | + if ($current_post == $post_name || $term_exists) { |
|
| 286 | 286 | // verify shortcode is in list of registered shortcodes |
| 287 | - if ( ! isset( $this->Registry->shortcodes->$shortcode_class )) { |
|
| 288 | - if ( $current_post != $page_for_posts && current_user_can( 'edit_post', $post_id )) { |
|
| 289 | - $msg = sprintf( __( 'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso' ), $shortcode_class ); |
|
| 290 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 291 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 287 | + if ( ! isset($this->Registry->shortcodes->$shortcode_class)) { |
|
| 288 | + if ($current_post != $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
| 289 | + $msg = sprintf(__('The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso'), $shortcode_class); |
|
| 290 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 291 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 292 | 292 | } |
| 293 | - add_shortcode( $shortcode_class, array( 'EES_Shortcode', 'invalid_shortcode_processor' )); |
|
| 293 | + add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | 296 | // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
| 297 | - if ( isset( $this->Registry->CFG->core->post_shortcodes[ $current_post ] ) || $term_exists || $current_post == $page_for_posts ) { |
|
| 297 | + if (isset($this->Registry->CFG->core->post_shortcodes[$current_post]) || $term_exists || $current_post == $page_for_posts) { |
|
| 298 | 298 | // let's pause to reflect on this... |
| 299 | - $sc_reflector = new ReflectionClass( 'EES_' . $shortcode_class ); |
|
| 299 | + $sc_reflector = new ReflectionClass('EES_'.$shortcode_class); |
|
| 300 | 300 | // ensure that class is actually a shortcode |
| 301 | - if ( ! $sc_reflector->isSubclassOf( 'EES_Shortcode' ) && defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE ) { |
|
| 302 | - $msg = sprintf( __( 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso' ), $shortcode_class ); |
|
| 303 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 304 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 301 | + if ( ! $sc_reflector->isSubclassOf('EES_Shortcode') && defined('WP_DEBUG') && WP_DEBUG === TRUE) { |
|
| 302 | + $msg = sprintf(__('The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso'), $shortcode_class); |
|
| 303 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 304 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
| 305 | 305 | continue; |
| 306 | 306 | } |
| 307 | 307 | // and pass the request object to the run method |
| 308 | 308 | $this->Registry->shortcodes->$shortcode_class = $sc_reflector->newInstance(); |
| 309 | 309 | // fire the shortcode class's run method, so that it can activate resources |
| 310 | - $this->Registry->shortcodes->$shortcode_class->run( $WP ); |
|
| 310 | + $this->Registry->shortcodes->$shortcode_class->run($WP); |
|
| 311 | 311 | } |
| 312 | 312 | // if this is NOT the "Posts page" and we have a valid entry for the "Posts page" in our tracked post_shortcodes array |
| 313 | - } else if ( $post_name != $page_for_posts && isset( $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ] )) { |
|
| 313 | + } else if ($post_name != $page_for_posts && isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts])) { |
|
| 314 | 314 | // and the shortcode is not being tracked for this page |
| 315 | - if ( ! isset( $this->Registry->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] )) { |
|
| 315 | + if ( ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
| 316 | 316 | // then remove the "fallback" shortcode processor |
| 317 | - remove_shortcode( $shortcode_class ); |
|
| 317 | + remove_shortcode($shortcode_class); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__end', $this ); |
|
| 323 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
@@ -332,20 +332,20 @@ discard block |
||
| 332 | 332 | * @param WP_Query $WP_Query |
| 333 | 333 | * @return void |
| 334 | 334 | */ |
| 335 | - public function pre_get_posts( $WP_Query ) { |
|
| 335 | + public function pre_get_posts($WP_Query) { |
|
| 336 | 336 | // only load Module_Request_Router if this is the main query |
| 337 | - if ( $WP_Query->is_main_query() ) { |
|
| 337 | + if ($WP_Query->is_main_query()) { |
|
| 338 | 338 | //// load module request router |
| 339 | 339 | //$Module_Request_Router = $this->Registry->load_core( 'Module_Request_Router' ); |
| 340 | 340 | // verify object |
| 341 | - if ( $this->Module_Request_Router instanceof EE_Module_Request_Router ) { |
|
| 341 | + if ($this->Module_Request_Router instanceof EE_Module_Request_Router) { |
|
| 342 | 342 | // cycle thru module routes |
| 343 | - while ( $route = $this->Module_Request_Router->get_route( $WP_Query )) { |
|
| 343 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
| 344 | 344 | // determine module and method for route |
| 345 | - $module = $this->Module_Request_Router->resolve_route( $route[0], $route[1] ); |
|
| 346 | - if( $module instanceof EED_Module ) { |
|
| 345 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 346 | + if ($module instanceof EED_Module) { |
|
| 347 | 347 | // get registered view for route |
| 348 | - $this->_template_path = $this->Module_Request_Router->get_view( $route ); |
|
| 348 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
| 349 | 349 | // grab module name |
| 350 | 350 | $module_name = $module->module_name(); |
| 351 | 351 | // map the module to the module objects |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | * @return void |
| 373 | 373 | */ |
| 374 | 374 | public function wp() { |
| 375 | - $this->Registry->load_helper( 'Template' ); |
|
| 375 | + $this->Registry->load_helper('Template'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -390,30 +390,30 @@ discard block |
||
| 390 | 390 | public function wp_enqueue_scripts() { |
| 391 | 391 | |
| 392 | 392 | // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
| 393 | - if ( apply_filters( 'FHEE_load_css', TRUE ) ) { |
|
| 393 | + if (apply_filters('FHEE_load_css', TRUE)) { |
|
| 394 | 394 | |
| 395 | 395 | $this->Registry->CFG->template_settings->enable_default_style = TRUE; |
| 396 | 396 | //Load the ThemeRoller styles if enabled |
| 397 | - if ( isset( $this->Registry->CFG->template_settings->enable_default_style ) && $this->Registry->CFG->template_settings->enable_default_style ) { |
|
| 397 | + if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
| 398 | 398 | |
| 399 | 399 | //Load custom style sheet if available |
| 400 | - if ( isset( $this->Registry->CFG->template_settings->custom_style_sheet )) { |
|
| 401 | - wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION ); |
|
| 400 | + if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
| 401 | + wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->Registry->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION); |
|
| 402 | 402 | wp_enqueue_style('espresso_custom_css'); |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $this->Registry->load_helper( 'File' ); |
|
| 406 | - if ( is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )) { |
|
| 407 | - wp_register_style( 'espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
| 405 | + $this->Registry->load_helper('File'); |
|
| 406 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
| 407 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
| 408 | 408 | } else { |
| 409 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
| 409 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
| 410 | 410 | } |
| 411 | 411 | wp_enqueue_style('espresso_default'); |
| 412 | 412 | |
| 413 | - if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css' )) { |
|
| 414 | - wp_register_style( 'espresso_style', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 413 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
| 414 | + wp_register_style('espresso_style', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 415 | 415 | } else { |
| 416 | - wp_register_style( 'espresso_style', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
| 416 | + wp_register_style('espresso_style', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | } |
@@ -421,29 +421,29 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
| 424 | - if ( apply_filters( 'FHEE_load_js', TRUE ) ) { |
|
| 424 | + if (apply_filters('FHEE_load_js', TRUE)) { |
|
| 425 | 425 | |
| 426 | - wp_enqueue_script( 'jquery' ); |
|
| 426 | + wp_enqueue_script('jquery'); |
|
| 427 | 427 | //let's make sure that all required scripts have been setup |
| 428 | - if ( function_exists( 'wp_script_is' )) { |
|
| 429 | - if ( ! wp_script_is( 'jquery' )) { |
|
| 428 | + if (function_exists('wp_script_is')) { |
|
| 429 | + if ( ! wp_script_is('jquery')) { |
|
| 430 | 430 | $msg = sprintf( |
| 431 | - __( '%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso' ), |
|
| 431 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso'), |
|
| 432 | 432 | '<em><br />', |
| 433 | 433 | '</em>' |
| 434 | 434 | ); |
| 435 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 435 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 436 | 436 | } |
| 437 | 437 | } |
| 438 | 438 | // load core js |
| 439 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 440 | - wp_enqueue_script( 'espresso_core' ); |
|
| 441 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
| 439 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 440 | + wp_enqueue_script('espresso_core'); |
|
| 441 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
| 442 | 442 | |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
| 446 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
| 446 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
| 447 | 447 | $this->Registry->load_helper('Qtip_Loader'); |
| 448 | 448 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
| 449 | 449 | } |
@@ -451,11 +451,11 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | //accounting.js library |
| 453 | 453 | // @link http://josscrowcroft.github.io/accounting.js/ |
| 454 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
| 455 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
| 456 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 457 | - wp_register_script( 'ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE ); |
|
| 458 | - wp_enqueue_script( 'ee-accounting' ); |
|
| 454 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
| 455 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
| 456 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 457 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE); |
|
| 458 | + wp_enqueue_script('ee-accounting'); |
|
| 459 | 459 | |
| 460 | 460 | $currency_config = array( |
| 461 | 461 | 'currency' => array( |
@@ -478,21 +478,21 @@ discard block |
||
| 478 | 478 | wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - if ( ! function_exists( 'wp_head' )) { |
|
| 481 | + if ( ! function_exists('wp_head')) { |
|
| 482 | 482 | $msg = sprintf( |
| 483 | - __( '%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
| 483 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
| 484 | 484 | '<em><br />', |
| 485 | 485 | '</em>' |
| 486 | 486 | ); |
| 487 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 487 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 488 | 488 | } |
| 489 | - if ( ! function_exists( 'wp_footer' )) { |
|
| 489 | + if ( ! function_exists('wp_footer')) { |
|
| 490 | 490 | $msg = sprintf( |
| 491 | - __( '%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
| 491 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
| 492 | 492 | '<em><br />', |
| 493 | 493 | '</em>' |
| 494 | 494 | ); |
| 495 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 495 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | } |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | * @return void |
| 507 | 507 | */ |
| 508 | 508 | public function header_meta_tag() { |
| 509 | - print( apply_filters("FHEE__EE_Front_Controller__header_meta_tag","<meta name='generator' content='Event Espresso Version " . EVENT_ESPRESSO_VERSION . "' />")); |
|
| 509 | + print(apply_filters("FHEE__EE_Front_Controller__header_meta_tag", "<meta name='generator' content='Event Espresso Version ".EVENT_ESPRESSO_VERSION."' />")); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | |
@@ -520,9 +520,9 @@ discard block |
||
| 520 | 520 | * @param $the_content |
| 521 | 521 | * @return string |
| 522 | 522 | */ |
| 523 | - public function the_content( $the_content ) { |
|
| 523 | + public function the_content($the_content) { |
|
| 524 | 524 | // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
| 525 | - if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 525 | + if (apply_filters('FHEE_run_EE_the_content', FALSE)) { |
|
| 526 | 526 | } |
| 527 | 527 | return $the_content; |
| 528 | 528 | } |
@@ -547,9 +547,9 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | public function display_errors() { |
| 549 | 549 | static $shown_already = FALSE; |
| 550 | - do_action( 'AHEE__EE_Front_Controller__display_errors__begin' ); |
|
| 550 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 551 | 551 | if ( |
| 552 | - apply_filters( 'FHEE__EE_Front_Controller__display_errors', TRUE ) |
|
| 552 | + apply_filters('FHEE__EE_Front_Controller__display_errors', TRUE) |
|
| 553 | 553 | && ! $shown_already |
| 554 | 554 | && is_main_query() |
| 555 | 555 | && ! is_feed() |
@@ -558,10 +558,10 @@ discard block |
||
| 558 | 558 | ) { |
| 559 | 559 | echo EE_Error::get_notices(); |
| 560 | 560 | $shown_already = TRUE; |
| 561 | - $this->Registry->load_helper( 'Template' ); |
|
| 562 | - EEH_Template::display_template( EE_TEMPLATES . 'espresso-ajax-notices.template.php' ); |
|
| 561 | + $this->Registry->load_helper('Template'); |
|
| 562 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
| 563 | 563 | } |
| 564 | - do_action( 'AHEE__EE_Front_Controller__display_errors__end' ); |
|
| 564 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | |
@@ -576,12 +576,12 @@ discard block |
||
| 576 | 576 | * @param string $template_include_path |
| 577 | 577 | * @return string |
| 578 | 578 | */ |
| 579 | - public function template_include( $template_include_path = NULL ) { |
|
| 580 | - if ( $this->Request_Handler->is_espresso_page() ) { |
|
| 581 | - $this->_template_path = ! empty( $this->_template_path ) ? basename( $this->_template_path ) : basename( $template_include_path ); |
|
| 582 | - $template_path = EEH_Template::locate_template( $this->_template_path, array(), false ); |
|
| 583 | - $this->_template_path = ! empty( $template_path ) ? $template_path : $template_include_path; |
|
| 584 | - $this->_template = basename( $this->_template_path ); |
|
| 579 | + public function template_include($template_include_path = NULL) { |
|
| 580 | + if ($this->Request_Handler->is_espresso_page()) { |
|
| 581 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 582 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 583 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 584 | + $this->_template = basename($this->_template_path); |
|
| 585 | 585 | return $this->_template_path; |
| 586 | 586 | } |
| 587 | 587 | return $template_include_path; |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | * @param bool $with_path |
| 597 | 597 | * @return string |
| 598 | 598 | */ |
| 599 | - public function get_selected_template( $with_path = FALSE ) { |
|
| 599 | + public function get_selected_template($with_path = FALSE) { |
|
| 600 | 600 | return $with_path ? $this->_template_path : $this->_template; |
| 601 | 601 | } |
| 602 | 602 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | public static function instance() { |
| 161 | 161 | // check if class object is instantiated |
| 162 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
| 162 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
| 163 | 163 | self::$_instance = new self(); |
| 164 | 164 | } |
| 165 | 165 | return self::$_instance; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | $this->modules = new StdClass(); |
| 223 | 223 | $this->shortcodes = new StdClass(); |
| 224 | 224 | $this->widgets = new StdClass(); |
| 225 | - $this->load_core( 'Base', array(), true ); |
|
| 226 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
| 225 | + $this->load_core('Base', array(), true); |
|
| 226 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function init() { |
| 238 | 238 | // Get current page protocol |
| 239 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
| 239 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
| 240 | 240 | // Output admin-ajax.php URL with same protocol as current page |
| 241 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
| 242 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
| 241 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
| 242 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * @return string |
| 251 | 251 | */ |
| 252 | 252 | public static function localize_i18n_js_strings() { |
| 253 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
| 254 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
| 255 | - if ( is_scalar( $value ) ) { |
|
| 256 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
| 253 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
| 254 | + foreach ($i18n_js_strings as $key => $value) { |
|
| 255 | + if (is_scalar($value)) { |
|
| 256 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
| 260 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
@@ -265,15 +265,15 @@ discard block |
||
| 265 | 265 | /** |
| 266 | 266 | * @param mixed string | EED_Module $module |
| 267 | 267 | */ |
| 268 | - public function add_module( $module ) { |
|
| 269 | - if ( $module instanceof EED_Module ) { |
|
| 270 | - $module_class = get_class( $module ); |
|
| 268 | + public function add_module($module) { |
|
| 269 | + if ($module instanceof EED_Module) { |
|
| 270 | + $module_class = get_class($module); |
|
| 271 | 271 | $this->modules->{$module_class} = $module; |
| 272 | 272 | } else { |
| 273 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
| 274 | - $this->load_core( 'Module_Request_Router' ); |
|
| 273 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
| 274 | + $this->load_core('Module_Request_Router'); |
|
| 275 | 275 | } |
| 276 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
| 276 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
@@ -283,8 +283,8 @@ discard block |
||
| 283 | 283 | * @param string $module_name |
| 284 | 284 | * @return mixed EED_Module | NULL |
| 285 | 285 | */ |
| 286 | - public function get_module( $module_name = '' ) { |
|
| 287 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 286 | + public function get_module($module_name = '') { |
|
| 287 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | |
@@ -299,18 +299,18 @@ discard block |
||
| 299 | 299 | * @param bool $resolve_dependencies |
| 300 | 300 | * @return mixed |
| 301 | 301 | */ |
| 302 | - public function load_core( $class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false ) { |
|
| 302 | + public function load_core($class_name, $arguments = array(), $load_only = false, $resolve_dependencies = false) { |
|
| 303 | 303 | $core_paths = apply_filters( |
| 304 | 304 | 'FHEE__EE_Registry__load_core__core_paths', |
| 305 | 305 | array( |
| 306 | 306 | EE_CORE, |
| 307 | 307 | EE_ADMIN, |
| 308 | 308 | EE_CPTS, |
| 309 | - EE_CORE . 'data_migration_scripts' . DS |
|
| 309 | + EE_CORE.'data_migration_scripts'.DS |
|
| 310 | 310 | ) |
| 311 | 311 | ); |
| 312 | 312 | // retrieve instantiated class |
| 313 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies ); |
|
| 313 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only, $resolve_dependencies); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
@@ -324,15 +324,15 @@ discard block |
||
| 324 | 324 | * @param bool $load_only |
| 325 | 325 | * @return mixed |
| 326 | 326 | */ |
| 327 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
| 327 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
| 328 | 328 | $service_paths = apply_filters( |
| 329 | 329 | 'FHEE__EE_Registry__load_service__service_paths', |
| 330 | 330 | array( |
| 331 | - EE_CORE . 'services' . DS, |
|
| 331 | + EE_CORE.'services'.DS, |
|
| 332 | 332 | ) |
| 333 | 333 | ); |
| 334 | 334 | // retrieve instantiated class |
| 335 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true ); |
|
| 335 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only, true); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | * @param mixed $arguments |
| 346 | 346 | * @return EE_Data_Migration_Script_Base |
| 347 | 347 | */ |
| 348 | - public function load_dms( $class_name, $arguments = array() ) { |
|
| 348 | + public function load_dms($class_name, $arguments = array()) { |
|
| 349 | 349 | // retrieve instantiated class |
| 350 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
| 350 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -362,14 +362,14 @@ discard block |
||
| 362 | 362 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
| 363 | 363 | * @return EE_Base_Class |
| 364 | 364 | */ |
| 365 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
| 366 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
| 365 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
| 366 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
| 367 | 367 | EE_CORE, |
| 368 | 368 | EE_CLASSES, |
| 369 | 369 | EE_BUSINESS |
| 370 | - ) ); |
|
| 370 | + )); |
|
| 371 | 371 | // retrieve instantiated class |
| 372 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
| 372 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | * @param bool $load_only |
| 383 | 383 | * @return EEH_Base |
| 384 | 384 | */ |
| 385 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
| 386 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
| 385 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
| 386 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
| 387 | 387 | // retrieve instantiated class |
| 388 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
| 388 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | |
@@ -399,16 +399,16 @@ discard block |
||
| 399 | 399 | * @param bool $load_only |
| 400 | 400 | * @return mixed |
| 401 | 401 | */ |
| 402 | - public function load_lib( $class_name, $arguments = array(), $load_only = false ) { |
|
| 402 | + public function load_lib($class_name, $arguments = array(), $load_only = false) { |
|
| 403 | 403 | $paths = array( |
| 404 | 404 | EE_LIBRARIES, |
| 405 | - EE_LIBRARIES . 'messages' . DS, |
|
| 406 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
| 407 | - EE_LIBRARIES . 'qtips' . DS, |
|
| 408 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
| 405 | + EE_LIBRARIES.'messages'.DS, |
|
| 406 | + EE_LIBRARIES.'shortcodes'.DS, |
|
| 407 | + EE_LIBRARIES.'qtips'.DS, |
|
| 408 | + EE_LIBRARIES.'payment_methods'.DS, |
|
| 409 | 409 | ); |
| 410 | 410 | // retrieve instantiated class |
| 411 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only ); |
|
| 411 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, true, $load_only); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | |
@@ -421,13 +421,13 @@ discard block |
||
| 421 | 421 | * @param bool $load_only |
| 422 | 422 | * @return EEM_Base |
| 423 | 423 | */ |
| 424 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
| 425 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
| 424 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
| 425 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
| 426 | 426 | EE_MODELS, |
| 427 | 427 | EE_CORE |
| 428 | - ) ); |
|
| 428 | + )); |
|
| 429 | 429 | // retrieve instantiated class |
| 430 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
| 430 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | |
@@ -440,15 +440,15 @@ discard block |
||
| 440 | 440 | * @param bool $load_only |
| 441 | 441 | * @return mixed |
| 442 | 442 | */ |
| 443 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
| 443 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
| 444 | 444 | $paths = array( |
| 445 | - EE_MODELS . 'fields' . DS, |
|
| 446 | - EE_MODELS . 'helpers' . DS, |
|
| 447 | - EE_MODELS . 'relations' . DS, |
|
| 448 | - EE_MODELS . 'strategies' . DS |
|
| 445 | + EE_MODELS.'fields'.DS, |
|
| 446 | + EE_MODELS.'helpers'.DS, |
|
| 447 | + EE_MODELS.'relations'.DS, |
|
| 448 | + EE_MODELS.'strategies'.DS |
|
| 449 | 449 | ); |
| 450 | 450 | // retrieve instantiated class |
| 451 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
| 451 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | |
@@ -458,8 +458,8 @@ discard block |
||
| 458 | 458 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
| 459 | 459 | * @return boolean |
| 460 | 460 | */ |
| 461 | - public function is_model_name( $model_name ) { |
|
| 462 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
| 461 | + public function is_model_name($model_name) { |
|
| 462 | + return isset($this->models[$model_name]) ? true : false; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | * @param bool $load_only |
| 475 | 475 | * @return mixed |
| 476 | 476 | */ |
| 477 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
| 477 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
| 478 | 478 | // retrieve instantiated class |
| 479 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
| 479 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | * @param bool $load_only |
| 492 | 492 | * @return EE_Addon |
| 493 | 493 | */ |
| 494 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
| 494 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
| 495 | 495 | // retrieve instantiated class |
| 496 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
| 496 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | |
@@ -525,27 +525,27 @@ discard block |
||
| 525 | 525 | $resolve_dependencies = false |
| 526 | 526 | ) { |
| 527 | 527 | // strip php file extension |
| 528 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
| 528 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
| 529 | 529 | // does the class have a prefix ? |
| 530 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
| 530 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
| 531 | 531 | // make sure $class_prefix is uppercase |
| 532 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
| 532 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
| 533 | 533 | // add class prefix ONCE!!! |
| 534 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
| 534 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
| 535 | 535 | } |
| 536 | 536 | // return object if it's already cached |
| 537 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
| 538 | - if ( $cached_class !== null ) { |
|
| 537 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
| 538 | + if ($cached_class !== null) { |
|
| 539 | 539 | return $cached_class; |
| 540 | 540 | } |
| 541 | 541 | // get full path to file |
| 542 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
| 542 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
| 543 | 543 | // load the file |
| 544 | - $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
| 544 | + $this->_require_file($path, $class_name, $type, $file_paths); |
|
| 545 | 545 | // instantiate the requested object |
| 546 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies ); |
|
| 546 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db, $load_only, $resolve_dependencies); |
|
| 547 | 547 | // save it for later... kinda like gum { : $ |
| 548 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db, $cache ); |
|
| 548 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db, $cache); |
|
| 549 | 549 | return $class_obj; |
| 550 | 550 | } |
| 551 | 551 | |
@@ -566,21 +566,21 @@ discard block |
||
| 566 | 566 | * @param string $class_prefix |
| 567 | 567 | * @return null|object |
| 568 | 568 | */ |
| 569 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
| 570 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 571 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 569 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
| 570 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 571 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 572 | 572 | } else { |
| 573 | 573 | // have to specify something, but not anything that will conflict |
| 574 | 574 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
| 575 | 575 | } |
| 576 | 576 | // check if class has already been loaded, and return it if it has been |
| 577 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
| 577 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
| 578 | 578 | return $this->{$class_abbreviation}; |
| 579 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
| 579 | + } else if (isset ($this->{$class_name} )) { |
|
| 580 | 580 | return $this->{$class_name}; |
| 581 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
| 581 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
| 582 | 582 | return $this->LIB->{$class_name}; |
| 583 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
| 583 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
| 584 | 584 | return $this->addons->{$class_name}; |
| 585 | 585 | } |
| 586 | 586 | return null; |
@@ -601,20 +601,20 @@ discard block |
||
| 601 | 601 | * @param array $file_paths |
| 602 | 602 | * @return string | bool |
| 603 | 603 | */ |
| 604 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
| 604 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
| 605 | 605 | // make sure $file_paths is an array |
| 606 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
| 606 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
| 607 | 607 | // cycle thru paths |
| 608 | - foreach ( $file_paths as $key => $file_path ) { |
|
| 608 | + foreach ($file_paths as $key => $file_path) { |
|
| 609 | 609 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
| 610 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
| 610 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
| 611 | 611 | // prep file type |
| 612 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
| 612 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
| 613 | 613 | // build full file path |
| 614 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
| 614 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
| 615 | 615 | //does the file exist and can be read ? |
| 616 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
| 617 | - return $file_paths[ $key ]; |
|
| 616 | + if (is_readable($file_paths[$key])) { |
|
| 617 | + return $file_paths[$key]; |
|
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | return false; |
@@ -636,29 +636,29 @@ discard block |
||
| 636 | 636 | * @return void |
| 637 | 637 | * @throws \EE_Error |
| 638 | 638 | */ |
| 639 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
| 639 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
| 640 | 640 | // don't give up! you gotta... |
| 641 | 641 | try { |
| 642 | 642 | //does the file exist and can it be read ? |
| 643 | - if ( ! $path ) { |
|
| 643 | + if ( ! $path) { |
|
| 644 | 644 | // so sorry, can't find the file |
| 645 | - throw new EE_Error ( |
|
| 645 | + throw new EE_Error( |
|
| 646 | 646 | sprintf( |
| 647 | - __( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ), |
|
| 648 | - trim( $type, '.' ), |
|
| 647 | + __('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'), |
|
| 648 | + trim($type, '.'), |
|
| 649 | 649 | $class_name, |
| 650 | - '<br />' . implode( ',<br />', $file_paths ) |
|
| 650 | + '<br />'.implode(',<br />', $file_paths) |
|
| 651 | 651 | ) |
| 652 | 652 | ); |
| 653 | 653 | } |
| 654 | 654 | // get the file |
| 655 | - require_once( $path ); |
|
| 655 | + require_once($path); |
|
| 656 | 656 | // if the class isn't already declared somewhere |
| 657 | - if ( class_exists( $class_name, false ) === false ) { |
|
| 657 | + if (class_exists($class_name, false) === false) { |
|
| 658 | 658 | // so sorry, not a class |
| 659 | 659 | throw new EE_Error( |
| 660 | 660 | sprintf( |
| 661 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
| 661 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
| 662 | 662 | $type, |
| 663 | 663 | $path, |
| 664 | 664 | $class_name |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - } catch ( EE_Error $e ) { |
|
| 669 | + } catch (EE_Error $e) { |
|
| 670 | 670 | $e->get_error(); |
| 671 | 671 | } |
| 672 | 672 | } |
@@ -698,52 +698,52 @@ discard block |
||
| 698 | 698 | * @return null | object |
| 699 | 699 | * @throws \EE_Error |
| 700 | 700 | */ |
| 701 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true ) { |
|
| 701 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false, $load_only = false, $resolve_dependencies = true) { |
|
| 702 | 702 | $class_obj = null; |
| 703 | - $resolve_dependencies = isset( $this->_auto_resolve_dependencies[ $class_name ] ) /*&& empty( $arguments )*/ ? true : $resolve_dependencies; |
|
| 703 | + $resolve_dependencies = isset($this->_auto_resolve_dependencies[$class_name]) /*&& empty( $arguments )*/ ? true : $resolve_dependencies; |
|
| 704 | 704 | // don't give up! you gotta... |
| 705 | 705 | try { |
| 706 | 706 | // create reflection |
| 707 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
| 707 | + $reflector = $this->get_ReflectionClass($class_name); |
|
| 708 | 708 | // make sure arguments are an array |
| 709 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
| 709 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
| 710 | 710 | // and if arguments array is NOT numerically indexed, then we want it to stay as an array, |
| 711 | 711 | // so wrap it in an additional array so that it doesn't get split into multiple parameters |
| 712 | - $arguments = isset( $arguments[ 0 ] ) ? $arguments : array( $arguments ); |
|
| 712 | + $arguments = isset($arguments[0]) ? $arguments : array($arguments); |
|
| 713 | 713 | // attempt to inject dependencies ? |
| 714 | - if ( $resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf( 'EE_Base_Class' ) ) { |
|
| 715 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
| 714 | + if ($resolve_dependencies && ! $from_db && ! $load_only && ! $reflector->isSubclassOf('EE_Base_Class')) { |
|
| 715 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
| 716 | 716 | } |
| 717 | 717 | // instantiate the class and add to the LIB array for tracking |
| 718 | 718 | // EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db) |
| 719 | - if ( $reflector->getConstructor() === null || $reflector->isAbstract() || $load_only ) { |
|
| 719 | + if ($reflector->getConstructor() === null || $reflector->isAbstract() || $load_only) { |
|
| 720 | 720 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
| 721 | 721 | //$instantiation_mode = "no constructor"; |
| 722 | 722 | return true; |
| 723 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
| 723 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
| 724 | 724 | //$instantiation_mode = "new_instance_from_db"; |
| 725 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
| 726 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
| 725 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
| 726 | + } else if (method_exists($class_name, 'new_instance')) { |
|
| 727 | 727 | //$instantiation_mode = "new_instance"; |
| 728 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
| 729 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
| 728 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
| 729 | + } else if (method_exists($class_name, 'instance')) { |
|
| 730 | 730 | //$instantiation_mode = "instance"; |
| 731 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
| 732 | - } else if ( $reflector->isInstantiable() ) { |
|
| 731 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
| 732 | + } else if ($reflector->isInstantiable()) { |
|
| 733 | 733 | //$instantiation_mode = "isInstantiable"; |
| 734 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
| 735 | - } else if ( ! $load_only ) { |
|
| 734 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
| 735 | + } else if ( ! $load_only) { |
|
| 736 | 736 | // heh ? something's not right ! |
| 737 | 737 | //$instantiation_mode = 'none'; |
| 738 | 738 | throw new EE_Error( |
| 739 | 739 | sprintf( |
| 740 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
| 740 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
| 741 | 741 | $type, |
| 742 | 742 | $class_name |
| 743 | 743 | ) |
| 744 | 744 | ); |
| 745 | 745 | } |
| 746 | - } catch ( EE_Error $e ) { |
|
| 746 | + } catch (EE_Error $e) { |
|
| 747 | 747 | $e->get_error(); |
| 748 | 748 | } |
| 749 | 749 | return $class_obj; |
@@ -761,14 +761,14 @@ discard block |
||
| 761 | 761 | * @param string $class_name |
| 762 | 762 | * @return ReflectionClass |
| 763 | 763 | */ |
| 764 | - public function get_ReflectionClass( $class_name ) { |
|
| 764 | + public function get_ReflectionClass($class_name) { |
|
| 765 | 765 | if ( |
| 766 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
| 767 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
| 766 | + ! isset($this->_reflectors[$class_name]) |
|
| 767 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
| 768 | 768 | ) { |
| 769 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
| 769 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
| 770 | 770 | } |
| 771 | - return $this->_reflectors[ $class_name ]; |
|
| 771 | + return $this->_reflectors[$class_name]; |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | |
@@ -793,19 +793,19 @@ discard block |
||
| 793 | 793 | * @param array $arguments |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
| 796 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
| 797 | 797 | // let's examine the constructor |
| 798 | 798 | $constructor = $reflector->getConstructor(); |
| 799 | 799 | // whu? huh? nothing? |
| 800 | - if ( ! $constructor ) { |
|
| 800 | + if ( ! $constructor) { |
|
| 801 | 801 | return $arguments; |
| 802 | 802 | } |
| 803 | 803 | // get constructor parameters |
| 804 | 804 | $params = $constructor->getParameters(); |
| 805 | 805 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
| 806 | - $argument_keys = array_keys( $arguments ); |
|
| 806 | + $argument_keys = array_keys($arguments); |
|
| 807 | 807 | // now loop thru all of the constructors expected parameters |
| 808 | - foreach ( $params as $index => $param ) { |
|
| 808 | + foreach ($params as $index => $param) { |
|
| 809 | 809 | // is this a dependency for a specific class ? |
| 810 | 810 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
| 811 | 811 | if ( |
@@ -813,40 +813,40 @@ discard block |
||
| 813 | 813 | $param_class === null || |
| 814 | 814 | ( |
| 815 | 815 | // something already exists in the incoming arguments for this param |
| 816 | - isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
| 816 | + isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
| 817 | 817 | // AND it's the correct class |
| 818 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
| 818 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
| 819 | 819 | ) |
| 820 | 820 | |
| 821 | 821 | ) { |
| 822 | 822 | // so let's skip this argument and move on to the next |
| 823 | 823 | continue; |
| 824 | 824 | } else if ( |
| 825 | - isset( $this->_auto_resolve_dependencies[ $class_name ] ) |
|
| 826 | - && isset( $this->_auto_resolve_dependencies[ $class_name ][ $param_class ] ) |
|
| 825 | + isset($this->_auto_resolve_dependencies[$class_name]) |
|
| 826 | + && isset($this->_auto_resolve_dependencies[$class_name][$param_class]) |
|
| 827 | 827 | ) { |
| 828 | 828 | // we might have a dependency... let's try and find it in our cache |
| 829 | - $cached_class = $this->_get_cached_class( $param_class ); |
|
| 829 | + $cached_class = $this->_get_cached_class($param_class); |
|
| 830 | 830 | $dependency = null; |
| 831 | 831 | // and grab it if it exists |
| 832 | - if ( $cached_class instanceof $param_class ) { |
|
| 832 | + if ($cached_class instanceof $param_class) { |
|
| 833 | 833 | $dependency = $cached_class; |
| 834 | - } else if ( $param_class != $class_name ) { |
|
| 835 | - $loader = $this->_auto_resolve_dependencies[ $class_name ][ $param_class ]; |
|
| 834 | + } else if ($param_class != $class_name) { |
|
| 835 | + $loader = $this->_auto_resolve_dependencies[$class_name][$param_class]; |
|
| 836 | 836 | // or if not cached, then let's try and load it directly |
| 837 | - $core_class = $this->$loader( $param_class ); |
|
| 837 | + $core_class = $this->$loader($param_class); |
|
| 838 | 838 | // as long as we aren't creating some recursive loading loop |
| 839 | - if ( $core_class instanceof $param_class ) { |
|
| 839 | + if ($core_class instanceof $param_class) { |
|
| 840 | 840 | $dependency = $core_class; |
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | // did we successfully find the correct dependency ? |
| 844 | - if ( $dependency instanceof $param_class ) { |
|
| 844 | + if ($dependency instanceof $param_class) { |
|
| 845 | 845 | // then let's inject it into the incoming array of arguments at the correct location |
| 846 | - array_splice( $arguments, $index, 1, array( $dependency ) ); |
|
| 846 | + array_splice($arguments, $index, 1, array($dependency)); |
|
| 847 | 847 | } |
| 848 | 848 | } else { |
| 849 | - $arguments[ $index ] = null; |
|
| 849 | + $arguments[$index] = null; |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | } |
@@ -875,16 +875,16 @@ discard block |
||
| 875 | 875 | * @param bool $cache |
| 876 | 876 | * @return void |
| 877 | 877 | */ |
| 878 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true ) { |
|
| 878 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false, $cache = true) { |
|
| 879 | 879 | // return newly instantiated class |
| 880 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
| 881 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
| 880 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
| 881 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
| 882 | 882 | $this->{$class_abbreviation} = $class_obj; |
| 883 | - } else if ( property_exists( $this, $class_name ) ) { |
|
| 883 | + } else if (property_exists($this, $class_name)) { |
|
| 884 | 884 | $this->{$class_name} = $class_obj; |
| 885 | - } else if ( $class_prefix == 'addon' && $cache ) { |
|
| 885 | + } else if ($class_prefix == 'addon' && $cache) { |
|
| 886 | 886 | $this->addons->{$class_name} = $class_obj; |
| 887 | - } else if ( ! $from_db && $cache ) { |
|
| 887 | + } else if ( ! $from_db && $cache) { |
|
| 888 | 888 | $this->LIB->{$class_name} = $class_obj; |
| 889 | 889 | } |
| 890 | 890 | } |
@@ -897,9 +897,9 @@ discard block |
||
| 897 | 897 | * @param string $name |
| 898 | 898 | * @return EE_Addon |
| 899 | 899 | */ |
| 900 | - public function get_addon_by_name( $name ) { |
|
| 901 | - foreach ( $this->addons as $addon ) { |
|
| 902 | - if ( $addon->name() == $name ) { |
|
| 900 | + public function get_addon_by_name($name) { |
|
| 901 | + foreach ($this->addons as $addon) { |
|
| 902 | + if ($addon->name() == $name) { |
|
| 903 | 903 | return $addon; |
| 904 | 904 | } |
| 905 | 905 | } |
@@ -915,8 +915,8 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | public function get_addons_by_name() { |
| 917 | 917 | $addons = array(); |
| 918 | - foreach ( $this->addons as $addon ) { |
|
| 919 | - $addons[ $addon->name() ] = $addon; |
|
| 918 | + foreach ($this->addons as $addon) { |
|
| 919 | + $addons[$addon->name()] = $addon; |
|
| 920 | 920 | } |
| 921 | 921 | return $addons; |
| 922 | 922 | } |
@@ -931,14 +931,14 @@ discard block |
||
| 931 | 931 | * @return \EEM_Base |
| 932 | 932 | * @throws \EE_Error |
| 933 | 933 | */ |
| 934 | - public function reset_model( $model_name ) { |
|
| 935 | - $model = $this->load_model( $model_name ); |
|
| 936 | - $model_class_name = get_class( $model ); |
|
| 934 | + public function reset_model($model_name) { |
|
| 935 | + $model = $this->load_model($model_name); |
|
| 936 | + $model_class_name = get_class($model); |
|
| 937 | 937 | //get that model reset it and make sure we nuke the old reference to it |
| 938 | - if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
| 938 | + if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
| 939 | 939 | $this->LIB->$model_class_name = $model::reset(); |
| 940 | 940 | } else { |
| 941 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
| 941 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
| 942 | 942 | } |
| 943 | 943 | return $this->LIB->$model_class_name; |
| 944 | 944 | } |
@@ -956,15 +956,15 @@ discard block |
||
| 956 | 956 | * currently reinstantiate the singletons at the moment) |
| 957 | 957 | * @return EE_Registry |
| 958 | 958 | */ |
| 959 | - public static function reset( $hard = false, $reinstantiate = true ) { |
|
| 959 | + public static function reset($hard = false, $reinstantiate = true) { |
|
| 960 | 960 | $instance = self::instance(); |
| 961 | - $instance->load_helper( 'Activation' ); |
|
| 961 | + $instance->load_helper('Activation'); |
|
| 962 | 962 | EEH_Activation::reset(); |
| 963 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
| 963 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
| 964 | 964 | $instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset(); |
| 965 | 965 | $instance->LIB = new stdClass(); |
| 966 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
| 967 | - $instance->reset_model( $model_name ); |
|
| 966 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
| 967 | + $instance->reset_model($model_name); |
|
| 968 | 968 | } |
| 969 | 969 | return $instance; |
| 970 | 970 | } |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | * @param $a |
| 985 | 985 | * @param $b |
| 986 | 986 | */ |
| 987 | - final function __call( $a, $b ) { |
|
| 987 | + final function __call($a, $b) { |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | /** |
| 993 | 993 | * @param $a |
| 994 | 994 | */ |
| 995 | - final function __get( $a ) { |
|
| 995 | + final function __get($a) { |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | * @param $a |
| 1002 | 1002 | * @param $b |
| 1003 | 1003 | */ |
| 1004 | - final function __set( $a, $b ) { |
|
| 1004 | + final function __set($a, $b) { |
|
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | |
@@ -1009,7 +1009,7 @@ discard block |
||
| 1009 | 1009 | /** |
| 1010 | 1010 | * @param $a |
| 1011 | 1011 | */ |
| 1012 | - final function __isset( $a ) { |
|
| 1012 | + final function __isset($a) { |
|
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | |
@@ -1017,7 +1017,7 @@ discard block |
||
| 1017 | 1017 | /** |
| 1018 | 1018 | * @param $a |
| 1019 | 1019 | */ |
| 1020 | - final function __unset( $a ) { |
|
| 1020 | + final function __unset($a) { |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | * @param $a |
| 1065 | 1065 | * @param $b |
| 1066 | 1066 | */ |
| 1067 | - final static function __callStatic( $a, $b ) { |
|
| 1067 | + final static function __callStatic($a, $b) { |
|
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
@@ -1073,9 +1073,9 @@ discard block |
||
| 1073 | 1073 | */ |
| 1074 | 1074 | public function cpt_models() { |
| 1075 | 1075 | $cpt_models = array(); |
| 1076 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
| 1077 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
| 1078 | - $cpt_models[ $short_name ] = $classname; |
|
| 1076 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
| 1077 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
| 1078 | + $cpt_models[$short_name] = $classname; |
|
| 1079 | 1079 | } |
| 1080 | 1080 | } |
| 1081 | 1081 | return $cpt_models; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 4 | 4 | exit('NO direct script access allowed'); |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -55,45 +55,45 @@ discard block |
||
| 55 | 55 | * @throws \EE_Error |
| 56 | 56 | * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems. |
| 57 | 57 | */ |
| 58 | - public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
| 58 | + public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) { |
|
| 59 | 59 | //make sure message_type is an array. |
| 60 | 60 | $message_types = (array) $message_types; |
| 61 | 61 | $templates = array(); |
| 62 | 62 | $success = TRUE; |
| 63 | 63 | |
| 64 | - if ( empty($messenger) ) { |
|
| 65 | - throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') ); |
|
| 64 | + if (empty($messenger)) { |
|
| 65 | + throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso')); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | //if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files. |
| 69 | - if ( empty($message_types) ) { |
|
| 70 | - throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') ); |
|
| 69 | + if (empty($message_types)) { |
|
| 70 | + throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso')); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | self::_set_autoloader(); |
| 74 | 74 | |
| 75 | 75 | |
| 76 | - $MSG = EE_Registry::instance()->load_lib( 'Messages' ); |
|
| 76 | + $MSG = EE_Registry::instance()->load_lib('Messages'); |
|
| 77 | 77 | |
| 78 | - foreach ( $message_types as $message_type ) { |
|
| 78 | + foreach ($message_types as $message_type) { |
|
| 79 | 79 | //if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty. |
| 80 | - if ( $global && empty( $GRP_ID ) ) { |
|
| 81 | - $GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) ); |
|
| 80 | + if ($global && empty($GRP_ID)) { |
|
| 81 | + $GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE))); |
|
| 82 | 82 | $GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0; |
| 83 | 83 | } |
| 84 | 84 | //if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination. If we do then NO generation!! |
| 85 | - if ( $global && self::already_generated($messenger, $message_type, $GRP_ID ) ) { |
|
| 85 | + if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) { |
|
| 86 | 86 | $templates = TRUE; |
| 87 | 87 | continue; //get out we've already got generated templates for this. |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $new_message_template_group = $MSG->create_new_templates($messenger, $message_type, $GRP_ID, $global); |
| 91 | 91 | |
| 92 | - if ( !$new_message_template_group ) { |
|
| 92 | + if ( ! $new_message_template_group) { |
|
| 93 | 93 | $success = FALSE; |
| 94 | 94 | continue; |
| 95 | 95 | } |
| 96 | - if ( $templates === TRUE ) $templates = array(); |
|
| 96 | + if ($templates === TRUE) $templates = array(); |
|
| 97 | 97 | $templates[] = $new_message_template_group; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | * @param bool $update_to_active if true then we also toggle the template to active. |
| 110 | 110 | * @return bool true = generated, false = hasn't been generated. |
| 111 | 111 | */ |
| 112 | - public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) { |
|
| 112 | + public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) { |
|
| 113 | 113 | self::_set_autoloader(); |
| 114 | 114 | $MTP = EEM_Message_Template::instance(); |
| 115 | 115 | |
| 116 | 116 | //what method we use depends on whether we have an GRP_ID or not |
| 117 | - $count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) : $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) ); |
|
| 117 | + $count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID))); |
|
| 118 | 118 | |
| 119 | - if ( $update_to_active ) { |
|
| 120 | - self::update_to_active( $messenger, $message_type ); |
|
| 119 | + if ($update_to_active) { |
|
| 120 | + self::update_to_active($messenger, $message_type); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return ( $count > 0 ) ? TRUE : FALSE; |
|
| 123 | + return ($count > 0) ? TRUE : FALSE; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | * @static |
| 135 | 135 | * @return int count of updated records. |
| 136 | 136 | */ |
| 137 | - public static function update_to_active( $messenger, $message_type ) { |
|
| 137 | + public static function update_to_active($messenger, $message_type) { |
|
| 138 | 138 | return EEM_Message_Template_Group::instance()->update( |
| 139 | - array( 'MTP_is_active' => 1 ), |
|
| 139 | + array('MTP_is_active' => 1), |
|
| 140 | 140 | array( |
| 141 | 141 | array( |
| 142 | 142 | 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return int count of updated records. |
| 161 | 161 | */ |
| 162 | - public static function update_to_inactive( $messenger = '', $message_type = '' ) { |
|
| 162 | + public static function update_to_inactive($messenger = '', $message_type = '') { |
|
| 163 | 163 | return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for( |
| 164 | 164 | $messenger, |
| 165 | 165 | $message_type |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | public static function get_installed_message_objects($type = 'all') { |
| 178 | 178 | self::_set_autoloader(); |
| 179 | 179 | //get all installed messengers and message_types |
| 180 | - $EE_MSG = EE_Registry::instance()->load_lib( 'Messages' ); |
|
| 180 | + $EE_MSG = EE_Registry::instance()->load_lib('Messages'); |
|
| 181 | 181 | $installed_message_objects = $EE_MSG->get_installed($type); |
| 182 | 182 | return $installed_message_objects; |
| 183 | 183 | } |
@@ -211,38 +211,38 @@ discard block |
||
| 211 | 211 | $context = 'admin', |
| 212 | 212 | $merged = false |
| 213 | 213 | ) { |
| 214 | - $messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) ); |
|
| 215 | - $mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) ); |
|
| 214 | + $messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger))); |
|
| 215 | + $mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type))); |
|
| 216 | 216 | |
| 217 | 217 | //convert slug to object |
| 218 | - $messenger = self::messenger_obj( $messenger ); |
|
| 218 | + $messenger = self::messenger_obj($messenger); |
|
| 219 | 219 | |
| 220 | 220 | //validate class for getting our list of shortcodes |
| 221 | - $classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator'; |
|
| 222 | - if ( !class_exists( $classname ) ) { |
|
| 223 | - $msg[] = __( 'The Validator class was unable to load', 'event_espresso'); |
|
| 221 | + $classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator'; |
|
| 222 | + if ( ! class_exists($classname)) { |
|
| 223 | + $msg[] = __('The Validator class was unable to load', 'event_espresso'); |
|
| 224 | 224 | $msg[] = sprintf( |
| 225 | 225 | __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), |
| 226 | 226 | $classname |
| 227 | 227 | ); |
| 228 | - throw new EE_Error( implode( '||', $msg ) ); |
|
| 228 | + throw new EE_Error(implode('||', $msg)); |
|
| 229 | 229 | } |
| 230 | 230 | /** @type EE_Messages_Validator $_VLD */ |
| 231 | - $_VLD = new $classname( array(), $context ); |
|
| 231 | + $_VLD = new $classname(array(), $context); |
|
| 232 | 232 | $valid_shortcodes = $_VLD->get_validators(); |
| 233 | 233 | |
| 234 | 234 | //let's make sure we're only getting the shortcode part of the validators |
| 235 | 235 | $shortcodes = array(); |
| 236 | - foreach( $valid_shortcodes as $field => $validators ) { |
|
| 236 | + foreach ($valid_shortcodes as $field => $validators) { |
|
| 237 | 237 | $shortcodes[$field] = $validators['shortcodes']; |
| 238 | 238 | } |
| 239 | 239 | $valid_shortcodes = $shortcodes; |
| 240 | 240 | |
| 241 | 241 | //if not all fields let's make sure we ONLY include the shortcodes for the specified fields. |
| 242 | - if ( ! empty( $fields ) ) { |
|
| 242 | + if ( ! empty($fields)) { |
|
| 243 | 243 | $specified_shortcodes = array(); |
| 244 | - foreach ( $fields as $field ) { |
|
| 245 | - if ( isset( $valid_shortcodes[$field] ) ) |
|
| 244 | + foreach ($fields as $field) { |
|
| 245 | + if (isset($valid_shortcodes[$field])) |
|
| 246 | 246 | $specified_shortcodes[$field] = $valid_shortcodes[$field]; |
| 247 | 247 | } |
| 248 | 248 | $valid_shortcodes = $specified_shortcodes; |
@@ -250,16 +250,16 @@ discard block |
||
| 250 | 250 | |
| 251 | 251 | |
| 252 | 252 | //if not merged then let's replace the fields with the localized fields |
| 253 | - if ( ! $merged ) { |
|
| 253 | + if ( ! $merged) { |
|
| 254 | 254 | //let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array. |
| 255 | 255 | $field_settings = $messenger->get_template_fields(); |
| 256 | 256 | $localized = array(); |
| 257 | - foreach ( $valid_shortcodes as $field => $shortcodes ) { |
|
| 257 | + foreach ($valid_shortcodes as $field => $shortcodes) { |
|
| 258 | 258 | //get localized field label |
| 259 | - if ( isset( $field_settings[$field] ) ) { |
|
| 259 | + if (isset($field_settings[$field])) { |
|
| 260 | 260 | //possible that this is used as a main field. |
| 261 | - if ( empty( $field_settings[$field] ) ) { |
|
| 262 | - if ( isset( $field_settings['extra'][$field] ) ) { |
|
| 261 | + if (empty($field_settings[$field])) { |
|
| 262 | + if (isset($field_settings['extra'][$field])) { |
|
| 263 | 263 | $_field = $field_settings['extra'][$field]['main']['label']; |
| 264 | 264 | } else { |
| 265 | 265 | $_field = $field; |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | } else { |
| 268 | 268 | $_field = $field_settings[$field]['label']; |
| 269 | 269 | } |
| 270 | - } else if ( isset( $field_settings['extra'] ) ) { |
|
| 270 | + } else if (isset($field_settings['extra'])) { |
|
| 271 | 271 | //loop through extra "main fields" and see if any of their children have our field |
| 272 | - foreach ( $field_settings['extra'] as $main_field => $fields ) { |
|
| 273 | - if ( isset( $fields[$field] ) ) |
|
| 272 | + foreach ($field_settings['extra'] as $main_field => $fields) { |
|
| 273 | + if (isset($fields[$field])) |
|
| 274 | 274 | $_field = $fields[$field]['label']; |
| 275 | 275 | else |
| 276 | 276 | $_field = $field; |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | } else { |
| 279 | 279 | $_field = $field; |
| 280 | 280 | } |
| 281 | - if ( isset( $_field )) { |
|
| 282 | - $localized[ $_field ] = $shortcodes; |
|
| 281 | + if (isset($_field)) { |
|
| 282 | + $localized[$_field] = $shortcodes; |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | $valid_shortcodes = $localized; |
@@ -287,11 +287,11 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | //if $merged then let's merge all the shortcodes into one list NOT indexed by field. |
| 290 | - if ( $merged ) { |
|
| 290 | + if ($merged) { |
|
| 291 | 291 | $merged_codes = array(); |
| 292 | - foreach ( $valid_shortcodes as $field => $shortcode ) { |
|
| 293 | - foreach ( $shortcode as $code => $label ) { |
|
| 294 | - if ( isset( $merged_codes[$code] ) ) |
|
| 292 | + foreach ($valid_shortcodes as $field => $shortcode) { |
|
| 293 | + foreach ($shortcode as $code => $label) { |
|
| 294 | + if (isset($merged_codes[$code])) |
|
| 295 | 295 | continue; |
| 296 | 296 | else |
| 297 | 297 | $merged_codes[$code] = $label; |
@@ -313,10 +313,10 @@ discard block |
||
| 313 | 313 | * @throws \EE_Error |
| 314 | 314 | * @return EE_Messenger |
| 315 | 315 | */ |
| 316 | - public static function messenger_obj( $messenger ) { |
|
| 317 | - $ee_msg = EE_Registry::instance()->load_lib( 'Messages' ); |
|
| 316 | + public static function messenger_obj($messenger) { |
|
| 317 | + $ee_msg = EE_Registry::instance()->load_lib('Messages'); |
|
| 318 | 318 | $installed_messengers = $ee_msg->get_installed_messengers(); |
| 319 | - return isset( $installed_messengers[ $messenger ] ) ? $installed_messengers[ $messenger ] : null; |
|
| 319 | + return isset($installed_messengers[$messenger]) ? $installed_messengers[$messenger] : null; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
@@ -329,10 +329,10 @@ discard block |
||
| 329 | 329 | * @throws \EE_Error |
| 330 | 330 | * @return EE_message_type |
| 331 | 331 | */ |
| 332 | - public static function message_type_obj( $message_type ) { |
|
| 333 | - $ee_msg = EE_Registry::instance()->load_lib( 'Messages' ); |
|
| 332 | + public static function message_type_obj($message_type) { |
|
| 333 | + $ee_msg = EE_Registry::instance()->load_lib('Messages'); |
|
| 334 | 334 | $installed_message_types = $ee_msg->get_installed_message_types(); |
| 335 | - return isset( $installed_message_types[ $message_type ] ) ? $installed_message_types[ $message_type ] : null; |
|
| 335 | + return isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : null; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | * @param string $message_type message type to check for. |
| 347 | 347 | * @return boolean |
| 348 | 348 | */ |
| 349 | - public static function is_mt_active( $message_type ) { |
|
| 349 | + public static function is_mt_active($message_type) { |
|
| 350 | 350 | self::_set_autoloader(); |
| 351 | - $active_mts = EE_Registry::instance()->load_lib( 'Messages' )->get_active_message_types(); |
|
| 352 | - return in_array( $message_type, $active_mts ); |
|
| 351 | + $active_mts = EE_Registry::instance()->load_lib('Messages')->get_active_message_types(); |
|
| 352 | + return in_array($message_type, $active_mts); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | |
@@ -362,10 +362,10 @@ discard block |
||
| 362 | 362 | * @param string $messenger slug for messenger to check. |
| 363 | 363 | * @return boolean |
| 364 | 364 | */ |
| 365 | - public static function is_messenger_active( $messenger ) { |
|
| 365 | + public static function is_messenger_active($messenger) { |
|
| 366 | 366 | self::_set_autoloader(); |
| 367 | 367 | $active_messengers = EE_Registry::instance()->load_lib('messages')->get_active_messengers(); |
| 368 | - return isset( $active_messengers[ $messenger ] ); |
|
| 368 | + return isset($active_messengers[$messenger]); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | public static function get_active_messengers_in_db() { |
| 382 | 382 | return apply_filters( |
| 383 | 383 | 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', |
| 384 | - get_option( 'ee_active_messengers', array() ) |
|
| 384 | + get_option('ee_active_messengers', array()) |
|
| 385 | 385 | ); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return bool FALSE if not updated, TRUE if updated. |
| 399 | 399 | */ |
| 400 | - public static function update_active_messengers_in_db( $data_to_save ) { |
|
| 401 | - return update_option( 'ee_active_messengers', $data_to_save ); |
|
| 400 | + public static function update_active_messengers_in_db($data_to_save) { |
|
| 401 | + return update_option('ee_active_messengers', $data_to_save); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | |
@@ -422,34 +422,34 @@ discard block |
||
| 422 | 422 | $sending_messenger = '' |
| 423 | 423 | ) { |
| 424 | 424 | //first determine if the url can be to the EE_Message object. |
| 425 | - if ( ! $message_type->always_generate() ) { |
|
| 426 | - return EEH_MSG_Template::generate_browser_trigger( $message ); |
|
| 425 | + if ( ! $message_type->always_generate()) { |
|
| 426 | + return EEH_MSG_Template::generate_browser_trigger($message); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | //if $registration object is not valid then exit early because there's nothing that can be generated. |
| 430 | - if ( ! $registration instanceof EE_Registration ) { |
|
| 430 | + if ( ! $registration instanceof EE_Registration) { |
|
| 431 | 431 | throw new EE_Error( |
| 432 | - __( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' ) |
|
| 432 | + __('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso') |
|
| 433 | 433 | ); |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | //validate given context |
| 437 | 437 | $contexts = $message_type->get_contexts(); |
| 438 | - if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) { |
|
| 438 | + if ($message->context() !== '' && ! isset($contexts[$message->context()])) { |
|
| 439 | 439 | throw new EE_Error( |
| 440 | 440 | sprintf( |
| 441 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
| 441 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
| 442 | 442 | $message->context(), |
| 443 | - get_class( $message_type ) |
|
| 443 | + get_class($message_type) |
|
| 444 | 444 | ) |
| 445 | 445 | ); |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | //valid sending messenger but only if sending messenger set. Otherwise generating messenger is used. |
| 449 | - if ( ! empty( $sending_messenger ) ) { |
|
| 449 | + if ( ! empty($sending_messenger)) { |
|
| 450 | 450 | $with_messengers = $message_type->with_messengers(); |
| 451 | - if ( ! isset( $with_messengers[$message->messenger()] ) |
|
| 452 | - || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) { |
|
| 451 | + if ( ! isset($with_messengers[$message->messenger()]) |
|
| 452 | + || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) { |
|
| 453 | 453 | throw new EE_Error( |
| 454 | 454 | sprintf( |
| 455 | 455 | __( |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | 'event_espresso' |
| 458 | 458 | ), |
| 459 | 459 | $sending_messenger, |
| 460 | - get_class( $message_type ) |
|
| 460 | + get_class($message_type) |
|
| 461 | 461 | ) |
| 462 | 462 | ); |
| 463 | 463 | } |
@@ -480,14 +480,14 @@ discard block |
||
| 480 | 480 | * @param EE_Message $message |
| 481 | 481 | * @return string. |
| 482 | 482 | */ |
| 483 | - public static function generate_browser_trigger( EE_Message $message ) { |
|
| 483 | + public static function generate_browser_trigger(EE_Message $message) { |
|
| 484 | 484 | $query_args = array( |
| 485 | 485 | 'ee' => 'msg_browser_trigger', |
| 486 | 486 | 'token' => $message->MSG_token() |
| 487 | 487 | ); |
| 488 | 488 | return apply_filters( |
| 489 | 489 | 'FHEE__EEH_MSG_Template__generate_browser_trigger', |
| 490 | - add_query_arg( $query_args, site_url() ), |
|
| 490 | + add_query_arg($query_args, site_url()), |
|
| 491 | 491 | $message |
| 492 | 492 | ); |
| 493 | 493 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * @param EE_Message $message |
| 503 | 503 | * @return string |
| 504 | 504 | */ |
| 505 | - public static function generate_error_display_trigger( EE_Message $message ) { |
|
| 505 | + public static function generate_error_display_trigger(EE_Message $message) { |
|
| 506 | 506 | return apply_filters( |
| 507 | 507 | 'FHEE__EEH_MSG_Template__generate_error_display_trigger', |
| 508 | 508 | add_query_arg( |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | 'GRP_ID' => $message_template_group, |
| 553 | 553 | 'id' => $data_id |
| 554 | 554 | ); |
| 555 | - $url = add_query_arg( $query_args, get_site_url() ); |
|
| 555 | + $url = add_query_arg($query_args, get_site_url()); |
|
| 556 | 556 | |
| 557 | 557 | //made it here so now we can just get the url and filter it. Filtered globally and by message type. |
| 558 | 558 | $url = apply_filters( |
@@ -580,9 +580,9 @@ discard block |
||
| 580 | 580 | * @param string $type What action to return. |
| 581 | 581 | * @return string |
| 582 | 582 | */ |
| 583 | - public static function get_message_action_icon( $type ) { |
|
| 583 | + public static function get_message_action_icon($type) { |
|
| 584 | 584 | $action_icons = self::get_message_action_icons(); |
| 585 | - return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : ''; |
|
| 585 | + return isset($action_icons[$type]) ? $action_icons[$type] : ''; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
@@ -594,34 +594,34 @@ discard block |
||
| 594 | 594 | * @return array |
| 595 | 595 | */ |
| 596 | 596 | public static function get_message_action_icons() { |
| 597 | - return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons', |
|
| 597 | + return apply_filters('FHEE__EEH_MSG_Template__message_action_icons', |
|
| 598 | 598 | array( |
| 599 | 599 | 'view' => array( |
| 600 | - 'label' => __( 'View Message', 'event_espresso' ), |
|
| 600 | + 'label' => __('View Message', 'event_espresso'), |
|
| 601 | 601 | 'css_class' => 'dashicons dashicons-welcome-view-site', |
| 602 | 602 | ), |
| 603 | 603 | 'error' => array( |
| 604 | - 'label' => __( 'View Error Message', 'event_espresso' ), |
|
| 604 | + 'label' => __('View Error Message', 'event_espresso'), |
|
| 605 | 605 | 'css_class' => 'dashicons dashicons-info', |
| 606 | 606 | ), |
| 607 | 607 | 'see_notifications_for' => array( |
| 608 | - 'label' => __( 'View Related Messages', 'event_espresso' ), |
|
| 608 | + 'label' => __('View Related Messages', 'event_espresso'), |
|
| 609 | 609 | 'css_class' => 'dashicons dashicons-images-alt', |
| 610 | 610 | ), |
| 611 | 611 | 'generate_now' => array( |
| 612 | - 'label' => __( 'Generate the message now.', 'event_espresso' ), |
|
| 612 | + 'label' => __('Generate the message now.', 'event_espresso'), |
|
| 613 | 613 | 'css_class' => 'dashicons dashicons-admin-tools', |
| 614 | 614 | ), |
| 615 | 615 | 'send_now' => array( |
| 616 | - 'label' => __( 'Send Immediately', 'event_espresso' ), |
|
| 616 | + 'label' => __('Send Immediately', 'event_espresso'), |
|
| 617 | 617 | 'css_class' => 'dashicons dashicons-controls-forward', |
| 618 | 618 | ), |
| 619 | 619 | 'queue_for_resending' => array( |
| 620 | - 'label' => __( 'Queue for Resending', 'event_espresso' ), |
|
| 620 | + 'label' => __('Queue for Resending', 'event_espresso'), |
|
| 621 | 621 | 'css_class' => 'dashicons dashicons-controls-repeat', |
| 622 | 622 | ), |
| 623 | 623 | 'view_transaction' => array( |
| 624 | - 'label' => __( 'View related Transaction', 'event_espresso' ), |
|
| 624 | + 'label' => __('View related Transaction', 'event_espresso'), |
|
| 625 | 625 | 'css_class' => 'dashicons dashicons-cart', |
| 626 | 626 | ) |
| 627 | 627 | ) |
@@ -640,9 +640,9 @@ discard block |
||
| 640 | 640 | * |
| 641 | 641 | * @return string |
| 642 | 642 | */ |
| 643 | - public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) { |
|
| 644 | - $action_urls = self::get_message_action_urls( $message, $query_params ); |
|
| 645 | - return isset( $action_urls[ $type ] ) ? $action_urls[ $type ] : ''; |
|
| 643 | + public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) { |
|
| 644 | + $action_urls = self::get_message_action_urls($message, $query_params); |
|
| 645 | + return isset($action_urls[$type]) ? $action_urls[$type] : ''; |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | |
@@ -656,15 +656,15 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @return array |
| 658 | 658 | */ |
| 659 | - public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) { |
|
| 660 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
| 659 | + public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) { |
|
| 660 | + EE_Registry::instance()->load_helper('URL'); |
|
| 661 | 661 | //if $message is not an instance of EE_Message then let's just do a dummy. |
| 662 | - $message = empty( $message ) ? EE_Message_Factory::create() : $message; |
|
| 663 | - $action_urls = apply_filters( |
|
| 662 | + $message = empty($message) ? EE_Message_Factory::create() : $message; |
|
| 663 | + $action_urls = apply_filters( |
|
| 664 | 664 | 'FHEE__EEH_MSG_Template__get_message_action_url', |
| 665 | 665 | array( |
| 666 | - 'view' => EEH_MSG_Template::generate_browser_trigger( $message ), |
|
| 667 | - 'error' => EEH_MSG_Template::generate_error_display_trigger( $message ), |
|
| 666 | + 'view' => EEH_MSG_Template::generate_browser_trigger($message), |
|
| 667 | + 'error' => EEH_MSG_Template::generate_error_display_trigger($message), |
|
| 668 | 668 | 'see_notifications_for' => EEH_URL::add_query_args_and_nonce( |
| 669 | 669 | array_merge( |
| 670 | 670 | array( |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | ), |
| 675 | 675 | $query_params |
| 676 | 676 | ), |
| 677 | - admin_url( 'admin.php' ) |
|
| 677 | + admin_url('admin.php') |
|
| 678 | 678 | ), |
| 679 | 679 | 'generate_now' => EEH_URL::add_query_args_and_nonce( |
| 680 | 680 | array( |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | 'action' => 'generate_now', |
| 683 | 683 | 'MSG_ID' => $message->ID() |
| 684 | 684 | ), |
| 685 | - admin_url( 'admin.php' ) |
|
| 685 | + admin_url('admin.php') |
|
| 686 | 686 | ), |
| 687 | 687 | 'send_now' => EEH_URL::add_query_args_and_nonce( |
| 688 | 688 | array( |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | 'action' => 'send_now', |
| 691 | 691 | 'MSG_ID' => $message->ID() |
| 692 | 692 | ), |
| 693 | - admin_url( 'admin.php' ) |
|
| 693 | + admin_url('admin.php') |
|
| 694 | 694 | ), |
| 695 | 695 | 'queue_for_resending' => EEH_URL::add_query_args_and_nonce( |
| 696 | 696 | array( |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | 'action' => 'queue_for_resending', |
| 699 | 699 | 'MSG_ID' => $message->ID() |
| 700 | 700 | ), |
| 701 | - admin_url( 'admin.php' ) |
|
| 701 | + admin_url('admin.php') |
|
| 702 | 702 | ), |
| 703 | 703 | ) |
| 704 | 704 | ); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | 'action' => 'view_transaction', |
| 717 | 717 | 'TXN_ID' => $message->TXN_ID() |
| 718 | 718 | ), |
| 719 | - admin_url( 'admin.php' ) |
|
| 719 | + admin_url('admin.php') |
|
| 720 | 720 | ); |
| 721 | 721 | } else { |
| 722 | 722 | $action_urls['view_transaction'] = ''; |
@@ -737,24 +737,24 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return string |
| 739 | 739 | */ |
| 740 | - public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) { |
|
| 741 | - $url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params ); |
|
| 742 | - $icon_css = EEH_MSG_Template::get_message_action_icon( $type ); |
|
| 743 | - if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) { |
|
| 740 | + public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) { |
|
| 741 | + $url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params); |
|
| 742 | + $icon_css = EEH_MSG_Template::get_message_action_icon($type); |
|
| 743 | + if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) { |
|
| 744 | 744 | return ''; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | $icon_css['css_class'] .= esc_attr( |
| 748 | 748 | apply_filters( |
| 749 | 749 | 'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class', |
| 750 | - ' js-ee-message-action-link ee-message-action-link-' . $type, |
|
| 750 | + ' js-ee-message-action-link ee-message-action-link-'.$type, |
|
| 751 | 751 | $type, |
| 752 | 752 | $message, |
| 753 | 753 | $query_params |
| 754 | 754 | ) |
| 755 | 755 | ); |
| 756 | 756 | |
| 757 | - return '<a href="' . $url . '"><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>'; |
|
| 757 | + return '<a href="'.$url.'"><span class="'.esc_attr($icon_css['css_class']).'"></span></a>'; |
|
| 758 | 758 | |
| 759 | 759 | } |
| 760 | 760 | |
@@ -792,9 +792,9 @@ discard block |
||
| 792 | 792 | * @param $reg_status |
| 793 | 793 | * @return string |
| 794 | 794 | */ |
| 795 | - public static function convert_reg_status_to_message_type( $reg_status ) { |
|
| 795 | + public static function convert_reg_status_to_message_type($reg_status) { |
|
| 796 | 796 | $reg_status_array = self::reg_status_to_message_type_array(); |
| 797 | - return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : ''; |
|
| 797 | + return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : ''; |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | |
@@ -828,9 +828,9 @@ discard block |
||
| 828 | 828 | * @param $payment_status |
| 829 | 829 | * @return string |
| 830 | 830 | */ |
| 831 | - public static function convert_payment_status_to_message_type( $payment_status ) { |
|
| 831 | + public static function convert_payment_status_to_message_type($payment_status) { |
|
| 832 | 832 | $payment_status_array = self::payment_status_to_message_type_array(); |
| 833 | - return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : ''; |
|
| 833 | + return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : ''; |
|
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | |
@@ -841,32 +841,32 @@ discard block |
||
| 841 | 841 | * |
| 842 | 842 | * @return EE_Messages_Template_Pack |
| 843 | 843 | */ |
| 844 | - public static function get_template_pack( $template_pack_name ) { |
|
| 845 | - if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) { |
|
| 844 | + public static function get_template_pack($template_pack_name) { |
|
| 845 | + if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) { |
|
| 846 | 846 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | //first see if in collection already |
| 850 | - $template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name ); |
|
| 850 | + $template_pack = self::$_template_pack_collection->get_by_name($template_pack_name); |
|
| 851 | 851 | |
| 852 | - if ( $template_pack instanceof EE_Messages_Template_Pack ) { |
|
| 852 | + if ($template_pack instanceof EE_Messages_Template_Pack) { |
|
| 853 | 853 | return $template_pack; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | //nope...let's get it. |
| 857 | 857 | //not set yet so let's attempt to get it. |
| 858 | - $pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
| 858 | + $pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
| 859 | 859 | ' ', |
| 860 | 860 | '_', |
| 861 | 861 | ucwords( |
| 862 | - str_replace( '_', ' ', $template_pack_name ) |
|
| 862 | + str_replace('_', ' ', $template_pack_name) |
|
| 863 | 863 | ) |
| 864 | 864 | ); |
| 865 | - if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) { |
|
| 866 | - return self::get_template_pack( 'default' ); |
|
| 865 | + if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') { |
|
| 866 | + return self::get_template_pack('default'); |
|
| 867 | 867 | } else { |
| 868 | 868 | $template_pack = new $pack_class_name; |
| 869 | - self::$_template_pack_collection->add( $template_pack ); |
|
| 869 | + self::$_template_pack_collection->add($template_pack); |
|
| 870 | 870 | return $template_pack; |
| 871 | 871 | } |
| 872 | 872 | } |
@@ -884,26 +884,26 @@ discard block |
||
| 884 | 884 | */ |
| 885 | 885 | public static function get_template_pack_collection() { |
| 886 | 886 | $new_collection = false; |
| 887 | - if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) { |
|
| 887 | + if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) { |
|
| 888 | 888 | self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection(); |
| 889 | 889 | $new_collection = true; |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | //glob the defaults directory for messages |
| 893 | - $templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR ); |
|
| 894 | - foreach( $templates as $template_path ) { |
|
| 893 | + $templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR); |
|
| 894 | + foreach ($templates as $template_path) { |
|
| 895 | 895 | //grab folder name |
| 896 | - $template = basename( $template_path ); |
|
| 896 | + $template = basename($template_path); |
|
| 897 | 897 | |
| 898 | - if ( ! $new_collection ) { |
|
| 898 | + if ( ! $new_collection) { |
|
| 899 | 899 | //already have it? |
| 900 | - if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) { |
|
| 900 | + if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) { |
|
| 901 | 901 | continue; |
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | //setup classname. |
| 906 | - $template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace( |
|
| 906 | + $template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace( |
|
| 907 | 907 | ' ', |
| 908 | 908 | '_', |
| 909 | 909 | ucwords( |
@@ -914,20 +914,20 @@ discard block |
||
| 914 | 914 | ) |
| 915 | 915 | ) |
| 916 | 916 | ); |
| 917 | - if ( ! class_exists( $template_pack_class_name ) ) { |
|
| 917 | + if ( ! class_exists($template_pack_class_name)) { |
|
| 918 | 918 | continue; |
| 919 | 919 | } |
| 920 | - self::$_template_pack_collection->add( new $template_pack_class_name ); |
|
| 920 | + self::$_template_pack_collection->add(new $template_pack_class_name); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | 924 | * Filter for plugins to add in any additional template packs |
| 925 | 925 | * Note the filter name here is for backward compat, this used to be found in EED_Messages. |
| 926 | 926 | */ |
| 927 | - $additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() ); |
|
| 928 | - foreach ( (array) $additional_template_packs as $template_pack ) { |
|
| 929 | - if ( ! self::$_template_pack_collection->contains($template_pack ) ) { |
|
| 930 | - self::$_template_pack_collection->add( $template_pack ); |
|
| 927 | + $additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array()); |
|
| 928 | + foreach ((array) $additional_template_packs as $template_pack) { |
|
| 929 | + if ( ! self::$_template_pack_collection->contains($template_pack)) { |
|
| 930 | + self::$_template_pack_collection->add($template_pack); |
|
| 931 | 931 | } |
| 932 | 932 | } |
| 933 | 933 | return self::$_template_pack_collection; |
@@ -92,42 +92,42 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return EEM_Message |
| 94 | 94 | */ |
| 95 | - protected function __construct( $timezone = null ) { |
|
| 96 | - $this->singular_item = __('Message','event_espresso'); |
|
| 97 | - $this->plural_item = __('Messages','event_espresso'); |
|
| 95 | + protected function __construct($timezone = null) { |
|
| 96 | + $this->singular_item = __('Message', 'event_espresso'); |
|
| 97 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
| 98 | 98 | |
| 99 | 99 | //used for token generator |
| 100 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
| 100 | + EE_Registry::instance()->load_helper('URL'); |
|
| 101 | 101 | |
| 102 | 102 | $this->_tables = array( |
| 103 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
| 103 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | $allowed_priority = array( |
| 107 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
| 108 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
| 109 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
| 107 | + self::priority_high => __('high', 'event_espresso'), |
|
| 108 | + self::priority_medium => __('medium', 'event_espresso'), |
|
| 109 | + self::priority_low => __('low', 'event_espresso') |
|
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | $this->_fields = array( |
| 113 | 113 | 'Message'=>array( |
| 114 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
| 115 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
| 116 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
| 117 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
| 118 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_Messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
| 119 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
| 120 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
| 121 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
| 122 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
| 123 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
| 124 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
| 125 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
| 126 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
| 127 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
| 128 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
| 129 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
| 130 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
| 114 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
| 115 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
| 116 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
| 117 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
| 118 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_Messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
| 119 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
| 120 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
| 121 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
| 122 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
| 123 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
| 124 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
| 125 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
| 126 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
| 127 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
| 128 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
| 129 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
| 130 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
| 131 | 131 | ) |
| 132 | 132 | ); |
| 133 | 133 | $this->_model_relations = array( |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
| 138 | 138 | 'Transaction' => new EE_Belongs_To_Relation() |
| 139 | 139 | ); |
| 140 | - parent::__construct( $timezone ); |
|
| 140 | + parent::__construct($timezone); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | public function create_default_object() { |
| 149 | 149 | /** @type EE_Message $message */ |
| 150 | 150 | $message = parent::create_default_object(); |
| 151 | - return EE_Message_Factory::set_messenger_and_message_type( $message, false ); |
|
| 151 | + return EE_Message_Factory::set_messenger_and_message_type($message, false); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | * @param mixed $cols_n_values |
| 158 | 158 | * @return \EE_Message |
| 159 | 159 | */ |
| 160 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
| 160 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
| 161 | 161 | /** @type EE_Message $message */ |
| 162 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
| 163 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
| 162 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
| 163 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | * @param string $message_type the message type slug |
| 172 | 172 | * @return boolean |
| 173 | 173 | */ |
| 174 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
| 175 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
| 176 | - return $this->exists( array( array( |
|
| 174 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
| 175 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
| 176 | + return $this->exists(array(array( |
|
| 177 | 177 | 'Attendee.ATT_ID' => $attendee_ID, |
| 178 | 178 | 'MSG_message_type' => $message_type, |
| 179 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
| 180 | - ) ) ); |
|
| 179 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
| 180 | + ))); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | * @param string $message_type the message type slug |
| 190 | 190 | * @return boolean |
| 191 | 191 | */ |
| 192 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
| 193 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
| 194 | - return $this->exists( array( array( |
|
| 192 | + public function message_sent_for_registration($registration, $message_type) { |
|
| 193 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
| 194 | + return $this->exists(array(array( |
|
| 195 | 195 | 'Registration.REG_ID' => $registrationID, |
| 196 | 196 | 'MSG_message_type' => $message_type, |
| 197 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
| 198 | - ) ) ); |
|
| 197 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
| 198 | + ))); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | |
@@ -206,10 +206,10 @@ discard block |
||
| 206 | 206 | * @param string $token |
| 207 | 207 | * @return EE_Message | null |
| 208 | 208 | */ |
| 209 | - public function get_one_by_token( $token ) { |
|
| 210 | - return $this->get_one( array( array( |
|
| 209 | + public function get_one_by_token($token) { |
|
| 210 | + return $this->get_one(array(array( |
|
| 211 | 211 | 'MSG_token' => $token |
| 212 | - ) ) ); |
|
| 212 | + ))); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -217,8 +217,8 @@ discard block |
||
| 217 | 217 | * Returns stati that indicate the message HAS been sent |
| 218 | 218 | * @return array of strings for possible stati |
| 219 | 219 | */ |
| 220 | - public function stati_indicating_sent(){ |
|
| 221 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
| 220 | + public function stati_indicating_sent() { |
|
| 221 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
@@ -229,13 +229,13 @@ discard block |
||
| 229 | 229 | * @return array of strings for possible stati. |
| 230 | 230 | */ |
| 231 | 231 | public function stati_indicating_to_send() { |
| 232 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
| 232 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | |
| 236 | 236 | |
| 237 | 237 | public function stati_indicating_failed_sending() { |
| 238 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry ) ); |
|
| 238 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry)); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | |
@@ -275,25 +275,25 @@ discard block |
||
| 275 | 275 | 'EVT_ID' => 'Event', |
| 276 | 276 | ); |
| 277 | 277 | $query_params[0] = array(); |
| 278 | - EE_Registry::instance()->load_class( 'Request_Handler' ); |
|
| 279 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
| 280 | - if ( $request_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
| 278 | + EE_Registry::instance()->load_class('Request_Handler'); |
|
| 279 | + foreach ($expected_vars as $request_key => $model_name) { |
|
| 280 | + if ($request_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
| 281 | 281 | //special case |
| 282 | - if ( $request_key === '_REG_ID' ) { |
|
| 282 | + if ($request_key === '_REG_ID') { |
|
| 283 | 283 | $query_params[0]['AND**filter_by']['OR**filter_by'] = array( |
| 284 | 284 | 'Registration.REG_ID' => $request_value, |
| 285 | 285 | 'Attendee.Registration.REG_ID' => $request_value, |
| 286 | 286 | ); |
| 287 | 287 | continue; |
| 288 | 288 | } |
| 289 | - if ( $request_key === 'EVT_ID' ) { |
|
| 289 | + if ($request_key === 'EVT_ID') { |
|
| 290 | 290 | $query_params[0]['AND**filter_by']['OR**filter_by'] = array( |
| 291 | 291 | 'Registration.EVT_ID' => $request_value, |
| 292 | 292 | 'Attendee.Registration.EVT_ID' => $request_value, |
| 293 | 293 | ); |
| 294 | 294 | continue; |
| 295 | 295 | } |
| 296 | - $query_params[0][ $model_name . '.' . $request_key ] = EE_Registry::instance()->REQ->get( $request_key ); |
|
| 296 | + $query_params[0][$model_name.'.'.$request_key] = EE_Registry::instance()->REQ->get($request_key); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | return $query_params; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed $info |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function add( $object, $info = null ) { |
|
| 43 | - $info = empty( $info ) && $object instanceof EE_Messenger ? $object->name : $info; |
|
| 44 | - return parent::add( $object, $info ); // TODO: Change the autogenerated stub |
|
| 42 | + public function add($object, $info = null) { |
|
| 43 | + $info = empty($info) && $object instanceof EE_Messenger ? $object->name : $info; |
|
| 44 | + return parent::add($object, $info); // TODO: Change the autogenerated stub |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param mixed $info |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public function set_info( $object, $info = null ) { |
|
| 61 | - $info = empty( $info ) && $object instanceof EE_Messenger ? $object->name : $info; |
|
| 62 | - return parent::set_info( $object, $info ); |
|
| 60 | + public function set_info($object, $info = null) { |
|
| 61 | + $info = empty($info) && $object instanceof EE_Messenger ? $object->name : $info; |
|
| 62 | + return parent::set_info($object, $info); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param mixed |
| 75 | 75 | * @return null | object |
| 76 | 76 | */ |
| 77 | - public function get_by_info( $info ) { |
|
| 78 | - return parent::get_by_info( $info ); // TODO: Change the autogenerated stub |
|
| 77 | + public function get_by_info($info) { |
|
| 78 | + return parent::get_by_info($info); // TODO: Change the autogenerated stub |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | * @param object $object |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function has( $object ) { |
|
| 93 | - return parent::has( $object ); // TODO: Change the autogenerated stub |
|
| 92 | + public function has($object) { |
|
| 93 | + return parent::has($object); // TODO: Change the autogenerated stub |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $messenger_classname |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - public function has_by_classname( $messenger_classname ) { |
|
| 108 | - return $this->get_by_info( $messenger_classname ) instanceof $messenger_classname ? true :false; |
|
| 107 | + public function has_by_classname($messenger_classname) { |
|
| 108 | + return $this->get_by_info($messenger_classname) instanceof $messenger_classname ? true : false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param $object |
| 120 | 120 | * @return bool |
| 121 | 121 | */ |
| 122 | - public function remove( $object ) { |
|
| 123 | - return parent::remove( $object ); // TODO: Change the autogenerated stub |
|
| 122 | + public function remove($object) { |
|
| 123 | + return parent::remove($object); // TODO: Change the autogenerated stub |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | * @param $object |
| 149 | 149 | * @return void |
| 150 | 150 | */ |
| 151 | - public function set_current( $object ) { |
|
| 152 | - parent::set_current( $object ); // TODO: Change the autogenerated stub |
|
| 151 | + public function set_current($object) { |
|
| 152 | + parent::set_current($object); // TODO: Change the autogenerated stub |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * @param $info |
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | - public function set_current_by_info( $info ) { |
|
| 167 | - parent::set_current_by_info( $info ); // TODO: Change the autogenerated stub |
|
| 166 | + public function set_current_by_info($info) { |
|
| 167 | + parent::set_current_by_info($info); // TODO: Change the autogenerated stub |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @return void |
| 179 | 179 | */ |
| 180 | 180 | public function show_collection_classes() { |
| 181 | - if ( WP_DEBUG ) { |
|
| 181 | + if (WP_DEBUG) { |
|
| 182 | 182 | $this->rewind(); |
| 183 | - while ( $this->valid() ) { |
|
| 184 | - echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">' . $this->getInfo() |
|
| 183 | + while ($this->valid()) { |
|
| 184 | + echo '<h5 style="color:#2EA2CC;">collection class : <span style="color:#E76700">'.$this->getInfo() |
|
| 185 | 185 | . '</span></h5>'; |
| 186 | 186 | $this->next(); |
| 187 | 187 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * This class is used for generating EE_Message objects with given info. |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | * @param EE_Messages_Queue $queue |
| 120 | 120 | * @param EE_Messages $eemsg |
| 121 | 121 | */ |
| 122 | - public function __construct( EE_Messages_Queue $queue, EE_Messages $eemsg ) { |
|
| 122 | + public function __construct(EE_Messages_Queue $queue, EE_Messages $eemsg) { |
|
| 123 | 123 | $this->_generation_queue = $queue; |
| 124 | - $this->_ready_queue = new EE_Messages_Queue( $eemsg ); |
|
| 124 | + $this->_ready_queue = new EE_Messages_Queue($eemsg); |
|
| 125 | 125 | $this->_EEMSG = $eemsg; |
| 126 | 126 | $this->_data_handler_collection = new EE_Messages_Data_Handler_Collection(); |
| 127 | 127 | $this->_template_collection = new EE_Message_Template_Group_Collection(); |
| 128 | 128 | |
| 129 | - EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ); |
|
| 129 | + EE_Registry::instance()->load_helper('Parse_Shortcodes'); |
|
| 130 | 130 | $this->_shortcode_parser = new EEH_Parse_Shortcodes(); |
| 131 | 131 | |
| 132 | 132 | //load request handler |
| 133 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
| 133 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -147,17 +147,17 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return EE_Messages_Queue The new queue for holding generated EE_Message objects. |
| 149 | 149 | */ |
| 150 | - public function generate( $save = true ) { |
|
| 150 | + public function generate($save = true) { |
|
| 151 | 151 | //iterate through the messages in the queue, generate, and add to new queue. |
| 152 | 152 | $this->_generation_queue->get_queue()->rewind(); |
| 153 | - while ( $this->_generation_queue->get_queue()->valid() ) { |
|
| 153 | + while ($this->_generation_queue->get_queue()->valid()) { |
|
| 154 | 154 | //resent "current" properties |
| 155 | 155 | $this->_reset_current_properties(); |
| 156 | 156 | |
| 157 | 157 | /** @type EE_Message $msg */ |
| 158 | 158 | $msg = $this->_generation_queue->get_queue()->current(); |
| 159 | 159 | |
| 160 | - if ( $this->_verify() ) { |
|
| 160 | + if ($this->_verify()) { |
|
| 161 | 161 | //let's get generating! |
| 162 | 162 | $this->_generate(); |
| 163 | 163 | } |
@@ -169,23 +169,23 @@ discard block |
||
| 169 | 169 | $this->_generation_queue->get_queue()->next(); |
| 170 | 170 | $next_msg = $this->_generation_queue->get_queue()->current(); |
| 171 | 171 | //restore pointer to current item |
| 172 | - $this->_generation_queue->get_queue()->set_current( $msg ); |
|
| 172 | + $this->_generation_queue->get_queue()->set_current($msg); |
|
| 173 | 173 | |
| 174 | 174 | //if there are error messages then let's set the status and the error message. |
| 175 | - if ( $this->_error_msg ) { |
|
| 176 | - $msg->set_STS_ID( EEM_Message::status_failed ); |
|
| 175 | + if ($this->_error_msg) { |
|
| 176 | + $msg->set_STS_ID(EEM_Message::status_failed); |
|
| 177 | 177 | $msg->set_error_message( |
| 178 | - __( 'Message failed to generate for the following reasons: ' ) |
|
| 178 | + __('Message failed to generate for the following reasons: ') |
|
| 179 | 179 | . "\n" |
| 180 | - . implode( "\n", $this->_error_msg ) |
|
| 180 | + . implode("\n", $this->_error_msg) |
|
| 181 | 181 | ); |
| 182 | - $msg->set_modified( time() ); |
|
| 182 | + $msg->set_modified(time()); |
|
| 183 | 183 | } else { |
| 184 | 184 | //remove from db |
| 185 | 185 | $this->_generation_queue->get_queue()->delete(); |
| 186 | 186 | } |
| 187 | 187 | //next item |
| 188 | - $this->_generation_queue->get_queue()->set_current( $next_msg ); |
|
| 188 | + $this->_generation_queue->get_queue()->set_current($next_msg); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | //generation queue is ALWAYS saved to record any errors in the generation process. |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * so a EE_Extra_Meta entry could be created and attached to the EE_Message. In those cases the save flag is |
| 199 | 199 | * irrelevant. |
| 200 | 200 | */ |
| 201 | - if ( $save ) { |
|
| 201 | + if ($save) { |
|
| 202 | 202 | $this->_ready_queue->save(); |
| 203 | 203 | } |
| 204 | 204 | return $this->_ready_queue; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | protected function _generate() { |
| 229 | 229 | //double check verification has run and that everything is ready to work with (saves us having to validate everything again). |
| 230 | - if ( ! $this->_verified ) { |
|
| 230 | + if ( ! $this->_verified) { |
|
| 231 | 231 | return false; //get out because we don't have a valid setup to work with. |
| 232 | 232 | } |
| 233 | 233 | |
@@ -237,34 +237,34 @@ discard block |
||
| 237 | 237 | $this->_current_data_handler, |
| 238 | 238 | $this->_generation_queue->get_queue()->current()->context() |
| 239 | 239 | ); |
| 240 | - } catch ( EE_Error $e ) { |
|
| 240 | + } catch (EE_Error $e) { |
|
| 241 | 241 | $this->_error_msg[] = $e->getMessage(); |
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | //if no addressees then get out because there is nothing to generation (possible bad data). |
| 247 | - if ( ! $this->_valid_addressees( $addressees ) ) { |
|
| 248 | - $this->_error_msg[] = __( 'Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
| 247 | + if ( ! $this->_valid_addressees($addressees)) { |
|
| 248 | + $this->_error_msg[] = __('Unable to generate messages EE_Messages_Addressee objects. There were no attendees prepared by the data handler. |
|
| 249 | 249 | Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to |
| 250 | - approved registrations.', 'event_espresso' ); |
|
| 250 | + approved registrations.', 'event_espresso'); |
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $mtpg = $this->_get_message_template_group(); |
| 255 | 255 | |
| 256 | 256 | //in the unlikely event there is no EE_Message_Template_Group available, get out! |
| 257 | - if ( ! $mtpg instanceof EE_Message_Template_Group ) { |
|
| 258 | - $this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso' ); |
|
| 257 | + if ( ! $mtpg instanceof EE_Message_Template_Group) { |
|
| 258 | + $this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated. No message template group accessible.', 'event_espresso'); |
|
| 259 | 259 | return false; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | //get formatted templates for using to parse and setup EE_Message objects. |
| 263 | - $templates = $this->_get_templates( $mtpg ); |
|
| 263 | + $templates = $this->_get_templates($mtpg); |
|
| 264 | 264 | |
| 265 | 265 | |
| 266 | 266 | //setup new EE_Message objects (and add to _ready_queue) |
| 267 | - return $this->_assemble_messages( $addressees, $templates, $mtpg ); |
|
| 267 | + return $this->_assemble_messages($addressees, $templates, $mtpg); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
@@ -282,17 +282,17 @@ discard block |
||
| 282 | 282 | //so let's use that. |
| 283 | 283 | $GRP_ID = $this->_generation_queue->get_queue()->current()->GRP_ID(); |
| 284 | 284 | |
| 285 | - if ( $GRP_ID ) { |
|
| 285 | + if ($GRP_ID) { |
|
| 286 | 286 | //attempt to retrieve from repo first |
| 287 | - $GRP = $this->_template_collection->get_by_ID( $GRP_ID ); |
|
| 288 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
| 289 | - return $GRP; //got it! |
|
| 287 | + $GRP = $this->_template_collection->get_by_ID($GRP_ID); |
|
| 288 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
| 289 | + return $GRP; //got it! |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | //nope don't have it yet. Get from DB then add to repo |
| 293 | - $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
| 294 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
| 295 | - $this->_template_collection->add( $GRP ); |
|
| 293 | + $GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
| 294 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
| 295 | + $this->_template_collection->add($GRP); |
|
| 296 | 296 | } |
| 297 | 297 | return $GRP; |
| 298 | 298 | } |
@@ -311,41 +311,41 @@ discard block |
||
| 311 | 311 | //in vanilla EE we're assuming there's only one event. |
| 312 | 312 | //However, if there are multiple events then we'll just use the default templates instead of different |
| 313 | 313 | // templates per event (which could create problems). |
| 314 | - if ( count( $this->_current_data_handler->events ) === 1 ) { |
|
| 315 | - foreach ( $this->_current_data_handler->events as $event ) { |
|
| 314 | + if (count($this->_current_data_handler->events) === 1) { |
|
| 315 | + foreach ($this->_current_data_handler->events as $event) { |
|
| 316 | 316 | $EVT_ID = $event['ID']; |
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | //before going any further, let's see if its in the queue |
| 321 | - $GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) ); |
|
| 321 | + $GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID)); |
|
| 322 | 322 | |
| 323 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
| 323 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
| 324 | 324 | return $GRP; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | //nope still no GRP? |
| 328 | 328 | //first we get the global template in case it has an override set. |
| 329 | - $global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa ); |
|
| 330 | - $global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) ); |
|
| 329 | + $global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa); |
|
| 330 | + $global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa)); |
|
| 331 | 331 | |
| 332 | 332 | //if this is an override, then we just return it. |
| 333 | - if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) { |
|
| 334 | - $this->_template_collection->add( $global_GRP, $EVT_ID ); |
|
| 333 | + if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) { |
|
| 334 | + $this->_template_collection->add($global_GRP, $EVT_ID); |
|
| 335 | 335 | return $global_GRP; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | //STILL here? Okay that means we want to see if there is event specific group and if there is we return it, |
| 339 | 339 | //otherwise we return the global group we retrieved. |
| 340 | - if ( $EVT_ID ) { |
|
| 340 | + if ($EVT_ID) { |
|
| 341 | 341 | $template_qa['Event.EVT_ID'] = $EVT_ID; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) ); |
|
| 344 | + $GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa)); |
|
| 345 | 345 | $GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP; |
| 346 | 346 | |
| 347 | - if ( $GRP instanceof EE_Message_Template_Group ) { |
|
| 348 | - $this->_template_collection->add( $GRP, $EVT_ID ); |
|
| 347 | + if ($GRP instanceof EE_Message_Template_Group) { |
|
| 348 | + $this->_template_collection->add($GRP, $EVT_ID); |
|
| 349 | 349 | return $GRP; |
| 350 | 350 | } |
| 351 | 351 | |
@@ -369,15 +369,15 @@ discard block |
||
| 369 | 369 | * ) |
| 370 | 370 | * ) |
| 371 | 371 | */ |
| 372 | - protected function _get_templates( EE_Message_Template_Group $mtpg ) { |
|
| 372 | + protected function _get_templates(EE_Message_Template_Group $mtpg) { |
|
| 373 | 373 | $templates = array(); |
| 374 | 374 | $context_templates = $mtpg->context_templates(); |
| 375 | - foreach ( $context_templates as $context => $template_fields ) { |
|
| 376 | - foreach ( $template_fields as $template_field => $template_obj ) { |
|
| 377 | - if ( ! $template_obj instanceof EE_Message_Template ) { |
|
| 375 | + foreach ($context_templates as $context => $template_fields) { |
|
| 376 | + foreach ($template_fields as $template_field => $template_obj) { |
|
| 377 | + if ( ! $template_obj instanceof EE_Message_Template) { |
|
| 378 | 378 | continue; |
| 379 | 379 | } |
| 380 | - $templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' ); |
|
| 380 | + $templates[$template_field][$context] = $template_obj->get('MTP_content'); |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | return $templates; |
@@ -399,21 +399,21 @@ discard block |
||
| 399 | 399 | * get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added |
| 400 | 400 | * to the queue as EEM_Message::status_failed. Very rarely should "false" be returned from this method. |
| 401 | 401 | */ |
| 402 | - protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $mtpg ) { |
|
| 402 | + protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $mtpg) { |
|
| 403 | 403 | |
| 404 | 404 | //if templates are empty then get out because we can't generate anything. |
| 405 | - if ( ! $templates ) { |
|
| 405 | + if ( ! $templates) { |
|
| 406 | 406 | return false; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | //We use this as the counter for generated messages because don't forget we may be executing this inside of a |
| 410 | 410 | //generation_queue. So _ready_queue may have generated EE_Message objects already. |
| 411 | 411 | $generated_count = 0; |
| 412 | - foreach ( $addressees as $context => $recipients ) { |
|
| 413 | - foreach ( $recipients as $recipient ) { |
|
| 414 | - $message = $this->_setup_message_object( $context, $recipient, $templates, $mtpg ); |
|
| 415 | - if ( $message instanceof EE_Message ) { |
|
| 416 | - $this->_ready_queue->add( $message, array(), $this->_generation_queue->get_queue()->is_preview(), $this->_generation_queue->get_queue()->is_test_send() ); |
|
| 412 | + foreach ($addressees as $context => $recipients) { |
|
| 413 | + foreach ($recipients as $recipient) { |
|
| 414 | + $message = $this->_setup_message_object($context, $recipient, $templates, $mtpg); |
|
| 415 | + if ($message instanceof EE_Message) { |
|
| 416 | + $this->_ready_queue->add($message, array(), $this->_generation_queue->get_queue()->is_preview(), $this->_generation_queue->get_queue()->is_test_send()); |
|
| 417 | 417 | $generated_count++; |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -434,10 +434,10 @@ discard block |
||
| 434 | 434 | * @param EE_Message_Template_Group $mtpg |
| 435 | 435 | * @return EE_Message | bool (false is used when no EE_Message is generated) |
| 436 | 436 | */ |
| 437 | - protected function _setup_message_object( $context, EE_Messages_Addressee $recipient, $templates, EE_Message_Template_Group $mtpg ) { |
|
| 437 | + protected function _setup_message_object($context, EE_Messages_Addressee $recipient, $templates, EE_Message_Template_Group $mtpg) { |
|
| 438 | 438 | //stuff we already know |
| 439 | 439 | $transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0; |
| 440 | - $transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction ? $this->_current_data_handler->txn->ID() : $transaction_id; |
|
| 440 | + $transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction ? $this->_current_data_handler->txn->ID() : $transaction_id; |
|
| 441 | 441 | $message_fields = array( |
| 442 | 442 | 'GRP_ID' => $mtpg->ID(), |
| 443 | 443 | 'TXN_ID' => $transaction_id, |
@@ -449,14 +449,14 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | //recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the |
| 451 | 451 | //info from the att_obj found in the EE_Messages_Addressee object. |
| 452 | - if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) { |
|
| 452 | + if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) { |
|
| 453 | 453 | $message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee ? $recipient->att_obj->ID() : 0; |
| 454 | 454 | $message_fields['MSG_recipient_type'] = 'Attendee'; |
| 455 | 455 | } else { |
| 456 | 456 | $message_fields['MSG_recipient_ID'] = $recipient->recipient_id; |
| 457 | 457 | $message_fields['MSG_recipient_type'] = $recipient->recipient_type; |
| 458 | 458 | } |
| 459 | - $message = EE_Message_Factory::create( $message_fields ); |
|
| 459 | + $message = EE_Message_Factory::create($message_fields); |
|
| 460 | 460 | |
| 461 | 461 | //grab valid shortcodes for shortcode parser |
| 462 | 462 | $mt_shortcodes = $this->_current_message_type->get_valid_shortcodes(); |
@@ -464,43 +464,43 @@ discard block |
||
| 464 | 464 | |
| 465 | 465 | //if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this |
| 466 | 466 | //context is turned off) EXCEPT if we're previewing |
| 467 | - if ( empty( $templates['to'][ $context ] ) |
|
| 467 | + if (empty($templates['to'][$context]) |
|
| 468 | 468 | && ! $this->_generation_queue->get_queue()->is_preview() |
| 469 | - && ! $this->_current_messenger->allow_empty_to_field() ) { |
|
| 469 | + && ! $this->_current_messenger->allow_empty_to_field()) { |
|
| 470 | 470 | //we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field. |
| 471 | 471 | return false; |
| 472 | 472 | } |
| 473 | 473 | $error_msg = array(); |
| 474 | - foreach ( $templates as $field => $ctxt ) { |
|
| 474 | + foreach ($templates as $field => $ctxt) { |
|
| 475 | 475 | $error_msg = array(); |
| 476 | 476 | //let's setup the valid shortcodes for the incoming context. |
| 477 | - $valid_shortcodes = $mt_shortcodes[ $context ]; |
|
| 477 | + $valid_shortcodes = $mt_shortcodes[$context]; |
|
| 478 | 478 | //merge in valid shortcodes for the field. |
| 479 | - $shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes; |
|
| 480 | - if ( isset( $templates[ $field ][ $context ] ) ) { |
|
| 479 | + $shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes; |
|
| 480 | + if (isset($templates[$field][$context])) { |
|
| 481 | 481 | //prefix field. |
| 482 | - $column_name = 'MSG_' . $field; |
|
| 482 | + $column_name = 'MSG_'.$field; |
|
| 483 | 483 | try { |
| 484 | 484 | $content = $this->_shortcode_parser->parse_message_template( |
| 485 | - $templates[ $field ][ $context ], |
|
| 485 | + $templates[$field][$context], |
|
| 486 | 486 | $recipient, |
| 487 | 487 | $shortcodes, |
| 488 | 488 | $this->_current_message_type, |
| 489 | 489 | $this->_current_messenger, |
| 490 | 490 | $message ); |
| 491 | - $message->set_field_or_extra_meta( $column_name, $content ); |
|
| 492 | - } catch ( EE_Error $e ) { |
|
| 493 | - $error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() ); |
|
| 494 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
| 491 | + $message->set_field_or_extra_meta($column_name, $content); |
|
| 492 | + } catch (EE_Error $e) { |
|
| 493 | + $error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage()); |
|
| 494 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
| 495 | 495 | } |
| 496 | 496 | } |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | - if ( $message->STS_ID() === EEM_Message::status_failed ) { |
|
| 500 | - $error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg ); |
|
| 501 | - $message->set_error_message( $error_msg ); |
|
| 499 | + if ($message->STS_ID() === EEM_Message::status_failed) { |
|
| 500 | + $error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg); |
|
| 501 | + $message->set_error_message($error_msg); |
|
| 502 | 502 | } else { |
| 503 | - $message->set_STS_ID( EEM_Message::status_idle ); |
|
| 503 | + $message->set_STS_ID(EEM_Message::status_idle); |
|
| 504 | 504 | } |
| 505 | 505 | return $message; |
| 506 | 506 | } |
@@ -534,14 +534,14 @@ discard block |
||
| 534 | 534 | * @param array $addressees Keys correspond to contexts for the message type and values are EE_Messages_Addressee[] |
| 535 | 535 | * @return bool |
| 536 | 536 | */ |
| 537 | - protected function _valid_addressees( $addressees ) { |
|
| 538 | - if ( ! $addressees || ! is_array( $addressees ) ) { |
|
| 537 | + protected function _valid_addressees($addressees) { |
|
| 538 | + if ( ! $addressees || ! is_array($addressees)) { |
|
| 539 | 539 | return false; |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - foreach( $addressees as $addressee_array ) { |
|
| 543 | - foreach ( $addressee_array as $addressee ) { |
|
| 544 | - if ( ! $addressee instanceof EE_Messages_Addressee ) { |
|
| 542 | + foreach ($addressees as $addressee_array) { |
|
| 543 | + foreach ($addressee_array as $addressee) { |
|
| 544 | + if ( ! $addressee instanceof EE_Messages_Addressee) { |
|
| 545 | 545 | return false; |
| 546 | 546 | } |
| 547 | 547 | } |
@@ -562,20 +562,20 @@ discard block |
||
| 562 | 562 | protected function _validate_messenger_and_message_type() { |
| 563 | 563 | |
| 564 | 564 | //first are there any existing error messages? If so then return. |
| 565 | - if ( $this->_error_msg ) { |
|
| 565 | + if ($this->_error_msg) { |
|
| 566 | 566 | return false; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - $validated_for_use = $this->_EEMSG->validate_for_use( $this->_generation_queue->get_queue()->current() ); |
|
| 569 | + $validated_for_use = $this->_EEMSG->validate_for_use($this->_generation_queue->get_queue()->current()); |
|
| 570 | 570 | |
| 571 | - if ( ! isset( $validated_for_use['messenger'] ) || ! $validated_for_use['messenger'] instanceof EE_Messenger ) { |
|
| 572 | - $this->_error_msg[] = sprintf( __( 'The %s Messenger is not active.', 'event_espresso' ), $this->_generation_queue->get_queue()->current()->messenger() ); |
|
| 571 | + if ( ! isset($validated_for_use['messenger']) || ! $validated_for_use['messenger'] instanceof EE_Messenger) { |
|
| 572 | + $this->_error_msg[] = sprintf(__('The %s Messenger is not active.', 'event_espresso'), $this->_generation_queue->get_queue()->current()->messenger()); |
|
| 573 | 573 | } else { |
| 574 | 574 | $this->_current_messenger = $validated_for_use['messenger']; |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if ( ! isset( $validated_for_use['message_type'] ) || ! $validated_for_use['message_type'] instanceof EE_message_type ) { |
|
| 578 | - $this->_error_msg[] = sprintf( __( 'The %s Message Type is not active.', 'event_espresso' ), $this->_generation_queue->get_queue()->current()->message_type() ); |
|
| 577 | + if ( ! isset($validated_for_use['message_type']) || ! $validated_for_use['message_type'] instanceof EE_message_type) { |
|
| 578 | + $this->_error_msg[] = sprintf(__('The %s Message Type is not active.', 'event_espresso'), $this->_generation_queue->get_queue()->current()->message_type()); |
|
| 579 | 579 | } else { |
| 580 | 580 | $this->_current_message_type = $validated_for_use['message_type']; |
| 581 | 581 | } |
@@ -588,10 +588,10 @@ discard block |
||
| 588 | 588 | ! $this->_generation_queue->get_queue()->is_preview() |
| 589 | 589 | && $this->_generation_queue->get_queue()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' ) |
| 590 | 590 | ) { |
| 591 | - $this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' ); |
|
| 591 | + $this->_error_msg[] = __('There is no generation data for this message. Unable to generate.'); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - return empty( $this->_error_msg ); |
|
| 594 | + return empty($this->_error_msg); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | |
@@ -608,7 +608,7 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | //First, are there any existing error messages? If so, return because if there were errors elsewhere this can't |
| 610 | 610 | //be used anyways. |
| 611 | - if ( $this->_error_msg ) { |
|
| 611 | + if ($this->_error_msg) { |
|
| 612 | 612 | return false; |
| 613 | 613 | } |
| 614 | 614 | |
@@ -616,17 +616,17 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | $data_handler_class_name = $this->_generation_queue->get_queue()->get_data_handler() |
| 618 | 618 | ? $this->_generation_queue->get_queue()->get_data_handler() |
| 619 | - : 'EE_Messages_' . $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data'; |
|
| 619 | + : 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data'; |
|
| 620 | 620 | |
| 621 | 621 | |
| 622 | 622 | |
| 623 | 623 | //If this EE_Message is for a preview, then let's switch out to the preview data handler. |
| 624 | - if ( $this->_generation_queue->get_queue()->is_preview() ) { |
|
| 625 | - $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
| 624 | + if ($this->_generation_queue->get_queue()->is_preview()) { |
|
| 625 | + $data_handler_class_name = 'EE_Messages_Preview_incoming_data'; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | //First get the class name for the data handler (and also verifies it exists. |
| 629 | - if ( ! class_exists( $data_handler_class_name ) ) { |
|
| 629 | + if ( ! class_exists($data_handler_class_name)) { |
|
| 630 | 630 | $this->_error_msg[] = sprintf( |
| 631 | 631 | __('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes. Looking for %s.', 'event_espresso'), |
| 632 | 632 | $data_handler_class_name ); |
@@ -634,12 +634,12 @@ discard block |
||
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | //convert generation_data for data_handler_instantiation. |
| 637 | - $generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data ); |
|
| 637 | + $generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data); |
|
| 638 | 638 | |
| 639 | 639 | //note, this may set error messages as well. |
| 640 | - $this->_set_data_handler( $generation_data, $data_handler_class_name ); |
|
| 640 | + $this->_set_data_handler($generation_data, $data_handler_class_name); |
|
| 641 | 641 | |
| 642 | - return empty( $this->_error_msg ); |
|
| 642 | + return empty($this->_error_msg); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | |
@@ -656,16 +656,16 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @return void. |
| 658 | 658 | */ |
| 659 | - protected function _set_data_handler( $generating_data, $data_handler_class_name ) { |
|
| 659 | + protected function _set_data_handler($generating_data, $data_handler_class_name) { |
|
| 660 | 660 | //valid classname for the data handler. Now let's setup the key for the data handler repository to see if there |
| 661 | 661 | //is already a ready data handler in the repository. |
| 662 | - $this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) ); |
|
| 663 | - if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) { |
|
| 662 | + $this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data)); |
|
| 663 | + if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) { |
|
| 664 | 664 | //no saved data_handler in the repo so let's set one up and add it to the repo. |
| 665 | 665 | try { |
| 666 | - $this->_current_data_handler = new $data_handler_class_name( $generating_data ); |
|
| 667 | - $this->_data_handler_collection->add( $this->_current_data_handler, $generating_data ); |
|
| 668 | - } catch( EE_Error $e ) { |
|
| 666 | + $this->_current_data_handler = new $data_handler_class_name($generating_data); |
|
| 667 | + $this->_data_handler_collection->add($this->_current_data_handler, $generating_data); |
|
| 668 | + } catch (EE_Error $e) { |
|
| 669 | 669 | $this->_error_msg[] = $e->get_error(); |
| 670 | 670 | } |
| 671 | 671 | } |
@@ -685,12 +685,12 @@ discard block |
||
| 685 | 685 | * @param bool $preview Indicate whether this is being used for a preview or not. |
| 686 | 686 | * @return mixed Prepped data for persisting to the queue. false is returned if unable to prep data. |
| 687 | 687 | */ |
| 688 | - protected function _prepare_data_for_queue( EE_Message_To_Generate $mtg, $preview ) { |
|
| 689 | - $data_handler = $mtg->get_data_handler_class_name( $preview ); |
|
| 690 | - if ( ! $mtg->valid() ) { |
|
| 688 | + protected function _prepare_data_for_queue(EE_Message_To_Generate $mtg, $preview) { |
|
| 689 | + $data_handler = $mtg->get_data_handler_class_name($preview); |
|
| 690 | + if ( ! $mtg->valid()) { |
|
| 691 | 691 | return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid. |
| 692 | 692 | } |
| 693 | - return $data_handler::convert_data_for_persistent_storage( $mtg->data ); |
|
| 693 | + return $data_handler::convert_data_for_persistent_storage($mtg->data); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | |
@@ -702,26 +702,26 @@ discard block |
||
| 702 | 702 | * @param EE_Message_To_Generate $mtg |
| 703 | 703 | * @param bool $test_send Whether this is just a test send or not. Typically used for previews. |
| 704 | 704 | */ |
| 705 | - public function create_and_add_message_to_queue( EE_Message_To_Generate $mtg, $test_send = false ) { |
|
| 705 | + public function create_and_add_message_to_queue(EE_Message_To_Generate $mtg, $test_send = false) { |
|
| 706 | 706 | //prep data |
| 707 | - $data = $this->_prepare_data_for_queue( $mtg, $mtg->preview ); |
|
| 707 | + $data = $this->_prepare_data_for_queue($mtg, $mtg->preview); |
|
| 708 | 708 | |
| 709 | 709 | $message = $mtg->get_EE_Message(); |
| 710 | 710 | |
| 711 | 711 | //is there a GRP_ID in the request? |
| 712 | - if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) { |
|
| 713 | - $message->set_GRP_ID( $GRP_ID ); |
|
| 712 | + if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) { |
|
| 713 | + $message->set_GRP_ID($GRP_ID); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - if ( $data === false ) { |
|
| 717 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
| 718 | - $message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) ); |
|
| 716 | + if ($data === false) { |
|
| 717 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
| 718 | + $message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso')); |
|
| 719 | 719 | } else { |
| 720 | 720 | //make sure that the data handler is cached on the message as well |
| 721 | 721 | $data['data_handler_class_name'] = $mtg->get_data_handler_class_name(); |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | - $this->_generation_queue->add( $message, $data, $mtg->preview, $test_send ); |
|
| 724 | + $this->_generation_queue->add($message, $data, $mtg->preview, $test_send); |
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @param EE_Messages $ee_msg |
| 26 | 26 | * @param EE_Messages_Queue $queue |
| 27 | 27 | */ |
| 28 | - public function __construct( $messenger, $message_type, EE_Messages $ee_msg, EE_Messages_Queue $queue ) { |
|
| 29 | - parent::__construct( $messenger, $message_type, array(), $ee_msg ); |
|
| 28 | + public function __construct($messenger, $message_type, EE_Messages $ee_msg, EE_Messages_Queue $queue) { |
|
| 29 | + parent::__construct($messenger, $message_type, array(), $ee_msg); |
|
| 30 | 30 | $this->queue = $queue; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Returns an instantiated EE_Message object from the internal data. |
| 37 | 37 | */ |
| 38 | 38 | public function get_EE_Message() { |
| 39 | - if ( ! $this->valid() ) { |
|
| 39 | + if ( ! $this->valid()) { |
|
| 40 | 40 | return null; |
| 41 | 41 | } |
| 42 | - if ( $this->_EE_Message instanceof EE_Message ) { |
|
| 42 | + if ($this->_EE_Message instanceof EE_Message) { |
|
| 43 | 43 | return $this->_EE_Message; |
| 44 | 44 | } |
| 45 | 45 | $this->_EE_Message = $this->_EE_Message instanceof EE_Message |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | protected function _get_content() { |
| 69 | 69 | $content = ''; |
| 70 | 70 | $this->queue->get_queue()->rewind(); |
| 71 | - while ( $this->queue->get_queue()->valid() ) { |
|
| 71 | + while ($this->queue->get_queue()->valid()) { |
|
| 72 | 72 | $content .= $this->queue->get_queue()->current()->content(); |
| 73 | 73 | $this->queue->get_queue()->next(); |
| 74 | 74 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param EE_Message_Type_Collection $message_types |
| 33 | 33 | */ |
| 34 | - public function __construct( EE_Message_Type_Collection $message_types ) { |
|
| 35 | - $this->set_message_type_collection( $message_types ); |
|
| 34 | + public function __construct(EE_Message_Type_Collection $message_types) { |
|
| 35 | + $this->set_message_type_collection($message_types); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @param mixed $message_types |
| 51 | 51 | */ |
| 52 | - public function set_message_type_collection( EE_Message_Type_Collection $message_types ) { |
|
| 52 | + public function set_message_type_collection(EE_Message_Type_Collection $message_types) { |
|
| 53 | 53 | $this->_message_type_collection = $message_types; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -62,26 +62,26 @@ discard block |
||
| 62 | 62 | * @param string $folder |
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | - public function load_message_types_from_folder( $folder = '' ) { |
|
| 65 | + public function load_message_types_from_folder($folder = '') { |
|
| 66 | 66 | //make sure autoloaders are set (fail-safe) |
| 67 | 67 | EED_Messages::set_autoloaders(); |
| 68 | - $folder = ! empty( $folder ) ? $folder : EE_LIBRARIES . 'messages' . DS . 'message_type'; |
|
| 69 | - $folder .= $folder[ strlen( $folder ) - 1 ] != DS ? DS : ''; |
|
| 68 | + $folder = ! empty($folder) ? $folder : EE_LIBRARIES.'messages'.DS.'message_type'; |
|
| 69 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
| 70 | 70 | // get all the files in that folder that end in ".class.php |
| 71 | 71 | $filepaths = apply_filters( |
| 72 | 72 | 'FHEE__EE_messages__get_installed__messagetype_files', |
| 73 | - glob( $folder . '*.class.php' ) |
|
| 73 | + glob($folder.'*.class.php') |
|
| 74 | 74 | ); |
| 75 | - if ( empty( $filepaths ) ) { |
|
| 75 | + if (empty($filepaths)) { |
|
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | - foreach ( (array)$filepaths as $file_path ) { |
|
| 78 | + foreach ((array) $filepaths as $file_path) { |
|
| 79 | 79 | // extract filename from path |
| 80 | - $file_path = basename( $file_path ); |
|
| 80 | + $file_path = basename($file_path); |
|
| 81 | 81 | // now remove any file extensions |
| 82 | - $message_type_class_name = substr( $file_path, 0, strpos( $file_path, '.' ) ); |
|
| 82 | + $message_type_class_name = substr($file_path, 0, strpos($file_path, '.')); |
|
| 83 | 83 | $message_type = new $message_type_class_name(); |
| 84 | - if ( $this->message_type_collection()->has_by_classname( $message_type->name ) ) { |
|
| 84 | + if ($this->message_type_collection()->has_by_classname($message_type->name)) { |
|
| 85 | 85 | continue; |
| 86 | 86 | } |
| 87 | 87 | $this->message_type_collection()->add( |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 4 | 4 | exit('NO direct script access allowed'); |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -144,23 +144,23 @@ discard block |
||
| 144 | 144 | $actives = is_array($_actives) ? array_keys($_actives) : $_actives; |
| 145 | 145 | $active_names = $this->_load_files('messenger', $actives); |
| 146 | 146 | |
| 147 | - if ( is_array($active_names) ) { |
|
| 148 | - foreach ( $active_names as $name => $class ) { |
|
| 147 | + if (is_array($active_names)) { |
|
| 148 | + foreach ($active_names as $name => $class) { |
|
| 149 | 149 | $active = new $class(); |
| 150 | - if ( ! $active instanceof EE_Messenger ) { |
|
| 150 | + if ( ! $active instanceof EE_Messenger) { |
|
| 151 | 151 | //we've got an error so let's bubble up the error_object to be caught by caller. |
| 152 | 152 | //todo: would be better to just catch the errors and then return any aggregated errors later. |
| 153 | 153 | EE_Error::add_error( |
| 154 | 154 | sprintf( |
| 155 | - __( 'The "%1$s" messenger is not installed or is invalid', 'event_espresso' ), |
|
| 155 | + __('The "%1$s" messenger is not installed or is invalid', 'event_espresso'), |
|
| 156 | 156 | $class |
| 157 | 157 | ), |
| 158 | 158 | __FILE__, __FUNCTION__, __LINE__ |
| 159 | 159 | ); |
| 160 | 160 | } |
| 161 | 161 | $this->_active_messengers[$name] = $active; |
| 162 | - $this->_active_message_types[$name] = ! empty( $_actives[$name]['settings'][$name . '-message_types'] ) |
|
| 163 | - ? $_actives[$name]['settings'][$name . '-message_types'] |
|
| 162 | + $this->_active_message_types[$name] = ! empty($_actives[$name]['settings'][$name.'-message_types']) |
|
| 163 | + ? $_actives[$name]['settings'][$name.'-message_types'] |
|
| 164 | 164 | : array(); |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | * @param string $messenger_name |
| 173 | 173 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 174 | 174 | */ |
| 175 | - public function ensure_messenger_is_active( $messenger_name ){ |
|
| 175 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 176 | 176 | //note: active messengers indexed by their names |
| 177 | 177 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
| 178 | - if( ! isset( $active_messengers[ $messenger_name ] ) ) { |
|
| 179 | - $this->activate_messenger( $messenger_name ); |
|
| 178 | + if ( ! isset($active_messengers[$messenger_name])) { |
|
| 179 | + $this->activate_messenger($messenger_name); |
|
| 180 | 180 | return FALSE; |
| 181 | - }else{ |
|
| 181 | + } else { |
|
| 182 | 182 | return TRUE; |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -194,19 +194,19 @@ discard block |
||
| 194 | 194 | * @return bool true if it got activated (or was active) and false if not. |
| 195 | 195 | * @throws \EE_Error |
| 196 | 196 | */ |
| 197 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 197 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 198 | 198 | //first validate that the incoming messenger allows this message type to be activated. |
| 199 | 199 | $messengers = $this->get_installed_messengers(); |
| 200 | - if ( ! isset( $messengers[$messenger] ) ) { |
|
| 201 | - throw new EE_Error( sprintf( __('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__ ) ); |
|
| 200 | + if ( ! isset($messengers[$messenger])) { |
|
| 201 | + throw new EE_Error(sprintf(__('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__)); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $msgr = $messengers[$messenger]; |
| 205 | 205 | $valid_message_types = $msgr instanceof EE_Messenger ? $msgr->get_valid_message_types() : array(); |
| 206 | - if ( ! in_array( $message_type, $valid_message_types ) ) { |
|
| 206 | + if ( ! in_array($message_type, $valid_message_types)) { |
|
| 207 | 207 | throw new EE_Error( |
| 208 | 208 | sprintf( |
| 209 | - __('The message type (%1$s) sent to %2$s is not valid for the %3$s messenger. Double-check the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso' ), |
|
| 209 | + __('The message type (%1$s) sent to %2$s is not valid for the %3$s messenger. Double-check the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso'), |
|
| 210 | 210 | $message_type, |
| 211 | 211 | __METHOD__, |
| 212 | 212 | $messenger |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | //all is good so let's just get it active |
| 218 | - return $this->activate_messenger( $messenger, array( $message_type ) ); |
|
| 218 | + return $this->activate_messenger($messenger, array($message_type)); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | /** |
@@ -226,40 +226,40 @@ discard block |
||
| 226 | 226 | * they are already setup.) |
| 227 | 227 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 228 | 228 | */ |
| 229 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ){ |
|
| 229 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 230 | 230 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
| 231 | 231 | $message_types = $this->get_installed_message_types(); |
| 232 | 232 | $installed_messengers = $this->get_installed_messengers(); |
| 233 | 233 | $templates = false; |
| 234 | 234 | $settings = array(); |
| 235 | 235 | //get has_active so we can be sure its kept up to date. |
| 236 | - $has_activated = get_option( 'ee_has_activated_messenger' ); |
|
| 236 | + $has_activated = get_option('ee_has_activated_messenger'); |
|
| 237 | 237 | |
| 238 | 238 | //grab the messenger to work with. |
| 239 | - $messenger = isset( $installed_messengers[$messenger_name] ) ? $installed_messengers[$messenger_name] : null; |
|
| 239 | + $messenger = isset($installed_messengers[$messenger_name]) ? $installed_messengers[$messenger_name] : null; |
|
| 240 | 240 | |
| 241 | 241 | //it's inactive. Activate it. |
| 242 | 242 | |
| 243 | - if( $messenger instanceof EE_Messenger ) { |
|
| 244 | - $active_messengers[ $messenger->name ][ 'obj' ] = $messenger; |
|
| 243 | + if ($messenger instanceof EE_Messenger) { |
|
| 244 | + $active_messengers[$messenger->name]['obj'] = $messenger; |
|
| 245 | 245 | |
| 246 | 246 | /** @var EE_Messenger[] $installed_messengers */ |
| 247 | - $mts_to_activate = ! empty( $mts_to_activate ) ? $mts_to_activate : $messenger->get_default_message_types(); |
|
| 248 | - foreach ( $mts_to_activate as $message_type ) { |
|
| 247 | + $mts_to_activate = ! empty($mts_to_activate) ? $mts_to_activate : $messenger->get_default_message_types(); |
|
| 248 | + foreach ($mts_to_activate as $message_type) { |
|
| 249 | 249 | //we need to setup any initial settings for message types |
| 250 | 250 | /** @var EE_message_type[] $installed_mts */ |
| 251 | - $settings_fields = isset( $message_types[$message_type] ) ? $message_types[ $message_type ]->get_admin_settings_fields() : array(); |
|
| 252 | - if ( !empty( $settings_fields ) ) { |
|
| 253 | - foreach ( $settings_fields as $field => $values ) { |
|
| 254 | - $settings[$field] = $values[ 'default' ]; |
|
| 251 | + $settings_fields = isset($message_types[$message_type]) ? $message_types[$message_type]->get_admin_settings_fields() : array(); |
|
| 252 | + if ( ! empty($settings_fields)) { |
|
| 253 | + foreach ($settings_fields as $field => $values) { |
|
| 254 | + $settings[$field] = $values['default']; |
|
| 255 | 255 | } |
| 256 | 256 | } else { |
| 257 | 257 | $settings = array(); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $active_messengers[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type ][ 'settings' ] = $settings; |
|
| 260 | + $active_messengers[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type]['settings'] = $settings; |
|
| 261 | 261 | |
| 262 | - if ( ! empty( $has_activated[$messenger->name] ) && ! in_array( $message_type, $has_activated[$messenger->name] ) ) { |
|
| 262 | + if ( ! empty($has_activated[$messenger->name]) && ! in_array($message_type, $has_activated[$messenger->name])) { |
|
| 263 | 263 | $has_activated[$messenger->name][] = $message_type; |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -267,22 +267,22 @@ discard block |
||
| 267 | 267 | //setup any initial settings for the messenger |
| 268 | 268 | $msgr_settings = $messenger->get_admin_settings_fields(); |
| 269 | 269 | |
| 270 | - if ( !empty( $msgr_settings ) ) { |
|
| 271 | - foreach ( $msgr_settings as $field => $value ) { |
|
| 272 | - $active_messengers[ $messenger->name ][ 'settings' ][ $field ] = $value; |
|
| 270 | + if ( ! empty($msgr_settings)) { |
|
| 271 | + foreach ($msgr_settings as $field => $value) { |
|
| 272 | + $active_messengers[$messenger->name]['settings'][$field] = $value; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - EEH_MSG_Template::update_active_messengers_in_db( $active_messengers ); |
|
| 277 | - update_option( 'ee_has_activated_messenger', $has_activated ); |
|
| 276 | + EEH_MSG_Template::update_active_messengers_in_db($active_messengers); |
|
| 277 | + update_option('ee_has_activated_messenger', $has_activated); |
|
| 278 | 278 | |
| 279 | 279 | //make sure that the cached active_messengers is set on this object |
| 280 | 280 | $this->_active_messengers[$messenger->name] = $messenger; |
| 281 | 281 | $this->_active_message_types[$messenger->name] = $active_messengers[$messenger->name]; |
| 282 | 282 | |
| 283 | 283 | //might need to generate new templates |
| 284 | - if ( ! empty( $mts_to_activate ) ) { |
|
| 285 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $mts_to_activate, 0, TRUE ); |
|
| 284 | + if ( ! empty($mts_to_activate)) { |
|
| 285 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $mts_to_activate, 0, TRUE); |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
@@ -299,8 +299,8 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | private function _load_files($kind, $actives) { |
| 301 | 301 | $active_names = array(); |
| 302 | - $base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS; |
|
| 303 | - if ( empty($actives) ) return false; |
|
| 302 | + $base_path = EE_LIBRARIES.'messages'.DS.$kind.DS; |
|
| 303 | + if (empty($actives)) return false; |
|
| 304 | 304 | |
| 305 | 305 | //make sure autoloaders are set (fail-safe) |
| 306 | 306 | EED_Messages::set_autoloaders(); |
@@ -308,12 +308,12 @@ discard block |
||
| 308 | 308 | //make sure $actives is an array |
| 309 | 309 | $actives = (array) $actives; |
| 310 | 310 | |
| 311 | - EE_Registry::instance()->load_helper( 'File' ); |
|
| 312 | - foreach ( $actives as $active ) { |
|
| 313 | - $msg_name = 'EE_' . ucwords( str_replace( ' ', '_', $active) ) . '_' . $kind; |
|
| 314 | - $filename = $msg_name . '.class.php'; |
|
| 315 | - $load_file = $base_path . DS . $filename; |
|
| 316 | - if ( is_readable($load_file) ) { |
|
| 311 | + EE_Registry::instance()->load_helper('File'); |
|
| 312 | + foreach ($actives as $active) { |
|
| 313 | + $msg_name = 'EE_'.ucwords(str_replace(' ', '_', $active)).'_'.$kind; |
|
| 314 | + $filename = $msg_name.'.class.php'; |
|
| 315 | + $load_file = $base_path.DS.$filename; |
|
| 316 | + if (is_readable($load_file)) { |
|
| 317 | 317 | require_once($load_file); |
| 318 | 318 | $active_names[$active] = $msg_name; |
| 319 | 319 | } else { |
@@ -344,25 +344,25 @@ discard block |
||
| 344 | 344 | * @param string $kind messenger or message_type? |
| 345 | 345 | * @return void |
| 346 | 346 | */ |
| 347 | - private function _unset_active( $active_name, $kind ) { |
|
| 347 | + private function _unset_active($active_name, $kind) { |
|
| 348 | 348 | //pluralize |
| 349 | 349 | $active_messengers = EEH_MSG_Template::get_active_messengers_in_db(); |
| 350 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 351 | - if ( $kind == 'messenger' ) { |
|
| 352 | - unset( $active_messengers[$active_name] ); |
|
| 353 | - EEH_MSG_Template::update_to_inactive( $active_name ); |
|
| 354 | - if ( isset( $this->_active_messengers[$active_name] ) ) { |
|
| 355 | - unset( $this->_active_messengers[$active_name] ); |
|
| 350 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 351 | + if ($kind == 'messenger') { |
|
| 352 | + unset($active_messengers[$active_name]); |
|
| 353 | + EEH_MSG_Template::update_to_inactive($active_name); |
|
| 354 | + if (isset($this->_active_messengers[$active_name])) { |
|
| 355 | + unset($this->_active_messengers[$active_name]); |
|
| 356 | 356 | } |
| 357 | 357 | } else { |
| 358 | - foreach( $active_messengers as $messenger => $settings ) { |
|
| 359 | - if ( ! empty( $settings['settings'][$messenger . '-message_types'][$active_name] ) ) { |
|
| 360 | - unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$active_name] ); |
|
| 358 | + foreach ($active_messengers as $messenger => $settings) { |
|
| 359 | + if ( ! empty($settings['settings'][$messenger.'-message_types'][$active_name])) { |
|
| 360 | + unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$active_name]); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | - EEH_MSG_Template::update_to_inactive( '', $active_name ); |
|
| 364 | - if ( isset( $this->_active_message_types[$active_name] ) ) { |
|
| 365 | - unset( $this->_active_message_types[$active_name] ); |
|
| 363 | + EEH_MSG_Template::update_to_inactive('', $active_name); |
|
| 364 | + if (isset($this->_active_message_types[$active_name])) { |
|
| 365 | + unset($this->_active_message_types[$active_name]); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
@@ -380,12 +380,12 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 382 | 382 | */ |
| 383 | - public function is_generating_messenger_and_active( EE_Messenger $messenger, EE_message_type $message_type ) { |
|
| 383 | + public function is_generating_messenger_and_active(EE_Messenger $messenger, EE_message_type $message_type) { |
|
| 384 | 384 | //get the $messengers the message type says it can be used with. |
| 385 | 385 | $used_with = $message_type->with_messengers(); |
| 386 | 386 | |
| 387 | - foreach ( $used_with as $generating_msgr => $secondary_msgrs ) { |
|
| 388 | - if ( $messenger->name == $generating_msgr && isset( $this->_active_message_types[$generating_msgr][$message_type->name] ) ) { |
|
| 387 | + foreach ($used_with as $generating_msgr => $secondary_msgrs) { |
|
| 388 | + if ($messenger->name == $generating_msgr && isset($this->_active_message_types[$generating_msgr][$message_type->name])) { |
|
| 389 | 389 | return true; |
| 390 | 390 | } |
| 391 | 391 | } |
@@ -400,8 +400,8 @@ discard block |
||
| 400 | 400 | * @param string $messenger |
| 401 | 401 | * @return EE_Messenger | null |
| 402 | 402 | */ |
| 403 | - public function get_messenger_if_active( $messenger ) { |
|
| 404 | - return ! empty( $this->_active_messengers[$messenger] ) ? $this->_active_messengers[$messenger] : null; |
|
| 403 | + public function get_messenger_if_active($messenger) { |
|
| 404 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | |
@@ -425,9 +425,9 @@ discard block |
||
| 425 | 425 | * 'message_type' => null |
| 426 | 426 | * ) |
| 427 | 427 | */ |
| 428 | - public function validate_for_use( EE_Message $message ) { |
|
| 428 | + public function validate_for_use(EE_Message $message) { |
|
| 429 | 429 | $validated_for_use['messenger'] = $this->get_messenger_if_active($message->messenger()); |
| 430 | - $validated_for_use['message_type'] = $this->get_active_message_type( $message->messenger(), $message->message_type() ); |
|
| 430 | + $validated_for_use['message_type'] = $this->get_active_message_type($message->messenger(), $message->message_type()); |
|
| 431 | 431 | return $validated_for_use; |
| 432 | 432 | } |
| 433 | 433 | |
@@ -444,35 +444,35 @@ discard block |
||
| 444 | 444 | * @param bool $send Default TRUE. If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it). |
| 445 | 445 | * @return bool |
| 446 | 446 | */ |
| 447 | - public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) { |
|
| 448 | - $processor = new EE_Messages_Processor( $this ); |
|
| 447 | + public function send_message($type, $vars, $sending_messenger = '', $generating_messenger = '', $context = '', $send = TRUE) { |
|
| 448 | + $processor = new EE_Messages_Processor($this); |
|
| 449 | 449 | $error = FALSE; |
| 450 | 450 | |
| 451 | 451 | //try to intelligently determine what method we'll call based on the incoming data. |
| 452 | 452 | //if generating and sending are different then generate and send immediately. |
| 453 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 453 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 454 | 454 | //in the legacy system, when generating and sending were different, that means all the |
| 455 | 455 | //vars are already in the request object. So let's just use that. |
| 456 | 456 | try { |
| 457 | - $mtg = new EE_Message_To_Generate_From_Request( $this, EE_Registry::instance()->REQ ); |
|
| 458 | - $processor->generate_and_send_now( $mtg ); |
|
| 459 | - } catch ( EE_Error $e ) { |
|
| 460 | - $error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' ); |
|
| 457 | + $mtg = new EE_Message_To_Generate_From_Request($this, EE_Registry::instance()->REQ); |
|
| 458 | + $processor->generate_and_send_now($mtg); |
|
| 459 | + } catch (EE_Error $e) { |
|
| 460 | + $error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso'); |
|
| 461 | 461 | // add specific message for developers if WP_DEBUG in on |
| 462 | - $error_msg .= '||' . $e->getMessage(); |
|
| 463 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 462 | + $error_msg .= '||'.$e->getMessage(); |
|
| 463 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 464 | 464 | $error = true; |
| 465 | 465 | } |
| 466 | 466 | } else { |
| 467 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 467 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 468 | 468 | //let's find out if there were any errors and how many successfully were queued. |
| 469 | - $count_errors = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_failed ); |
|
| 470 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 471 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 469 | + $count_errors = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_failed); |
|
| 470 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 471 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 472 | 472 | $count_errors = $count_errors + $count_retry; |
| 473 | - if ( $count_errors > 0 ) { |
|
| 473 | + if ($count_errors > 0) { |
|
| 474 | 474 | $error = true; |
| 475 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 475 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 476 | 476 | $message = sprintf( |
| 477 | 477 | __( |
| 478 | 478 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | $count_errors, |
| 482 | 482 | $count_queued |
| 483 | 483 | ); |
| 484 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 484 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 485 | 485 | $message = sprintf( |
| 486 | 486 | __( |
| 487 | 487 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | $count_errors, |
| 491 | 491 | $count_queued |
| 492 | 492 | ); |
| 493 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 493 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 494 | 494 | $message = sprintf( |
| 495 | 495 | __( |
| 496 | 496 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -508,9 +508,9 @@ discard block |
||
| 508 | 508 | $count_errors |
| 509 | 509 | ); |
| 510 | 510 | } |
| 511 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 511 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 512 | 512 | } else { |
| 513 | - if ( $count_queued === 1 ) { |
|
| 513 | + if ($count_queued === 1) { |
|
| 514 | 514 | $message = sprintf( |
| 515 | 515 | __( |
| 516 | 516 | '%d message successfully queued for generation.', |
@@ -527,18 +527,18 @@ discard block |
||
| 527 | 527 | $count_queued |
| 528 | 528 | ); |
| 529 | 529 | } |
| 530 | - EE_Error::add_success( $message ); |
|
| 530 | + EE_Error::add_success($message); |
|
| 531 | 531 | } |
| 532 | 532 | } |
| 533 | 533 | //if no error then return the generated message(s). |
| 534 | - if ( ! $error && ! $send ) { |
|
| 535 | - $generated_queue = $processor->generate_queue( false ); |
|
| 534 | + if ( ! $error && ! $send) { |
|
| 535 | + $generated_queue = $processor->generate_queue(false); |
|
| 536 | 536 | //get message and return. |
| 537 | 537 | $generated_queue->get_queue()->rewind(); |
| 538 | 538 | $messages = array(); |
| 539 | - while( $generated_queue->get_queue()->valid() ) { |
|
| 539 | + while ($generated_queue->get_queue()->valid()) { |
|
| 540 | 540 | $message = $generated_queue->get_queue()->current(); |
| 541 | - if ( $message instanceof EE_Message ) { |
|
| 541 | + if ($message instanceof EE_Message) { |
|
| 542 | 542 | //set properties that might be expected by add-ons (backward compat) |
| 543 | 543 | $message->content = $message->content(); |
| 544 | 544 | $message->template_pack = $message->get_template_pack(); |
@@ -565,8 +565,8 @@ discard block |
||
| 565 | 565 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 566 | 566 | * @return string The body of the message. |
| 567 | 567 | */ |
| 568 | - public function preview_message( $type, $context, $messenger, $send = FALSE ) { |
|
| 569 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 568 | + public function preview_message($type, $context, $messenger, $send = FALSE) { |
|
| 569 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | |
@@ -581,11 +581,11 @@ discard block |
||
| 581 | 581 | * |
| 582 | 582 | * @return bool success or fail. |
| 583 | 583 | */ |
| 584 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 584 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 585 | 585 | //setup for sending to new method. |
| 586 | - $queue = new EE_Messages_Queue( $this ); |
|
| 586 | + $queue = new EE_Messages_Queue($this); |
|
| 587 | 587 | //make sure we have a proper message object |
| 588 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 588 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 589 | 589 | $msg = EE_Message_Factory::create( |
| 590 | 590 | array( |
| 591 | 591 | 'MSG_messenger' => $messenger, |
@@ -598,15 +598,15 @@ discard block |
||
| 598 | 598 | $msg = $message; |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if ( ! $msg instanceof EE_Message ) { |
|
| 601 | + if ( ! $msg instanceof EE_Message) { |
|
| 602 | 602 | return false; |
| 603 | 603 | } |
| 604 | 604 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 605 | - if ( ! empty( $msg->content ) ) { |
|
| 606 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 605 | + if ( ! empty($msg->content)) { |
|
| 606 | + $msg->set('MSG_content', $msg->content); |
|
| 607 | 607 | } |
| 608 | - $queue->add( $msg ); |
|
| 609 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 608 | + $queue->add($msg); |
|
| 609 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | |
@@ -623,7 +623,7 @@ discard block |
||
| 623 | 623 | */ |
| 624 | 624 | private function _validate_setup($messenger, $message_type, $is_global = FALSE) { |
| 625 | 625 | |
| 626 | - $message_type = strtolower(str_replace(' ', '_', $message_type) ); |
|
| 626 | + $message_type = strtolower(str_replace(' ', '_', $message_type)); |
|
| 627 | 627 | $messenger = strtolower(str_replace(' ', '_', $messenger)); |
| 628 | 628 | $installed_message_types = $this->get_installed_message_types(); |
| 629 | 629 | |
@@ -639,14 +639,14 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | //do we have the necessary objects loaded? |
| 642 | - if ( empty( $this->_messenger) || empty($this->_message_type) ) |
|
| 643 | - throw new EE_Error( sprintf( __(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type ) ); |
|
| 642 | + if (empty($this->_messenger) || empty($this->_message_type)) |
|
| 643 | + throw new EE_Error(sprintf(__(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type)); |
|
| 644 | 644 | |
| 645 | 645 | //is given message_type valid for given messenger (if this is not a global save) |
| 646 | - if ( !$is_global ) { |
|
| 647 | - $has_active = EEM_Message_Template_Group::instance()->count( array( array( 'MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type ) ) ); |
|
| 646 | + if ( ! $is_global) { |
|
| 647 | + $has_active = EEM_Message_Template_Group::instance()->count(array(array('MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type))); |
|
| 648 | 648 | |
| 649 | - if ( $has_active == 0 ) { |
|
| 649 | + if ($has_active == 0) { |
|
| 650 | 650 | EE_Error::add_error( |
| 651 | 651 | sprintf( |
| 652 | 652 | __(' The %1$s message type is not registered with the %2$s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'), |
@@ -673,16 +673,16 @@ discard block |
||
| 673 | 673 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 674 | 674 | * @throws \EE_Error |
| 675 | 675 | */ |
| 676 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 676 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 677 | 677 | |
| 678 | 678 | $valid_mt = $this->_validate_setup($messenger, $message_type, $is_global); |
| 679 | 679 | |
| 680 | - if ( is_wp_error($valid_mt) && $is_global ) { |
|
| 680 | + if (is_wp_error($valid_mt) && $is_global) { |
|
| 681 | 681 | //we're setting up a brand new global templates (with messenger activation) so we're assuming that the message types sent in are valid. |
| 682 | 682 | $valid_mt = true; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | - if ( is_wp_error($valid_mt) ) { |
|
| 685 | + if (is_wp_error($valid_mt)) { |
|
| 686 | 686 | //if we've still got no valid_mt then bubble up error object |
| 687 | 687 | return $valid_mt; |
| 688 | 688 | } |
@@ -694,10 +694,10 @@ discard block |
||
| 694 | 694 | protected function _create_new_templates($GRP_ID, $is_global) { |
| 695 | 695 | |
| 696 | 696 | //if we're creating a custom template then we don't need to use the defaults class |
| 697 | - if ( ! $is_global ) |
|
| 698 | - return $this->_create_custom_template_group( $GRP_ID ); |
|
| 697 | + if ( ! $is_global) |
|
| 698 | + return $this->_create_custom_template_group($GRP_ID); |
|
| 699 | 699 | |
| 700 | - $DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID ); |
|
| 700 | + $DFLT = new EE_Message_Template_Defaults($this, $this->_messenger->name, $this->_message_type->name, $GRP_ID); |
|
| 701 | 701 | |
| 702 | 702 | //generate templates |
| 703 | 703 | $success = $DFLT->create_new_templates(); |
@@ -725,16 +725,16 @@ discard block |
||
| 725 | 725 | * ) |
| 726 | 726 | * @access private |
| 727 | 727 | */ |
| 728 | - private function _create_custom_template_group( $GRP_ID ) { |
|
| 728 | + private function _create_custom_template_group($GRP_ID) { |
|
| 729 | 729 | //defaults |
| 730 | - $success = array( 'GRP_ID' => NULL, 'MTP_context' => '' ); |
|
| 730 | + $success = array('GRP_ID' => NULL, 'MTP_context' => ''); |
|
| 731 | 731 | |
| 732 | 732 | //get the template group to use as a template from the db. If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type. |
| 733 | - $mtg = empty( $GRP_ID ) ? EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE ) ) ) : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
| 733 | + $mtg = empty($GRP_ID) ? EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE))) : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
| 734 | 734 | |
| 735 | 735 | //if we don't have a mtg at this point then we need to bail. |
| 736 | - if ( ! $mtg instanceof EE_Message_Template_Group ) { |
|
| 737 | - EE_Error::add_error( sprintf( __('Something went wrong with generating the custom template from this group id: %s. This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 736 | + if ( ! $mtg instanceof EE_Message_Template_Group) { |
|
| 737 | + EE_Error::add_error(sprintf(__('Something went wrong with generating the custom template from this group id: %s. This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID), __FILE__, __FUNCTION__, __LINE__); |
|
| 738 | 738 | return $success; |
| 739 | 739 | } |
| 740 | 740 | |
@@ -746,27 +746,27 @@ discard block |
||
| 746 | 746 | $new_mtg->set('GRP_ID', 0); |
| 747 | 747 | $new_mtg->set('MTP_is_global', FALSE); |
| 748 | 748 | |
| 749 | - $template_name = defined('DOING_AJAX') && !empty( $_POST['templateName'] ) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso'); |
|
| 750 | - $template_description = defined("DOING_AJAX") && !empty( $_POST['templateDescription'] ) ? $_POST['templateDescription'] : sprintf( __('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso' ), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular'] ); |
|
| 749 | + $template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso'); |
|
| 750 | + $template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) ? $_POST['templateDescription'] : sprintf(__('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso'), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular']); |
|
| 751 | 751 | |
| 752 | 752 | |
| 753 | - $new_mtg->set('MTP_name', $template_name ); |
|
| 754 | - $new_mtg->set('MTP_description', $template_description ); |
|
| 753 | + $new_mtg->set('MTP_name', $template_name); |
|
| 754 | + $new_mtg->set('MTP_description', $template_description); |
|
| 755 | 755 | //remove ALL relations on this template group so they don't get saved! |
| 756 | - $new_mtg->_remove_relations( 'Message_Template' ); |
|
| 756 | + $new_mtg->_remove_relations('Message_Template'); |
|
| 757 | 757 | $new_mtg->save(); |
| 758 | 758 | $success['GRP_ID'] = $new_mtg->ID(); |
| 759 | 759 | $success['template_name'] = $template_name; |
| 760 | 760 | |
| 761 | 761 | //add new message templates and add relation to. |
| 762 | - foreach ( $mtts as $mtt ) { |
|
| 763 | - if ( ! $mtt instanceof EE_Message_Template ) |
|
| 762 | + foreach ($mtts as $mtt) { |
|
| 763 | + if ( ! $mtt instanceof EE_Message_Template) |
|
| 764 | 764 | continue; |
| 765 | 765 | $nmtt = clone $mtt; |
| 766 | 766 | $nmtt->set('MTP_ID', 0); |
| 767 | - $nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation |
|
| 767 | + $nmtt->set('GRP_ID', $new_mtg->ID()); //relation |
|
| 768 | 768 | $nmtt->save(); |
| 769 | - if ( empty( $success['MTP_context'] ) ) |
|
| 769 | + if (empty($success['MTP_context'])) |
|
| 770 | 770 | $success['MTP_context'] = $nmtt->get('MTP_context'); |
| 771 | 771 | } |
| 772 | 772 | |
@@ -791,14 +791,14 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | |
| 793 | 793 | //okay now let's assemble an array with the messenger template fields added to the message_type contexts. |
| 794 | - foreach ( $this->_message_type->get_contexts() as $context => $details ) { |
|
| 795 | - foreach ( $this->_messenger->get_template_fields() as $field => $value ) { |
|
| 794 | + foreach ($this->_message_type->get_contexts() as $context => $details) { |
|
| 795 | + foreach ($this->_messenger->get_template_fields() as $field => $value) { |
|
| 796 | 796 | $template_fields[$context][$field] = $value; |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | - if ( empty($template_fields) ) { |
|
| 801 | - EE_Error::add_error( __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 800 | + if (empty($template_fields)) { |
|
| 801 | + EE_Error::add_error(__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 802 | 802 | return FALSE; |
| 803 | 803 | } |
| 804 | 804 | |
@@ -815,30 +815,30 @@ discard block |
||
| 815 | 815 | * @return array multidimensional array of messenger and message_type objects |
| 816 | 816 | * (messengers index, and message_type index); |
| 817 | 817 | */ |
| 818 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 818 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 819 | 819 | $installed = array(); |
| 820 | 820 | |
| 821 | 821 | //first let's account for caching |
| 822 | - if ( $skip_cache ) { |
|
| 823 | - $message_base = EE_LIBRARIES . "messages" . DS; |
|
| 822 | + if ($skip_cache) { |
|
| 823 | + $message_base = EE_LIBRARIES."messages".DS; |
|
| 824 | 824 | |
| 825 | - $messenger_files = $type == 'all' || $type == 'messengers' ? scandir( $message_base . "messenger", 1) : NULL; |
|
| 826 | - $messagetype_files = $type == 'all' || $type == 'message_types' ? scandir( $message_base . "message_type", 1) : NULL; |
|
| 825 | + $messenger_files = $type == 'all' || $type == 'messengers' ? scandir($message_base."messenger", 1) : NULL; |
|
| 826 | + $messagetype_files = $type == 'all' || $type == 'message_types' ? scandir($message_base."message_type", 1) : NULL; |
|
| 827 | 827 | |
| 828 | 828 | |
| 829 | 829 | //allow plugins to filter in their messenger/message_type files |
| 830 | - $messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type ); |
|
| 831 | - $messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type ); |
|
| 830 | + $messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type); |
|
| 831 | + $messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type); |
|
| 832 | 832 | |
| 833 | - $installed['messengers'] = !empty($messenger_files ) ? $this->_get_installed($messenger_files) : ''; |
|
| 834 | - $installed['message_types'] = !empty($messagetype_files) ? $this->_get_installed($messagetype_files) : ''; |
|
| 833 | + $installed['messengers'] = ! empty($messenger_files) ? $this->_get_installed($messenger_files) : ''; |
|
| 834 | + $installed['message_types'] = ! empty($messagetype_files) ? $this->_get_installed($messagetype_files) : ''; |
|
| 835 | 835 | } else { |
| 836 | 836 | $installed['messengers'] = $this->get_installed_messengers(); |
| 837 | 837 | $installed['message_types'] = $this->get_installed_message_types(); |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | |
| 841 | - if ( $type != 'all' ) { |
|
| 841 | + if ($type != 'all') { |
|
| 842 | 842 | $installed = $type == 'messengers' ? $installed['messengers'] : $installed['message_types']; |
| 843 | 843 | } |
| 844 | 844 | |
@@ -856,15 +856,15 @@ discard block |
||
| 856 | 856 | $the_goods = array(); |
| 857 | 857 | $filenames = (array) $filenames; |
| 858 | 858 | $replace = ".class.php"; |
| 859 | - foreach ( $filenames as $filename ) { |
|
| 860 | - $classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false; |
|
| 859 | + foreach ($filenames as $filename) { |
|
| 860 | + $classname = preg_match("/".$replace."/", $filename) ? str_replace($replace, "", $filename) : false; |
|
| 861 | 861 | |
| 862 | 862 | //no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE. |
| 863 | - if ( !$classname || 0 !== stripos($classname, 'EE') ) continue; |
|
| 863 | + if ( ! $classname || 0 !== stripos($classname, 'EE')) continue; |
|
| 864 | 864 | |
| 865 | 865 | //note: I'm not sure if this will work without including the file. We do have autoloaders so it "may" work. |
| 866 | 866 | $object = new $classname(); |
| 867 | - $the_goods[ $object->name ] = $object; |
|
| 867 | + $the_goods[$object->name] = $object; |
|
| 868 | 868 | } |
| 869 | 869 | return $the_goods; |
| 870 | 870 | } |
@@ -881,9 +881,9 @@ discard block |
||
| 881 | 881 | */ |
| 882 | 882 | public function get_active_message_types() { |
| 883 | 883 | $message_types = array(); |
| 884 | - foreach ( $this->_active_message_types as $messenger => $mtvalues ) { |
|
| 885 | - foreach ( $mtvalues as $mt => $config ) { |
|
| 886 | - if ( !in_array( $mt, $message_types ) ) |
|
| 884 | + foreach ($this->_active_message_types as $messenger => $mtvalues) { |
|
| 885 | + foreach ($mtvalues as $mt => $config) { |
|
| 886 | + if ( ! in_array($mt, $message_types)) |
|
| 887 | 887 | $message_types[] = $mt; |
| 888 | 888 | } |
| 889 | 889 | } |
@@ -902,8 +902,8 @@ discard block |
||
| 902 | 902 | $message_types = array(); |
| 903 | 903 | $message_type_refs = $this->get_active_message_types(); |
| 904 | 904 | $installed_message_types = $this->get_installed_message_types(); |
| 905 | - foreach ( $message_type_refs as $ref ) { |
|
| 906 | - if ( isset( $installed_message_types[$ref] ) ) { |
|
| 905 | + foreach ($message_type_refs as $ref) { |
|
| 906 | + if (isset($installed_message_types[$ref])) { |
|
| 907 | 907 | $message_types[] = $installed_message_types[$ref]; |
| 908 | 908 | } |
| 909 | 909 | } |
@@ -922,17 +922,17 @@ discard block |
||
| 922 | 922 | * |
| 923 | 923 | * @return EE_message_type[] (or empty array if none present) |
| 924 | 924 | */ |
| 925 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 925 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 926 | 926 | $messenger = (string) $messenger; |
| 927 | - if ( empty( $this->_active_message_types[$messenger] ) ) { |
|
| 927 | + if (empty($this->_active_message_types[$messenger])) { |
|
| 928 | 928 | return array(); |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | $mts = array(); |
| 932 | 932 | $message_types = $this->_active_message_types[$messenger]; |
| 933 | 933 | $installed_message_types = $this->get_installed_message_types(); |
| 934 | - foreach ( $message_types as $mt => $settings ) { |
|
| 935 | - if ( ! empty( $installed_message_types[$mt] ) ) { |
|
| 934 | + foreach ($message_types as $mt => $settings) { |
|
| 935 | + if ( ! empty($installed_message_types[$mt])) { |
|
| 936 | 936 | $mts[] = $installed_message_types[$mt]; |
| 937 | 937 | } |
| 938 | 938 | } |
@@ -949,9 +949,9 @@ discard block |
||
| 949 | 949 | * |
| 950 | 950 | * @return EE_Message_Type|null |
| 951 | 951 | */ |
| 952 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 952 | + public function get_active_message_type($messenger, $message_type) { |
|
| 953 | 953 | $installed_message_types = $this->get_installed_message_types(); |
| 954 | - if ( !empty( $this->_active_message_types[$messenger][$message_type] ) && !empty( $installed_message_types[$message_type] ) ) { |
|
| 954 | + if ( ! empty($this->_active_message_types[$messenger][$message_type]) && ! empty($installed_message_types[$message_type])) { |
|
| 955 | 955 | return $installed_message_types[$message_type]; |
| 956 | 956 | } |
| 957 | 957 | return NULL; |
@@ -960,8 +960,8 @@ discard block |
||
| 960 | 960 | |
| 961 | 961 | |
| 962 | 962 | public function get_installed_message_types() { |
| 963 | - $this->_installed_message_types = empty( $this->_installed_message_types ) |
|
| 964 | - ? $this->get_installed( 'message_types', true ) |
|
| 963 | + $this->_installed_message_types = empty($this->_installed_message_types) |
|
| 964 | + ? $this->get_installed('message_types', true) |
|
| 965 | 965 | : $this->_installed_message_types; |
| 966 | 966 | return $this->_installed_message_types; |
| 967 | 967 | } |
@@ -969,8 +969,8 @@ discard block |
||
| 969 | 969 | |
| 970 | 970 | |
| 971 | 971 | public function get_installed_messengers() { |
| 972 | - $this->_installed_messengers = empty( $this->_installed_messengers ) |
|
| 973 | - ? $this->get_installed( 'messengers', true ) |
|
| 972 | + $this->_installed_messengers = empty($this->_installed_messengers) |
|
| 973 | + ? $this->get_installed('messengers', true) |
|
| 974 | 974 | : $this->_installed_messengers; |
| 975 | 975 | return $this->_installed_messengers; |
| 976 | 976 | } |
@@ -1002,21 +1002,21 @@ discard block |
||
| 1002 | 1002 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 1003 | 1003 | * @return array |
| 1004 | 1004 | */ |
| 1005 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 1005 | + public function get_all_contexts($slugs_only = true) { |
|
| 1006 | 1006 | $key = $slugs_only ? 'slugs' : 'all'; |
| 1007 | - if ( ! empty( $this->_contexts[$key] ) ) { |
|
| 1007 | + if ( ! empty($this->_contexts[$key])) { |
|
| 1008 | 1008 | return $this->_contexts[$key]; |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | //contexts has not been setup yet. So let's get all active message type objects and loop through to get all |
| 1012 | 1012 | //unique contexts |
| 1013 | 1013 | $contexts = array(); |
| 1014 | - foreach ( $this->get_active_message_type_objects() as $mt ) { |
|
| 1015 | - if ( $mt instanceof EE_message_type ) { |
|
| 1014 | + foreach ($this->get_active_message_type_objects() as $mt) { |
|
| 1015 | + if ($mt instanceof EE_message_type) { |
|
| 1016 | 1016 | $mt_contexts = $mt->get_contexts(); |
| 1017 | - if ( $slugs_only ) { |
|
| 1018 | - foreach ( $mt_contexts as $context => $context_details ) { |
|
| 1019 | - $contexts[ $context ] = $context_details['label']; |
|
| 1017 | + if ($slugs_only) { |
|
| 1018 | + foreach ($mt_contexts as $context => $context_details) { |
|
| 1019 | + $contexts[$context] = $context_details['label']; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | } else { |
| 1022 | 1022 | $contexts[$mt->name] = $mt_contexts; |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | * @param string $data_handler_reference |
| 1038 | 1038 | * @return string |
| 1039 | 1039 | */ |
| 1040 | - public function verify_and_retrieve_class_name_for_data_handler_reference( $data_handler_reference ) { |
|
| 1040 | + public function verify_and_retrieve_class_name_for_data_handler_reference($data_handler_reference) { |
|
| 1041 | 1041 | return EE_Message_To_Generate::verify_and_retrieve_class_name_for_data_handler_reference( |
| 1042 | 1042 | $data_handler_reference |
| 1043 | 1043 | ); |