@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Venue extends EEM_CPT_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE,time()), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE,time()), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ); |
77 | 77 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID'); |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
80 | - parent::__construct( $timezone ); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
80 | + parent::__construct($timezone); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * other than explicitly setting it to EE_INF. |
8 | 8 | * Makes use of constant EE_INF_IN_DB set in espresso.php, and EE_INF, which is a PHP constant definedin the ether |
9 | 9 | */ |
10 | -class EE_Infinite_Integer_Field extends EE_Model_Field_Base{ |
|
11 | - function get_wpdb_data_type(){ |
|
10 | +class EE_Infinite_Integer_Field extends EE_Model_Field_Base { |
|
11 | + function get_wpdb_data_type() { |
|
12 | 12 | return '%d'; |
13 | 13 | } |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if($value_of_field_on_model_object === EE_INF){ |
|
15 | + if ($value_of_field_on_model_object === EE_INF) { |
|
16 | 16 | return EE_INF_IN_DB; |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return intval($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
22 | - if($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
22 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
23 | 23 | $value_inputted_for_field_on_model_object === EE_INF || |
24 | 24 | $value_inputted_for_field_on_model_object === "EE_INF" |
25 | - ){ |
|
25 | + ) { |
|
26 | 26 | return EE_INF; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | return intval($value_inputted_for_field_on_model_object); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
32 | 32 | $intval = intval($value_inputted_for_field_on_model_object); |
33 | - if($intval == EE_INF_IN_DB){ |
|
33 | + if ($intval == EE_INF_IN_DB) { |
|
34 | 34 | return EE_INF; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return $intval; |
37 | 37 | } |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = null ) { |
|
49 | - if( $value_on_field_to_be_outputted === EE_INF ){ |
|
50 | - switch($schema){ |
|
48 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
49 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
50 | + switch ($schema) { |
|
51 | 51 | case 'input': |
52 | 52 | return ''; |
53 | 53 | case 'symbol': |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * @return \EEH_Autoloader |
41 | 41 | */ |
42 | 42 | private function __construct() { |
43 | - if ( self::$_autoloaders === null ) { |
|
43 | + if (self::$_autoloaders === null) { |
|
44 | 44 | self::$_autoloaders = array(); |
45 | 45 | $this->_register_custom_autoloaders(); |
46 | - spl_autoload_register( array( $this, 'espresso_autoloader' ) ); |
|
46 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function instance() { |
57 | 57 | // check if class object is instantiated |
58 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
58 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
59 | 59 | self::$_instance = new self(); |
60 | 60 | } |
61 | 61 | return self::$_instance; |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * @internal param string $class_name - simple class name ie: session |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public static function espresso_autoloader( $class_name ) { |
|
76 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
77 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
75 | + public static function espresso_autoloader($class_name) { |
|
76 | + if (isset(self::$_autoloaders[$class_name])) { |
|
77 | + require_once(self::$_autoloaders[$class_name]); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | * @throws \EE_Error |
92 | 92 | */ |
93 | - public static function register_autoloader( $class_paths, $read_check = true, $debug = false ) { |
|
94 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
95 | - foreach ( $class_paths as $class => $path ) { |
|
93 | + public static function register_autoloader($class_paths, $read_check = true, $debug = false) { |
|
94 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
95 | + foreach ($class_paths as $class => $path) { |
|
96 | 96 | // don't give up! you gotta... |
97 | 97 | // get some class |
98 | - if ( empty( $class )) { |
|
99 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
98 | + if (empty($class)) { |
|
99 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
100 | 100 | } |
101 | 101 | // one day you will find the path young grasshopper |
102 | - if ( empty( $path )) { |
|
103 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
102 | + if (empty($path)) { |
|
103 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
104 | 104 | } |
105 | 105 | // is file readable ? |
106 | - if ( $read_check && ! is_readable( $path )) { |
|
107 | - throw new EE_Error ( sprintf( __( 'The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s','event_espresso' ), $class, $path )); |
|
106 | + if ($read_check && ! is_readable($path)) { |
|
107 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
108 | 108 | } |
109 | - if ( ! isset( self::$_autoloaders[ $class ] )) { |
|
110 | - self::$_autoloaders[ $class ] = str_replace( array( '/', '\\' ), DS, $path ); |
|
111 | - if ( WP_DEBUG && $debug ) { |
|
112 | - EEH_Debug_Tools::printr( self::$_autoloaders[ $class ], $class, __FILE__, __LINE__ ); |
|
109 | + if ( ! isset(self::$_autoloaders[$class])) { |
|
110 | + self::$_autoloaders[$class] = str_replace(array('/', '\\'), DS, $path); |
|
111 | + if (WP_DEBUG && $debug) { |
|
112 | + EEH_Debug_Tools::printr(self::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @return void |
139 | 139 | */ |
140 | 140 | private function _register_custom_autoloaders() { |
141 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'interfaces' ); |
|
142 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
143 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_INTERFACES, true ); |
|
144 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, true ); |
|
145 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
146 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
141 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
142 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
143 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
144 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
145 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
146 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return void |
170 | 170 | */ |
171 | 171 | public static function register_line_item_display_autoloaders() { |
172 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , true ); |
|
172 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | public static function register_line_item_filter_autoloaders() { |
185 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_filters' , true ); |
|
185 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @return void |
196 | 196 | */ |
197 | 197 | public static function register_template_part_autoloaders() { |
198 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'template_parts', true ); |
|
198 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | |
@@ -213,30 +213,30 @@ discard block |
||
213 | 213 | * @return void |
214 | 214 | * @throws \EE_Error |
215 | 215 | */ |
216 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = false, $debug = false ){ |
|
216 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) { |
|
217 | 217 | // make sure last char is a / |
218 | - $folder .= $folder[strlen($folder)-1] != DS ? DS : ''; |
|
218 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
219 | 219 | $class_to_filepath_map = array(); |
220 | - $exclude = array( 'index' ); |
|
220 | + $exclude = array('index'); |
|
221 | 221 | //get all the files in that folder that end in php |
222 | - $filepaths = glob( $folder.'*'); |
|
222 | + $filepaths = glob($folder.'*'); |
|
223 | 223 | |
224 | - if ( empty( $filepaths ) ) { |
|
224 | + if (empty($filepaths)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach( $filepaths as $filepath ) { |
|
229 | - if ( substr( $filepath, -4, 4 ) == '.php' ) { |
|
230 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
231 | - if ( ! in_array( $class_name, $exclude )) { |
|
232 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
228 | + foreach ($filepaths as $filepath) { |
|
229 | + if (substr($filepath, -4, 4) == '.php') { |
|
230 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
231 | + if ( ! in_array($class_name, $exclude)) { |
|
232 | + $class_to_filepath_map [$class_name] = $filepath; |
|
233 | 233 | } |
234 | - } else if ( $recursive ) { |
|
235 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive ); |
|
234 | + } else if ($recursive) { |
|
235 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive); |
|
236 | 236 | } |
237 | 237 | } |
238 | 238 | // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
239 | - self::register_autoloader( $class_to_filepath_map, false, $debug ); |
|
239 | + self::register_autoloader($class_to_filepath_map, false, $debug); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * |
10 | 10 | * ------------------------------------------------------------------------ |
11 | 11 | */ |
12 | -class EEH_URL{ |
|
12 | +class EEH_URL { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * _add_query_arg |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
22 | 22 | * @return string |
23 | 23 | */ |
24 | - public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) { |
|
25 | - if ( empty( $url ) ) { |
|
26 | - $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' ); |
|
27 | - $dev_msg = $user_msg . "\n" . sprintf( |
|
28 | - __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ), |
|
24 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) { |
|
25 | + if (empty($url)) { |
|
26 | + $user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso'); |
|
27 | + $dev_msg = $user_msg."\n".sprintf( |
|
28 | + __('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'), |
|
29 | 29 | __CLASS__ |
30 | 30 | ); |
31 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
31 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
32 | 32 | } |
33 | 33 | // check that an action exists and add nonce |
34 | - if ( ! $exclude_nonce ) { |
|
35 | - if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) { |
|
36 | - $args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) ); |
|
34 | + if ( ! $exclude_nonce) { |
|
35 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
36 | + $args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'))); |
|
37 | 37 | } else { |
38 | - $args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) ); |
|
38 | + $args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce'))); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | 42 | //finally, let's always add a return address (if present) :) |
43 | - $args = ! empty( $_REQUEST['action'] ) ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) : $args; |
|
43 | + $args = ! empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args; |
|
44 | 44 | |
45 | - return add_query_arg( $args, $url ); |
|
45 | + return add_query_arg($args, $url); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -55,17 +55,17 @@ discard block |
||
55 | 55 | * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly |
56 | 56 | * @return boolean |
57 | 57 | */ |
58 | - public static function remote_file_exists( $url, $args = array() ){ |
|
59 | - $results = wp_remote_request($url,array_merge( array( |
|
58 | + public static function remote_file_exists($url, $args = array()) { |
|
59 | + $results = wp_remote_request($url, array_merge(array( |
|
60 | 60 | 'method'=>'GET', |
61 | 61 | 'redirection'=>1 |
62 | - ), $args ) ); |
|
63 | - if( ! $results instanceof WP_Error && |
|
62 | + ), $args)); |
|
63 | + if ( ! $results instanceof WP_Error && |
|
64 | 64 | isset($results['response']) && |
65 | 65 | isset($results['response']['code']) && |
66 | - $results['response']['code'] == '200'){ |
|
66 | + $results['response']['code'] == '200') { |
|
67 | 67 | return true; |
68 | - }else{ |
|
68 | + } else { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | } |
@@ -81,29 +81,29 @@ discard block |
||
81 | 81 | * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) { |
|
84 | + public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) { |
|
85 | 85 | // break apart incoming URL |
86 | - $url_bits = parse_url( $url ); |
|
86 | + $url_bits = parse_url($url); |
|
87 | 87 | // HTTP or HTTPS ? |
88 | - $scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://'; |
|
88 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
89 | 89 | // domain |
90 | - $host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : ''; |
|
90 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
91 | 91 | // if only the base URL is requested, then return that now |
92 | - if ( $base_url_only ) { |
|
93 | - return $scheme . $host; |
|
92 | + if ($base_url_only) { |
|
93 | + return $scheme.$host; |
|
94 | 94 | } |
95 | - $port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : ''; |
|
96 | - $user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : ''; |
|
97 | - $pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : ''; |
|
98 | - $pass = ( $user || $pass ) ? $pass . '@' : ''; |
|
99 | - $path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : ''; |
|
95 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
96 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
97 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
98 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
99 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
100 | 100 | // if the query string is not required, then return what we have so far |
101 | - if ( $remove_query ) { |
|
102 | - return $scheme . $user . $pass . $host . $port . $path; |
|
101 | + if ($remove_query) { |
|
102 | + return $scheme.$user.$pass.$host.$port.$path; |
|
103 | 103 | } |
104 | - $query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : ''; |
|
105 | - $fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : ''; |
|
106 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
104 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
105 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
106 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -116,29 +116,29 @@ discard block |
||
116 | 116 | * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string |
117 | 117 | * @return string|array |
118 | 118 | */ |
119 | - public static function get_query_string( $url = '', $as_array = TRUE ) { |
|
119 | + public static function get_query_string($url = '', $as_array = TRUE) { |
|
120 | 120 | // break apart incoming URL |
121 | - $url_bits = parse_url( $url ); |
|
121 | + $url_bits = parse_url($url); |
|
122 | 122 | // grab query string from URL |
123 | - $query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : ''; |
|
123 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
124 | 124 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
125 | - if ( ! $as_array ) { |
|
125 | + if ( ! $as_array) { |
|
126 | 126 | return $query; |
127 | 127 | } |
128 | 128 | // if no query string exists then just return an empty array now |
129 | - if ( empty( $query )) { |
|
129 | + if (empty($query)) { |
|
130 | 130 | return array(); |
131 | 131 | } |
132 | 132 | // empty array to hold results |
133 | 133 | $query_params = array(); |
134 | 134 | // now break apart the query string into separate params |
135 | - $query = explode( '&', $query ); |
|
135 | + $query = explode('&', $query); |
|
136 | 136 | // loop thru our query params |
137 | - foreach ( $query as $query_args ) { |
|
137 | + foreach ($query as $query_args) { |
|
138 | 138 | // break apart the key value pairs |
139 | - $query_args = explode( '=', $query_args ); |
|
139 | + $query_args = explode('=', $query_args); |
|
140 | 140 | // and add to our results array |
141 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
141 | + $query_params[$query_args[0]] = $query_args[1]; |
|
142 | 142 | } |
143 | 143 | return $query_params; |
144 | 144 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * prevent_prefetching |
150 | 150 | * @return void |
151 | 151 | */ |
152 | - public static function prevent_prefetching(){ |
|
152 | + public static function prevent_prefetching() { |
|
153 | 153 | // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
154 | 154 | remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
155 | 155 | } |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | * @param string $prefix Use this to prefix the string with something. |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public static function generate_unique_token( $prefix = '' ) { |
|
168 | - $token = md5( uniqid() . mt_rand() ); |
|
169 | - return $prefix ? $prefix . '_' . $token : $token; |
|
167 | + public static function generate_unique_token($prefix = '') { |
|
168 | + $token = md5(uniqid().mt_rand()); |
|
169 | + return $prefix ? $prefix.'_'.$token : $token; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * add_nocache_headers |
176 | 176 | * @return void |
177 | 177 | */ |
178 | - public static function add_nocache_headers(){ |
|
178 | + public static function add_nocache_headers() { |
|
179 | 179 | // add no cache headers |
180 | 180 | // add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 ); |
181 | 181 | // plus a little extra for nginx |
@@ -192,19 +192,19 @@ discard block |
||
192 | 192 | * @param string $server_variable |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){ |
|
195 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') { |
|
196 | 196 | $URL = ''; |
197 | 197 | $server_variables = array( |
198 | 198 | 'REQUEST_URI' => 1, |
199 | 199 | 'HTTP_HOST' => 1, |
200 | 200 | 'PHP_SELF' => 1, |
201 | 201 | ); |
202 | - $server_variable = strtoupper( $server_variable ); |
|
202 | + $server_variable = strtoupper($server_variable); |
|
203 | 203 | // whitelist INPUT_SERVER var |
204 | - if ( isset( $server_variables[ $server_variable ] ) ) { |
|
205 | - $URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE ); |
|
206 | - if ( empty( $URL ) ) { |
|
207 | - $URL = esc_url( $_SERVER[ $server_variable ] ); |
|
204 | + if (isset($server_variables[$server_variable])) { |
|
205 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
206 | + if (empty($URL)) { |
|
207 | + $URL = esc_url($_SERVER[$server_variable]); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | return $URL; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -class EE_CVV_Input extends EE_Text_Input{ |
|
11 | +class EE_CVV_Input extends EE_Text_Input { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @param array $input_settings { |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function __construct($input_settings = array()) { |
19 | 19 | $this->set_sensitive_data_removal_strategy(new EE_CCV_Sensitive_Data_Removal()); |
20 | - $this->_add_validation_strategy( new EE_Int_Validation_Strategy(isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ); |
|
20 | + $this->_add_validation_strategy(new EE_Int_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)); |
|
21 | 21 | parent::__construct($input_settings); |
22 | - if( |
|
23 | - ! isset( $input_settings[ 'include_whats_this_link' ] ) || |
|
24 | - ( isset( $input_settings[ 'include_whats_this_link' ] ) && |
|
25 | - $input_settings[ 'include_whats_this_link' ] == true ) ) { |
|
22 | + if ( |
|
23 | + ! isset($input_settings['include_whats_this_link']) || |
|
24 | + (isset($input_settings['include_whats_this_link']) && |
|
25 | + $input_settings['include_whats_this_link'] == true) ) { |
|
26 | 26 | $this->_html_label_text = sprintf( |
27 | 27 | _x( |
28 | 28 | '%1$s %2$s(What\'s this?)%3$s', |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
31 | 31 | * which implements EEHI_Line_Item_Helper; etc). |
32 | 32 | */ |
33 | -abstract class EE_Gateway{ |
|
33 | +abstract class EE_Gateway { |
|
34 | 34 | /** |
35 | 35 | * a constant used as a possible value for $_currencies_supported to indicate |
36 | 36 | * that ALL currencies are supported by this gateway |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return EE_Gateway |
110 | 110 | */ |
111 | - public function __construct(){ |
|
111 | + public function __construct() { |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | * beginning again) |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function __sleep(){ |
|
123 | + public function __sleep() { |
|
124 | 124 | $properties = get_object_vars($this); |
125 | - unset( $properties[ '_pay_model' ] ); |
|
126 | - unset( $properties[ '_pay_log' ] ); |
|
125 | + unset($properties['_pay_model']); |
|
126 | + unset($properties['_pay_log']); |
|
127 | 127 | return array_keys($properties); |
128 | 128 | } |
129 | 129 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * see $_supports_sending_refunds |
132 | 132 | * @return boolean |
133 | 133 | */ |
134 | - public function supports_sending_refunds(){ |
|
134 | + public function supports_sending_refunds() { |
|
135 | 135 | return $this->_supports_sending_refunds; |
136 | 136 | } |
137 | 137 | /** |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * see $_supports_receiving_refunds |
140 | 140 | * @return boolean |
141 | 141 | */ |
142 | - public function supports_receiving_refunds(){ |
|
142 | + public function supports_receiving_refunds() { |
|
143 | 143 | return $this->_supports_receiving_refunds; |
144 | 144 | } |
145 | 145 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return EE_Payment for the refund |
155 | 155 | * @throws EE_Error |
156 | 156 | */ |
157 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
157 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
158 | 158 | return NULL; |
159 | 159 | } |
160 | 160 | |
@@ -165,8 +165,8 @@ discard block |
||
165 | 165 | * etc |
166 | 166 | * @param array $settings_array |
167 | 167 | */ |
168 | - public function set_settings($settings_array){ |
|
169 | - foreach($settings_array as $name => $value){ |
|
168 | + public function set_settings($settings_array) { |
|
169 | + foreach ($settings_array as $name => $value) { |
|
170 | 170 | $property_name = "_".$name; |
171 | 171 | $this->$property_name = $value; |
172 | 172 | } |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * See this class description |
176 | 176 | * @param EEMI_Payment $payment_model |
177 | 177 | */ |
178 | - public function set_payment_model($payment_model){ |
|
178 | + public function set_payment_model($payment_model) { |
|
179 | 179 | $this->_pay_model = $payment_model; |
180 | 180 | } |
181 | 181 | /** |
182 | 182 | * See this class description |
183 | 183 | * @param EEMI_Payment_Log $payment_log_model |
184 | 184 | */ |
185 | - public function set_payment_log($payment_log_model){ |
|
185 | + public function set_payment_log($payment_log_model) { |
|
186 | 186 | $this->_pay_log = $payment_log_model; |
187 | 187 | } |
188 | 188 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * See this class description |
191 | 191 | * @param EEHI_Template $template_helper |
192 | 192 | */ |
193 | - public function set_template_helper($template_helper){ |
|
193 | + public function set_template_helper($template_helper) { |
|
194 | 194 | $this->_template = $template_helper; |
195 | 195 | } |
196 | 196 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * See this class description |
199 | 199 | * @param EEHI_Line_Item $line_item_helper |
200 | 200 | */ |
201 | - public function set_line_item_helper( $line_item_helper ){ |
|
201 | + public function set_line_item_helper($line_item_helper) { |
|
202 | 202 | $this->_line_item = $line_item_helper; |
203 | 203 | } |
204 | 204 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * See this class description |
207 | 207 | * @param EEHI_Money $money_helper |
208 | 208 | */ |
209 | - public function set_money_helper( $money_helper ){ |
|
209 | + public function set_money_helper($money_helper) { |
|
210 | 210 | $this->_money = $money_helper; |
211 | 211 | } |
212 | 212 | |
@@ -215,23 +215,23 @@ discard block |
||
215 | 215 | * @param $message |
216 | 216 | * @param $payment |
217 | 217 | */ |
218 | - public function log($message,$payment){ |
|
219 | - if($payment instanceof EEI_Payment){ |
|
220 | - $type='Payment'; |
|
218 | + public function log($message, $payment) { |
|
219 | + if ($payment instanceof EEI_Payment) { |
|
220 | + $type = 'Payment'; |
|
221 | 221 | $id = $payment->ID(); |
222 | - }else{ |
|
222 | + } else { |
|
223 | 223 | $type = 'Payment_Method'; |
224 | 224 | $id = $this->_ID; |
225 | 225 | } |
226 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
226 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
227 | 227 | } |
228 | 228 | /** |
229 | 229 | * Formats the amount so it can generally be sent to gateways |
230 | 230 | * @param float $amount |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - public function format_currency($amount){ |
|
234 | - return number_format( $amount, 2, '.', '' ); |
|
233 | + public function format_currency($amount) { |
|
234 | + return number_format($amount, 2, '.', ''); |
|
235 | 235 | // return $this->_template->format_currency($amount, true); |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
241 | 241 | * @return mixed array or string |
242 | 242 | */ |
243 | - public function currencies_supported(){ |
|
243 | + public function currencies_supported() { |
|
244 | 244 | return $this->_currencies_supported; |
245 | 245 | } |
246 | 246 | |
@@ -252,14 +252,14 @@ discard block |
||
252 | 252 | * @param EE_Transaction $transaction |
253 | 253 | * @return float |
254 | 254 | */ |
255 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
255 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
256 | 256 | $total_line_item = $transaction->total_line_item(); |
257 | 257 | $total = 0; |
258 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
259 | - $total += max( $item_line_item->total(), 0 ); |
|
258 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
259 | + $total += max($item_line_item->total(), 0); |
|
260 | 260 | } |
261 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
262 | - $total += max( $tax_line_item->total(), 0 ); |
|
261 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
262 | + $total += max($tax_line_item->total(), 0); |
|
263 | 263 | } |
264 | 264 | return $total; |
265 | 265 | } |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * @param EEI_Payment $payment |
271 | 271 | * @return boolean |
272 | 272 | */ |
273 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
273 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
274 | 274 | return $this->_money->compare_floats( |
275 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
275 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
276 | 276 | $payment->transaction()->total() ) && |
277 | 277 | $this->_money->compare_floats( |
278 | 278 | $payment->amount(), |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param EE_Payment $payment |
291 | 291 | * @return void |
292 | 292 | */ |
293 | - public function update_txn_based_on_payment( $payment ){ |
|
293 | + public function update_txn_based_on_payment($payment) { |
|
294 | 294 | //maybe update the transaction or line items or registrations |
295 | 295 | //but most gateways don't need to do this, because they only update the payment |
296 | 296 | } |
@@ -1,35 +1,35 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Seth Shoultes |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.2 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EE_Gateway |
|
17 | - * |
|
18 | - * Abstract base class for all gateways |
|
19 | - * |
|
20 | - * @package Event Espresso |
|
21 | - * @subpackage core/libraries/payment_methods |
|
22 | - * @author Mike Nelson |
|
23 | - * |
|
24 | - * ------------------------------------------------------------------------ |
|
25 | - * Class for processing payments. This has been designed in a way so that other WP Plugins |
|
26 | - * can use this class for processing payments, and theoreitcally any of its children, provided they implement the |
|
27 | - * interfaces it uses. |
|
28 | - * The necessary interfaces to be implemented are contained in core/libaries/payment_methods/EEI_Payment_Method_Interfaces.php and |
|
29 | - * EEI_Interfaces. After constructing a gateway object, you need to set all the properties which reference many of the |
|
30 | - * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
|
31 | - * which implements EEHI_Line_Item_Helper; etc). |
|
32 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Seth Shoultes |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.2 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EE_Gateway |
|
17 | + * |
|
18 | + * Abstract base class for all gateways |
|
19 | + * |
|
20 | + * @package Event Espresso |
|
21 | + * @subpackage core/libraries/payment_methods |
|
22 | + * @author Mike Nelson |
|
23 | + * |
|
24 | + * ------------------------------------------------------------------------ |
|
25 | + * Class for processing payments. This has been designed in a way so that other WP Plugins |
|
26 | + * can use this class for processing payments, and theoreitcally any of its children, provided they implement the |
|
27 | + * interfaces it uses. |
|
28 | + * The necessary interfaces to be implemented are contained in core/libaries/payment_methods/EEI_Payment_Method_Interfaces.php and |
|
29 | + * EEI_Interfaces. After constructing a gateway object, you need to set all the properties which reference many of the |
|
30 | + * needed helpers and models (see all the methods starting with "set_", eg seg_line_item_helper which should be passed an object |
|
31 | + * which implements EEHI_Line_Item_Helper; etc). |
|
32 | + */ |
|
33 | 33 | abstract class EE_Gateway{ |
34 | 34 | /** |
35 | 35 | * a constant used as a possible value for $_currencies_supported to indicate |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @since $VID:$ |
15 | 15 | * |
16 | 16 | */ |
17 | -abstract class EE_PMT_Base{ |
|
17 | +abstract class EE_PMT_Base { |
|
18 | 18 | |
19 | 19 | const onsite = 'on-site'; |
20 | 20 | const offsite = 'off-site'; |
@@ -95,36 +95,36 @@ discard block |
||
95 | 95 | * @return EE_PMT_Base |
96 | 96 | */ |
97 | 97 | function __construct($pm_instance = NULL) { |
98 | - if ( $pm_instance instanceof EE_Payment_Method ){ |
|
98 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
99 | 99 | $this->set_instance($pm_instance); |
100 | 100 | } |
101 | 101 | $this->_set_file_folder(); |
102 | 102 | $this->_set_file_url(); |
103 | - if($this->_gateway){ |
|
104 | - $this->_gateway->set_payment_model( EEM_Payment::instance() ); |
|
105 | - $this->_gateway->set_payment_log( EEM_Change_Log::instance() ); |
|
106 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
107 | - $this->_gateway->set_template_helper( new EEH_Template() ); |
|
108 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
109 | - $this->_gateway->set_line_item_helper( new EEH_Line_Item() ); |
|
110 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
111 | - $this->_gateway->set_money_helper( new EEH_Money() ); |
|
103 | + if ($this->_gateway) { |
|
104 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
105 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
106 | + EE_Registry::instance()->load_helper('Template'); |
|
107 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
108 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
109 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
110 | + EE_Registry::instance()->load_helper('Money'); |
|
111 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
112 | 112 | } |
113 | - if ( ! isset( $this->_has_billing_form ) ) { |
|
113 | + if ( ! isset($this->_has_billing_form)) { |
|
114 | 114 | // by default, On Site gateways have a billing form |
115 | - if ( $this->payment_occurs() == EE_PMT_Base::onsite ) { |
|
116 | - $this->set_has_billing_form( true ); |
|
115 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
116 | + $this->set_has_billing_form(true); |
|
117 | 117 | } else { |
118 | - $this->set_has_billing_form( false ); |
|
118 | + $this->set_has_billing_form(false); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | - if( ! $this->_pretty_name){ |
|
122 | + if ( ! $this->_pretty_name) { |
|
123 | 123 | throw new EE_Error(sprintf(__("You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", "event_espresso"))); |
124 | 124 | } |
125 | 125 | //if the child didn't specify a default button, use the credit card one |
126 | - if( $this->_default_button_url === NULL){ |
|
127 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods' . DS . 'pay-by-credit-card.png'; |
|
126 | + if ($this->_default_button_url === NULL) { |
|
127 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods'.DS.'pay-by-credit-card.png'; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @param boolean $has_billing_form |
135 | 135 | */ |
136 | - public function set_has_billing_form( $has_billing_form ) { |
|
137 | - $this->_has_billing_form = filter_var( $has_billing_form, FILTER_VALIDATE_BOOLEAN ); |
|
136 | + public function set_has_billing_form($has_billing_form) { |
|
137 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * sets the file_folder property |
144 | 144 | */ |
145 | - protected function _set_file_folder(){ |
|
145 | + protected function _set_file_folder() { |
|
146 | 146 | $reflector = new ReflectionClass(get_class($this)); |
147 | 147 | $fn = $reflector->getFileName(); |
148 | - $this->_file_folder = dirname($fn).DS; |
|
148 | + $this->_file_folder = dirname($fn).DS; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * sets the file URL with a trailing slash for this PMT |
155 | 155 | */ |
156 | - protected function _set_file_url(){ |
|
157 | - $plugins_dir_fixed = str_replace('\\',DS,WP_PLUGIN_DIR); |
|
158 | - $file_folder_fixed = str_replace('\\',DS,$this->file_folder()); |
|
159 | - $file_path = str_replace($plugins_dir_fixed,WP_PLUGIN_URL,$file_folder_fixed); |
|
156 | + protected function _set_file_url() { |
|
157 | + $plugins_dir_fixed = str_replace('\\', DS, WP_PLUGIN_DIR); |
|
158 | + $file_folder_fixed = str_replace('\\', DS, $this->file_folder()); |
|
159 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
160 | 160 | $this->_file_url = $file_path; |
161 | 161 | } |
162 | 162 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * Gets the default description on all payment methods of this type |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function default_description(){ |
|
167 | + public function default_description() { |
|
168 | 168 | return $this->_default_description; |
169 | 169 | } |
170 | 170 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * Returns the folder containing the PMT child class, with a trailing slash |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - public function file_folder(){ |
|
177 | + public function file_folder() { |
|
178 | 178 | return $this->_file_folder; |
179 | 179 | } |
180 | 180 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - public function file_url(){ |
|
186 | + public function file_url() { |
|
187 | 187 | return $this->_file_url; |
188 | 188 | } |
189 | 189 | |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | * Its important teh payment method instance is set before |
195 | 195 | * @param EE_Payment_Method $payment_method_instance |
196 | 196 | */ |
197 | - function set_instance($payment_method_instance){ |
|
197 | + function set_instance($payment_method_instance) { |
|
198 | 198 | $this->_pm_instance = $payment_method_instance; |
199 | 199 | //if they have already requested the settings form, make sure its |
200 | 200 | //data matches this model object |
201 | - if($this->_settings_form){ |
|
201 | + if ($this->_settings_form) { |
|
202 | 202 | $this->settings_form()->populate_model_obj($payment_method_instance); |
203 | 203 | } |
204 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
204 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
205 | 205 | $this->_gateway->set_settings($payment_method_instance->settings_array()); |
206 | 206 | } |
207 | 207 | } |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | * Gets teh form for displaying to admins where they setup the payment method |
213 | 213 | * @return EE_Payment_Method_Form |
214 | 214 | */ |
215 | - function settings_form(){ |
|
216 | - if( ! $this->_settings_form){ |
|
215 | + function settings_form() { |
|
216 | + if ( ! $this->_settings_form) { |
|
217 | 217 | $this->_settings_form = $this->generate_new_settings_form(); |
218 | - $this->_settings_form->set_payment_method_type( $this ); |
|
219 | - $this->_settings_form->_construct_finalize(NULL, NULL ); |
|
218 | + $this->_settings_form->set_payment_method_type($this); |
|
219 | + $this->_settings_form->_construct_finalize(NULL, NULL); |
|
220 | 220 | //if we have already assigned a model object to this pmt, make |
221 | 221 | //sure its reflected in teh form we just generated |
222 | - if($this->_pm_instance){ |
|
222 | + if ($this->_pm_instance) { |
|
223 | 223 | $this->_settings_form->populate_model_obj($this->_pm_instance); |
224 | 224 | } |
225 | 225 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * this payment method type's settings form later in the request |
246 | 246 | * @param EE_Payment_Method_Form $form |
247 | 247 | */ |
248 | - public function set_settings_form($form){ |
|
248 | + public function set_settings_form($form) { |
|
249 | 249 | $this->_settings_form = $form; |
250 | 250 | } |
251 | 251 | |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param array $extra_args |
269 | 269 | * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
270 | 270 | */ |
271 | - public function billing_form( EE_Transaction $transaction = NULL, $extra_args = array() ){ |
|
271 | + public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array()) { |
|
272 | 272 | // has billing form already been regenerated ? or overwrite cache? |
273 | - if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form ){ |
|
274 | - $this->_billing_form = $this->generate_new_billing_form( $transaction, $extra_args ); |
|
273 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
274 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
275 | 275 | } |
276 | 276 | //if we know who the attendee is, and this is a billing form |
277 | 277 | //that uses attendee info, populate it |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | $transaction instanceof EE_Transaction && |
281 | 281 | $transaction->primary_registration() instanceof EE_Registration && |
282 | 282 | $transaction->primary_registration()->attendee() instanceof EE_Attendee |
283 | - ){ |
|
284 | - $this->_billing_form->populate_from_attendee( $transaction->primary_registration()->attendee() ); |
|
283 | + ) { |
|
284 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
285 | 285 | } |
286 | 286 | return $this->_billing_form; |
287 | 287 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @param \EE_Transaction $transaction |
293 | 293 | * @return \EE_Billing_Info_Form |
294 | 294 | */ |
295 | - abstract function generate_new_billing_form( EE_Transaction $transaction = NULL ); |
|
295 | + abstract function generate_new_billing_form(EE_Transaction $transaction = NULL); |
|
296 | 296 | |
297 | 297 | |
298 | 298 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param \EE_Billing_Info_Form $billing_form |
304 | 304 | * @return \EE_Billing_Info_Form |
305 | 305 | */ |
306 | - public function apply_billing_form_debug_settings( EE_Billing_Info_Form $billing_form ) { |
|
306 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) { |
|
307 | 307 | return $billing_form; |
308 | 308 | } |
309 | 309 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * if you have form |
315 | 315 | * @param EE_Payment_Method $form |
316 | 316 | */ |
317 | - public function set_billing_form($form){ |
|
317 | + public function set_billing_form($form) { |
|
318 | 318 | $this->_billing_form = $form; |
319 | 319 | } |
320 | 320 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * Returns whether or not this payment method requires HTTPS to be used |
325 | 325 | * @return boolean |
326 | 326 | */ |
327 | - function requires_https(){ |
|
327 | + function requires_https() { |
|
328 | 328 | return $this->_requires_https; |
329 | 329 | } |
330 | 330 | |
@@ -342,9 +342,9 @@ discard block |
||
342 | 342 | * @return EE_Payment |
343 | 343 | * @throws EE_Error |
344 | 344 | */ |
345 | - function process_payment( EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null,$fail_url = '', $method = 'CART', $by_admin = false ){ |
|
345 | + function process_payment(EE_Transaction $transaction, $amount = null, $billing_info = null, $return_url = null, $fail_url = '', $method = 'CART', $by_admin = false) { |
|
346 | 346 | // @todo: add surcharge for the payment method, if any |
347 | - if ( $this->_gateway ) { |
|
347 | + if ($this->_gateway) { |
|
348 | 348 | //there is a gateway, so we're going to make a payment object |
349 | 349 | //but wait! do they already have a payment in progress that we thought was failed? |
350 | 350 | $duplicate_properties = array( |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
356 | 356 | 'PAY_gateway_response' => null, |
357 | 357 | ); |
358 | - $payment = EEM_Payment::instance()->get_one( array( $duplicate_properties )); |
|
358 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
359 | 359 | //if we didn't already have a payment in progress for the same thing, |
360 | 360 | //then we actually want to make a new payment |
361 | - if ( ! $payment instanceof EE_Payment ){ |
|
361 | + if ( ! $payment instanceof EE_Payment) { |
|
362 | 362 | $payment = EE_Payment::new_instance( |
363 | 363 | array_merge( |
364 | 364 | $duplicate_properties, |
@@ -374,10 +374,10 @@ discard block |
||
374 | 374 | } |
375 | 375 | //make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
376 | 376 | $payment->save(); |
377 | - $billing_values = $this->_get_billing_values_from_form( $billing_info ); |
|
377 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
378 | 378 | |
379 | 379 | // Offsite Gateway |
380 | - if( $this->_gateway instanceof EE_Offsite_Gateway ){ |
|
380 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
381 | 381 | |
382 | 382 | $payment = $this->_gateway->set_redirection_info( |
383 | 383 | $payment, |
@@ -393,17 +393,17 @@ discard block |
||
393 | 393 | ); |
394 | 394 | $payment->save(); |
395 | 395 | // Onsite Gateway |
396 | - } elseif ( $this->_gateway instanceof EE_Onsite_Gateway ) { |
|
396 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
397 | 397 | |
398 | - $payment = $this->_gateway->do_direct_payment($payment,$billing_values); |
|
398 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
399 | 399 | $payment->save(); |
400 | 400 | |
401 | 401 | } else { |
402 | 402 | throw new EE_Error( |
403 | 403 | sprintf( |
404 | - __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso' ), |
|
404 | + __('Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', 'event_espresso'), |
|
405 | 405 | get_class($this), |
406 | - gettype( $this->_gateway ) |
|
406 | + gettype($this->_gateway) |
|
407 | 407 | ) |
408 | 408 | ); |
409 | 409 | } |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // if there is billing info, clean it and save it now |
428 | - if( $billing_info instanceof EE_Billing_Attendee_Info_Form ){ |
|
429 | - $this->_save_billing_info_to_attendee( $billing_info, $transaction ); |
|
428 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
429 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | return $payment; |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | * @param EE_Billing_Info_Form $billing_form |
440 | 440 | * @return array |
441 | 441 | */ |
442 | - protected function _get_billing_values_from_form( $billing_form ){ |
|
443 | - if($billing_form instanceof EE_Form_Section_Proper ){ |
|
444 | - return $billing_form->input_pretty_values( true ); |
|
445 | - }else{ |
|
442 | + protected function _get_billing_values_from_form($billing_form) { |
|
443 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
444 | + return $billing_form->input_pretty_values(true); |
|
445 | + } else { |
|
446 | 446 | return NULL; |
447 | 447 | } |
448 | 448 | } |
@@ -456,13 +456,13 @@ discard block |
||
456 | 456 | * @return EE_Payment |
457 | 457 | * @throws EE_Error |
458 | 458 | */ |
459 | - public function handle_ipn($req_data,$transaction){ |
|
459 | + public function handle_ipn($req_data, $transaction) { |
|
460 | 460 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
461 | - if( ! $this->_gateway instanceof EE_Offsite_Gateway){ |
|
462 | - throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r( $this->_gateway, TRUE ))); |
|
461 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
462 | + throw new EE_Error(sprintf(__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), print_r($this->_gateway, TRUE))); |
|
463 | 463 | |
464 | 464 | } |
465 | - $payment = $this->_gateway->handle_payment_update( $req_data, $transaction ); |
|
465 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
466 | 466 | return $payment; |
467 | 467 | } |
468 | 468 | |
@@ -475,22 +475,22 @@ discard block |
||
475 | 475 | * @param EE_Transaction $transaction |
476 | 476 | * @return boolean success |
477 | 477 | */ |
478 | - protected function _save_billing_info_to_attendee($billing_form, $transaction){ |
|
479 | - if( ! $transaction || ! $transaction instanceof EE_Transaction){ |
|
478 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) { |
|
479 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
480 | 480 | EE_Error::add_error(__("Cannot save billing info because no transaction was specified", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
481 | 481 | return false; |
482 | 482 | } |
483 | 483 | $primary_reg = $transaction->primary_registration(); |
484 | - if( ! $primary_reg ){ |
|
484 | + if ( ! $primary_reg) { |
|
485 | 485 | EE_Error::add_error(__("Cannot save billing info because the transaction has no primary registration", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
486 | 486 | return false; |
487 | 487 | } |
488 | 488 | $attendee = $primary_reg->attendee(); |
489 | - if( ! $attendee ){ |
|
489 | + if ( ! $attendee) { |
|
490 | 490 | EE_Error::add_error(__("Cannot save billing info because the transaction's primary registration has no attendee!", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
491 | 491 | return false; |
492 | 492 | } |
493 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method() ); |
|
493 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
@@ -503,7 +503,7 @@ discard block |
||
503 | 503 | * @param array $req_data |
504 | 504 | * @return EE_Payment |
505 | 505 | */ |
506 | - protected function find_payment_for_ipn( EE_Transaction $transaction, $req_data = array() ){ |
|
506 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) { |
|
507 | 507 | return $transaction->last_payment(); |
508 | 508 | } |
509 | 509 | |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
521 | 521 | * @throws EE_Error |
522 | 522 | */ |
523 | - public function handle_unclaimed_ipn( $req_data = array() ){ |
|
524 | - throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this) )); |
|
523 | + public function handle_unclaimed_ipn($req_data = array()) { |
|
524 | + throw new EE_Error(sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | * @param EE_Transaction $transaction |
538 | 538 | * @return EE_Payment |
539 | 539 | */ |
540 | - public function finalize_payment_for($transaction){ |
|
540 | + public function finalize_payment_for($transaction) { |
|
541 | 541 | return $transaction->last_payment(); |
542 | 542 | } |
543 | 543 | |
@@ -547,10 +547,10 @@ discard block |
||
547 | 547 | * Whether or not this payment method's gateway supports sending refund requests |
548 | 548 | * @return boolean |
549 | 549 | */ |
550 | - public function supports_sending_refunds(){ |
|
551 | - if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
|
550 | + public function supports_sending_refunds() { |
|
551 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
552 | 552 | return $this->_gateway->supports_sending_refunds(); |
553 | - }else{ |
|
553 | + } else { |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | } |
@@ -564,14 +564,14 @@ discard block |
||
564 | 564 | * @throws EE_Error |
565 | 565 | * @return EE_Payment |
566 | 566 | */ |
567 | - public function process_refund( EE_Payment $payment, $refund_info = array()){ |
|
568 | - if ( $this->_gateway && $this->_gateway instanceof EE_Gateway ) { |
|
569 | - return $this->_gateway->do_direct_refund( $payment, $refund_info ); |
|
567 | + public function process_refund(EE_Payment $payment, $refund_info = array()) { |
|
568 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
569 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
570 | 570 | } else { |
571 | 571 | throw new EE_Error( |
572 | 572 | sprintf( |
573 | - __( 'Payment Method Type "%s" does not support sending refund requests', 'event_espresso' ), |
|
574 | - get_class( $this ) |
|
573 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
574 | + get_class($this) |
|
575 | 575 | ) |
576 | 576 | ); |
577 | 577 | } |
@@ -585,15 +585,15 @@ discard block |
||
585 | 585 | * @return string |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function payment_occurs(){ |
|
589 | - if( ! $this->_gateway){ |
|
588 | + public function payment_occurs() { |
|
589 | + if ( ! $this->_gateway) { |
|
590 | 590 | return EE_PMT_Base::offline; |
591 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
591 | + }elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
592 | 592 | return EE_PMT_Base::onsite; |
593 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
593 | + }elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
594 | 594 | return EE_PMT_Base::offsite; |
595 | - }else{ |
|
596 | - throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
|
595 | + } else { |
|
596 | + throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"), get_class($this))); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | * @param EE_Payment $payment |
607 | 607 | * @return string |
608 | 608 | */ |
609 | - public function payment_overview_content(EE_Payment $payment){ |
|
609 | + public function payment_overview_content(EE_Payment $payment) { |
|
610 | 610 | EE_Registry::instance()->load_helper('Template'); |
611 | - return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance,'payment'=>$payment) , true); |
|
611 | + return EEH_Template::display_template(EE_LIBRARIES.'payment_methods'.DS.'templates'.DS.'payment_details_content.template.php', array('payment_method'=>$this->_pm_instance, 'payment'=>$payment), true); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | /** |
617 | 617 | * @return array exactly like EE_Admin_Page _page_config's 'help_tabs' attribute. @see EE_Admin_Page::_set_page_config() |
618 | 618 | */ |
619 | - public function help_tabs_config(){ |
|
619 | + public function help_tabs_config() { |
|
620 | 620 | return array(); |
621 | 621 | } |
622 | 622 | |
@@ -627,9 +627,9 @@ discard block |
||
627 | 627 | * the payment method's table's PMT_type column) |
628 | 628 | * @return string |
629 | 629 | */ |
630 | - public function system_name(){ |
|
630 | + public function system_name() { |
|
631 | 631 | $classname = get_class($this); |
632 | - return str_replace("EE_PMT_",'',$classname); |
|
632 | + return str_replace("EE_PMT_", '', $classname); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * A pretty i18n version of the PMT name |
639 | 639 | * @return string |
640 | 640 | */ |
641 | - public function pretty_name(){ |
|
641 | + public function pretty_name() { |
|
642 | 642 | return $this->_pretty_name; |
643 | 643 | } |
644 | 644 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * Gets the default absolute URL to the payment method type's button |
649 | 649 | * @return string |
650 | 650 | */ |
651 | - public function default_button_url(){ |
|
651 | + public function default_button_url() { |
|
652 | 652 | return $this->_default_button_url; |
653 | 653 | } |
654 | 654 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * Gets the gateway used by this payment method (if any) |
659 | 659 | * @return EE_Gateway |
660 | 660 | */ |
661 | - public function get_gateway(){ |
|
661 | + public function get_gateway() { |
|
662 | 662 | return $this->_gateway; |
663 | 663 | } |
664 | 664 | |
@@ -667,9 +667,9 @@ discard block |
||
667 | 667 | /** |
668 | 668 | * @return string html for the link to a help tab |
669 | 669 | */ |
670 | - public function get_help_tab_link(){ |
|
671 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
672 | - return EEH_Template::get_help_tab_link( $this->get_help_tab_name() ); |
|
670 | + public function get_help_tab_link() { |
|
671 | + EE_Registry::instance()->load_helper('Template'); |
|
672 | + return EEH_Template::get_help_tab_link($this->get_help_tab_name()); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | |
@@ -678,8 +678,8 @@ discard block |
||
678 | 678 | * Returns the name of the help tab for this PMT |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - public function get_help_tab_name(){ |
|
682 | - return 'ee_' . strtolower( $this->system_name() ) . '_help_tab'; |
|
681 | + public function get_help_tab_name() { |
|
682 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | /** |
@@ -687,8 +687,8 @@ discard block |
||
687 | 687 | * this PMT by an admin |
688 | 688 | * @return string |
689 | 689 | */ |
690 | - public function cap_name(){ |
|
691 | - return 'ee_payment_method_' . strtolower( $this->system_name() ); |
|
690 | + public function cap_name() { |
|
691 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -700,9 +700,9 @@ discard block |
||
700 | 700 | * @param EE_Payment $payment |
701 | 701 | * @return void |
702 | 702 | */ |
703 | - public function update_txn_based_on_payment( $payment ){ |
|
704 | - if( $this->_gateway instanceof EE_Gateway ){ |
|
705 | - $this->_gateway->update_txn_based_on_payment( $payment ); |
|
703 | + public function update_txn_based_on_payment($payment) { |
|
704 | + if ($this->_gateway instanceof EE_Gateway) { |
|
705 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
706 | 706 | } |
707 | 707 | } |
708 | 708 |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | protected function _get_billing_values_from_form( $billing_form ){ |
443 | 443 | if($billing_form instanceof EE_Form_Section_Proper ){ |
444 | 444 | return $billing_form->input_pretty_values( true ); |
445 | - }else{ |
|
445 | + } else{ |
|
446 | 446 | return NULL; |
447 | 447 | } |
448 | 448 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | public function supports_sending_refunds(){ |
551 | 551 | if($this->_gateway && $this->_gateway instanceof EE_Gateway){ |
552 | 552 | return $this->_gateway->supports_sending_refunds(); |
553 | - }else{ |
|
553 | + } else{ |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | } |
@@ -588,11 +588,11 @@ discard block |
||
588 | 588 | public function payment_occurs(){ |
589 | 589 | if( ! $this->_gateway){ |
590 | 590 | return EE_PMT_Base::offline; |
591 | - }elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
591 | + } elseif($this->_gateway instanceof EE_Onsite_Gateway){ |
|
592 | 592 | return EE_PMT_Base::onsite; |
593 | - }elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
593 | + } elseif($this->_gateway instanceof EE_Offsite_Gateway){ |
|
594 | 594 | return EE_PMT_Base::offsite; |
595 | - }else{ |
|
595 | + } else{ |
|
596 | 596 | throw new EE_Error(sprintf(__("Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", "event_espresso"),get_class($this))); |
597 | 597 | } |
598 | 598 | } |
@@ -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 | /** |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | * @param string $shortcode |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - protected function _parser( $shortcode ) { |
|
64 | + protected function _parser($shortcode) { |
|
65 | 65 | |
66 | - if ( ! $this->_data instanceof EE_Datetime ) { |
|
66 | + if ( ! $this->_data instanceof EE_Datetime) { |
|
67 | 67 | return ''; //get out cause we can only parse with the datetime object. |
68 | 68 | } |
69 | 69 | |
70 | - switch ( $shortcode ) { |
|
70 | + switch ($shortcode) { |
|
71 | 71 | |
72 | 72 | case '[DATETIME_START]' : |
73 | 73 | return $this->_data->get_i18n_datetime('DTT_EVT_start'); |
@@ -81,27 +81,27 @@ discard block |
||
81 | 81 | return $this->_data->get_timezone(); |
82 | 82 | break; |
83 | 83 | case '[DATE_START]' : |
84 | - return $this->_data->get_i18n_datetime( 'DTT_EVT_start', get_option( 'date_format' ) ); |
|
84 | + return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('date_format')); |
|
85 | 85 | break; |
86 | 86 | case '[DATE_END]' : |
87 | - return $this->_data->get_i18n_datetime( 'DTT_EVT_end', get_option( 'date_format' ) ); |
|
87 | + return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('date_format')); |
|
88 | 88 | break; |
89 | 89 | case '[TIME_START]' : |
90 | - return $this->_data->get_i18n_datetime( 'DTT_EVT_start', get_option( 'time_format' ) ); |
|
90 | + return $this->_data->get_i18n_datetime('DTT_EVT_start', get_option('time_format')); |
|
91 | 91 | break; |
92 | 92 | case '[TIME_END]' : |
93 | - return $this->_data->get_i18n_datetime( 'DTT_EVT_end', get_option( 'time_format' ) ); |
|
93 | + return $this->_data->get_i18n_datetime('DTT_EVT_end', get_option('time_format')); |
|
94 | 94 | break; |
95 | 95 | } |
96 | 96 | |
97 | - if ( strpos( $shortcode, '[ICAL_LINK_*') !== FALSE ) { |
|
98 | - $attrs = $this->_get_shortcode_attrs( $shortcode ); |
|
97 | + if (strpos($shortcode, '[ICAL_LINK_*') !== FALSE) { |
|
98 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
99 | 99 | |
100 | - $link_text = empty( $attrs['link_text'] ) ? __( 'Add to iCal Calendar', 'event_espresso' ) : $attrs['link_text']; |
|
100 | + $link_text = empty($attrs['link_text']) ? __('Add to iCal Calendar', 'event_espresso') : $attrs['link_text']; |
|
101 | 101 | |
102 | - $URL = add_query_arg( array( 'ee' => 'download_ics_file', 'ics_id' => $this->_data->ID() ), site_url() ); |
|
102 | + $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $this->_data->ID()), site_url()); |
|
103 | 103 | |
104 | - return '<a class="ee-ical" href="' . $URL . '">' . $link_text . '</a>'; |
|
104 | + return '<a class="ee-ical" href="'.$URL.'">'.$link_text.'</a>'; |
|
105 | 105 | |
106 | 106 | } |
107 | 107 |
@@ -5,16 +5,16 @@ |
||
5 | 5 | exit( 'No direct script access allowed' ); |
6 | 6 | } |
7 | 7 | /** |
8 | - * Class EE_Template_Part |
|
9 | - * |
|
10 | - * class for holding details about a template part |
|
11 | - * |
|
12 | - * @package Event Espresso |
|
13 | - * @subpackage core |
|
14 | - * @author Brent Christensen |
|
15 | - * @since $VID:$ |
|
16 | - * |
|
17 | - */ |
|
8 | + * Class EE_Template_Part |
|
9 | + * |
|
10 | + * class for holding details about a template part |
|
11 | + * |
|
12 | + * @package Event Espresso |
|
13 | + * @subpackage core |
|
14 | + * @author Brent Christensen |
|
15 | + * @since $VID:$ |
|
16 | + * |
|
17 | + */ |
|
18 | 18 | class EE_Template_Part { |
19 | 19 | |
20 | 20 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | //namespace EventEspresso\core\libraries\templates; |
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 | * Class EE_Template_Part |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param string $template |
48 | 48 | * @param int $priority |
49 | 49 | */ |
50 | - public function __construct( $name, $label, $template, $priority = 100 ) { |
|
51 | - $this->set_name( $name ); |
|
52 | - $this->set_label( $label ); |
|
53 | - $this->set_template( $template ); |
|
54 | - $this->set_priority( $priority ); |
|
50 | + public function __construct($name, $label, $template, $priority = 100) { |
|
51 | + $this->set_name($name); |
|
52 | + $this->set_label($label); |
|
53 | + $this->set_template($template); |
|
54 | + $this->set_priority($priority); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /** |
69 | 69 | * @param mixed $name |
70 | 70 | */ |
71 | - public function set_name( $name ) { |
|
71 | + public function set_name($name) { |
|
72 | 72 | $this->name = $name; |
73 | 73 | } |
74 | 74 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @param string $label |
88 | 88 | */ |
89 | - public function set_label( $label ) { |
|
89 | + public function set_label($label) { |
|
90 | 90 | $this->label = $label; |
91 | 91 | } |
92 | 92 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * @param string $template |
106 | 106 | */ |
107 | - public function set_template( $template ) { |
|
107 | + public function set_template($template) { |
|
108 | 108 | $this->template = $template; |
109 | 109 | } |
110 | 110 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | /** |
123 | 123 | * @param int $priority |
124 | 124 | */ |
125 | - public function set_priority( $priority ) { |
|
126 | - $this->priority = intval( $priority ); |
|
125 | + public function set_priority($priority) { |
|
126 | + $this->priority = intval($priority); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 |