@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | } |
6 | 6 | /** |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | //define some page related constants |
30 | - define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' ); |
|
31 | - define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG )); |
|
32 | - define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS ); |
|
33 | - define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS ); |
|
34 | - define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' ); |
|
35 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
30 | + define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings'); |
|
31 | + define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG)); |
|
32 | + define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS); |
|
33 | + define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS); |
|
34 | + define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/'); |
|
35 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
36 | 36 | //check that there are active gateways on all admin page loads. but dont do it just yet |
37 | 37 | // echo "constructing payments admin page";die; |
38 | - add_action('admin_notices',array($this,'check_payment_gateway_setup')); |
|
38 | + add_action('admin_notices', array($this, 'check_payment_gateway_setup')); |
|
39 | 39 | parent::__construct(); |
40 | 40 | } |
41 | 41 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
59 | 59 | 'parent_slug' => 'espresso_events', |
60 | 60 | 'menu_slug' => EE_PAYMENTS_PG_SLUG, |
61 | - 'menu_label' => __( 'Payment Methods', 'event_espresso' ), |
|
61 | + 'menu_label' => __('Payment Methods', 'event_espresso'), |
|
62 | 62 | 'capability' => 'ee_manage_gateways', |
63 | 63 | 'admin_init_page' => $this, |
64 | 64 | ) |
@@ -72,25 +72,25 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function check_payment_gateway_setup(){ |
|
75 | + public function check_payment_gateway_setup() { |
|
76 | 76 | //ONLY do this check if models can query |
77 | 77 | //and avoid a bug where when we nuke EE4's data that this causes a fatal error |
78 | 78 | //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539 |
79 | 79 | if ( |
80 | 80 | ! EE_Maintenance_Mode::instance()->models_can_query() |
81 | - || ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() ) |
|
81 | + || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) |
|
82 | 82 | ) { |
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | // ensure Payment_Method model is loaded |
88 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
89 | - $actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
90 | - if( $actives < 1 ){ |
|
88 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
89 | + $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
90 | + if ($actives < 1) { |
|
91 | 91 | $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL); |
92 | 92 | echo '<div class="error"> |
93 | - <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p> |
|
93 | + <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p> |
|
94 | 94 | </div>'; |
95 | 95 | } |
96 | 96 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @throws \EE_Error |
102 | 102 | */ |
103 | 103 | protected function _get_table_analysis() { |
104 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
104 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
105 | 105 | return $this->_table_analysis; |
106 | 106 | } else { |
107 | 107 | throw new \EE_Error( |
108 | 108 | sprintf( |
109 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
110 | - get_class( $this ) |
|
109 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
110 | + get_class($this) |
|
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
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 | * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // defined some new constants related to caffeinated folder |
14 | -define( 'EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/' ); |
|
15 | -define( 'EE_CAF_CORE', EE_CAFF_PATH . 'core' . DS ); |
|
16 | -define( 'EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries' . DS ); |
|
17 | -define( 'EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods' . DS ); |
|
14 | +define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/'); |
|
15 | +define('EE_CAF_CORE', EE_CAFF_PATH.'core'.DS); |
|
16 | +define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries'.DS); |
|
17 | +define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods'.DS); |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
@@ -35,31 +35,31 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * EE_Brewing_Regular constructor. |
37 | 37 | */ |
38 | - public function __construct( TableAnalysis $table_analysis ) { |
|
38 | + public function __construct(TableAnalysis $table_analysis) { |
|
39 | 39 | $this->_table_analysis = $table_analysis; |
40 | - if ( defined( 'EE_CAFF_PATH' ) ) { |
|
40 | + if (defined('EE_CAFF_PATH')) { |
|
41 | 41 | // activation |
42 | - add_action( 'AHEE__EEH_Activation__initialize_db_content', array( $this, 'initialize_caf_db_content' ) ); |
|
42 | + add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content')); |
|
43 | 43 | // load caff init |
44 | - add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'caffeinated_init' ) ); |
|
44 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init')); |
|
45 | 45 | // remove the "powered by" credit link from receipts and invoices |
46 | - add_filter( 'FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false' ); |
|
46 | + add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false'); |
|
47 | 47 | // add caffeinated modules |
48 | 48 | add_filter( |
49 | 49 | 'FHEE__EE_Config__register_modules__modules_to_register', |
50 | - array( $this, 'caffeinated_modules_to_register' ) |
|
50 | + array($this, 'caffeinated_modules_to_register') |
|
51 | 51 | ); |
52 | 52 | // load caff scripts |
53 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_caffeinated_scripts' ), 10 ); |
|
54 | - add_filter( 'FHEE__EE_Registry__load_helper__helper_paths', array( $this, 'caf_helper_paths' ), 10 ); |
|
53 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10); |
|
54 | + add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
|
55 | 55 | add_filter( |
56 | 56 | 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
57 | - array( $this, 'caf_payment_methods' ) |
|
57 | + array($this, 'caf_payment_methods') |
|
58 | 58 | ); |
59 | 59 | // caffeinated constructed |
60 | - do_action( 'AHEE__EE_Brewing_Regular__construct__complete' ); |
|
60 | + do_action('AHEE__EE_Brewing_Regular__construct__complete'); |
|
61 | 61 | //seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer |
62 | - add_filter( 'FHEE__ee_show_affiliate_links', '__return_false' ); |
|
62 | + add_filter('FHEE__ee_show_affiliate_links', '__return_false'); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param array $paths original helper paths array |
72 | 72 | * @return array new array of paths |
73 | 73 | */ |
74 | - public function caf_helper_paths( $paths ) { |
|
75 | - $paths[] = EE_CAF_CORE . 'helpers' . DS; |
|
74 | + public function caf_helper_paths($paths) { |
|
75 | + $paths[] = EE_CAF_CORE.'helpers'.DS; |
|
76 | 76 | return $paths; |
77 | 77 | } |
78 | 78 | |
@@ -89,21 +89,21 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @global wpdb $wpdb |
91 | 91 | */ |
92 | - public function initialize_caf_db_content(){ |
|
92 | + public function initialize_caf_db_content() { |
|
93 | 93 | global $wpdb; |
94 | 94 | //use same method of getting creator id as the version introducing the change |
95 | - $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id',get_current_user_id()); |
|
95 | + $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
|
96 | 96 | $price_type_table = $wpdb->prefix."esp_price_type"; |
97 | 97 | $price_table = $wpdb->prefix."esp_price"; |
98 | - if ( $this->_get_table_analysis()->tableExists( $price_type_table ) ) { |
|
98 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
99 | 99 | |
100 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types |
|
101 | - $tax_price_type_count = $wpdb->get_var( $SQL ); |
|
102 | - if ( $tax_price_type_count <= 1 ) { |
|
100 | + $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; //include trashed price types |
|
101 | + $tax_price_type_count = $wpdb->get_var($SQL); |
|
102 | + if ($tax_price_type_count <= 1) { |
|
103 | 103 | $wpdb->insert( |
104 | 104 | $price_type_table, |
105 | 105 | array( |
106 | - 'PRT_name' => __( "Regional Tax", "event_espresso" ), |
|
106 | + 'PRT_name' => __("Regional Tax", "event_espresso"), |
|
107 | 107 | 'PBT_ID' => 4, |
108 | 108 | 'PRT_is_percent' => true, |
109 | 109 | 'PRT_order' => 60, |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | 'PRT_wp_user' => $default_creator_id, |
112 | 112 | ), |
113 | 113 | array( |
114 | - '%s',//PRT_name |
|
115 | - '%d',//PBT_id |
|
116 | - '%d',//PRT_is_percent |
|
117 | - '%d',//PRT_order |
|
118 | - '%d',//PRT_deleted |
|
114 | + '%s', //PRT_name |
|
115 | + '%d', //PBT_id |
|
116 | + '%d', //PRT_is_percent |
|
117 | + '%d', //PRT_order |
|
118 | + '%d', //PRT_deleted |
|
119 | 119 | '%d', //PRT_wp_user |
120 | 120 | ) |
121 | 121 | ); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $result = $wpdb->insert( |
124 | 124 | $price_type_table, |
125 | 125 | array( |
126 | - 'PRT_name' => __( "Federal Tax", "event_espresso" ), |
|
126 | + 'PRT_name' => __("Federal Tax", "event_espresso"), |
|
127 | 127 | 'PBT_ID' => 4, |
128 | 128 | 'PRT_is_percent' => true, |
129 | 129 | 'PRT_order' => 70, |
@@ -131,21 +131,21 @@ discard block |
||
131 | 131 | 'PRT_wp_user' => $default_creator_id, |
132 | 132 | ), |
133 | 133 | array( |
134 | - '%s',//PRT_name |
|
135 | - '%d',//PBT_id |
|
136 | - '%d',//PRT_is_percent |
|
137 | - '%d',//PRT_order |
|
138 | - '%d',//PRT_deleted |
|
134 | + '%s', //PRT_name |
|
135 | + '%d', //PBT_id |
|
136 | + '%d', //PRT_is_percent |
|
137 | + '%d', //PRT_order |
|
138 | + '%d', //PRT_deleted |
|
139 | 139 | '%d' //PRT_wp_user |
140 | 140 | ) |
141 | 141 | ); |
142 | - if ( $result ) { |
|
142 | + if ($result) { |
|
143 | 143 | $wpdb->insert( |
144 | 144 | $price_table, |
145 | 145 | array( |
146 | 146 | 'PRT_ID' => $wpdb->insert_id, |
147 | 147 | 'PRC_amount' => 15.00, |
148 | - 'PRC_name' => __( "Sales Tax", "event_espresso" ), |
|
148 | + 'PRC_name' => __("Sales Tax", "event_espresso"), |
|
149 | 149 | 'PRC_desc' => '', |
150 | 150 | 'PRC_is_default' => true, |
151 | 151 | 'PRC_overrides' => null, |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | 'PRC_wp_user' => $default_creator_id, |
156 | 156 | ), |
157 | 157 | array( |
158 | - '%d',//PRT_id |
|
159 | - '%f',//PRC_amount |
|
160 | - '%s',//PRC_name |
|
161 | - '%s',//PRC_desc |
|
162 | - '%d',//PRC_is_default |
|
163 | - '%d',//PRC_overrides |
|
164 | - '%d',//PRC_deleted |
|
165 | - '%d',//PRC_order |
|
166 | - '%d',//PRC_parent |
|
158 | + '%d', //PRT_id |
|
159 | + '%f', //PRC_amount |
|
160 | + '%s', //PRC_name |
|
161 | + '%s', //PRC_desc |
|
162 | + '%d', //PRC_is_default |
|
163 | + '%d', //PRC_overrides |
|
164 | + '%d', //PRC_deleted |
|
165 | + '%d', //PRC_order |
|
166 | + '%d', //PRC_parent |
|
167 | 167 | '%d' //PRC_wp_user |
168 | 168 | ) |
169 | 169 | ); |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | * @param array $modules_to_register |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - public function caffeinated_modules_to_register( $modules_to_register = array() ) { |
|
185 | - if ( is_readable( EE_CAFF_PATH . 'modules' ) ) { |
|
186 | - $caffeinated_modules_to_register = glob( EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR ); |
|
187 | - if ( is_array( $caffeinated_modules_to_register ) && ! empty( $caffeinated_modules_to_register ) ) { |
|
188 | - $modules_to_register = array_merge( $modules_to_register, $caffeinated_modules_to_register ); |
|
184 | + public function caffeinated_modules_to_register($modules_to_register = array()) { |
|
185 | + if (is_readable(EE_CAFF_PATH.'modules')) { |
|
186 | + $caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules'.DS.'*', GLOB_ONLYDIR); |
|
187 | + if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
|
188 | + $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | return $modules_to_register; |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | |
196 | 196 | public function caffeinated_init() { |
197 | 197 | // EE_Register_CPTs hooks |
198 | - add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( $this, 'filter_taxonomies' ), 10 ); |
|
199 | - add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( $this, 'filter_cpts' ), 10 ); |
|
200 | - add_filter( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', array( $this, 'nav_metabox_items' ), 10 ); |
|
201 | - EE_Registry::instance()->load_file( EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false ); |
|
198 | + add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10); |
|
199 | + add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10); |
|
200 | + add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10); |
|
201 | + EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false); |
|
202 | 202 | // caffeinated_init__complete hook |
203 | - do_action( 'AHEE__EE_Brewing_Regular__caffeinated_init__complete' ); |
|
203 | + do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param array $taxonomy_array |
218 | 218 | * @return array |
219 | 219 | */ |
220 | - public function filter_taxonomies( array $taxonomy_array ) { |
|
220 | + public function filter_taxonomies(array $taxonomy_array) { |
|
221 | 221 | $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true; |
222 | 222 | return $taxonomy_array; |
223 | 223 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $cpt_array |
229 | 229 | * @return mixed |
230 | 230 | */ |
231 | - public function filter_cpts( array $cpt_array ) { |
|
231 | + public function filter_cpts(array $cpt_array) { |
|
232 | 232 | $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true; |
233 | 233 | return $cpt_array; |
234 | 234 | } |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | * @param array $menuitems |
240 | 240 | * @return array |
241 | 241 | */ |
242 | - public function nav_metabox_items( array $menuitems ) { |
|
242 | + public function nav_metabox_items(array $menuitems) { |
|
243 | 243 | $menuitems[] = array( |
244 | - 'title' => __( 'Venue List', 'event_espresso' ), |
|
245 | - 'url' => get_post_type_archive_link( 'espresso_venues' ), |
|
246 | - 'description' => __( 'Archive page for all venues.', 'event_espresso' ), |
|
244 | + 'title' => __('Venue List', 'event_espresso'), |
|
245 | + 'url' => get_post_type_archive_link('espresso_venues'), |
|
246 | + 'description' => __('Archive page for all venues.', 'event_espresso'), |
|
247 | 247 | ); |
248 | 248 | return $menuitems; |
249 | 249 | } |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | * @param array $payment_method_paths |
257 | 257 | * @return array values are folder paths to payment method folders |
258 | 258 | */ |
259 | - public function caf_payment_methods( $payment_method_paths ) { |
|
260 | - $caf_payment_methods_paths = glob( EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR ); |
|
261 | - $payment_method_paths = array_merge( $payment_method_paths, $caf_payment_methods_paths ); |
|
259 | + public function caf_payment_methods($payment_method_paths) { |
|
260 | + $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR); |
|
261 | + $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths); |
|
262 | 262 | return $payment_method_paths; |
263 | 263 | } |
264 | 264 | /** |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | * @throws \EE_Error |
268 | 268 | */ |
269 | 269 | protected function _get_table_analysis() { |
270 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
270 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
271 | 271 | return $this->_table_analysis; |
272 | 272 | } else { |
273 | 273 | throw new \EE_Error( |
274 | 274 | sprintf( |
275 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
276 | - get_class( $this ) |
|
275 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
276 | + get_class($this) |
|
277 | 277 | ) |
278 | 278 | ); |
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
282 | 282 | $brewing = new EE_Brewing_Regular( |
283 | - EE_Registry::instance()->create( 'TableAnalysis', array(), true ) |
|
283 | + EE_Registry::instance()->create('TableAnalysis', array(), true) |
|
284 | 284 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param \EE_Request $request |
76 | 76 | * @param \EE_Response $response |
77 | 77 | */ |
78 | - protected function __construct( EE_Request $request, EE_Response $response ) { |
|
78 | + protected function __construct(EE_Request $request, EE_Response $response) { |
|
79 | 79 | $this->_request = $request; |
80 | 80 | $this->_response = $response; |
81 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
82 | - do_action( 'EE_Dependency_Map____construct' ); |
|
81 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
82 | + do_action('EE_Dependency_Map____construct'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | * @param \EE_Response $response |
102 | 102 | * @return \EE_Dependency_Map instance |
103 | 103 | */ |
104 | - public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
|
104 | + public static function instance(EE_Request $request = null, EE_Response $response = null) { |
|
105 | 105 | // check if class object is instantiated, and instantiated properly |
106 | - if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
|
107 | - self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
106 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
107 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
108 | 108 | } |
109 | 109 | return self::$_instance; |
110 | 110 | } |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * @param array $dependencies |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function register_dependencies( $class, $dependencies ) { |
|
120 | - if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
|
119 | + public static function register_dependencies($class, $dependencies) { |
|
120 | + if ( ! isset(self::$_instance->_dependency_map[$class])) { |
|
121 | 121 | // we need to make sure that any aliases used when registering a dependency |
122 | 122 | // get resolved to the correct class name |
123 | - foreach ( (array) $dependencies as $dependency => $load_source ) { |
|
124 | - $alias = self::$_instance->get_alias( $dependency ); |
|
125 | - unset( $dependencies[ $dependency ] ); |
|
126 | - $dependencies[ $alias ] = $load_source; |
|
123 | + foreach ((array) $dependencies as $dependency => $load_source) { |
|
124 | + $alias = self::$_instance->get_alias($dependency); |
|
125 | + unset($dependencies[$dependency]); |
|
126 | + $dependencies[$alias] = $load_source; |
|
127 | 127 | } |
128 | - self::$_instance->_dependency_map[ $class ] = (array) $dependencies; |
|
128 | + self::$_instance->_dependency_map[$class] = (array) $dependencies; |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | return false; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | * @return bool |
140 | 140 | * @throws \EE_Error |
141 | 141 | */ |
142 | - public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
|
142 | + public static function register_class_loader($class_name, $loader = 'load_core') { |
|
143 | 143 | // check that loader method starts with "load_" and exists in EE_Registry |
144 | - if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader ) ) { |
|
144 | + if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) { |
|
145 | 145 | throw new EE_Error( |
146 | 146 | sprintf( |
147 | - __( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
|
147 | + __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'), |
|
148 | 148 | $loader |
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
152 | - $class_name = self::$_instance->get_alias( $class_name ); |
|
153 | - if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
|
154 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
152 | + $class_name = self::$_instance->get_alias($class_name); |
|
153 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
154 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
155 | 155 | return true; |
156 | 156 | } |
157 | 157 | return false; |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param string $class_name |
175 | 175 | * @return boolean |
176 | 176 | */ |
177 | - public function has( $class_name = '' ) { |
|
178 | - return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
|
177 | + public function has($class_name = '') { |
|
178 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param string $dependency |
188 | 188 | * @return bool |
189 | 189 | */ |
190 | - public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
|
191 | - $dependency = $this->get_alias( $dependency ); |
|
192 | - return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
|
190 | + public function has_dependency_for_class($class_name = '', $dependency = '') { |
|
191 | + $dependency = $this->get_alias($dependency); |
|
192 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
193 | 193 | ? true |
194 | 194 | : false; |
195 | 195 | } |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | * @param string $dependency |
204 | 204 | * @return int |
205 | 205 | */ |
206 | - public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
|
207 | - $dependency = $this->get_alias( $dependency ); |
|
208 | - return $this->has_dependency_for_class( $class_name, $dependency ) |
|
209 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
206 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') { |
|
207 | + $dependency = $this->get_alias($dependency); |
|
208 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
209 | + ? $this->_dependency_map[$class_name][$dependency] |
|
210 | 210 | : EE_Dependency_Map::not_registered; |
211 | 211 | } |
212 | 212 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | * @param string $class_name |
217 | 217 | * @return string | Closure |
218 | 218 | */ |
219 | - public function class_loader( $class_name ) { |
|
220 | - $class_name = $this->get_alias( $class_name ); |
|
221 | - return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
|
219 | + public function class_loader($class_name) { |
|
220 | + $class_name = $this->get_alias($class_name); |
|
221 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | * @param string $class_name |
239 | 239 | * @param string $alias |
240 | 240 | */ |
241 | - public function add_alias( $class_name, $alias ) { |
|
242 | - $this->_aliases[ $class_name ] = $alias; |
|
241 | + public function add_alias($class_name, $alias) { |
|
242 | + $this->_aliases[$class_name] = $alias; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @param string $class_name |
251 | 251 | * @return boolean |
252 | 252 | */ |
253 | - public function has_alias( $class_name = '' ) { |
|
254 | - return isset( $this->_aliases[ $class_name ] ) ? true : false; |
|
253 | + public function has_alias($class_name = '') { |
|
254 | + return isset($this->_aliases[$class_name]) ? true : false; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | * @param string $class_name |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - public function get_alias( $class_name = '' ) { |
|
275 | - return $this->has_alias( $class_name ) |
|
276 | - ? $this->get_alias( $this->_aliases[ $class_name ] ) |
|
274 | + public function get_alias($class_name = '') { |
|
275 | + return $this->has_alias($class_name) |
|
276 | + ? $this->get_alias($this->_aliases[$class_name]) |
|
277 | 277 | : $class_name; |
278 | 278 | } |
279 | 279 | |
@@ -489,17 +489,17 @@ discard block |
||
489 | 489 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
490 | 490 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
491 | 491 | 'EE_Messages_Generator' => function() { |
492 | - return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
|
492 | + return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false); |
|
493 | 493 | }, |
494 | - 'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
|
495 | - return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
|
494 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
495 | + return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false); |
|
496 | 496 | }, |
497 | 497 | //load_model |
498 | 498 | 'EEM_Message_Template_Group' => 'load_model', |
499 | 499 | 'EEM_Message_Template' => 'load_model', |
500 | 500 | //load_helper |
501 | 501 | 'EEH_Parse_Shortcodes' => function() { |
502 | - if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
|
502 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
503 | 503 | return new EEH_Parse_Shortcodes(); |
504 | 504 | } |
505 | 505 | return null; |
@@ -9,10 +9,10 @@ |
||
9 | 9 | class EE_CPT_Strategy extends EE_Base { |
10 | 10 | |
11 | 11 | /** |
12 | - * EE_CPT_Strategy Object |
|
13 | - * @private _instance |
|
14 | - * @private protected |
|
15 | - */ |
|
12 | + * EE_CPT_Strategy Object |
|
13 | + * @private _instance |
|
14 | + * @private protected |
|
15 | + */ |
|
16 | 16 | private static $_instance; |
17 | 17 | |
18 | 18 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -55,38 +55,38 @@ discard block |
||
55 | 55 | '[EVENT_NAME]' => __("This also can be used for the name of the event", 'event_espresso'), |
56 | 56 | '[EVENT_PHONE]' => __('The phone number for the event (usually an info number)', 'event_espresso'), |
57 | 57 | '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
58 | - '[EVENT_EXCERPT]' => __( 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso' ), |
|
58 | + '[EVENT_EXCERPT]' => __('This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', 'event_espresso'), |
|
59 | 59 | '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
60 | 60 | '[EVENT_URL]' => __('A link to the event set up on the host site.', 'event_espresso'), |
61 | 61 | '[VIRTUAL_URL]' => __('What was used for the "URL of Event" field in the Venue settings', 'event_espresso'), |
62 | 62 | '[VIRTUAL_PHONE]' => __('An alternate phone number for the event. Typically used as a "call-in" number', 'event_espresso'), |
63 | 63 | '[EVENT_IMAGE]' => __('This will parse to the Feature image for the event.', 'event_espresso'), |
64 | 64 | '[EVENT_IMAGE_*]' => sprintf( |
65 | - __( 'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.', 'event_espresso' ), |
|
65 | + __('This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.', 'event_espresso'), |
|
66 | 66 | '<code>', |
67 | 67 | '</code>' |
68 | 68 | ), |
69 | 69 | '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
70 | - __( 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso' ), |
|
70 | + __('This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', 'event_espresso'), |
|
71 | 71 | '<code>', |
72 | 72 | '</code>' |
73 | 73 | ), |
74 | - '[EVENT_TOTAL_SPOTS_TAKEN]' => __( 'This shortcode will parse to the output the total approved registrations for this event', 'event_espresso' ), |
|
74 | + '[EVENT_TOTAL_SPOTS_TAKEN]' => __('This shortcode will parse to the output the total approved registrations for this event', 'event_espresso'), |
|
75 | 75 | '[EVENT_FACEBOOK_URL]' => __('This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', 'event_espresso'), |
76 | 76 | '[EVENT_TWITTER_URL]' => __('This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', 'event_espresso'), |
77 | 77 | '[EVENT_META_*]' => __('This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode.', 'event_espresso'), |
78 | - '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( 'This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso' ), |
|
78 | + '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __('This parses to the url for the registration list table filtered by registrations for this event.', 'event_espresso'), |
|
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
82 | 82 | |
83 | - protected function _parser( $shortcode ) { |
|
83 | + protected function _parser($shortcode) { |
|
84 | 84 | |
85 | 85 | |
86 | 86 | $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
87 | 87 | |
88 | 88 | //if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
89 | - if ( empty( $this->_event ) ) { |
|
89 | + if (empty($this->_event)) { |
|
90 | 90 | $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL; |
91 | 91 | $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
92 | 92 | |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | //If there is no event objecdt by now then get out. |
98 | - if ( ! $this->_event instanceof EE_Event ) |
|
98 | + if ( ! $this->_event instanceof EE_Event) |
|
99 | 99 | return ''; |
100 | 100 | |
101 | - switch ( $shortcode ) { |
|
101 | + switch ($shortcode) { |
|
102 | 102 | |
103 | 103 | case '[EVENT_ID]' : |
104 | 104 | return $this->_event->ID(); |
@@ -131,41 +131,41 @@ discard block |
||
131 | 131 | |
132 | 132 | case '[VIRTUAL_URL]' : |
133 | 133 | $venue = $this->_event->get_first_related('Venue'); |
134 | - if ( empty( $venue ) ) |
|
134 | + if (empty($venue)) |
|
135 | 135 | return ''; |
136 | 136 | return $venue->get('VNU_virtual_url'); |
137 | 137 | |
138 | 138 | case '[VIRTUAL_PHONE]' : |
139 | 139 | $venue = $this->_event->get_first_related('Venue'); |
140 | - if ( empty( $venue ) ) |
|
140 | + if (empty($venue)) |
|
141 | 141 | return ''; |
142 | 142 | return $venue->get('VNU_virtual_phone'); |
143 | 143 | break; |
144 | 144 | |
145 | 145 | case '[EVENT_IMAGE]' : |
146 | - $image = $this->_event->feature_image_url(array(600,300) ); |
|
146 | + $image = $this->_event->feature_image_url(array(600, 300)); |
|
147 | 147 | // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
148 | - return ! empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '" />' : ''; |
|
148 | + return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'" />' : ''; |
|
149 | 149 | break; |
150 | 150 | |
151 | 151 | case '[EVENT_FACEBOOK_URL]' : |
152 | - $facebook_url = $this->_event->get_post_meta('event_facebook', true ); |
|
153 | - return empty( $facebook_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : $facebook_url; |
|
152 | + $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
153 | + return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; |
|
154 | 154 | break; |
155 | 155 | |
156 | 156 | case '[EVENT_TWITTER_URL]' : |
157 | 157 | $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
158 | - return empty( $twitter_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : $twitter_url; |
|
158 | + return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; |
|
159 | 159 | break; |
160 | 160 | |
161 | 161 | case '[EVENT_AUTHOR_EMAIL]' : |
162 | 162 | $author_id = $this->_event->get('EVT_wp_user'); |
163 | - $user_data = get_userdata( (int) $author_id ); |
|
163 | + $user_data = get_userdata((int) $author_id); |
|
164 | 164 | return $user_data->user_email; |
165 | 165 | break; |
166 | 166 | |
167 | 167 | case '[EVENT_TOTAL_SPOTS_TAKEN]' : |
168 | - return EEM_Registration::instance()->count( array( array( 'EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved ) ), 'REG_ID', true ); |
|
168 | + return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); |
|
169 | 169 | break; |
170 | 170 | |
171 | 171 | case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' : |
@@ -175,49 +175,49 @@ discard block |
||
175 | 175 | 'page' => 'espresso_registrations', |
176 | 176 | 'action' => 'default' |
177 | 177 | ), |
178 | - admin_url( 'admin.php' ), |
|
178 | + admin_url('admin.php'), |
|
179 | 179 | true |
180 | 180 | ); |
181 | 181 | break; |
182 | 182 | } |
183 | 183 | |
184 | - if ( strpos( $shortcode, '[EVENT_META_*' ) !== false ) { |
|
185 | - $shortcode = str_replace( '[EVENT_META_*', '', $shortcode ); |
|
186 | - $shortcode = trim( str_replace( ']', '', $shortcode ) ); |
|
184 | + if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
185 | + $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
186 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
187 | 187 | |
188 | 188 | //pull the meta value from the event post |
189 | - $event_meta = $this->_event->get_post_meta( $shortcode, true ); |
|
189 | + $event_meta = $this->_event->get_post_meta($shortcode, true); |
|
190 | 190 | |
191 | - return ! empty( $event_meta ) ? $this->_event->get_post_meta( $shortcode, true ) : ''; |
|
191 | + return ! empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | - if ( strpos( $shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*' ) !== false ) { |
|
196 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
197 | - $method = empty( $attrs['method'] ) ? 'current' : $attrs['method']; |
|
195 | + if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
196 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
197 | + $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
198 | 198 | $method = $method === 'current'; |
199 | 199 | $available = $this->_event->total_available_spaces($method); |
200 | 200 | return $available === EE_INF ? '∞' : $available; |
201 | 201 | } |
202 | 202 | |
203 | - if ( strpos( $shortcode, '[EVENT_IMAGE_*' ) !== false ) { |
|
204 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
205 | - $width = empty( $attrs['width'] ) ? '' : ' width="' . $attrs['width'] . '"'; |
|
206 | - $height = empty( $attrs['height'] ) ? '' : ' height="'. $attrs['height'] .'"'; |
|
203 | + if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) { |
|
204 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
205 | + $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"'; |
|
206 | + $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"'; |
|
207 | 207 | |
208 | 208 | //Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200' |
209 | - if ( ! empty( $attrs['size'] ) ) { |
|
210 | - $size = explode( ',', $attrs['size'] ); |
|
211 | - if ( count($size) === 1 ) { |
|
209 | + if ( ! empty($attrs['size'])) { |
|
210 | + $size = explode(',', $attrs['size']); |
|
211 | + if (count($size) === 1) { |
|
212 | 212 | $size = $size[0]; |
213 | 213 | } |
214 | 214 | } else { |
215 | 215 | $size = 'thumbnail'; |
216 | 216 | } |
217 | 217 | |
218 | - $image = $this->_event->feature_image_url( $size ); |
|
218 | + $image = $this->_event->feature_image_url($size); |
|
219 | 219 | |
220 | - return ! empty( $image ) ? '<img src="' . $image . '" alt="' . sprintf( esc_attr__( '%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name') ) . '"' . $width . $height . '/>' : ''; |
|
220 | + return ! empty($image) ? '<img src="'.$image.'" alt="'.sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')).'"'.$width.$height.'/>' : ''; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | return ''; |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. Otherwise we just return the url of the event. |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - private function _get_event_link( $event, $full_link = TRUE ) { |
|
233 | + private function _get_event_link($event, $full_link = TRUE) { |
|
234 | 234 | $url = get_permalink($event->ID()); |
235 | 235 | |
236 | - return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
236 | + return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | * @ return void |
29 | 29 | */ |
30 | 30 | public function __get($a) { return FALSE; } |
31 | - public function __set($a,$b) { return FALSE; } |
|
31 | + public function __set($a, $b) { return FALSE; } |
|
32 | 32 | public function __isset($a) { return FALSE; } |
33 | 33 | public function __unset($a) { return FALSE; } |
34 | 34 | public function __clone() { return FALSE; } |
@@ -5,25 +5,25 @@ |
||
5 | 5 | <table id="txn-admin-transaction-attendees-table" class="admin-primary-mbox-tbl"> |
6 | 6 | <thead> |
7 | 7 | <tr> |
8 | - <th class="jst-left"><?php _e( '#', 'event_espresso' );?></th> |
|
9 | - <th class="jst-left"><?php _e( 'Event Name and Ticket', 'event_espresso' );?></th> |
|
10 | - <th class="jst-left"><?php _e( 'Registrant', 'event_espresso' );?></th> |
|
11 | - <th class="jst-left"><?php _e( 'Ticket Price', 'event_espresso' );?></th> |
|
12 | - <th class="jst-left"><?php _e( 'Email', 'event_espresso' );?></th> |
|
13 | - <th class="jst-left"><?php _e( 'Address', 'event_espresso' );?></th> |
|
8 | + <th class="jst-left"><?php _e('#', 'event_espresso'); ?></th> |
|
9 | + <th class="jst-left"><?php _e('Event Name and Ticket', 'event_espresso'); ?></th> |
|
10 | + <th class="jst-left"><?php _e('Registrant', 'event_espresso'); ?></th> |
|
11 | + <th class="jst-left"><?php _e('Ticket Price', 'event_espresso'); ?></th> |
|
12 | + <th class="jst-left"><?php _e('Email', 'event_espresso'); ?></th> |
|
13 | + <th class="jst-left"><?php _e('Address', 'event_espresso'); ?></th> |
|
14 | 14 | </tr> |
15 | 15 | </thead> |
16 | 16 | <tbody> |
17 | - <?php if ( isset( $event_attendees ) && is_array( $event_attendees )) : ?> |
|
18 | - <?php foreach ( $event_attendees as $registration => $attendee ) : ?> |
|
17 | + <?php if (isset($event_attendees) && is_array($event_attendees)) : ?> |
|
18 | + <?php foreach ($event_attendees as $registration => $attendee) : ?> |
|
19 | 19 | <tr class="ee-status-strip reg-status-<?php echo $attendee['STS_ID']; ?>" style="display: table-row;"> |
20 | - <td class="jst-left"><?php echo $attendee['att_num'];?></td> |
|
21 | - <td class="jst-left"><?php echo $attendee['event_ticket_name'];?></td> |
|
20 | + <td class="jst-left"><?php echo $attendee['att_num']; ?></td> |
|
21 | + <td class="jst-left"><?php echo $attendee['event_ticket_name']; ?></td> |
|
22 | 22 | <td class="jst-left"> |
23 | 23 | <?php |
24 | - $att_link = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_registration', '_REG_ID'=>$registration), REG_ADMIN_URL ); |
|
24 | + $att_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_registration', '_REG_ID'=>$registration), REG_ADMIN_URL); |
|
25 | 25 | ?> |
26 | - <a href="<?php echo $att_link; ?>" title="<?php _e( 'View details for this registrant', 'event_espresso' );?>"> |
|
26 | + <a href="<?php echo $att_link; ?>" title="<?php _e('View details for this registrant', 'event_espresso'); ?>"> |
|
27 | 27 | <?php echo $attendee['attendee']?> |
28 | 28 | </a> |
29 | 29 | </td> |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @param string $table_name |
25 | 25 | * @return string $tableName, having ensured it has the wpdb prefix on the front |
26 | 26 | */ |
27 | - public function ensureTableNameHasPrefix( $table_name ) |
|
27 | + public function ensureTableNameHasPrefix($table_name) |
|
28 | 28 | { |
29 | 29 | global $wpdb; |
30 | - return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
30 | + return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @param string $table_name |
40 | 40 | * @return bool |
41 | 41 | */ |
42 | - public function tableIsEmpty( $table_name ) |
|
42 | + public function tableIsEmpty($table_name) |
|
43 | 43 | { |
44 | 44 | global $wpdb; |
45 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
46 | - if ( $this->tableExists( $table_name ) ) { |
|
47 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
48 | - return absint( $count ) === 0 ? true : false; |
|
45 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
46 | + if ($this->tableExists($table_name)) { |
|
47 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
48 | + return absint($count) === 0 ? true : false; |
|
49 | 49 | } |
50 | 50 | return false; |
51 | 51 | } |
@@ -60,24 +60,24 @@ discard block |
||
60 | 60 | * @param $table_name |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - public function tableExists( $table_name ) |
|
63 | + public function tableExists($table_name) |
|
64 | 64 | { |
65 | 65 | global $wpdb, $EZSQL_ERROR; |
66 | - $table_name = $this->ensureTableNameHasPrefix( $table_name ); |
|
66 | + $table_name = $this->ensureTableNameHasPrefix($table_name); |
|
67 | 67 | //ignore if this causes an sql error |
68 | 68 | $old_error = $wpdb->last_error; |
69 | 69 | $old_suppress_errors = $wpdb->suppress_errors(); |
70 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
70 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
71 | 71 | $ezsql_error_cache = $EZSQL_ERROR; |
72 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
73 | - $wpdb->show_errors( $old_show_errors_value ); |
|
74 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
72 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
73 | + $wpdb->show_errors($old_show_errors_value); |
|
74 | + $wpdb->suppress_errors($old_suppress_errors); |
|
75 | 75 | $new_error = $wpdb->last_error; |
76 | 76 | $wpdb->last_error = $old_error; |
77 | 77 | $EZSQL_ERROR = $ezsql_error_cache; |
78 | 78 | //if there was a table doesn't exist error |
79 | - if( ! empty( $new_error ) ) { |
|
80 | - if( |
|
79 | + if ( ! empty($new_error)) { |
|
80 | + if ( |
|
81 | 81 | in_array( |
82 | 82 | \EEH_Activation::last_wpdb_error_code(), |
83 | 83 | array( |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | ) |
88 | 88 | ) |
89 | 89 | || |
90 | - preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
90 | + preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string |
|
91 | 91 | ) { |
92 | 92 | return false; |
93 | 93 | } else { |
94 | 94 | //log this because that's weird. Just use the normal PHP error log |
95 | 95 | error_log( |
96 | 96 | sprintf( |
97 | - __( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ), |
|
97 | + __('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'), |
|
98 | 98 | $new_error |
99 | 99 | ) |
100 | 100 | ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -define('EE_Event_Category_Taxonomy','espresso_event_category'); |
|
2 | +define('EE_Event_Category_Taxonomy', 'espresso_event_category'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EEM_CPT_Base |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @author Mike Nelson |
17 | 17 | * |
18 | 18 | */ |
19 | -abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{ |
|
19 | +abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var string post_status_publish - the wp post status for published cpts |
@@ -69,55 +69,55 @@ discard block |
||
69 | 69 | * @param string $timezone |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - protected function __construct( $timezone = NULL ){ |
|
72 | + protected function __construct($timezone = NULL) { |
|
73 | 73 | |
74 | 74 | //adds a relationship to Term_Taxonomy for all these models. For this to work |
75 | 75 | //Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly |
76 | 76 | //eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry |
77 | 77 | //with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value |
78 | 78 | //must also be new EE_HABTM_Relation('Term_Relationship'); |
79 | - $this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship'); |
|
79 | + $this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship'); |
|
80 | 80 | $primary_table_name = NULL; |
81 | 81 | //add the common _status field to all CPT primary tables. |
82 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
83 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
82 | + foreach ($this->_tables as $alias => $table_obj) { |
|
83 | + if ($table_obj instanceof EE_Primary_Table) { |
|
84 | 84 | $primary_table_name = $alias; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | //set default wp post statuses if child has not already set. |
88 | - if ( ! isset( $this->_fields[$primary_table_name]['status'] )) { |
|
88 | + if ( ! isset($this->_fields[$primary_table_name]['status'])) { |
|
89 | 89 | $this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft'); |
90 | 90 | } |
91 | - if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){ |
|
92 | - $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, ''); |
|
91 | + if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) { |
|
92 | + $this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, ''); |
|
93 | 93 | } |
94 | - if( ! isset( $this->_fields[$primary_table_name]['pinged'])){ |
|
95 | - $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, ''); |
|
94 | + if ( ! isset($this->_fields[$primary_table_name]['pinged'])) { |
|
95 | + $this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, ''); |
|
96 | 96 | } |
97 | 97 | |
98 | - if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){ |
|
99 | - $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open'); |
|
98 | + if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) { |
|
99 | + $this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open'); |
|
100 | 100 | } |
101 | 101 | |
102 | - if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){ |
|
102 | + if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) { |
|
103 | 103 | $this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open'); |
104 | 104 | } |
105 | 105 | |
106 | - if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){ |
|
107 | - $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, ''); |
|
106 | + if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) { |
|
107 | + $this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, ''); |
|
108 | 108 | } |
109 | - if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) { |
|
109 | + if ( ! isset($this->_model_relations['Post_Meta'])) { |
|
110 | 110 | //don't block deletes though because we want to maintain the current behaviour |
111 | - $this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false ); |
|
111 | + $this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false); |
|
112 | 112 | } |
113 | - if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
113 | + if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
114 | 114 | //nothing was set during child constructor, so set default |
115 | - $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() ); |
|
115 | + $this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type()); |
|
116 | 116 | } |
117 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) { |
|
117 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
118 | 118 | //nothing was set during child constructor, so set default |
119 | 119 | //it's ok for child classes to specify this, but generally this is more DRY |
120 | - $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() ); |
|
120 | + $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type()); |
|
121 | 121 | } |
122 | 122 | parent::__construct($timezone); |
123 | 123 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function public_event_stati() { |
132 | 132 | // @see wp-includes/post.php |
133 | - return get_post_stati( array( 'public' => TRUE )); |
|
133 | + return get_post_stati(array('public' => TRUE)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @return string |
142 | 142 | * @throws EE_Error |
143 | 143 | */ |
144 | - public function deleted_field_name(){ |
|
144 | + public function deleted_field_name() { |
|
145 | 145 | throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso"))); |
146 | 146 | } |
147 | 147 | |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @throws EE_Error |
154 | 154 | */ |
155 | - public function post_status_field_name(){ |
|
155 | + public function post_status_field_name() { |
|
156 | 156 | $field = $this->get_a_field_of_type('EE_WP_Post_Status_Field'); |
157 | - if($field){ |
|
157 | + if ($field) { |
|
158 | 158 | return $field->get_name(); |
159 | - }else{ |
|
160 | - throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
159 | + } else { |
|
160 | + throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | * @param array $query_params like EEM_Base::get_all's $query_params |
169 | 169 | * @return array like EEM_Base::get_all's $query_params |
170 | 170 | */ |
171 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
172 | - $post_status_field_name=$this->post_status_field_name(); |
|
173 | - $query_params[0][$post_status_field_name]=self::post_status_trashed; |
|
171 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
172 | + $post_status_field_name = $this->post_status_field_name(); |
|
173 | + $query_params[0][$post_status_field_name] = self::post_status_trashed; |
|
174 | 174 | return $query_params; |
175 | 175 | } |
176 | 176 | |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param array $query_params |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
185 | - $query_params[ 'default_where_conditions' ] = 'minimum'; |
|
184 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
185 | + $query_params['default_where_conditions'] = 'minimum'; |
|
186 | 186 | return $query_params; |
187 | 187 | } |
188 | 188 | |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | * @param array $query_params like EEM_Base::get_all |
195 | 195 | * @return boolean success |
196 | 196 | */ |
197 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
198 | - $post_status_field_name=$this->post_status_field_name(); |
|
197 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
198 | + $post_status_field_name = $this->post_status_field_name(); |
|
199 | 199 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
200 | 200 | $new_status = $delete ? self::post_status_trashed : 'draft'; |
201 | - if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) { |
|
201 | + if ($this->update(array($post_status_field_name=>$new_status), $query_params)) { |
|
202 | 202 | return TRUE; |
203 | 203 | } else { |
204 | 204 | return FALSE; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function meta_table() { |
217 | 217 | $meta_table = $this->_get_other_tables(); |
218 | - $meta_table = reset( $meta_table ); |
|
218 | + $meta_table = reset($meta_table); |
|
219 | 219 | return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL; |
220 | 220 | } |
221 | 221 | |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | * @param bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields. Defaults to false (no db only fields) |
228 | 228 | * @return array |
229 | 229 | */ |
230 | - public function get_meta_table_fields( $all = FALSE ) { |
|
230 | + public function get_meta_table_fields($all = FALSE) { |
|
231 | 231 | $all_fields = $fields_to_return = array(); |
232 | - foreach ( $this->_tables as $alias => $table_obj ) { |
|
233 | - if ( $table_obj instanceof EE_Secondary_Table ) |
|
234 | - $all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields ); |
|
232 | + foreach ($this->_tables as $alias => $table_obj) { |
|
233 | + if ($table_obj instanceof EE_Secondary_Table) |
|
234 | + $all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields); |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( !$all ) { |
|
238 | - foreach ( $all_fields as $name => $obj ) { |
|
239 | - if ( $obj instanceof EE_DB_Only_Field_Base ) |
|
237 | + if ( ! $all) { |
|
238 | + foreach ($all_fields as $name => $obj) { |
|
239 | + if ($obj instanceof EE_DB_Only_Field_Base) |
|
240 | 240 | continue; |
241 | 241 | $fields_to_return[] = $name; |
242 | 242 | } |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param int $parent_term_taxonomy_id |
260 | 260 | * @return EE_Term_Taxonomy |
261 | 261 | */ |
262 | - function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){ |
|
262 | + function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) { |
|
263 | 263 | //create term |
264 | - require_once( EE_MODELS . 'EEM_Term.model.php'); |
|
264 | + require_once(EE_MODELS.'EEM_Term.model.php'); |
|
265 | 265 | //first, check for a term by the same name or slug |
266 | 266 | $category_slug = sanitize_title($category_name); |
267 | - $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug)))); |
|
268 | - if( ! $term ){ |
|
267 | + $term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug)))); |
|
268 | + if ( ! $term) { |
|
269 | 269 | $term = EE_Term::new_instance(array( |
270 | 270 | 'name'=>$category_name, |
271 | 271 | 'slug'=>$category_slug |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | $term->save(); |
274 | 274 | } |
275 | 275 | //make sure there's a term-taxonomy entry too |
276 | - require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php'); |
|
277 | - $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
276 | + require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php'); |
|
277 | + $term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
278 | 278 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
279 | - if( ! $term_taxonomy ){ |
|
279 | + if ( ! $term_taxonomy) { |
|
280 | 280 | $term_taxonomy = EE_Term_Taxonomy::new_instance(array( |
281 | 281 | 'term_id'=>$term->ID(), |
282 | 282 | 'taxonomy'=>EE_Event_Category_Taxonomy, |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | 'parent'=>$parent_term_taxonomy_id |
286 | 286 | )); |
287 | 287 | $term_taxonomy->save(); |
288 | - }else{ |
|
288 | + } else { |
|
289 | 289 | $term_taxonomy->set_count($term_taxonomy->count() + 1); |
290 | 290 | $term_taxonomy->save(); |
291 | 291 | } |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | * @param string $category_name name of the event category (term) |
301 | 301 | * @return bool |
302 | 302 | */ |
303 | - function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){ |
|
303 | + function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) { |
|
304 | 304 | //find the term_taxonomy by that name |
305 | - $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
305 | + $term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy))); |
|
306 | 306 | /** @var $term_taxonomy EE_Term_Taxonomy */ |
307 | - if( $term_taxonomy ){ |
|
307 | + if ($term_taxonomy) { |
|
308 | 308 | $term_taxonomy->set_count($term_taxonomy->count() - 1); |
309 | 309 | $term_taxonomy->save(); |
310 | 310 | } |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | * @param string|array $attr Optional. Query string or array of attributes. |
325 | 325 | * @return string HTML image element |
326 | 326 | */ |
327 | - public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) { |
|
328 | - return get_the_post_thumbnail( $id, $size, $attr ); |
|
327 | + public function get_feature_image($id, $size = 'thumbnail', $attr = '') { |
|
328 | + return get_the_post_thumbnail($id, $size, $attr); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | * @global array $wp_post_statuses set in wp core for storing all the post stati |
339 | 339 | * @return array |
340 | 340 | */ |
341 | - public function get_post_statuses(){ |
|
341 | + public function get_post_statuses() { |
|
342 | 342 | global $wp_post_statuses; |
343 | 343 | $statuses = array(); |
344 | - foreach($wp_post_statuses as $post_status => $args_object){ |
|
344 | + foreach ($wp_post_statuses as $post_status => $args_object) { |
|
345 | 345 | $statuses[$post_status] = $args_object->label; |
346 | 346 | } |
347 | 347 | return $statuses; |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | public function get_status_array() { |
357 | 357 | $statuses = $this->get_post_statuses(); |
358 | 358 | //first the global filter |
359 | - $statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses ); |
|
359 | + $statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses); |
|
360 | 360 | //now the class specific filter |
361 | - $statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses ); |
|
361 | + $statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses); |
|
362 | 362 | return $statuses; |
363 | 363 | } |
364 | 364 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function get_custom_post_statuses() { |
372 | 372 | $new_stati = array(); |
373 | - foreach ( $this->_custom_stati as $status => $props ) { |
|
373 | + foreach ($this->_custom_stati as $status => $props) { |
|
374 | 374 | $new_stati[$status] = $props['label']; |
375 | 375 | } |
376 | 376 | return $new_stati; |
@@ -387,24 +387,24 @@ discard block |
||
387 | 387 | * @param WP_Post|array $post |
388 | 388 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class |
389 | 389 | */ |
390 | - public function instantiate_class_from_post_object_orig($post){ |
|
391 | - $post = (array)$post; |
|
390 | + public function instantiate_class_from_post_object_orig($post) { |
|
391 | + $post = (array) $post; |
|
392 | 392 | $has_all_necessary_fields_for_table = true; |
393 | 393 | //check if the post has fields on the meta table already |
394 | - foreach($this->_get_other_tables() as $table_obj){ |
|
394 | + foreach ($this->_get_other_tables() as $table_obj) { |
|
395 | 395 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
396 | - foreach($fields_for_that_table as $field_obj){ |
|
397 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
398 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
396 | + foreach ($fields_for_that_table as $field_obj) { |
|
397 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
398 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
399 | 399 | $has_all_necessary_fields_for_table = false; |
400 | 400 | } |
401 | 401 | } |
402 | 402 | } |
403 | 403 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
404 | - if( ! $has_all_necessary_fields_for_table){ |
|
404 | + if ( ! $has_all_necessary_fields_for_table) { |
|
405 | 405 | |
406 | 406 | return $this->get_one_by_ID($post['ID']); |
407 | - }else{ |
|
407 | + } else { |
|
408 | 408 | return $this->instantiate_class_from_array_or_object($post); |
409 | 409 | } |
410 | 410 | } |
@@ -415,30 +415,30 @@ discard block |
||
415 | 415 | * @param null $post |
416 | 416 | * @return EE_Base_Class|EE_Soft_Delete_Base_Class |
417 | 417 | */ |
418 | - public function instantiate_class_from_post_object( $post = NULL ){ |
|
419 | - if ( empty( $post )) { |
|
418 | + public function instantiate_class_from_post_object($post = NULL) { |
|
419 | + if (empty($post)) { |
|
420 | 420 | global $post; |
421 | 421 | } |
422 | - $post = (array)$post; |
|
422 | + $post = (array) $post; |
|
423 | 423 | $tables_needing_to_be_queried = array(); |
424 | 424 | //check if the post has fields on the meta table already |
425 | - foreach($this->get_tables() as $table_obj){ |
|
425 | + foreach ($this->get_tables() as $table_obj) { |
|
426 | 426 | $fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias()); |
427 | - foreach($fields_for_that_table as $field_obj){ |
|
428 | - if( ! isset($post[$field_obj->get_table_column()]) |
|
429 | - && ! isset($post[$field_obj->get_qualified_column()])){ |
|
427 | + foreach ($fields_for_that_table as $field_obj) { |
|
428 | + if ( ! isset($post[$field_obj->get_table_column()]) |
|
429 | + && ! isset($post[$field_obj->get_qualified_column()])) { |
|
430 | 430 | $tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj; |
431 | 431 | } |
432 | 432 | } |
433 | 433 | } |
434 | 434 | //if we don't have all the fields we need, then just fetch the proper model from the DB |
435 | - if( $tables_needing_to_be_queried){ |
|
436 | - if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){ |
|
435 | + if ($tables_needing_to_be_queried) { |
|
436 | + if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) { |
|
437 | 437 | //so we're only missing data from a secondary table. Well that's not too hard to query for |
438 | 438 | $table_to_query = reset($tables_needing_to_be_queried); |
439 | - $missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A )); |
|
440 | - if ( ! empty( $missing_data )) { |
|
441 | - $post = array_merge( $post, $missing_data ); |
|
439 | + $missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A)); |
|
440 | + if ( ! empty($missing_data)) { |
|
441 | + $post = array_merge($post, $missing_data); |
|
442 | 442 | } |
443 | 443 | } else { |
444 | 444 | return $this->get_one_by_ID($post['ID']); |
@@ -455,15 +455,15 @@ discard block |
||
455 | 455 | * @throws EE_Error |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function post_type(){ |
|
458 | + public function post_type() { |
|
459 | 459 | $post_type_field = NULL; |
460 | - foreach($this->field_settings(true) as $field_obj){ |
|
461 | - if($field_obj instanceof EE_WP_Post_Type_Field){ |
|
462 | - $post_type_field = $field_obj;break; |
|
460 | + foreach ($this->field_settings(true) as $field_obj) { |
|
461 | + if ($field_obj instanceof EE_WP_Post_Type_Field) { |
|
462 | + $post_type_field = $field_obj; break; |
|
463 | 463 | } |
464 | 464 | } |
465 | - if($post_type_field == NULL){ |
|
466 | - throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this))); |
|
465 | + if ($post_type_field == NULL) { |
|
466 | + throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this))); |
|
467 | 467 | } |
468 | 468 | return $post_type_field->get_default_value(); |
469 | 469 | } |