@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -58,96 +58,96 @@ discard block |
||
58 | 58 | '[CO_GOOGLE_URL]' => esc_html__('Link to organization Google page', 'event_espresso'), |
59 | 59 | '[CO_LINKEDIN_URL]' => esc_html__('Link to organization LinkedIn page', 'event_espresso'), |
60 | 60 | '[CO_INSTAGRAM_URL]' => esc_html__('Link to organization Instagram page', 'event_espresso'), |
61 | - '[CO_TAX_NUMBER_*]' => sprintf( esc_html__('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso' ),'<strong>','</strong>') |
|
61 | + '[CO_TAX_NUMBER_*]' => sprintf(esc_html__('This is the shortcode used for displaying any tax number for the company. %1$sNote: This is a special dynamic shortcode.%2$s You can use the "prefix" parameter to indicate what the prefix for this tax number is. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: [CO_TAX_NUMBER_* prefix="GST: "] and that will output: GST: 12345t56. Also take note that if you have NO number in your settings, the prefix is not output either.', 'event_espresso'), '<strong>', '</strong>') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | - protected function _parser( $shortcode ) { |
|
66 | + protected function _parser($shortcode) { |
|
67 | 67 | |
68 | - switch ( $shortcode ) { |
|
68 | + switch ($shortcode) { |
|
69 | 69 | |
70 | 70 | case '[COMPANY]' : |
71 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
71 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
72 | 72 | break; |
73 | 73 | |
74 | 74 | case '[CO_ADD1]' : |
75 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ); |
|
75 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_1'); |
|
76 | 76 | break; |
77 | 77 | |
78 | 78 | case '[CO_ADD2]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('address_2'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | case '[CO_CITY]' : |
83 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'city' ); |
|
83 | + return EE_Registry::instance()->CFG->organization->get_pretty('city'); |
|
84 | 84 | break; |
85 | 85 | |
86 | 86 | case '[CO_STATE]' : |
87 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( EE_Registry::instance()->CFG->organization->STA_ID ); |
|
87 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID(EE_Registry::instance()->CFG->organization->STA_ID); |
|
88 | 88 | return $state->name(); |
89 | 89 | break; |
90 | 90 | |
91 | 91 | case '[CO_ZIP]' : |
92 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ); |
|
92 | + return EE_Registry::instance()->CFG->organization->get_pretty('zip'); |
|
93 | 93 | break; |
94 | 94 | |
95 | 95 | case '[CO_EMAIL]' : |
96 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
96 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
97 | 97 | break; |
98 | 98 | |
99 | 99 | case '[CO_PHONE]' : |
100 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ); |
|
100 | + return EE_Registry::instance()->CFG->organization->get_pretty('phone'); |
|
101 | 101 | break; |
102 | 102 | |
103 | 103 | case '[CO_LOGO]' : |
104 | - return '<img src="' . EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) . '" id="headerImage" />'; |
|
104 | + return '<img src="'.EE_Registry::instance()->CFG->organization->get_pretty('logo_url').'" id="headerImage" />'; |
|
105 | 105 | break; |
106 | 106 | |
107 | 107 | case '[CO_LOGO_URL]' : |
108 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
108 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[CO_FACEBOOK_URL]' : |
112 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
112 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
113 | 113 | break; |
114 | 114 | |
115 | 115 | case '[CO_TWITTER_URL]' : |
116 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
116 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
117 | 117 | break; |
118 | 118 | |
119 | 119 | case '[CO_PINTEREST_URL]' : |
120 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
120 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
121 | 121 | break; |
122 | 122 | |
123 | 123 | case '[CO_LINKEDIN_URL]' : |
124 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
124 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
125 | 125 | break; |
126 | 126 | |
127 | 127 | case '[CO_GOOGLE_URL]' : |
128 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
128 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
129 | 129 | break; |
130 | 130 | |
131 | 131 | case '[CO_INSTAGRAM_URL]' : |
132 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
132 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | 137 | //also allow for parameter shortcode |
138 | - if ( strpos( $shortcode, '[CO_TAX_NUMBER_*' ) !== FALSE ) { |
|
138 | + if (strpos($shortcode, '[CO_TAX_NUMBER_*') !== FALSE) { |
|
139 | 139 | //first see if there is any company tax number set and bail early if not |
140 | 140 | $tax_number = EE_Registry::instance()->CFG->organization->vat; |
141 | - if ( empty( $tax_number ) ) { |
|
141 | + if (empty($tax_number)) { |
|
142 | 142 | return ''; |
143 | 143 | } |
144 | 144 | |
145 | 145 | //see if there are any attributes. |
146 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
146 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
147 | 147 | |
148 | 148 | //set custom attrs if present (or default) |
149 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
150 | - return $prefix . $tax_number; |
|
149 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
150 | + return $prefix.$tax_number; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return ''; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | $this->description = esc_html__('All shortcodes related to emails', 'event_espresso'); |
44 | 44 | $this->_shortcodes = array( |
45 | 45 | '[SITE_ADMIN_EMAIL]' => esc_html__('Will be replaced with the admin email for the site that Event Espresso is installed on', 'event_espresso'), |
46 | - '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf( esc_html__('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'),'<strong>','</strong>' ), |
|
47 | - '[EVENT_AUTHOR_EMAIL]' => sprintf( esc_html__('This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', 'event_espresso'), '[EVENT_AUTHOR_FORMATTED_EMAIL]' ), |
|
48 | - '[CO_FORMATTED_EMAIL]' => esc_html__('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
46 | + '[EVENT_AUTHOR_FORMATTED_EMAIL]' => sprintf(esc_html__('This will be replaced with a properly formatted list of Event Creator emails for the events in a registration. %1$sNOTE:%2$s If the event author has not filled out their WordPress user profile then the organization name will be used as the "From" name.', 'event_espresso'), '<strong>', '</strong>'), |
|
47 | + '[EVENT_AUTHOR_EMAIL]' => sprintf(esc_html__('This is the same as %1$s shortcode except it is just a list of emails (not fancy headers).', 'event_espresso'), '[EVENT_AUTHOR_FORMATTED_EMAIL]'), |
|
48 | + '[CO_FORMATTED_EMAIL]' => esc_html__('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
49 | 49 | '[CO_EMAIL]' => esc_html__('This will parse to the email address only for the organization set in Your Organization Settings.', 'event_espresso'), |
50 | - '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso' ), |
|
50 | + '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' => esc_html__('This parses to the formatted email address of the organization name set in Your Organization Settings. "My Organization <[email protected]>"', 'event_espresso'), |
|
51 | 51 | '[ESPRESSO_ADMIN_EMAIL]' => esc_html__('This parses to the email address only for the organization set in Your Organization Settings page.', 'event_espresso') |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | 55 | |
56 | - protected function _parser( $shortcode ) { |
|
56 | + protected function _parser($shortcode) { |
|
57 | 57 | |
58 | - switch ( $shortcode ) { |
|
58 | + switch ($shortcode) { |
|
59 | 59 | |
60 | 60 | case '[SITE_ADMIN_EMAIL]' : |
61 | 61 | return $this->_get_site_admin_email(); |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | break; |
67 | 67 | |
68 | 68 | case '[EVENT_AUTHOR_EMAIL]' : |
69 | - return $this->_get_event_admin_emails( FALSE ); |
|
69 | + return $this->_get_event_admin_emails(FALSE); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case '[CO_FORMATTED_EMAIL]' : |
73 | 73 | case '[ESPRESSO_ADMIN_FORMATTED_EMAIL]' : |
74 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) . '>'; |
|
74 | + return EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.EE_Registry::instance()->CFG->organization->get_pretty('email').'>'; |
|
75 | 75 | break; |
76 | 76 | |
77 | 77 | case '[CO_EMAIL]' : |
78 | 78 | case '[ESPRESSO_ADMIN_EMAIL]' : |
79 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
79 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | default : |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - private function _get_event_admin_emails( $fancy_headers = TRUE ) { |
|
101 | + private function _get_event_admin_emails($fancy_headers = TRUE) { |
|
102 | 102 | |
103 | - if ( !empty( $this->_data->admin_email ) ) { |
|
104 | - if ( ! $fancy_headers ) |
|
103 | + if ( ! empty($this->_data->admin_email)) { |
|
104 | + if ( ! $fancy_headers) |
|
105 | 105 | return $this->_data->admin_email; |
106 | - return !empty( $this->_data->fname ) ? $this->_data->fname . ' ' . $this->_data->lname . ' <' . $this->_data->admin_email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $this->_data->admin_email . '>'; |
|
106 | + return ! empty($this->_data->fname) ? $this->_data->fname.' '.$this->_data->lname.' <'.$this->_data->admin_email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$this->_data->admin_email.'>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //k this shortcode has been used else where. Since we don't know what particular event this is for, let's loop through the events and get an array of event admins for the events. We'll return the formatted list of admin emails and let the messenger make sure we only pick one if this is for a field that can only have ONE!. |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | $admin_email = array(); |
112 | 112 | |
113 | 113 | //loop through events and set the list of event_ids to retrieve so we can do ONE query. |
114 | - foreach ( $this->_data->events as $event ) { |
|
114 | + foreach ($this->_data->events as $event) { |
|
115 | 115 | $ids[] = $event['ID']; |
116 | 116 | } |
117 | 117 | |
118 | 118 | //get all the events |
119 | - $events = EE_Registry::instance()->load_model('Event')->get_all( array(array('EVT_ID' => array('IN', $ids ) ) ) ); |
|
119 | + $events = EE_Registry::instance()->load_model('Event')->get_all(array(array('EVT_ID' => array('IN', $ids)))); |
|
120 | 120 | |
121 | 121 | //now loop through each event and setup the details |
122 | 122 | $admin_details = array(); |
123 | 123 | $cnt = 0; |
124 | - foreach ( $events as $event ) { |
|
125 | - $user = get_userdata($event->get('EVT_wp_user') ); |
|
124 | + foreach ($events as $event) { |
|
125 | + $user = get_userdata($event->get('EVT_wp_user')); |
|
126 | 126 | $admin_details[$cnt] = new stdClass(); |
127 | 127 | $admin_details[$cnt]->email = $user->user_email; |
128 | 128 | $admin_details[$cnt]->first_name = $user->user_firstname; |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | } |
132 | 132 | |
133 | 133 | //results? |
134 | - if ( empty($admin_details) || !is_array($admin_details) ) { |
|
134 | + if (empty($admin_details) || ! is_array($admin_details)) { |
|
135 | 135 | $msg[] = esc_html__('The admin details could not be retrieved from the database.', 'event_espresso'); |
136 | - $msg[] = sprintf( esc_html__('Query: %s', 'event_espresso'), $sql ); |
|
137 | - $msg[] = sprintf( esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE) ); |
|
138 | - $msg[] = sprintf( esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE) ); |
|
139 | - $msg[] = sprintf( esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details) ); |
|
140 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, implode( PHP_EOL, $msg ), 'shortcode_parser' ); |
|
136 | + $msg[] = sprintf(esc_html__('Query: %s', 'event_espresso'), $sql); |
|
137 | + $msg[] = sprintf(esc_html__('Events Data: %s', 'event_espresso'), var_export($this->_data->events, TRUE)); |
|
138 | + $msg[] = sprintf(esc_html__('Event IDS: %s', 'event_espresso'), var_export($ids, TRUE)); |
|
139 | + $msg[] = sprintf(esc_html__('Query Results: %s', 'event_espresso'), var_export($admin_details)); |
|
140 | + do_action('AHEE_log', __FILE__, __FUNCTION__, implode(PHP_EOL, $msg), 'shortcode_parser'); |
|
141 | 141 | } |
142 | 142 | |
143 | - foreach ( $admin_details as $admin ) { |
|
143 | + foreach ($admin_details as $admin) { |
|
144 | 144 | //only add an admin email if it is present. |
145 | - if ( empty( $admin->email ) || $admin->email == '' ) continue; |
|
145 | + if (empty($admin->email) || $admin->email == '') continue; |
|
146 | 146 | |
147 | - if ( ! $fancy_headers ) { |
|
147 | + if ( ! $fancy_headers) { |
|
148 | 148 | $admin_email[] = $admin->email; |
149 | 149 | continue; |
150 | 150 | } |
151 | 151 | |
152 | - $admin_email[] = !empty( $admin->first_name ) ? $admin->first_name . ' ' . $admin->last_name . ' <' . $admin->email . '>' : EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) . ' <' . $admin->email . '>'; |
|
152 | + $admin_email[] = ! empty($admin->first_name) ? $admin->first_name.' '.$admin->last_name.' <'.$admin->email.'>' : EE_Registry::instance()->CFG->organization->get_pretty('name').' <'.$admin->email.'>'; |
|
153 | 153 | } |
154 | 154 | |
155 | - $admin_email = implode( ',', $admin_email ); |
|
155 | + $admin_email = implode(',', $admin_email); |
|
156 | 156 | return $admin_email; |
157 | 157 | } |
158 | 158 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | $this->_shortcodes = array( |
43 | 43 | '[TXN_ID]' => esc_html__('The transaction id for the purchase.', 'event_espresso'), |
44 | 44 | '[PAYMENT_URL]' => esc_html__('This is a link to make a payment for the event', 'event_espresso'), |
45 | - '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>' |
|
46 | - . '<li>' . sprintf( esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
47 | - . '<li>' . sprintf( esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
48 | - . '<li>' . sprintf( esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
45 | + '[PAYMENT_LINK_IF_NEEDED_*]' => esc_html__('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>' |
|
46 | + . '<li>'.sprintf(esc_html__('%sclass:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
47 | + . '<li>'.sprintf(esc_html__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
48 | + . '<li>'.sprintf(esc_html__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
49 | 49 | . '</ul>', |
50 | - '[PAYMENT_DUE_DATE_*]' => esc_html__( 'This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso' ) |
|
50 | + '[PAYMENT_DUE_DATE_*]' => esc_html__('This is a special dynamic shortcode that allows one to output a payment due date. It will only result in a date shown if there is money owing. Three parameters are available on this shortcode:', 'event_espresso') |
|
51 | 51 | . '<ul>' |
52 | - . '<li>' . sprintf( esc_html__( '%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
53 | - . '<li>' . sprintf( esc_html__( '%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>' |
|
54 | - . '<li>' . sprintf( esc_html__( '%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>', |
|
52 | + . '<li>'.sprintf(esc_html__('%sformat:%s This is used to indicate what format the date is in. Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
53 | + . '<li>'.sprintf(esc_html__('%sdays_until_due:%s This is the number of days form the transaction creation date that the payment is due. Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>' |
|
54 | + . '<li>'.sprintf(esc_html__('%sprefix_text:%s You can use this to indicate what text will prefix the date string. Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>', |
|
55 | 55 | '[INVOICE_LINK]' => esc_html__('This is a full html link to the invoice', 'event_espresso'), |
56 | 56 | '[INVOICE_URL]' => esc_html__('This is just the url for the invoice', 'event_espresso'), |
57 | 57 | '[INVOICE_LOGO_URL]' => esc_html__('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'), |
58 | 58 | '[INVOICE_LOGO]' => esc_html__('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'), |
59 | 59 | '[INVOICE_PAYEE_NAME]' => esc_html__('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
60 | - '[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
61 | - '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ), |
|
62 | - '[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ), |
|
63 | - '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf( esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ), '<code>', '</code>' ), |
|
60 | + '[INVOICE_PAYEE_ADDRESS]' => esc_html__('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
61 | + '[INVOICE_PAYMENT_INSTRUCTIONS]' => esc_html__('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'), |
|
62 | + '[INVOICE_PAYEE_EMAIL]' => esc_html__('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'), |
|
63 | + '[INVOICE_PAYEE_TAX_NUMBER_*]' => sprintf(esc_html__('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number. It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: %1$s[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]%2$s and that will ouptut: GST: 12345t56. If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'), '<code>', '</code>'), |
|
64 | 64 | '[TOTAL_COST]' => esc_html__('The total cost for the transaction', 'event_espresso'), |
65 | 65 | '[TXN_STATUS]' => esc_html__('The transaction status for the transaction.', 'event_espresso'), |
66 | 66 | '[TXN_STATUS_ID]' => esc_html__('The ID representing the transaction status as saved in the db. This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'), |
@@ -71,52 +71,52 @@ discard block |
||
71 | 71 | '[TOTAL_OWING]' => esc_html__('The total owing on a transaction with no attributes.', 'event_espresso'), |
72 | 72 | '[TXN_SUBTOTAL]' => esc_html__('The subtotal for all txn line items.', 'event_espresso'), |
73 | 73 | '[TXN_TAX_SUBTOTAL]' => esc_html__('The subtotal for all tax line items.', 'event_espresso'), |
74 | - '[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' . |
|
75 | - '<li><strong>still_owing</strong>:' . esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' . |
|
76 | - '<li><strong>none_owing</strong>:' . esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>', |
|
74 | + '[OWING_STATUS_MESSAGE_*]' => esc_html__('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'. |
|
75 | + '<li><strong>still_owing</strong>:'.esc_html__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'. |
|
76 | + '<li><strong>none_owing</strong>:'.esc_html__('If the transaction is paid in full, then you can indicate how this gets displayed. Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>', |
|
77 | 77 | '[TXN_TOTAL_TICKETS]' => esc_html__('The total number of all tickets purchased in a transaction', 'event_espresso'), |
78 | - '[TKT_QTY_PURCHASED]' => sprintf( esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>' ), |
|
78 | + '[TKT_QTY_PURCHASED]' => sprintf(esc_html__('The total number of all tickets purchased in a transaction. %1$sNOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.%2$s', 'event_espresso'), '<strong>', '</strong>'), |
|
79 | 79 | '[TRANSACTION_ADMIN_URL]' => esc_html__('The url to the admin page for this transaction', 'event_espresso'), |
80 | 80 | '[RECEIPT_URL]' => esc_html__('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'), |
81 | - '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | - '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( esc_html__( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' ) |
|
81 | + '[INVOICE_RECEIPT_SWITCHER_URL]' => esc_html__('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active then will parse to an empty string.', 'event_espresso'), |
|
82 | + '[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(esc_html__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>') |
|
83 | 83 | ); |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | - protected function _parser( $shortcode ) { |
|
87 | + protected function _parser($shortcode) { |
|
88 | 88 | |
89 | 89 | //attempt to get the transaction. Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction. |
90 | 90 | $transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null; |
91 | - $transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction; |
|
91 | + $transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction; |
|
92 | 92 | |
93 | 93 | //payment |
94 | 94 | $payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null; |
95 | - $payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) && isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment; |
|
95 | + $payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment; |
|
96 | 96 | |
97 | 97 | |
98 | - if ( ! $transaction instanceof EE_Transaction ) |
|
98 | + if ( ! $transaction instanceof EE_Transaction) |
|
99 | 99 | return ''; |
100 | 100 | |
101 | - switch ( $shortcode ) { |
|
101 | + switch ($shortcode) { |
|
102 | 102 | case '[TXN_ID]' : |
103 | 103 | return $transaction->ID(); |
104 | 104 | break; |
105 | 105 | |
106 | 106 | case '[PAYMENT_URL]' : |
107 | 107 | $payment_url = $transaction->payment_overview_url(); |
108 | - return empty( $payment_url ) ? esc_html__( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
108 | + return empty($payment_url) ? esc_html__('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url; |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case '[INVOICE_LINK]' : |
112 | 112 | $invoice_url = $transaction->invoice_url(); |
113 | - $invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | - return sprintf( esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' ); |
|
113 | + $invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
114 | + return sprintf(esc_html__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>'); |
|
115 | 115 | break; /**/ |
116 | 116 | |
117 | 117 | case '[INVOICE_URL]' : |
118 | 118 | $invoice_url = $transaction->invoice_url(); |
119 | - return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
119 | + return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case '[INVOICE_LOGO_URL]' : |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | break; |
125 | 125 | |
126 | 126 | case '[INVOICE_LOGO]' : |
127 | - return $this->_get_invoice_logo( TRUE ); |
|
127 | + return $this->_get_invoice_logo(TRUE); |
|
128 | 128 | break; |
129 | 129 | |
130 | 130 | case '[INVOICE_PAYEE_NAME]' : |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | |
147 | 147 | case "[TOTAL_COST]" : |
148 | 148 | $total = $transaction->total(); |
149 | - return ! empty($total) ? EEH_Template::format_currency( $total ) : ''; |
|
149 | + return ! empty($total) ? EEH_Template::format_currency($total) : ''; |
|
150 | 150 | break; |
151 | 151 | |
152 | 152 | case "[PAYMENT_STATUS]" : |
153 | 153 | $status = $transaction->pretty_status(); |
154 | - return !empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
154 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
155 | 155 | break; /**/ |
156 | 156 | |
157 | 157 | // note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity. |
158 | 158 | case "[TXN_STATUS]" : |
159 | 159 | $status = $transaction->pretty_status(); |
160 | - return !empty( $status ) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
160 | + return ! empty($status) ? $status : esc_html__('Unknown', 'event_espresso'); |
|
161 | 161 | break; |
162 | 162 | |
163 | 163 | case "[TXN_STATUS_ID]" : |
@@ -165,21 +165,21 @@ discard block |
||
165 | 165 | break; |
166 | 166 | |
167 | 167 | case "[PAYMENT_GATEWAY]" : |
168 | - return $this->_get_payment_gateway( $transaction ); |
|
168 | + return $this->_get_payment_gateway($transaction); |
|
169 | 169 | break; |
170 | 170 | |
171 | 171 | case "[AMOUNT_PAID]" : |
172 | 172 | $amount = $payment instanceof EE_Payment ? $payment->amount() : 0; |
173 | - return EEH_Template::format_currency( $amount ); |
|
173 | + return EEH_Template::format_currency($amount); |
|
174 | 174 | break; |
175 | 175 | |
176 | 176 | case "[TOTAL_AMOUNT_PAID]" : |
177 | - return EEH_Template::format_currency( $transaction->paid() ); |
|
177 | + return EEH_Template::format_currency($transaction->paid()); |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case "[TOTAL_OWING]" : |
181 | 181 | $total_owing = $transaction->remaining(); |
182 | - return EEH_Template::format_currency( $total_owing ); |
|
182 | + return EEH_Template::format_currency($total_owing); |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case "[TXN_SUBTOTAL]" : |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | case "[TXN_TAX_SUBTOTAL]" : |
190 | - return EEH_Template::format_currency($this->_get_subtotal( TRUE )); |
|
190 | + return EEH_Template::format_currency($this->_get_subtotal(TRUE)); |
|
191 | 191 | break; |
192 | 192 | |
193 | 193 | case "[TKT_QTY_PURCHASED]" : |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | break; |
197 | 197 | |
198 | 198 | case "[TRANSACTION_ADMIN_URL]" : |
199 | - require_once EE_CORE . 'admin/EE_Admin_Page.core.php'; |
|
200 | - $query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() ); |
|
201 | - $url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') ); |
|
199 | + require_once EE_CORE.'admin/EE_Admin_Page.core.php'; |
|
200 | + $query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID()); |
|
201 | + $url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')); |
|
202 | 202 | return $url; |
203 | 203 | break; |
204 | 204 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | //get primary_registration |
207 | 207 | $reg = $this->_data->primary_reg_obj; |
208 | 208 | |
209 | - if ( ! $reg instanceof EE_Registration ) { |
|
209 | + if ( ! $reg instanceof EE_Registration) { |
|
210 | 210 | return ''; |
211 | 211 | } |
212 | 212 | return $reg->receipt_url(); |
213 | 213 | break; |
214 | 214 | |
215 | 215 | case "[INVOICE_RECEIPT_SWITCHER_URL]" : |
216 | - return $this->_get_invoice_receipt_switcher( FALSE ); |
|
216 | + return $this->_get_invoice_receipt_switcher(FALSE); |
|
217 | 217 | break; |
218 | 218 | |
219 | 219 | case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" : |
@@ -223,20 +223,20 @@ discard block |
||
223 | 223 | |
224 | 224 | } |
225 | 225 | |
226 | - if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) { |
|
227 | - return $this->_get_custom_total_oweing( $shortcode ); |
|
226 | + if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) { |
|
227 | + return $this->_get_custom_total_oweing($shortcode); |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) { |
|
231 | - return $this->_get_invoice_payee_tax_number( $shortcode ); |
|
230 | + if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) { |
|
231 | + return $this->_get_invoice_payee_tax_number($shortcode); |
|
232 | 232 | } |
233 | 233 | |
234 | - if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) { |
|
235 | - return $this->_get_payment_link_if_needed( $shortcode ); |
|
234 | + if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) { |
|
235 | + return $this->_get_payment_link_if_needed($shortcode); |
|
236 | 236 | } |
237 | 237 | |
238 | - if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) { |
|
239 | - return $this->_get_payment_due_date( $shortcode, $transaction ); |
|
238 | + if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) { |
|
239 | + return $this->_get_payment_due_date($shortcode, $transaction); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | return ''; |
@@ -253,19 +253,19 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return string parsed. |
255 | 255 | */ |
256 | - private function _get_custom_total_oweing( $shortcode ) { |
|
257 | - $valid_shortcodes = array( 'transaction' ); |
|
258 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
256 | + private function _get_custom_total_oweing($shortcode) { |
|
257 | + $valid_shortcodes = array('transaction'); |
|
258 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
259 | 259 | |
260 | 260 | //ensure default is set. |
261 | 261 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
262 | 262 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
263 | 263 | |
264 | - if ( $total_owing > 0 ) { |
|
265 | - $owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( esc_html__( '%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ); |
|
266 | - $owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
264 | + if ($total_owing > 0) { |
|
265 | + $owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(esc_html__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>'); |
|
266 | + $owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
267 | 267 | } else { |
268 | - $owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
268 | + $owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : ''; |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return $owing_content; |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | |
274 | 274 | |
275 | 275 | |
276 | - private function _get_payment_gateway( $transaction ) { |
|
277 | - $pm = $this->_get_payment_method( $transaction ); |
|
276 | + private function _get_payment_gateway($transaction) { |
|
277 | + $pm = $this->_get_payment_method($transaction); |
|
278 | 278 | return $pm instanceof EE_Payment_Method ? $pm->name() : ''; |
279 | 279 | } |
280 | 280 | |
@@ -289,37 +289,37 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @return string url or html |
291 | 291 | */ |
292 | - private function _get_invoice_logo( $img_tags = FALSE ) { |
|
292 | + private function _get_invoice_logo($img_tags = FALSE) { |
|
293 | 293 | //try to get the invoice payment method's logo for this transaction image first |
294 | 294 | $pm = $this->_get_payment_method(); |
295 | - if ( $pm instanceof EE_Payment_Method ){ |
|
296 | - $invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE ); |
|
297 | - }else{ |
|
295 | + if ($pm instanceof EE_Payment_Method) { |
|
296 | + $invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE); |
|
297 | + } else { |
|
298 | 298 | $invoice_logo_url = NULL; |
299 | 299 | } |
300 | - if( empty( $invoice_logo_url ) ){ |
|
300 | + if (empty($invoice_logo_url)) { |
|
301 | 301 | $invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url; |
302 | 302 | } |
303 | 303 | |
304 | - if ( empty( $invoice_logo_url ) ) { |
|
304 | + if (empty($invoice_logo_url)) { |
|
305 | 305 | return ''; |
306 | 306 | } |
307 | 307 | |
308 | - if ( ! $img_tags ) { |
|
308 | + if ( ! $img_tags) { |
|
309 | 309 | return $invoice_logo_url; |
310 | 310 | } |
311 | 311 | |
312 | 312 | //image tags have been requested. |
313 | - $image_size = getimagesize( $invoice_logo_url ); |
|
313 | + $image_size = getimagesize($invoice_logo_url); |
|
314 | 314 | |
315 | 315 | //if image is wider than 200px, set the wideth to 200 |
316 | - if ( $image_size[0] > 300 ) { |
|
316 | + if ($image_size[0] > 300) { |
|
317 | 317 | $image_width = 300; |
318 | - }else{ |
|
318 | + } else { |
|
319 | 319 | $image_width = $image_size[0]; |
320 | 320 | } |
321 | 321 | |
322 | - return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />'; |
|
322 | + return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />'; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -336,26 +336,26 @@ discard block |
||
336 | 336 | private function _get_invoice_payee_name() { |
337 | 337 | $payee_name = NULL; |
338 | 338 | $pm = $this->_get_payment_method(); |
339 | - if( $pm instanceof EE_Payment_Method ){ |
|
340 | - $payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE ); |
|
339 | + if ($pm instanceof EE_Payment_Method) { |
|
340 | + $payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE); |
|
341 | 341 | } |
342 | - $payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name; |
|
342 | + $payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name; |
|
343 | 343 | return $payee_name; |
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
347 | 347 | * gets the payment method for this transaction. Otherwise gets a default one. |
348 | 348 | */ |
349 | - private function _get_payment_method( $transaction = null ){ |
|
350 | - if( $transaction instanceof EE_Transaction ) { |
|
349 | + private function _get_payment_method($transaction = null) { |
|
350 | + if ($transaction instanceof EE_Transaction) { |
|
351 | 351 | $payment_method = $transaction->payment_method(); |
352 | - if ( empty( $payment_method ) ) { |
|
353 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
352 | + if (empty($payment_method)) { |
|
353 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
354 | 354 | } |
355 | 355 | return $payment_method; |
356 | - }else{ |
|
356 | + } else { |
|
357 | 357 | //get the first payment method we can find |
358 | - return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
358 | + return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice')); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -372,10 +372,10 @@ discard block |
||
372 | 372 | private function _get_invoice_payee_email() { |
373 | 373 | $payee_email = NULL; |
374 | 374 | $pm = $this->_get_payment_method(); |
375 | - if( $pm instanceof EE_Payment_Method ){ |
|
376 | - $payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE ); |
|
375 | + if ($pm instanceof EE_Payment_Method) { |
|
376 | + $payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE); |
|
377 | 377 | } |
378 | - $payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email; |
|
378 | + $payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email; |
|
379 | 379 | return $payee_email; |
380 | 380 | } |
381 | 381 | |
@@ -391,24 +391,24 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - private function _get_invoice_payee_tax_number( $shortcode ) { |
|
394 | + private function _get_invoice_payee_tax_number($shortcode) { |
|
395 | 395 | $payee_tax_number = NULL; |
396 | 396 | $pm = $this->_get_payment_method(); |
397 | - if( $pm instanceof EE_Payment_Method ){ |
|
398 | - $payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE ); |
|
397 | + if ($pm instanceof EE_Payment_Method) { |
|
398 | + $payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE); |
|
399 | 399 | } |
400 | - $payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
400 | + $payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number; |
|
401 | 401 | |
402 | - if ( empty( $payee_tax_number ) ) { |
|
402 | + if (empty($payee_tax_number)) { |
|
403 | 403 | return ''; |
404 | 404 | } |
405 | 405 | |
406 | 406 | //any attributes? |
407 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
407 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
408 | 408 | |
409 | 409 | //prefix? |
410 | - $prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : esc_html__( 'VAT/Tax Number: ', 'event_espresso' ); |
|
411 | - return $prefix . $payee_tax_number; |
|
410 | + $prefix = isset($attrs['prefix']) ? $attrs['prefix'] : esc_html__('VAT/Tax Number: ', 'event_espresso'); |
|
411 | + return $prefix.$payee_tax_number; |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | |
@@ -425,22 +425,22 @@ discard block |
||
425 | 425 | private function _get_invoice_payee_address() { |
426 | 426 | $payee_address = NULL; |
427 | 427 | $pm = $this->_get_payment_method(); |
428 | - if( $pm instanceof EE_Payment_Method ){ |
|
429 | - $payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE ); |
|
428 | + if ($pm instanceof EE_Payment_Method) { |
|
429 | + $payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE); |
|
430 | 430 | } |
431 | - if ( empty( $payee_address ) ) { |
|
431 | + if (empty($payee_address)) { |
|
432 | 432 | $organization = EE_Registry::instance()->CFG->organization; |
433 | - $payee_address = $organization->get_pretty( 'address_1' ) . '<br>'; |
|
434 | - $payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : ''; |
|
435 | - $payee_address .= $organization->get_pretty( 'city' ) . '<br>'; |
|
433 | + $payee_address = $organization->get_pretty('address_1').'<br>'; |
|
434 | + $payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : ''; |
|
435 | + $payee_address .= $organization->get_pretty('city').'<br>'; |
|
436 | 436 | |
437 | 437 | //state |
438 | - $state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID ); |
|
439 | - $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
438 | + $state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID); |
|
439 | + $payee_address .= $state instanceof EE_State ? $state->name() : ''; |
|
440 | 440 | |
441 | 441 | //Country |
442 | - $payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : ''; |
|
443 | - $payee_address .= ! empty( $organization->zip ) ? $organization->zip : ''; |
|
442 | + $payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : ''; |
|
443 | + $payee_address .= ! empty($organization->zip) ? $organization->zip : ''; |
|
444 | 444 | } |
445 | 445 | return $payee_address; |
446 | 446 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | private function _get_invoice_payment_instructions() { |
459 | 459 | $instructions = NULL; |
460 | 460 | $pm = $this->_get_payment_method(); |
461 | - return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : ''; |
|
461 | + return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : ''; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | |
@@ -472,27 +472,27 @@ discard block |
||
472 | 472 | * |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - protected function _get_invoice_receipt_switcher( $button = TRUE ) { |
|
475 | + protected function _get_invoice_receipt_switcher($button = TRUE) { |
|
476 | 476 | $reg = $this->_data->primary_reg_obj; |
477 | - $message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : ''; |
|
478 | - if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) { |
|
477 | + $message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : ''; |
|
478 | + if ( ! $reg instanceof EE_Registration || empty($message_type)) { |
|
479 | 479 | return ''; |
480 | 480 | } |
481 | 481 | |
482 | - $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
483 | - $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso' ) : esc_html__( 'Switch to Invoice', 'event_espresso' ); |
|
484 | - $switch_to_label = ! $switch_to_invoice ? esc_html__( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label; |
|
482 | + $switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false; |
|
483 | + $switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? esc_html__('View Invoice', 'event_espresso') : esc_html__('Switch to Invoice', 'event_espresso'); |
|
484 | + $switch_to_label = ! $switch_to_invoice ? esc_html__('Switch to Receipt', 'event_espresso') : $switch_to_label; |
|
485 | 485 | $switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url(); |
486 | 486 | |
487 | - if ( ! $button ) { |
|
487 | + if ( ! $button) { |
|
488 | 488 | return $switch_to_url; |
489 | 489 | } |
490 | 490 | |
491 | - if ( ! empty( $switch_to_url ) ) { |
|
491 | + if ( ! empty($switch_to_url)) { |
|
492 | 492 | |
493 | 493 | return ' |
494 | - <form method="post" action="' . $switch_to_url . '" > |
|
495 | - <input class="print_button" type="submit" value="' . $switch_to_label . '" /> |
|
494 | + <form method="post" action="' . $switch_to_url.'" > |
|
495 | + <input class="print_button" type="submit" value="' . $switch_to_label.'" /> |
|
496 | 496 | </form> |
497 | 497 | '; |
498 | 498 | } |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - private function _get_receipt_url( EE_Transaction $transaction ) { |
|
515 | + private function _get_receipt_url(EE_Transaction $transaction) { |
|
516 | 516 | //get primary_registration |
517 | 517 | $reg = $this->_data->primary_reg_obj; |
518 | 518 | |
519 | - if ( ! $reg instanceof EE_Registration ) { |
|
519 | + if ( ! $reg instanceof EE_Registration) { |
|
520 | 520 | return ''; |
521 | 521 | } |
522 | 522 | |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return int |
534 | 534 | */ |
535 | - private function _get_subtotal( $tax = FALSE ) { |
|
536 | - $grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL; |
|
535 | + private function _get_subtotal($tax = FALSE) { |
|
536 | + $grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL; |
|
537 | 537 | |
538 | - if ( ! $grand_total instanceof EE_Line_Item ) { |
|
538 | + if ( ! $grand_total instanceof EE_Line_Item) { |
|
539 | 539 | return 0; |
540 | 540 | } |
541 | 541 | |
@@ -554,26 +554,26 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return string parsed. |
556 | 556 | */ |
557 | - private function _get_payment_link_if_needed( $shortcode ) { |
|
558 | - $valid_shortcodes = array( 'transaction' ); |
|
559 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
557 | + private function _get_payment_link_if_needed($shortcode) { |
|
558 | + $valid_shortcodes = array('transaction'); |
|
559 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
560 | 560 | |
561 | 561 | //ensure default is set. |
562 | 562 | $addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
563 | 563 | $total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0; |
564 | 564 | |
565 | - if ( $total_owing > 0 ) { |
|
566 | - $class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout'; |
|
567 | - $custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
568 | - $container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p'; |
|
569 | - $opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : ''; |
|
570 | - $opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag; |
|
571 | - $opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag; |
|
572 | - $closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : ''; |
|
573 | - $content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag; |
|
565 | + if ($total_owing > 0) { |
|
566 | + $class = isset($attrs['class']) ? $attrs['class'] : 'callout'; |
|
567 | + $custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.'; |
|
568 | + $container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p'; |
|
569 | + $opening_tag = ! empty($container_tag) ? '<'.$container_tag : ''; |
|
570 | + $opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag; |
|
571 | + $opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag; |
|
572 | + $closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : ''; |
|
573 | + $content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag; |
|
574 | 574 | |
575 | 575 | //we need to re run this string through the parser to catch any shortcodes that are in it. |
576 | - $owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message ); |
|
576 | + $owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message); |
|
577 | 577 | } else { |
578 | 578 | return ''; |
579 | 579 | } |
@@ -593,31 +593,31 @@ discard block |
||
593 | 593 | * @param EE_Transaction $transaction |
594 | 594 | * @return string |
595 | 595 | */ |
596 | - protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) { |
|
596 | + protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) { |
|
597 | 597 | //if transaction is paid in full then we can just return an empty string |
598 | - if ( $transaction->remaining() === 0 ) { |
|
598 | + if ($transaction->remaining() === 0) { |
|
599 | 599 | return ''; |
600 | 600 | } |
601 | 601 | |
602 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
603 | - $format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' ); |
|
604 | - $days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30; |
|
605 | - $prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : esc_html__( 'Payment in full due by: ', 'event_espresso' ); |
|
606 | - $transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' ); |
|
602 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
603 | + $format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format'); |
|
604 | + $days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30; |
|
605 | + $prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : esc_html__('Payment in full due by: ', 'event_espresso'); |
|
606 | + $transaction_created = $transaction->get_DateTime_object('TXN_timestamp'); |
|
607 | 607 | |
608 | 608 | //setup date due: |
609 | 609 | try { |
610 | - if ( $transaction_created instanceof DateTime ) { |
|
611 | - $date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format ); |
|
610 | + if ($transaction_created instanceof DateTime) { |
|
611 | + $date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format); |
|
612 | 612 | } else { |
613 | 613 | throw new Exception(); |
614 | 614 | } |
615 | - } catch( Exception $e ) { |
|
615 | + } catch (Exception $e) { |
|
616 | 616 | //format was likely invalid. |
617 | 617 | $date_due = 'Unable to calculate date due, likely the format string is invalid.'; |
618 | 618 | } |
619 | 619 | |
620 | - return $prefix_text . $date_due; |
|
620 | + return $prefix_text.$date_due; |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | } //end EE_Transaction Shortcodes library |
@@ -92,7 +92,7 @@ |
||
92 | 92 | /** |
93 | 93 | * Model_Version_Info constructor. |
94 | 94 | * |
95 | - * @param array $requested_version |
|
95 | + * @param string $requested_version |
|
96 | 96 | */ |
97 | 97 | public function __construct( $requested_version ) { |
98 | 98 | $this->_requested_version = $requested_version; |
@@ -89,12 +89,12 @@ discard block |
||
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * Model_Version_Info constructor. |
|
94 | - * |
|
95 | - * @param array $requested_version |
|
96 | - */ |
|
97 | - public function __construct( $requested_version ) { |
|
92 | + /** |
|
93 | + * Model_Version_Info constructor. |
|
94 | + * |
|
95 | + * @param array $requested_version |
|
96 | + */ |
|
97 | + public function __construct( $requested_version ) { |
|
98 | 98 | $this->_requested_version = $requested_version; |
99 | 99 | $this->_model_changes = array( |
100 | 100 | '4.8.29' => array( |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | } |
210 | 210 | } |
211 | 211 | $this->_cached_models_for_requested_version = apply_filters( |
212 | - 'FHEE__EventEspresso_core_libraries_rest_api__models_for_requested_version', |
|
213 | - $all_models_in_current_version, |
|
214 | - $this |
|
215 | - ); |
|
212 | + 'FHEE__EventEspresso_core_libraries_rest_api__models_for_requested_version', |
|
213 | + $all_models_in_current_version, |
|
214 | + $this |
|
215 | + ); |
|
216 | 216 | } |
217 | 217 | return $this->_cached_models_for_requested_version; |
218 | 218 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param array $requested_version |
96 | 96 | */ |
97 | - public function __construct( $requested_version ) { |
|
97 | + public function __construct($requested_version) { |
|
98 | 98 | $this->_requested_version = $requested_version; |
99 | 99 | $this->_model_changes = array( |
100 | 100 | '4.8.29' => array( |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | 'table_column' => 'N/A', |
117 | 117 | 'always_available' => true, |
118 | 118 | ); |
119 | - foreach( $this->_resource_changes as $version => $model_classnames ) { |
|
120 | - foreach( $model_classnames as $model_classname => $extra_fields ) { |
|
121 | - foreach( $extra_fields as $fieldname => $field_data ) { |
|
122 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ 'name' ] = $fieldname; |
|
123 | - foreach( $defaults as $attribute => $default_value ) { |
|
124 | - if( ! isset( $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] ) ) { |
|
125 | - $this->_resource_changes[ $model_classname ][ $fieldname ][ $attribute ] = $default_value; |
|
119 | + foreach ($this->_resource_changes as $version => $model_classnames) { |
|
120 | + foreach ($model_classnames as $model_classname => $extra_fields) { |
|
121 | + foreach ($extra_fields as $fieldname => $field_data) { |
|
122 | + $this->_resource_changes[$model_classname][$fieldname]['name'] = $fieldname; |
|
123 | + foreach ($defaults as $attribute => $default_value) { |
|
124 | + if ( ! isset($this->_resource_changes[$model_classname][$fieldname][$attribute])) { |
|
125 | + $this->_resource_changes[$model_classname][$fieldname][$attribute] = $default_value; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | * @return array |
139 | 139 | */ |
140 | 140 | public function model_changes_between_requested_version_and_current() { |
141 | - if( $this->_cached_model_changes_between_requested_version_and_current === null ) { |
|
141 | + if ($this->_cached_model_changes_between_requested_version_and_current === null) { |
|
142 | 142 | $model_changes = array(); |
143 | - foreach( $this->model_changes() as $version => $models_changed_in_version ) { |
|
144 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
145 | - $model_changes[ $version ] = $models_changed_in_version; |
|
143 | + foreach ($this->model_changes() as $version => $models_changed_in_version) { |
|
144 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
145 | + $model_changes[$version] = $models_changed_in_version; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | $this->_cached_model_changes_between_requested_version_and_current = $model_changes; |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | * @return array |
159 | 159 | */ |
160 | 160 | public function resource_changes_between_requested_version_and_current() { |
161 | - if( $this->_cached_resource_changes_between_requested_version_and_current === null ) { |
|
161 | + if ($this->_cached_resource_changes_between_requested_version_and_current === null) { |
|
162 | 162 | $resource_changes = array(); |
163 | - foreach( $this->resource_changes() as $version => $model_classnames ) { |
|
164 | - if( $version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version() ) { |
|
165 | - $resource_changes[ $version ] = $model_classnames; |
|
163 | + foreach ($this->resource_changes() as $version => $model_classnames) { |
|
164 | + if ($version <= \EED_Core_Rest_Api::core_version() && $version > $this->requested_version()) { |
|
165 | + $resource_changes[$version] = $model_classnames; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | $this->_cached_resource_changes_between_requested_version_and_current = $resource_changes; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * If a request was sent to 'wp-json/ee/v4.7/events' this would be '4.7' |
175 | 175 | * @return string like '4.6' |
176 | 176 | */ |
177 | - public function requested_version(){ |
|
177 | + public function requested_version() { |
|
178 | 178 | return $this->_requested_version; |
179 | 179 | } |
180 | 180 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * If a version is missing then we don't know anything about what changes it introduced from the previous version |
189 | 189 | * @return array |
190 | 190 | */ |
191 | - public function model_changes(){ |
|
191 | + public function model_changes() { |
|
192 | 192 | return $this->_model_changes; |
193 | 193 | } |
194 | 194 | |
@@ -199,12 +199,12 @@ discard block |
||
199 | 199 | * @return array keys are model names, values are their classname |
200 | 200 | */ |
201 | 201 | public function models_for_requested_version() { |
202 | - if( $this->_cached_models_for_requested_version === null ) { |
|
202 | + if ($this->_cached_models_for_requested_version === null) { |
|
203 | 203 | $all_models_in_current_version = \EE_Registry::instance()->non_abstract_db_models; |
204 | - foreach( $this->model_changes_between_requested_version_and_current() as $version => $models_changed ) { |
|
205 | - foreach( $models_changed as $model_name => $new_indicator_or_fields_added ) { |
|
206 | - if( $new_indicator_or_fields_added === Model_Version_Info::model_added ) { |
|
207 | - unset( $all_models_in_current_version[ $model_name ] ); |
|
204 | + foreach ($this->model_changes_between_requested_version_and_current() as $version => $models_changed) { |
|
205 | + foreach ($models_changed as $model_name => $new_indicator_or_fields_added) { |
|
206 | + if ($new_indicator_or_fields_added === Model_Version_Info::model_added) { |
|
207 | + unset($all_models_in_current_version[$model_name]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | } |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | * @param string $model_name eg 'Event' |
228 | 228 | * @return boolean |
229 | 229 | */ |
230 | - public function is_model_name_in_this_version( $model_name ) { |
|
230 | + public function is_model_name_in_this_version($model_name) { |
|
231 | 231 | $model_names = $this->models_for_requested_version(); |
232 | - if( isset( $model_names[ $model_name ] ) ) { |
|
232 | + if (isset($model_names[$model_name])) { |
|
233 | 233 | return true; |
234 | - }else{ |
|
234 | + } else { |
|
235 | 235 | return false; |
236 | 236 | } |
237 | 237 | } |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | * @return \EEM_Base |
247 | 247 | * @throws \EE_Error |
248 | 248 | */ |
249 | - public function load_model( $model_name ) { |
|
250 | - if( $this->is_model_name_in_this_version( $model_name ) ) { |
|
251 | - return \EE_Registry::instance()->load_model( $model_name ); |
|
252 | - }else{ |
|
249 | + public function load_model($model_name) { |
|
250 | + if ($this->is_model_name_in_this_version($model_name)) { |
|
251 | + return \EE_Registry::instance()->load_model($model_name); |
|
252 | + } else { |
|
253 | 253 | throw new \EE_Error( |
254 | 254 | sprintf( |
255 | 255 | __( |
@@ -271,21 +271,21 @@ discard block |
||
271 | 271 | * @param \EEM_Base $model |
272 | 272 | * @return array|\EE_Model_Field_Base[] |
273 | 273 | */ |
274 | - public function fields_on_model_in_this_version( $model ) { |
|
275 | - if( ! isset( $this->_cached_fields_on_models[ $model->get_this_model_name() ] ) ) { |
|
274 | + public function fields_on_model_in_this_version($model) { |
|
275 | + if ( ! isset($this->_cached_fields_on_models[$model->get_this_model_name()])) { |
|
276 | 276 | //get all model changes between the requested version and current core version |
277 | 277 | $changes = $this->model_changes_between_requested_version_and_current(); |
278 | 278 | //fetch all fields currently on this model |
279 | 279 | $current_fields = $model->field_settings(); |
280 | 280 | //remove all fields that have been added since |
281 | - foreach( $changes as $version => $changes_in_version ) { |
|
282 | - if( |
|
283 | - isset( $changes_in_version[ $model->get_this_model_name() ] ) |
|
284 | - && $changes_in_version[ $model->get_this_model_name() ] !== Model_Version_Info::model_added |
|
281 | + foreach ($changes as $version => $changes_in_version) { |
|
282 | + if ( |
|
283 | + isset($changes_in_version[$model->get_this_model_name()]) |
|
284 | + && $changes_in_version[$model->get_this_model_name()] !== Model_Version_Info::model_added |
|
285 | 285 | ) { |
286 | 286 | $current_fields = array_diff_key( |
287 | 287 | $current_fields, |
288 | - array_flip( $changes_in_version[ $model->get_this_model_name() ] ) |
|
288 | + array_flip($changes_in_version[$model->get_this_model_name()]) |
|
289 | 289 | ); |
290 | 290 | } |
291 | 291 | } |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * @param array $classnames |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - public function is_subclass_of_one( $object, $classnames ) { |
|
307 | - foreach( $classnames as $classname ) { |
|
308 | - if( is_a( $object, $classname ) ) { |
|
306 | + public function is_subclass_of_one($object, $classnames) { |
|
307 | + foreach ($classnames as $classname) { |
|
308 | + if (is_a($object, $classname)) { |
|
309 | 309 | return true; |
310 | 310 | } |
311 | 311 | } |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | * Returns the list of model field classes that that the API basically ignores |
317 | 317 | * @return array |
318 | 318 | */ |
319 | - public function fields_ignored(){ |
|
319 | + public function fields_ignored() { |
|
320 | 320 | return apply_filters( |
321 | 321 | 'FHEE__Controller_Model_Read_fields_ignored', |
322 | - array( 'EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field' ) |
|
322 | + array('EE_Foreign_Key_Field_Base', 'EE_Any_Foreign_Model_Name_Field') |
|
323 | 323 | ); |
324 | 324 | } |
325 | 325 | |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param EE_Model_Field_Base |
329 | 329 | * @return boolean |
330 | 330 | */ |
331 | - public function field_is_ignored( $field_obj ){ |
|
332 | - return $this->is_subclass_of_one( $field_obj, $this->fields_ignored() ); |
|
331 | + public function field_is_ignored($field_obj) { |
|
332 | + return $this->is_subclass_of_one($field_obj, $this->fields_ignored()); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | public function fields_that_have_rendered_format() { |
341 | 341 | return apply_filters( |
342 | 342 | 'FHEE__Controller_Model_Read__fields_raw', |
343 | - array( 'EE_Post_Content_Field', 'EE_Full_HTML_Field' ) |
|
343 | + array('EE_Post_Content_Field', 'EE_Full_HTML_Field') |
|
344 | 344 | ); |
345 | 345 | } |
346 | 346 | |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | * @param EE_Model_Field_Base |
350 | 350 | * @return boolean |
351 | 351 | */ |
352 | - public function field_has_rendered_format( $field_obj ){ |
|
353 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_rendered_format() ); |
|
352 | + public function field_has_rendered_format($field_obj) { |
|
353 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_rendered_format()); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | public function fields_that_have_pretty_format() { |
363 | 363 | return apply_filters( |
364 | 364 | 'FHEE__Controller_Model_Read__fields_pretty', |
365 | - array( 'EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field' ) |
|
365 | + array('EE_Enum_Integer_Field', 'EE_Enum_Text_Field', 'EE_Money_Field') |
|
366 | 366 | ); |
367 | 367 | } |
368 | 368 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param EE_Model_Field_Base |
372 | 372 | * @return boolean |
373 | 373 | */ |
374 | - public function field_has_pretty_format( $field_obj ){ |
|
375 | - return $this->is_subclass_of_one( $field_obj, $this->fields_that_have_pretty_format() ); |
|
374 | + public function field_has_pretty_format($field_obj) { |
|
375 | + return $this->is_subclass_of_one($field_obj, $this->fields_that_have_pretty_format()); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | * @param \EEM_Base $model |
390 | 390 | * @return array |
391 | 391 | */ |
392 | - public function extra_resource_properties_for_model( $model ) { |
|
392 | + public function extra_resource_properties_for_model($model) { |
|
393 | 393 | $extra_properties = array(); |
394 | - foreach( $this->resource_changes_between_requested_version_and_current() as $version => $model_classnames ) { |
|
395 | - foreach( $model_classnames as $model_classname => $properties_added_in_this_version ) { |
|
396 | - if( is_subclass_of( $model, $model_classname ) ) { |
|
397 | - $extra_properties = array_merge( $extra_properties, $properties_added_in_this_version ); |
|
394 | + foreach ($this->resource_changes_between_requested_version_and_current() as $version => $model_classnames) { |
|
395 | + foreach ($model_classnames as $model_classname => $properties_added_in_this_version) { |
|
396 | + if (is_subclass_of($model, $model_classname)) { |
|
397 | + $extra_properties = array_merge($extra_properties, $properties_added_in_this_version); |
|
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | * @param \EEM_Base $model |
408 | 408 | * @return \EE_Model_Relation_Base[] |
409 | 409 | */ |
410 | - public function relation_settings( \EEM_Base $model ) { |
|
410 | + public function relation_settings(\EEM_Base $model) { |
|
411 | 411 | $relations = array(); |
412 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
413 | - if( $this->is_model_name_in_this_version( $relation_name ) ) { |
|
414 | - $relations[ $relation_name ] = $relation_obj; |
|
412 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
413 | + if ($this->is_model_name_in_this_version($relation_name)) { |
|
414 | + $relations[$relation_name] = $relation_obj; |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | //filter the results, but use the old filter name |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | */ |
43 | 43 | |
44 | -if ( function_exists( 'espresso_version' ) ) { |
|
44 | +if (function_exists('espresso_version')) { |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * espresso_duplicate_plugin_error |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | function espresso_duplicate_plugin_error() { |
51 | 51 | ?> |
52 | 52 | <div class="error"> |
53 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
53 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
54 | 54 | </div> |
55 | 55 | <?php |
56 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
56 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
57 | 57 | } |
58 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
58 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | 59 | |
60 | 60 | } else { |
61 | 61 | |
@@ -66,103 +66,103 @@ discard block |
||
66 | 66 | * @return string |
67 | 67 | */ |
68 | 68 | function espresso_version() { |
69 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.8.rc.012' ); |
|
69 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.8.rc.012'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | // define versions |
73 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
74 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
75 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
76 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
77 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
78 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
79 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
73 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
74 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
75 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
76 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
77 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
78 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
79 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
80 | 80 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
81 | - if ( ! defined( 'DS' ) ) { |
|
82 | - define( 'DS', '/' ); |
|
81 | + if ( ! defined('DS')) { |
|
82 | + define('DS', '/'); |
|
83 | 83 | } |
84 | - if ( ! defined( 'PS' ) ) { |
|
85 | - define( 'PS', PATH_SEPARATOR ); |
|
84 | + if ( ! defined('PS')) { |
|
85 | + define('PS', PATH_SEPARATOR); |
|
86 | 86 | } |
87 | - if ( ! defined( 'SP' ) ) { |
|
88 | - define( 'SP', ' ' ); |
|
87 | + if ( ! defined('SP')) { |
|
88 | + define('SP', ' '); |
|
89 | 89 | } |
90 | - if ( ! defined( 'EENL' ) ) { |
|
91 | - define( 'EENL', "\n" ); |
|
90 | + if ( ! defined('EENL')) { |
|
91 | + define('EENL', "\n"); |
|
92 | 92 | } |
93 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
93 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
94 | 94 | // define the plugin directory and URL |
95 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
95 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
96 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | 98 | // main root folder paths |
99 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
100 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
101 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
102 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
103 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
104 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
105 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
106 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
99 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
100 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
101 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
102 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
103 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
104 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
105 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
106 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
107 | 107 | // core system paths |
108 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
109 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
110 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
111 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
112 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
113 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
114 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
115 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
116 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
117 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
118 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
119 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
108 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
109 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
110 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
111 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
112 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
113 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
114 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
115 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
116 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
117 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
118 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
119 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
120 | 120 | // gateways |
121 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
122 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
121 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
122 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
123 | 123 | // asset URL paths |
124 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
125 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
126 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
127 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
128 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
129 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
124 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
125 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
126 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
127 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
128 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
129 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
130 | 130 | // define upload paths |
131 | 131 | $uploads = wp_upload_dir(); |
132 | 132 | // define the uploads directory and URL |
133 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
134 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
133 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
135 | 135 | // define the templates directory and URL |
136 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
136 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
138 | 138 | // define the gateway directory and URL |
139 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
139 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | 141 | // languages folder/path |
142 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
143 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
142 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
143 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
144 | 144 | //check for dompdf fonts in uploads |
145 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
146 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
145 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
146 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
147 | 147 | } |
148 | 148 | //ajax constants |
149 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
150 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
149 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
150 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
151 | 151 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
152 | 152 | //you're better to use this than its straight value (currently -1) in case you ever |
153 | 153 | //want to change its default value! or find when -1 means infinity |
154 | - define( 'EE_INF_IN_DB', -1 ); |
|
155 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
156 | - define( 'EE_DEBUG', false ); |
|
154 | + define('EE_INF_IN_DB', -1); |
|
155 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
156 | + define('EE_DEBUG', false); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * espresso_plugin_activation |
160 | 160 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
161 | 161 | */ |
162 | 162 | function espresso_plugin_activation() { |
163 | - update_option( 'ee_espresso_activation', true ); |
|
163 | + update_option('ee_espresso_activation', true); |
|
164 | 164 | } |
165 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
165 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // } |
177 | 177 | // |
178 | 178 | } |
179 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
179 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function espresso_load_error_handling() { |
188 | 188 | // load debugging tools |
189 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
190 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
189 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
190 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
191 | 191 | EEH_Debug_Tools::instance(); |
192 | 192 | } |
193 | 193 | // load error handling |
194 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
195 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
194 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
195 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
196 | 196 | } else { |
197 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
197 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @param string $full_path_to_file |
209 | 209 | * @throws EE_Error |
210 | 210 | */ |
211 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
211 | + function espresso_load_required($classname, $full_path_to_file) { |
|
212 | 212 | static $error_handling_loaded = false; |
213 | - if ( ! $error_handling_loaded ) { |
|
213 | + if ( ! $error_handling_loaded) { |
|
214 | 214 | espresso_load_error_handling(); |
215 | 215 | $error_handling_loaded = true; |
216 | 216 | } |
217 | - if ( is_readable( $full_path_to_file ) ) { |
|
218 | - require_once( $full_path_to_file ); |
|
217 | + if (is_readable($full_path_to_file)) { |
|
218 | + require_once($full_path_to_file); |
|
219 | 219 | } else { |
220 | - throw new EE_Error ( sprintf( |
|
221 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
220 | + throw new EE_Error(sprintf( |
|
221 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
222 | 222 | $classname |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
228 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
229 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
227 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
228 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
229 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
230 | 230 | new EE_Bootstrap(); |
231 | 231 | |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | |
237 | 237 | |
238 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
238 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
239 | 239 | /** |
240 | 240 | * deactivate_plugin |
241 | 241 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
248 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
249 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
247 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
248 | + if ( ! function_exists('deactivate_plugins')) { |
|
249 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
250 | 250 | } |
251 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
252 | - deactivate_plugins( $plugin_basename ); |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | 253 | } |
254 | 254 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
101 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) ) { |
|
100 | + if ( ! isset($_SERVER['PHP_AUTH_USER']) |
|
101 | + && ! isset($_SERVER['HTTP_AUTHORIZATION'])) { |
|
102 | 102 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
103 | 103 | return; |
104 | 104 | } |
105 | 105 | //ok they're using the WP API with Basic Auth |
106 | 106 | $message = sprintf( |
107 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
107 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
108 | 108 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
109 | 109 | '</a>', |
110 | 110 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
111 | 111 | '<br/>' |
112 | 112 | ); |
113 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
114 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
115 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
113 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
114 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
115 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
116 | 116 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
117 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
117 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
118 | 118 | //and send the message to the site admin too |
119 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
120 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
120 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | /** |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | * appear the same as they always did |
126 | 126 | */ |
127 | 127 | protected static function _set_hooks_for_changes() { |
128 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
129 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
128 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
129 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
130 | 130 | //ignore the base parent class |
131 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
131 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
132 | 132 | continue; |
133 | 133 | } |
134 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
135 | - if ( class_exists( $full_classname )) { |
|
134 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
135 | + if (class_exists($full_classname)) { |
|
136 | 136 | $instance_of_class = new $full_classname; |
137 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
137 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
138 | 138 | $instance_of_class->set_hooks(); |
139 | 139 | } |
140 | 140 | } |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
148 | 148 | */ |
149 | 149 | public static function register_routes() { |
150 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
151 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
152 | - foreach( $routes as $route ) { |
|
150 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
151 | + foreach ($relative_urls as $endpoint => $routes) { |
|
152 | + foreach ($routes as $route) { |
|
153 | 153 | register_rest_route( |
154 | 154 | $namespace, |
155 | 155 | $endpoint, |
156 | 156 | array( |
157 | - 'callback' => $route[ 'callback' ], |
|
158 | - 'methods' => $route[ 'methods' ], |
|
159 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
157 | + 'callback' => $route['callback'], |
|
158 | + 'methods' => $route['methods'], |
|
159 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
160 | 160 | ) |
161 | 161 | ); |
162 | 162 | } |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * next time the WP API is used |
171 | 171 | */ |
172 | 172 | public static function invalidate_cached_route_data_on_version_change() { |
173 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
173 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
174 | 174 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
175 | 175 | } |
176 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
177 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
176 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
177 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
178 | 178 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
179 | 179 | } |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public static function invalidate_cached_route_data() { |
187 | 187 | //delete the saved EE REST API routes |
188 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
188 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function get_ee_route_data() { |
200 | 200 | $ee_routes = array(); |
201 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
202 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
201 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
202 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
203 | 203 | } |
204 | 204 | return $ee_routes; |
205 | 205 | } |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | * @param boolean $hidden_endpoints |
212 | 212 | * @return array |
213 | 213 | */ |
214 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
215 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
216 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
217 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
214 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
215 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
216 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
217 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
218 | 218 | } |
219 | 219 | return $ee_routes; |
220 | 220 | } |
@@ -228,18 +228,18 @@ discard block |
||
228 | 228 | * @param boolean $hidden_endpoints |
229 | 229 | * @return mixed|null|void |
230 | 230 | */ |
231 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
231 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
232 | 232 | $instance = self::instance(); |
233 | 233 | $routes = apply_filters( |
234 | 234 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
235 | 235 | array_replace_recursive( |
236 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
237 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
238 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
239 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
236 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
237 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
238 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
239 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
240 | 240 | ) |
241 | 241 | ); |
242 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
242 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
243 | 243 | return $routes; |
244 | 244 | } |
245 | 245 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public static function save_ee_routes() { |
253 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
253 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
254 | 254 | $instance = self::instance(); |
255 | 255 | $routes = apply_filters( |
256 | 256 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $instance->_register_rpc_routes() |
262 | 262 | ) |
263 | 263 | ); |
264 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
264 | + update_option(self::saved_routes_option_names, $routes, true); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | */ |
273 | 273 | protected function _register_model_routes() { |
274 | 274 | $model_routes = array( ); |
275 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
276 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
275 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
276 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
277 | 277 | } |
278 | 278 | return $model_routes; |
279 | 279 | } |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | * @param boolean $hidden_endpoint |
285 | 285 | * @return array |
286 | 286 | */ |
287 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
288 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
287 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
288 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
289 | 289 | $models_to_register = apply_filters( |
290 | 290 | 'FHEE__EED_Core_REST_API___register_model_routes', |
291 | 291 | $model_version_info->models_for_requested_version() |
@@ -294,21 +294,21 @@ discard block |
||
294 | 294 | unset($models_to_register['Extra_Meta']); |
295 | 295 | unset($models_to_register['Extra_Join']); |
296 | 296 | $model_routes = array(); |
297 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
298 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
297 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
298 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
299 | 299 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
300 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
301 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
302 | - $model_routes[ $plural_model_route ] = array( |
|
300 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
301 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
302 | + $model_routes[$plural_model_route] = array( |
|
303 | 303 | array( |
304 | 304 | 'callback' => array( |
305 | 305 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
306 | 306 | 'handle_request_get_all' ), |
307 | 307 | 'methods' => WP_REST_Server::READABLE, |
308 | 308 | 'hidden_endpoint' => $hidden_endpoint, |
309 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
309 | + 'args' => $this->_get_read_query_params($model, $version), |
|
310 | 310 | '_links' => array( |
311 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
311 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
312 | 312 | ) |
313 | 313 | ), |
314 | 314 | // array( |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | // 'hidden_endpoint' => $hidden_endpoint |
320 | 320 | // ) |
321 | 321 | ); |
322 | - $model_routes[ $singular_model_route ] = array( |
|
322 | + $model_routes[$singular_model_route] = array( |
|
323 | 323 | array( |
324 | 324 | 'callback' => array( |
325 | 325 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
326 | 326 | 'handle_request_get_one' ), |
327 | 327 | 'methods' => WP_REST_Server::READABLE, |
328 | 328 | 'hidden_endpoint' => $hidden_endpoint, |
329 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
329 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
330 | 330 | ), |
331 | 331 | // array( |
332 | 332 | // 'callback' => array( |
@@ -337,19 +337,19 @@ discard block |
||
337 | 337 | // ), |
338 | 338 | ); |
339 | 339 | //@todo: also handle DELETE for a single item |
340 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
340 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
341 | 341 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
342 | 342 | $relation_name, |
343 | 343 | $relation_obj |
344 | 344 | ); |
345 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
345 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
346 | 346 | array( |
347 | 347 | 'callback' => array( |
348 | 348 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
349 | 349 | 'handle_request_get_related' ), |
350 | 350 | 'methods' => WP_REST_Server::READABLE, |
351 | 351 | 'hidden_endpoint' => $hidden_endpoint, |
352 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
352 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
353 | 353 | ), |
354 | 354 | // array( |
355 | 355 | // 'callback' => array( |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function _register_rpc_routes() { |
374 | 374 | $routes = array(); |
375 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
376 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
375 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
376 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
377 | 377 | } |
378 | 378 | return $routes; |
379 | 379 | } |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | * @param boolean $hidden_endpoint |
385 | 385 | * @return array |
386 | 386 | */ |
387 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
387 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
388 | 388 | $this_versions_routes = array(); |
389 | 389 | //checkin endpoint |
390 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
390 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
391 | 391 | array( |
392 | 392 | 'callback' => array( |
393 | 393 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | 'force' => array( |
399 | 399 | 'required' => false, |
400 | 400 | 'default' => false, |
401 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
401 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ) |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $version |
418 | 418 | * @return array |
419 | 419 | */ |
420 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
420 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
421 | 421 | return apply_filters( |
422 | 422 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
423 | 423 | array( |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | 'calculate' => array( |
429 | 429 | 'required' => false, |
430 | 430 | 'default' => '', |
431 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
431 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
432 | 432 | ) |
433 | 433 | ), |
434 | 434 | $model, |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | * @return array describing the args acceptable when querying this model |
447 | 447 | * @throws \EE_Error |
448 | 448 | */ |
449 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
449 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
450 | 450 | $default_orderby = array(); |
451 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
452 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
451 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
452 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
453 | 453 | } |
454 | 454 | return array_merge( |
455 | - $this->_get_response_selection_query_params( $model, $version ), |
|
455 | + $this->_get_response_selection_query_params($model, $version), |
|
456 | 456 | array( |
457 | 457 | 'where' => array( |
458 | 458 | 'required' => false, |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | */ |
490 | 490 | protected function _register_config_routes() { |
491 | 491 | $config_routes = array(); |
492 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
493 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
492 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
493 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
494 | 494 | } |
495 | 495 | return $config_routes; |
496 | 496 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param boolean $hidden_endpoint |
502 | 502 | * @return array |
503 | 503 | */ |
504 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
504 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
505 | 505 | return array( |
506 | 506 | 'config' => array( |
507 | 507 | array( |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | */ |
523 | 523 | protected function _register_meta_routes() { |
524 | 524 | $meta_routes = array(); |
525 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
526 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
525 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
526 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
527 | 527 | } |
528 | 528 | return $meta_routes; |
529 | 529 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @param boolean $hidden_endpoint |
535 | 535 | * @return array |
536 | 536 | */ |
537 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
537 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
538 | 538 | return array( |
539 | 539 | 'resources' => array( |
540 | 540 | array( |
@@ -556,13 +556,13 @@ discard block |
||
556 | 556 | * @param array $route_data |
557 | 557 | * @return array |
558 | 558 | */ |
559 | - public static function hide_old_endpoints( $route_data ) { |
|
560 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
561 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
562 | - foreach( $routes as $route ) { |
|
563 | - if( $route[ 'hidden_endpoint' ] ) { |
|
564 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
565 | - unset( $route_data[ $full_route ] ); |
|
559 | + public static function hide_old_endpoints($route_data) { |
|
560 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
561 | + foreach ($relative_urls as $endpoint => $routes) { |
|
562 | + foreach ($routes as $route) { |
|
563 | + if ($route['hidden_endpoint']) { |
|
564 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
565 | + unset($route_data[$full_route]); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | } |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public static function latest_rest_api_version() { |
603 | 603 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
604 | - $versions_served_keys = array_keys( $versions_served ); |
|
605 | - return end( $versions_served_keys ); |
|
604 | + $versions_served_keys = array_keys($versions_served); |
|
605 | + return end($versions_served_keys); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -616,32 +616,32 @@ discard block |
||
616 | 616 | public static function versions_served() { |
617 | 617 | $versions_served = array(); |
618 | 618 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
619 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
620 | - reset( $possibly_served_versions ); |
|
621 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
622 | - $latest_version = end( $versions_served_historically ); |
|
623 | - reset( $versions_served_historically ); |
|
619 | + $lowest_compatible_version = end($possibly_served_versions); |
|
620 | + reset($possibly_served_versions); |
|
621 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
622 | + $latest_version = end($versions_served_historically); |
|
623 | + reset($versions_served_historically); |
|
624 | 624 | //for each version of core we have ever served: |
625 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
625 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
626 | 626 | //if it's not above the current core version, and it's compatible with the current version of core |
627 | - if( $key_versioned_endpoint == $latest_version ) { |
|
627 | + if ($key_versioned_endpoint == $latest_version) { |
|
628 | 628 | //don't hide the latest version in the index |
629 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
630 | - } else if( |
|
629 | + $versions_served[$key_versioned_endpoint] = false; |
|
630 | + } else if ( |
|
631 | 631 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
632 | 632 | && $key_versioned_endpoint >= $lowest_compatible_version |
633 | 633 | ) { |
634 | 634 | //include, but hide, previous versions which are still supported |
635 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
636 | - } elseif( |
|
635 | + $versions_served[$key_versioned_endpoint] = true; |
|
636 | + } elseif ( |
|
637 | 637 | apply_filters( |
638 | 638 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
639 | 639 | false, |
640 | 640 | $possibly_served_versions |
641 | 641 | ) |
642 | - ){ |
|
642 | + ) { |
|
643 | 643 | //if a version is no longer supported, don't include it in index or list of versions served |
644 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
644 | + $versions_served[$key_versioned_endpoint] = true; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | return $versions_served; |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @return string |
655 | 655 | */ |
656 | 656 | public static function core_version() { |
657 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
657 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @param WP $WP |
680 | 680 | * @return void |
681 | 681 | */ |
682 | - public function run( $WP ) { |
|
682 | + public function run($WP) { |
|
683 | 683 | |
684 | 684 | } |
685 | 685 |