@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Venue extends EEM_CPT_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, EE_Datetime_Field::now ), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, EE_Datetime_Field::now ), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, EE_Datetime_Field::now), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, EE_Datetime_Field::now), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | 'Term_Taxonomy'=>new EE_HABTM_Relation('Term_Relationship'), |
78 | 78 | ); |
79 | 79 | //this model is generally available for reading |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
81 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
81 | + parent::__construct($timezone); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | } |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $table_name |
25 | 25 | * @return string $tableName, having ensured it has the wpdb prefix on the front |
26 | 26 | */ |
27 | - public function ensureTableNameHasPrefix( $table_name ) |
|
27 | + public function ensureTableNameHasPrefix($table_name) |
|
28 | 28 | { |
29 | 29 | global $wpdb; |
30 | - return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
30 | + return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param string $table_name |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function tableIsEmpty( $table_name ) |
|
42 | + public function tableIsEmpty($table_name) |
|
43 | 43 | { |
44 | 44 | global $wpdb; |
45 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
46 | - if ( $this->tableExists( $table_name ) ) { |
|
47 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
48 | - return absint( $count ) === 0 ? true : false; |
|
45 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
46 | + if ($this->tableExists($table_name)) { |
|
47 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
48 | + return absint($count) === 0 ? true : false; |
|
49 | 49 | } |
50 | 50 | return false; |
51 | 51 | } |
@@ -60,24 +60,24 @@ discard block |
||
60 | 60 | * @param $table_name |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function tableExists( $table_name ) |
|
63 | + public function tableExists($table_name) |
|
64 | 64 | { |
65 | 65 | global $wpdb, $EZSQL_ERROR; |
66 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
66 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
67 | 67 | //ignore if this causes an sql error |
68 | 68 | $old_error = $wpdb->last_error; |
69 | 69 | $old_suppress_errors = $wpdb->suppress_errors(); |
70 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
70 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
71 | 71 | $ezsql_error_cache = $EZSQL_ERROR; |
72 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
73 | - $wpdb->show_errors( $old_show_errors_value ); |
|
74 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
72 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
73 | + $wpdb->show_errors($old_show_errors_value); |
|
74 | + $wpdb->suppress_errors($old_suppress_errors); |
|
75 | 75 | $new_error = $wpdb->last_error; |
76 | 76 | $wpdb->last_error = $old_error; |
77 | 77 | $EZSQL_ERROR = $ezsql_error_cache; |
78 | 78 | //if there was a table doesn't exist error |
79 | - if( ! empty( $new_error ) ) { |
|
80 | - if( |
|
79 | + if ( ! empty($new_error)) { |
|
80 | + if ( |
|
81 | 81 | in_array( |
82 | 82 | \EEH_Activation::last_wpdb_error_code(), |
83 | 83 | array( |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | ) |
88 | 88 | ) |
89 | 89 | || |
90 | - preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
90 | + preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
91 | 91 | ) { |
92 | 92 | return false; |
93 | 93 | } else { |
94 | 94 | //log this because that's weird. Just use the normal PHP error log |
95 | 95 | error_log( |
96 | 96 | sprintf( |
97 | - __( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ), |
|
97 | + __('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'), |
|
98 | 98 | $new_error |
99 | 99 | ) |
100 | 100 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Base class for defining the tables that comprise models. This is used to store information |
5 | 5 | * about the table\s alias, private key, etc. |
6 | 6 | */ |
7 | -abstract class EE_Table_Base{ |
|
7 | +abstract class EE_Table_Base { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This holds the table_name without the table prefix. |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install, |
42 | 42 | * or whether each site on a multisite install has a copy of this table |
43 | 43 | */ |
44 | - function __construct($table_name, $pk_column, $global = false ){ |
|
44 | + function __construct($table_name, $pk_column, $global = false) { |
|
45 | 45 | $this->_global = $global; |
46 | 46 | $prefix = $this->get_table_prefix(); |
47 | 47 | //if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
48 | - if ( strpos( $table_name, $prefix ) === 0 ) { |
|
49 | - $table_name = ltrim( $table_name, $prefix ); |
|
48 | + if (strpos($table_name, $prefix) === 0) { |
|
49 | + $table_name = ltrim($table_name, $prefix); |
|
50 | 50 | } |
51 | 51 | $this->_table_name = $table_name; |
52 | 52 | $this->_pk_column = $pk_column; |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | public function get_table_prefix() { |
65 | 65 | global $wpdb; |
66 | 66 | |
67 | - if ( $this->_global ) { |
|
67 | + if ($this->_global) { |
|
68 | 68 | $prefix = $wpdb->base_prefix; |
69 | 69 | } else { |
70 | - $prefix = $wpdb->get_blog_prefix( EEM_Base::get_model_query_blog_id() ); |
|
70 | + $prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
71 | 71 | } |
72 | 72 | return $prefix; |
73 | 73 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param string $table_alias |
80 | 80 | */ |
81 | - function _construct_finalize_with_alias($table_alias){ |
|
81 | + function _construct_finalize_with_alias($table_alias) { |
|
82 | 82 | $this->_table_alias = $table_alias; |
83 | 83 | } |
84 | 84 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - function get_table_name(){ |
|
91 | - return $this->get_table_prefix() . $this->_table_name; |
|
90 | + function get_table_name() { |
|
91 | + return $this->get_table_prefix().$this->_table_name; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @return string |
101 | 101 | * @throws EE_Error |
102 | 102 | */ |
103 | - function get_table_alias(){ |
|
104 | - if( ! $this->_table_alias){ |
|
103 | + function get_table_alias() { |
|
104 | + if ( ! $this->_table_alias) { |
|
105 | 105 | throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
106 | 106 | } |
107 | 107 | return $this->_table_alias; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return string name of column of PK |
115 | 115 | */ |
116 | - function get_pk_column(){ |
|
116 | + function get_pk_column() { |
|
117 | 117 | return $this->_pk_column; |
118 | 118 | } |
119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * returns a string with the table alias, a period, and the private key's column. |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - function get_fully_qualified_pk_column(){ |
|
127 | - $sql = $this->get_table_alias().".".$this->get_pk_column(); |
|
126 | + function get_fully_qualified_pk_column() { |
|
127 | + $sql = $this->get_table_alias().".".$this->get_pk_column(); |
|
128 | 128 | return $sql; |
129 | 129 | } |
130 | 130 | |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | * returns the special sql for a inner select with a limit. |
134 | 134 | * @return string SQL select |
135 | 135 | */ |
136 | - public function get_select_join_limit( $limit ) { |
|
137 | - $limit = is_array( $limit ) ? 'LIMIT ' . implode(',', array_map( 'intval', $limit ) ) : 'LIMIT ' . (int) $limit; |
|
138 | - $SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
136 | + public function get_select_join_limit($limit) { |
|
137 | + $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit; |
|
138 | + $SQL = SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias; |
|
139 | 139 | return $SQL; |
140 | 140 | } |
141 | 141 |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | * constructor |
24 | 24 | * instantiated at init priority 5 |
25 | 25 | */ |
26 | - function __construct(){ |
|
26 | + function __construct() { |
|
27 | 27 | // register taxonomies |
28 | 28 | $taxonomies = self::get_taxonomies(); |
29 | - foreach ( $taxonomies as $taxonomy => $tax ) { |
|
30 | - $this->register_taxonomy( $taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args'] ); |
|
29 | + foreach ($taxonomies as $taxonomy => $tax) { |
|
30 | + $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
31 | 31 | } |
32 | 32 | // register CPTs |
33 | - $CPTs =self::get_CPTs(); |
|
34 | - foreach ( $CPTs as $CPT_name => $CPT ) { |
|
35 | - $this->register_CPT( $CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug'] ); |
|
33 | + $CPTs = self::get_CPTs(); |
|
34 | + foreach ($CPTs as $CPT_name => $CPT) { |
|
35 | + $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug']); |
|
36 | 36 | } |
37 | 37 | // setup default terms in any of our taxonomies (but only if we're in admin). |
38 | 38 | // Why not added via register_activation_hook? |
39 | 39 | // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
40 | 40 | // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
41 | - if ( is_admin() ) { |
|
41 | + if (is_admin()) { |
|
42 | 42 | $this->set_must_use_event_types(); |
43 | 43 | } |
44 | 44 | //set default terms |
45 | - $this->set_default_term( 'espresso_event_type', 'single-event', array('espresso_events') ); |
|
45 | + $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
46 | 46 | |
47 | 47 | |
48 | - add_action( 'AHEE__EE_System__initialize_last', array( __CLASS__, 'maybe_flush_rewrite_rules' ), 10 ); |
|
48 | + add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
49 | 49 | |
50 | 50 | //hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts IF they don't have a term for that taxonomy set. |
51 | - add_action('save_post', array( $this, 'save_default_term' ), 100, 2 ); |
|
51 | + add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
52 | 52 | |
53 | 53 | //remove no html restrictions from core wp saving of term descriptions. Note. this will affect only registered EE taxonomies. |
54 | 54 | $this->_allow_html_descriptions_for_ee_taxonomies(); |
55 | 55 | |
56 | - do_action( 'AHEE__EE_Register_CPTs__construct_end', $this ); |
|
56 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | public static function maybe_flush_rewrite_rules() { |
69 | - if ( get_option( 'ee_flush_rewrite_rules', TRUE )) { |
|
69 | + if (get_option('ee_flush_rewrite_rules', TRUE)) { |
|
70 | 70 | flush_rewrite_rules(); |
71 | - update_option( 'ee_flush_rewrite_rules', FALSE ); |
|
71 | + update_option('ee_flush_rewrite_rules', FALSE); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function _allow_html_descriptions_for_ee_taxonomies() { |
84 | 84 | //first remove default filter for term description but we have to do this earlier before wp sets their own filter |
85 | 85 | //because they just set a global filter on all term descriptions before the custom term description filter. Really sux. |
86 | - add_filter( 'pre_term_description', array( $this, 'ee_filter_ee_term_description_not_wp' ), 1, 2 ); |
|
86 | + add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public function ee_filter_ee_term_description_not_wp( $description, $taxonomy ) { |
|
96 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) { |
|
97 | 97 | //get a list of EE taxonomies |
98 | - $ee_taxonomies = array_keys( self::get_taxonomies() ); |
|
98 | + $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
99 | 99 | |
100 | 100 | //only do our own thing if the taxonomy listed is an ee taxonomy. |
101 | - if ( in_array( $taxonomy, $ee_taxonomies ) ) { |
|
101 | + if (in_array($taxonomy, $ee_taxonomies)) { |
|
102 | 102 | //remove default wp filter |
103 | - remove_filter( 'pre_term_description', 'wp_filter_kses' ); |
|
103 | + remove_filter('pre_term_description', 'wp_filter_kses'); |
|
104 | 104 | //sanitize THIS content. |
105 | - $description = wp_kses( $description, wp_kses_allowed_html( 'post' ) ); |
|
105 | + $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
106 | 106 | } |
107 | 107 | return $description; |
108 | 108 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @access public |
117 | 117 | * @return array |
118 | 118 | */ |
119 | - public static function get_taxonomies(){ |
|
119 | + public static function get_taxonomies() { |
|
120 | 120 | // define taxonomies |
121 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
121 | + return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
122 | 122 | 'espresso_event_categories' => array( |
123 | 123 | 'singular_name' => __("Event Category", "event_espresso"), |
124 | 124 | 'plural_name' => __("Event Categories", "event_espresso"), |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | 'delete_terms' => 'ee_delete_event_category', |
132 | 132 | 'assign_terms' => 'ee_assign_event_category' |
133 | 133 | ), |
134 | - 'rewrite' => array( 'slug' => __( 'event-category', 'event_espresso' )) |
|
134 | + 'rewrite' => array('slug' => __('event-category', 'event_espresso')) |
|
135 | 135 | )), |
136 | 136 | 'espresso_venue_categories' => array( |
137 | 137 | 'singular_name' => __("Venue Category", "event_espresso"), |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'delete_terms' => 'ee_delete_venue_category', |
146 | 146 | 'assign_terms' => 'ee_assign_venue_category' |
147 | 147 | ), |
148 | - 'rewrite' => array( 'slug' => __( 'venue-category', 'event_espresso' )) |
|
148 | + 'rewrite' => array('slug' => __('venue-category', 'event_espresso')) |
|
149 | 149 | )), |
150 | 150 | 'espresso_event_type' => array( |
151 | 151 | 'singular_name' => __("Event Type", "event_espresso"), |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | 'delete_terms' => 'ee_delete_event_type', |
160 | 160 | 'assign_terms' => 'ee_assign_event_type' |
161 | 161 | ), |
162 | - 'rewrite' => array( 'slug' => __( 'event-type', 'event_espresso' )), |
|
162 | + 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
163 | 163 | 'hierarchical'=>true |
164 | 164 | )) |
165 | - ) ); |
|
165 | + )); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -180,26 +180,26 @@ discard block |
||
180 | 180 | * @return array Empty array if no matching model names for the given slug or an array of model |
181 | 181 | * names indexed by post type slug. |
182 | 182 | */ |
183 | - public static function get_cpt_model_names( $post_type_slug = '' ) { |
|
183 | + public static function get_cpt_model_names($post_type_slug = '') { |
|
184 | 184 | $cpts = self::get_CPTs(); |
185 | 185 | |
186 | 186 | //first if slug passed in... |
187 | - if ( ! empty( $post_type_slug ) ) { |
|
187 | + if ( ! empty($post_type_slug)) { |
|
188 | 188 | //match? |
189 | - if ( ! isset( $cpts[$post_type_slug] ) || ( isset( $cpts[$post_type_slug] ) && empty( $cpts[$post_type_slug]['class_name'] ) ) ) { |
|
189 | + if ( ! isset($cpts[$post_type_slug]) || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))) { |
|
190 | 190 | return array(); |
191 | 191 | } |
192 | 192 | |
193 | 193 | //k let's get the model name for this cpt. |
194 | - return array( $post_type_slug => str_replace( 'EE', 'EEM', $cpts[$post_type_slug]['class_name'] ) ); |
|
194 | + return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
198 | 198 | //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
199 | 199 | $cpt_models = array(); |
200 | - foreach ( $cpts as $slug => $args ) { |
|
201 | - if ( ! empty( $args['class_name'] ) ) { |
|
202 | - $cpt_models[$slug] = str_replace( 'EE', 'EEM', $args['class_name'] ); |
|
200 | + foreach ($cpts as $slug => $args) { |
|
201 | + if ( ! empty($args['class_name'])) { |
|
202 | + $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
203 | 203 | } |
204 | 204 | } |
205 | 205 | return $cpt_models; |
@@ -220,12 +220,12 @@ discard block |
||
220 | 220 | * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated EEM |
221 | 221 | * models indexed by post slug. |
222 | 222 | */ |
223 | - public static function instantiate_cpt_models( $post_type_slug = '' ) { |
|
224 | - $cpt_model_names = self::get_cpt_model_names( $post_type_slug ); |
|
223 | + public static function instantiate_cpt_models($post_type_slug = '') { |
|
224 | + $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
225 | 225 | $instantiated = array(); |
226 | - foreach ( $cpt_model_names as $slug => $model_name ) { |
|
227 | - $instance = EE_Registry::instance()->load_model( str_replace( 'EEM_', '', $model_name ) ); |
|
228 | - if ( $instance instanceof EEM_CPT_Base ) { |
|
226 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
227 | + $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
228 | + if ($instance instanceof EEM_CPT_Base) { |
|
229 | 229 | $instantiated[$slug] = $instance; |
230 | 230 | } |
231 | 231 | } |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | * @access public |
243 | 243 | * @return array |
244 | 244 | */ |
245 | - public static function get_CPTs(){ |
|
245 | + public static function get_CPTs() { |
|
246 | 246 | // define CPTs |
247 | 247 | // NOTE the ['args']['page_templates'] array index is something specific to our CPTs and not part of the WP custom post type api. |
248 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
248 | + return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
249 | 249 | 'espresso_events' => array( |
250 | 250 | 'singular_name' => __("Event", "event_espresso"), |
251 | 251 | 'plural_name' => __("Events", "event_espresso"), |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'publicly_queryable'=> FALSE, |
321 | 321 | 'hierarchical'=> FALSE, |
322 | 322 | 'has_archive' => FALSE, |
323 | - 'taxonomies' => array( 'post_tag' ), |
|
323 | + 'taxonomies' => array('post_tag'), |
|
324 | 324 | 'capability_type' => 'contact', |
325 | 325 | 'capabilities' => array( |
326 | 326 | 'edit_post' => 'ee_edit_contact', |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | 'edit_private_posts' => 'ee_edit_contacts', |
338 | 338 | 'edit_published_posts' => 'ee_edit_contacts' |
339 | 339 | ), |
340 | - 'supports' => array( 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ), |
|
340 | + 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
341 | 341 | )) |
342 | - ) ); |
|
342 | + )); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | public static function get_private_CPTs() { |
353 | 353 | $CPTs = self::get_CPTs(); |
354 | 354 | $private_CPTs = array(); |
355 | - foreach ( $CPTs as $CPT => $details ) { |
|
356 | - if ( empty( $details['args']['public'] ) ) |
|
357 | - $private_CPTs[ $CPT ] = $details; |
|
355 | + foreach ($CPTs as $CPT => $details) { |
|
356 | + if (empty($details['args']['public'])) |
|
357 | + $private_CPTs[$CPT] = $details; |
|
358 | 358 | } |
359 | 359 | return $private_CPTs; |
360 | 360 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @param string $plural_name internationalized plural name |
373 | 373 | * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
374 | 374 | */ |
375 | - function register_taxonomy( $taxonomy_name, $singular_name, $plural_name, $override_args = array() ){ |
|
375 | + function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) { |
|
376 | 376 | |
377 | 377 | $args = array( |
378 | 378 | 'hierarchical' => true, |
@@ -389,15 +389,15 @@ discard block |
||
389 | 389 | //'rewrite' => array( 'slug' => 'genre' ), |
390 | 390 | ); |
391 | 391 | |
392 | - if($override_args){ |
|
393 | - if(isset($override_args['labels'])){ |
|
394 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
392 | + if ($override_args) { |
|
393 | + if (isset($override_args['labels'])) { |
|
394 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
395 | 395 | $args['labels'] = $labels; |
396 | 396 | } |
397 | - $args = array_merge($args,$override_args); |
|
397 | + $args = array_merge($args, $override_args); |
|
398 | 398 | |
399 | 399 | } |
400 | - register_taxonomy($taxonomy_name,null, $args); |
|
400 | + register_taxonomy($taxonomy_name, null, $args); |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | |
@@ -411,27 +411,27 @@ discard block |
||
411 | 411 | * The default values set in this function will be overridden by whatever you set in $override_args |
412 | 412 | * @return void, but registers the custom post type |
413 | 413 | */ |
414 | - function register_CPT($post_type, $singular_name,$plural_name,$override_args = array(), $singular_slug = '', $plural_slug = '' ) { |
|
414 | + function register_CPT($post_type, $singular_name, $plural_name, $override_args = array(), $singular_slug = '', $plural_slug = '') { |
|
415 | 415 | |
416 | 416 | $labels = array( |
417 | 417 | 'name' => $plural_name, |
418 | 418 | 'singular_name' => $singular_name, |
419 | - 'add_new' => sprintf(__("Add %s", "event_espresso"),$singular_name), |
|
420 | - 'add_new_item' => sprintf(__("Add New %s", "event_espresso"),$singular_name), |
|
421 | - 'edit_item' => sprintf(__("Edit %s", "event_espresso"),$singular_name), |
|
422 | - 'new_item' => sprintf(__("New %s", "event_espresso"),$singular_name), |
|
423 | - 'all_items' => sprintf(__("All %s", "event_espresso"),$plural_name), |
|
424 | - 'view_item' => sprintf(__("View %s", "event_espresso"),$singular_name), |
|
425 | - 'search_items' => sprintf(__("Search %s", "event_espresso"),$plural_name), |
|
426 | - 'not_found' => sprintf(__("No %s found", "event_espresso"),$plural_name), |
|
427 | - 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"),$plural_name), |
|
419 | + 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
420 | + 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
421 | + 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
422 | + 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
423 | + 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
424 | + 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
425 | + 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
426 | + 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
427 | + 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
428 | 428 | 'parent_item_colon' => '', |
429 | - 'menu_name' => sprintf(__("%s", "event_espresso"),$plural_name) |
|
429 | + 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name) |
|
430 | 430 | ); |
431 | 431 | |
432 | 432 | //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
433 | - $singular_slug = ! empty( $singular_slug ) ? $singular_slug : $singular_name; |
|
434 | - $plural_slug = ! empty( $plural_slug ) ? $plural_slug : $plural_name; |
|
433 | + $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
434 | + $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
435 | 435 | |
436 | 436 | |
437 | 437 | //note the page_templates arg in the supports index is something specific to EE. WordPress doesn't actually have that in their register_post_type api. |
@@ -444,24 +444,24 @@ discard block |
||
444 | 444 | 'show_in_menu' => false, |
445 | 445 | 'show_in_nav_menus' => false, |
446 | 446 | 'query_var' => true, |
447 | - 'rewrite' => apply_filters( 'FHEE__EE_Register_CPTs__register_CPT__rewrite', array( 'slug' => $plural_slug ), $post_type ), |
|
447 | + 'rewrite' => apply_filters('FHEE__EE_Register_CPTs__register_CPT__rewrite', array('slug' => $plural_slug), $post_type), |
|
448 | 448 | 'capability_type' => 'post', |
449 | 449 | 'map_meta_cap' => true, |
450 | 450 | 'has_archive' => true, |
451 | 451 | 'hierarchical' => true, |
452 | 452 | 'menu_position' => null, |
453 | - 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ) |
|
453 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments') |
|
454 | 454 | ); |
455 | 455 | |
456 | - if($override_args){ |
|
457 | - if(isset($override_args['labels'])){ |
|
458 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
456 | + if ($override_args) { |
|
457 | + if (isset($override_args['labels'])) { |
|
458 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
459 | 459 | } |
460 | - $args = array_merge($args,$override_args); |
|
460 | + $args = array_merge($args, $override_args); |
|
461 | 461 | $args['labels'] = $labels; |
462 | 462 | } |
463 | 463 | |
464 | - register_post_type( $post_type, $args ); |
|
464 | + register_post_type($post_type, $args); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -469,15 +469,15 @@ discard block |
||
469 | 469 | |
470 | 470 | function set_must_use_event_types() { |
471 | 471 | $term_details = array( |
472 | - 'single-event' => array( __('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days. Attendee\'s register for the first date-time only', 'event_espresso') ), //example: a party or two-day long workshop |
|
472 | + 'single-event' => array(__('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days. Attendee\'s register for the first date-time only', 'event_espresso')), //example: a party or two-day long workshop |
|
473 | 473 | |
474 | - 'multi-event' => array( __('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days. Attendee\'s can register for any of the date-times', 'event_espresso') ), //example: a three day music festival or week long conference |
|
474 | + 'multi-event' => array(__('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days. Attendee\'s can register for any of the date-times', 'event_espresso')), //example: a three day music festival or week long conference |
|
475 | 475 | |
476 | - 'event-series' => array( __('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days. Attendee\'s register for the first date-time only', 'event_espresso') ), //example: an 8 week introduction to basket weaving course |
|
476 | + 'event-series' => array(__('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days. Attendee\'s register for the first date-time only', 'event_espresso')), //example: an 8 week introduction to basket weaving course |
|
477 | 477 | |
478 | - 'recurring-event' => array( __('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days. Attendee\'s can register for any of the date-times.', 'event_espresso') ), //example: a yoga class |
|
478 | + 'recurring-event' => array(__('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days. Attendee\'s can register for any of the date-times.', 'event_espresso')), //example: a yoga class |
|
479 | 479 | |
480 | - 'ongoing' => array( __('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso') ) //example: access to a museum |
|
480 | + 'ongoing' => array(__('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso')) //example: access to a museum |
|
481 | 481 | |
482 | 482 | //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
483 | 483 | //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
486 | 486 | |
487 | 487 | ); |
488 | - $this->set_must_use_terms( 'espresso_event_type', $term_details ); |
|
488 | + $this->set_must_use_terms('espresso_event_type', $term_details); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -499,16 +499,16 @@ discard block |
||
499 | 499 | * |
500 | 500 | * @return void |
501 | 501 | */ |
502 | - function set_must_use_terms( $taxonomy, $term_details ) { |
|
502 | + function set_must_use_terms($taxonomy, $term_details) { |
|
503 | 503 | $term_details = (array) $term_details; |
504 | 504 | |
505 | - foreach ( $term_details as $slug => $details ) { |
|
506 | - if ( !term_exists( $slug, $taxonomy ) ) { |
|
505 | + foreach ($term_details as $slug => $details) { |
|
506 | + if ( ! term_exists($slug, $taxonomy)) { |
|
507 | 507 | $insert_arr = array( |
508 | 508 | 'slug' => $slug, |
509 | 509 | 'description' => $details[1] |
510 | 510 | ); |
511 | - wp_insert_term( $details[0], $taxonomy, $insert_arr ); |
|
511 | + wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | } |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | * @param string $term_slug The slug of the term that will be the default. |
523 | 523 | * @param array $cpt_slugs An array of custom post types we want the default assigned to |
524 | 524 | */ |
525 | - function set_default_term( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
526 | - $this->_default_terms[][$term_slug] = new EE_Default_Term( $taxonomy, $term_slug, $cpt_slugs ); |
|
525 | + function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
526 | + $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | |
@@ -535,20 +535,20 @@ discard block |
||
535 | 535 | * @param object $post Post object |
536 | 536 | * @return void |
537 | 537 | */ |
538 | - function save_default_term( $post_id, $post ) { |
|
539 | - if ( empty( $this->_default_terms ) ) |
|
538 | + function save_default_term($post_id, $post) { |
|
539 | + if (empty($this->_default_terms)) |
|
540 | 540 | return; //no default terms set so lets just exit. |
541 | 541 | |
542 | - foreach ( $this->_default_terms as $defaults ) { |
|
543 | - foreach ( $defaults as $default_obj ) { |
|
544 | - if ( $post->post_status == 'publish' && in_array( $post->post_type, $default_obj->cpt_slugs ) ) { |
|
542 | + foreach ($this->_default_terms as $defaults) { |
|
543 | + foreach ($defaults as $default_obj) { |
|
544 | + if ($post->post_status == 'publish' && in_array($post->post_type, $default_obj->cpt_slugs)) { |
|
545 | 545 | |
546 | 546 | //note some error proofing going on here to save unnecessary db queries |
547 | - $taxonomies = get_object_taxonomies( $post->post_type ); |
|
548 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
549 | - $terms = wp_get_post_terms( $post_id, $taxonomy); |
|
550 | - if ( empty( $terms ) && $taxonomy == $default_obj->taxonomy ) { |
|
551 | - wp_set_object_terms( $post_id, array( $default_obj->term_slug ), $taxonomy ); |
|
547 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
548 | + foreach ((array) $taxonomies as $taxonomy) { |
|
549 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
550 | + if (empty($terms) && $taxonomy == $default_obj->taxonomy) { |
|
551 | + wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
552 | 552 | } |
553 | 553 | } |
554 | 554 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @param string $term_slug The slug of the term that will be the default. |
581 | 581 | * @param array $cpt_slugs The custom post type the default term gets saved with |
582 | 582 | */ |
583 | - public function __construct( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
583 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
584 | 584 | $this->taxonomy = $taxonomy; |
585 | 585 | $this->cpt_slugs = (array) $cpt_slugs; |
586 | 586 | $this->term_slug = $term_slug; |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -160,8 +162,9 @@ discard block |
||
160 | 162 | */ |
161 | 163 | public function __construct( $routing = TRUE ) { |
162 | 164 | |
163 | - if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) |
|
164 | - $this->_is_caf = TRUE; |
|
165 | + if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false ) { |
|
166 | + $this->_is_caf = TRUE; |
|
167 | + } |
|
165 | 168 | |
166 | 169 | $this->_yes_no_values = array( |
167 | 170 | array('id' => TRUE, 'text' => __('Yes', 'event_espresso')), |
@@ -192,8 +195,9 @@ discard block |
||
192 | 195 | $this->_do_other_page_hooks(); |
193 | 196 | |
194 | 197 | //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
195 | - if ( method_exists( $this, '_before_page_setup' ) ) |
|
196 | - $this->_before_page_setup(); |
|
198 | + if ( method_exists( $this, '_before_page_setup' ) ) { |
|
199 | + $this->_before_page_setup(); |
|
200 | + } |
|
197 | 201 | |
198 | 202 | //set up page dependencies |
199 | 203 | $this->_page_setup(); |
@@ -500,7 +504,9 @@ discard block |
||
500 | 504 | global $ee_menu_slugs; |
501 | 505 | $ee_menu_slugs = (array) $ee_menu_slugs; |
502 | 506 | |
503 | - if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE; |
|
507 | + if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) { |
|
508 | + return FALSE; |
|
509 | + } |
|
504 | 510 | |
505 | 511 | |
506 | 512 | // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
@@ -535,12 +541,14 @@ discard block |
||
535 | 541 | } |
536 | 542 | |
537 | 543 | //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
538 | - if ( method_exists( $this, '_extend_page_config' ) ) |
|
539 | - $this->_extend_page_config(); |
|
544 | + if ( method_exists( $this, '_extend_page_config' ) ) { |
|
545 | + $this->_extend_page_config(); |
|
546 | + } |
|
540 | 547 | |
541 | 548 | //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
542 | - if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) |
|
543 | - $this->_extend_page_config_for_cpt(); |
|
549 | + if ( method_exists( $this, '_extend_page_config_for_cpt' ) ) { |
|
550 | + $this->_extend_page_config_for_cpt(); |
|
551 | + } |
|
544 | 552 | |
545 | 553 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
546 | 554 | $this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this ); |
@@ -656,8 +664,9 @@ discard block |
||
656 | 664 | //add screen options - global, page child class, and view specific |
657 | 665 | $this->_add_global_screen_options(); |
658 | 666 | $this->_add_screen_options(); |
659 | - if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) |
|
660 | - call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
667 | + if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) ) { |
|
668 | + call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) ); |
|
669 | + } |
|
661 | 670 | |
662 | 671 | |
663 | 672 | //add help tab(s) and tours- set via page_config and qtips. |
@@ -668,28 +677,32 @@ discard block |
||
668 | 677 | //add feature_pointers - global, page child class, and view specific |
669 | 678 | $this->_add_feature_pointers(); |
670 | 679 | $this->_add_global_feature_pointers(); |
671 | - if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) |
|
672 | - call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
680 | + if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) ) { |
|
681 | + call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) ); |
|
682 | + } |
|
673 | 683 | |
674 | 684 | //enqueue scripts/styles - global, page class, and view specific |
675 | 685 | add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 ); |
676 | 686 | add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 ); |
677 | - if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) |
|
678 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
687 | + if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) ) { |
|
688 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 ); |
|
689 | + } |
|
679 | 690 | |
680 | 691 | add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 ); |
681 | 692 | |
682 | 693 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
683 | 694 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 ); |
684 | 695 | add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 ); |
685 | - if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) |
|
686 | - add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
696 | + if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) ) { |
|
697 | + add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 ); |
|
698 | + } |
|
687 | 699 | |
688 | 700 | //admin footer scripts |
689 | 701 | add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 ); |
690 | 702 | add_action('admin_footer', array( $this, 'admin_footer'), 100 ); |
691 | - if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) |
|
692 | - add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
703 | + if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) ) { |
|
704 | + add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 ); |
|
705 | + } |
|
693 | 706 | |
694 | 707 | |
695 | 708 | do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug ); |
@@ -762,7 +775,9 @@ discard block |
||
762 | 775 | protected function _verify_routes() { |
763 | 776 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
764 | 777 | |
765 | - if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE; |
|
778 | + if ( !$this->_current_page && !defined( 'DOING_AJAX')) { |
|
779 | + return FALSE; |
|
780 | + } |
|
766 | 781 | |
767 | 782 | $this->_route = FALSE; |
768 | 783 | $func = FALSE; |
@@ -872,8 +887,9 @@ discard block |
||
872 | 887 | * @return void |
873 | 888 | */ |
874 | 889 | protected function _route_admin_request() { |
875 | - if ( ! $this->_is_UI_request ) |
|
876 | - $this->_verify_routes(); |
|
890 | + if ( ! $this->_is_UI_request ) { |
|
891 | + $this->_verify_routes(); |
|
892 | + } |
|
877 | 893 | |
878 | 894 | $nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE; |
879 | 895 | |
@@ -883,8 +899,9 @@ discard block |
||
883 | 899 | $this->_verify_nonce( $nonce, $this->_req_nonce ); |
884 | 900 | } |
885 | 901 | //set the nav_tabs array but ONLY if this is UI_request |
886 | - if ( $this->_is_UI_request ) |
|
887 | - $this->_set_nav_tabs(); |
|
902 | + if ( $this->_is_UI_request ) { |
|
903 | + $this->_set_nav_tabs(); |
|
904 | + } |
|
888 | 905 | |
889 | 906 | // grab callback function |
890 | 907 | $func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route; |
@@ -921,8 +938,9 @@ discard block |
||
921 | 938 | } |
922 | 939 | |
923 | 940 | |
924 | - if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) |
|
925 | - throw new EE_Error( $error_msg ); |
|
941 | + if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE ) { |
|
942 | + throw new EE_Error( $error_msg ); |
|
943 | + } |
|
926 | 944 | } |
927 | 945 | |
928 | 946 | //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
@@ -1049,8 +1067,9 @@ discard block |
||
1049 | 1067 | $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
1050 | 1068 | foreach ( $this->_help_tour['tours'] as $tour ) { |
1051 | 1069 | //if this is the end tour then we don't need to setup a button |
1052 | - if ( $tour instanceof EE_Help_Tour_final_stop ) |
|
1053 | - continue; |
|
1070 | + if ( $tour instanceof EE_Help_Tour_final_stop ) { |
|
1071 | + continue; |
|
1072 | + } |
|
1054 | 1073 | $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
1055 | 1074 | } |
1056 | 1075 | $tour_buttons .= implode('<br />', $tb); |
@@ -1060,8 +1079,9 @@ discard block |
||
1060 | 1079 | // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
1061 | 1080 | if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) { |
1062 | 1081 | //check that the callback given is valid |
1063 | - if ( !method_exists($this, $config['help_sidebar'] ) ) |
|
1064 | - throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1082 | + if ( !method_exists($this, $config['help_sidebar'] ) ) { |
|
1083 | + throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) ); |
|
1084 | + } |
|
1065 | 1085 | |
1066 | 1086 | $content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) ); |
1067 | 1087 | |
@@ -1085,18 +1105,23 @@ discard block |
||
1085 | 1105 | }/**/ |
1086 | 1106 | |
1087 | 1107 | |
1088 | - if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route |
|
1108 | + if ( !isset( $config['help_tabs'] ) ) { |
|
1109 | + return; |
|
1110 | + } |
|
1111 | + //no help tabs for this route |
|
1089 | 1112 | |
1090 | 1113 | foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) { |
1091 | 1114 | //we're here so there ARE help tabs! |
1092 | 1115 | |
1093 | 1116 | //make sure we've got what we need |
1094 | - if ( !isset( $cfg['title'] ) ) |
|
1095 | - throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1117 | + if ( !isset( $cfg['title'] ) ) { |
|
1118 | + throw new EE_Error( __('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso') ); |
|
1119 | + } |
|
1096 | 1120 | |
1097 | 1121 | |
1098 | - if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) |
|
1099 | - throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1122 | + if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) ) { |
|
1123 | + throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') ); |
|
1124 | + } |
|
1100 | 1125 | |
1101 | 1126 | |
1102 | 1127 | |
@@ -1159,14 +1184,16 @@ discard block |
||
1159 | 1184 | $this->_help_tour = array(); |
1160 | 1185 | |
1161 | 1186 | //exit early if help tours are turned off globally |
1162 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) |
|
1163 | - return; |
|
1187 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) ) { |
|
1188 | + return; |
|
1189 | + } |
|
1164 | 1190 | |
1165 | 1191 | //loop through _page_config to find any help_tour defined |
1166 | 1192 | foreach ( $this->_page_config as $route => $config ) { |
1167 | 1193 | //we're only going to set things up for this route |
1168 | - if ( $route !== $this->_req_action ) |
|
1169 | - continue; |
|
1194 | + if ( $route !== $this->_req_action ) { |
|
1195 | + continue; |
|
1196 | + } |
|
1170 | 1197 | |
1171 | 1198 | if ( isset( $config['help_tour'] ) ) { |
1172 | 1199 | |
@@ -1201,8 +1228,9 @@ discard block |
||
1201 | 1228 | } |
1202 | 1229 | } |
1203 | 1230 | |
1204 | - if ( !empty( $tours ) ) |
|
1205 | - $this->_help_tour['tours'] = $tours; |
|
1231 | + if ( !empty( $tours ) ) { |
|
1232 | + $this->_help_tour['tours'] = $tours; |
|
1233 | + } |
|
1206 | 1234 | |
1207 | 1235 | //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
1208 | 1236 | } |
@@ -1242,15 +1270,21 @@ discard block |
||
1242 | 1270 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
1243 | 1271 | $i = 0; |
1244 | 1272 | foreach ( $this->_page_config as $slug => $config ) { |
1245 | - if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) |
|
1246 | - continue; //no nav tab for this config |
|
1273 | + if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) ) { |
|
1274 | + continue; |
|
1275 | + } |
|
1276 | + //no nav tab for this config |
|
1247 | 1277 | |
1248 | 1278 | //check for persistent flag |
1249 | - if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) |
|
1250 | - continue; //nav tab is only to appear when route requested. |
|
1279 | + if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action ) { |
|
1280 | + continue; |
|
1281 | + } |
|
1282 | + //nav tab is only to appear when route requested. |
|
1251 | 1283 | |
1252 | - if ( ! $this->check_user_access( $slug, TRUE ) ) |
|
1253 | - continue; //no nav tab becasue current user does not have access. |
|
1284 | + if ( ! $this->check_user_access( $slug, TRUE ) ) { |
|
1285 | + continue; |
|
1286 | + } |
|
1287 | + //no nav tab becasue current user does not have access. |
|
1254 | 1288 | |
1255 | 1289 | $css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : ''; |
1256 | 1290 | $this->_nav_tabs[$slug] = array( |
@@ -1486,10 +1520,11 @@ discard block |
||
1486 | 1520 | $content .= EEH_Template::display_template( $template_path, $template_args, TRUE ); |
1487 | 1521 | } |
1488 | 1522 | |
1489 | - if ( $display ) |
|
1490 | - echo $content; |
|
1491 | - else |
|
1492 | - return $content; |
|
1523 | + if ( $display ) { |
|
1524 | + echo $content; |
|
1525 | + } else { |
|
1526 | + return $content; |
|
1527 | + } |
|
1493 | 1528 | } |
1494 | 1529 | |
1495 | 1530 | |
@@ -1506,8 +1541,9 @@ discard block |
||
1506 | 1541 | $method_name = '_help_popup_content_' . $this->_req_action; |
1507 | 1542 | |
1508 | 1543 | //if method doesn't exist let's get out. |
1509 | - if ( !method_exists( $this, $method_name ) ) |
|
1510 | - return array(); |
|
1544 | + if ( !method_exists( $this, $method_name ) ) { |
|
1545 | + return array(); |
|
1546 | + } |
|
1511 | 1547 | |
1512 | 1548 | //k we're good to go let's retrieve the help array |
1513 | 1549 | $help_array = call_user_func( array( $this, $method_name ) ); |
@@ -1538,7 +1574,9 @@ discard block |
||
1538 | 1574 | */ |
1539 | 1575 | protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) { |
1540 | 1576 | |
1541 | - if ( defined('DOING_AJAX') ) return; |
|
1577 | + if ( defined('DOING_AJAX') ) { |
|
1578 | + return; |
|
1579 | + } |
|
1542 | 1580 | |
1543 | 1581 | //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
1544 | 1582 | $help_array = $this->_get_help_content(); |
@@ -1556,10 +1594,11 @@ discard block |
||
1556 | 1594 | $content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
1557 | 1595 | $content = $content . $help_content; |
1558 | 1596 | |
1559 | - if ( $display ) |
|
1560 | - echo $content; |
|
1561 | - else |
|
1562 | - return $content; |
|
1597 | + if ( $display ) { |
|
1598 | + echo $content; |
|
1599 | + } else { |
|
1600 | + return $content; |
|
1601 | + } |
|
1563 | 1602 | } |
1564 | 1603 | |
1565 | 1604 | |
@@ -1785,8 +1824,10 @@ discard block |
||
1785 | 1824 | protected function _set_list_table() { |
1786 | 1825 | |
1787 | 1826 | //first is this a list_table view? |
1788 | - if ( !isset($this->_route_config['list_table']) ) |
|
1789 | - return; //not a list_table view so get out. |
|
1827 | + if ( !isset($this->_route_config['list_table']) ) { |
|
1828 | + return; |
|
1829 | + } |
|
1830 | + //not a list_table view so get out. |
|
1790 | 1831 | |
1791 | 1832 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
1792 | 1833 | |
@@ -2148,8 +2189,9 @@ discard block |
||
2148 | 2189 | protected function _espresso_sponsors_post_box() { |
2149 | 2190 | |
2150 | 2191 | $show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE ); |
2151 | - if ( $show_sponsors ) |
|
2152 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2192 | + if ( $show_sponsors ) { |
|
2193 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2194 | + } |
|
2153 | 2195 | } |
2154 | 2196 | |
2155 | 2197 | |
@@ -2446,8 +2488,9 @@ discard block |
||
2446 | 2488 | |
2447 | 2489 | $template_path = $sidebar ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
2448 | 2490 | |
2449 | - if ( defined('DOING_AJAX' ) ) |
|
2450 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2491 | + if ( defined('DOING_AJAX' ) ) { |
|
2492 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2493 | + } |
|
2451 | 2494 | |
2452 | 2495 | $template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
2453 | 2496 | |
@@ -2589,10 +2632,11 @@ discard block |
||
2589 | 2632 | true |
2590 | 2633 | ); |
2591 | 2634 | // the final template wrapper |
2592 | - if ( $sidebar ) |
|
2593 | - $this->display_admin_page_with_sidebar(); |
|
2594 | - else |
|
2595 | - $this->display_admin_page_with_no_sidebar(); |
|
2635 | + if ( $sidebar ) { |
|
2636 | + $this->display_admin_page_with_sidebar(); |
|
2637 | + } else { |
|
2638 | + $this->display_admin_page_with_no_sidebar(); |
|
2639 | + } |
|
2596 | 2640 | } |
2597 | 2641 | |
2598 | 2642 | |
@@ -2660,8 +2704,9 @@ discard block |
||
2660 | 2704 | |
2661 | 2705 | |
2662 | 2706 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
2663 | - if ( NULL === error_get_last() || ! headers_sent() ) |
|
2664 | - header('Content-Type: application/json; charset=UTF-8'); |
|
2707 | + if ( NULL === error_get_last() || ! headers_sent() ) { |
|
2708 | + header('Content-Type: application/json; charset=UTF-8'); |
|
2709 | + } |
|
2665 | 2710 | if( function_exists( 'wp_json_encode' ) ) { |
2666 | 2711 | echo wp_json_encode( $json ); |
2667 | 2712 | } else { |
@@ -2679,10 +2724,9 @@ discard block |
||
2679 | 2724 | * @throws EE_Error |
2680 | 2725 | */ |
2681 | 2726 | public function return_json() { |
2682 | - if ( defined('DOING_AJAX') && DOING_AJAX ) |
|
2683 | - $this->_return_json(); |
|
2684 | - |
|
2685 | - else { |
|
2727 | + if ( defined('DOING_AJAX') && DOING_AJAX ) { |
|
2728 | + $this->_return_json(); |
|
2729 | + } else { |
|
2686 | 2730 | throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) ); |
2687 | 2731 | } |
2688 | 2732 | } |
@@ -2824,7 +2868,9 @@ discard block |
||
2824 | 2868 | $id = $this->_current_view . '_' . $ref; |
2825 | 2869 | $name = !empty($actions) ? $actions[$key] : $ref; |
2826 | 2870 | $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
2827 | - if ( !$both ) break; |
|
2871 | + if ( !$both ) { |
|
2872 | + break; |
|
2873 | + } |
|
2828 | 2874 | } |
2829 | 2875 | |
2830 | 2876 | } |
@@ -3180,13 +3226,15 @@ discard block |
||
3180 | 3226 | if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) { |
3181 | 3227 | check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); |
3182 | 3228 | |
3183 | - if ( !$user = wp_get_current_user() ) |
|
3184 | - return; |
|
3229 | + if ( !$user = wp_get_current_user() ) { |
|
3230 | + return; |
|
3231 | + } |
|
3185 | 3232 | $option = $_POST['wp_screen_options']['option']; |
3186 | 3233 | $value = $_POST['wp_screen_options']['value']; |
3187 | 3234 | |
3188 | - if ( $option != sanitize_key( $option ) ) |
|
3189 | - return; |
|
3235 | + if ( $option != sanitize_key( $option ) ) { |
|
3236 | + return; |
|
3237 | + } |
|
3190 | 3238 | |
3191 | 3239 | $map_option = $option; |
3192 | 3240 | |
@@ -3195,13 +3243,15 @@ discard block |
||
3195 | 3243 | switch ( $map_option ) { |
3196 | 3244 | case $this->_current_page . '_' . $this->_current_view . '_per_page': |
3197 | 3245 | $value = (int) $value; |
3198 | - if ( $value < 1 || $value > 999 ) |
|
3199 | - return; |
|
3246 | + if ( $value < 1 || $value > 999 ) { |
|
3247 | + return; |
|
3248 | + } |
|
3200 | 3249 | break; |
3201 | 3250 | default: |
3202 | 3251 | $value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value ); |
3203 | - if ( false === $value ) |
|
3204 | - return; |
|
3252 | + if ( false === $value ) { |
|
3253 | + return; |
|
3254 | + } |
|
3205 | 3255 | break; |
3206 | 3256 | } |
3207 | 3257 | |
@@ -3237,8 +3287,9 @@ discard block |
||
3237 | 3287 | protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) { |
3238 | 3288 | $user_id = get_current_user_id(); |
3239 | 3289 | |
3240 | - if ( !$skip_route_verify ) |
|
3241 | - $this->_verify_route($route); |
|
3290 | + if ( !$skip_route_verify ) { |
|
3291 | + $this->_verify_route($route); |
|
3292 | + } |
|
3242 | 3293 | |
3243 | 3294 | |
3244 | 3295 | //now let's set the string for what kind of transient we're setting |
@@ -1,16 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * Template for the ticket selector when displayed in an iframe. |
4 | - |
|
5 | 4 | * Following template arguments are available: |
6 | - |
|
7 | 5 | * @type string $notices HTML for notices and ajax gif |
8 | 6 | * @type string $ticket_selector This is the html for the ticket selector. |
9 | 7 | * @type string $powered_by credit link |
10 | 8 | * @type array $css An array of css urls. |
11 | 9 | * @type string $eei18n localized JSON vars |
12 | 10 | * @type array $js An array of js urls. |
13 | - |
|
14 | 11 | * @since 4.6.7 |
15 | 12 | * @package Event Espresso |
16 | 13 | * @subpackage module |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | |
107 | 107 | /** |
108 | 108 | * grab url requests and route them |
109 | - * @access private |
|
110 | - * @return void |
|
111 | - */ |
|
109 | + * @access private |
|
110 | + * @return void |
|
111 | + */ |
|
112 | 112 | public function _set_page_routes() { |
113 | 113 | |
114 | 114 | $this->_set_transaction_status_array(); |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | /** |
264 | 264 | * _set_transaction_status_array |
265 | 265 | * sets list of transaction statuses |
266 | - * |
|
266 | + * |
|
267 | 267 | * @access private |
268 | - * @return void |
|
269 | - */ |
|
268 | + * @return void |
|
269 | + */ |
|
270 | 270 | private function _set_transaction_status_array() { |
271 | 271 | self::$_txn_status = EEM_Transaction::instance()->status_array(TRUE); |
272 | 272 | } |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | |
289 | 289 | /** |
290 | 290 | * get list of payment statuses |
291 | - * |
|
291 | + * |
|
292 | 292 | * @access private |
293 | - * @return void |
|
294 | - */ |
|
293 | + * @return void |
|
294 | + */ |
|
295 | 295 | private function _get_payment_status_array() { |
296 | 296 | self::$_pay_status = EEM_Payment::instance()->status_array(TRUE); |
297 | 297 | $this->_template_args['payment_status'] = self::$_pay_status; |
@@ -399,19 +399,19 @@ discard block |
||
399 | 399 | if ( is_object( $this->_transaction) ) |
400 | 400 | return; //get out we've already set the object |
401 | 401 | |
402 | - $TXN = EEM_Transaction::instance(); |
|
402 | + $TXN = EEM_Transaction::instance(); |
|
403 | 403 | |
404 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
404 | + $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
405 | 405 | |
406 | - //get transaction object |
|
407 | - $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
408 | - $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
406 | + //get transaction object |
|
407 | + $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
|
408 | + $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
409 | 409 | $this->_transaction->verify_abandoned_transaction_status(); |
410 | 410 | |
411 | 411 | if ( empty( $this->_transaction ) ) { |
412 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
412 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
413 | 413 | EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
414 | - } |
|
414 | + } |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | |
@@ -526,12 +526,12 @@ discard block |
||
526 | 526 | |
527 | 527 | |
528 | 528 | /** |
529 | - * _transaction_details |
|
529 | + * _transaction_details |
|
530 | 530 | * generates HTML for the View Transaction Details Admin page |
531 | - * |
|
531 | + * |
|
532 | 532 | * @access protected |
533 | - * @return void |
|
534 | - */ |
|
533 | + * @return void |
|
534 | + */ |
|
535 | 535 | protected function _transaction_details() { |
536 | 536 | do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction ); |
537 | 537 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | 'button secondary-button right', |
583 | 583 | 'dashicons dashicons-email-alt' |
584 | 584 | ) |
585 | - : ''; |
|
585 | + : ''; |
|
586 | 586 | } else { |
587 | 587 | $this->_template_args['send_payment_reminder_button'] = ''; |
588 | 588 | } |
@@ -736,10 +736,10 @@ discard block |
||
736 | 736 | /** |
737 | 737 | * txn_details_meta_box |
738 | 738 | * generates HTML for the Transaction main meta box |
739 | - * |
|
739 | + * |
|
740 | 740 | * @access public |
741 | - * @return void |
|
742 | - */ |
|
741 | + * @return void |
|
742 | + */ |
|
743 | 743 | public function txn_details_meta_box() { |
744 | 744 | |
745 | 745 | $this->_set_transaction_object(); |
@@ -1115,10 +1115,10 @@ discard block |
||
1115 | 1115 | /** |
1116 | 1116 | * txn_billing_info_side_meta_box |
1117 | 1117 | * generates HTML for the Edit Transaction side meta box |
1118 | - * |
|
1118 | + * |
|
1119 | 1119 | * @access public |
1120 | - * @return void |
|
1121 | - */ |
|
1120 | + * @return void |
|
1121 | + */ |
|
1122 | 1122 | public function txn_billing_info_side_meta_box() { |
1123 | 1123 | |
1124 | 1124 | $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
@@ -1136,10 +1136,10 @@ discard block |
||
1136 | 1136 | /** |
1137 | 1137 | * apply_payments_or_refunds |
1138 | 1138 | * registers a payment or refund made towards a transaction |
1139 | - * |
|
1139 | + * |
|
1140 | 1140 | * @access public |
1141 | - * @return void |
|
1142 | - */ |
|
1141 | + * @return void |
|
1142 | + */ |
|
1143 | 1143 | public function apply_payments_or_refunds() { |
1144 | 1144 | $json_response_data = array( 'return_data' => FALSE ); |
1145 | 1145 | $valid_data = $this->_validate_payment_request_data(); |
@@ -1293,9 +1293,9 @@ discard block |
||
1293 | 1293 | 'default' => '', |
1294 | 1294 | 'required' => false, |
1295 | 1295 | 'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ), |
1296 | - 'validation_strategies' => array( |
|
1297 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1298 | - ) |
|
1296 | + 'validation_strategies' => array( |
|
1297 | + new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1298 | + ) |
|
1299 | 1299 | ) |
1300 | 1300 | ), |
1301 | 1301 | 'po_number' => new EE_Text_Input( |
@@ -1303,9 +1303,9 @@ discard block |
||
1303 | 1303 | 'default' => '', |
1304 | 1304 | 'required' => false, |
1305 | 1305 | 'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ), |
1306 | - 'validation_strategies' => array( |
|
1307 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1308 | - ) |
|
1306 | + 'validation_strategies' => array( |
|
1307 | + new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1308 | + ) |
|
1309 | 1309 | ) |
1310 | 1310 | ), |
1311 | 1311 | 'accounting' => new EE_Text_Input( |
@@ -1313,9 +1313,9 @@ discard block |
||
1313 | 1313 | 'default' => '', |
1314 | 1314 | 'required' => false, |
1315 | 1315 | 'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ), |
1316 | - 'validation_strategies' => array( |
|
1317 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1318 | - ) |
|
1316 | + 'validation_strategies' => array( |
|
1317 | + new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1318 | + ) |
|
1319 | 1319 | ) |
1320 | 1320 | ), |
1321 | 1321 | ) |
@@ -1610,10 +1610,10 @@ discard block |
||
1610 | 1610 | /** |
1611 | 1611 | * delete_payment |
1612 | 1612 | * delete a payment or refund made towards a transaction |
1613 | - * |
|
1613 | + * |
|
1614 | 1614 | * @access public |
1615 | - * @return void |
|
1616 | - */ |
|
1615 | + * @return void |
|
1616 | + */ |
|
1617 | 1617 | public function delete_payment() { |
1618 | 1618 | $json_response_data = array( 'return_data' => FALSE ); |
1619 | 1619 | $PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0; |
@@ -1730,12 +1730,12 @@ discard block |
||
1730 | 1730 | /** |
1731 | 1731 | * _send_payment_reminder |
1732 | 1732 | * generates HTML for the View Transaction Details Admin page |
1733 | - * |
|
1733 | + * |
|
1734 | 1734 | * @access protected |
1735 | - * @return void |
|
1736 | - */ |
|
1735 | + * @return void |
|
1736 | + */ |
|
1737 | 1737 | protected function _send_payment_reminder() { |
1738 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
1738 | + $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
1739 | 1739 | $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
1740 | 1740 | $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array(); |
1741 | 1741 | do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction ); |
@@ -1757,29 +1757,29 @@ discard block |
||
1757 | 1757 | |
1758 | 1758 | $TXN = EEM_Transaction::instance(); |
1759 | 1759 | |
1760 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
1761 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
1760 | + $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
1761 | + $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
1762 | 1762 | |
1763 | - //make sure our timestamps start and end right at the boundaries for each day |
|
1764 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
1765 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
1763 | + //make sure our timestamps start and end right at the boundaries for each day |
|
1764 | + $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
1765 | + $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
1766 | 1766 | |
1767 | 1767 | |
1768 | - //convert to timestamps |
|
1769 | - $start_date = strtotime( $start_date ); |
|
1770 | - $end_date = strtotime( $end_date ); |
|
1768 | + //convert to timestamps |
|
1769 | + $start_date = strtotime( $start_date ); |
|
1770 | + $end_date = strtotime( $end_date ); |
|
1771 | 1771 | |
1772 | - //makes sure start date is the lowest value and vice versa |
|
1773 | - $start_date = min( $start_date, $end_date ); |
|
1774 | - $end_date = max( $start_date, $end_date ); |
|
1772 | + //makes sure start date is the lowest value and vice versa |
|
1773 | + $start_date = min( $start_date, $end_date ); |
|
1774 | + $end_date = max( $start_date, $end_date ); |
|
1775 | 1775 | |
1776 | - //convert to correct format for query |
|
1776 | + //convert to correct format for query |
|
1777 | 1777 | $start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
1778 | 1778 | $end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
1779 | 1779 | |
1780 | 1780 | |
1781 | 1781 | |
1782 | - //set orderby |
|
1782 | + //set orderby |
|
1783 | 1783 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
1784 | 1784 | |
1785 | 1785 | switch ( $this->_req_data['orderby'] ) { |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Transactions_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | protected function _ajax_hooks() { |
83 | - add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds')); |
|
84 | - add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds')); |
|
85 | - add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment')); |
|
83 | + add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds')); |
|
84 | + add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds')); |
|
85 | + add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | 'buttons' => array( |
98 | 98 | 'add' => esc_html__('Add New Transaction', 'event_espresso'), |
99 | 99 | 'edit' => esc_html__('Edit Transaction', 'event_espresso'), |
100 | - 'delete' => esc_html__('Delete Transaction','event_espresso'), |
|
100 | + 'delete' => esc_html__('Delete Transaction', 'event_espresso'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $this->_set_transaction_status_array(); |
115 | 115 | |
116 | - $txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0; |
|
116 | + $txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0; |
|
117 | 117 | |
118 | 118 | $this->_page_routes = array( |
119 | 119 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | 'filename' => 'transactions_overview_views_filters_search' |
186 | 186 | ), |
187 | 187 | ), |
188 | - 'help_tour' => array( 'Transactions_Overview_Help_Tour' ), |
|
188 | + 'help_tour' => array('Transactions_Overview_Help_Tour'), |
|
189 | 189 | /** |
190 | 190 | * commented out because currently we are not displaying tips for transaction list table status but this |
191 | 191 | * may change in a later iteration so want to keep the code for then. |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | 'nav' => array( |
198 | 198 | 'label' => esc_html__('View Transaction', 'event_espresso'), |
199 | 199 | 'order' => 5, |
200 | - 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
|
200 | + 'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url, |
|
201 | 201 | 'persistent' => FALSE |
202 | 202 | ), |
203 | 203 | 'help_tabs' => array( |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | 'filename' => 'transactions_view_transaction_primary_registrant_billing_information' |
219 | 219 | ), |
220 | 220 | ), |
221 | - 'qtips' => array( 'Transaction_Details_Tips' ), |
|
222 | - 'help_tour' => array( 'Transaction_Details_Help_Tour' ), |
|
221 | + 'qtips' => array('Transaction_Details_Tips'), |
|
222 | + 'help_tour' => array('Transaction_Details_Help_Tour'), |
|
223 | 223 | 'metaboxes' => array('_transaction_details_metaboxes'), |
224 | 224 | |
225 | 225 | 'require_nonce' => FALSE |
@@ -237,23 +237,23 @@ discard block |
||
237 | 237 | // IF a registration was JUST added via the admin... |
238 | 238 | if ( |
239 | 239 | isset( |
240 | - $this->_req_data[ 'redirect_from' ], |
|
241 | - $this->_req_data[ 'EVT_ID' ], |
|
242 | - $this->_req_data[ 'event_name' ] |
|
240 | + $this->_req_data['redirect_from'], |
|
241 | + $this->_req_data['EVT_ID'], |
|
242 | + $this->_req_data['event_name'] |
|
243 | 243 | ) |
244 | 244 | ) { |
245 | 245 | // then set a cookie so that we can block any attempts to use |
246 | 246 | // the back button as a way to enter another registration. |
247 | - setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' ); |
|
247 | + setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/'); |
|
248 | 248 | // and update the global |
249 | - $_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ]; |
|
249 | + $_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID']; |
|
250 | 250 | } |
251 | - EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = esc_html__( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' ); |
|
252 | - EE_Registry::$i18n_js_strings[ 'error_occurred' ] = esc_html__( 'An error occurred! Please refresh the page and try again.', 'event_espresso' ); |
|
253 | - EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status; |
|
254 | - EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status; |
|
255 | - EE_Registry::$i18n_js_strings[ 'payments_total' ] = esc_html__( 'Payments Total', 'event_espresso' ); |
|
256 | - EE_Registry::$i18n_js_strings[ 'transaction_overpaid' ] = esc_html__( 'This transaction has been overpaid ! Payments Total', 'event_espresso' ); |
|
251 | + EE_Registry::$i18n_js_strings['invalid_server_response'] = esc_html__('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso'); |
|
252 | + EE_Registry::$i18n_js_strings['error_occurred'] = esc_html__('An error occurred! Please refresh the page and try again.', 'event_espresso'); |
|
253 | + EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status; |
|
254 | + EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status; |
|
255 | + EE_Registry::$i18n_js_strings['payments_total'] = esc_html__('Payments Total', 'event_espresso'); |
|
256 | + EE_Registry::$i18n_js_strings['transaction_overpaid'] = esc_html__('This transaction has been overpaid ! Payments Total', 'event_espresso'); |
|
257 | 257 | } |
258 | 258 | public function admin_notices() {} |
259 | 259 | public function admin_footer_scripts() {} |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function load_scripts_styles() { |
322 | 322 | //enqueue style |
323 | - wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
323 | + wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
324 | 324 | wp_enqueue_style('espresso_txn'); |
325 | 325 | |
326 | 326 | //scripts |
327 | 327 | add_filter('FHEE_load_accounting_js', '__return_true'); |
328 | 328 | |
329 | 329 | //scripts |
330 | - wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
330 | + wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE); |
|
331 | 331 | wp_enqueue_script('espresso_txn'); |
332 | 332 | |
333 | 333 | } |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @return void |
368 | 368 | */ |
369 | 369 | protected function _set_list_table_views_default() { |
370 | - $this->_views = array ( |
|
371 | - 'all' => array ( |
|
370 | + $this->_views = array( |
|
371 | + 'all' => array( |
|
372 | 372 | 'slug' => 'all', |
373 | 373 | 'label' => esc_html__('View All Transactions', 'event_espresso'), |
374 | 374 | 'count' => 0 |
@@ -396,21 +396,21 @@ discard block |
||
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | private function _set_transaction_object() { |
399 | - if ( is_object( $this->_transaction) ) |
|
399 | + if (is_object($this->_transaction)) |
|
400 | 400 | return; //get out we've already set the object |
401 | 401 | |
402 | 402 | $TXN = EEM_Transaction::instance(); |
403 | 403 | |
404 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
404 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
405 | 405 | |
406 | 406 | //get transaction object |
407 | 407 | $this->_transaction = $TXN->get_one_by_ID($TXN_ID); |
408 | - $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
408 | + $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL; |
|
409 | 409 | $this->_transaction->verify_abandoned_transaction_status(); |
410 | 410 | |
411 | - if ( empty( $this->_transaction ) ) { |
|
412 | - $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID . esc_html__(' could not be retrieved.', 'event_espresso'); |
|
413 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
411 | + if (empty($this->_transaction)) { |
|
412 | + $error_msg = esc_html__('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.esc_html__(' could not be retrieved.', 'event_espresso'); |
|
413 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 | |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | * @return array |
424 | 424 | */ |
425 | 425 | protected function _transaction_legend_items() { |
426 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
426 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
427 | 427 | $items = array(); |
428 | 428 | |
429 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
430 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
431 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
429 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
430 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
431 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
432 | 432 | $items['view_related_messages'] = array( |
433 | 433 | 'class' => $related_for_icon['css_class'], |
434 | 434 | 'desc' => $related_for_icon['label'], |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | $items = apply_filters( |
440 | 440 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__items', |
441 | - array_merge( $items, |
|
441 | + array_merge($items, |
|
442 | 442 | array( |
443 | 443 | 'view_details' => array( |
444 | 444 | 'class' => 'dashicons dashicons-cart', |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | ), |
451 | 451 | 'view_receipt' => array( |
452 | 452 | 'class' => 'dashicons dashicons-media-default', |
453 | - 'desc' => esc_html__('View Transaction Receipt', 'event_espresso' ) |
|
453 | + 'desc' => esc_html__('View Transaction Receipt', 'event_espresso') |
|
454 | 454 | ), |
455 | 455 | 'view_registration' => array( |
456 | 456 | 'class' => 'dashicons dashicons-clipboard', |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | ) |
461 | 461 | ); |
462 | 462 | |
463 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) { |
|
464 | - if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) { |
|
463 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) { |
|
464 | + if (EEH_MSG_Template::is_mt_active('payment_reminder')) { |
|
465 | 465 | $items['send_payment_reminder'] = array( |
466 | 466 | 'class' => 'dashicons dashicons-email-alt', |
467 | 467 | 'desc' => esc_html__('Send Payment Reminder', 'event_espresso') |
@@ -482,29 +482,29 @@ discard block |
||
482 | 482 | 'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items', |
483 | 483 | array( |
484 | 484 | 'overpaid' => array( |
485 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code, |
|
486 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' ) |
|
485 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code, |
|
486 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence') |
|
487 | 487 | ), |
488 | 488 | 'complete' => array( |
489 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code, |
|
490 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' ) |
|
489 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code, |
|
490 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence') |
|
491 | 491 | ), |
492 | 492 | 'incomplete' => array( |
493 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code, |
|
494 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' ) |
|
493 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code, |
|
494 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence') |
|
495 | 495 | ), |
496 | 496 | 'abandoned' => array( |
497 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code, |
|
498 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' ) |
|
497 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code, |
|
498 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence') |
|
499 | 499 | ), |
500 | 500 | 'failed' => array( |
501 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code, |
|
502 | - 'desc' => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' ) |
|
501 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code, |
|
502 | + 'desc' => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence') |
|
503 | 503 | ) |
504 | 504 | ) |
505 | 505 | ); |
506 | 506 | |
507 | - return array_merge( $items, $more_items); |
|
507 | + return array_merge($items, $more_items); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | */ |
518 | 518 | protected function _transactions_overview_list_table() { |
519 | 519 | $this->_admin_page_title = esc_html__('Transactions', 'event_espresso'); |
520 | - $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL; |
|
521 | - $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : ''; |
|
522 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() ); |
|
520 | + $event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL; |
|
521 | + $this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(esc_html__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : ''; |
|
522 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items()); |
|
523 | 523 | $this->display_admin_list_table_page_with_no_sidebar(); |
524 | 524 | } |
525 | 525 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @return void |
534 | 534 | */ |
535 | 535 | protected function _transaction_details() { |
536 | - do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction ); |
|
536 | + do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction); |
|
537 | 537 | |
538 | 538 | $this->_set_transaction_status_array(); |
539 | 539 | |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | $attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL; |
547 | 547 | |
548 | 548 | $this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID(); |
549 | - $this->_template_args['txn_nmbr']['label'] = esc_html__( 'Transaction Number', 'event_espresso' ); |
|
549 | + $this->_template_args['txn_nmbr']['label'] = esc_html__('Transaction Number', 'event_espresso'); |
|
550 | 550 | |
551 | 551 | $this->_template_args['txn_datetime']['value'] = $this->_transaction->get_i18n_datetime('TXN_timestamp'); |
552 | - $this->_template_args['txn_datetime']['label'] = esc_html__( 'Date', 'event_espresso' ); |
|
552 | + $this->_template_args['txn_datetime']['label'] = esc_html__('Date', 'event_espresso'); |
|
553 | 553 | |
554 | - $this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ]; |
|
555 | - $this->_template_args['txn_status']['label'] = esc_html__( 'Transaction Status', 'event_espresso' ); |
|
556 | - $this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID'); |
|
554 | + $this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')]; |
|
555 | + $this->_template_args['txn_status']['label'] = esc_html__('Transaction Status', 'event_espresso'); |
|
556 | + $this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID'); |
|
557 | 557 | |
558 | 558 | $this->_template_args['grand_total'] = $this->_transaction->get('TXN_total'); |
559 | 559 | $this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid'); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | ) |
567 | 567 | ) { |
568 | 568 | $this->_template_args['send_payment_reminder_button'] = |
569 | - EEH_MSG_Template::is_mt_active( 'payment_reminder' ) |
|
569 | + EEH_MSG_Template::is_mt_active('payment_reminder') |
|
570 | 570 | && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code |
571 | 571 | && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code |
572 | 572 | ? EEH_Template::get_button_or_link( |
@@ -588,40 +588,40 @@ discard block |
||
588 | 588 | } |
589 | 589 | |
590 | 590 | $amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid'); |
591 | - $this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE ); |
|
592 | - if ( EE_Registry::instance()->CFG->currency->sign_b4 ) { |
|
593 | - $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due']; |
|
591 | + $this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE); |
|
592 | + if (EE_Registry::instance()->CFG->currency->sign_b4) { |
|
593 | + $this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due']; |
|
594 | 594 | } else { |
595 | - $this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign; |
|
595 | + $this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign; |
|
596 | 596 | } |
597 | - $this->_template_args['amount_due_class'] = ''; |
|
597 | + $this->_template_args['amount_due_class'] = ''; |
|
598 | 598 | |
599 | - if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) { |
|
599 | + if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) { |
|
600 | 600 | // paid in full |
601 | - $this->_template_args['amount_due'] = FALSE; |
|
602 | - } elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) { |
|
601 | + $this->_template_args['amount_due'] = FALSE; |
|
602 | + } elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) { |
|
603 | 603 | // overpaid |
604 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
605 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) { |
|
604 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
605 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) { |
|
606 | 606 | // monies owing |
607 | - $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
608 | - } elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) { |
|
607 | + $this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn'; |
|
608 | + } elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) { |
|
609 | 609 | // no payments made yet |
610 | - $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
611 | - } elseif ( $this->_transaction->get('TXN_total') == 0 ) { |
|
610 | + $this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn'; |
|
611 | + } elseif ($this->_transaction->get('TXN_total') == 0) { |
|
612 | 612 | // free event |
613 | - $this->_template_args['amount_due'] = FALSE; |
|
613 | + $this->_template_args['amount_due'] = FALSE; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | $payment_method = $this->_transaction->payment_method(); |
617 | 617 | |
618 | 618 | $this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method |
619 | 619 | ? $payment_method->admin_name() |
620 | - : esc_html__( 'Unknown', 'event_espresso' ); |
|
620 | + : esc_html__('Unknown', 'event_espresso'); |
|
621 | 621 | |
622 | 622 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
623 | 623 | // link back to overview |
624 | - $this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) |
|
624 | + $this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) |
|
625 | 625 | ? $_SERVER['HTTP_REFERER'] |
626 | 626 | : TXN_ADMIN_URL; |
627 | 627 | |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | // next link |
630 | 630 | $next_txn = $this->_transaction->next( |
631 | 631 | null, |
632 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
632 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
633 | 633 | 'TXN_ID' |
634 | 634 | ); |
635 | 635 | $this->_template_args['next_transaction'] = $next_txn |
636 | 636 | ? $this->_next_link( |
637 | 637 | EE_Admin_Page::add_query_args_and_nonce( |
638 | - array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), |
|
638 | + array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), |
|
639 | 639 | TXN_ADMIN_URL |
640 | 640 | ), |
641 | 641 | 'dashicons dashicons-arrow-right ee-icon-size-22' |
@@ -644,13 +644,13 @@ discard block |
||
644 | 644 | // previous link |
645 | 645 | $previous_txn = $this->_transaction->previous( |
646 | 646 | null, |
647 | - array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), |
|
647 | + array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), |
|
648 | 648 | 'TXN_ID' |
649 | 649 | ); |
650 | 650 | $this->_template_args['previous_transaction'] = $previous_txn |
651 | 651 | ? $this->_previous_link( |
652 | 652 | EE_Admin_Page::add_query_args_and_nonce( |
653 | - array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), |
|
653 | + array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), |
|
654 | 654 | TXN_ADMIN_URL |
655 | 655 | ), |
656 | 656 | 'dashicons dashicons-arrow-left ee-icon-size-22' |
@@ -660,16 +660,16 @@ discard block |
||
660 | 660 | // were we just redirected here after adding a new registration ??? |
661 | 661 | if ( |
662 | 662 | isset( |
663 | - $this->_req_data[ 'redirect_from' ], |
|
664 | - $this->_req_data[ 'EVT_ID' ], |
|
665 | - $this->_req_data[ 'event_name' ] |
|
663 | + $this->_req_data['redirect_from'], |
|
664 | + $this->_req_data['EVT_ID'], |
|
665 | + $this->_req_data['event_name'] |
|
666 | 666 | ) |
667 | 667 | ) { |
668 | 668 | if ( |
669 | 669 | EE_Registry::instance()->CAP->current_user_can( |
670 | 670 | 'ee_edit_registrations', |
671 | 671 | 'espresso_registrations_new_registration', |
672 | - $this->_req_data[ 'EVT_ID' ] |
|
672 | + $this->_req_data['EVT_ID'] |
|
673 | 673 | ) |
674 | 674 | ) { |
675 | 675 | $this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="'; |
@@ -679,25 +679,25 @@ discard block |
||
679 | 679 | 'action' => 'new_registration', |
680 | 680 | 'return' => 'default', |
681 | 681 | 'TXN_ID' => $this->_transaction->ID(), |
682 | - 'event_id' => $this->_req_data[ 'EVT_ID' ], |
|
682 | + 'event_id' => $this->_req_data['EVT_ID'], |
|
683 | 683 | ), |
684 | 684 | REG_ADMIN_URL |
685 | 685 | ); |
686 | 686 | $this->_admin_page_title .= '">'; |
687 | 687 | |
688 | 688 | $this->_admin_page_title .= sprintf( |
689 | - esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso' ), |
|
690 | - htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' ) |
|
689 | + esc_html__('Add Another New Registration to Event: "%1$s" ?', 'event_espresso'), |
|
690 | + htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8') |
|
691 | 691 | ); |
692 | 692 | $this->_admin_page_title .= '</a>'; |
693 | 693 | } |
694 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
694 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
695 | 695 | } |
696 | 696 | // grab messages at the last second |
697 | 697 | $this->_template_args['notices'] = EE_Error::get_notices(); |
698 | 698 | // path to template |
699 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php'; |
|
700 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
699 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php'; |
|
700 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
701 | 701 | |
702 | 702 | // the details template wrapper |
703 | 703 | $this->display_admin_page_with_sidebar(); |
@@ -716,18 +716,18 @@ discard block |
||
716 | 716 | |
717 | 717 | $this->_set_transaction_object(); |
718 | 718 | |
719 | - add_meta_box( 'edit-txn-details-mbox', esc_html__( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' ); |
|
719 | + add_meta_box('edit-txn-details-mbox', esc_html__('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high'); |
|
720 | 720 | add_meta_box( |
721 | 721 | 'edit-txn-attendees-mbox', |
722 | - esc_html__( 'Attendees Registered in this Transaction', 'event_espresso' ), |
|
723 | - array( $this, 'txn_attendees_meta_box' ), |
|
722 | + esc_html__('Attendees Registered in this Transaction', 'event_espresso'), |
|
723 | + array($this, 'txn_attendees_meta_box'), |
|
724 | 724 | $this->_wp_page_slug, |
725 | 725 | 'normal', |
726 | 726 | 'high', |
727 | - array( 'TXN_ID' => $this->_transaction->ID() ) |
|
727 | + array('TXN_ID' => $this->_transaction->ID()) |
|
728 | 728 | ); |
729 | - add_meta_box( 'edit-txn-registrant-mbox', esc_html__( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
730 | - add_meta_box( 'edit-txn-billing-info-mbox', esc_html__( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' ); |
|
729 | + add_meta_box('edit-txn-registrant-mbox', esc_html__('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
730 | + add_meta_box('edit-txn-billing-info-mbox', esc_html__('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high'); |
|
731 | 731 | |
732 | 732 | } |
733 | 733 | |
@@ -748,15 +748,15 @@ discard block |
||
748 | 748 | |
749 | 749 | //get line table |
750 | 750 | EEH_Autoloader::register_line_item_display_autoloaders(); |
751 | - $Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' ); |
|
752 | - $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() ); |
|
751 | + $Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy'); |
|
752 | + $this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item()); |
|
753 | 753 | $this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code'); |
754 | 754 | |
755 | 755 | // process taxes |
756 | - $taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax ))); |
|
757 | - $this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE; |
|
756 | + $taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
757 | + $this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE; |
|
758 | 758 | |
759 | - $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE ); |
|
759 | + $this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE); |
|
760 | 760 | $this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total'); |
761 | 761 | $this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID'); |
762 | 762 | |
@@ -764,63 +764,63 @@ discard block |
||
764 | 764 | |
765 | 765 | // process payment details |
766 | 766 | $payments = $this->_transaction->get_many_related('Payment'); |
767 | - if( ! empty( $payments ) ) { |
|
768 | - $this->_template_args[ 'payments' ] = $payments; |
|
769 | - $this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments ); |
|
767 | + if ( ! empty($payments)) { |
|
768 | + $this->_template_args['payments'] = $payments; |
|
769 | + $this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments); |
|
770 | 770 | } else { |
771 | - $this->_template_args[ 'payments' ] = false; |
|
772 | - $this->_template_args[ 'existing_reg_payments' ] = array(); |
|
771 | + $this->_template_args['payments'] = false; |
|
772 | + $this->_template_args['existing_reg_payments'] = array(); |
|
773 | 773 | } |
774 | 774 | |
775 | - $this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment' ), TXN_ADMIN_URL ); |
|
776 | - $this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL ); |
|
775 | + $this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL); |
|
776 | + $this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL); |
|
777 | 777 | |
778 | - if ( isset( $txn_details['invoice_number'] )) { |
|
778 | + if (isset($txn_details['invoice_number'])) { |
|
779 | 779 | $this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code']; |
780 | - $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__( 'Invoice Number', 'event_espresso' ); |
|
780 | + $this->_template_args['txn_details']['invoice_number']['label'] = esc_html__('Invoice Number', 'event_espresso'); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | $this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session'); |
784 | - $this->_template_args['txn_details']['registration_session']['label'] = esc_html__( 'Registration Session', 'event_espresso' ); |
|
784 | + $this->_template_args['txn_details']['registration_session']['label'] = esc_html__('Registration Session', 'event_espresso'); |
|
785 | 785 | |
786 | - $this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : ''; |
|
787 | - $this->_template_args['txn_details']['ip_address']['label'] = esc_html__( 'Transaction placed from IP', 'event_espresso' ); |
|
786 | + $this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : ''; |
|
787 | + $this->_template_args['txn_details']['ip_address']['label'] = esc_html__('Transaction placed from IP', 'event_espresso'); |
|
788 | 788 | |
789 | - $this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : ''; |
|
790 | - $this->_template_args['txn_details']['user_agent']['label'] = esc_html__( 'Registrant User Agent', 'event_espresso' ); |
|
789 | + $this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : ''; |
|
790 | + $this->_template_args['txn_details']['user_agent']['label'] = esc_html__('Registrant User Agent', 'event_espresso'); |
|
791 | 791 | |
792 | 792 | $reg_steps = '<ul>'; |
793 | - foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) { |
|
794 | - if ( $reg_step_status === true ) { |
|
795 | - $reg_steps .= '<li style="color:#70cc50">' . sprintf( esc_html__( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
796 | - } else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) { |
|
797 | - $reg_steps .= '<li style="color:#2EA2CC">' . sprintf( |
|
798 | - esc_html__( '%1$s : Initiated %2$s', 'event_espresso' ), |
|
799 | - ucwords( str_replace( '_', ' ', $reg_step ) ), |
|
800 | - gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ) |
|
801 | - ) . '</li>'; |
|
793 | + foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) { |
|
794 | + if ($reg_step_status === true) { |
|
795 | + $reg_steps .= '<li style="color:#70cc50">'.sprintf(esc_html__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
796 | + } else if (is_numeric($reg_step_status) && $reg_step_status !== false) { |
|
797 | + $reg_steps .= '<li style="color:#2EA2CC">'.sprintf( |
|
798 | + esc_html__('%1$s : Initiated %2$s', 'event_espresso'), |
|
799 | + ucwords(str_replace('_', ' ', $reg_step)), |
|
800 | + gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS))) |
|
801 | + ).'</li>'; |
|
802 | 802 | } else { |
803 | - $reg_steps .= '<li style="color:#E76700">' . sprintf( esc_html__( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>'; |
|
803 | + $reg_steps .= '<li style="color:#E76700">'.sprintf(esc_html__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>'; |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | $reg_steps .= '</ul>'; |
807 | 807 | $this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps; |
808 | - $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__( 'Registration Step Progress', 'event_espresso' ); |
|
808 | + $this->_template_args['txn_details']['reg_steps']['label'] = esc_html__('Registration Step Progress', 'event_espresso'); |
|
809 | 809 | |
810 | 810 | |
811 | 811 | $this->_get_registrations_to_apply_payment_to(); |
812 | - $this->_get_payment_methods( $payments ); |
|
812 | + $this->_get_payment_methods($payments); |
|
813 | 813 | $this->_get_payment_status_array(); |
814 | 814 | $this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction. |
815 | 815 | |
816 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction' ), TXN_ADMIN_URL ); |
|
817 | - $this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL ); |
|
818 | - $this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL ); |
|
816 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL); |
|
817 | + $this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL); |
|
818 | + $this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL); |
|
819 | 819 | |
820 | 820 | // 'espresso_delete_payment_nonce' |
821 | 821 | |
822 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
823 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
822 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php'; |
|
823 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
@@ -835,27 +835,27 @@ discard block |
||
835 | 835 | * @param EE_Payment[] $payments |
836 | 836 | * @return array |
837 | 837 | */ |
838 | - protected function _get_registration_payment_IDs( $payments = array() ) { |
|
838 | + protected function _get_registration_payment_IDs($payments = array()) { |
|
839 | 839 | $existing_reg_payments = array(); |
840 | 840 | // get all reg payments for these payments |
841 | - $reg_payments = EEM_Registration_Payment::instance()->get_all( array( |
|
841 | + $reg_payments = EEM_Registration_Payment::instance()->get_all(array( |
|
842 | 842 | array( |
843 | 843 | 'PAY_ID' => array( |
844 | 844 | 'IN', |
845 | - array_keys( $payments ) |
|
845 | + array_keys($payments) |
|
846 | 846 | ) |
847 | 847 | ) |
848 | - ) ); |
|
849 | - if ( ! empty( $reg_payments ) ) { |
|
850 | - foreach ( $payments as $payment ) { |
|
851 | - if ( ! $payment instanceof EE_Payment ) { |
|
848 | + )); |
|
849 | + if ( ! empty($reg_payments)) { |
|
850 | + foreach ($payments as $payment) { |
|
851 | + if ( ! $payment instanceof EE_Payment) { |
|
852 | 852 | continue; |
853 | - } else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) { |
|
854 | - $existing_reg_payments[ $payment->ID() ] = array(); |
|
853 | + } else if ( ! isset($existing_reg_payments[$payment->ID()])) { |
|
854 | + $existing_reg_payments[$payment->ID()] = array(); |
|
855 | 855 | } |
856 | - foreach ( $reg_payments as $reg_payment ) { |
|
857 | - if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) { |
|
858 | - $existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID(); |
|
856 | + foreach ($reg_payments as $reg_payment) { |
|
857 | + if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) { |
|
858 | + $existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID(); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
@@ -888,54 +888,54 @@ discard block |
||
888 | 888 | ) |
889 | 889 | ) |
890 | 890 | ); |
891 | - $registrations_to_apply_payment_to = EEH_HTML::br() . EEH_HTML::div( |
|
891 | + $registrations_to_apply_payment_to = EEH_HTML::br().EEH_HTML::div( |
|
892 | 892 | '', 'txn-admin-apply-payment-to-registrations-dv', '', 'clear: both; margin: 1.5em 0 0; display: none;' |
893 | 893 | ); |
894 | - $registrations_to_apply_payment_to .= EEH_HTML::br() . EEH_HTML::div( '', '', 'admin-primary-mbox-tbl-wrap' ); |
|
895 | - $registrations_to_apply_payment_to .= EEH_HTML::table( '', '', 'admin-primary-mbox-tbl' ); |
|
894 | + $registrations_to_apply_payment_to .= EEH_HTML::br().EEH_HTML::div('', '', 'admin-primary-mbox-tbl-wrap'); |
|
895 | + $registrations_to_apply_payment_to .= EEH_HTML::table('', '', 'admin-primary-mbox-tbl'); |
|
896 | 896 | $registrations_to_apply_payment_to .= EEH_HTML::thead( |
897 | 897 | EEH_HTML::tr( |
898 | - EEH_HTML::th( esc_html__( 'ID', 'event_espresso' ) ) . |
|
899 | - EEH_HTML::th( esc_html__( 'Registrant', 'event_espresso' ) ) . |
|
900 | - EEH_HTML::th( esc_html__( 'Ticket', 'event_espresso' ) ) . |
|
901 | - EEH_HTML::th( esc_html__( 'Event', 'event_espresso' ) ) . |
|
902 | - EEH_HTML::th( esc_html__( 'Paid', 'event_espresso' ), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
903 | - EEH_HTML::th( esc_html__( 'Owing', 'event_espresso' ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
904 | - EEH_HTML::th( esc_html__( 'Apply', 'event_espresso' ), '', 'jst-cntr' ) |
|
898 | + EEH_HTML::th(esc_html__('ID', 'event_espresso')). |
|
899 | + EEH_HTML::th(esc_html__('Registrant', 'event_espresso')). |
|
900 | + EEH_HTML::th(esc_html__('Ticket', 'event_espresso')). |
|
901 | + EEH_HTML::th(esc_html__('Event', 'event_espresso')). |
|
902 | + EEH_HTML::th(esc_html__('Paid', 'event_espresso'), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
903 | + EEH_HTML::th(esc_html__('Owing', 'event_espresso'), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
904 | + EEH_HTML::th(esc_html__('Apply', 'event_espresso'), '', 'jst-cntr') |
|
905 | 905 | ) |
906 | 906 | ); |
907 | 907 | $registrations_to_apply_payment_to .= EEH_HTML::tbody(); |
908 | 908 | // get registrations for TXN |
909 | - $registrations = $this->_transaction->registrations( $query_params ); |
|
910 | - foreach ( $registrations as $registration ) { |
|
911 | - if ( $registration instanceof EE_Registration ) { |
|
909 | + $registrations = $this->_transaction->registrations($query_params); |
|
910 | + foreach ($registrations as $registration) { |
|
911 | + if ($registration instanceof EE_Registration) { |
|
912 | 912 | $attendee_name = $registration->attendee() instanceof EE_Attendee |
913 | 913 | ? $registration->attendee()->full_name() |
914 | - : esc_html__( 'Unknown Attendee', 'event_espresso' ); |
|
914 | + : esc_html__('Unknown Attendee', 'event_espresso'); |
|
915 | 915 | $owing = $registration->final_price() - $registration->paid(); |
916 | 916 | $taxable = $registration->ticket()->taxable() |
917 | - ? ' <span class="smaller-text lt-grey-text"> ' . esc_html__( '+ tax', 'event_espresso' ) . '</span>' |
|
917 | + ? ' <span class="smaller-text lt-grey-text"> '.esc_html__('+ tax', 'event_espresso').'</span>' |
|
918 | 918 | : ''; |
919 | - $checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) |
|
919 | + $checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) |
|
920 | 920 | ? ' checked="checked"' |
921 | 921 | : ''; |
922 | 922 | $disabled = $registration->final_price() > 0 ? '' : ' disabled'; |
923 | 923 | $registrations_to_apply_payment_to .= EEH_HTML::tr( |
924 | - EEH_HTML::td( $registration->ID() ) . |
|
925 | - EEH_HTML::td( $attendee_name ) . |
|
924 | + EEH_HTML::td($registration->ID()). |
|
925 | + EEH_HTML::td($attendee_name). |
|
926 | 926 | EEH_HTML::td( |
927 | - $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable |
|
928 | - ) . |
|
929 | - EEH_HTML::td( $registration->event_name() ) . |
|
930 | - EEH_HTML::td( $registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr' ) . |
|
931 | - EEH_HTML::td( EEH_Template::format_currency( $owing ), '', 'txn-admin-payment-owing-td jst-cntr' ) . |
|
927 | + $registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable |
|
928 | + ). |
|
929 | + EEH_HTML::td($registration->event_name()). |
|
930 | + EEH_HTML::td($registration->pretty_paid(), '', 'txn-admin-payment-paid-td jst-cntr'). |
|
931 | + EEH_HTML::td(EEH_Template::format_currency($owing), '', 'txn-admin-payment-owing-td jst-cntr'). |
|
932 | 932 | EEH_HTML::td( |
933 | - '<input type="checkbox" value="' . $registration->ID() |
|
933 | + '<input type="checkbox" value="'.$registration->ID() |
|
934 | 934 | . '" name="txn_admin_payment[registrations]"' |
935 | - . $checked . $disabled . '>', |
|
935 | + . $checked.$disabled.'>', |
|
936 | 936 | '', 'jst-cntr' |
937 | 937 | ), |
938 | - 'apply-payment-registration-row-' . $registration->ID() |
|
938 | + 'apply-payment-registration-row-'.$registration->ID() |
|
939 | 939 | ); |
940 | 940 | } |
941 | 941 | } |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | '', 'clear description' |
951 | 951 | ); |
952 | 952 | $registrations_to_apply_payment_to .= EEH_HTML::divx(); |
953 | - $this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to; |
|
953 | + $this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to; |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | |
@@ -967,9 +967,9 @@ discard block |
||
967 | 967 | $statuses = EEM_Registration::reg_status_array(array(), TRUE); |
968 | 968 | //let's add a "don't change" option. |
969 | 969 | $status_array['NAN'] = esc_html__('Leave the Same', 'event_espresso'); |
970 | - $status_array = array_merge( $status_array, $statuses ); |
|
971 | - $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' ); |
|
972 | - $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' ); |
|
970 | + $status_array = array_merge($status_array, $statuses); |
|
971 | + $this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status'); |
|
972 | + $this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status'); |
|
973 | 973 | |
974 | 974 | } |
975 | 975 | |
@@ -984,21 +984,21 @@ discard block |
||
984 | 984 | * @param EE_Payment[] to show on this page |
985 | 985 | * @return void |
986 | 986 | */ |
987 | - private function _get_payment_methods( $payments = array() ) { |
|
987 | + private function _get_payment_methods($payments = array()) { |
|
988 | 988 | $payment_methods_of_payments = array(); |
989 | - foreach( $payments as $payment ){ |
|
990 | - if( $payment instanceof EE_Payment ){ |
|
991 | - $payment_methods_of_payments[] = $payment->get( 'PMD_ID' ); |
|
989 | + foreach ($payments as $payment) { |
|
990 | + if ($payment instanceof EE_Payment) { |
|
991 | + $payment_methods_of_payments[] = $payment->get('PMD_ID'); |
|
992 | 992 | } |
993 | 993 | } |
994 | - if( $payment_methods_of_payments ){ |
|
995 | - $query_args = array( array( 'OR*payment_method_for_payment' => array( |
|
996 | - 'PMD_ID' => array( 'IN', $payment_methods_of_payments ), |
|
997 | - 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) ); |
|
998 | - }else{ |
|
999 | - $query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ); |
|
994 | + if ($payment_methods_of_payments) { |
|
995 | + $query_args = array(array('OR*payment_method_for_payment' => array( |
|
996 | + 'PMD_ID' => array('IN', $payment_methods_of_payments), |
|
997 | + 'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') ))); |
|
998 | + } else { |
|
999 | + $query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%'))); |
|
1000 | 1000 | } |
1001 | - $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args ); |
|
1001 | + $this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | |
@@ -1012,17 +1012,17 @@ discard block |
||
1012 | 1012 | * @param array $metabox |
1013 | 1013 | * @return void |
1014 | 1014 | */ |
1015 | - public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) { |
|
1015 | + public function txn_attendees_meta_box($post, $metabox = array('args' => array())) { |
|
1016 | 1016 | |
1017 | - extract( $metabox['args'] ); |
|
1017 | + extract($metabox['args']); |
|
1018 | 1018 | $this->_template_args['post'] = $post; |
1019 | 1019 | $this->_template_args['event_attendees'] = array(); |
1020 | 1020 | // process items in cart |
1021 | - $line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) ); |
|
1022 | - if ( ! empty( $line_items )) { |
|
1023 | - foreach ( $line_items as $item ) { |
|
1024 | - if ( $item instanceof EE_Line_Item ) { |
|
1025 | - switch( $item->OBJ_type() ) { |
|
1021 | + $line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item'))); |
|
1022 | + if ( ! empty($line_items)) { |
|
1023 | + foreach ($line_items as $item) { |
|
1024 | + if ($item instanceof EE_Line_Item) { |
|
1025 | + switch ($item->OBJ_type()) { |
|
1026 | 1026 | |
1027 | 1027 | case 'Event' : |
1028 | 1028 | break; |
@@ -1030,39 +1030,39 @@ discard block |
||
1030 | 1030 | case 'Ticket' : |
1031 | 1031 | $ticket = $item->ticket(); |
1032 | 1032 | //right now we're only handling tickets here. Cause its expected that only tickets will have attendees right? |
1033 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
1033 | + if ( ! $ticket instanceof EE_Ticket) { |
|
1034 | 1034 | continue; |
1035 | 1035 | } |
1036 | 1036 | try { |
1037 | 1037 | $event_name = $ticket->get_event_name(); |
1038 | - } catch ( Exception $e ) { |
|
1039 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1040 | - $event_name = esc_html__( 'Unknown Event', 'event_espresso' ); |
|
1038 | + } catch (Exception $e) { |
|
1039 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1040 | + $event_name = esc_html__('Unknown Event', 'event_espresso'); |
|
1041 | 1041 | } |
1042 | - $event_name .= ' - ' . $item->get( 'LIN_name' ); |
|
1043 | - $ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ) ); |
|
1042 | + $event_name .= ' - '.$item->get('LIN_name'); |
|
1043 | + $ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price')); |
|
1044 | 1044 | // now get all of the registrations for this transaction that use this ticket |
1045 | - $registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() ))); |
|
1046 | - foreach( $registrations as $registration ) { |
|
1047 | - if ( ! $registration instanceof EE_Registration ) { |
|
1045 | + $registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID()))); |
|
1046 | + foreach ($registrations as $registration) { |
|
1047 | + if ( ! $registration instanceof EE_Registration) { |
|
1048 | 1048 | continue; |
1049 | 1049 | } |
1050 | - $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1051 | - $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1052 | - $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1053 | - $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1050 | + $this->_template_args['event_attendees'][$registration->ID()]['STS_ID'] = $registration->status_ID(); |
|
1051 | + $this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->count(); |
|
1052 | + $this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name; |
|
1053 | + $this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price; |
|
1054 | 1054 | // attendee info |
1055 | 1055 | $attendee = $registration->get_first_related('Attendee'); |
1056 | - if ( $attendee instanceof EE_Attendee ) { |
|
1057 | - $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1058 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1059 | - $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:' . $attendee->email() . '?subject=' . $event_name . esc_html__(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>'; |
|
1060 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format( $attendee, 'inline', false, false ); |
|
1056 | + if ($attendee instanceof EE_Attendee) { |
|
1057 | + $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = $attendee->ID(); |
|
1058 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = $attendee->full_name(); |
|
1059 | + $this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event_name.esc_html__(' Event', 'event_espresso').'">'.$attendee->email().'</a>'; |
|
1060 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = EEH_Address::format($attendee, 'inline', false, false); |
|
1061 | 1061 | } else { |
1062 | 1062 | $this->_template_args['event_attendees'][$registration->ID()]['att_id'] = ''; |
1063 | - $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1063 | + $this->_template_args['event_attendees'][$registration->ID()]['attendee'] = ''; |
|
1064 | 1064 | $this->_template_args['event_attendees'][$registration->ID()]['email'] = ''; |
1065 | - $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1065 | + $this->_template_args['event_attendees'][$registration->ID()]['address'] = ''; |
|
1066 | 1066 | } |
1067 | 1067 | } |
1068 | 1068 | break; |
@@ -1071,12 +1071,12 @@ discard block |
||
1071 | 1071 | } |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - $this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees' ), TXN_ADMIN_URL ); |
|
1075 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE ); |
|
1074 | + $this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL); |
|
1075 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE); |
|
1076 | 1076 | |
1077 | 1077 | } else { |
1078 | 1078 | echo sprintf( |
1079 | - esc_html__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ), |
|
1079 | + esc_html__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'), |
|
1080 | 1080 | '<p class="important-notice">', |
1081 | 1081 | '</p>' |
1082 | 1082 | ); |
@@ -1095,19 +1095,19 @@ discard block |
||
1095 | 1095 | */ |
1096 | 1096 | public function txn_registrant_side_meta_box() { |
1097 | 1097 | $primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null; |
1098 | - if ( ! $primary_att instanceof EE_Attendee ) { |
|
1098 | + if ( ! $primary_att instanceof EE_Attendee) { |
|
1099 | 1099 | $this->_template_args['no_attendee_message'] = esc_html__('There is no attached contact for this transaction. The transaction either failed due to an error or was abandoned.', 'event_espresso'); |
1100 | 1100 | $primary_att = EEM_Attendee::instance()->create_default_object(); |
1101 | 1101 | } |
1102 | - $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1102 | + $this->_template_args['ATT_ID'] = $primary_att->ID(); |
|
1103 | 1103 | $this->_template_args['prime_reg_fname'] = $primary_att->fname(); |
1104 | 1104 | $this->_template_args['prime_reg_lname'] = $primary_att->lname(); |
1105 | - $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1105 | + $this->_template_args['prime_reg_email'] = $primary_att->email(); |
|
1106 | 1106 | $this->_template_args['prime_reg_phone'] = $primary_att->phone(); |
1107 | - $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID() ), REG_ADMIN_URL ); |
|
1107 | + $this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL); |
|
1108 | 1108 | // get formatted address for registrant |
1109 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att ); |
|
1110 | - echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE ); |
|
1109 | + $this->_template_args['formatted_address'] = EEH_Address::format($primary_att); |
|
1110 | + echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE); |
|
1111 | 1111 | } |
1112 | 1112 | |
1113 | 1113 | |
@@ -1123,12 +1123,12 @@ discard block |
||
1123 | 1123 | |
1124 | 1124 | $this->_template_args['billing_form'] = $this->_transaction->billing_info(); |
1125 | 1125 | $this->_template_args['billing_form_url'] = add_query_arg( |
1126 | - array( 'action' => 'edit_transaction', 'process' => 'billing' ), |
|
1126 | + array('action' => 'edit_transaction', 'process' => 'billing'), |
|
1127 | 1127 | TXN_ADMIN_URL |
1128 | 1128 | ); |
1129 | 1129 | |
1130 | - $template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1131 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/ |
|
1130 | + $template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php'; |
|
1131 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/ |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
@@ -1141,42 +1141,42 @@ discard block |
||
1141 | 1141 | * @return void |
1142 | 1142 | */ |
1143 | 1143 | public function apply_payments_or_refunds() { |
1144 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1144 | + $json_response_data = array('return_data' => FALSE); |
|
1145 | 1145 | $valid_data = $this->_validate_payment_request_data(); |
1146 | - if ( ! empty( $valid_data ) ) { |
|
1147 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1146 | + if ( ! empty($valid_data)) { |
|
1147 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1148 | 1148 | //save the new payment |
1149 | - $payment = $this->_create_payment_from_request_data( $valid_data ); |
|
1149 | + $payment = $this->_create_payment_from_request_data($valid_data); |
|
1150 | 1150 | // get the TXN for this payment |
1151 | 1151 | $transaction = $payment->transaction(); |
1152 | 1152 | // verify transaction |
1153 | - if ( $transaction instanceof EE_Transaction ) { |
|
1153 | + if ($transaction instanceof EE_Transaction) { |
|
1154 | 1154 | // calculate_total_payments_and_update_status |
1155 | - $this->_process_transaction_payments( $transaction ); |
|
1156 | - $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment ); |
|
1157 | - $this->_remove_existing_registration_payments( $payment, $PAY_ID ); |
|
1155 | + $this->_process_transaction_payments($transaction); |
|
1156 | + $REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment); |
|
1157 | + $this->_remove_existing_registration_payments($payment, $PAY_ID); |
|
1158 | 1158 | // apply payment to registrations (if applicable) |
1159 | - if ( ! empty( $REG_IDs ) ) { |
|
1160 | - $this->_update_registration_payments( $transaction, $payment, $REG_IDs ); |
|
1159 | + if ( ! empty($REG_IDs)) { |
|
1160 | + $this->_update_registration_payments($transaction, $payment, $REG_IDs); |
|
1161 | 1161 | $this->_maybe_send_notifications(); |
1162 | 1162 | // now process status changes for the same registrations |
1163 | - $this->_process_registration_status_change( $transaction, $REG_IDs ); |
|
1163 | + $this->_process_registration_status_change($transaction, $REG_IDs); |
|
1164 | 1164 | } |
1165 | - $this->_maybe_send_notifications( $payment ); |
|
1165 | + $this->_maybe_send_notifications($payment); |
|
1166 | 1166 | //prepare to render page |
1167 | - $json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs ); |
|
1168 | - do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment ); |
|
1167 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs); |
|
1168 | + do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment); |
|
1169 | 1169 | } else { |
1170 | 1170 | EE_Error::add_error( |
1171 | - esc_html__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ), |
|
1171 | + esc_html__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'), |
|
1172 | 1172 | __FILE__, __FUNCTION__, __LINE__ |
1173 | 1173 | ); |
1174 | 1174 | } |
1175 | 1175 | } else { |
1176 | - EE_Error::add_error( esc_html__( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1176 | + EE_Error::add_error(esc_html__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | - $notices = EE_Error::get_notices( false, false, false ); |
|
1179 | + $notices = EE_Error::get_notices(false, false, false); |
|
1180 | 1180 | $this->_template_args = array( |
1181 | 1181 | 'data' => $json_response_data, |
1182 | 1182 | 'error' => $notices['errors'], |
@@ -1193,30 +1193,30 @@ discard block |
||
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | 1195 | protected function _validate_payment_request_data() { |
1196 | - if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) { |
|
1196 | + if ( ! isset($this->_req_data['txn_admin_payment'])) { |
|
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | $payment_form = $this->_generate_payment_form_section(); |
1200 | 1200 | try { |
1201 | - if ( $payment_form->was_submitted() ) { |
|
1201 | + if ($payment_form->was_submitted()) { |
|
1202 | 1202 | $payment_form->receive_form_submission(); |
1203 | - if ( ! $payment_form->is_valid() ) { |
|
1203 | + if ( ! $payment_form->is_valid()) { |
|
1204 | 1204 | $submission_error_messages = array(); |
1205 | - foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) { |
|
1206 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1205 | + foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) { |
|
1206 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1207 | 1207 | $submission_error_messages[] = sprintf( |
1208 | - _x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ), |
|
1208 | + _x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'), |
|
1209 | 1209 | $validation_error->get_form_section()->html_label_text(), |
1210 | 1210 | $validation_error->getMessage() |
1211 | 1211 | ); |
1212 | 1212 | } |
1213 | 1213 | } |
1214 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1214 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1215 | 1215 | return array(); |
1216 | 1216 | } |
1217 | 1217 | } |
1218 | - } catch ( EE_Error $e ) { |
|
1219 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1218 | + } catch (EE_Error $e) { |
|
1219 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1220 | 1220 | return array(); |
1221 | 1221 | } |
1222 | 1222 | return $payment_form->valid_data(); |
@@ -1238,63 +1238,63 @@ discard block |
||
1238 | 1238 | array( |
1239 | 1239 | 'default' => 0, |
1240 | 1240 | 'required' => false, |
1241 | - 'html_label_text' => esc_html__( 'Payment ID', 'event_espresso' ), |
|
1242 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1241 | + 'html_label_text' => esc_html__('Payment ID', 'event_espresso'), |
|
1242 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1243 | 1243 | ) |
1244 | 1244 | ), |
1245 | 1245 | 'TXN_ID' => new EE_Text_Input( |
1246 | 1246 | array( |
1247 | 1247 | 'default' => 0, |
1248 | 1248 | 'required' => true, |
1249 | - 'html_label_text' => esc_html__( 'Transaction ID', 'event_espresso' ), |
|
1250 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1249 | + 'html_label_text' => esc_html__('Transaction ID', 'event_espresso'), |
|
1250 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1251 | 1251 | ) |
1252 | 1252 | ), |
1253 | 1253 | 'type' => new EE_Text_Input( |
1254 | 1254 | array( |
1255 | 1255 | 'default' => 1, |
1256 | 1256 | 'required' => true, |
1257 | - 'html_label_text' => esc_html__( 'Payment or Refund', 'event_espresso' ), |
|
1258 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1257 | + 'html_label_text' => esc_html__('Payment or Refund', 'event_espresso'), |
|
1258 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1259 | 1259 | ) |
1260 | 1260 | ), |
1261 | 1261 | 'amount' => new EE_Text_Input( |
1262 | 1262 | array( |
1263 | 1263 | 'default' => 0, |
1264 | 1264 | 'required' => true, |
1265 | - 'html_label_text' => esc_html__( 'Payment amount', 'event_espresso' ), |
|
1266 | - 'validation_strategies' => array( new EE_Float_Normalization() ) |
|
1265 | + 'html_label_text' => esc_html__('Payment amount', 'event_espresso'), |
|
1266 | + 'validation_strategies' => array(new EE_Float_Normalization()) |
|
1267 | 1267 | ) |
1268 | 1268 | ), |
1269 | 1269 | 'status' => new EE_Text_Input( |
1270 | 1270 | array( |
1271 | 1271 | 'default' => EEM_Payment::status_id_approved, |
1272 | 1272 | 'required' => true, |
1273 | - 'html_label_text' => esc_html__( 'Payment status', 'event_espresso' ), |
|
1273 | + 'html_label_text' => esc_html__('Payment status', 'event_espresso'), |
|
1274 | 1274 | ) |
1275 | 1275 | ), |
1276 | 1276 | 'PMD_ID' => new EE_Text_Input( |
1277 | 1277 | array( |
1278 | 1278 | 'default' => 2, |
1279 | 1279 | 'required' => true, |
1280 | - 'html_label_text' => esc_html__( 'Payment Method', 'event_espresso' ), |
|
1281 | - 'validation_strategies' => array( new EE_Int_Normalization() ) |
|
1280 | + 'html_label_text' => esc_html__('Payment Method', 'event_espresso'), |
|
1281 | + 'validation_strategies' => array(new EE_Int_Normalization()) |
|
1282 | 1282 | ) |
1283 | 1283 | ), |
1284 | 1284 | 'date' => new EE_Text_Input( |
1285 | 1285 | array( |
1286 | 1286 | 'default' => time(), |
1287 | 1287 | 'required' => true, |
1288 | - 'html_label_text' => esc_html__( 'Payment date', 'event_espresso' ), |
|
1288 | + 'html_label_text' => esc_html__('Payment date', 'event_espresso'), |
|
1289 | 1289 | ) |
1290 | 1290 | ), |
1291 | 1291 | 'txn_id_chq_nmbr' => new EE_Text_Input( |
1292 | 1292 | array( |
1293 | 1293 | 'default' => '', |
1294 | 1294 | 'required' => false, |
1295 | - 'html_label_text' => esc_html__( 'Transaction or Cheque Number', 'event_espresso' ), |
|
1295 | + 'html_label_text' => esc_html__('Transaction or Cheque Number', 'event_espresso'), |
|
1296 | 1296 | 'validation_strategies' => array( |
1297 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1297 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1298 | 1298 | ) |
1299 | 1299 | ) |
1300 | 1300 | ), |
@@ -1302,9 +1302,9 @@ discard block |
||
1302 | 1302 | array( |
1303 | 1303 | 'default' => '', |
1304 | 1304 | 'required' => false, |
1305 | - 'html_label_text' => esc_html__( 'Purchase Order Number', 'event_espresso' ), |
|
1305 | + 'html_label_text' => esc_html__('Purchase Order Number', 'event_espresso'), |
|
1306 | 1306 | 'validation_strategies' => array( |
1307 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1307 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1308 | 1308 | ) |
1309 | 1309 | ) |
1310 | 1310 | ), |
@@ -1312,9 +1312,9 @@ discard block |
||
1312 | 1312 | array( |
1313 | 1313 | 'default' => '', |
1314 | 1314 | 'required' => false, |
1315 | - 'html_label_text' => esc_html__( 'Extra Field for Accounting', 'event_espresso' ), |
|
1315 | + 'html_label_text' => esc_html__('Extra Field for Accounting', 'event_espresso'), |
|
1316 | 1316 | 'validation_strategies' => array( |
1317 | - new EE_Max_Length_Validation_Strategy( esc_html__('Input too long', 'event_espresso'), 100 ), |
|
1317 | + new EE_Max_Length_Validation_Strategy(esc_html__('Input too long', 'event_espresso'), 100), |
|
1318 | 1318 | ) |
1319 | 1319 | ) |
1320 | 1320 | ), |
@@ -1331,37 +1331,37 @@ discard block |
||
1331 | 1331 | * @param array $valid_data |
1332 | 1332 | * @return EE_Payment |
1333 | 1333 | */ |
1334 | - protected function _create_payment_from_request_data( $valid_data ) { |
|
1335 | - $PAY_ID = $valid_data[ 'PAY_ID' ]; |
|
1334 | + protected function _create_payment_from_request_data($valid_data) { |
|
1335 | + $PAY_ID = $valid_data['PAY_ID']; |
|
1336 | 1336 | // get payment amount |
1337 | - $amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0; |
|
1337 | + $amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0; |
|
1338 | 1338 | // payments have a type value of 1 and refunds have a type value of -1 |
1339 | 1339 | // so multiplying amount by type will give a positive value for payments, and negative values for refunds |
1340 | - $amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount; |
|
1340 | + $amount = $valid_data['type'] < 0 ? $amount * -1 : $amount; |
|
1341 | 1341 | // for some reason the date string coming in has extra spaces between the date and time. This fixes that. |
1342 | - $date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) ); |
|
1342 | + $date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp')); |
|
1343 | 1343 | $payment = EE_Payment::new_instance( |
1344 | 1344 | array( |
1345 | - 'TXN_ID' => $valid_data[ 'TXN_ID' ], |
|
1346 | - 'STS_ID' => $valid_data[ 'status' ], |
|
1345 | + 'TXN_ID' => $valid_data['TXN_ID'], |
|
1346 | + 'STS_ID' => $valid_data['status'], |
|
1347 | 1347 | 'PAY_timestamp' => $date, |
1348 | 1348 | 'PAY_source' => EEM_Payment_Method::scope_admin, |
1349 | - 'PMD_ID' => $valid_data[ 'PMD_ID' ], |
|
1349 | + 'PMD_ID' => $valid_data['PMD_ID'], |
|
1350 | 1350 | 'PAY_amount' => $amount, |
1351 | - 'PAY_txn_id_chq_nmbr' => $valid_data[ 'txn_id_chq_nmbr' ], |
|
1352 | - 'PAY_po_number' => $valid_data[ 'po_number' ], |
|
1353 | - 'PAY_extra_accntng' => $valid_data[ 'accounting' ], |
|
1351 | + 'PAY_txn_id_chq_nmbr' => $valid_data['txn_id_chq_nmbr'], |
|
1352 | + 'PAY_po_number' => $valid_data['po_number'], |
|
1353 | + 'PAY_extra_accntng' => $valid_data['accounting'], |
|
1354 | 1354 | 'PAY_details' => $valid_data, |
1355 | 1355 | 'PAY_ID' => $PAY_ID |
1356 | 1356 | ), |
1357 | 1357 | '', |
1358 | - array( 'Y-m-d', 'g:i a' ) |
|
1358 | + array('Y-m-d', 'g:i a') |
|
1359 | 1359 | ); |
1360 | 1360 | |
1361 | - if ( ! $payment->save() ) { |
|
1361 | + if ( ! $payment->save()) { |
|
1362 | 1362 | EE_Error::add_error( |
1363 | 1363 | sprintf( |
1364 | - esc_html__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ), |
|
1364 | + esc_html__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'), |
|
1365 | 1365 | $payment->ID() |
1366 | 1366 | ), |
1367 | 1367 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1378,15 +1378,15 @@ discard block |
||
1378 | 1378 | * @param \EE_Transaction $transaction |
1379 | 1379 | * @return array |
1380 | 1380 | */ |
1381 | - protected function _process_transaction_payments( EE_Transaction $transaction ) { |
|
1381 | + protected function _process_transaction_payments(EE_Transaction $transaction) { |
|
1382 | 1382 | /** @type EE_Transaction_Payments $transaction_payments */ |
1383 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1383 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1384 | 1384 | //update the transaction with this payment |
1385 | - if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) { |
|
1386 | - EE_Error::add_success( esc_html__( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1385 | + if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) { |
|
1386 | + EE_Error::add_success(esc_html__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1387 | 1387 | } else { |
1388 | 1388 | EE_Error::add_error( |
1389 | - esc_html__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' ) |
|
1389 | + esc_html__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso') |
|
1390 | 1390 | , __FILE__, __FUNCTION__, __LINE__ |
1391 | 1391 | ); |
1392 | 1392 | } |
@@ -1402,19 +1402,19 @@ discard block |
||
1402 | 1402 | * @param \EE_Payment $payment |
1403 | 1403 | * @return array |
1404 | 1404 | */ |
1405 | - protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) { |
|
1405 | + protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) { |
|
1406 | 1406 | $REG_IDs = array(); |
1407 | 1407 | // grab array of IDs for specific registrations to apply changes to |
1408 | - if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) { |
|
1409 | - $REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ]; |
|
1408 | + if (isset($this->_req_data['txn_admin_payment']['registrations'])) { |
|
1409 | + $REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations']; |
|
1410 | 1410 | } |
1411 | 1411 | //nothing specified ? then get all reg IDs |
1412 | - if ( empty( $REG_IDs ) ) { |
|
1412 | + if (empty($REG_IDs)) { |
|
1413 | 1413 | $registrations = $payment->transaction()->registrations(); |
1414 | - $REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1414 | + $REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1415 | 1415 | } |
1416 | 1416 | // ensure that REG_IDs are integers and NOT strings |
1417 | - return array_map( 'intval', $REG_IDs ); |
|
1417 | + return array_map('intval', $REG_IDs); |
|
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | |
@@ -1431,7 +1431,7 @@ discard block |
||
1431 | 1431 | /** |
1432 | 1432 | * @param array $existing_reg_payment_REG_IDs |
1433 | 1433 | */ |
1434 | - public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) { |
|
1434 | + public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) { |
|
1435 | 1435 | $this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs; |
1436 | 1436 | } |
1437 | 1437 | |
@@ -1446,13 +1446,13 @@ discard block |
||
1446 | 1446 | * @param \EE_Payment $payment |
1447 | 1447 | * @return array |
1448 | 1448 | */ |
1449 | - protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) { |
|
1450 | - if ( $this->existing_reg_payment_REG_IDs() === null ) { |
|
1449 | + protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) { |
|
1450 | + if ($this->existing_reg_payment_REG_IDs() === null) { |
|
1451 | 1451 | // let's get any existing reg payment records for this payment |
1452 | - $existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' ); |
|
1452 | + $existing_reg_payment_REG_IDs = $payment->get_many_related('Registration'); |
|
1453 | 1453 | // but we only want the REG IDs, so grab the array keys |
1454 | - $existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array(); |
|
1455 | - $this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs ); |
|
1454 | + $existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array(); |
|
1455 | + $this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs); |
|
1456 | 1456 | } |
1457 | 1457 | return $this->existing_reg_payment_REG_IDs(); |
1458 | 1458 | } |
@@ -1471,23 +1471,23 @@ discard block |
||
1471 | 1471 | * @param int $PAY_ID |
1472 | 1472 | * @return bool; |
1473 | 1473 | */ |
1474 | - protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) { |
|
1474 | + protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) { |
|
1475 | 1475 | // newly created payments will have nothing recorded for $PAY_ID |
1476 | - if ( $PAY_ID == 0 ) { |
|
1476 | + if ($PAY_ID == 0) { |
|
1477 | 1477 | return false; |
1478 | 1478 | } |
1479 | - $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1480 | - if ( empty( $existing_reg_payment_REG_IDs )) { |
|
1479 | + $existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1480 | + if (empty($existing_reg_payment_REG_IDs)) { |
|
1481 | 1481 | return false; |
1482 | 1482 | } |
1483 | 1483 | /** @type EE_Transaction_Payments $transaction_payments */ |
1484 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1484 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1485 | 1485 | return $transaction_payments->delete_registration_payments_and_update_registrations( |
1486 | 1486 | $payment, |
1487 | 1487 | array( |
1488 | 1488 | array( |
1489 | 1489 | 'PAY_ID' => $payment->ID(), |
1490 | - 'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ), |
|
1490 | + 'REG_ID' => array('IN', $existing_reg_payment_REG_IDs), |
|
1491 | 1491 | ) |
1492 | 1492 | ) |
1493 | 1493 | ); |
@@ -1506,25 +1506,25 @@ discard block |
||
1506 | 1506 | * @param array $REG_IDs |
1507 | 1507 | * @return bool |
1508 | 1508 | */ |
1509 | - protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) { |
|
1509 | + protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) { |
|
1510 | 1510 | // we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments() |
1511 | 1511 | // so let's do that using our set of REG_IDs from the form |
1512 | 1512 | $registration_query_where_params = array( |
1513 | - 'REG_ID' => array( 'IN', $REG_IDs ) |
|
1513 | + 'REG_ID' => array('IN', $REG_IDs) |
|
1514 | 1514 | ); |
1515 | 1515 | // but add in some conditions regarding payment, |
1516 | 1516 | // so that we don't apply payments to registrations that are free or have already been paid for |
1517 | 1517 | // but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative ) |
1518 | - if ( ! $payment->is_a_refund() ) { |
|
1519 | - $registration_query_where_params[ 'REG_final_price' ] = array( '!=', 0 ); |
|
1520 | - $registration_query_where_params[ 'REG_final_price*' ] = array( '!=', 'REG_paid', true ); |
|
1518 | + if ( ! $payment->is_a_refund()) { |
|
1519 | + $registration_query_where_params['REG_final_price'] = array('!=', 0); |
|
1520 | + $registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true); |
|
1521 | 1521 | } |
1522 | 1522 | //EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ ); |
1523 | - $registrations = $transaction->registrations( array( $registration_query_where_params ) ); |
|
1524 | - if ( ! empty( $registrations ) ) { |
|
1523 | + $registrations = $transaction->registrations(array($registration_query_where_params)); |
|
1524 | + if ( ! empty($registrations)) { |
|
1525 | 1525 | /** @type EE_Payment_Processor $payment_processor */ |
1526 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1527 | - $payment_processor->process_registration_payments( $transaction, $payment, $registrations ); |
|
1526 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1527 | + $payment_processor->process_registration_payments($transaction, $payment, $registrations); |
|
1528 | 1528 | } |
1529 | 1529 | } |
1530 | 1530 | |
@@ -1540,22 +1540,22 @@ discard block |
||
1540 | 1540 | * @param array $REG_IDs |
1541 | 1541 | * @return bool |
1542 | 1542 | */ |
1543 | - protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) { |
|
1543 | + protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) { |
|
1544 | 1544 | // first if there is no change in status then we get out. |
1545 | 1545 | if ( |
1546 | - ! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ) |
|
1546 | + ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status']) |
|
1547 | 1547 | || $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN' |
1548 | 1548 | ) { |
1549 | 1549 | //no error message, no change requested, just nothing to do man. |
1550 | 1550 | return FALSE; |
1551 | 1551 | } |
1552 | 1552 | /** @type EE_Transaction_Processor $transaction_processor */ |
1553 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1553 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1554 | 1554 | // made it here dude? Oh WOW. K, let's take care of changing the statuses |
1555 | 1555 | return $transaction_processor->manually_update_registration_statuses( |
1556 | 1556 | $transaction, |
1557 | - sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ), |
|
1558 | - array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) |
|
1557 | + sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']), |
|
1558 | + array(array('REG_ID' => array('IN', $REG_IDs))) |
|
1559 | 1559 | ); |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1570,16 +1570,16 @@ discard block |
||
1570 | 1570 | * @param bool | null $delete_txn_reg_status_change |
1571 | 1571 | * @return array |
1572 | 1572 | */ |
1573 | - protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) { |
|
1573 | + protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) { |
|
1574 | 1574 | // was the payment deleted ? |
1575 | - if ( is_bool( $delete_txn_reg_status_change )) { |
|
1575 | + if (is_bool($delete_txn_reg_status_change)) { |
|
1576 | 1576 | return array( |
1577 | 1577 | 'PAY_ID' => $payment->ID(), |
1578 | 1578 | 'amount' => $payment->amount(), |
1579 | 1579 | 'total_paid' => $payment->transaction()->paid(), |
1580 | 1580 | 'txn_status' => $payment->transaction()->status_ID(), |
1581 | 1581 | 'pay_status' => $payment->STS_ID(), |
1582 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1582 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1583 | 1583 | 'delete_txn_reg_status_change' => $delete_txn_reg_status_change, |
1584 | 1584 | ); |
1585 | 1585 | } else { |
@@ -1591,16 +1591,16 @@ discard block |
||
1591 | 1591 | 'pay_status' => $payment->STS_ID(), |
1592 | 1592 | 'PAY_ID' => $payment->ID(), |
1593 | 1593 | 'STS_ID' => $payment->STS_ID(), |
1594 | - 'status' => self::$_pay_status[ $payment->STS_ID() ], |
|
1595 | - 'date' => $payment->timestamp( 'Y-m-d', 'h:i a' ), |
|
1596 | - 'method' => strtoupper( $payment->source() ), |
|
1594 | + 'status' => self::$_pay_status[$payment->STS_ID()], |
|
1595 | + 'date' => $payment->timestamp('Y-m-d', 'h:i a'), |
|
1596 | + 'method' => strtoupper($payment->source()), |
|
1597 | 1597 | 'PM_ID' => $payment->payment_method() ? $payment->payment_method()->ID() : 1, |
1598 | - 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__( "Unknown", 'event_espresso' ), |
|
1598 | + 'gateway' => $payment->payment_method() ? $payment->payment_method()->admin_name() : esc_html__("Unknown", 'event_espresso'), |
|
1599 | 1599 | 'gateway_response' => $payment->gateway_response(), |
1600 | 1600 | 'txn_id_chq_nmbr' => $payment->txn_id_chq_nmbr(), |
1601 | 1601 | 'po_number' => $payment->po_number(), |
1602 | 1602 | 'extra_accntng' => $payment->extra_accntng(), |
1603 | - 'registrations' => $this->_registration_payment_data_array( $REG_IDs ), |
|
1603 | + 'registrations' => $this->_registration_payment_data_array($REG_IDs), |
|
1604 | 1604 | ); |
1605 | 1605 | } |
1606 | 1606 | } |
@@ -1615,39 +1615,39 @@ discard block |
||
1615 | 1615 | * @return void |
1616 | 1616 | */ |
1617 | 1617 | public function delete_payment() { |
1618 | - $json_response_data = array( 'return_data' => FALSE ); |
|
1619 | - $PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0; |
|
1620 | - if ( $PAY_ID ) { |
|
1621 | - $delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false; |
|
1622 | - $payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID ); |
|
1623 | - if ( $payment instanceof EE_Payment ) { |
|
1624 | - $REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment ); |
|
1618 | + $json_response_data = array('return_data' => FALSE); |
|
1619 | + $PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0; |
|
1620 | + if ($PAY_ID) { |
|
1621 | + $delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false; |
|
1622 | + $payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID); |
|
1623 | + if ($payment instanceof EE_Payment) { |
|
1624 | + $REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment); |
|
1625 | 1625 | /** @type EE_Transaction_Payments $transaction_payments */ |
1626 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1627 | - if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) { |
|
1628 | - $json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change ); |
|
1629 | - if ( $delete_txn_reg_status_change ) { |
|
1626 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1627 | + if ($transaction_payments->delete_payment_and_update_transaction($payment)) { |
|
1628 | + $json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change); |
|
1629 | + if ($delete_txn_reg_status_change) { |
|
1630 | 1630 | $this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1631 | 1631 | //MAKE sure we also add the delete_txn_req_status_change to the |
1632 | 1632 | //$_REQUEST global because that's how messages will be looking for it. |
1633 | 1633 | $_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change; |
1634 | 1634 | $this->_maybe_send_notifications(); |
1635 | - $this->_process_registration_status_change( $payment->transaction(), $REG_IDs ); |
|
1635 | + $this->_process_registration_status_change($payment->transaction(), $REG_IDs); |
|
1636 | 1636 | } |
1637 | 1637 | } |
1638 | 1638 | } else { |
1639 | 1639 | EE_Error::add_error( |
1640 | - esc_html__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ), |
|
1640 | + esc_html__('Valid Payment data could not be retrieved from the database.', 'event_espresso'), |
|
1641 | 1641 | __FILE__, __FUNCTION__, __LINE__ |
1642 | 1642 | ); |
1643 | 1643 | } |
1644 | 1644 | } else { |
1645 | 1645 | EE_Error::add_error( |
1646 | - esc_html__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ), |
|
1646 | + esc_html__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'), |
|
1647 | 1647 | __FILE__, __FUNCTION__, __LINE__ |
1648 | 1648 | ); |
1649 | 1649 | } |
1650 | - $notices = EE_Error::get_notices( false, false, false); |
|
1650 | + $notices = EE_Error::get_notices(false, false, false); |
|
1651 | 1651 | $this->_template_args = array( |
1652 | 1652 | 'data' => $json_response_data, |
1653 | 1653 | 'success' => $notices['success'], |
@@ -1667,16 +1667,16 @@ discard block |
||
1667 | 1667 | * @param array $REG_IDs |
1668 | 1668 | * @return array |
1669 | 1669 | */ |
1670 | - protected function _registration_payment_data_array( $REG_IDs ) { |
|
1670 | + protected function _registration_payment_data_array($REG_IDs) { |
|
1671 | 1671 | $registration_payment_data = array(); |
1672 | 1672 | //if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows. |
1673 | - if ( ! empty( $REG_IDs ) ) { |
|
1674 | - $registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) ); |
|
1675 | - foreach ( $registrations as $registration ) { |
|
1676 | - if ( $registration instanceof EE_Registration ) { |
|
1677 | - $registration_payment_data[ $registration->ID() ] = array( |
|
1673 | + if ( ! empty($REG_IDs)) { |
|
1674 | + $registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs)))); |
|
1675 | + foreach ($registrations as $registration) { |
|
1676 | + if ($registration instanceof EE_Registration) { |
|
1677 | + $registration_payment_data[$registration->ID()] = array( |
|
1678 | 1678 | 'paid' => $registration->pretty_paid(), |
1679 | - 'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ), |
|
1679 | + 'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()), |
|
1680 | 1680 | ); |
1681 | 1681 | } |
1682 | 1682 | } |
@@ -1696,30 +1696,30 @@ discard block |
||
1696 | 1696 | * @access protected |
1697 | 1697 | * @param \EE_Payment | null $payment |
1698 | 1698 | */ |
1699 | - protected function _maybe_send_notifications( $payment = null ) { |
|
1700 | - switch ( $payment instanceof EE_Payment ) { |
|
1699 | + protected function _maybe_send_notifications($payment = null) { |
|
1700 | + switch ($payment instanceof EE_Payment) { |
|
1701 | 1701 | // payment notifications |
1702 | 1702 | case true : |
1703 | 1703 | if ( |
1704 | 1704 | isset( |
1705 | - $this->_req_data[ 'txn_payments' ], |
|
1706 | - $this->_req_data[ 'txn_payments' ][ 'send_notifications' ] |
|
1705 | + $this->_req_data['txn_payments'], |
|
1706 | + $this->_req_data['txn_payments']['send_notifications'] |
|
1707 | 1707 | ) && |
1708 | - filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1708 | + filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1709 | 1709 | ) { |
1710 | - $this->_process_payment_notification( $payment ); |
|
1710 | + $this->_process_payment_notification($payment); |
|
1711 | 1711 | } |
1712 | 1712 | break; |
1713 | 1713 | // registration notifications |
1714 | 1714 | case false : |
1715 | 1715 | if ( |
1716 | 1716 | isset( |
1717 | - $this->_req_data[ 'txn_reg_status_change' ], |
|
1718 | - $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] |
|
1717 | + $this->_req_data['txn_reg_status_change'], |
|
1718 | + $this->_req_data['txn_reg_status_change']['send_notifications'] |
|
1719 | 1719 | ) && |
1720 | - filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN ) |
|
1720 | + filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN) |
|
1721 | 1721 | ) { |
1722 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
1722 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
1723 | 1723 | } |
1724 | 1724 | break; |
1725 | 1725 | } |
@@ -1735,11 +1735,11 @@ discard block |
||
1735 | 1735 | * @return void |
1736 | 1736 | */ |
1737 | 1737 | protected function _send_payment_reminder() { |
1738 | - $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE; |
|
1739 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1740 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array(); |
|
1741 | - do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction ); |
|
1742 | - $this->_redirect_after_action( FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE ); |
|
1738 | + $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE; |
|
1739 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1740 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array(); |
|
1741 | + do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction); |
|
1742 | + $this->_redirect_after_action(FALSE, esc_html__('payment reminder', 'event_espresso'), esc_html__('sent', 'event_espresso'), $query_args, TRUE); |
|
1743 | 1743 | } |
1744 | 1744 | |
1745 | 1745 | |
@@ -1753,36 +1753,36 @@ discard block |
||
1753 | 1753 | * @param string $view |
1754 | 1754 | * @return mixed int = count || array of transaction objects |
1755 | 1755 | */ |
1756 | - public function get_transactions( $perpage, $count = FALSE, $view = '' ) { |
|
1756 | + public function get_transactions($perpage, $count = FALSE, $view = '') { |
|
1757 | 1757 | |
1758 | 1758 | $TXN = EEM_Transaction::instance(); |
1759 | 1759 | |
1760 | - $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' )); |
|
1761 | - $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' ); |
|
1760 | + $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year')); |
|
1761 | + $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y'); |
|
1762 | 1762 | |
1763 | 1763 | //make sure our timestamps start and end right at the boundaries for each day |
1764 | - $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00'; |
|
1765 | - $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59'; |
|
1764 | + $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00'; |
|
1765 | + $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59'; |
|
1766 | 1766 | |
1767 | 1767 | |
1768 | 1768 | //convert to timestamps |
1769 | - $start_date = strtotime( $start_date ); |
|
1770 | - $end_date = strtotime( $end_date ); |
|
1769 | + $start_date = strtotime($start_date); |
|
1770 | + $end_date = strtotime($end_date); |
|
1771 | 1771 | |
1772 | 1772 | //makes sure start date is the lowest value and vice versa |
1773 | - $start_date = min( $start_date, $end_date ); |
|
1774 | - $end_date = max( $start_date, $end_date ); |
|
1773 | + $start_date = min($start_date, $end_date); |
|
1774 | + $end_date = max($start_date, $end_date); |
|
1775 | 1775 | |
1776 | 1776 | //convert to correct format for query |
1777 | - $start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' ); |
|
1778 | - $end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' ); |
|
1777 | + $start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s'); |
|
1778 | + $end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s'); |
|
1779 | 1779 | |
1780 | 1780 | |
1781 | 1781 | |
1782 | 1782 | //set orderby |
1783 | 1783 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
1784 | 1784 | |
1785 | - switch ( $this->_req_data['orderby'] ) { |
|
1785 | + switch ($this->_req_data['orderby']) { |
|
1786 | 1786 | case 'TXN_ID': |
1787 | 1787 | $orderby = 'TXN_ID'; |
1788 | 1788 | break; |
@@ -1796,66 +1796,66 @@ discard block |
||
1796 | 1796 | $orderby = 'TXN_timestamp'; |
1797 | 1797 | } |
1798 | 1798 | |
1799 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
1800 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
1801 | - $per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10; |
|
1802 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
1799 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
1800 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
1801 | + $per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10; |
|
1802 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
1803 | 1803 | |
1804 | - $offset = ($current_page-1)*$per_page; |
|
1805 | - $limit = array( $offset, $per_page ); |
|
1804 | + $offset = ($current_page - 1) * $per_page; |
|
1805 | + $limit = array($offset, $per_page); |
|
1806 | 1806 | |
1807 | 1807 | $_where = array( |
1808 | - 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ), |
|
1808 | + 'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)), |
|
1809 | 1809 | 'Registration.REG_count' => 1 |
1810 | 1810 | ); |
1811 | 1811 | |
1812 | - if ( isset( $this->_req_data['EVT_ID'] ) ) { |
|
1812 | + if (isset($this->_req_data['EVT_ID'])) { |
|
1813 | 1813 | $_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID']; |
1814 | 1814 | } |
1815 | 1815 | |
1816 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1817 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | + if (isset($this->_req_data['s'])) { |
|
1817 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1818 | 1818 | $_where['OR'] = array( |
1819 | - 'Registration.Event.EVT_name' => array( 'LIKE', $search_string ), |
|
1820 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ), |
|
1821 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ), |
|
1822 | - 'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ), |
|
1823 | - 'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ), |
|
1824 | - 'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ), |
|
1825 | - 'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ), |
|
1826 | - 'Registration.Attendee.ATT_email' => array('LIKE', $search_string ), |
|
1827 | - 'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ), |
|
1828 | - 'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ), |
|
1829 | - 'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ), |
|
1830 | - 'Registration.REG_final_price' => array( 'LIKE', $search_string ), |
|
1831 | - 'Registration.REG_code' => array( 'LIKE', $search_string ), |
|
1832 | - 'Registration.REG_count' => array( 'LIKE' , $search_string ), |
|
1833 | - 'Registration.REG_group_size' => array( 'LIKE' , $search_string ), |
|
1834 | - 'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ), |
|
1835 | - 'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ), |
|
1836 | - 'Payment.PAY_source' => array('LIKE', $search_string ), |
|
1837 | - 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ), |
|
1838 | - 'TXN_session_data' => array( 'LIKE', $search_string ), |
|
1839 | - 'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string ) |
|
1819 | + 'Registration.Event.EVT_name' => array('LIKE', $search_string), |
|
1820 | + 'Registration.Event.EVT_desc' => array('LIKE', $search_string), |
|
1821 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $search_string), |
|
1822 | + 'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string), |
|
1823 | + 'Registration.Attendee.ATT_fname' => array('LIKE', $search_string), |
|
1824 | + 'Registration.Attendee.ATT_lname' => array('LIKE', $search_string), |
|
1825 | + 'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string), |
|
1826 | + 'Registration.Attendee.ATT_email' => array('LIKE', $search_string), |
|
1827 | + 'Registration.Attendee.ATT_address' => array('LIKE', $search_string), |
|
1828 | + 'Registration.Attendee.ATT_address2' => array('LIKE', $search_string), |
|
1829 | + 'Registration.Attendee.ATT_city' => array('LIKE', $search_string), |
|
1830 | + 'Registration.REG_final_price' => array('LIKE', $search_string), |
|
1831 | + 'Registration.REG_code' => array('LIKE', $search_string), |
|
1832 | + 'Registration.REG_count' => array('LIKE', $search_string), |
|
1833 | + 'Registration.REG_group_size' => array('LIKE', $search_string), |
|
1834 | + 'Registration.Ticket.TKT_name' => array('LIKE', $search_string), |
|
1835 | + 'Registration.Ticket.TKT_description' => array('LIKE', $search_string), |
|
1836 | + 'Payment.PAY_source' => array('LIKE', $search_string), |
|
1837 | + 'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string), |
|
1838 | + 'TXN_session_data' => array('LIKE', $search_string), |
|
1839 | + 'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string) |
|
1840 | 1840 | ); |
1841 | 1841 | } |
1842 | 1842 | |
1843 | 1843 | //failed transactions |
1844 | - $failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE; |
|
1845 | - $abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE; |
|
1844 | + $failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE; |
|
1845 | + $abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE; |
|
1846 | 1846 | |
1847 | - if ( $failed ) { |
|
1848 | - $_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code; |
|
1849 | - } else if ( $abandoned ) { |
|
1847 | + if ($failed) { |
|
1848 | + $_where['STS_ID'] = EEM_Transaction::failed_status_code; |
|
1849 | + } else if ($abandoned) { |
|
1850 | 1850 | $_where['STS_ID'] = EEM_Transaction::abandoned_status_code; |
1851 | 1851 | } else { |
1852 | - $_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code ); |
|
1853 | - $_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code ); |
|
1852 | + $_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code); |
|
1853 | + $_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code); |
|
1854 | 1854 | } |
1855 | 1855 | |
1856 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit ); |
|
1856 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit); |
|
1857 | 1857 | |
1858 | - $transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params); |
|
1858 | + $transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params); |
|
1859 | 1859 | |
1860 | 1860 | |
1861 | 1861 | return $transactions; |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | * @param \EE_Dependency_Map $dependency_map |
185 | 185 | * @return \EE_Registry instance |
186 | 186 | */ |
187 | - public static function instance( \EE_Dependency_Map $dependency_map = null ) { |
|
187 | + public static function instance(\EE_Dependency_Map $dependency_map = null) { |
|
188 | 188 | // check if class object is instantiated |
189 | - if ( ! self::$_instance instanceof EE_Registry ) { |
|
190 | - self::$_instance = new EE_Registry( $dependency_map ); |
|
189 | + if ( ! self::$_instance instanceof EE_Registry) { |
|
190 | + self::$_instance = new EE_Registry($dependency_map); |
|
191 | 191 | } |
192 | 192 | return self::$_instance; |
193 | 193 | } |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | * @param \EE_Dependency_Map $dependency_map |
203 | 203 | * @return \EE_Registry |
204 | 204 | */ |
205 | - protected function __construct( \EE_Dependency_Map $dependency_map ) { |
|
205 | + protected function __construct(\EE_Dependency_Map $dependency_map) { |
|
206 | 206 | $this->_dependency_map = $dependency_map; |
207 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
207 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -232,19 +232,19 @@ discard block |
||
232 | 232 | $this->modules = new stdClass(); |
233 | 233 | $this->shortcodes = new stdClass(); |
234 | 234 | $this->widgets = new stdClass(); |
235 | - $this->load_core( 'Base', array(), true ); |
|
235 | + $this->load_core('Base', array(), true); |
|
236 | 236 | // add our request and response objects to the cache |
237 | - $request_loader = $this->_dependency_map->class_loader( 'EE_Request' ); |
|
237 | + $request_loader = $this->_dependency_map->class_loader('EE_Request'); |
|
238 | 238 | $this->_set_cached_class( |
239 | 239 | $request_loader(), |
240 | 240 | 'EE_Request' |
241 | 241 | ); |
242 | - $response_loader = $this->_dependency_map->class_loader( 'EE_Response' ); |
|
242 | + $response_loader = $this->_dependency_map->class_loader('EE_Response'); |
|
243 | 243 | $this->_set_cached_class( |
244 | 244 | $response_loader(), |
245 | 245 | 'EE_Response' |
246 | 246 | ); |
247 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) ); |
|
247 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -257,10 +257,10 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function init() { |
259 | 259 | // Get current page protocol |
260 | - $protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://'; |
|
260 | + $protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://'; |
|
261 | 261 | // Output admin-ajax.php URL with same protocol as current page |
262 | - self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol ); |
|
263 | - self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false; |
|
262 | + self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol); |
|
263 | + self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -271,14 +271,14 @@ discard block |
||
271 | 271 | * @return string |
272 | 272 | */ |
273 | 273 | public static function localize_i18n_js_strings() { |
274 | - $i18n_js_strings = (array)EE_Registry::$i18n_js_strings; |
|
275 | - foreach ( $i18n_js_strings as $key => $value ) { |
|
276 | - if ( is_scalar( $value ) ) { |
|
277 | - $i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' ); |
|
274 | + $i18n_js_strings = (array) EE_Registry::$i18n_js_strings; |
|
275 | + foreach ($i18n_js_strings as $key => $value) { |
|
276 | + if (is_scalar($value)) { |
|
277 | + $i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8'); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */'; |
|
281 | + return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */'; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | /** |
287 | 287 | * @param mixed string | EED_Module $module |
288 | 288 | */ |
289 | - public function add_module( $module ) { |
|
290 | - if ( $module instanceof EED_Module ) { |
|
291 | - $module_class = get_class( $module ); |
|
289 | + public function add_module($module) { |
|
290 | + if ($module instanceof EED_Module) { |
|
291 | + $module_class = get_class($module); |
|
292 | 292 | $this->modules->{$module_class} = $module; |
293 | 293 | } else { |
294 | - if ( ! class_exists( 'EE_Module_Request_Router' ) ) { |
|
295 | - $this->load_core( 'Module_Request_Router' ); |
|
294 | + if ( ! class_exists('EE_Module_Request_Router')) { |
|
295 | + $this->load_core('Module_Request_Router'); |
|
296 | 296 | } |
297 | - $this->modules->{$module} = EE_Module_Request_Router::module_factory( $module ); |
|
297 | + $this->modules->{$module} = EE_Module_Request_Router::module_factory($module); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * @param string $module_name |
305 | 305 | * @return mixed EED_Module | NULL |
306 | 306 | */ |
307 | - public function get_module( $module_name = '' ) { |
|
308 | - return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
307 | + public function get_module($module_name = '') { |
|
308 | + return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | * @param bool $load_only |
320 | 320 | * @return mixed |
321 | 321 | */ |
322 | - public function load_core( $class_name, $arguments = array(), $load_only = false ) { |
|
322 | + public function load_core($class_name, $arguments = array(), $load_only = false) { |
|
323 | 323 | $core_paths = apply_filters( |
324 | 324 | 'FHEE__EE_Registry__load_core__core_paths', |
325 | 325 | array( |
326 | 326 | EE_CORE, |
327 | 327 | EE_ADMIN, |
328 | 328 | EE_CPTS, |
329 | - EE_CORE . 'data_migration_scripts' . DS, |
|
330 | - EE_CORE . 'request_stack' . DS, |
|
331 | - EE_CORE . 'middleware' . DS, |
|
329 | + EE_CORE.'data_migration_scripts'.DS, |
|
330 | + EE_CORE.'request_stack'.DS, |
|
331 | + EE_CORE.'middleware'.DS, |
|
332 | 332 | ) |
333 | 333 | ); |
334 | 334 | // retrieve instantiated class |
335 | - return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only ); |
|
335 | + return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -346,15 +346,15 @@ discard block |
||
346 | 346 | * @param bool $load_only |
347 | 347 | * @return mixed |
348 | 348 | */ |
349 | - public function load_service( $class_name, $arguments = array(), $load_only = false ) { |
|
349 | + public function load_service($class_name, $arguments = array(), $load_only = false) { |
|
350 | 350 | $service_paths = apply_filters( |
351 | 351 | 'FHEE__EE_Registry__load_service__service_paths', |
352 | 352 | array( |
353 | - EE_CORE . 'services' . DS, |
|
353 | + EE_CORE.'services'.DS, |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | // retrieve instantiated class |
357 | - return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only ); |
|
357 | + return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @param mixed $arguments |
368 | 368 | * @return EE_Data_Migration_Script_Base|mixed |
369 | 369 | */ |
370 | - public function load_dms( $class_name, $arguments = array() ) { |
|
370 | + public function load_dms($class_name, $arguments = array()) { |
|
371 | 371 | // retrieve instantiated class |
372 | - return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false ); |
|
372 | + return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -384,14 +384,14 @@ discard block |
||
384 | 384 | * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default) |
385 | 385 | * @return EE_Base_Class | bool |
386 | 386 | */ |
387 | - public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) { |
|
388 | - $paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array( |
|
387 | + public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) { |
|
388 | + $paths = apply_filters('FHEE__EE_Registry__load_class__paths', array( |
|
389 | 389 | EE_CORE, |
390 | 390 | EE_CLASSES, |
391 | 391 | EE_BUSINESS |
392 | - ) ); |
|
392 | + )); |
|
393 | 393 | // retrieve instantiated class |
394 | - return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only ); |
|
394 | + return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | * @param bool $load_only |
405 | 405 | * @return EEH_Base | bool |
406 | 406 | */ |
407 | - public function load_helper( $class_name, $arguments = array(), $load_only = true ) { |
|
407 | + public function load_helper($class_name, $arguments = array(), $load_only = true) { |
|
408 | 408 | // todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed |
409 | - $helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) ); |
|
409 | + $helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS)); |
|
410 | 410 | // retrieve instantiated class |
411 | - return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only ); |
|
411 | + return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | * @param bool $cache whether to cache the object or not. |
424 | 424 | * @return mixed |
425 | 425 | */ |
426 | - public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) { |
|
426 | + public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) { |
|
427 | 427 | $paths = array( |
428 | 428 | EE_LIBRARIES, |
429 | - EE_LIBRARIES . 'messages' . DS, |
|
430 | - EE_LIBRARIES . 'shortcodes' . DS, |
|
431 | - EE_LIBRARIES . 'qtips' . DS, |
|
432 | - EE_LIBRARIES . 'payment_methods' . DS, |
|
429 | + EE_LIBRARIES.'messages'.DS, |
|
430 | + EE_LIBRARIES.'shortcodes'.DS, |
|
431 | + EE_LIBRARIES.'qtips'.DS, |
|
432 | + EE_LIBRARIES.'payment_methods'.DS, |
|
433 | 433 | ); |
434 | 434 | // retrieve instantiated class |
435 | - return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only ); |
|
435 | + return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -445,13 +445,13 @@ discard block |
||
445 | 445 | * @param bool $load_only |
446 | 446 | * @return EEM_Base | bool |
447 | 447 | */ |
448 | - public function load_model( $class_name, $arguments = array(), $load_only = false ) { |
|
449 | - $paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array( |
|
448 | + public function load_model($class_name, $arguments = array(), $load_only = false) { |
|
449 | + $paths = apply_filters('FHEE__EE_Registry__load_model__paths', array( |
|
450 | 450 | EE_MODELS, |
451 | 451 | EE_CORE |
452 | - ) ); |
|
452 | + )); |
|
453 | 453 | // retrieve instantiated class |
454 | - return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only ); |
|
454 | + return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | * @param bool $load_only |
465 | 465 | * @return mixed | bool |
466 | 466 | */ |
467 | - public function load_model_class( $class_name, $arguments = array(), $load_only = true ) { |
|
467 | + public function load_model_class($class_name, $arguments = array(), $load_only = true) { |
|
468 | 468 | $paths = array( |
469 | - EE_MODELS . 'fields' . DS, |
|
470 | - EE_MODELS . 'helpers' . DS, |
|
471 | - EE_MODELS . 'relations' . DS, |
|
472 | - EE_MODELS . 'strategies' . DS |
|
469 | + EE_MODELS.'fields'.DS, |
|
470 | + EE_MODELS.'helpers'.DS, |
|
471 | + EE_MODELS.'relations'.DS, |
|
472 | + EE_MODELS.'strategies'.DS |
|
473 | 473 | ); |
474 | 474 | // retrieve instantiated class |
475 | - return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only ); |
|
475 | + return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $model_name like Event, Attendee, Question_Group_Question, etc. |
483 | 483 | * @return boolean |
484 | 484 | */ |
485 | - public function is_model_name( $model_name ) { |
|
486 | - return isset( $this->models[ $model_name ] ) ? true : false; |
|
485 | + public function is_model_name($model_name) { |
|
486 | + return isset($this->models[$model_name]) ? true : false; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @param bool $load_only |
499 | 499 | * @return mixed |
500 | 500 | */ |
501 | - public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) { |
|
501 | + public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) { |
|
502 | 502 | // retrieve instantiated class |
503 | - return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only ); |
|
503 | + return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -515,9 +515,9 @@ discard block |
||
515 | 515 | * @param bool $load_only |
516 | 516 | * @return EE_Addon |
517 | 517 | */ |
518 | - public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) { |
|
518 | + public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) { |
|
519 | 519 | // retrieve instantiated class |
520 | - return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only ); |
|
520 | + return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -548,35 +548,35 @@ discard block |
||
548 | 548 | $load_only = false, |
549 | 549 | $addon = false |
550 | 550 | ) { |
551 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
552 | - if ( ! class_exists( $class_name ) ) { |
|
551 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
552 | + if ( ! class_exists($class_name)) { |
|
553 | 553 | // maybe the class is registered with a preceding \ |
554 | - $class_name = strpos( $class_name, '\\' ) !== 0 ? '\\' . $class_name : $class_name; |
|
554 | + $class_name = strpos($class_name, '\\') !== 0 ? '\\'.$class_name : $class_name; |
|
555 | 555 | // still doesn't exist ? |
556 | - if ( ! class_exists( $class_name ) ) { |
|
556 | + if ( ! class_exists($class_name)) { |
|
557 | 557 | return null; |
558 | 558 | } |
559 | 559 | } |
560 | 560 | // if we're only loading the class and it already exists, then let's just return true immediately |
561 | - if ( $load_only ) { |
|
561 | + if ($load_only) { |
|
562 | 562 | return true; |
563 | 563 | } |
564 | 564 | $addon = $addon ? 'addon' : ''; |
565 | 565 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
566 | 566 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
567 | 567 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
568 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
568 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
569 | 569 | // return object if it's already cached |
570 | - $cached_class = $this->_get_cached_class( $class_name, $addon ); |
|
571 | - if ( $cached_class !== null ) { |
|
570 | + $cached_class = $this->_get_cached_class($class_name, $addon); |
|
571 | + if ($cached_class !== null) { |
|
572 | 572 | return $cached_class; |
573 | 573 | } |
574 | 574 | } |
575 | 575 | // instantiate the requested object |
576 | - $class_obj = $this->_create_object( $class_name, $arguments, $addon, $from_db ); |
|
577 | - if ( $this->_cache_on && $cache ) { |
|
576 | + $class_obj = $this->_create_object($class_name, $arguments, $addon, $from_db); |
|
577 | + if ($this->_cache_on && $cache) { |
|
578 | 578 | // save it for later... kinda like gum { : $ |
579 | - $this->_set_cached_class( $class_obj, $class_name, $addon, $from_db ); |
|
579 | + $this->_set_cached_class($class_obj, $class_name, $addon, $from_db); |
|
580 | 580 | } |
581 | 581 | $this->_cache_on = true; |
582 | 582 | return $class_obj; |
@@ -611,47 +611,47 @@ discard block |
||
611 | 611 | $load_only = false |
612 | 612 | ) { |
613 | 613 | // strip php file extension |
614 | - $class_name = str_replace( '.php', '', trim( $class_name ) ); |
|
614 | + $class_name = str_replace('.php', '', trim($class_name)); |
|
615 | 615 | // does the class have a prefix ? |
616 | - if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) { |
|
616 | + if ( ! empty($class_prefix) && $class_prefix != 'addon') { |
|
617 | 617 | // make sure $class_prefix is uppercase |
618 | - $class_prefix = strtoupper( trim( $class_prefix ) ); |
|
618 | + $class_prefix = strtoupper(trim($class_prefix)); |
|
619 | 619 | // add class prefix ONCE!!! |
620 | - $class_name = $class_prefix . str_replace( $class_prefix, '', $class_name ); |
|
620 | + $class_name = $class_prefix.str_replace($class_prefix, '', $class_name); |
|
621 | 621 | } |
622 | - $class_name = $this->_dependency_map->get_alias( $class_name ); |
|
623 | - $class_exists = class_exists( $class_name ); |
|
622 | + $class_name = $this->_dependency_map->get_alias($class_name); |
|
623 | + $class_exists = class_exists($class_name); |
|
624 | 624 | // if we're only loading the class and it already exists, then let's just return true immediately |
625 | - if ( $load_only && $class_exists ) { |
|
625 | + if ($load_only && $class_exists) { |
|
626 | 626 | return true; |
627 | 627 | } |
628 | 628 | // $this->_cache_on is toggled during the recursive loading that can occur with dependency injection |
629 | 629 | // $cache is controlled by individual calls to separate Registry loader methods like load_class() |
630 | 630 | // $load_only is also controlled by individual calls to separate Registry loader methods like load_file() |
631 | - if ( $this->_cache_on && $cache && ! $load_only ) { |
|
631 | + if ($this->_cache_on && $cache && ! $load_only) { |
|
632 | 632 | // return object if it's already cached |
633 | - $cached_class = $this->_get_cached_class( $class_name, $class_prefix ); |
|
634 | - if ( $cached_class !== null ) { |
|
633 | + $cached_class = $this->_get_cached_class($class_name, $class_prefix); |
|
634 | + if ($cached_class !== null) { |
|
635 | 635 | return $cached_class; |
636 | 636 | } |
637 | 637 | } |
638 | 638 | // if the class doesn't already exist.. then we need to try and find the file and load it |
639 | - if ( ! $class_exists ) { |
|
639 | + if ( ! $class_exists) { |
|
640 | 640 | // get full path to file |
641 | - $path = $this->_resolve_path( $class_name, $type, $file_paths ); |
|
641 | + $path = $this->_resolve_path($class_name, $type, $file_paths); |
|
642 | 642 | // load the file |
643 | - $loaded = $this->_require_file( $path, $class_name, $type, $file_paths ); |
|
643 | + $loaded = $this->_require_file($path, $class_name, $type, $file_paths); |
|
644 | 644 | // if loading failed, or we are only loading a file but NOT instantiating an object |
645 | - if ( ! $loaded || $load_only ) { |
|
645 | + if ( ! $loaded || $load_only) { |
|
646 | 646 | // return boolean if only loading, or null if an object was expected |
647 | 647 | return $load_only ? $loaded : null; |
648 | 648 | } |
649 | 649 | } |
650 | 650 | // instantiate the requested object |
651 | - $class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db ); |
|
652 | - if ( $this->_cache_on && $cache ) { |
|
651 | + $class_obj = $this->_create_object($class_name, $arguments, $type, $from_db); |
|
652 | + if ($this->_cache_on && $cache) { |
|
653 | 653 | // save it for later... kinda like gum { : $ |
654 | - $this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db ); |
|
654 | + $this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db); |
|
655 | 655 | } |
656 | 656 | $this->_cache_on = true; |
657 | 657 | return $class_obj; |
@@ -674,21 +674,21 @@ discard block |
||
674 | 674 | * @param string $class_prefix |
675 | 675 | * @return mixed |
676 | 676 | */ |
677 | - protected function _get_cached_class( $class_name, $class_prefix = '' ) { |
|
678 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
679 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
677 | + protected function _get_cached_class($class_name, $class_prefix = '') { |
|
678 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
679 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
680 | 680 | } else { |
681 | 681 | // have to specify something, but not anything that will conflict |
682 | 682 | $class_abbreviation = 'FANCY_BATMAN_PANTS'; |
683 | 683 | } |
684 | 684 | // check if class has already been loaded, and return it if it has been |
685 | - if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) { |
|
685 | + if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) { |
|
686 | 686 | return $this->{$class_abbreviation}; |
687 | - } else if ( isset ( $this->{$class_name} ) ) { |
|
687 | + } else if (isset ($this->{$class_name} )) { |
|
688 | 688 | return $this->{$class_name}; |
689 | - } else if ( isset ( $this->LIB->{$class_name} ) ) { |
|
689 | + } else if (isset ($this->LIB->{$class_name} )) { |
|
690 | 690 | return $this->LIB->{$class_name}; |
691 | - } else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) { |
|
691 | + } else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) { |
|
692 | 692 | return $this->addons->{$class_name}; |
693 | 693 | } |
694 | 694 | return null; |
@@ -709,20 +709,20 @@ discard block |
||
709 | 709 | * @param array $file_paths |
710 | 710 | * @return string | bool |
711 | 711 | */ |
712 | - protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) { |
|
712 | + protected function _resolve_path($class_name, $type = '', $file_paths = array()) { |
|
713 | 713 | // make sure $file_paths is an array |
714 | - $file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths ); |
|
714 | + $file_paths = is_array($file_paths) ? $file_paths : array($file_paths); |
|
715 | 715 | // cycle thru paths |
716 | - foreach ( $file_paths as $key => $file_path ) { |
|
716 | + foreach ($file_paths as $key => $file_path) { |
|
717 | 717 | // convert all separators to proper DS, if no filepath, then use EE_CLASSES |
718 | - $file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES; |
|
718 | + $file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES; |
|
719 | 719 | // prep file type |
720 | - $type = ! empty( $type ) ? trim( $type, '.' ) . '.' : ''; |
|
720 | + $type = ! empty($type) ? trim($type, '.').'.' : ''; |
|
721 | 721 | // build full file path |
722 | - $file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php'; |
|
722 | + $file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php'; |
|
723 | 723 | //does the file exist and can be read ? |
724 | - if ( is_readable( $file_paths[ $key ] ) ) { |
|
725 | - return $file_paths[ $key ]; |
|
724 | + if (is_readable($file_paths[$key])) { |
|
725 | + return $file_paths[$key]; |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | return false; |
@@ -744,29 +744,29 @@ discard block |
||
744 | 744 | * @return boolean |
745 | 745 | * @throws \EE_Error |
746 | 746 | */ |
747 | - protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) { |
|
747 | + protected function _require_file($path, $class_name, $type = '', $file_paths = array()) { |
|
748 | 748 | // don't give up! you gotta... |
749 | 749 | try { |
750 | 750 | //does the file exist and can it be read ? |
751 | - if ( ! $path ) { |
|
751 | + if ( ! $path) { |
|
752 | 752 | // so sorry, can't find the file |
753 | - throw new EE_Error ( |
|
753 | + throw new EE_Error( |
|
754 | 754 | sprintf( |
755 | - __( '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' ), |
|
756 | - trim( $type, '.' ), |
|
755 | + __('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'), |
|
756 | + trim($type, '.'), |
|
757 | 757 | $class_name, |
758 | - '<br />' . implode( ',<br />', $file_paths ) |
|
758 | + '<br />'.implode(',<br />', $file_paths) |
|
759 | 759 | ) |
760 | 760 | ); |
761 | 761 | } |
762 | 762 | // get the file |
763 | - require_once( $path ); |
|
763 | + require_once($path); |
|
764 | 764 | // if the class isn't already declared somewhere |
765 | - if ( class_exists( $class_name, false ) === false ) { |
|
765 | + if (class_exists($class_name, false) === false) { |
|
766 | 766 | // so sorry, not a class |
767 | 767 | throw new EE_Error( |
768 | 768 | sprintf( |
769 | - __( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ), |
|
769 | + __('The %s file %s does not appear to contain the %s Class.', 'event_espresso'), |
|
770 | 770 | $type, |
771 | 771 | $path, |
772 | 772 | $class_name |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | ); |
775 | 775 | } |
776 | 776 | |
777 | - } catch ( EE_Error $e ) { |
|
777 | + } catch (EE_Error $e) { |
|
778 | 778 | $e->get_error(); |
779 | 779 | return false; |
780 | 780 | } |
@@ -806,61 +806,61 @@ discard block |
||
806 | 806 | * @return null | object |
807 | 807 | * @throws \EE_Error |
808 | 808 | */ |
809 | - protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) { |
|
809 | + protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) { |
|
810 | 810 | $class_obj = null; |
811 | 811 | $instantiation_mode = '0) none'; |
812 | 812 | // don't give up! you gotta... |
813 | 813 | try { |
814 | 814 | // create reflection |
815 | - $reflector = $this->get_ReflectionClass( $class_name ); |
|
815 | + $reflector = $this->get_ReflectionClass($class_name); |
|
816 | 816 | // make sure arguments are an array |
817 | - $arguments = is_array( $arguments ) ? $arguments : array( $arguments ); |
|
817 | + $arguments = is_array($arguments) ? $arguments : array($arguments); |
|
818 | 818 | // and if arguments array is numerically and sequentially indexed, then we want it to remain as is, |
819 | 819 | // else wrap it in an additional array so that it doesn't get split into multiple parameters |
820 | - $arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments ) |
|
820 | + $arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments) |
|
821 | 821 | ? $arguments |
822 | - : array( $arguments ); |
|
822 | + : array($arguments); |
|
823 | 823 | // attempt to inject dependencies ? |
824 | - if ( $this->_dependency_map->has( $class_name ) ) { |
|
825 | - $arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments ); |
|
824 | + if ($this->_dependency_map->has($class_name)) { |
|
825 | + $arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments); |
|
826 | 826 | } |
827 | 827 | // instantiate the class if possible |
828 | - if ( $reflector->isAbstract() ) { |
|
828 | + if ($reflector->isAbstract()) { |
|
829 | 829 | // nothing to instantiate, loading file was enough |
830 | 830 | // does not throw an exception so $instantiation_mode is unused |
831 | 831 | // $instantiation_mode = "1) no constructor abstract class"; |
832 | 832 | $class_obj = true; |
833 | - } else if ( $reflector->getConstructor() === null && $reflector->isInstantiable() && empty( $arguments ) ) { |
|
833 | + } else if ($reflector->getConstructor() === null && $reflector->isInstantiable() && empty($arguments)) { |
|
834 | 834 | // no constructor = static methods only... nothing to instantiate, loading file was enough |
835 | 835 | $instantiation_mode = "2) no constructor but instantiable"; |
836 | 836 | $class_obj = $reflector->newInstance(); |
837 | - } else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) { |
|
837 | + } else if ($from_db && method_exists($class_name, 'new_instance_from_db')) { |
|
838 | 838 | $instantiation_mode = "3) new_instance_from_db()"; |
839 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments ); |
|
840 | - } else if ( method_exists( $class_name, 'new_instance' ) ) { |
|
839 | + $class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments); |
|
840 | + } else if (method_exists($class_name, 'new_instance')) { |
|
841 | 841 | $instantiation_mode = "4) new_instance()"; |
842 | - $class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments ); |
|
843 | - } else if ( method_exists( $class_name, 'instance' ) ) { |
|
842 | + $class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments); |
|
843 | + } else if (method_exists($class_name, 'instance')) { |
|
844 | 844 | $instantiation_mode = "5) instance()"; |
845 | - $class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments ); |
|
846 | - } else if ( $reflector->isInstantiable() ) { |
|
845 | + $class_obj = call_user_func_array(array($class_name, 'instance'), $arguments); |
|
846 | + } else if ($reflector->isInstantiable()) { |
|
847 | 847 | $instantiation_mode = "6) constructor"; |
848 | - $class_obj = $reflector->newInstanceArgs( $arguments ); |
|
848 | + $class_obj = $reflector->newInstanceArgs($arguments); |
|
849 | 849 | } else { |
850 | 850 | // heh ? something's not right ! |
851 | 851 | throw new EE_Error( |
852 | 852 | sprintf( |
853 | - __( 'The %s file %s could not be instantiated.', 'event_espresso' ), |
|
853 | + __('The %s file %s could not be instantiated.', 'event_espresso'), |
|
854 | 854 | $type, |
855 | 855 | $class_name |
856 | 856 | ) |
857 | 857 | ); |
858 | 858 | } |
859 | - } catch ( Exception $e ) { |
|
860 | - if ( ! $e instanceof EE_Error ) { |
|
859 | + } catch (Exception $e) { |
|
860 | + if ( ! $e instanceof EE_Error) { |
|
861 | 861 | $e = new EE_Error( |
862 | 862 | sprintf( |
863 | - __( 'The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso' ), |
|
863 | + __('The following error occurred while attempting to instantiate "%1$s": %2$s %3$s %2$s instantiation mode : %4$s', 'event_espresso'), |
|
864 | 864 | $class_name, |
865 | 865 | '<br />', |
866 | 866 | $e->getMessage(), |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param array $array |
881 | 881 | * @return bool |
882 | 882 | */ |
883 | - protected function _array_is_numerically_and_sequentially_indexed( array $array ) { |
|
884 | - return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true; |
|
883 | + protected function _array_is_numerically_and_sequentially_indexed(array $array) { |
|
884 | + return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | |
@@ -896,14 +896,14 @@ discard block |
||
896 | 896 | * @param string $class_name |
897 | 897 | * @return ReflectionClass |
898 | 898 | */ |
899 | - public function get_ReflectionClass( $class_name ) { |
|
899 | + public function get_ReflectionClass($class_name) { |
|
900 | 900 | if ( |
901 | - ! isset( $this->_reflectors[ $class_name ] ) |
|
902 | - || ! $this->_reflectors[ $class_name ] instanceof ReflectionClass |
|
901 | + ! isset($this->_reflectors[$class_name]) |
|
902 | + || ! $this->_reflectors[$class_name] instanceof ReflectionClass |
|
903 | 903 | ) { |
904 | - $this->_reflectors[ $class_name ] = new ReflectionClass( $class_name ); |
|
904 | + $this->_reflectors[$class_name] = new ReflectionClass($class_name); |
|
905 | 905 | } |
906 | - return $this->_reflectors[ $class_name ]; |
|
906 | + return $this->_reflectors[$class_name]; |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | |
@@ -928,50 +928,50 @@ discard block |
||
928 | 928 | * @return array |
929 | 929 | * @throws \ReflectionException |
930 | 930 | */ |
931 | - protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) { |
|
931 | + protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) { |
|
932 | 932 | // let's examine the constructor |
933 | 933 | $constructor = $reflector->getConstructor(); |
934 | 934 | // whu? huh? nothing? |
935 | - if ( ! $constructor ) { |
|
935 | + if ( ! $constructor) { |
|
936 | 936 | return $arguments; |
937 | 937 | } |
938 | 938 | // get constructor parameters |
939 | 939 | $params = $constructor->getParameters(); |
940 | 940 | // and the keys for the incoming arguments array so that we can compare existing arguments with what is expected |
941 | - $argument_keys = array_keys( $arguments ); |
|
941 | + $argument_keys = array_keys($arguments); |
|
942 | 942 | // now loop thru all of the constructors expected parameters |
943 | - foreach ( $params as $index => $param ) { |
|
943 | + foreach ($params as $index => $param) { |
|
944 | 944 | // is this a dependency for a specific class ? |
945 | 945 | $param_class = $param->getClass() ? $param->getClass()->name : null; |
946 | 946 | if ( |
947 | 947 | // param is not even a class |
948 | - empty( $param_class ) |
|
948 | + empty($param_class) |
|
949 | 949 | // and something already exists in the incoming arguments for this param |
950 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
950 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
951 | 951 | ) { |
952 | 952 | // so let's skip this argument and move on to the next |
953 | 953 | continue; |
954 | 954 | } else if ( |
955 | 955 | // parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class |
956 | - ! empty( $param_class ) |
|
957 | - && isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] ) |
|
958 | - && $arguments[ $argument_keys[ $index ] ] instanceof $param_class |
|
956 | + ! empty($param_class) |
|
957 | + && isset($argument_keys[$index], $arguments[$argument_keys[$index]]) |
|
958 | + && $arguments[$argument_keys[$index]] instanceof $param_class |
|
959 | 959 | ) { |
960 | 960 | // skip this argument and move on to the next |
961 | 961 | continue; |
962 | 962 | } else if ( |
963 | 963 | // parameter is type hinted as a class, and should be injected |
964 | - ! empty( $param_class ) |
|
965 | - && $this->_dependency_map->has_dependency_for_class( $class_name, $param_class ) |
|
964 | + ! empty($param_class) |
|
965 | + && $this->_dependency_map->has_dependency_for_class($class_name, $param_class) |
|
966 | 966 | ) { |
967 | - $arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index ); |
|
967 | + $arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index); |
|
968 | 968 | } else { |
969 | 969 | try { |
970 | - $arguments[ $index ] = $param->getDefaultValue(); |
|
971 | - } catch ( ReflectionException $e ) { |
|
970 | + $arguments[$index] = $param->getDefaultValue(); |
|
971 | + } catch (ReflectionException $e) { |
|
972 | 972 | throw new ReflectionException( |
973 | 973 | sprintf( |
974 | - __( '%1$s for parameter "$%2$s"', 'event_espresso' ), |
|
974 | + __('%1$s for parameter "$%2$s"', 'event_espresso'), |
|
975 | 975 | $e->getMessage(), |
976 | 976 | $param->getName() |
977 | 977 | ) |
@@ -993,30 +993,30 @@ discard block |
||
993 | 993 | * @param mixed $index |
994 | 994 | * @return array |
995 | 995 | */ |
996 | - protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) { |
|
996 | + protected function _resolve_dependency($class_name, $param_class, $arguments, $index) { |
|
997 | 997 | $dependency = null; |
998 | 998 | // should dependency be loaded from cache ? |
999 | - $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency( $class_name, $param_class ) |
|
999 | + $cache_on = $this->_dependency_map->loading_strategy_for_class_dependency($class_name, $param_class) |
|
1000 | 1000 | !== EE_Dependency_Map::load_new_object |
1001 | 1001 | ? true |
1002 | 1002 | : false; |
1003 | 1003 | // we might have a dependency... |
1004 | 1004 | // let's MAYBE try and find it in our cache if that's what's been requested |
1005 | - $cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null; |
|
1005 | + $cached_class = $cache_on ? $this->_get_cached_class($param_class) : null; |
|
1006 | 1006 | // and grab it if it exists |
1007 | - if ( $cached_class instanceof $param_class ) { |
|
1007 | + if ($cached_class instanceof $param_class) { |
|
1008 | 1008 | $dependency = $cached_class; |
1009 | - } else if ( $param_class != $class_name ) { |
|
1009 | + } else if ($param_class != $class_name) { |
|
1010 | 1010 | // obtain the loader method from the dependency map |
1011 | - $loader = $this->_dependency_map->class_loader( $param_class ); |
|
1011 | + $loader = $this->_dependency_map->class_loader($param_class); |
|
1012 | 1012 | // is loader a custom closure ? |
1013 | - if ( $loader instanceof Closure ) { |
|
1013 | + if ($loader instanceof Closure) { |
|
1014 | 1014 | $dependency = $loader(); |
1015 | 1015 | } else { |
1016 | 1016 | // set the cache on property for the recursive loading call |
1017 | 1017 | $this->_cache_on = $cache_on; |
1018 | 1018 | // if not, then let's try and load it via the registry |
1019 | - if ( method_exists( $this, $loader ) ) { |
|
1019 | + if (method_exists($this, $loader)) { |
|
1020 | 1020 | $dependency = $this->{$loader}($param_class); |
1021 | 1021 | } else { |
1022 | 1022 | $dependency = $this->create($param_class, array(), $cache_on); |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | // did we successfully find the correct dependency ? |
1027 | - if ( $dependency instanceof $param_class ) { |
|
1027 | + if ($dependency instanceof $param_class) { |
|
1028 | 1028 | // then let's inject it into the incoming array of arguments at the correct location |
1029 | - if ( isset( $argument_keys[ $index ] ) ) { |
|
1030 | - $arguments[ $argument_keys[ $index ] ] = $dependency; |
|
1029 | + if (isset($argument_keys[$index])) { |
|
1030 | + $arguments[$argument_keys[$index]] = $dependency; |
|
1031 | 1031 | } else { |
1032 | - $arguments[ $index ] = $dependency; |
|
1032 | + $arguments[$index] = $dependency; |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | return $arguments; |
@@ -1054,19 +1054,19 @@ discard block |
||
1054 | 1054 | * @param bool $from_db |
1055 | 1055 | * @return void |
1056 | 1056 | */ |
1057 | - protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) { |
|
1058 | - if ( empty( $class_obj ) ) { |
|
1057 | + protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) { |
|
1058 | + if (empty($class_obj)) { |
|
1059 | 1059 | return; |
1060 | 1060 | } |
1061 | 1061 | // return newly instantiated class |
1062 | - if ( isset( $this->_class_abbreviations[ $class_name ] ) ) { |
|
1063 | - $class_abbreviation = $this->_class_abbreviations[ $class_name ]; |
|
1062 | + if (isset($this->_class_abbreviations[$class_name])) { |
|
1063 | + $class_abbreviation = $this->_class_abbreviations[$class_name]; |
|
1064 | 1064 | $this->{$class_abbreviation} = $class_obj; |
1065 | - } else if ( property_exists( $this, $class_name ) ) { |
|
1065 | + } else if (property_exists($this, $class_name)) { |
|
1066 | 1066 | $this->{$class_name} = $class_obj; |
1067 | - } else if ( $class_prefix == 'addon' ) { |
|
1067 | + } else if ($class_prefix == 'addon') { |
|
1068 | 1068 | $this->addons->{$class_name} = $class_obj; |
1069 | - } else if ( ! $from_db ) { |
|
1069 | + } else if ( ! $from_db) { |
|
1070 | 1070 | $this->LIB->{$class_name} = $class_obj; |
1071 | 1071 | } |
1072 | 1072 | } |
@@ -1083,12 +1083,12 @@ discard block |
||
1083 | 1083 | * @param array $arguments |
1084 | 1084 | * @return object |
1085 | 1085 | */ |
1086 | - public static function factory( $classname, $arguments = array() ) { |
|
1087 | - $loader = self::instance()->_dependency_map->class_loader( $classname ); |
|
1088 | - if ( $loader instanceof Closure ) { |
|
1089 | - return $loader( $arguments ); |
|
1090 | - } else if ( method_exists( EE_Registry::instance(), $loader ) ) { |
|
1091 | - return EE_Registry::instance()->{$loader}( $classname, $arguments ); |
|
1086 | + public static function factory($classname, $arguments = array()) { |
|
1087 | + $loader = self::instance()->_dependency_map->class_loader($classname); |
|
1088 | + if ($loader instanceof Closure) { |
|
1089 | + return $loader($arguments); |
|
1090 | + } else if (method_exists(EE_Registry::instance(), $loader)) { |
|
1091 | + return EE_Registry::instance()->{$loader}($classname, $arguments); |
|
1092 | 1092 | } |
1093 | 1093 | return null; |
1094 | 1094 | } |
@@ -1101,9 +1101,9 @@ discard block |
||
1101 | 1101 | * @param string $name |
1102 | 1102 | * @return EE_Addon |
1103 | 1103 | */ |
1104 | - public function get_addon_by_name( $name ) { |
|
1105 | - foreach ( $this->addons as $addon ) { |
|
1106 | - if ( $addon->name() == $name ) { |
|
1104 | + public function get_addon_by_name($name) { |
|
1105 | + foreach ($this->addons as $addon) { |
|
1106 | + if ($addon->name() == $name) { |
|
1107 | 1107 | return $addon; |
1108 | 1108 | } |
1109 | 1109 | } |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | */ |
1120 | 1120 | public function get_addons_by_name() { |
1121 | 1121 | $addons = array(); |
1122 | - foreach ( $this->addons as $addon ) { |
|
1123 | - $addons[ $addon->name() ] = $addon; |
|
1122 | + foreach ($this->addons as $addon) { |
|
1123 | + $addons[$addon->name()] = $addon; |
|
1124 | 1124 | } |
1125 | 1125 | return $addons; |
1126 | 1126 | } |
@@ -1135,16 +1135,16 @@ discard block |
||
1135 | 1135 | * @return \EEM_Base |
1136 | 1136 | * @throws \EE_Error |
1137 | 1137 | */ |
1138 | - public function reset_model( $model_name ) { |
|
1139 | - $model_class_name = strpos( $model_name, 'EEM_' ) !== 0 ? "EEM_{$model_name}" : $model_name; |
|
1140 | - if( ! isset( $this->LIB->{$model_class_name} ) || ! $this->LIB->{$model_class_name} instanceof EEM_Base ) { |
|
1138 | + public function reset_model($model_name) { |
|
1139 | + $model_class_name = strpos($model_name, 'EEM_') !== 0 ? "EEM_{$model_name}" : $model_name; |
|
1140 | + if ( ! isset($this->LIB->{$model_class_name} ) || ! $this->LIB->{$model_class_name} instanceof EEM_Base) { |
|
1141 | 1141 | return null; |
1142 | 1142 | } |
1143 | 1143 | //get that model reset it and make sure we nuke the old reference to it |
1144 | - if ( $this->LIB->{$model_class_name} instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) { |
|
1144 | + if ($this->LIB->{$model_class_name} instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) { |
|
1145 | 1145 | $this->LIB->{$model_class_name} = $this->LIB->{$model_class_name}->reset(); |
1146 | 1146 | } else { |
1147 | - throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) ); |
|
1147 | + throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name)); |
|
1148 | 1148 | } |
1149 | 1149 | return $this->LIB->{$model_class_name}; |
1150 | 1150 | } |
@@ -1181,22 +1181,22 @@ discard block |
||
1181 | 1181 | * |
1182 | 1182 | * @return EE_Registry |
1183 | 1183 | */ |
1184 | - public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) { |
|
1184 | + public static function reset($hard = false, $reinstantiate = true, $reset_models = true) { |
|
1185 | 1185 | $instance = self::instance(); |
1186 | 1186 | EEH_Activation::reset(); |
1187 | 1187 | |
1188 | 1188 | //properties that get reset |
1189 | 1189 | $instance->_cache_on = true; |
1190 | - $instance->CFG = EE_Config::reset( $hard, $reinstantiate ); |
|
1190 | + $instance->CFG = EE_Config::reset($hard, $reinstantiate); |
|
1191 | 1191 | $instance->CART = null; |
1192 | 1192 | $instance->MRM = null; |
1193 | 1193 | |
1194 | 1194 | //messages reset |
1195 | 1195 | EED_Messages::reset(); |
1196 | 1196 | |
1197 | - if ( $reset_models ) { |
|
1198 | - foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) { |
|
1199 | - $instance->reset_model( $model_name ); |
|
1197 | + if ($reset_models) { |
|
1198 | + foreach (array_keys($instance->non_abstract_db_models) as $model_name) { |
|
1199 | + $instance->reset_model($model_name); |
|
1200 | 1200 | } |
1201 | 1201 | } |
1202 | 1202 | |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | * @param $a |
1221 | 1221 | * @param $b |
1222 | 1222 | */ |
1223 | - final function __call( $a, $b ) { |
|
1223 | + final function __call($a, $b) { |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | /** |
1229 | 1229 | * @param $a |
1230 | 1230 | */ |
1231 | - final function __get( $a ) { |
|
1231 | + final function __get($a) { |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1237,7 +1237,7 @@ discard block |
||
1237 | 1237 | * @param $a |
1238 | 1238 | * @param $b |
1239 | 1239 | */ |
1240 | - final function __set( $a, $b ) { |
|
1240 | + final function __set($a, $b) { |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | |
@@ -1245,7 +1245,7 @@ discard block |
||
1245 | 1245 | /** |
1246 | 1246 | * @param $a |
1247 | 1247 | */ |
1248 | - final function __isset( $a ) { |
|
1248 | + final function __isset($a) { |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | /** |
1254 | 1254 | * @param $a |
1255 | 1255 | */ |
1256 | - final function __unset( $a ) { |
|
1256 | + final function __unset($a) { |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | |
@@ -1300,7 +1300,7 @@ discard block |
||
1300 | 1300 | * @param $a |
1301 | 1301 | * @param $b |
1302 | 1302 | */ |
1303 | - final static function __callStatic( $a, $b ) { |
|
1303 | + final static function __callStatic($a, $b) { |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1309,9 +1309,9 @@ discard block |
||
1309 | 1309 | */ |
1310 | 1310 | public function cpt_models() { |
1311 | 1311 | $cpt_models = array(); |
1312 | - foreach( $this->non_abstract_db_models as $short_name => $classname ) { |
|
1313 | - if( is_subclass_of( $classname, 'EEM_CPT_Base' ) ) { |
|
1314 | - $cpt_models[ $short_name ] = $classname; |
|
1312 | + foreach ($this->non_abstract_db_models as $short_name => $classname) { |
|
1313 | + if (is_subclass_of($classname, 'EEM_CPT_Base')) { |
|
1314 | + $cpt_models[$short_name] = $classname; |
|
1315 | 1315 | } |
1316 | 1316 | } |
1317 | 1317 | return $cpt_models; |