@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | |
29 | - $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' ); |
|
30 | - $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' ); |
|
29 | + $this->templates_dir = apply_filters('getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates'); |
|
30 | + $this->templates_url = apply_filters('getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates'); |
|
31 | 31 | |
32 | 32 | // Oxygen plugin |
33 | - if ( defined( 'CT_VERSION' ) ) { |
|
34 | - add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
33 | + if (defined('CT_VERSION')) { |
|
34 | + add_filter('wpinv_locate_template', array($this, 'oxygen_override_template'), 11, 4); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | public function is_elementor_preview() { |
63 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
63 | + return isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return bool |
71 | 71 | */ |
72 | 72 | public function is_divi_preview() { |
73 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
73 | + return isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'et_pb'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return bool |
81 | 81 | */ |
82 | 82 | public function is_beaver_preview() { |
83 | - return isset( $_REQUEST['fl_builder'] ); |
|
83 | + return isset($_REQUEST['fl_builder']); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return bool |
91 | 91 | */ |
92 | 92 | public function is_siteorigin_preview() { |
93 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
93 | + return !empty($_REQUEST['siteorigin_panels_live_editor']); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return bool |
101 | 101 | */ |
102 | 102 | public function is_cornerstone_preview() { |
103 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
103 | + return !empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return bool |
111 | 111 | */ |
112 | 112 | public function is_fusion_preview() { |
113 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
113 | + return !empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce']); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @return bool |
121 | 121 | */ |
122 | 122 | public function is_oxygen_preview() { |
123 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
123 | + return !empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_")); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,24 +130,24 @@ discard block |
||
130 | 130 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
131 | 131 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
132 | 132 | */ |
133 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
133 | + public function locate_template($template_name, $template_path = '', $default_path = '') { |
|
134 | 134 | |
135 | 135 | // Load the defaults for the template path and default path. |
136 | - $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
|
137 | - $default_path = empty( $default_path ) ? $this->templates_dir : $default_path; |
|
138 | - $default_path = apply_filters( 'getpaid_template_default_template_path', $default_path, $template_name ); |
|
136 | + $template_path = empty($template_path) ? 'invoicing' : $template_path; |
|
137 | + $default_path = empty($default_path) ? $this->templates_dir : $default_path; |
|
138 | + $default_path = apply_filters('getpaid_template_default_template_path', $default_path, $template_name); |
|
139 | 139 | |
140 | 140 | // Is it overidden? |
141 | 141 | $template = locate_template( |
142 | - array( trailingslashit( $template_path ) . $template_name, 'wpinv-' . $template_name ) |
|
142 | + array(trailingslashit($template_path) . $template_name, 'wpinv-' . $template_name) |
|
143 | 143 | ); |
144 | 144 | |
145 | 145 | // If not, load the default template. |
146 | - if ( empty( $template ) ) { |
|
147 | - $template = trailingslashit( $default_path ) . $template_name; |
|
146 | + if (empty($template)) { |
|
147 | + $template = trailingslashit($default_path) . $template_name; |
|
148 | 148 | } |
149 | 149 | |
150 | - return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path, $default_path ); |
|
150 | + return apply_filters('wpinv_locate_template', $template, $template_name, $template_path, $default_path); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * @since 1.0.19 |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | - protected function load_template( $template_name, $template_path, $args ) { |
|
159 | + protected function load_template($template_name, $template_path, $args) { |
|
160 | 160 | |
161 | - if ( is_array( $args ) ){ |
|
162 | - extract( $args ); |
|
161 | + if (is_array($args)) { |
|
162 | + extract($args); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Fires before loading a template. |
166 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
166 | + do_action('wpinv_before_template_part', $template_name, $template_path, $args); |
|
167 | 167 | |
168 | 168 | // Load the template. |
169 | - include( $template_path ); |
|
169 | + include($template_path); |
|
170 | 170 | |
171 | 171 | // Fires after loading a template. |
172 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
|
172 | + do_action('wpinv_after_template_part', $template_name, $template_path, $args); |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
184 | 184 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
185 | 185 | */ |
186 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
186 | + public function display_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
187 | 187 | |
188 | 188 | // Locate the template. |
189 | - $located = $this->locate_template( $template_name, $template_path, $default_path ); |
|
189 | + $located = $this->locate_template($template_name, $template_path, $default_path); |
|
190 | 190 | |
191 | 191 | // Abort if the file does not exist. |
192 | - if ( ! file_exists( $located ) ) { |
|
193 | - getpaid_doing_it_wrong( __METHOD__, sprintf( '<code>%s</code> does not exist.', $located ), '2.0.0' ); |
|
192 | + if (!file_exists($located)) { |
|
193 | + getpaid_doing_it_wrong(__METHOD__, sprintf('<code>%s</code> does not exist.', $located), '2.0.0'); |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | - $this->load_template( $template_name, $located, $args ); |
|
197 | + $this->load_template($template_name, $located, $args); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
209 | 209 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
210 | 210 | */ |
211 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
211 | + public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
212 | 212 | ob_start(); |
213 | - $this->display_template( $template_name, $args, $template_path, $default_path ); |
|
213 | + $this->display_template($template_name, $args, $template_path, $default_path); |
|
214 | 214 | return ob_get_clean(); |
215 | 215 | } |
216 | 216 | |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public static function get_theme_template_path() { |
224 | 224 | $template = get_template(); |
225 | - $theme_root = get_theme_root( $template ); |
|
225 | + $theme_root = get_theme_root($template); |
|
226 | 226 | |
227 | - return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
227 | + return $theme_root . '/' . $template . '/' . untrailingslashit(wpinv_get_theme_template_dir_name()); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -234,28 +234,28 @@ discard block |
||
234 | 234 | * @param string $template The template. |
235 | 235 | * @return string The theme template. |
236 | 236 | */ |
237 | - public static function oxygen_locate_template( $template ) { |
|
237 | + public static function oxygen_locate_template($template) { |
|
238 | 238 | |
239 | - if ( empty( $template ) ) { |
|
239 | + if (empty($template)) { |
|
240 | 240 | return ''; |
241 | 241 | } |
242 | 242 | |
243 | - $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
243 | + $has_filter = has_filter('template', 'ct_oxygen_template_name'); |
|
244 | 244 | |
245 | 245 | // Remove template filter |
246 | - if ( $has_filter ) { |
|
247 | - remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
246 | + if ($has_filter) { |
|
247 | + remove_filter('template', 'ct_oxygen_template_name'); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | $template = self::get_theme_template_path() . '/' . $template; |
251 | 251 | |
252 | - if ( ! file_exists( $template ) ) { |
|
252 | + if (!file_exists($template)) { |
|
253 | 253 | $template = ''; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Add template filter |
257 | - if ( $has_filter ) { |
|
258 | - add_filter( 'template', 'ct_oxygen_template_name' ); |
|
257 | + if ($has_filter) { |
|
258 | + add_filter('template', 'ct_oxygen_template_name'); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $template; |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param string $template_name Template name. |
269 | 269 | * @return string Located template. |
270 | 270 | */ |
271 | - public function oxygen_override_template( $located, $template_name ) { |
|
271 | + public function oxygen_override_template($located, $template_name) { |
|
272 | 272 | |
273 | - $oxygen_overide = self::oxygen_locate_template( $template_name ); |
|
274 | - if ( ! empty( $oxygen_overide ) ) { |
|
273 | + $oxygen_overide = self::oxygen_locate_template($template_name); |
|
274 | + if (!empty($oxygen_overide)) { |
|
275 | 275 | return $oxygen_overide; |
276 | 276 | } |
277 | 277 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | global $wpinv_options; |
44 | 44 | |
45 | 45 | // Try fetching the saved options. |
46 | - if ( ! is_array( $wpinv_options ) ) { |
|
47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
46 | + if (!is_array($wpinv_options)) { |
|
47 | + $wpinv_options = get_option('wpinv_settings'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | // If that fails, don't fetch the default settings to prevent a loop. |
51 | - if ( ! is_array( $wpinv_options ) ) { |
|
51 | + if (!is_array($wpinv_options)) { |
|
52 | 52 | $wpinv_options = array(); |
53 | 53 | } |
54 | 54 | |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @param mixed $default The default value to use if the setting has not been set. |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | -function wpinv_get_option( $key = '', $default = false ) { |
|
65 | +function wpinv_get_option($key = '', $default = false) { |
|
66 | 66 | |
67 | 67 | $options = wpinv_get_options(); |
68 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
69 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
68 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
69 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
71 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param array $options the new options. |
78 | 78 | * @return bool |
79 | 79 | */ |
80 | -function wpinv_update_options( $options ) { |
|
80 | +function wpinv_update_options($options) { |
|
81 | 81 | global $wpinv_options; |
82 | 82 | |
83 | 83 | // update the option. |
84 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
84 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
85 | 85 | $wpinv_options = $options; |
86 | 86 | return true; |
87 | 87 | } |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | * @param mixed $value The setting value. |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | -function wpinv_update_option( $key = '', $value = false ) { |
|
99 | +function wpinv_update_option($key = '', $value = false) { |
|
100 | 100 | |
101 | 101 | // If no key, exit. |
102 | - if ( empty( $key ) ) { |
|
102 | + if (empty($key)) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Maybe delete the option instead. |
107 | - if ( is_null( $value ) ) { |
|
108 | - return wpinv_delete_option( $key ); |
|
107 | + if (is_null($value)) { |
|
108 | + return wpinv_delete_option($key); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | // Prepare the new options. |
112 | 112 | $options = wpinv_get_options(); |
113 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
113 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
114 | 114 | |
115 | 115 | // Save the new options. |
116 | - return wpinv_update_options( $options ); |
|
116 | + return wpinv_update_options($options); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -123,18 +123,18 @@ discard block |
||
123 | 123 | * @param string $key the setting key. |
124 | 124 | * @return bool |
125 | 125 | */ |
126 | -function wpinv_delete_option( $key = '' ) { |
|
126 | +function wpinv_delete_option($key = '') { |
|
127 | 127 | |
128 | 128 | // If no key, exit |
129 | - if ( empty( $key ) ) { |
|
129 | + if (empty($key)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $options = wpinv_get_options(); |
134 | 134 | |
135 | - if ( isset( $options[ $key ] ) ) { |
|
136 | - unset( $options[ $key ] ); |
|
137 | - return wpinv_update_options( $options ); |
|
135 | + if (isset($options[$key])) { |
|
136 | + unset($options[$key]); |
|
137 | + return wpinv_update_options($options); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | return true; |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | function wpinv_register_settings() { |
149 | 149 | |
150 | 150 | // Loop through all tabs. |
151 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
151 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
152 | 152 | |
153 | 153 | // In each tab, loop through sections. |
154 | - foreach ( $sections as $section => $settings ) { |
|
154 | + foreach ($sections as $section => $settings) { |
|
155 | 155 | |
156 | 156 | // Check for backwards compatibility |
157 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
158 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
157 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
158 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
159 | 159 | $section = 'main'; |
160 | 160 | $settings = $sections; |
161 | 161 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | 'wpinv_settings_' . $tab . '_' . $section |
169 | 169 | ); |
170 | 170 | |
171 | - foreach ( $settings as $option ) { |
|
172 | - if ( ! empty( $option['id'] ) ) { |
|
173 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
171 | + foreach ($settings as $option) { |
|
172 | + if (!empty($option['id'])) { |
|
173 | + wpinv_register_settings_option($tab, $section, $option); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | } |
183 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
183 | +add_action('admin_init', 'wpinv_register_settings'); |
|
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Register a single settings option. |
@@ -190,47 +190,47 @@ discard block |
||
190 | 190 | * @param string $option |
191 | 191 | * |
192 | 192 | */ |
193 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
193 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
194 | 194 | |
195 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
195 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = wpinv_clean( $option['desc'] ); |
|
199 | + if (isset($option['desc']) && !empty($option['help-tip'])) { |
|
200 | + $tip = wpinv_clean($option['desc']); |
|
201 | 201 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
202 | - unset( $option['desc'] ); |
|
202 | + unset($option['desc']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
207 | 207 | 'wpinv_settings[' . $option['id'] . ']', |
208 | 208 | $name, |
209 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
209 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
210 | 210 | $section, |
211 | 211 | $section, |
212 | 212 | array( |
213 | 213 | 'section' => $section, |
214 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
215 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
214 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
215 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
216 | 216 | 'name' => $name, |
217 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
218 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
219 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
220 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
221 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
222 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
223 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
224 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
225 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
226 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
227 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
228 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
229 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
230 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
231 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
232 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
217 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
218 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
219 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
220 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
221 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
222 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
223 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
224 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
225 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
226 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
227 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
228 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
229 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
230 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
231 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
232 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
233 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array |
243 | 243 | */ |
244 | 244 | function wpinv_get_registered_settings() { |
245 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
245 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @return array |
252 | 252 | */ |
253 | 253 | function getpaid_get_integration_settings() { |
254 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
254 | + return apply_filters('getpaid_integration_settings', array()); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -259,144 +259,144 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return array |
261 | 261 | */ |
262 | -function wpinv_settings_sanitize( $input = array() ) { |
|
262 | +function wpinv_settings_sanitize($input = array()) { |
|
263 | 263 | |
264 | 264 | $wpinv_options = wpinv_get_options(); |
265 | 265 | $raw_referrer = wp_get_raw_referer(); |
266 | 266 | |
267 | - if ( empty( $raw_referrer ) ) { |
|
267 | + if (empty($raw_referrer)) { |
|
268 | 268 | return $input; |
269 | 269 | } |
270 | 270 | |
271 | - wp_parse_str( $raw_referrer, $referrer ); |
|
271 | + wp_parse_str($raw_referrer, $referrer); |
|
272 | 272 | |
273 | - if ( empty( $referrer['tab'] ) ) { |
|
273 | + if (empty($referrer['tab'])) { |
|
274 | 274 | return $input; |
275 | 275 | } |
276 | 276 | |
277 | 277 | $settings = wpinv_get_registered_settings(); |
278 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
279 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
278 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
279 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
280 | 280 | |
281 | 281 | $input = $input ? $input : array(); |
282 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
283 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
282 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
283 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
284 | 284 | |
285 | 285 | // Loop through each setting being saved and pass it through a sanitization filter |
286 | - foreach ( $input as $key => $value ) { |
|
286 | + foreach ($input as $key => $value) { |
|
287 | 287 | |
288 | 288 | // Get the setting type (checkbox, select, etc) |
289 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
289 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
290 | 290 | |
291 | - if ( $type ) { |
|
291 | + if ($type) { |
|
292 | 292 | // Field type specific filter |
293 | - $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key ); |
|
293 | + $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // General filter |
297 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
297 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
298 | 298 | |
299 | 299 | // Key specific filter. |
300 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
300 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | // Loop through the whitelist and unset any that are empty for the tab being saved |
304 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
305 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
304 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
305 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
306 | 306 | |
307 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
307 | + $found_settings = array_merge($main_settings, $section_settings); |
|
308 | 308 | |
309 | - if ( ! empty( $found_settings ) ) { |
|
310 | - foreach ( $found_settings as $key => $value ) { |
|
309 | + if (!empty($found_settings)) { |
|
310 | + foreach ($found_settings as $key => $value) { |
|
311 | 311 | |
312 | 312 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
313 | - if ( is_numeric( $key ) ) { |
|
313 | + if (is_numeric($key)) { |
|
314 | 314 | $key = $value['id']; |
315 | 315 | } |
316 | 316 | |
317 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
318 | - unset( $wpinv_options[ $key ] ); |
|
317 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
318 | + unset($wpinv_options[$key]); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | // Merge our new settings with the existing |
324 | - $output = array_merge( $wpinv_options, $input ); |
|
324 | + $output = array_merge($wpinv_options, $input); |
|
325 | 325 | |
326 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
326 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
327 | 327 | |
328 | 328 | return $output; |
329 | 329 | } |
330 | 330 | |
331 | -function wpinv_settings_sanitize_misc_accounting( $input ) { |
|
331 | +function wpinv_settings_sanitize_misc_accounting($input) { |
|
332 | 332 | |
333 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
333 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
334 | 334 | return $input; |
335 | 335 | } |
336 | 336 | |
337 | - if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) { |
|
337 | + if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) { |
|
338 | 338 | // Shows an admin notice about upgrading previous order numbers |
339 | - getpaid_session()->set( 'upgrade_sequential', '1' ); |
|
339 | + getpaid_session()->set('upgrade_sequential', '1'); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | return $input; |
343 | 343 | } |
344 | -add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' ); |
|
344 | +add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting'); |
|
345 | 345 | |
346 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
347 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
346 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
347 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
348 | 348 | return $input; |
349 | 349 | } |
350 | 350 | |
351 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array(); |
|
351 | + $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array(); |
|
352 | 352 | $tax_rates = array(); |
353 | 353 | |
354 | - foreach ( $new_rates as $rate ) { |
|
354 | + foreach ($new_rates as $rate) { |
|
355 | 355 | |
356 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
357 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
358 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
359 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
360 | - $rate['global'] = empty( $rate['state'] ); |
|
356 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
357 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
358 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
359 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
360 | + $rate['global'] = empty($rate['state']); |
|
361 | 361 | $tax_rates[] = $rate; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
365 | + update_option('wpinv_tax_rates', $tax_rates); |
|
366 | 366 | |
367 | 367 | return $input; |
368 | 368 | } |
369 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
369 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
370 | 370 | |
371 | -function wpinv_sanitize_text_field( $input ) { |
|
372 | - return trim( $input ); |
|
371 | +function wpinv_sanitize_text_field($input) { |
|
372 | + return trim($input); |
|
373 | 373 | } |
374 | -add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' ); |
|
374 | +add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field'); |
|
375 | 375 | |
376 | 376 | function wpinv_get_settings_tabs() { |
377 | 377 | $tabs = array(); |
378 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
379 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
380 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
381 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
378 | + $tabs['general'] = __('General', 'invoicing'); |
|
379 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
380 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
381 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
382 | 382 | |
383 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
384 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
383 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
384 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
385 | 385 | } |
386 | 386 | |
387 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
388 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
389 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
387 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
388 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
389 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
390 | 390 | |
391 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
391 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
392 | 392 | } |
393 | 393 | |
394 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
394 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
395 | 395 | $tabs = false; |
396 | 396 | $sections = wpinv_get_registered_settings_sections(); |
397 | 397 | |
398 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
399 | - $tabs = $sections[ $tab ]; |
|
398 | + if ($tab && !empty($sections[$tab])) { |
|
399 | + $tabs = $sections[$tab]; |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | return $tabs; |
@@ -405,91 +405,91 @@ discard block |
||
405 | 405 | function wpinv_get_registered_settings_sections() { |
406 | 406 | static $sections = false; |
407 | 407 | |
408 | - if ( false !== $sections ) { |
|
408 | + if (false !== $sections) { |
|
409 | 409 | return $sections; |
410 | 410 | } |
411 | 411 | |
412 | 412 | $sections = array( |
413 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
414 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
415 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
416 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
417 | - ) ), |
|
418 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
419 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
420 | - ) ), |
|
421 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
422 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
423 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
424 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
425 | - ) ), |
|
426 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
427 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
428 | - ) ), |
|
429 | - |
|
430 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
431 | - |
|
432 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
433 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
434 | - ) ), |
|
435 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
436 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
437 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
438 | - ) ), |
|
439 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
440 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
441 | - ) ), |
|
413 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
414 | + 'main' => __('General Settings', 'invoicing'), |
|
415 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
416 | + 'labels' => __('Label Texts', 'invoicing'), |
|
417 | + )), |
|
418 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
419 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
420 | + )), |
|
421 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
422 | + 'main' => __('Tax Settings', 'invoicing'), |
|
423 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
424 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
425 | + )), |
|
426 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
427 | + 'main' => __('Email Settings', 'invoicing'), |
|
428 | + )), |
|
429 | + |
|
430 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
431 | + |
|
432 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
433 | + 'main' => __('Privacy policy', 'invoicing'), |
|
434 | + )), |
|
435 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
436 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
437 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
438 | + )), |
|
439 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
440 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
441 | + )), |
|
442 | 442 | ); |
443 | 443 | |
444 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
444 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
445 | 445 | |
446 | 446 | return $sections; |
447 | 447 | } |
448 | 448 | |
449 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
449 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
450 | 450 | $pages_options = array(); |
451 | 451 | |
452 | - if( $default_label !== NULL && $default_label !== false ) { |
|
453 | - $pages_options = array( '' => $default_label ); // Blank option |
|
452 | + if ($default_label !== NULL && $default_label !== false) { |
|
453 | + $pages_options = array('' => $default_label); // Blank option |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | $pages = get_pages(); |
457 | - if ( $pages ) { |
|
458 | - foreach ( $pages as $page ) { |
|
457 | + if ($pages) { |
|
458 | + foreach ($pages as $page) { |
|
459 | 459 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
460 | - $pages_options[ $page->ID ] = $title; |
|
460 | + $pages_options[$page->ID] = $title; |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | 464 | return $pages_options; |
465 | 465 | } |
466 | 466 | |
467 | -function wpinv_header_callback( $args ) { |
|
468 | - if ( !empty( $args['desc'] ) ) { |
|
467 | +function wpinv_header_callback($args) { |
|
468 | + if (!empty($args['desc'])) { |
|
469 | 469 | echo $args['desc']; |
470 | 470 | } |
471 | 471 | } |
472 | 472 | |
473 | -function wpinv_hidden_callback( $args ) { |
|
473 | +function wpinv_hidden_callback($args) { |
|
474 | 474 | global $wpinv_options; |
475 | 475 | |
476 | - if ( isset( $args['set_value'] ) ) { |
|
476 | + if (isset($args['set_value'])) { |
|
477 | 477 | $value = $args['set_value']; |
478 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
479 | - $value = $wpinv_options[ $args['id'] ]; |
|
478 | + } elseif (isset($wpinv_options[$args['id']])) { |
|
479 | + $value = $wpinv_options[$args['id']]; |
|
480 | 480 | } else { |
481 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
481 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
482 | 482 | } |
483 | 483 | |
484 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
484 | + if (isset($args['faux']) && true === $args['faux']) { |
|
485 | 485 | $args['readonly'] = true; |
486 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
486 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
487 | 487 | $name = ''; |
488 | 488 | } else { |
489 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
489 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
490 | 490 | } |
491 | 491 | |
492 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
492 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
493 | 493 | |
494 | 494 | echo $html; |
495 | 495 | } |
@@ -497,61 +497,61 @@ discard block |
||
497 | 497 | /** |
498 | 498 | * Displays a checkbox settings callback. |
499 | 499 | */ |
500 | -function wpinv_checkbox_callback( $args ) { |
|
500 | +function wpinv_checkbox_callback($args) { |
|
501 | 501 | |
502 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
503 | - $std = wpinv_get_option( $args['id'], $std ); |
|
504 | - $id = esc_attr( $args['id'] ); |
|
502 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
503 | + $std = wpinv_get_option($args['id'], $std); |
|
504 | + $id = esc_attr($args['id']); |
|
505 | 505 | |
506 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
506 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
507 | 507 | ?> |
508 | 508 | <fieldset> |
509 | 509 | <label> |
510 | - <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
511 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
510 | + <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
511 | + <?php echo wp_kses_post($args['desc']); ?> |
|
512 | 512 | </label> |
513 | 513 | </fieldset> |
514 | 514 | <?php |
515 | 515 | } |
516 | 516 | |
517 | -function wpinv_multicheck_callback( $args ) { |
|
517 | +function wpinv_multicheck_callback($args) { |
|
518 | 518 | |
519 | 519 | global $wpinv_options; |
520 | 520 | |
521 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
522 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
521 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
522 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
523 | 523 | |
524 | - if ( ! empty( $args['options'] ) ) { |
|
524 | + if (!empty($args['options'])) { |
|
525 | 525 | |
526 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
527 | - $value = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std; |
|
526 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
527 | + $value = isset($wpinv_options[$args['id']]) ? $wpinv_options[$args['id']] : $std; |
|
528 | 528 | |
529 | 529 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
530 | - foreach( $args['options'] as $key => $option ): |
|
531 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
532 | - if ( in_array( $sanitize_key, $value ) ) { |
|
530 | + foreach ($args['options'] as $key => $option): |
|
531 | + $sanitize_key = wpinv_sanitize_key($key); |
|
532 | + if (in_array($sanitize_key, $value)) { |
|
533 | 533 | $enabled = $sanitize_key; |
534 | 534 | } else { |
535 | 535 | $enabled = NULL; |
536 | 536 | } |
537 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
538 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
537 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
538 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
539 | 539 | endforeach; |
540 | 540 | echo '</div>'; |
541 | 541 | echo '<p class="description">' . $args['desc'] . '</p>'; |
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | -function wpinv_payment_icons_callback( $args ) { |
|
545 | +function wpinv_payment_icons_callback($args) { |
|
546 | 546 | global $wpinv_options; |
547 | 547 | |
548 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
548 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
549 | 549 | |
550 | - if ( ! empty( $args['options'] ) ) { |
|
551 | - foreach( $args['options'] as $key => $option ) { |
|
552 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
550 | + if (!empty($args['options'])) { |
|
551 | + foreach ($args['options'] as $key => $option) { |
|
552 | + $sanitize_key = wpinv_sanitize_key($key); |
|
553 | 553 | |
554 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
554 | + if (isset($wpinv_options[$args['id']][$key])) { |
|
555 | 555 | $enabled = $option; |
556 | 556 | } else { |
557 | 557 | $enabled = NULL; |
@@ -559,67 +559,67 @@ discard block |
||
559 | 559 | |
560 | 560 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
561 | 561 | |
562 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
562 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
563 | 563 | |
564 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
565 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
564 | + if (wpinv_string_is_image_url($key)) { |
|
565 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
566 | 566 | } else { |
567 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
567 | + $card = strtolower(str_replace(' ', '', $option)); |
|
568 | 568 | |
569 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
570 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
569 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
570 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
571 | 571 | } else { |
572 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
572 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
573 | 573 | $content_dir = WP_CONTENT_DIR; |
574 | 574 | |
575 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
575 | + if (function_exists('wp_normalize_path')) { |
|
576 | 576 | // Replaces backslashes with forward slashes for Windows systems |
577 | - $image = wp_normalize_path( $image ); |
|
578 | - $content_dir = wp_normalize_path( $content_dir ); |
|
577 | + $image = wp_normalize_path($image); |
|
578 | + $content_dir = wp_normalize_path($content_dir); |
|
579 | 579 | } |
580 | 580 | |
581 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
581 | + $image = str_replace($content_dir, content_url(), $image); |
|
582 | 582 | } |
583 | 583 | |
584 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
584 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
585 | 585 | } |
586 | 586 | echo $option . '</label>'; |
587 | 587 | } |
588 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
588 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
593 | 593 | * Displays a radio settings field. |
594 | 594 | */ |
595 | -function wpinv_radio_callback( $args ) { |
|
595 | +function wpinv_radio_callback($args) { |
|
596 | 596 | |
597 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
598 | - $std = wpinv_get_option( $args['id'], $std ); |
|
597 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
598 | + $std = wpinv_get_option($args['id'], $std); |
|
599 | 599 | ?> |
600 | 600 | <fieldset> |
601 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
602 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
601 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
602 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
603 | 603 | <li> |
604 | 604 | <label> |
605 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
606 | - <?php echo wp_kses_post( $option ); ?> |
|
605 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
606 | + <?php echo wp_kses_post($option); ?> |
|
607 | 607 | </label> |
608 | 608 | </li> |
609 | 609 | <?php endforeach; ?> |
610 | 610 | </ul> |
611 | 611 | </fieldset> |
612 | 612 | <?php |
613 | - getpaid_settings_description_callback( $args ); |
|
613 | + getpaid_settings_description_callback($args); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Displays a description if available. |
618 | 618 | */ |
619 | -function getpaid_settings_description_callback( $args ) { |
|
619 | +function getpaid_settings_description_callback($args) { |
|
620 | 620 | |
621 | - if ( ! empty( $args['desc'] ) ) { |
|
622 | - $description = wp_kses_post( $args['desc'] ); |
|
621 | + if (!empty($args['desc'])) { |
|
622 | + $description = wp_kses_post($args['desc']); |
|
623 | 623 | echo "<p class='description'>$description</p>"; |
624 | 624 | } |
625 | 625 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | </tr> |
636 | 636 | <tr class="bsui"> |
637 | 637 | <td colspan="2" class="p-0"> |
638 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
638 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
639 | 639 | |
640 | 640 | <?php |
641 | 641 | } |
@@ -643,22 +643,22 @@ discard block |
||
643 | 643 | function wpinv_gateway_select_callback($args) { |
644 | 644 | global $wpinv_options; |
645 | 645 | |
646 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
647 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
646 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
647 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
648 | 648 | |
649 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
649 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
650 | 650 | |
651 | - foreach ( $args['options'] as $key => $option ) : |
|
652 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
653 | - $selected = selected( $key, $args['selected'], false ); |
|
651 | + foreach ($args['options'] as $key => $option) : |
|
652 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
653 | + $selected = selected($key, $args['selected'], false); |
|
654 | 654 | } else { |
655 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
|
655 | + $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : ''; |
|
656 | 656 | } |
657 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
657 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
658 | 658 | endforeach; |
659 | 659 | |
660 | 660 | echo '</select>'; |
661 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
661 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | /** |
@@ -667,28 +667,28 @@ discard block |
||
667 | 667 | * @param array $args |
668 | 668 | * @return string |
669 | 669 | */ |
670 | -function wpinv_settings_attrs_helper( $args ) { |
|
670 | +function wpinv_settings_attrs_helper($args) { |
|
671 | 671 | |
672 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
673 | - $id = esc_attr( $args['id'] ); |
|
674 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
672 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
673 | + $id = esc_attr($args['id']); |
|
674 | + $placeholder = esc_attr($args['placeholder']); |
|
675 | 675 | |
676 | - if ( ! empty( $args['faux'] ) ) { |
|
676 | + if (!empty($args['faux'])) { |
|
677 | 677 | $args['readonly'] = true; |
678 | 678 | $name = ''; |
679 | 679 | } else { |
680 | - $value = wpinv_get_option( $args['id'], $value ); |
|
680 | + $value = wpinv_get_option($args['id'], $value); |
|
681 | 681 | $name = "wpinv_settings[$id]"; |
682 | 682 | } |
683 | 683 | |
684 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
685 | - $class = esc_attr( $args['class'] ); |
|
686 | - $style = esc_attr( $args['style'] ); |
|
687 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
684 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
685 | + $class = esc_attr($args['class']); |
|
686 | + $style = esc_attr($args['style']); |
|
687 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
688 | 688 | |
689 | 689 | $onchange = ''; |
690 | - if ( ! empty( $args['onchange'] ) ) { |
|
691 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
690 | + if (!empty($args['onchange'])) { |
|
691 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -697,11 +697,11 @@ discard block |
||
697 | 697 | /** |
698 | 698 | * Displays a text input settings callback. |
699 | 699 | */ |
700 | -function wpinv_text_callback( $args ) { |
|
700 | +function wpinv_text_callback($args) { |
|
701 | 701 | |
702 | - $desc = wp_kses_post( $args['desc'] ); |
|
703 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
704 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
702 | + $desc = wp_kses_post($args['desc']); |
|
703 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
704 | + $attr = wpinv_settings_attrs_helper($args); |
|
705 | 705 | |
706 | 706 | ?> |
707 | 707 | <label style="width: 100%;"> |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | /** |
716 | 716 | * Displays a number input settings callback. |
717 | 717 | */ |
718 | -function wpinv_number_callback( $args ) { |
|
718 | +function wpinv_number_callback($args) { |
|
719 | 719 | |
720 | - $desc = wp_kses_post( $args['desc'] ); |
|
721 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
722 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
723 | - $max = intval( $args['max'] ); |
|
724 | - $min = intval( $args['min'] ); |
|
725 | - $step = floatval( $args['step'] ); |
|
720 | + $desc = wp_kses_post($args['desc']); |
|
721 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
722 | + $attr = wpinv_settings_attrs_helper($args); |
|
723 | + $max = intval($args['max']); |
|
724 | + $min = intval($args['min']); |
|
725 | + $step = floatval($args['step']); |
|
726 | 726 | |
727 | 727 | ?> |
728 | 728 | <label style="width: 100%;"> |
@@ -733,47 +733,47 @@ discard block |
||
733 | 733 | |
734 | 734 | } |
735 | 735 | |
736 | -function wpinv_textarea_callback( $args ) { |
|
736 | +function wpinv_textarea_callback($args) { |
|
737 | 737 | global $wpinv_options; |
738 | 738 | |
739 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
739 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
740 | 740 | |
741 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
742 | - $value = $wpinv_options[ $args['id'] ]; |
|
741 | + if (isset($wpinv_options[$args['id']])) { |
|
742 | + $value = $wpinv_options[$args['id']]; |
|
743 | 743 | } else { |
744 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
744 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
745 | 745 | } |
746 | 746 | |
747 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
748 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
747 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
748 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
749 | 749 | |
750 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
751 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
750 | + $html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
751 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | |
753 | 753 | echo $html; |
754 | 754 | } |
755 | 755 | |
756 | -function wpinv_password_callback( $args ) { |
|
756 | +function wpinv_password_callback($args) { |
|
757 | 757 | global $wpinv_options; |
758 | 758 | |
759 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
759 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
760 | 760 | |
761 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
762 | - $value = $wpinv_options[ $args['id'] ]; |
|
761 | + if (isset($wpinv_options[$args['id']])) { |
|
762 | + $value = $wpinv_options[$args['id']]; |
|
763 | 763 | } else { |
764 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
764 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
765 | 765 | } |
766 | 766 | |
767 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
768 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
769 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
767 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
768 | + $html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
769 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
770 | 770 | |
771 | 771 | echo $html; |
772 | 772 | } |
773 | 773 | |
774 | 774 | function wpinv_missing_callback($args) { |
775 | 775 | printf( |
776 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
776 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
777 | 777 | '<strong>' . $args['id'] . '</strong>' |
778 | 778 | ); |
779 | 779 | } |
@@ -781,20 +781,20 @@ discard block |
||
781 | 781 | /** |
782 | 782 | * Displays a number input settings callback. |
783 | 783 | */ |
784 | -function wpinv_select_callback( $args ) { |
|
784 | +function wpinv_select_callback($args) { |
|
785 | 785 | |
786 | - $desc = wp_kses_post( $args['desc'] ); |
|
787 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
788 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
789 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
790 | - $value = wpinv_get_option( $args['id'], $value ); |
|
786 | + $desc = wp_kses_post($args['desc']); |
|
787 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
788 | + $attr = wpinv_settings_attrs_helper($args); |
|
789 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
790 | + $value = wpinv_get_option($args['id'], $value); |
|
791 | 791 | |
792 | 792 | ?> |
793 | 793 | <label style="width: 100%;"> |
794 | 794 | <select <?php echo $attr; ?>> |
795 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
796 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
797 | - <?php endforeach;?> |
|
795 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
796 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
797 | + <?php endforeach; ?> |
|
798 | 798 | </select> |
799 | 799 | <?php echo $desc; ?> |
800 | 800 | </label> |
@@ -802,95 +802,95 @@ discard block |
||
802 | 802 | |
803 | 803 | } |
804 | 804 | |
805 | -function wpinv_color_select_callback( $args ) { |
|
805 | +function wpinv_color_select_callback($args) { |
|
806 | 806 | global $wpinv_options; |
807 | 807 | |
808 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
808 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
809 | 809 | |
810 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
811 | - $value = $wpinv_options[ $args['id'] ]; |
|
810 | + if (isset($wpinv_options[$args['id']])) { |
|
811 | + $value = $wpinv_options[$args['id']]; |
|
812 | 812 | } else { |
813 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
813 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
814 | 814 | } |
815 | 815 | |
816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
817 | 817 | |
818 | - foreach ( $args['options'] as $option => $color ) { |
|
819 | - $selected = selected( $option, $value, false ); |
|
820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
818 | + foreach ($args['options'] as $option => $color) { |
|
819 | + $selected = selected($option, $value, false); |
|
820 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>'; |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | $html .= '</select>'; |
824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
825 | 825 | |
826 | 826 | echo $html; |
827 | 827 | } |
828 | 828 | |
829 | -function wpinv_rich_editor_callback( $args ) { |
|
829 | +function wpinv_rich_editor_callback($args) { |
|
830 | 830 | global $wpinv_options, $wp_version; |
831 | 831 | |
832 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
832 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
833 | 833 | |
834 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
835 | - $value = $wpinv_options[ $args['id'] ]; |
|
834 | + if (isset($wpinv_options[$args['id']])) { |
|
835 | + $value = $wpinv_options[$args['id']]; |
|
836 | 836 | |
837 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
837 | + if (empty($args['allow_blank']) && empty($value)) { |
|
838 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
839 | 839 | } |
840 | 840 | } else { |
841 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
841 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
842 | 842 | } |
843 | 843 | |
844 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
844 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
845 | 845 | |
846 | 846 | $html = '<div class="getpaid-settings-editor-input">'; |
847 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
847 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
848 | 848 | ob_start(); |
849 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
849 | + wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false)); |
|
850 | 850 | $html .= ob_get_clean(); |
851 | 851 | } else { |
852 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
852 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
853 | 853 | } |
854 | 854 | |
855 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
855 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
856 | 856 | |
857 | 857 | echo $html; |
858 | 858 | } |
859 | 859 | |
860 | -function wpinv_upload_callback( $args ) { |
|
860 | +function wpinv_upload_callback($args) { |
|
861 | 861 | global $wpinv_options; |
862 | 862 | |
863 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
863 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
864 | 864 | |
865 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
865 | + if (isset($wpinv_options[$args['id']])) { |
|
866 | 866 | $value = $wpinv_options[$args['id']]; |
867 | 867 | } else { |
868 | 868 | $value = isset($args['std']) ? $args['std'] : ''; |
869 | 869 | } |
870 | 870 | |
871 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
872 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
873 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
874 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
871 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
872 | + $html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
873 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
874 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
875 | 875 | |
876 | 876 | echo $html; |
877 | 877 | } |
878 | 878 | |
879 | -function wpinv_color_callback( $args ) { |
|
879 | +function wpinv_color_callback($args) { |
|
880 | 880 | global $wpinv_options; |
881 | 881 | |
882 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
882 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
883 | 883 | |
884 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
885 | - $value = $wpinv_options[ $args['id'] ]; |
|
884 | + if (isset($wpinv_options[$args['id']])) { |
|
885 | + $value = $wpinv_options[$args['id']]; |
|
886 | 886 | } else { |
887 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
887 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
888 | 888 | } |
889 | 889 | |
890 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
890 | + $default = isset($args['std']) ? $args['std'] : ''; |
|
891 | 891 | |
892 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
893 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
892 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />'; |
|
893 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
894 | 894 | |
895 | 895 | echo $html; |
896 | 896 | } |
@@ -898,9 +898,9 @@ discard block |
||
898 | 898 | function wpinv_country_states_callback($args) { |
899 | 899 | global $wpinv_options; |
900 | 900 | |
901 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
901 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
902 | 902 | |
903 | - if ( isset( $args['placeholder'] ) ) { |
|
903 | + if (isset($args['placeholder'])) { |
|
904 | 904 | $placeholder = $args['placeholder']; |
905 | 905 | } else { |
906 | 906 | $placeholder = ''; |
@@ -908,16 +908,16 @@ discard block |
||
908 | 908 | |
909 | 909 | $states = wpinv_get_country_states(); |
910 | 910 | |
911 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
911 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
912 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
913 | 913 | |
914 | - foreach ( $states as $option => $name ) { |
|
915 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
916 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
914 | + foreach ($states as $option => $name) { |
|
915 | + $selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : ''; |
|
916 | + $html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>'; |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | $html .= '</select>'; |
920 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
920 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
921 | 921 | |
922 | 922 | echo $html; |
923 | 923 | } |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | </tr> |
933 | 933 | <tr class="bsui"> |
934 | 934 | <td colspan="2" class="p-0"> |
935 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
935 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
936 | 936 | |
937 | 937 | <?php |
938 | 938 | |
@@ -941,14 +941,14 @@ discard block |
||
941 | 941 | /** |
942 | 942 | * Displays a tax rate' edit row. |
943 | 943 | */ |
944 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
944 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
945 | 945 | ob_start(); |
946 | 946 | |
947 | - $key = sanitize_key( $key ); |
|
948 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
949 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
947 | + $key = sanitize_key($key); |
|
948 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
949 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
950 | 950 | |
951 | - if ( $echo ) { |
|
951 | + if ($echo) { |
|
952 | 952 | echo ob_get_clean(); |
953 | 953 | } else { |
954 | 954 | return ob_get_clean(); |
@@ -961,134 +961,134 @@ discard block |
||
961 | 961 | ob_start(); ?> |
962 | 962 | </td><tr> |
963 | 963 | <td colspan="2" class="wpinv_tools_tdbox"> |
964 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
965 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
964 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
965 | + <?php do_action('wpinv_tools_before'); ?> |
|
966 | 966 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
967 | 967 | <thead> |
968 | 968 | <tr> |
969 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
970 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
971 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
969 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
970 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
971 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
972 | 972 | </tr> |
973 | 973 | </thead> |
974 | 974 | |
975 | 975 | <tbody> |
976 | 976 | <tr> |
977 | - <td><?php _e( 'Check Pages', 'invoicing' );?></td> |
|
977 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
978 | 978 | <td> |
979 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
979 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
980 | 980 | </td> |
981 | 981 | <td> |
982 | 982 | <a href="<?php |
983 | 983 | echo esc_url( |
984 | 984 | wp_nonce_url( |
985 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
985 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
986 | 986 | 'getpaid-nonce', |
987 | 987 | 'getpaid-nonce' |
988 | 988 | ) |
989 | 989 | ); |
990 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
990 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
991 | 991 | </td> |
992 | 992 | </tr> |
993 | 993 | <tr> |
994 | - <td><?php _e( 'Create Database Tables', 'invoicing' );?></td> |
|
994 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
995 | 995 | <td> |
996 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
996 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
997 | 997 | </td> |
998 | 998 | <td> |
999 | 999 | <a href="<?php |
1000 | 1000 | echo esc_url( |
1001 | 1001 | wp_nonce_url( |
1002 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1002 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1003 | 1003 | 'getpaid-nonce', |
1004 | 1004 | 'getpaid-nonce' |
1005 | 1005 | ) |
1006 | 1006 | ); |
1007 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1007 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1008 | 1008 | </td> |
1009 | 1009 | </tr> |
1010 | 1010 | <tr> |
1011 | - <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td> |
|
1011 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
1012 | 1012 | <td> |
1013 | - <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1013 | + <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1014 | 1014 | </td> |
1015 | 1015 | <td> |
1016 | 1016 | <a href="<?php |
1017 | 1017 | echo esc_url( |
1018 | 1018 | wp_nonce_url( |
1019 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1019 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1020 | 1020 | 'getpaid-nonce', |
1021 | 1021 | 'getpaid-nonce' |
1022 | 1022 | ) |
1023 | 1023 | ); |
1024 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1024 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1025 | 1025 | </td> |
1026 | 1026 | </tr> |
1027 | 1027 | |
1028 | 1028 | <tr> |
1029 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td> |
|
1029 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1030 | 1030 | <td> |
1031 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1031 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1032 | 1032 | </td> |
1033 | 1033 | <td> |
1034 | 1034 | <a href="<?php |
1035 | 1035 | echo esc_url( |
1036 | 1036 | wp_nonce_url( |
1037 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1037 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1038 | 1038 | 'getpaid-nonce', |
1039 | 1039 | 'getpaid-nonce' |
1040 | 1040 | ) |
1041 | 1041 | ); |
1042 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1042 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
1043 | 1043 | </td> |
1044 | 1044 | </tr> |
1045 | 1045 | |
1046 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1046 | + <?php do_action('wpinv_tools_row'); ?> |
|
1047 | 1047 | </tbody> |
1048 | 1048 | </table> |
1049 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1049 | + <?php do_action('wpinv_tools_after'); ?> |
|
1050 | 1050 | <?php |
1051 | 1051 | echo ob_get_clean(); |
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
1055 | -function wpinv_descriptive_text_callback( $args ) { |
|
1056 | - echo wp_kses_post( $args['desc'] ); |
|
1055 | +function wpinv_descriptive_text_callback($args) { |
|
1056 | + echo wp_kses_post($args['desc']); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | -function wpinv_raw_html_callback( $args ) { |
|
1059 | +function wpinv_raw_html_callback($args) { |
|
1060 | 1060 | echo $args['desc']; |
1061 | 1061 | } |
1062 | 1062 | |
1063 | -function wpinv_hook_callback( $args ) { |
|
1064 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1063 | +function wpinv_hook_callback($args) { |
|
1064 | + do_action('wpinv_' . $args['id'], $args); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | function wpinv_set_settings_cap() { |
1068 | 1068 | return wpinv_get_capability(); |
1069 | 1069 | } |
1070 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1070 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1071 | 1071 | |
1072 | -function wpinv_settings_sanitize_input( $value, $key ) { |
|
1072 | +function wpinv_settings_sanitize_input($value, $key) { |
|
1073 | 1073 | |
1074 | - if ( $key == 'tax_rate' ) { |
|
1075 | - $value = wpinv_sanitize_amount( $value ); |
|
1076 | - $value = absint( min( $value, 99 ) ); |
|
1074 | + if ($key == 'tax_rate') { |
|
1075 | + $value = wpinv_sanitize_amount($value); |
|
1076 | + $value = absint(min($value, 99)); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | 1079 | return $value; |
1080 | 1080 | } |
1081 | -add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 ); |
|
1081 | +add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2); |
|
1082 | 1082 | |
1083 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1084 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1085 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1083 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1084 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1085 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1086 | 1086 | |
1087 | - if ( $old != $new ) { |
|
1088 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1087 | + if ($old != $new) { |
|
1088 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1089 | 1089 | } |
1090 | 1090 | } |
1091 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1091 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1092 | 1092 | |
1093 | 1093 | /** |
1094 | 1094 | * Returns the merge tags help text. |
@@ -1097,16 +1097,16 @@ discard block |
||
1097 | 1097 | * |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1100 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1101 | 1101 | |
1102 | 1102 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
1103 | 1103 | $link = sprintf( |
1104 | 1104 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
1105 | 1105 | $url, |
1106 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1106 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
1107 | 1107 | ); |
1108 | 1108 | |
1109 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1109 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1110 | 1110 | |
1111 | 1111 | return "$description $link"; |
1112 | 1112 |
@@ -8,205 +8,205 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $invoice_number_padd_options = array(); |
23 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
23 | +for ($i = 0; $i <= 20; $i++) { |
|
24 | 24 | $invoice_number_padd_options[$i] = $i; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $currency_symbol = wpinv_currency_symbol(); |
28 | 28 | |
29 | 29 | $last_number = $reset_number = ''; |
30 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
31 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
30 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
31 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
32 | 32 | |
33 | - if ( !empty( $last_invoice_number ) ) { |
|
34 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
33 | + if (!empty($last_invoice_number)) { |
|
34 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $nonce = wp_create_nonce('reset_invoice_count'); |
38 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
38 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $alert_wrapper_start = '<p style="color: #F00">'; |
42 | 42 | $alert_wrapper_close = '</p>'; |
43 | 43 | |
44 | 44 | return array( |
45 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
45 | + 'general' => apply_filters('wpinv_settings_general', |
|
46 | 46 | array( |
47 | 47 | 'main' => array( |
48 | 48 | 'location_settings' => array( |
49 | 49 | 'id' => 'location_settings', |
50 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
50 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
51 | 51 | 'desc' => '', |
52 | 52 | 'type' => 'header', |
53 | 53 | ), |
54 | 54 | 'default_country' => array( |
55 | 55 | 'id' => 'default_country', |
56 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
57 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
56 | + 'name' => __('Default Country', 'invoicing'), |
|
57 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
58 | 58 | 'type' => 'select', |
59 | 59 | 'options' => wpinv_get_country_list(), |
60 | 60 | 'std' => 'GB', |
61 | 61 | 'class' => 'wpi_select2', |
62 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
62 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
63 | 63 | ), |
64 | 64 | 'default_state' => array( |
65 | 65 | 'id' => 'default_state', |
66 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
67 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
66 | + 'name' => __('Default State / Province', 'invoicing'), |
|
67 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
68 | 68 | 'type' => 'country_states', |
69 | 69 | 'class' => 'wpi_select2', |
70 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
70 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
71 | 71 | ), |
72 | 72 | 'store_name' => array( |
73 | 73 | 'id' => 'store_name', |
74 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
75 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
74 | + 'name' => __('Store Name', 'invoicing'), |
|
75 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
76 | 76 | 'std' => get_option('blogname'), |
77 | 77 | 'type' => 'text', |
78 | 78 | ), |
79 | 79 | 'logo' => array( |
80 | 80 | 'id' => 'logo', |
81 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
82 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
81 | + 'name' => __('Logo URL', 'invoicing'), |
|
82 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo_width' => array( |
86 | 86 | 'id' => 'logo_width', |
87 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
88 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
87 | + 'name' => __('Logo width', 'invoicing'), |
|
88 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
89 | 89 | 'type' => 'number', |
90 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
90 | + 'placeholder' => __('Auto', 'invoicing'), |
|
91 | 91 | ), |
92 | 92 | 'logo_height' => array( |
93 | 93 | 'id' => 'logo_height', |
94 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
95 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
94 | + 'name' => __('Logo height', 'invoicing'), |
|
95 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
96 | 96 | 'type' => 'number', |
97 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
97 | + 'placeholder' => __('Auto', 'invoicing'), |
|
98 | 98 | ), |
99 | 99 | 'store_address' => array( |
100 | 100 | 'id' => 'store_address', |
101 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
102 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
101 | + 'name' => __('Store Address', 'invoicing'), |
|
102 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
103 | 103 | 'type' => 'textarea', |
104 | 104 | ), |
105 | 105 | 'page_settings' => array( |
106 | 106 | 'id' => 'page_settings', |
107 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
107 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
108 | 108 | 'desc' => '', |
109 | 109 | 'type' => 'header', |
110 | 110 | ), |
111 | 111 | 'checkout_page' => array( |
112 | 112 | 'id' => 'checkout_page', |
113 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
114 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
113 | + 'name' => __('Checkout Page', 'invoicing'), |
|
114 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
115 | 115 | 'type' => 'select', |
116 | 116 | 'options' => $pages, |
117 | 117 | 'class' => 'wpi_select2', |
118 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
118 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
119 | 119 | 'help-tip' => true, |
120 | 120 | ), |
121 | 121 | 'success_page' => array( |
122 | 122 | 'id' => 'success_page', |
123 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
124 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
123 | + 'name' => __('Success Page', 'invoicing'), |
|
124 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
125 | 125 | 'type' => 'select', |
126 | 126 | 'options' => $pages, |
127 | 127 | 'class' => 'wpi_select2', |
128 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
128 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
129 | 129 | 'help-tip' => true, |
130 | 130 | ), |
131 | 131 | 'failure_page' => array( |
132 | 132 | 'id' => 'failure_page', |
133 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
134 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
133 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
134 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
135 | 135 | 'type' => 'select', |
136 | 136 | 'options' => $pages, |
137 | 137 | 'class' => 'wpi_select2', |
138 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
138 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
139 | 139 | 'help-tip' => true, |
140 | 140 | ), |
141 | 141 | 'invoice_history_page' => array( |
142 | 142 | 'id' => 'invoice_history_page', |
143 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
144 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
143 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
144 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
145 | 145 | 'type' => 'select', |
146 | 146 | 'options' => $pages, |
147 | 147 | 'class' => 'wpi_select2', |
148 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
148 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
149 | 149 | 'help-tip' => true, |
150 | 150 | ), |
151 | 151 | 'invoice_subscription_page' => array( |
152 | 152 | 'id' => 'invoice_subscription_page', |
153 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
154 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
153 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
154 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
155 | 155 | 'type' => 'select', |
156 | 156 | 'options' => $pages, |
157 | 157 | 'class' => 'wpi_select2', |
158 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
158 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
159 | 159 | 'help-tip' => true, |
160 | 160 | ), |
161 | 161 | ), |
162 | 162 | 'currency_section' => array( |
163 | 163 | 'currency_settings' => array( |
164 | 164 | 'id' => 'currency_settings', |
165 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
165 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
166 | 166 | 'desc' => '', |
167 | 167 | 'type' => 'header', |
168 | 168 | ), |
169 | 169 | 'currency' => array( |
170 | 170 | 'id' => 'currency', |
171 | - 'name' => __( 'Currency', 'invoicing' ), |
|
172 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
171 | + 'name' => __('Currency', 'invoicing'), |
|
172 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
173 | 173 | 'type' => 'select', |
174 | 174 | 'class' => 'wpi_select2', |
175 | 175 | 'options' => $currency_code_options, |
176 | 176 | ), |
177 | 177 | 'currency_position' => array( |
178 | 178 | 'id' => 'currency_position', |
179 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
180 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
179 | + 'name' => __('Currency Position', 'invoicing'), |
|
180 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
181 | 181 | 'type' => 'select', |
182 | 182 | 'class' => 'wpi_select2', |
183 | 183 | 'options' => array( |
184 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
185 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
186 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
187 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
184 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
185 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
186 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
187 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
188 | 188 | ) |
189 | 189 | ), |
190 | 190 | 'thousands_separator' => array( |
191 | 191 | 'id' => 'thousands_separator', |
192 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
193 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
192 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
193 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
194 | 194 | 'type' => 'text', |
195 | 195 | 'size' => 'small', |
196 | 196 | 'std' => ',', |
197 | 197 | ), |
198 | 198 | 'decimal_separator' => array( |
199 | 199 | 'id' => 'decimal_separator', |
200 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
201 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
200 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
201 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
202 | 202 | 'type' => 'text', |
203 | 203 | 'size' => 'small', |
204 | 204 | 'std' => '.', |
205 | 205 | ), |
206 | 206 | 'decimals' => array( |
207 | 207 | 'id' => 'decimals', |
208 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
209 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
208 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
209 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
210 | 210 | 'type' => 'number', |
211 | 211 | 'size' => 'small', |
212 | 212 | 'std' => '2', |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | 'labels' => array( |
219 | 219 | 'labels' => array( |
220 | 220 | 'id' => 'labels_settings', |
221 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
221 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
222 | 222 | 'desc' => '', |
223 | 223 | 'type' => 'header', |
224 | 224 | ), |
225 | 225 | 'vat_invoice_notice_label' => array( |
226 | 226 | 'id' => 'vat_invoice_notice_label', |
227 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
228 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
227 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
228 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
229 | 229 | 'type' => 'text', |
230 | 230 | 'size' => 'regular', |
231 | 231 | ), |
232 | 232 | 'vat_invoice_notice' => array( |
233 | 233 | 'id' => 'vat_invoice_notice', |
234 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
235 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
234 | + 'name' => __('Invoice notice', 'invoicing'), |
|
235 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
236 | 236 | 'type' => 'text', |
237 | 237 | 'size' => 'regular', |
238 | 238 | ), |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | 'main' => array( |
245 | 245 | 'gateway_settings' => array( |
246 | 246 | 'id' => 'api_header', |
247 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
247 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
248 | 248 | 'desc' => '', |
249 | 249 | 'type' => 'header', |
250 | 250 | ), |
251 | 251 | 'gateways' => array( |
252 | 252 | 'id' => 'gateways', |
253 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
254 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
253 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
254 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
255 | 255 | 'type' => 'gateways', |
256 | - 'std' => array( 'manual'=>1 ), |
|
256 | + 'std' => array('manual'=>1), |
|
257 | 257 | 'options' => wpinv_get_payment_gateways(), |
258 | 258 | ), |
259 | 259 | 'default_gateway' => array( |
260 | 260 | 'id' => 'default_gateway', |
261 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
262 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
261 | + 'name' => __('Default Gateway', 'invoicing'), |
|
262 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
263 | 263 | 'type' => 'gateway_select', |
264 | 264 | 'std' => 'manual', |
265 | 265 | 'class' => 'wpi_select2', |
@@ -274,32 +274,32 @@ discard block |
||
274 | 274 | 'main' => array( |
275 | 275 | 'tax_settings' => array( |
276 | 276 | 'id' => 'tax_settings', |
277 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
277 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
278 | 278 | 'type' => 'header', |
279 | 279 | ), |
280 | 280 | |
281 | 281 | 'enable_taxes' => array( |
282 | 282 | 'id' => 'enable_taxes', |
283 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
284 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
283 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
284 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
285 | 285 | 'type' => 'checkbox', |
286 | 286 | 'std' => 0, |
287 | 287 | ), |
288 | 288 | |
289 | 289 | 'tax_subtotal_rounding' => array( |
290 | 290 | 'id' => 'tax_subtotal_rounding', |
291 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
292 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
291 | + 'name' => __('Rounding', 'invoicing'), |
|
292 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
293 | 293 | 'type' => 'checkbox', |
294 | 294 | 'std' => 1, |
295 | 295 | ), |
296 | 296 | |
297 | 297 | 'prices_include_tax' => array( |
298 | 298 | 'id' => 'prices_include_tax', |
299 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
299 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
300 | 300 | 'options' => array( |
301 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
302 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
301 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
302 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
303 | 303 | ), |
304 | 304 | 'type' => 'select', |
305 | 305 | 'std' => 'no', |
@@ -307,10 +307,10 @@ discard block |
||
307 | 307 | |
308 | 308 | 'tax_base' => array( |
309 | 309 | 'id' => 'tax_base', |
310 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
310 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
311 | 311 | 'options' => array( |
312 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
313 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
312 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
313 | + 'base' => __('Shop base address', 'invoicing'), |
|
314 | 314 | ), |
315 | 315 | 'type' => 'select', |
316 | 316 | 'std' => 'billing', |
@@ -318,10 +318,10 @@ discard block |
||
318 | 318 | |
319 | 319 | 'tax_display_totals' => array( |
320 | 320 | 'id' => 'tax_display_totals', |
321 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
321 | + 'name' => __('Display tax totals', 'invoicing'), |
|
322 | 322 | 'options' => array( |
323 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
324 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
323 | + 'single' => __('As a single total', 'invoicing'), |
|
324 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
325 | 325 | ), |
326 | 326 | 'type' => 'select', |
327 | 327 | 'std' => 'individual', |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | |
330 | 330 | 'tax_rate' => array( |
331 | 331 | 'id' => 'tax_rate', |
332 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
333 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
332 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
333 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
334 | 334 | 'type' => 'number', |
335 | 335 | 'size' => 'small', |
336 | 336 | 'min' => '0', |
@@ -342,8 +342,8 @@ discard block |
||
342 | 342 | 'rates' => array( |
343 | 343 | 'tax_rates' => array( |
344 | 344 | 'id' => 'tax_rates', |
345 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
346 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
345 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
346 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
347 | 347 | 'type' => 'tax_rates', |
348 | 348 | ), |
349 | 349 | ), |
@@ -352,45 +352,45 @@ discard block |
||
352 | 352 | |
353 | 353 | 'vat_company_name' => array( |
354 | 354 | 'id' => 'vat_company_name', |
355 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
356 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
355 | + 'name' => __('Company Name', 'invoicing'), |
|
356 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
357 | 357 | 'type' => 'text', |
358 | 358 | 'size' => 'regular', |
359 | 359 | ), |
360 | 360 | |
361 | 361 | 'vat_number' => array( |
362 | 362 | 'id' => 'vat_number', |
363 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
364 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
363 | + 'name' => __('VAT Number', 'invoicing'), |
|
364 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
365 | 365 | 'type' => 'text', |
366 | 366 | 'size' => 'regular', |
367 | 367 | ), |
368 | 368 | |
369 | 369 | 'vat_prevent_b2c_purchase' => array( |
370 | 370 | 'id' => 'vat_prevent_b2c_purchase', |
371 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
372 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
371 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
372 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
373 | 373 | 'type' => 'checkbox' |
374 | 374 | ), |
375 | 375 | |
376 | 376 | 'validate_vat_number' => array( |
377 | 377 | 'id' => 'validate_vat_number', |
378 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
379 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
378 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
379 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
380 | 380 | 'type' => 'checkbox' |
381 | 381 | ), |
382 | 382 | |
383 | 383 | 'vat_same_country_rule' => array( |
384 | 384 | 'id' => 'vat_same_country_rule', |
385 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
386 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
385 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
386 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
387 | 387 | 'type' => 'select', |
388 | 388 | 'options' => array( |
389 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
390 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
391 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
389 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
390 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
391 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
392 | 392 | ), |
393 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
393 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
394 | 394 | 'std' => 'vat_too', |
395 | 395 | ), |
396 | 396 | |
@@ -404,59 +404,59 @@ discard block |
||
404 | 404 | 'main' => array( |
405 | 405 | 'email_settings_header' => array( |
406 | 406 | 'id' => 'email_settings_header', |
407 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
407 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
408 | 408 | 'type' => 'header', |
409 | 409 | ), |
410 | 410 | 'email_from_name' => array( |
411 | 411 | 'id' => 'email_from_name', |
412 | - 'name' => __( 'From Name', 'invoicing' ), |
|
413 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
414 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
412 | + 'name' => __('From Name', 'invoicing'), |
|
413 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
414 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
415 | 415 | 'type' => 'text', |
416 | 416 | ), |
417 | 417 | 'email_from' => array( |
418 | 418 | 'id' => 'email_from', |
419 | - 'name' => __( 'From Email', 'invoicing' ), |
|
420 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
421 | - 'std' => get_option( 'admin_email' ), |
|
419 | + 'name' => __('From Email', 'invoicing'), |
|
420 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
421 | + 'std' => get_option('admin_email'), |
|
422 | 422 | 'type' => 'text', |
423 | 423 | ), |
424 | 424 | 'admin_email' => array( |
425 | 425 | 'id' => 'admin_email', |
426 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
427 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
428 | - 'std' => get_option( 'admin_email' ), |
|
426 | + 'name' => __('Admin Email', 'invoicing'), |
|
427 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
428 | + 'std' => get_option('admin_email'), |
|
429 | 429 | 'type' => 'text', |
430 | 430 | ), |
431 | 431 | 'overdue_settings_header' => array( |
432 | 432 | 'id' => 'overdue_settings_header', |
433 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
433 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
434 | 434 | 'type' => 'header', |
435 | 435 | ), |
436 | 436 | 'overdue_active' => array( |
437 | 437 | 'id' => 'overdue_active', |
438 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
439 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
438 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
439 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
440 | 440 | 'type' => 'checkbox', |
441 | 441 | 'std' => false, |
442 | 442 | ), |
443 | 443 | 'email_template_header' => array( |
444 | 444 | 'id' => 'email_template_header', |
445 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
445 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
446 | 446 | 'type' => 'header', |
447 | 447 | ), |
448 | 448 | 'email_header_image' => array( |
449 | 449 | 'id' => 'email_header_image', |
450 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
451 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
450 | + 'name' => __('Header Image', 'invoicing'), |
|
451 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
452 | 452 | 'std' => '', |
453 | 453 | 'type' => 'text', |
454 | 454 | ), |
455 | 455 | 'email_footer_text' => array( |
456 | 456 | 'id' => 'email_footer_text', |
457 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
458 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
459 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
457 | + 'name' => __('Footer Text', 'invoicing'), |
|
458 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
459 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
460 | 460 | 'type' => 'textarea', |
461 | 461 | 'class' => 'regular-text', |
462 | 462 | 'rows' => 2, |
@@ -464,29 +464,29 @@ discard block |
||
464 | 464 | ), |
465 | 465 | 'email_base_color' => array( |
466 | 466 | 'id' => 'email_base_color', |
467 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
468 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
467 | + 'name' => __('Base Color', 'invoicing'), |
|
468 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
469 | 469 | 'std' => '#557da2', |
470 | 470 | 'type' => 'color', |
471 | 471 | ), |
472 | 472 | 'email_background_color' => array( |
473 | 473 | 'id' => 'email_background_color', |
474 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
475 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
474 | + 'name' => __('Background Color', 'invoicing'), |
|
475 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
476 | 476 | 'std' => '#f5f5f5', |
477 | 477 | 'type' => 'color', |
478 | 478 | ), |
479 | 479 | 'email_body_background_color' => array( |
480 | 480 | 'id' => 'email_body_background_color', |
481 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
482 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
481 | + 'name' => __('Body Background Color', 'invoicing'), |
|
482 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
483 | 483 | 'std' => '#fdfdfd', |
484 | 484 | 'type' => 'color', |
485 | 485 | ), |
486 | 486 | 'email_text_color' => array( |
487 | 487 | 'id' => 'email_text_color', |
488 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
489 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
488 | + 'name' => __('Body Text Color', 'invoicing'), |
|
489 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
490 | 490 | 'std' => '#505050', |
491 | 491 | 'type' => 'color', |
492 | 492 | ), |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | ), |
502 | 502 | |
503 | 503 | // Integrations. |
504 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
504 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
505 | 505 | |
506 | 506 | /** Privacy Settings */ |
507 | 507 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -509,17 +509,17 @@ discard block |
||
509 | 509 | 'main' => array( |
510 | 510 | 'invoicing_privacy_policy_settings' => array( |
511 | 511 | 'id' => 'invoicing_privacy_policy_settings', |
512 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
512 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
513 | 513 | 'type' => 'header', |
514 | 514 | ), |
515 | 515 | 'privacy_page' => array( |
516 | 516 | 'id' => 'privacy_page', |
517 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
518 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
517 | + 'name' => __('Privacy Page', 'invoicing'), |
|
518 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
519 | 519 | 'type' => 'select', |
520 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
520 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
521 | 521 | 'class' => 'wpi_select2', |
522 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
522 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
523 | 523 | ), |
524 | 524 | ), |
525 | 525 | ) |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | 'main' => array( |
531 | 531 | 'invoice_number_format_settings' => array( |
532 | 532 | 'id' => 'invoice_number_format_settings', |
533 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
533 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
534 | 534 | 'type' => 'header', |
535 | 535 | ), |
536 | 536 | 'sequential_invoice_number' => array( |
537 | 537 | 'id' => 'sequential_invoice_number', |
538 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
539 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
538 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
539 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
540 | 540 | 'type' => 'checkbox', |
541 | 541 | ), |
542 | 542 | 'invoice_sequence_start' => array( |
543 | 543 | 'id' => 'invoice_sequence_start', |
544 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
545 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
544 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
545 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
546 | 546 | 'type' => 'number', |
547 | 547 | 'size' => 'small', |
548 | 548 | 'std' => '1', |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | ), |
551 | 551 | 'invoice_number_padd' => array( |
552 | 552 | 'id' => 'invoice_number_padd', |
553 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
554 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
553 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
554 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
555 | 555 | 'type' => 'select', |
556 | 556 | 'options' => $invoice_number_padd_options, |
557 | 557 | 'std' => 5, |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | ), |
560 | 560 | 'invoice_number_prefix' => array( |
561 | 561 | 'id' => 'invoice_number_prefix', |
562 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
563 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
562 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
563 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
564 | 564 | 'type' => 'text', |
565 | 565 | 'size' => 'regular', |
566 | 566 | 'std' => 'INV-', |
@@ -568,41 +568,41 @@ discard block |
||
568 | 568 | ), |
569 | 569 | 'invoice_number_postfix' => array( |
570 | 570 | 'id' => 'invoice_number_postfix', |
571 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
572 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
571 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
572 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
573 | 573 | 'type' => 'text', |
574 | 574 | 'size' => 'regular', |
575 | 575 | 'std' => '' |
576 | 576 | ), |
577 | 577 | 'checkout_settings' => array( |
578 | 578 | 'id' => 'checkout_settings', |
579 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
579 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
580 | 580 | 'type' => 'header', |
581 | 581 | ), |
582 | 582 | 'login_to_checkout' => array( |
583 | 583 | 'id' => 'login_to_checkout', |
584 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
585 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
584 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
585 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
586 | 586 | 'type' => 'checkbox', |
587 | 587 | ), |
588 | 588 | |
589 | 589 | 'maxmind_license_key' => array( |
590 | 590 | 'id' => 'maxmind_license_key', |
591 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
591 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
592 | 592 | 'type' => 'text', |
593 | 593 | 'size' => 'regular', |
594 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
594 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
595 | 595 | ), |
596 | 596 | |
597 | 597 | 'uninstall_settings' => array( |
598 | 598 | 'id' => 'uninstall_settings', |
599 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
599 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
600 | 600 | 'type' => 'header', |
601 | 601 | ), |
602 | 602 | 'remove_data_on_unistall' => array( |
603 | 603 | 'id' => 'remove_data_on_unistall', |
604 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
605 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
604 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
605 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
606 | 606 | 'type' => 'checkbox', |
607 | 607 | 'std' => '' |
608 | 608 | ), |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | 'custom-css' => array( |
612 | 612 | 'css_settings' => array( |
613 | 613 | 'id' => 'css_settings', |
614 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
614 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
615 | 615 | 'type' => 'header', |
616 | 616 | ), |
617 | 617 | 'template_custom_css' => array( |
618 | 618 | 'id' => 'template_custom_css', |
619 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
620 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
619 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
620 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
621 | 621 | 'type' => 'textarea', |
622 | 622 | 'class'=> 'regular-text', |
623 | 623 | 'rows' => 10, |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | 'main' => array( |
632 | 632 | 'tool_settings' => array( |
633 | 633 | 'id' => 'tool_settings', |
634 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
635 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
634 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
635 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
636 | 636 | 'type' => 'tools', |
637 | 637 | ), |
638 | 638 | ), |
@@ -7,24 +7,24 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$logo_width = wpinv_get_option( 'logo_width' ); |
|
13 | -$logo_height = wpinv_get_option( 'logo_height' ); |
|
12 | +$logo_width = wpinv_get_option('logo_width'); |
|
13 | +$logo_height = wpinv_get_option('logo_height'); |
|
14 | 14 | |
15 | 15 | ?> |
16 | -<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
16 | +<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
17 | 17 | |
18 | - <?php if ( $logo = wpinv_get_business_logo() ) : ?> |
|
18 | + <?php if ($logo = wpinv_get_business_logo()) : ?> |
|
19 | 19 | |
20 | - <?php if ( ! empty( $logo_width ) && ! empty( $logo_height ) ) : ?> |
|
21 | - <img class="logo" style="max-width:100%; width:<?php echo absint( $logo_width ); ?>px; height:<?php echo absint( $logo_height ); ?>px;" src="<?php echo esc_url( $logo ); ?>"> |
|
20 | + <?php if (!empty($logo_width) && !empty($logo_height)) : ?> |
|
21 | + <img class="logo" style="max-width:100%; width:<?php echo absint($logo_width); ?>px; height:<?php echo absint($logo_height); ?>px;" src="<?php echo esc_url($logo); ?>"> |
|
22 | 22 | <?php else: ?> |
23 | - <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <img class="logo" style="max-width:100%;" src="<?php echo esc_url($logo); ?>"> |
|
24 | 24 | <?php endif; ?> |
25 | 25 | |
26 | 26 | <?php else: ?> |
27 | - <h1 class="h3"><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1 class="h3"><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php endif; ?> |
29 | 29 | |
30 | 30 | </a> |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Returns an array of eu states. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | */ |
14 | 14 | function getpaid_get_eu_states() { |
15 | - return wpinv_get_data( 'eu-states' ); |
|
15 | + return wpinv_get_data('eu-states'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | -function getpaid_is_eu_state( $country ) { |
|
24 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false; |
|
23 | +function getpaid_is_eu_state($country) { |
|
24 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @return array |
31 | 31 | */ |
32 | 32 | function getpaid_get_gst_states() { |
33 | - return array( 'AU', 'NZ', 'CA', 'CN' ); |
|
33 | + return array('AU', 'NZ', 'CA', 'CN'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return bool |
40 | 40 | */ |
41 | -function getpaid_is_gst_country( $country ) { |
|
42 | - return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false; |
|
41 | +function getpaid_is_gst_country($country) { |
|
42 | + return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function wpinv_use_taxes() { |
51 | 51 | |
52 | - $ret = wpinv_get_option( 'enable_taxes', false ); |
|
53 | - return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) ); |
|
52 | + $ret = wpinv_get_option('enable_taxes', false); |
|
53 | + return (bool) apply_filters('wpinv_use_taxes', !empty($ret)); |
|
54 | 54 | |
55 | 55 | } |
56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param WPInv_Invoice $invoice |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | -function wpinv_is_invoice_taxable( $invoice ) { |
|
63 | +function wpinv_is_invoice_taxable($invoice) { |
|
64 | 64 | return $invoice->is_taxable(); |
65 | 65 | } |
66 | 66 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @param string $country |
71 | 71 | * @return bool |
72 | 72 | */ |
73 | -function wpinv_is_country_taxable( $country ) { |
|
74 | - $is_eu = getpaid_is_eu_state( $country ); |
|
75 | - $is_exempt = ! $is_eu && wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat(); |
|
73 | +function wpinv_is_country_taxable($country) { |
|
74 | + $is_eu = getpaid_is_eu_state($country); |
|
75 | + $is_exempt = !$is_eu && wpinv_is_base_country($country) && wpinv_same_country_exempt_vat(); |
|
76 | 76 | |
77 | - return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); |
|
77 | + return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param WPInv_Item|GetPaid_Form_Item $item |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | -function wpinv_is_item_taxable( $item ) { |
|
87 | +function wpinv_is_item_taxable($item) { |
|
88 | 88 | return '_exempt' != $item->get_vat_rule(); |
89 | 89 | } |
90 | 90 | |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @return bool |
95 | 95 | */ |
96 | 96 | function wpinv_use_store_address_as_tax_base() { |
97 | - $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base'; |
|
98 | - return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base ); |
|
97 | + $use_base = wpinv_get_option('tax_base', 'billing') == 'base'; |
|
98 | + return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function wpinv_prices_include_tax() { |
107 | - $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes'; |
|
108 | - return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive ); |
|
107 | + $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes'; |
|
108 | + return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | * @return bool |
115 | 115 | */ |
116 | 116 | function wpinv_round_tax_per_tax_rate() { |
117 | - $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 ); |
|
118 | - return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) ); |
|
117 | + $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1); |
|
118 | + return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding)); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @return bool |
125 | 125 | */ |
126 | 126 | function wpinv_display_individual_tax_rates() { |
127 | - $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual'; |
|
128 | - return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual ); |
|
127 | + $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual'; |
|
128 | + return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @return float |
135 | 135 | */ |
136 | 136 | function wpinv_get_default_tax_rate() { |
137 | - $rate = wpinv_get_option( 'tax_rate', 0 ); |
|
138 | - return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) ); |
|
137 | + $rate = wpinv_get_option('tax_rate', 0); |
|
138 | + return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate)); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | function wpinv_same_country_exempt_vat() { |
147 | - return 'no' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ); |
|
147 | + return 'no' == wpinv_get_option('vat_same_country_rule', 'vat_too'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -164,28 +164,28 @@ discard block |
||
164 | 164 | * @param string $state |
165 | 165 | * @return array |
166 | 166 | */ |
167 | -function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) { |
|
167 | +function getpaid_get_item_tax_rates($item, $country = '', $state = '') { |
|
168 | 168 | |
169 | 169 | // Abort if the item is not taxable. |
170 | - if ( ! wpinv_is_item_taxable( $item ) ) { |
|
170 | + if (!wpinv_is_item_taxable($item)) { |
|
171 | 171 | return array(); |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Maybe use the store address. |
175 | - if ( wpinv_use_store_address_as_tax_base() ) { |
|
175 | + if (wpinv_use_store_address_as_tax_base()) { |
|
176 | 176 | $country = wpinv_get_default_country(); |
177 | 177 | $state = wpinv_get_default_state(); |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Retrieve tax rates. |
181 | - $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state ); |
|
181 | + $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state); |
|
182 | 182 | |
183 | 183 | // Fallback to the default tax rates if non were found. |
184 | - if ( empty( $tax_rates ) ) { |
|
184 | + if (empty($tax_rates)) { |
|
185 | 185 | $tax_rates = GetPaid_Tax::get_default_tax_rates(); |
186 | 186 | } |
187 | 187 | |
188 | - return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state ); |
|
188 | + return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,23 +195,23 @@ discard block |
||
195 | 195 | * @param array $rates |
196 | 196 | * @return array |
197 | 197 | */ |
198 | -function getpaid_filter_item_tax_rates( $item, $rates ) { |
|
198 | +function getpaid_filter_item_tax_rates($item, $rates) { |
|
199 | 199 | |
200 | 200 | $tax_class = $item->get_vat_class(); |
201 | 201 | |
202 | - foreach ( $rates as $i => $rate ) { |
|
202 | + foreach ($rates as $i => $rate) { |
|
203 | 203 | |
204 | - if ( $tax_class == '_reduced' ) { |
|
205 | - $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate']; |
|
204 | + if ($tax_class == '_reduced') { |
|
205 | + $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate']; |
|
206 | 206 | } |
207 | 207 | |
208 | - if ( $tax_class == '_exempt' ) { |
|
209 | - $rates[ $i ]['rate'] = 0; |
|
208 | + if ($tax_class == '_exempt') { |
|
209 | + $rates[$i]['rate'] = 0; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
213 | 213 | |
214 | - return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item ); |
|
214 | + return apply_filters('getpaid_filter_item_tax_rates', $rates, $item); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,12 +221,12 @@ discard block |
||
221 | 221 | * @param array $rates |
222 | 222 | * @return array |
223 | 223 | */ |
224 | -function getpaid_calculate_item_taxes( $amount, $rates ) { |
|
224 | +function getpaid_calculate_item_taxes($amount, $rates) { |
|
225 | 225 | |
226 | 226 | $is_inclusive = wpinv_prices_include_tax(); |
227 | - $taxes = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive ); |
|
227 | + $taxes = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive); |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates ); |
|
229 | + return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param float $recurring_tax_amount |
239 | 239 | * @return array |
240 | 240 | */ |
241 | -function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) { |
|
241 | +function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) { |
|
242 | 242 | |
243 | - $initial_tax = $tax_amount; |
|
243 | + $initial_tax = $tax_amount; |
|
244 | 244 | $recurring_tax = 0; |
245 | 245 | |
246 | - if ( $item->is_recurring() ) { |
|
246 | + if ($item->is_recurring()) { |
|
247 | 247 | $recurring_tax = $recurring_tax_amount; |
248 | 248 | } |
249 | 249 | |
250 | 250 | return array( |
251 | - 'name' => sanitize_text_field( $tax_name ), |
|
251 | + 'name' => sanitize_text_field($tax_name), |
|
252 | 252 | 'initial_tax' => $initial_tax, |
253 | 253 | 'recurring_tax' => $recurring_tax, |
254 | 254 | ); |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $vat_number |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function wpinv_sanitize_vat_number( $vat_number ) { |
|
265 | - return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) ); |
|
264 | +function wpinv_sanitize_vat_number($vat_number) { |
|
265 | + return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number))); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param string $vat_number |
272 | 272 | * @return bool |
273 | 273 | */ |
274 | -function wpinv_regex_validate_vat_number( $vat_number ) { |
|
274 | +function wpinv_regex_validate_vat_number($vat_number) { |
|
275 | 275 | |
276 | - $country = substr( $vat_number, 0, 2 ); |
|
277 | - $vatin = substr( $vat_number, 2 ); |
|
278 | - $regexes = wpinv_get_data( 'vat-number-regexes' ); |
|
276 | + $country = substr($vat_number, 0, 2); |
|
277 | + $vatin = substr($vat_number, 2); |
|
278 | + $regexes = wpinv_get_data('vat-number-regexes'); |
|
279 | 279 | |
280 | - if ( isset( $regexes[ $country ] ) ) { |
|
280 | + if (isset($regexes[$country])) { |
|
281 | 281 | |
282 | - $regex = $regexes[ $country ]; |
|
282 | + $regex = $regexes[$country]; |
|
283 | 283 | $regex = '/^(?:' . $regex . ')$/'; |
284 | - return 1 === preg_match( $regex, $vatin ); |
|
284 | + return 1 === preg_match($regex, $vatin); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Not an EU state, use filters to validate the number. |
289 | - return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number ); |
|
289 | + return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -295,29 +295,29 @@ discard block |
||
295 | 295 | * @param string $vat_number |
296 | 296 | * @return bool |
297 | 297 | */ |
298 | -function wpinv_vies_validate_vat_number( $vat_number ) { |
|
298 | +function wpinv_vies_validate_vat_number($vat_number) { |
|
299 | 299 | |
300 | - $country = substr( $vat_number, 0, 2 ); |
|
301 | - $vatin = substr( $vat_number, 2 ); |
|
300 | + $country = substr($vat_number, 0, 2); |
|
301 | + $vatin = substr($vat_number, 2); |
|
302 | 302 | |
303 | 303 | $url = add_query_arg( |
304 | 304 | array( |
305 | - 'ms' => urlencode( $country ), |
|
306 | - 'iso' => urlencode( $country ), |
|
307 | - 'vat' => urlencode( $vatin ), |
|
305 | + 'ms' => urlencode($country), |
|
306 | + 'iso' => urlencode($country), |
|
307 | + 'vat' => urlencode($vatin), |
|
308 | 308 | ), |
309 | 309 | 'http://ec.europa.eu/taxation_customs/vies/viesquer.do' |
310 | 310 | ); |
311 | 311 | |
312 | - $response = wp_remote_get( $url ); |
|
313 | - $response = wp_remote_retrieve_body( $response ); |
|
312 | + $response = wp_remote_get($url); |
|
313 | + $response = wp_remote_retrieve_body($response); |
|
314 | 314 | |
315 | 315 | // Fallback gracefully if the VIES website is down. |
316 | - if ( empty( $response ) ) { |
|
316 | + if (empty($response)) { |
|
317 | 317 | return true; |
318 | 318 | } |
319 | 319 | |
320 | - return 1 !== preg_match( '/invalid VAT number/i', $response ); |
|
320 | + return 1 !== preg_match('/invalid VAT number/i', $response); |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,18 +328,18 @@ discard block |
||
328 | 328 | * @param string $country |
329 | 329 | * @return bool |
330 | 330 | */ |
331 | -function wpinv_validate_vat_number( $vat_number, $country ) { |
|
331 | +function wpinv_validate_vat_number($vat_number, $country) { |
|
332 | 332 | |
333 | 333 | // In case the vat number does not have a country code... |
334 | - $vat_number = wpinv_sanitize_vat_number( $vat_number ); |
|
335 | - $_country = substr( $vat_number, 0, 2 ); |
|
336 | - $_country = $_country == wpinv_country_name( $_country ); |
|
334 | + $vat_number = wpinv_sanitize_vat_number($vat_number); |
|
335 | + $_country = substr($vat_number, 0, 2); |
|
336 | + $_country = $_country == wpinv_country_name($_country); |
|
337 | 337 | |
338 | - if ( $_country ) { |
|
339 | - $vat_number = strtoupper( $country ) . $vat_number; |
|
338 | + if ($_country) { |
|
339 | + $vat_number = strtoupper($country) . $vat_number; |
|
340 | 340 | } |
341 | 341 | |
342 | - return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number ); |
|
342 | + return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -348,40 +348,40 @@ discard block |
||
348 | 348 | * @return bool |
349 | 349 | */ |
350 | 350 | function wpinv_should_validate_vat_number() { |
351 | - $validate = wpinv_get_option( 'validate_vat_number' ); |
|
352 | - return ! empty( $validate ); |
|
351 | + $validate = wpinv_get_option('validate_vat_number'); |
|
352 | + return !empty($validate); |
|
353 | 353 | } |
354 | 354 | |
355 | -function wpinv_sales_tax_for_year( $year = null ) { |
|
356 | - return wpinv_price( wpinv_get_sales_tax_for_year( $year ) ); |
|
355 | +function wpinv_sales_tax_for_year($year = null) { |
|
356 | + return wpinv_price(wpinv_get_sales_tax_for_year($year)); |
|
357 | 357 | } |
358 | 358 | |
359 | -function wpinv_get_sales_tax_for_year( $year = null ) { |
|
359 | +function wpinv_get_sales_tax_for_year($year = null) { |
|
360 | 360 | global $wpdb; |
361 | 361 | |
362 | 362 | // Start at zero |
363 | 363 | $tax = 0; |
364 | 364 | |
365 | - if ( ! empty( $year ) ) { |
|
365 | + if (!empty($year)) { |
|
366 | 366 | $args = array( |
367 | 367 | 'post_type' => 'wpi_invoice', |
368 | - 'post_status' => array( 'publish' ), |
|
368 | + 'post_status' => array('publish'), |
|
369 | 369 | 'posts_per_page' => -1, |
370 | 370 | 'year' => $year, |
371 | 371 | 'fields' => 'ids' |
372 | 372 | ); |
373 | 373 | |
374 | - $payments = get_posts( $args ); |
|
375 | - $payment_ids = implode( ',', $payments ); |
|
374 | + $payments = get_posts($args); |
|
375 | + $payment_ids = implode(',', $payments); |
|
376 | 376 | |
377 | - if ( count( $payments ) > 0 ) { |
|
377 | + if (count($payments) > 0) { |
|
378 | 378 | $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )"; |
379 | - $tax = $wpdb->get_var( $sql ); |
|
379 | + $tax = $wpdb->get_var($sql); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year ); |
|
384 | + return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | function wpinv_is_cart_taxed() { |
@@ -390,33 +390,33 @@ discard block |
||
390 | 390 | |
391 | 391 | function wpinv_prices_show_tax_on_checkout() { |
392 | 392 | return false; // TODO |
393 | - $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() ); |
|
393 | + $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes()); |
|
394 | 394 | |
395 | - return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret ); |
|
395 | + return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_display_tax_rate() { |
399 | - $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false ); |
|
399 | + $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false); |
|
400 | 400 | |
401 | - return apply_filters( 'wpinv_display_tax_rate', $ret ); |
|
401 | + return apply_filters('wpinv_display_tax_rate', $ret); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | function wpinv_cart_needs_tax_address_fields() { |
405 | - if( !wpinv_is_cart_taxed() ) |
|
405 | + if (!wpinv_is_cart_taxed()) |
|
406 | 406 | return false; |
407 | 407 | |
408 | - return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' ); |
|
408 | + return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields'); |
|
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_item_is_tax_exclusive( $item_id = 0 ) { |
|
412 | - $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false ); |
|
413 | - return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id ); |
|
411 | +function wpinv_item_is_tax_exclusive($item_id = 0) { |
|
412 | + $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false); |
|
413 | + return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id); |
|
414 | 414 | } |
415 | 415 | |
416 | -function wpinv_currency_decimal_filter( $decimals = 2 ) { |
|
416 | +function wpinv_currency_decimal_filter($decimals = 2) { |
|
417 | 417 | $currency = wpinv_get_currency(); |
418 | 418 | |
419 | - switch ( $currency ) { |
|
419 | + switch ($currency) { |
|
420 | 420 | case 'RIAL' : |
421 | 421 | case 'JPY' : |
422 | 422 | case 'TWD' : |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | break; |
426 | 426 | } |
427 | 427 | |
428 | - return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency ); |
|
428 | + return apply_filters('wpinv_currency_decimal_count', $decimals, $currency); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | function wpinv_tax_amount() { |
432 | 432 | $output = 0.00; |
433 | 433 | |
434 | - return apply_filters( 'wpinv_tax_amount', $output ); |
|
434 | + return apply_filters('wpinv_tax_amount', $output); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -439,25 +439,25 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @param string|bool|null $vat_rule |
441 | 441 | */ |
442 | -function getpaid_filter_vat_rule( $vat_rule ) { |
|
442 | +function getpaid_filter_vat_rule($vat_rule) { |
|
443 | 443 | |
444 | - if ( empty( $vat_rule ) ) { |
|
444 | + if (empty($vat_rule)) { |
|
445 | 445 | return 'digital'; |
446 | 446 | } |
447 | 447 | |
448 | 448 | return $vat_rule; |
449 | 449 | } |
450 | -add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' ); |
|
450 | +add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule'); |
|
451 | 451 | |
452 | 452 | /** |
453 | 453 | * Filters the VAT class to ensure that each item has a VAT class. |
454 | 454 | * |
455 | 455 | * @param string|bool|null $vat_rule |
456 | 456 | */ |
457 | -function getpaid_filter_vat_class( $vat_class ) { |
|
458 | - return empty( $vat_class ) ? '_standard' : $vat_class; |
|
457 | +function getpaid_filter_vat_class($vat_class) { |
|
458 | + return empty($vat_class) ? '_standard' : $vat_class; |
|
459 | 459 | } |
460 | -add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' ); |
|
460 | +add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class'); |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Returns a list of all tax classes. |
@@ -469,9 +469,9 @@ discard block |
||
469 | 469 | return apply_filters( |
470 | 470 | 'getpaid_tax_classes', |
471 | 471 | array( |
472 | - '_standard' => __( 'Standard Tax Rate', 'invoicing' ), |
|
473 | - '_reduced' => __( 'Reduced Tax Rate', 'invoicing' ), |
|
474 | - '_exempt' => __( 'Tax Exempt', 'invoicing' ), |
|
472 | + '_standard' => __('Standard Tax Rate', 'invoicing'), |
|
473 | + '_reduced' => __('Reduced Tax Rate', 'invoicing'), |
|
474 | + '_exempt' => __('Tax Exempt', 'invoicing'), |
|
475 | 475 | ) |
476 | 476 | ); |
477 | 477 | |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | return apply_filters( |
488 | 488 | 'getpaid_tax_rules', |
489 | 489 | array( |
490 | - 'physical' => __( 'Physical Item', 'invoicing' ), |
|
491 | - 'digital' => __( 'Digital Item', 'invoicing' ), |
|
490 | + 'physical' => __('Physical Item', 'invoicing'), |
|
491 | + 'digital' => __('Digital Item', 'invoicing'), |
|
492 | 492 | ) |
493 | 493 | ); |
494 | 494 | |
@@ -500,15 +500,15 @@ discard block |
||
500 | 500 | * @param string $tax_class |
501 | 501 | * @return string |
502 | 502 | */ |
503 | -function getpaid_get_tax_class_label( $tax_class ) { |
|
503 | +function getpaid_get_tax_class_label($tax_class) { |
|
504 | 504 | |
505 | 505 | $classes = getpaid_get_tax_classes(); |
506 | 506 | |
507 | - if ( isset( $classes[ $tax_class ] ) ) { |
|
508 | - return sanitize_text_field( $classes[ $tax_class ] ); |
|
507 | + if (isset($classes[$tax_class])) { |
|
508 | + return sanitize_text_field($classes[$tax_class]); |
|
509 | 509 | } |
510 | 510 | |
511 | - return sanitize_text_field( $tax_class ); |
|
511 | + return sanitize_text_field($tax_class); |
|
512 | 512 | |
513 | 513 | } |
514 | 514 | |
@@ -518,15 +518,15 @@ discard block |
||
518 | 518 | * @param string $tax_rule |
519 | 519 | * @return string |
520 | 520 | */ |
521 | -function getpaid_get_tax_rule_label( $tax_rule ) { |
|
521 | +function getpaid_get_tax_rule_label($tax_rule) { |
|
522 | 522 | |
523 | 523 | $rules = getpaid_get_tax_rules(); |
524 | 524 | |
525 | - if ( isset( $rules[ $tax_rule ] ) ) { |
|
526 | - return sanitize_text_field( $rules[ $tax_rule ] ); |
|
525 | + if (isset($rules[$tax_rule])) { |
|
526 | + return sanitize_text_field($rules[$tax_rule]); |
|
527 | 527 | } |
528 | 528 | |
529 | - return sanitize_text_field( $tax_rule ); |
|
529 | + return sanitize_text_field($tax_rule); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 | |
@@ -537,11 +537,11 @@ discard block |
||
537 | 537 | * @param string $recurring |
538 | 538 | * @return string |
539 | 539 | */ |
540 | -function getpaid_get_taxable_amount( $item, $recurring = false ) { |
|
540 | +function getpaid_get_taxable_amount($item, $recurring = false) { |
|
541 | 541 | |
542 | 542 | $taxable_amount = $recurring ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
543 | 543 | $taxable_amount -= $recurring ? $item->recurring_item_discount : $item->item_discount; |
544 | - $taxable_amount = max( 0, $taxable_amount ); |
|
545 | - return apply_filters( 'getpaid_taxable_amount', $taxable_amount, $item, $recurring ); |
|
544 | + $taxable_amount = max(0, $taxable_amount); |
|
545 | + return apply_filters('getpaid_taxable_amount', $taxable_amount, $item, $recurring); |
|
546 | 546 | |
547 | 547 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @since 1.0.15 |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Discount class. |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @since 1.0.15 |
14 | 14 | * |
15 | 15 | */ |
16 | -class WPInv_Discount extends GetPaid_Data { |
|
16 | +class WPInv_Discount extends GetPaid_Data { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Which data store to load. |
@@ -79,35 +79,35 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param int|array|string|WPInv_Discount|WP_Post $discount discount data, object, ID or code. |
81 | 81 | */ |
82 | - public function __construct( $discount = 0 ) { |
|
83 | - parent::__construct( $discount ); |
|
82 | + public function __construct($discount = 0) { |
|
83 | + parent::__construct($discount); |
|
84 | 84 | |
85 | - if ( is_numeric( $discount ) && 'wpi_discount' === get_post_type( $discount ) ) { |
|
86 | - $this->set_id( $discount ); |
|
87 | - } elseif ( $discount instanceof self ) { |
|
88 | - $this->set_id( $discount->get_id() ); |
|
89 | - } elseif ( ! empty( $discount->ID ) ) { |
|
90 | - $this->set_id( $discount->ID ); |
|
91 | - } elseif ( is_array( $discount ) ) { |
|
92 | - $this->set_props( $discount ); |
|
85 | + if (is_numeric($discount) && 'wpi_discount' === get_post_type($discount)) { |
|
86 | + $this->set_id($discount); |
|
87 | + } elseif ($discount instanceof self) { |
|
88 | + $this->set_id($discount->get_id()); |
|
89 | + } elseif (!empty($discount->ID)) { |
|
90 | + $this->set_id($discount->ID); |
|
91 | + } elseif (is_array($discount)) { |
|
92 | + $this->set_props($discount); |
|
93 | 93 | |
94 | - if ( isset( $discount['ID'] ) ) { |
|
95 | - $this->set_id( $discount['ID'] ); |
|
94 | + if (isset($discount['ID'])) { |
|
95 | + $this->set_id($discount['ID']); |
|
96 | 96 | } |
97 | 97 | |
98 | - } elseif ( is_scalar( $discount ) && $discount = self::get_discount_id_by_code( $discount ) ) { |
|
99 | - $this->set_id( $discount ); |
|
98 | + } elseif (is_scalar($discount) && $discount = self::get_discount_id_by_code($discount)) { |
|
99 | + $this->set_id($discount); |
|
100 | 100 | } else { |
101 | - $this->set_object_read( true ); |
|
101 | + $this->set_object_read(true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | // Load the datastore. |
105 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
105 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
106 | 106 | |
107 | - if ( $this->get_id() > 0 ) { |
|
108 | - $this->post = get_post( $this->get_id() ); |
|
107 | + if ($this->get_id() > 0) { |
|
108 | + $this->post = get_post($this->get_id()); |
|
109 | 109 | $this->ID = $this->get_id(); |
110 | - $this->data_store->read( $this ); |
|
110 | + $this->data_store->read($this); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -123,50 +123,50 @@ discard block |
||
123 | 123 | * @since 1.0.15 |
124 | 124 | * @return array|bool array of discount details on success. False otherwise. |
125 | 125 | */ |
126 | - public static function get_data_by( $field, $value ) { |
|
126 | + public static function get_data_by($field, $value) { |
|
127 | 127 | |
128 | - if ( 'id' == strtolower( $field ) ) { |
|
128 | + if ('id' == strtolower($field)) { |
|
129 | 129 | // Make sure the value is numeric to avoid casting objects, for example, |
130 | 130 | // to int 1. |
131 | - if ( ! is_numeric( $value ) ) |
|
131 | + if (!is_numeric($value)) |
|
132 | 132 | return false; |
133 | - $value = intval( $value ); |
|
134 | - if ( $value < 1 ) |
|
133 | + $value = intval($value); |
|
134 | + if ($value < 1) |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | - if ( ! $value || ! is_string( $field ) ) { |
|
138 | + if (!$value || !is_string($field)) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | - $field = trim( $field ); |
|
142 | + $field = trim($field); |
|
143 | 143 | |
144 | 144 | // prepare query args |
145 | - switch ( strtolower( $field ) ) { |
|
145 | + switch (strtolower($field)) { |
|
146 | 146 | case 'id': |
147 | 147 | $discount_id = $value; |
148 | - $args = array( 'include' => array( $value ) ); |
|
148 | + $args = array('include' => array($value)); |
|
149 | 149 | break; |
150 | 150 | case 'discount_code': |
151 | 151 | case 'code': |
152 | - $value = trim( $value ); |
|
153 | - $discount_id = wp_cache_get( $value, 'WPInv_Discount_Codes' ); |
|
154 | - $args = array( 'meta_key' => '_wpi_discount_code', 'meta_value' => $value ); |
|
152 | + $value = trim($value); |
|
153 | + $discount_id = wp_cache_get($value, 'WPInv_Discount_Codes'); |
|
154 | + $args = array('meta_key' => '_wpi_discount_code', 'meta_value' => $value); |
|
155 | 155 | break; |
156 | 156 | case 'name': |
157 | 157 | $discount_id = 0; |
158 | - $args = array( 'name' => trim( $value ) ); |
|
158 | + $args = array('name' => trim($value)); |
|
159 | 159 | break; |
160 | 160 | default: |
161 | - $args = apply_filters( "wpinv_discount_get_data_by_{$field}_args", null, $value ); |
|
162 | - if ( ! is_array( $args ) ) { |
|
163 | - return apply_filters( "wpinv_discount_get_data_by_$field", false, $value ); |
|
161 | + $args = apply_filters("wpinv_discount_get_data_by_{$field}_args", null, $value); |
|
162 | + if (!is_array($args)) { |
|
163 | + return apply_filters("wpinv_discount_get_data_by_$field", false, $value); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Check if there is a cached value. |
169 | - if ( ! empty( $discount_id ) && $discount = wp_cache_get( (int) $discount_id, 'WPInv_Discounts' ) ) { |
|
169 | + if (!empty($discount_id) && $discount = wp_cache_get((int) $discount_id, 'WPInv_Discounts')) { |
|
170 | 170 | return $discount; |
171 | 171 | } |
172 | 172 | |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | array( |
176 | 176 | 'post_type' => 'wpi_discount', |
177 | 177 | 'posts_per_page' => 1, |
178 | - 'post_status' => array( 'publish', 'pending', 'draft', 'expired' ) |
|
178 | + 'post_status' => array('publish', 'pending', 'draft', 'expired') |
|
179 | 179 | ) |
180 | 180 | ); |
181 | 181 | |
182 | - $discount = get_posts( $args ); |
|
182 | + $discount = get_posts($args); |
|
183 | 183 | |
184 | - if( empty( $discount ) ) { |
|
184 | + if (empty($discount)) { |
|
185 | 185 | return false; |
186 | 186 | } |
187 | 187 | |
@@ -190,30 +190,30 @@ discard block |
||
190 | 190 | // Prepare the return data. |
191 | 191 | $return = array( |
192 | 192 | 'ID' => $discount->ID, |
193 | - 'code' => get_post_meta( $discount->ID, '_wpi_discount_code', true ), |
|
194 | - 'amount' => get_post_meta( $discount->ID, '_wpi_discount_amount', true ), |
|
193 | + 'code' => get_post_meta($discount->ID, '_wpi_discount_code', true), |
|
194 | + 'amount' => get_post_meta($discount->ID, '_wpi_discount_amount', true), |
|
195 | 195 | 'date_created' => $discount->post_date, |
196 | 196 | 'date_modified' => $discount->post_modified, |
197 | 197 | 'status' => $discount->post_status, |
198 | - 'start' => get_post_meta( $discount->ID, '_wpi_discount_start', true ), |
|
199 | - 'expiration' => get_post_meta( $discount->ID, '_wpi_discount_expiration', true ), |
|
200 | - 'type' => get_post_meta( $discount->ID, '_wpi_discount_type', true ), |
|
198 | + 'start' => get_post_meta($discount->ID, '_wpi_discount_start', true), |
|
199 | + 'expiration' => get_post_meta($discount->ID, '_wpi_discount_expiration', true), |
|
200 | + 'type' => get_post_meta($discount->ID, '_wpi_discount_type', true), |
|
201 | 201 | 'description' => $discount->post_excerpt, |
202 | - 'uses' => get_post_meta( $discount->ID, '_wpi_discount_uses', true ), |
|
203 | - 'is_single_use' => get_post_meta( $discount->ID, '_wpi_discount_is_single_use', true ), |
|
204 | - 'items' => get_post_meta( $discount->ID, '_wpi_discount_items', true ), |
|
205 | - 'excluded_items' => get_post_meta( $discount->ID, '_wpi_discount_excluded_items', true ), |
|
206 | - 'max_uses' => get_post_meta( $discount->ID, '_wpi_discount_max_uses', true ), |
|
207 | - 'is_recurring' => get_post_meta( $discount->ID, '_wpi_discount_is_recurring', true ), |
|
208 | - 'min_total' => get_post_meta( $discount->ID, '_wpi_discount_min_total', true ), |
|
209 | - 'max_total' => get_post_meta( $discount->ID, '_wpi_discount_max_total', true ), |
|
202 | + 'uses' => get_post_meta($discount->ID, '_wpi_discount_uses', true), |
|
203 | + 'is_single_use' => get_post_meta($discount->ID, '_wpi_discount_is_single_use', true), |
|
204 | + 'items' => get_post_meta($discount->ID, '_wpi_discount_items', true), |
|
205 | + 'excluded_items' => get_post_meta($discount->ID, '_wpi_discount_excluded_items', true), |
|
206 | + 'max_uses' => get_post_meta($discount->ID, '_wpi_discount_max_uses', true), |
|
207 | + 'is_recurring' => get_post_meta($discount->ID, '_wpi_discount_is_recurring', true), |
|
208 | + 'min_total' => get_post_meta($discount->ID, '_wpi_discount_min_total', true), |
|
209 | + 'max_total' => get_post_meta($discount->ID, '_wpi_discount_max_total', true), |
|
210 | 210 | ); |
211 | 211 | |
212 | - $return = apply_filters( 'wpinv_discount_properties', $return ); |
|
212 | + $return = apply_filters('wpinv_discount_properties', $return); |
|
213 | 213 | |
214 | 214 | // Update the cache with our data |
215 | - wp_cache_add( $discount->ID, $return, 'WPInv_Discounts' ); |
|
216 | - wp_cache_add( $return['code'], $discount->ID, 'WPInv_Discount_Codes' ); |
|
215 | + wp_cache_add($discount->ID, $return, 'WPInv_Discounts'); |
|
216 | + wp_cache_add($return['code'], $discount->ID, 'WPInv_Discount_Codes'); |
|
217 | 217 | |
218 | 218 | return $return; |
219 | 219 | } |
@@ -227,19 +227,19 @@ discard block |
||
227 | 227 | * @since 1.0.15 |
228 | 228 | * @return int |
229 | 229 | */ |
230 | - public static function get_discount_id_by_code( $discount_code ) { |
|
230 | + public static function get_discount_id_by_code($discount_code) { |
|
231 | 231 | |
232 | 232 | // Trim the code. |
233 | - $discount_code = trim( $discount_code ); |
|
233 | + $discount_code = trim($discount_code); |
|
234 | 234 | |
235 | 235 | // Ensure a value has been passed. |
236 | - if ( empty( $discount_code ) ) { |
|
236 | + if (empty($discount_code)) { |
|
237 | 237 | return 0; |
238 | 238 | } |
239 | 239 | |
240 | 240 | // Maybe retrieve from the cache. |
241 | - $discount_id = wp_cache_get( $discount_code, 'getpaid_discount_codes' ); |
|
242 | - if ( ! empty( $discount_id ) ) { |
|
241 | + $discount_id = wp_cache_get($discount_code, 'getpaid_discount_codes'); |
|
242 | + if (!empty($discount_id)) { |
|
243 | 243 | return $discount_id; |
244 | 244 | } |
245 | 245 | |
@@ -250,19 +250,19 @@ discard block |
||
250 | 250 | 'meta_value' => $discount_code, |
251 | 251 | 'post_type' => 'wpi_discount', |
252 | 252 | 'posts_per_page' => 1, |
253 | - 'post_status' => array( 'publish', 'pending', 'draft', 'expired' ), |
|
253 | + 'post_status' => array('publish', 'pending', 'draft', 'expired'), |
|
254 | 254 | 'fields' => 'ids', |
255 | 255 | ) |
256 | 256 | ); |
257 | 257 | |
258 | - if ( empty( $discounts ) ) { |
|
258 | + if (empty($discounts)) { |
|
259 | 259 | return 0; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $discount_id = $discounts[0]; |
263 | 263 | |
264 | 264 | // Update the cache with our data |
265 | - wp_cache_add( get_post_meta( $discount_id, '_wpi_discount_code', true ), $discount_id, 'getpaid_discount_codes' ); |
|
265 | + wp_cache_add(get_post_meta($discount_id, '_wpi_discount_code', true), $discount_id, 'getpaid_discount_codes'); |
|
266 | 266 | |
267 | 267 | return $discount_id; |
268 | 268 | } |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return bool Whether the given discount field is set. |
277 | 277 | */ |
278 | - public function __isset( $key ){ |
|
279 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key"); |
|
278 | + public function __isset($key) { |
|
279 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /* |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_status( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'status', $context ); |
|
304 | + public function get_status($context = 'view') { |
|
305 | + return $this->get_prop('status', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public function get_version( $context = 'view' ) { |
|
316 | - return $this->get_prop( 'version', $context ); |
|
315 | + public function get_version($context = 'view') { |
|
316 | + return $this->get_prop('version', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return string |
325 | 325 | */ |
326 | - public function get_date_created( $context = 'view' ) { |
|
327 | - return $this->get_prop( 'date_created', $context ); |
|
326 | + public function get_date_created($context = 'view') { |
|
327 | + return $this->get_prop('date_created', $context); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public function get_date_created_gmt( $context = 'view' ) { |
|
338 | - $date = $this->get_date_created( $context ); |
|
337 | + public function get_date_created_gmt($context = 'view') { |
|
338 | + $date = $this->get_date_created($context); |
|
339 | 339 | |
340 | - if ( $date ) { |
|
341 | - $date = get_gmt_from_date( $date ); |
|
340 | + if ($date) { |
|
341 | + $date = get_gmt_from_date($date); |
|
342 | 342 | } |
343 | 343 | return $date; |
344 | 344 | } |
@@ -350,8 +350,8 @@ discard block |
||
350 | 350 | * @param string $context View or edit context. |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - public function get_date_modified( $context = 'view' ) { |
|
354 | - return $this->get_prop( 'date_modified', $context ); |
|
353 | + public function get_date_modified($context = 'view') { |
|
354 | + return $this->get_prop('date_modified', $context); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -361,11 +361,11 @@ discard block |
||
361 | 361 | * @param string $context View or edit context. |
362 | 362 | * @return string |
363 | 363 | */ |
364 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
365 | - $date = $this->get_date_modified( $context ); |
|
364 | + public function get_date_modified_gmt($context = 'view') { |
|
365 | + $date = $this->get_date_modified($context); |
|
366 | 366 | |
367 | - if ( $date ) { |
|
368 | - $date = get_gmt_from_date( $date ); |
|
367 | + if ($date) { |
|
368 | + $date = get_gmt_from_date($date); |
|
369 | 369 | } |
370 | 370 | return $date; |
371 | 371 | } |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @param string $context View or edit context. |
378 | 378 | * @return string |
379 | 379 | */ |
380 | - public function get_name( $context = 'view' ) { |
|
381 | - return $this->get_prop( 'name', $context ); |
|
380 | + public function get_name($context = 'view') { |
|
381 | + return $this->get_prop('name', $context); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @param string $context View or edit context. |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public function get_title( $context = 'view' ) { |
|
392 | - return $this->get_name( $context ); |
|
391 | + public function get_title($context = 'view') { |
|
392 | + return $this->get_name($context); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -399,8 +399,8 @@ discard block |
||
399 | 399 | * @param string $context View or edit context. |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function get_description( $context = 'view' ) { |
|
403 | - return $this->get_prop( 'description', $context ); |
|
402 | + public function get_description($context = 'view') { |
|
403 | + return $this->get_prop('description', $context); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | * @param string $context View or edit context. |
411 | 411 | * @return string |
412 | 412 | */ |
413 | - public function get_excerpt( $context = 'view' ) { |
|
414 | - return $this->get_description( $context ); |
|
413 | + public function get_excerpt($context = 'view') { |
|
414 | + return $this->get_description($context); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * @param string $context View or edit context. |
422 | 422 | * @return string |
423 | 423 | */ |
424 | - public function get_summary( $context = 'view' ) { |
|
425 | - return $this->get_description( $context ); |
|
424 | + public function get_summary($context = 'view') { |
|
425 | + return $this->get_description($context); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | * @param string $context View or edit context. |
433 | 433 | * @return string |
434 | 434 | */ |
435 | - public function get_author( $context = 'view' ) { |
|
436 | - return (int) $this->get_prop( 'author', $context ); |
|
435 | + public function get_author($context = 'view') { |
|
436 | + return (int) $this->get_prop('author', $context); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | /** |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * @param string $context View or edit context. |
444 | 444 | * @return string |
445 | 445 | */ |
446 | - public function get_code( $context = 'view' ) { |
|
447 | - return $this->get_prop( 'code', $context ); |
|
446 | + public function get_code($context = 'view') { |
|
447 | + return $this->get_prop('code', $context); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param string $context View or edit context. |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - public function get_coupon_code( $context = 'view' ) { |
|
458 | - return $this->get_code( $context ); |
|
457 | + public function get_coupon_code($context = 'view') { |
|
458 | + return $this->get_code($context); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | * @param string $context View or edit context. |
466 | 466 | * @return string |
467 | 467 | */ |
468 | - public function get_discount_code( $context = 'view' ) { |
|
469 | - return $this->get_code( $context ); |
|
468 | + public function get_discount_code($context = 'view') { |
|
469 | + return $this->get_code($context); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | * @param string $context View or edit context. |
477 | 477 | * @return float |
478 | 478 | */ |
479 | - public function get_amount( $context = 'view' ) { |
|
480 | - return $context == 'view' ? floatval( $this->get_prop( 'amount', $context ) ) : $this->get_prop( 'amount', $context ); |
|
479 | + public function get_amount($context = 'view') { |
|
480 | + return $context == 'view' ? floatval($this->get_prop('amount', $context)) : $this->get_prop('amount', $context); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -488,13 +488,13 @@ discard block |
||
488 | 488 | */ |
489 | 489 | public function get_formatted_amount() { |
490 | 490 | |
491 | - if ( $this->is_type( 'flat' ) ) { |
|
492 | - $rate = wpinv_price( $this->get_amount() ); |
|
491 | + if ($this->is_type('flat')) { |
|
492 | + $rate = wpinv_price($this->get_amount()); |
|
493 | 493 | } else { |
494 | 494 | $rate = $this->get_amount() . '%'; |
495 | 495 | } |
496 | 496 | |
497 | - return apply_filters( 'wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount() ); |
|
497 | + return apply_filters('wpinv_format_discount_rate', $rate, $this->get_type(), $this->get_amount()); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @param string $context View or edit context. |
505 | 505 | * @return string |
506 | 506 | */ |
507 | - public function get_start( $context = 'view' ) { |
|
508 | - return $this->get_prop( 'start', $context ); |
|
507 | + public function get_start($context = 'view') { |
|
508 | + return $this->get_prop('start', $context); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -515,8 +515,8 @@ discard block |
||
515 | 515 | * @param string $context View or edit context. |
516 | 516 | * @return string |
517 | 517 | */ |
518 | - public function get_start_date( $context = 'view' ) { |
|
519 | - return $this->get_start( $context ); |
|
518 | + public function get_start_date($context = 'view') { |
|
519 | + return $this->get_start($context); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | /** |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | * @param string $context View or edit context. |
527 | 527 | * @return string |
528 | 528 | */ |
529 | - public function get_expiration( $context = 'view' ) { |
|
530 | - return $this->get_prop( 'expiration', $context ); |
|
529 | + public function get_expiration($context = 'view') { |
|
530 | + return $this->get_prop('expiration', $context); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | /** |
@@ -537,8 +537,8 @@ discard block |
||
537 | 537 | * @param string $context View or edit context. |
538 | 538 | * @return string |
539 | 539 | */ |
540 | - public function get_expiration_date( $context = 'view' ) { |
|
541 | - return $this->get_expiration( $context ); |
|
540 | + public function get_expiration_date($context = 'view') { |
|
541 | + return $this->get_expiration($context); |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * @param string $context View or edit context. |
549 | 549 | * @return string |
550 | 550 | */ |
551 | - public function get_end_date( $context = 'view' ) { |
|
552 | - return $this->get_expiration( $context ); |
|
551 | + public function get_end_date($context = 'view') { |
|
552 | + return $this->get_expiration($context); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @param string $context View or edit context. |
560 | 560 | * @return string |
561 | 561 | */ |
562 | - public function get_type( $context = 'view' ) { |
|
563 | - return $this->get_prop( 'type', $context ); |
|
562 | + public function get_type($context = 'view') { |
|
563 | + return $this->get_prop('type', $context); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | * @param string $context View or edit context. |
571 | 571 | * @return int |
572 | 572 | */ |
573 | - public function get_uses( $context = 'view' ) { |
|
574 | - return (int) $this->get_prop( 'uses', $context ); |
|
573 | + public function get_uses($context = 'view') { |
|
574 | + return (int) $this->get_prop('uses', $context); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | */ |
583 | 583 | public function get_usage() { |
584 | 584 | |
585 | - if ( ! $this->has_limit() ) { |
|
585 | + if (!$this->has_limit()) { |
|
586 | 586 | return $this->get_uses() . ' / ' . ' ∞'; |
587 | 587 | } |
588 | 588 | |
@@ -597,9 +597,9 @@ discard block |
||
597 | 597 | * @param string $context View or edit context. |
598 | 598 | * @return int |
599 | 599 | */ |
600 | - public function get_max_uses( $context = 'view' ) { |
|
601 | - $max_uses = $this->get_prop( 'max_uses', $context ); |
|
602 | - return empty( $max_uses ) ? null : $max_uses; |
|
600 | + public function get_max_uses($context = 'view') { |
|
601 | + $max_uses = $this->get_prop('max_uses', $context); |
|
602 | + return empty($max_uses) ? null : $max_uses; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -609,8 +609,8 @@ discard block |
||
609 | 609 | * @param string $context View or edit context. |
610 | 610 | * @return bool |
611 | 611 | */ |
612 | - public function get_is_single_use( $context = 'view' ) { |
|
613 | - return $this->get_prop( 'is_single_use', $context ); |
|
612 | + public function get_is_single_use($context = 'view') { |
|
613 | + return $this->get_prop('is_single_use', $context); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -620,8 +620,8 @@ discard block |
||
620 | 620 | * @param string $context View or edit context. |
621 | 621 | * @return array |
622 | 622 | */ |
623 | - public function get_items( $context = 'view' ) { |
|
624 | - return wpinv_parse_list( $this->get_prop( 'items', $context ) ); |
|
623 | + public function get_items($context = 'view') { |
|
624 | + return wpinv_parse_list($this->get_prop('items', $context)); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | * @param string $context View or edit context. |
632 | 632 | * @return array |
633 | 633 | */ |
634 | - public function get_allowed_items( $context = 'view' ) { |
|
635 | - return $this->get_items( $context ); |
|
634 | + public function get_allowed_items($context = 'view') { |
|
635 | + return $this->get_items($context); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -642,8 +642,8 @@ discard block |
||
642 | 642 | * @param string $context View or edit context. |
643 | 643 | * @return array |
644 | 644 | */ |
645 | - public function get_excluded_items( $context = 'view' ) { |
|
646 | - return wpinv_parse_list( $this->get_prop( 'excluded_items', $context ) ); |
|
645 | + public function get_excluded_items($context = 'view') { |
|
646 | + return wpinv_parse_list($this->get_prop('excluded_items', $context)); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $context View or edit context. |
654 | 654 | * @return int|string|bool |
655 | 655 | */ |
656 | - public function get_is_recurring( $context = 'view' ) { |
|
657 | - return $this->get_prop( 'is_recurring', $context ); |
|
656 | + public function get_is_recurring($context = 'view') { |
|
657 | + return $this->get_prop('is_recurring', $context); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @param string $context View or edit context. |
665 | 665 | * @return float |
666 | 666 | */ |
667 | - public function get_min_total( $context = 'view' ) { |
|
668 | - $minimum = $this->get_prop( 'min_total', $context ); |
|
669 | - return empty( $minimum ) ? null : $minimum; |
|
667 | + public function get_min_total($context = 'view') { |
|
668 | + $minimum = $this->get_prop('min_total', $context); |
|
669 | + return empty($minimum) ? null : $minimum; |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @param string $context View or edit context. |
677 | 677 | * @return float |
678 | 678 | */ |
679 | - public function get_minimum_total( $context = 'view' ) { |
|
680 | - return $this->get_min_total( $context ); |
|
679 | + public function get_minimum_total($context = 'view') { |
|
680 | + return $this->get_min_total($context); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -687,9 +687,9 @@ discard block |
||
687 | 687 | * @param string $context View or edit context. |
688 | 688 | * @return float |
689 | 689 | */ |
690 | - public function get_max_total( $context = 'view' ) { |
|
691 | - $maximum = $this->get_prop( 'max_total', $context ); |
|
692 | - return empty( $maximum ) ? null : $maximum; |
|
690 | + public function get_max_total($context = 'view') { |
|
691 | + $maximum = $this->get_prop('max_total', $context); |
|
692 | + return empty($maximum) ? null : $maximum; |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | /** |
@@ -699,8 +699,8 @@ discard block |
||
699 | 699 | * @param string $context View or edit context. |
700 | 700 | * @return float |
701 | 701 | */ |
702 | - public function get_maximum_total( $context = 'view' ) { |
|
703 | - return $this->get_max_total( $context ); |
|
702 | + public function get_maximum_total($context = 'view') { |
|
703 | + return $this->get_max_total($context); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | * @param string $context View or edit context. |
714 | 714 | * @return mixed Value of the given discount property (if set). |
715 | 715 | */ |
716 | - public function get( $key, $context = 'view' ) { |
|
717 | - return $this->get_prop( $key, $context ); |
|
716 | + public function get($key, $context = 'view') { |
|
717 | + return $this->get_prop($key, $context); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /* |
@@ -734,10 +734,10 @@ discard block |
||
734 | 734 | * @param string $status New status. |
735 | 735 | * @return array details of change. |
736 | 736 | */ |
737 | - public function set_status( $status ) { |
|
737 | + public function set_status($status) { |
|
738 | 738 | $old_status = $this->get_status(); |
739 | 739 | |
740 | - $this->set_prop( 'status', $status ); |
|
740 | + $this->set_prop('status', $status); |
|
741 | 741 | |
742 | 742 | return array( |
743 | 743 | 'from' => $old_status, |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | * |
751 | 751 | * @since 1.0.19 |
752 | 752 | */ |
753 | - public function set_version( $value ) { |
|
754 | - $this->set_prop( 'version', $value ); |
|
753 | + public function set_version($value) { |
|
754 | + $this->set_prop('version', $value); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -761,11 +761,11 @@ discard block |
||
761 | 761 | * @param string $value Value to set. |
762 | 762 | * @return bool Whether or not the date was set. |
763 | 763 | */ |
764 | - public function set_date_created( $value ) { |
|
765 | - $date = strtotime( $value ); |
|
764 | + public function set_date_created($value) { |
|
765 | + $date = strtotime($value); |
|
766 | 766 | |
767 | - if ( $date ) { |
|
768 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
767 | + if ($date) { |
|
768 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
769 | 769 | return true; |
770 | 770 | } |
771 | 771 | |
@@ -780,11 +780,11 @@ discard block |
||
780 | 780 | * @param string $value Value to set. |
781 | 781 | * @return bool Whether or not the date was set. |
782 | 782 | */ |
783 | - public function set_date_modified( $value ) { |
|
784 | - $date = strtotime( $value ); |
|
783 | + public function set_date_modified($value) { |
|
784 | + $date = strtotime($value); |
|
785 | 785 | |
786 | - if ( $date ) { |
|
787 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
786 | + if ($date) { |
|
787 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
788 | 788 | return true; |
789 | 789 | } |
790 | 790 | |
@@ -798,9 +798,9 @@ discard block |
||
798 | 798 | * @since 1.0.19 |
799 | 799 | * @param string $value New name. |
800 | 800 | */ |
801 | - public function set_name( $value ) { |
|
802 | - $name = sanitize_text_field( $value ); |
|
803 | - $this->set_prop( 'name', $name ); |
|
801 | + public function set_name($value) { |
|
802 | + $name = sanitize_text_field($value); |
|
803 | + $this->set_prop('name', $name); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | * @since 1.0.19 |
810 | 810 | * @param string $value New name. |
811 | 811 | */ |
812 | - public function set_title( $value ) { |
|
813 | - $this->set_name( $value ); |
|
812 | + public function set_title($value) { |
|
813 | + $this->set_name($value); |
|
814 | 814 | } |
815 | 815 | |
816 | 816 | /** |
@@ -819,9 +819,9 @@ discard block |
||
819 | 819 | * @since 1.0.19 |
820 | 820 | * @param string $value New description. |
821 | 821 | */ |
822 | - public function set_description( $value ) { |
|
823 | - $description = wp_kses_post( $value ); |
|
824 | - return $this->set_prop( 'description', $description ); |
|
822 | + public function set_description($value) { |
|
823 | + $description = wp_kses_post($value); |
|
824 | + return $this->set_prop('description', $description); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | /** |
@@ -830,8 +830,8 @@ discard block |
||
830 | 830 | * @since 1.0.19 |
831 | 831 | * @param string $value New description. |
832 | 832 | */ |
833 | - public function set_excerpt( $value ) { |
|
834 | - $this->set_description( $value ); |
|
833 | + public function set_excerpt($value) { |
|
834 | + $this->set_description($value); |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -840,8 +840,8 @@ discard block |
||
840 | 840 | * @since 1.0.19 |
841 | 841 | * @param string $value New description. |
842 | 842 | */ |
843 | - public function set_summary( $value ) { |
|
844 | - $this->set_description( $value ); |
|
843 | + public function set_summary($value) { |
|
844 | + $this->set_description($value); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * @since 1.0.19 |
851 | 851 | * @param int $value New author. |
852 | 852 | */ |
853 | - public function set_author( $value ) { |
|
854 | - $this->set_prop( 'author', (int) $value ); |
|
853 | + public function set_author($value) { |
|
854 | + $this->set_prop('author', (int) $value); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -860,9 +860,9 @@ discard block |
||
860 | 860 | * @since 1.0.19 |
861 | 861 | * @param string $value New discount code. |
862 | 862 | */ |
863 | - public function set_code( $value ) { |
|
864 | - $code = sanitize_text_field( $value ); |
|
865 | - $this->set_prop( 'code', $code ); |
|
863 | + public function set_code($value) { |
|
864 | + $code = sanitize_text_field($value); |
|
865 | + $this->set_prop('code', $code); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | /** |
@@ -871,8 +871,8 @@ discard block |
||
871 | 871 | * @since 1.0.19 |
872 | 872 | * @param string $value New discount code. |
873 | 873 | */ |
874 | - public function set_coupon_code( $value ) { |
|
875 | - $this->set_code( $value ); |
|
874 | + public function set_coupon_code($value) { |
|
875 | + $this->set_code($value); |
|
876 | 876 | } |
877 | 877 | |
878 | 878 | /** |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | * @since 1.0.19 |
882 | 882 | * @param string $value New discount code. |
883 | 883 | */ |
884 | - public function set_discount_code( $value ) { |
|
885 | - $this->set_code( $value ); |
|
884 | + public function set_discount_code($value) { |
|
885 | + $this->set_code($value); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -891,9 +891,9 @@ discard block |
||
891 | 891 | * @since 1.0.19 |
892 | 892 | * @param float $value New discount code. |
893 | 893 | */ |
894 | - public function set_amount( $value ) { |
|
895 | - $amount = floatval( wpinv_sanitize_amount( $value ) ); |
|
896 | - $this->set_prop( 'amount', $amount ); |
|
894 | + public function set_amount($value) { |
|
895 | + $amount = floatval(wpinv_sanitize_amount($value)); |
|
896 | + $this->set_prop('amount', $amount); |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | /** |
@@ -902,15 +902,15 @@ discard block |
||
902 | 902 | * @since 1.0.19 |
903 | 903 | * @param float $value New start date. |
904 | 904 | */ |
905 | - public function set_start( $value ) { |
|
906 | - $date = strtotime( $value ); |
|
905 | + public function set_start($value) { |
|
906 | + $date = strtotime($value); |
|
907 | 907 | |
908 | - if ( $date ) { |
|
909 | - $this->set_prop( 'start', date( 'Y-m-d H:i', $date ) ); |
|
908 | + if ($date) { |
|
909 | + $this->set_prop('start', date('Y-m-d H:i', $date)); |
|
910 | 910 | return true; |
911 | 911 | } |
912 | 912 | |
913 | - $this->set_prop( 'start', '' ); |
|
913 | + $this->set_prop('start', ''); |
|
914 | 914 | |
915 | 915 | return false; |
916 | 916 | } |
@@ -921,8 +921,8 @@ discard block |
||
921 | 921 | * @since 1.0.19 |
922 | 922 | * @param string $value New start date. |
923 | 923 | */ |
924 | - public function set_start_date( $value ) { |
|
925 | - $this->set_start( $value ); |
|
924 | + public function set_start_date($value) { |
|
925 | + $this->set_start($value); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | /** |
@@ -931,15 +931,15 @@ discard block |
||
931 | 931 | * @since 1.0.19 |
932 | 932 | * @param float $value New expiration date. |
933 | 933 | */ |
934 | - public function set_expiration( $value ) { |
|
935 | - $date = strtotime( $value ); |
|
934 | + public function set_expiration($value) { |
|
935 | + $date = strtotime($value); |
|
936 | 936 | |
937 | - if ( $date ) { |
|
938 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i', $date ) ); |
|
937 | + if ($date) { |
|
938 | + $this->set_prop('expiration', date('Y-m-d H:i', $date)); |
|
939 | 939 | return true; |
940 | 940 | } |
941 | 941 | |
942 | - $this->set_prop( 'expiration', '' ); |
|
942 | + $this->set_prop('expiration', ''); |
|
943 | 943 | return false; |
944 | 944 | } |
945 | 945 | |
@@ -949,8 +949,8 @@ discard block |
||
949 | 949 | * @since 1.0.19 |
950 | 950 | * @param string $value New expiration date. |
951 | 951 | */ |
952 | - public function set_expiration_date( $value ) { |
|
953 | - $this->set_expiration( $value ); |
|
952 | + public function set_expiration_date($value) { |
|
953 | + $this->set_expiration($value); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | * @since 1.0.19 |
960 | 960 | * @param string $value New expiration date. |
961 | 961 | */ |
962 | - public function set_end_date( $value ) { |
|
963 | - $this->set_expiration( $value ); |
|
962 | + public function set_end_date($value) { |
|
963 | + $this->set_expiration($value); |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -969,9 +969,9 @@ discard block |
||
969 | 969 | * @since 1.0.19 |
970 | 970 | * @param string $value New discount type. |
971 | 971 | */ |
972 | - public function set_type( $value ) { |
|
973 | - if ( $value && array_key_exists( sanitize_text_field( $value ), wpinv_get_discount_types() ) ) { |
|
974 | - $this->set_prop( 'type', sanitize_text_field( $value ) ); |
|
972 | + public function set_type($value) { |
|
973 | + if ($value && array_key_exists(sanitize_text_field($value), wpinv_get_discount_types())) { |
|
974 | + $this->set_prop('type', sanitize_text_field($value)); |
|
975 | 975 | } |
976 | 976 | } |
977 | 977 | |
@@ -981,15 +981,15 @@ discard block |
||
981 | 981 | * @since 1.0.19 |
982 | 982 | * @param int $value usage count. |
983 | 983 | */ |
984 | - public function set_uses( $value ) { |
|
984 | + public function set_uses($value) { |
|
985 | 985 | |
986 | 986 | $value = (int) $value; |
987 | 987 | |
988 | - if ( $value < 0 ) { |
|
988 | + if ($value < 0) { |
|
989 | 989 | $value = 0; |
990 | 990 | } |
991 | 991 | |
992 | - $this->set_prop( 'uses', (int) $value ); |
|
992 | + $this->set_prop('uses', (int) $value); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | /** |
@@ -998,8 +998,8 @@ discard block |
||
998 | 998 | * @since 1.0.19 |
999 | 999 | * @param int $value maximum usage count. |
1000 | 1000 | */ |
1001 | - public function set_max_uses( $value ) { |
|
1002 | - $this->set_prop( 'max_uses', absint( $value ) ); |
|
1001 | + public function set_max_uses($value) { |
|
1002 | + $this->set_prop('max_uses', absint($value)); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1008,8 +1008,8 @@ discard block |
||
1008 | 1008 | * @since 1.0.19 |
1009 | 1009 | * @param int|bool $value is single use. |
1010 | 1010 | */ |
1011 | - public function set_is_single_use( $value ) { |
|
1012 | - $this->set_prop( 'is_single_use', (bool) $value ); |
|
1011 | + public function set_is_single_use($value) { |
|
1012 | + $this->set_prop('is_single_use', (bool) $value); |
|
1013 | 1013 | } |
1014 | 1014 | |
1015 | 1015 | /** |
@@ -1018,8 +1018,8 @@ discard block |
||
1018 | 1018 | * @since 1.0.19 |
1019 | 1019 | * @param array $value items. |
1020 | 1020 | */ |
1021 | - public function set_items( $value ) { |
|
1022 | - $this->set_prop( 'items', wpinv_parse_list( $value ) ); |
|
1021 | + public function set_items($value) { |
|
1022 | + $this->set_prop('items', wpinv_parse_list($value)); |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | /** |
@@ -1028,8 +1028,8 @@ discard block |
||
1028 | 1028 | * @since 1.0.19 |
1029 | 1029 | * @param array $value items. |
1030 | 1030 | */ |
1031 | - public function set_allowed_items( $value ) { |
|
1032 | - $this->set_items( $value ); |
|
1031 | + public function set_allowed_items($value) { |
|
1032 | + $this->set_items($value); |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | /** |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | * @since 1.0.19 |
1039 | 1039 | * @param array $value items. |
1040 | 1040 | */ |
1041 | - public function set_excluded_items( $value ) { |
|
1042 | - $this->set_prop( 'excluded_items', wpinv_parse_list( $value ) ); |
|
1041 | + public function set_excluded_items($value) { |
|
1042 | + $this->set_prop('excluded_items', wpinv_parse_list($value)); |
|
1043 | 1043 | } |
1044 | 1044 | |
1045 | 1045 | /** |
@@ -1048,8 +1048,8 @@ discard block |
||
1048 | 1048 | * @since 1.0.19 |
1049 | 1049 | * @param int|bool $value is recurring. |
1050 | 1050 | */ |
1051 | - public function set_is_recurring( $value ) { |
|
1052 | - $this->set_prop( 'is_recurring', (bool) $value ); |
|
1051 | + public function set_is_recurring($value) { |
|
1052 | + $this->set_prop('is_recurring', (bool) $value); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | /** |
@@ -1058,8 +1058,8 @@ discard block |
||
1058 | 1058 | * @since 1.0.19 |
1059 | 1059 | * @param float $value minimum total. |
1060 | 1060 | */ |
1061 | - public function set_min_total( $value ) { |
|
1062 | - $this->set_prop( 'min_total', (float) wpinv_sanitize_amount( $value ) ); |
|
1061 | + public function set_min_total($value) { |
|
1062 | + $this->set_prop('min_total', (float) wpinv_sanitize_amount($value)); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | /** |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | * @since 1.0.19 |
1069 | 1069 | * @param float $value minimum total. |
1070 | 1070 | */ |
1071 | - public function set_minimum_total( $value ) { |
|
1072 | - $this->set_min_total( $value ); |
|
1071 | + public function set_minimum_total($value) { |
|
1072 | + $this->set_min_total($value); |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1078,8 +1078,8 @@ discard block |
||
1078 | 1078 | * @since 1.0.19 |
1079 | 1079 | * @param float $value maximum total. |
1080 | 1080 | */ |
1081 | - public function set_max_total( $value ) { |
|
1082 | - $this->set_prop( 'max_total', (float) wpinv_sanitize_amount( $value ) ); |
|
1081 | + public function set_max_total($value) { |
|
1082 | + $this->set_prop('max_total', (float) wpinv_sanitize_amount($value)); |
|
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | /** |
@@ -1088,23 +1088,23 @@ discard block |
||
1088 | 1088 | * @since 1.0.19 |
1089 | 1089 | * @param float $value maximum total. |
1090 | 1090 | */ |
1091 | - public function set_maximum_total( $value ) { |
|
1092 | - $this->set_max_total( $value ); |
|
1091 | + public function set_maximum_total($value) { |
|
1092 | + $this->set_max_total($value); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
1096 | 1096 | * @deprecated |
1097 | 1097 | */ |
1098 | - public function refresh(){} |
|
1098 | + public function refresh() {} |
|
1099 | 1099 | |
1100 | 1100 | /** |
1101 | 1101 | * @deprecated |
1102 | 1102 | * |
1103 | 1103 | */ |
1104 | - public function update_status( $status = 'publish' ){ |
|
1104 | + public function update_status($status = 'publish') { |
|
1105 | 1105 | |
1106 | - if ( $this->exists() && $this->get_status() != $status ) { |
|
1107 | - $this->set_status( $status ); |
|
1106 | + if ($this->exists() && $this->get_status() != $status) { |
|
1107 | + $this->set_status($status); |
|
1108 | 1108 | $this->save(); |
1109 | 1109 | } |
1110 | 1110 | |
@@ -1124,9 +1124,9 @@ discard block |
||
1124 | 1124 | * |
1125 | 1125 | * @since 1.0.15 |
1126 | 1126 | */ |
1127 | - public function exists(){ |
|
1127 | + public function exists() { |
|
1128 | 1128 | $id = $this->get_id(); |
1129 | - return ! empty( $id ); |
|
1129 | + return !empty($id); |
|
1130 | 1130 | } |
1131 | 1131 | |
1132 | 1132 | /** |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | * @since 1.0.15 |
1138 | 1138 | * @return bool |
1139 | 1139 | */ |
1140 | - public function is_type( $type ) { |
|
1140 | + public function is_type($type) { |
|
1141 | 1141 | return $this->get_type() == $type; |
1142 | 1142 | } |
1143 | 1143 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | public function has_limit() { |
1161 | 1161 | $limit = $this->get_max_uses(); |
1162 | - return ! empty( $limit ); |
|
1162 | + return !empty($limit); |
|
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | /** |
@@ -1180,13 +1180,13 @@ discard block |
||
1180 | 1180 | */ |
1181 | 1181 | public function has_exceeded_limit() { |
1182 | 1182 | |
1183 | - if ( ! $this->has_limit() || ! $this->has_uses() ) { |
|
1184 | - $exceeded = false ; |
|
1183 | + if (!$this->has_limit() || !$this->has_uses()) { |
|
1184 | + $exceeded = false; |
|
1185 | 1185 | } else { |
1186 | 1186 | $exceeded = (int) $this->get_max_uses() <= $this->get_uses(); |
1187 | 1187 | } |
1188 | 1188 | |
1189 | - return apply_filters( 'wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code() ); |
|
1189 | + return apply_filters('wpinv_is_discount_maxed_out', $exceeded, $this->get_id(), $this, $this->get_code()); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | /** |
@@ -1197,7 +1197,7 @@ discard block |
||
1197 | 1197 | */ |
1198 | 1198 | public function has_expiration_date() { |
1199 | 1199 | $date = $this->get_expiration_date(); |
1200 | - return ! empty( $date ); |
|
1200 | + return !empty($date); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | 1203 | /** |
@@ -1207,8 +1207,8 @@ discard block |
||
1207 | 1207 | * @return bool |
1208 | 1208 | */ |
1209 | 1209 | public function is_expired() { |
1210 | - $expired = $this->has_expiration_date() ? current_time( 'timestamp' ) > strtotime( $this->get_expiration_date() ) : false; |
|
1211 | - return apply_filters( 'wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code() ); |
|
1210 | + $expired = $this->has_expiration_date() ? current_time('timestamp') > strtotime($this->get_expiration_date()) : false; |
|
1211 | + return apply_filters('wpinv_is_discount_expired', $expired, $this->get_id(), $this, $this->get_code()); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | /** |
@@ -1219,7 +1219,7 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | public function has_start_date() { |
1221 | 1221 | $date = $this->get_start_date(); |
1222 | - return ! empty( $date ); |
|
1222 | + return !empty($date); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | /** |
@@ -1229,8 +1229,8 @@ discard block |
||
1229 | 1229 | * @return bool |
1230 | 1230 | */ |
1231 | 1231 | public function has_started() { |
1232 | - $started = $this->has_start_date() ? true : current_time( 'timestamp' ) > strtotime( $this->get_start_date() ); |
|
1233 | - return apply_filters( 'wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code() ); |
|
1232 | + $started = $this->has_start_date() ? true : current_time('timestamp') > strtotime($this->get_start_date()); |
|
1233 | + return apply_filters('wpinv_is_discount_started', $started, $this->get_id(), $this, $this->get_code()); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | /** |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | */ |
1242 | 1242 | public function has_allowed_items() { |
1243 | 1243 | $allowed_items = $this->get_allowed_items(); |
1244 | - return ! empty( $allowed_items ); |
|
1244 | + return !empty($allowed_items); |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | /** |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | */ |
1253 | 1253 | public function has_excluded_items() { |
1254 | 1254 | $excluded_items = $this->get_excluded_items(); |
1255 | - return ! empty( $excluded_items ); |
|
1255 | + return !empty($excluded_items); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | /** |
@@ -1262,17 +1262,17 @@ discard block |
||
1262 | 1262 | * @since 1.0.15 |
1263 | 1263 | * @return boolean |
1264 | 1264 | */ |
1265 | - public function is_valid_for_items( $item_ids ) { |
|
1265 | + public function is_valid_for_items($item_ids) { |
|
1266 | 1266 | |
1267 | - $item_ids = wp_parse_id_list( $item_ids ); |
|
1268 | - $included = array_intersect( $item_ids, $this->get_allowed_items() ); |
|
1269 | - $excluded = array_intersect( $item_ids, $this->get_excluded_items() ); |
|
1267 | + $item_ids = wp_parse_id_list($item_ids); |
|
1268 | + $included = array_intersect($item_ids, $this->get_allowed_items()); |
|
1269 | + $excluded = array_intersect($item_ids, $this->get_excluded_items()); |
|
1270 | 1270 | |
1271 | - if ( $this->has_excluded_items() && ! empty( $excluded ) ) { |
|
1271 | + if ($this->has_excluded_items() && !empty($excluded)) { |
|
1272 | 1272 | return false; |
1273 | 1273 | } |
1274 | 1274 | |
1275 | - if ( $this->has_allowed_items() && empty( $included ) ) { |
|
1275 | + if ($this->has_allowed_items() && empty($included)) { |
|
1276 | 1276 | return false; |
1277 | 1277 | } |
1278 | 1278 | |
@@ -1286,8 +1286,8 @@ discard block |
||
1286 | 1286 | * @since 1.0.15 |
1287 | 1287 | * @return boolean |
1288 | 1288 | */ |
1289 | - public function is_valid_for_amount( $amount ) { |
|
1290 | - return $this->is_minimum_amount_met( $amount ) && $this->is_maximum_amount_met( $amount ); |
|
1289 | + public function is_valid_for_amount($amount) { |
|
1290 | + return $this->is_minimum_amount_met($amount) && $this->is_maximum_amount_met($amount); |
|
1291 | 1291 | } |
1292 | 1292 | |
1293 | 1293 | /** |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | */ |
1299 | 1299 | public function has_minimum_amount() { |
1300 | 1300 | $minimum = $this->get_minimum_total(); |
1301 | - return ! empty( $minimum ); |
|
1301 | + return !empty($minimum); |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | /** |
@@ -1308,10 +1308,10 @@ discard block |
||
1308 | 1308 | * @since 1.0.15 |
1309 | 1309 | * @return boolean |
1310 | 1310 | */ |
1311 | - public function is_minimum_amount_met( $amount ) { |
|
1312 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
1313 | - $min_met= ! ( $this->has_minimum_amount() && $amount < floatval( wpinv_sanitize_amount( $this->get_minimum_total() ) ) ); |
|
1314 | - return apply_filters( 'wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount ); |
|
1311 | + public function is_minimum_amount_met($amount) { |
|
1312 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
1313 | + $min_met = !($this->has_minimum_amount() && $amount < floatval(wpinv_sanitize_amount($this->get_minimum_total()))); |
|
1314 | + return apply_filters('wpinv_is_discount_min_met', $min_met, $this->get_id(), $this, $this->get_code(), $amount); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | /** |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | */ |
1323 | 1323 | public function has_maximum_amount() { |
1324 | 1324 | $maximum = $this->get_maximum_total(); |
1325 | - return ! empty( $maximum ); |
|
1325 | + return !empty($maximum); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | /** |
@@ -1332,10 +1332,10 @@ discard block |
||
1332 | 1332 | * @since 1.0.15 |
1333 | 1333 | * @return boolean |
1334 | 1334 | */ |
1335 | - public function is_maximum_amount_met( $amount ) { |
|
1336 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
1337 | - $max_met= ! ( $this->has_maximum_amount() && $amount > floatval( wpinv_sanitize_amount( $this->get_maximum_total() ) ) ); |
|
1338 | - return apply_filters( 'wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount ); |
|
1335 | + public function is_maximum_amount_met($amount) { |
|
1336 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
1337 | + $max_met = !($this->has_maximum_amount() && $amount > floatval(wpinv_sanitize_amount($this->get_maximum_total()))); |
|
1338 | + return apply_filters('wpinv_is_discount_max_met', $max_met, $this->get_id(), $this, $this->get_code(), $amount); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | /** |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | */ |
1347 | 1347 | public function is_recurring() { |
1348 | 1348 | $recurring = $this->get_is_recurring(); |
1349 | - return ! empty( $recurring ); |
|
1349 | + return !empty($recurring); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | /** |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | public function is_single_use() { |
1359 | 1359 | $usage = $this->get_is_single_use(); |
1360 | - return ! empty( $usage ); |
|
1360 | + return !empty($usage); |
|
1361 | 1361 | } |
1362 | 1362 | |
1363 | 1363 | /** |
@@ -1367,37 +1367,37 @@ discard block |
||
1367 | 1367 | * @since 1.0.15 |
1368 | 1368 | * @return boolean |
1369 | 1369 | */ |
1370 | - public function is_valid_for_user( $user ) { |
|
1370 | + public function is_valid_for_user($user) { |
|
1371 | 1371 | |
1372 | 1372 | // Ensure that the discount is single use. |
1373 | - if ( empty( $user ) || ! $this->is_single_use() ) { |
|
1373 | + if (empty($user) || !$this->is_single_use()) { |
|
1374 | 1374 | return true; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | // Prepare the user id. |
1378 | 1378 | $user_id = 0; |
1379 | - if ( is_numeric( $user ) ) { |
|
1380 | - $user_id = absint( $user ); |
|
1381 | - } else if ( is_email( $user ) && $user_data = get_user_by( 'email', $user ) ) { |
|
1379 | + if (is_numeric($user)) { |
|
1380 | + $user_id = absint($user); |
|
1381 | + } else if (is_email($user) && $user_data = get_user_by('email', $user)) { |
|
1382 | 1382 | $user_id = $user_data->ID; |
1383 | - } else if ( $user_data = get_user_by( 'login', $user ) ) { |
|
1383 | + } else if ($user_data = get_user_by('login', $user)) { |
|
1384 | 1384 | $user_id = $user_data->ID; |
1385 | 1385 | } |
1386 | 1386 | |
1387 | 1387 | // Ensure that we have a user. |
1388 | - if ( empty( $user_id ) ) { |
|
1388 | + if (empty($user_id)) { |
|
1389 | 1389 | return true; |
1390 | 1390 | } |
1391 | 1391 | |
1392 | 1392 | // Get all payments with matching user id. |
1393 | - $payments = wpinv_get_invoices( array( 'user' => $user_id, 'limit' => false, 'paginate' => false ) ); |
|
1394 | - $code = strtolower( $this->get_code() ); |
|
1393 | + $payments = wpinv_get_invoices(array('user' => $user_id, 'limit' => false, 'paginate' => false)); |
|
1394 | + $code = strtolower($this->get_code()); |
|
1395 | 1395 | |
1396 | 1396 | // For each payment... |
1397 | - foreach ( $payments as $payment ) { |
|
1397 | + foreach ($payments as $payment) { |
|
1398 | 1398 | |
1399 | 1399 | // Only check for paid invoices. |
1400 | - if ( $payment->is_paid() && strtolower( $payment->get_discount_code() ) == $code ) { |
|
1400 | + if ($payment->is_paid() && strtolower($payment->get_discount_code()) == $code) { |
|
1401 | 1401 | return false; |
1402 | 1402 | } |
1403 | 1403 | |
@@ -1423,24 +1423,24 @@ discard block |
||
1423 | 1423 | * @param int $by The number of usages to increas by. |
1424 | 1424 | * @return int |
1425 | 1425 | */ |
1426 | - public function increase_usage( $by = 1 ) { |
|
1426 | + public function increase_usage($by = 1) { |
|
1427 | 1427 | |
1428 | 1428 | // Abort if zero. |
1429 | - if ( empty( $by ) ) { |
|
1429 | + if (empty($by)) { |
|
1430 | 1430 | return; |
1431 | 1431 | } |
1432 | 1432 | |
1433 | 1433 | // Increase the usage. |
1434 | - $this->set_uses( $this->get_uses() + (int) $by ); |
|
1434 | + $this->set_uses($this->get_uses() + (int) $by); |
|
1435 | 1435 | |
1436 | 1436 | // Save the discount. |
1437 | 1437 | $this->save(); |
1438 | 1438 | |
1439 | 1439 | // Fire relevant hooks. |
1440 | - if( (int) $by > 0 ) { |
|
1441 | - do_action( 'wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) ); |
|
1440 | + if ((int) $by > 0) { |
|
1441 | + do_action('wpinv_discount_increase_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by)); |
|
1442 | 1442 | } else { |
1443 | - do_action( 'wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint( $by ) ); |
|
1443 | + do_action('wpinv_discount_decrease_use_count', $this->get_uses(), $this->get_id(), $this->get_code(), absint($by)); |
|
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | // Return the number of times the discount has been used. |
@@ -1464,7 +1464,7 @@ discard block |
||
1464 | 1464 | * @param float $amount |
1465 | 1465 | * @return float |
1466 | 1466 | */ |
1467 | - public function get_discounted_amount( $amount ) { |
|
1467 | + public function get_discounted_amount($amount) { |
|
1468 | 1468 | |
1469 | 1469 | // Convert amount to float. |
1470 | 1470 | $amount = (float) $amount; |
@@ -1472,29 +1472,29 @@ discard block |
||
1472 | 1472 | // Get discount amount. |
1473 | 1473 | $discount_amount = $this->get_amount(); |
1474 | 1474 | |
1475 | - if ( empty( $discount_amount ) ) { |
|
1475 | + if (empty($discount_amount)) { |
|
1476 | 1476 | return 0; |
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | // Format the amount. |
1480 | - $discount_amount = floatval( wpinv_sanitize_amount( $discount_amount ) ); |
|
1480 | + $discount_amount = floatval(wpinv_sanitize_amount($discount_amount)); |
|
1481 | 1481 | |
1482 | 1482 | // If this is a percentage discount. |
1483 | - if ( $this->is_type( 'percent' ) ) { |
|
1484 | - $discount_amount = $amount * ( $discount_amount / 100 ); |
|
1483 | + if ($this->is_type('percent')) { |
|
1484 | + $discount_amount = $amount * ($discount_amount / 100); |
|
1485 | 1485 | } |
1486 | 1486 | |
1487 | 1487 | // Discount can not be less than zero... |
1488 | - if ( $discount_amount < 0 ) { |
|
1488 | + if ($discount_amount < 0) { |
|
1489 | 1489 | $discount_amount = 0; |
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | // ... or more than the amount. |
1493 | - if ( $discount_amount > $amount ) { |
|
1493 | + if ($discount_amount > $amount) { |
|
1494 | 1494 | $discount_amount = $amount; |
1495 | 1495 | } |
1496 | 1496 | |
1497 | - return apply_filters( 'wpinv_discount_total_discount_amount', $discount_amount, $amount, $this ); |
|
1497 | + return apply_filters('wpinv_discount_total_discount_amount', $discount_amount, $amount, $this); |
|
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | |
34 | 34 | // Validate VAT number. |
35 | - $this->validate_vat( $submission ); |
|
35 | + $this->validate_vat($submission); |
|
36 | 36 | |
37 | - if ( $this->skip_taxes ) { |
|
37 | + if ($this->skip_taxes) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - foreach ( $submission->get_items() as $item ) { |
|
42 | - $this->process_item_tax( $item, $submission ); |
|
41 | + foreach ($submission->get_items() as $item) { |
|
42 | + $this->process_item_tax($item, $submission); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Process any existing invoice taxes. |
46 | - if ( $submission->has_invoice() ) { |
|
47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
46 | + if ($submission->has_invoice()) { |
|
47 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * @param GetPaid_Form_Item $item |
57 | 57 | * @param GetPaid_Payment_Form_Submission $submission |
58 | 58 | */ |
59 | - public function process_item_tax( $item, $submission ) { |
|
59 | + public function process_item_tax($item, $submission) { |
|
60 | 60 | |
61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
61 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
62 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
63 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
64 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
65 | 65 | |
66 | - foreach ( $taxes as $name => $amount ) { |
|
67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
66 | + foreach ($taxes as $name => $amount) { |
|
67 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
68 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
69 | 69 | |
70 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
71 | - $this->taxes[ $name ] = $tax; |
|
70 | + if (!isset($this->taxes[$name])) { |
|
71 | + $this->taxes[$name] = $tax; |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
76 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
75 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
76 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @since 1.0.19 |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - public function has_digital_item( $submission ) { |
|
89 | + public function has_digital_item($submission) { |
|
90 | 90 | |
91 | - foreach ( $submission->get_items() as $item ) { |
|
91 | + foreach ($submission->get_items() as $item) { |
|
92 | 92 | |
93 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
93 | + if ('digital' == $item->get_vat_rule()) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return bool |
107 | 107 | */ |
108 | 108 | public static function is_eu_store() { |
109 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
109 | + return self::is_eu_country(wpinv_get_default_country()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @since 1.0.19 |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public static function is_eu_country( $country ) { |
|
120 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
119 | + public static function is_eu_country($country) { |
|
120 | + return getpaid_is_eu_state($country) || getpaid_is_gst_country($country); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @since 1.0.19 |
128 | 128 | * @return bool |
129 | 129 | */ |
130 | - public static function is_eu_transaction( $customer_country ) { |
|
131 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
130 | + public static function is_eu_transaction($customer_country) { |
|
131 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @since 1.0.19 |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function get_vat_number( $submission ) { |
|
141 | + public function get_vat_number($submission) { |
|
142 | 142 | |
143 | 143 | // Retrieve from the posted number. |
144 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
145 | - if ( ! is_null( $vat_number ) ) { |
|
146 | - return wpinv_clean( $vat_number ); |
|
144 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
145 | + if (!is_null($vat_number)) { |
|
146 | + return wpinv_clean($vat_number); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | * @since 1.0.19 |
157 | 157 | * @return string |
158 | 158 | */ |
159 | - public function get_company( $submission ) { |
|
159 | + public function get_company($submission) { |
|
160 | 160 | |
161 | 161 | // Retrieve from the posted data. |
162 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
163 | - if ( ! empty( $company ) ) { |
|
164 | - return wpinv_clean( $company ); |
|
162 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
163 | + if (!empty($company)) { |
|
164 | + return wpinv_clean($company); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Retrieve from the invoice. |
@@ -176,10 +176,10 @@ discard block |
||
176 | 176 | * @since 1.0.19 |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
179 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
180 | 180 | |
181 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
182 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
181 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
182 | + $prevent_b2c = !empty($prevent_b2c); |
|
183 | 183 | $is_eu = $ip_in_eu || $country_in_eu; |
184 | 184 | |
185 | 185 | return $prevent_b2c && $is_eu; |
@@ -191,45 +191,45 @@ discard block |
||
191 | 191 | * @param GetPaid_Payment_Form_Submission $submission |
192 | 192 | * @since 1.0.19 |
193 | 193 | */ |
194 | - public function validate_vat( $submission ) { |
|
194 | + public function validate_vat($submission) { |
|
195 | 195 | |
196 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
196 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
197 | 197 | |
198 | 198 | // Abort if we are not validating vat numbers. |
199 | - if ( ! $in_eu ) { |
|
199 | + if (!$in_eu) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Prepare variables. |
204 | - $vat_number = $this->get_vat_number( $submission ); |
|
204 | + $vat_number = $this->get_vat_number($submission); |
|
205 | 205 | $ip_country = getpaid_get_ip_country(); |
206 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
207 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
206 | + $is_eu = $this->is_eu_country($submission->country); |
|
207 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
208 | 208 | |
209 | 209 | // Maybe abort early for initial fetches. |
210 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
210 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
211 | 211 | return; |
212 | 212 | } |
213 | 213 | |
214 | 214 | // If we're preventing business to consumer purchases, |
215 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
215 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
216 | 216 | |
217 | 217 | // Ensure that a vat number has been specified. |
218 | 218 | throw new Exception( |
219 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
219 | + __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing') |
|
220 | 220 | ); |
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | - if ( empty( $vat_number ) ) { |
|
224 | + if (empty($vat_number)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
229 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
228 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
229 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
230 | 230 | } |
231 | 231 | |
232 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
232 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
233 | 233 | return; |
234 | 234 | } |
235 | 235 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if (!defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
119 | 119 | */ |
120 | - public function __construct( $read = 0 ) { |
|
121 | - $this->data = array_merge( $this->data, $this->extra_data ); |
|
120 | + public function __construct($read = 0) { |
|
121 | + $this->data = array_merge($this->data, $this->extra_data); |
|
122 | 122 | $this->default_data = $this->data; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function __sleep() { |
131 | - return array( 'id' ); |
|
131 | + return array('id'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * If the object no longer exists, remove the ID. |
138 | 138 | */ |
139 | 139 | public function __wakeup() { |
140 | - $this->__construct( absint( $this->id ) ); |
|
140 | + $this->__construct(absint($this->id)); |
|
141 | 141 | |
142 | - if ( ! empty( $this->last_error ) ) { |
|
143 | - $this->set_id( 0 ); |
|
142 | + if (!empty($this->last_error)) { |
|
143 | + $this->set_id(0); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function __clone() { |
154 | 154 | $this->maybe_read_meta_data(); |
155 | - if ( ! empty( $this->meta_data ) ) { |
|
156 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | - $this->meta_data[ $array_key ] = clone $meta; |
|
158 | - if ( ! empty( $meta->id ) ) { |
|
159 | - $this->meta_data[ $array_key ]->id = null; |
|
155 | + if (!empty($this->meta_data)) { |
|
156 | + foreach ($this->meta_data as $array_key => $meta) { |
|
157 | + $this->meta_data[$array_key] = clone $meta; |
|
158 | + if (!empty($meta->id)) { |
|
159 | + $this->meta_data[$array_key]->id = null; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_status( $context = 'view' ) { |
|
203 | - return $this->get_prop( 'status', $context ); |
|
202 | + public function get_status($context = 'view') { |
|
203 | + return $this->get_prop('status', $context); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * @param bool $force_delete Should the data be deleted permanently. |
211 | 211 | * @return bool result |
212 | 212 | */ |
213 | - public function delete( $force_delete = false ) { |
|
214 | - if ( $this->data_store && $this->exists() ) { |
|
215 | - $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | - $this->set_id( 0 ); |
|
213 | + public function delete($force_delete = false) { |
|
214 | + if ($this->data_store && $this->exists()) { |
|
215 | + $this->data_store->delete($this, array('force_delete' => $force_delete)); |
|
216 | + $this->set_id(0); |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return int |
227 | 227 | */ |
228 | 228 | public function save() { |
229 | - if ( ! $this->data_store ) { |
|
229 | + if (!$this->data_store) { |
|
230 | 230 | return $this->get_id(); |
231 | 231 | } |
232 | 232 | |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @param GetPaid_Data $this The object being saved. |
237 | 237 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
238 | 238 | */ |
239 | - do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
239 | + do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
240 | 240 | |
241 | - if ( $this->get_id() ) { |
|
242 | - $this->data_store->update( $this ); |
|
241 | + if ($this->get_id()) { |
|
242 | + $this->data_store->update($this); |
|
243 | 243 | } else { |
244 | - $this->data_store->create( $this ); |
|
244 | + $this->data_store->create($this); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param GetPaid_Data $this The object being saved. |
251 | 251 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
252 | 252 | */ |
253 | - do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
253 | + do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
254 | 254 | |
255 | 255 | return $this->get_id(); |
256 | 256 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return string Data in JSON format. |
263 | 263 | */ |
264 | 264 | public function __toString() { |
265 | - return wp_json_encode( $this->get_data() ); |
|
265 | + return wp_json_encode($this->get_data()); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return array |
273 | 273 | */ |
274 | 274 | public function get_data() { |
275 | - return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
275 | + return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data())); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return array |
283 | 283 | */ |
284 | 284 | public function get_data_keys() { |
285 | - return array_keys( $this->data ); |
|
285 | + return array_keys($this->data); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return array |
293 | 293 | */ |
294 | 294 | public function get_extra_data_keys() { |
295 | - return array_keys( $this->extra_data ); |
|
295 | + return array_keys($this->extra_data); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param mixed $meta Meta value to check. |
303 | 303 | * @return bool |
304 | 304 | */ |
305 | - protected function filter_null_meta( $meta ) { |
|
306 | - return ! is_null( $meta->value ); |
|
305 | + protected function filter_null_meta($meta) { |
|
306 | + return !is_null($meta->value); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_meta_data() { |
316 | 316 | $this->maybe_read_meta_data(); |
317 | - return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
317 | + return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta'))); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * @param string $key Key to check. |
325 | 325 | * @return bool true if it's an internal key, false otherwise |
326 | 326 | */ |
327 | - protected function is_internal_meta_key( $key ) { |
|
328 | - $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
327 | + protected function is_internal_meta_key($key) { |
|
328 | + $internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true); |
|
329 | 329 | |
330 | - if ( ! $internal_meta_key ) { |
|
330 | + if (!$internal_meta_key) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
334 | - $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
334 | + $has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key)); |
|
335 | 335 | |
336 | - if ( ! $has_setter_or_getter ) { |
|
336 | + if (!$has_setter_or_getter) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | 340 | /* translators: %s: $key Key to check */ |
341 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
341 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
342 | 342 | |
343 | 343 | return true; |
344 | 344 | } |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | * @access public |
353 | 353 | * |
354 | 354 | */ |
355 | - public function __set( $key, $value ) { |
|
355 | + public function __set($key, $value) { |
|
356 | 356 | |
357 | - if ( 'id' == strtolower( $key ) ) { |
|
358 | - return $this->set_id( $value ); |
|
357 | + if ('id' == strtolower($key)) { |
|
358 | + return $this->set_id($value); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( method_exists( $this, "set_$key") ) { |
|
361 | + if (method_exists($this, "set_$key")) { |
|
362 | 362 | |
363 | 363 | /* translators: %s: $key Key to set */ |
364 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
364 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
365 | 365 | |
366 | - call_user_func( array( $this, "set_$key" ), $value ); |
|
366 | + call_user_func(array($this, "set_$key"), $value); |
|
367 | 367 | } else { |
368 | - $this->set_prop( $key, $value ); |
|
368 | + $this->set_prop($key, $value); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
@@ -373,25 +373,25 @@ discard block |
||
373 | 373 | /** |
374 | 374 | * Margic method for retrieving a property. |
375 | 375 | */ |
376 | - public function __get( $key ) { |
|
376 | + public function __get($key) { |
|
377 | 377 | |
378 | 378 | // Check if we have a helper method for that. |
379 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
379 | + if (method_exists($this, 'get_' . $key)) { |
|
380 | 380 | |
381 | - if ( 'post_type' != $key ) { |
|
381 | + if ('post_type' != $key) { |
|
382 | 382 | /* translators: %s: $key Key to set */ |
383 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
383 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
384 | 384 | } |
385 | 385 | |
386 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
386 | + return call_user_func(array($this, 'get_' . $key)); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Check if the key is in the associated $post object. |
390 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
390 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
391 | 391 | return $this->post->$key; |
392 | 392 | } |
393 | 393 | |
394 | - return $this->get_prop( $key ); |
|
394 | + return $this->get_prop($key); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | * @param string $context What the value is for. Valid values are view and edit. |
405 | 405 | * @return mixed |
406 | 406 | */ |
407 | - public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
407 | + public function get_meta($key = '', $single = true, $context = 'view') { |
|
408 | 408 | |
409 | 409 | // Check if this is an internal meta key. |
410 | - $_key = str_replace( '_wpinv', '', $key ); |
|
411 | - $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
410 | + $_key = str_replace('_wpinv', '', $key); |
|
411 | + $_key = str_replace('wpinv', '', $_key); |
|
412 | + if ($this->is_internal_meta_key($key)) { |
|
413 | 413 | $function = 'get_' . $_key; |
414 | 414 | |
415 | - if ( is_callable( array( $this, $function ) ) ) { |
|
415 | + if (is_callable(array($this, $function))) { |
|
416 | 416 | return $this->{$function}(); |
417 | 417 | } |
418 | 418 | } |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | // Read the meta data if not yet read. |
421 | 421 | $this->maybe_read_meta_data(); |
422 | 422 | $meta_data = $this->get_meta_data(); |
423 | - $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
423 | + $array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true); |
|
424 | 424 | $value = $single ? '' : array(); |
425 | 425 | |
426 | - if ( ! empty( $array_keys ) ) { |
|
426 | + if (!empty($array_keys)) { |
|
427 | 427 | // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
428 | - if ( $single ) { |
|
429 | - $value = $meta_data[ current( $array_keys ) ]->value; |
|
428 | + if ($single) { |
|
429 | + $value = $meta_data[current($array_keys)]->value; |
|
430 | 430 | } else { |
431 | - $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
431 | + $value = array_intersect_key($meta_data, array_flip($array_keys)); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( 'view' === $context ) { |
|
436 | - $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
435 | + if ('view' === $context) { |
|
436 | + $value = apply_filters($this->get_hook_prefix() . $key, $value, $this); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $value; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * @param string $key Meta Key. |
447 | 447 | * @return boolean |
448 | 448 | */ |
449 | - public function meta_exists( $key = '' ) { |
|
449 | + public function meta_exists($key = '') { |
|
450 | 450 | $this->maybe_read_meta_data(); |
451 | - $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | - return in_array( $key, $array_keys, true ); |
|
451 | + $array_keys = wp_list_pluck($this->get_meta_data(), 'key'); |
|
452 | + return in_array($key, $array_keys, true); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * @since 1.0.19 |
459 | 459 | * @param array $data Key/Value pairs. |
460 | 460 | */ |
461 | - public function set_meta_data( $data ) { |
|
462 | - if ( ! empty( $data ) && is_array( $data ) ) { |
|
461 | + public function set_meta_data($data) { |
|
462 | + if (!empty($data) && is_array($data)) { |
|
463 | 463 | $this->maybe_read_meta_data(); |
464 | - foreach ( $data as $meta ) { |
|
464 | + foreach ($data as $meta) { |
|
465 | 465 | $meta = (array) $meta; |
466 | - if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
466 | + if (isset($meta['key'], $meta['value'], $meta['id'])) { |
|
467 | 467 | $this->meta_data[] = new GetPaid_Meta_Data( |
468 | 468 | array( |
469 | 469 | 'id' => $meta['id'], |
@@ -485,18 +485,18 @@ discard block |
||
485 | 485 | * @param string|array $value Meta value. |
486 | 486 | * @param bool $unique Should this be a unique key?. |
487 | 487 | */ |
488 | - public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
488 | + public function add_meta_data($key, $value, $unique = false) { |
|
489 | + if ($this->is_internal_meta_key($key)) { |
|
490 | 490 | $function = 'set_' . $key; |
491 | 491 | |
492 | - if ( is_callable( array( $this, $function ) ) ) { |
|
493 | - return $this->{$function}( $value ); |
|
492 | + if (is_callable(array($this, $function))) { |
|
493 | + return $this->{$function}($value); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | $this->maybe_read_meta_data(); |
498 | - if ( $unique ) { |
|
499 | - $this->delete_meta_data( $key ); |
|
498 | + if ($unique) { |
|
499 | + $this->delete_meta_data($key); |
|
500 | 500 | } |
501 | 501 | $this->meta_data[] = new GetPaid_Meta_Data( |
502 | 502 | array( |
@@ -517,12 +517,12 @@ discard block |
||
517 | 517 | * @param string|array $value Meta value. |
518 | 518 | * @param int $meta_id Meta ID. |
519 | 519 | */ |
520 | - public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
521 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
520 | + public function update_meta_data($key, $value, $meta_id = 0) { |
|
521 | + if ($this->is_internal_meta_key($key)) { |
|
522 | 522 | $function = 'set_' . $key; |
523 | 523 | |
524 | - if ( is_callable( array( $this, $function ) ) ) { |
|
525 | - return $this->{$function}( $value ); |
|
524 | + if (is_callable(array($this, $function))) { |
|
525 | + return $this->{$function}($value); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
@@ -530,33 +530,33 @@ discard block |
||
530 | 530 | |
531 | 531 | $array_key = false; |
532 | 532 | |
533 | - if ( $meta_id ) { |
|
534 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
535 | - $array_key = $array_keys ? current( $array_keys ) : false; |
|
533 | + if ($meta_id) { |
|
534 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true); |
|
535 | + $array_key = $array_keys ? current($array_keys) : false; |
|
536 | 536 | } else { |
537 | 537 | // Find matches by key. |
538 | 538 | $matches = array(); |
539 | - foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
540 | - if ( $meta->key === $key ) { |
|
539 | + foreach ($this->meta_data as $meta_data_array_key => $meta) { |
|
540 | + if ($meta->key === $key) { |
|
541 | 541 | $matches[] = $meta_data_array_key; |
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | - if ( ! empty( $matches ) ) { |
|
545 | + if (!empty($matches)) { |
|
546 | 546 | // Set matches to null so only one key gets the new value. |
547 | - foreach ( $matches as $meta_data_array_key ) { |
|
548 | - $this->meta_data[ $meta_data_array_key ]->value = null; |
|
547 | + foreach ($matches as $meta_data_array_key) { |
|
548 | + $this->meta_data[$meta_data_array_key]->value = null; |
|
549 | 549 | } |
550 | - $array_key = current( $matches ); |
|
550 | + $array_key = current($matches); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
554 | - if ( false !== $array_key ) { |
|
555 | - $meta = $this->meta_data[ $array_key ]; |
|
554 | + if (false !== $array_key) { |
|
555 | + $meta = $this->meta_data[$array_key]; |
|
556 | 556 | $meta->key = $key; |
557 | 557 | $meta->value = $value; |
558 | 558 | } else { |
559 | - $this->add_meta_data( $key, $value, true ); |
|
559 | + $this->add_meta_data($key, $value, true); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
@@ -566,13 +566,13 @@ discard block |
||
566 | 566 | * @since 1.0.19 |
567 | 567 | * @param string $key Meta key. |
568 | 568 | */ |
569 | - public function delete_meta_data( $key ) { |
|
569 | + public function delete_meta_data($key) { |
|
570 | 570 | $this->maybe_read_meta_data(); |
571 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
571 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true); |
|
572 | 572 | |
573 | - if ( $array_keys ) { |
|
574 | - foreach ( $array_keys as $array_key ) { |
|
575 | - $this->meta_data[ $array_key ]->value = null; |
|
573 | + if ($array_keys) { |
|
574 | + foreach ($array_keys as $array_key) { |
|
575 | + $this->meta_data[$array_key]->value = null; |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | } |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | * @since 1.0.19 |
584 | 584 | * @param int $mid Meta ID. |
585 | 585 | */ |
586 | - public function delete_meta_data_by_mid( $mid ) { |
|
586 | + public function delete_meta_data_by_mid($mid) { |
|
587 | 587 | $this->maybe_read_meta_data(); |
588 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
588 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true); |
|
589 | 589 | |
590 | - if ( $array_keys ) { |
|
591 | - foreach ( $array_keys as $array_key ) { |
|
592 | - $this->meta_data[ $array_key ]->value = null; |
|
590 | + if ($array_keys) { |
|
591 | + foreach ($array_keys as $array_key) { |
|
592 | + $this->meta_data[$array_key]->value = null; |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | */ |
602 | 602 | protected function maybe_read_meta_data() { |
603 | - if ( is_null( $this->meta_data ) ) { |
|
603 | + if (is_null($this->meta_data)) { |
|
604 | 604 | $this->read_meta_data(); |
605 | 605 | } |
606 | 606 | } |
@@ -612,42 +612,42 @@ discard block |
||
612 | 612 | * @since 1.0.19 |
613 | 613 | * @param bool $force_read True to force a new DB read (and update cache). |
614 | 614 | */ |
615 | - public function read_meta_data( $force_read = false ) { |
|
615 | + public function read_meta_data($force_read = false) { |
|
616 | 616 | |
617 | 617 | // Reset meta data. |
618 | 618 | $this->meta_data = array(); |
619 | 619 | |
620 | 620 | // Maybe abort early. |
621 | - if ( ! $this->get_id() || ! $this->data_store ) { |
|
621 | + if (!$this->get_id() || !$this->data_store) { |
|
622 | 622 | return; |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Only read from cache if the cache key is set. |
626 | 626 | $cache_key = null; |
627 | - if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
628 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
629 | - $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
627 | + if (!$force_read && !empty($this->cache_group)) { |
|
628 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
629 | + $raw_meta_data = wp_cache_get($cache_key, $this->cache_group); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | // Should we force read? |
633 | - if ( empty( $raw_meta_data ) ) { |
|
634 | - $raw_meta_data = $this->data_store->read_meta( $this ); |
|
633 | + if (empty($raw_meta_data)) { |
|
634 | + $raw_meta_data = $this->data_store->read_meta($this); |
|
635 | 635 | |
636 | - if ( ! empty( $cache_key ) ) { |
|
637 | - wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
636 | + if (!empty($cache_key)) { |
|
637 | + wp_cache_set($cache_key, $raw_meta_data, $this->cache_group); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | } |
641 | 641 | |
642 | 642 | // Set meta data. |
643 | - if ( is_array( $raw_meta_data ) ) { |
|
643 | + if (is_array($raw_meta_data)) { |
|
644 | 644 | |
645 | - foreach ( $raw_meta_data as $meta ) { |
|
645 | + foreach ($raw_meta_data as $meta) { |
|
646 | 646 | $this->meta_data[] = new GetPaid_Meta_Data( |
647 | 647 | array( |
648 | 648 | 'id' => (int) $meta->meta_id, |
649 | 649 | 'key' => $meta->meta_key, |
650 | - 'value' => maybe_unserialize( $meta->meta_value ), |
|
650 | + 'value' => maybe_unserialize($meta->meta_value), |
|
651 | 651 | ) |
652 | 652 | ); |
653 | 653 | } |
@@ -662,28 +662,28 @@ discard block |
||
662 | 662 | * @since 1.0.19 |
663 | 663 | */ |
664 | 664 | public function save_meta_data() { |
665 | - if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
665 | + if (!$this->data_store || is_null($this->meta_data)) { |
|
666 | 666 | return; |
667 | 667 | } |
668 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
669 | - if ( is_null( $meta->value ) ) { |
|
670 | - if ( ! empty( $meta->id ) ) { |
|
671 | - $this->data_store->delete_meta( $this, $meta ); |
|
672 | - unset( $this->meta_data[ $array_key ] ); |
|
668 | + foreach ($this->meta_data as $array_key => $meta) { |
|
669 | + if (is_null($meta->value)) { |
|
670 | + if (!empty($meta->id)) { |
|
671 | + $this->data_store->delete_meta($this, $meta); |
|
672 | + unset($this->meta_data[$array_key]); |
|
673 | 673 | } |
674 | - } elseif ( empty( $meta->id ) ) { |
|
675 | - $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
674 | + } elseif (empty($meta->id)) { |
|
675 | + $meta->id = $this->data_store->add_meta($this, $meta); |
|
676 | 676 | $meta->apply_changes(); |
677 | 677 | } else { |
678 | - if ( $meta->get_changes() ) { |
|
679 | - $this->data_store->update_meta( $this, $meta ); |
|
678 | + if ($meta->get_changes()) { |
|
679 | + $this->data_store->update_meta($this, $meta); |
|
680 | 680 | $meta->apply_changes(); |
681 | 681 | } |
682 | 682 | } |
683 | 683 | } |
684 | - if ( ! empty( $this->cache_group ) ) { |
|
685 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
686 | - wp_cache_delete( $cache_key, $this->cache_group ); |
|
684 | + if (!empty($this->cache_group)) { |
|
685 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
686 | + wp_cache_delete($cache_key, $this->cache_group); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @since 1.0.19 |
694 | 694 | * @param int $id ID. |
695 | 695 | */ |
696 | - public function set_id( $id ) { |
|
697 | - $this->id = absint( $id ); |
|
696 | + public function set_id($id) { |
|
697 | + $this->id = absint($id); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | * @param string $status New status. |
705 | 705 | * @return array details of change. |
706 | 706 | */ |
707 | - public function set_status( $status ) { |
|
707 | + public function set_status($status) { |
|
708 | 708 | $old_status = $this->get_status(); |
709 | 709 | |
710 | - $this->set_prop( 'status', $status ); |
|
710 | + $this->set_prop('status', $status); |
|
711 | 711 | |
712 | 712 | return array( |
713 | 713 | 'from' => $old_status, |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | public function set_defaults() { |
724 | 724 | $this->data = $this->default_data; |
725 | 725 | $this->changes = array(); |
726 | - $this->set_object_read( false ); |
|
726 | + $this->set_object_read(false); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @since 1.0.19 |
733 | 733 | * @param boolean $read Should read?. |
734 | 734 | */ |
735 | - public function set_object_read( $read = true ) { |
|
735 | + public function set_object_read($read = true) { |
|
736 | 736 | $this->object_read = (bool) $read; |
737 | 737 | } |
738 | 738 | |
@@ -757,32 +757,32 @@ discard block |
||
757 | 757 | * |
758 | 758 | * @return bool|WP_Error |
759 | 759 | */ |
760 | - public function set_props( $props, $context = 'set' ) { |
|
760 | + public function set_props($props, $context = 'set') { |
|
761 | 761 | $errors = false; |
762 | 762 | |
763 | - foreach ( $props as $prop => $value ) { |
|
763 | + foreach ($props as $prop => $value) { |
|
764 | 764 | try { |
765 | 765 | /** |
766 | 766 | * Checks if the prop being set is allowed, and the value is not null. |
767 | 767 | */ |
768 | - if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
768 | + if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) { |
|
769 | 769 | continue; |
770 | 770 | } |
771 | 771 | $setter = "set_$prop"; |
772 | 772 | |
773 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
774 | - $this->{$setter}( $value ); |
|
773 | + if (is_callable(array($this, $setter))) { |
|
774 | + $this->{$setter}($value); |
|
775 | 775 | } |
776 | - } catch ( Exception $e ) { |
|
777 | - if ( ! $errors ) { |
|
776 | + } catch (Exception $e) { |
|
777 | + if (!$errors) { |
|
778 | 778 | $errors = new WP_Error(); |
779 | 779 | } |
780 | - $errors->add( $e->getCode(), $e->getMessage() ); |
|
780 | + $errors->add($e->getCode(), $e->getMessage()); |
|
781 | 781 | $this->last_error = $e->getMessage(); |
782 | 782 | } |
783 | 783 | } |
784 | 784 | |
785 | - return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
785 | + return $errors && count($errors->get_error_codes()) ? $errors : true; |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -795,14 +795,14 @@ discard block |
||
795 | 795 | * @param string $prop Name of prop to set. |
796 | 796 | * @param mixed $value Value of the prop. |
797 | 797 | */ |
798 | - protected function set_prop( $prop, $value ) { |
|
799 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
800 | - if ( true === $this->object_read ) { |
|
801 | - if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
802 | - $this->changes[ $prop ] = $value; |
|
798 | + protected function set_prop($prop, $value) { |
|
799 | + if (array_key_exists($prop, $this->data)) { |
|
800 | + if (true === $this->object_read) { |
|
801 | + if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) { |
|
802 | + $this->changes[$prop] = $value; |
|
803 | 803 | } |
804 | 804 | } else { |
805 | - $this->data[ $prop ] = $value; |
|
805 | + $this->data[$prop] = $value; |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | * @since 1.0.19 |
824 | 824 | */ |
825 | 825 | public function apply_changes() { |
826 | - $this->data = array_replace( $this->data, $this->changes ); |
|
826 | + $this->data = array_replace($this->data, $this->changes); |
|
827 | 827 | $this->changes = array(); |
828 | 828 | } |
829 | 829 | |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | * @param string $context What the value is for. Valid values are view and edit. |
849 | 849 | * @return mixed |
850 | 850 | */ |
851 | - protected function get_prop( $prop, $context = 'view' ) { |
|
851 | + protected function get_prop($prop, $context = 'view') { |
|
852 | 852 | $value = null; |
853 | 853 | |
854 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
855 | - $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
854 | + if (array_key_exists($prop, $this->data)) { |
|
855 | + $value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop]; |
|
856 | 856 | |
857 | - if ( 'view' === $context ) { |
|
858 | - $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
857 | + if ('view' === $context) { |
|
858 | + $value = apply_filters($this->get_hook_prefix() . $prop, $value, $this); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | |
@@ -869,13 +869,13 @@ discard block |
||
869 | 869 | * @param string $prop Name of prop to set. |
870 | 870 | * @param string|integer $value Value of the prop. |
871 | 871 | */ |
872 | - protected function set_date_prop( $prop, $value ) { |
|
872 | + protected function set_date_prop($prop, $value) { |
|
873 | 873 | |
874 | - if ( empty( $value ) ) { |
|
875 | - $this->set_prop( $prop, null ); |
|
874 | + if (empty($value)) { |
|
875 | + $this->set_prop($prop, null); |
|
876 | 876 | return; |
877 | 877 | } |
878 | - $this->set_prop( $prop, $value ); |
|
878 | + $this->set_prop($prop, $value); |
|
879 | 879 | |
880 | 880 | } |
881 | 881 | |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * @param string $code Error code. |
887 | 887 | * @param string $message Error message. |
888 | 888 | */ |
889 | - protected function error( $code, $message ) { |
|
889 | + protected function error($code, $message) { |
|
890 | 890 | $this->last_error = $message; |
891 | 891 | } |
892 | 892 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | */ |
899 | 899 | public function exists() { |
900 | 900 | $id = $this->get_id(); |
901 | - return ! empty( $id ); |
|
901 | + return !empty($id); |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | } |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) |
|
182 | + if (isset($name)) |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | $templates[] = $slug . '.php'; |
185 | 185 | |
186 | 186 | // Allow template parts to be filtered |
187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
188 | 188 | |
189 | 189 | // Return the part that is found |
190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
191 | 191 | } |
192 | 192 | |
193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
194 | 194 | // No file found yet |
195 | 195 | $located = false; |
196 | 196 | |
197 | 197 | // Try to find a template file |
198 | - foreach ( (array)$template_names as $template_name ) { |
|
198 | + foreach ((array) $template_names as $template_name) { |
|
199 | 199 | |
200 | 200 | // Continue if template is empty |
201 | - if ( empty( $template_name ) ) |
|
201 | + if (empty($template_name)) |
|
202 | 202 | continue; |
203 | 203 | |
204 | 204 | // Trim off any slashes from the template name |
205 | - $template_name = ltrim( $template_name, '/' ); |
|
205 | + $template_name = ltrim($template_name, '/'); |
|
206 | 206 | |
207 | 207 | // try locating this template file by looping through the template paths |
208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
209 | 209 | |
210 | - if( file_exists( $template_path . $template_name ) ) { |
|
210 | + if (file_exists($template_path . $template_name)) { |
|
211 | 211 | $located = $template_path . $template_name; |
212 | 212 | break; |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - if( !empty( $located ) ) { |
|
216 | + if (!empty($located)) { |
|
217 | 217 | break; |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
222 | - load_template( $located, $require_once ); |
|
221 | + if ((true == $load) && !empty($located)) |
|
222 | + load_template($located, $require_once); |
|
223 | 223 | |
224 | 224 | return $located; |
225 | 225 | } |
@@ -228,127 +228,127 @@ discard block |
||
228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
229 | 229 | |
230 | 230 | $file_paths = array( |
231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
233 | 233 | 100 => wpinv_get_templates_dir() |
234 | 234 | ); |
235 | 235 | |
236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
237 | 237 | |
238 | 238 | // sort the file paths based on priority |
239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
239 | + ksort($file_paths, SORT_NUMERIC); |
|
240 | 240 | |
241 | - return array_map( 'trailingslashit', $file_paths ); |
|
241 | + return array_map('trailingslashit', $file_paths); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | function wpinv_checkout_meta_tags() { |
245 | 245 | |
246 | 246 | $pages = array(); |
247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
247 | + $pages[] = wpinv_get_option('success_page'); |
|
248 | + $pages[] = wpinv_get_option('failure_page'); |
|
249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
251 | 251 | |
252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
257 | 257 | } |
258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
259 | 259 | |
260 | -function wpinv_add_body_classes( $class ) { |
|
261 | - $classes = (array)$class; |
|
260 | +function wpinv_add_body_classes($class) { |
|
261 | + $classes = (array) $class; |
|
262 | 262 | |
263 | - if( wpinv_is_checkout() ) { |
|
263 | + if (wpinv_is_checkout()) { |
|
264 | 264 | $classes[] = 'wpinv-checkout'; |
265 | 265 | $classes[] = 'wpinv-page'; |
266 | 266 | } |
267 | 267 | |
268 | - if( wpinv_is_success_page() ) { |
|
268 | + if (wpinv_is_success_page()) { |
|
269 | 269 | $classes[] = 'wpinv-success'; |
270 | 270 | $classes[] = 'wpinv-page'; |
271 | 271 | } |
272 | 272 | |
273 | - if( wpinv_is_failed_transaction_page() ) { |
|
273 | + if (wpinv_is_failed_transaction_page()) { |
|
274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
275 | 275 | $classes[] = 'wpinv-page'; |
276 | 276 | } |
277 | 277 | |
278 | - if( wpinv_is_invoice_history_page() ) { |
|
278 | + if (wpinv_is_invoice_history_page()) { |
|
279 | 279 | $classes[] = 'wpinv-history'; |
280 | 280 | $classes[] = 'wpinv-page'; |
281 | 281 | } |
282 | 282 | |
283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
283 | + if (wpinv_is_subscriptions_history_page()) { |
|
284 | 284 | $classes[] = 'wpinv-subscription'; |
285 | 285 | $classes[] = 'wpinv-page'; |
286 | 286 | } |
287 | 287 | |
288 | - if( wpinv_is_test_mode() ) { |
|
288 | + if (wpinv_is_test_mode()) { |
|
289 | 289 | $classes[] = 'wpinv-test-mode'; |
290 | 290 | $classes[] = 'wpinv-page'; |
291 | 291 | } |
292 | 292 | |
293 | - return array_unique( $classes ); |
|
293 | + return array_unique($classes); |
|
294 | 294 | } |
295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
296 | 296 | |
297 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
298 | - $current = date( 'Y' ); |
|
299 | - $start_year = $current - absint( $years_before ); |
|
300 | - $end_year = $current + absint( $years_after ); |
|
301 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
297 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
298 | + $current = date('Y'); |
|
299 | + $start_year = $current - absint($years_before); |
|
300 | + $end_year = $current + absint($years_after); |
|
301 | + $selected = empty($selected) ? date('Y') : $selected; |
|
302 | 302 | $options = array(); |
303 | 303 | |
304 | - while ( $start_year <= $end_year ) { |
|
305 | - $options[ absint( $start_year ) ] = $start_year; |
|
304 | + while ($start_year <= $end_year) { |
|
305 | + $options[absint($start_year)] = $start_year; |
|
306 | 306 | $start_year++; |
307 | 307 | } |
308 | 308 | |
309 | - $output = wpinv_html_select( array( |
|
309 | + $output = wpinv_html_select(array( |
|
310 | 310 | 'name' => $name, |
311 | 311 | 'selected' => $selected, |
312 | 312 | 'options' => $options, |
313 | 313 | 'show_option_all' => false, |
314 | 314 | 'show_option_none' => false |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | |
317 | 317 | return $output; |
318 | 318 | } |
319 | 319 | |
320 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
320 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
321 | 321 | |
322 | 322 | $options = array( |
323 | - '1' => __( 'January', 'invoicing' ), |
|
324 | - '2' => __( 'February', 'invoicing' ), |
|
325 | - '3' => __( 'March', 'invoicing' ), |
|
326 | - '4' => __( 'April', 'invoicing' ), |
|
327 | - '5' => __( 'May', 'invoicing' ), |
|
328 | - '6' => __( 'June', 'invoicing' ), |
|
329 | - '7' => __( 'July', 'invoicing' ), |
|
330 | - '8' => __( 'August', 'invoicing' ), |
|
331 | - '9' => __( 'September', 'invoicing' ), |
|
332 | - '10' => __( 'October', 'invoicing' ), |
|
333 | - '11' => __( 'November', 'invoicing' ), |
|
334 | - '12' => __( 'December', 'invoicing' ), |
|
323 | + '1' => __('January', 'invoicing'), |
|
324 | + '2' => __('February', 'invoicing'), |
|
325 | + '3' => __('March', 'invoicing'), |
|
326 | + '4' => __('April', 'invoicing'), |
|
327 | + '5' => __('May', 'invoicing'), |
|
328 | + '6' => __('June', 'invoicing'), |
|
329 | + '7' => __('July', 'invoicing'), |
|
330 | + '8' => __('August', 'invoicing'), |
|
331 | + '9' => __('September', 'invoicing'), |
|
332 | + '10' => __('October', 'invoicing'), |
|
333 | + '11' => __('November', 'invoicing'), |
|
334 | + '12' => __('December', 'invoicing'), |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | // If no month is selected, default to the current month |
338 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
338 | + $selected = empty($selected) ? date('n') : $selected; |
|
339 | 339 | |
340 | - $output = wpinv_html_select( array( |
|
340 | + $output = wpinv_html_select(array( |
|
341 | 341 | 'name' => $name, |
342 | 342 | 'selected' => $selected, |
343 | 343 | 'options' => $options, |
344 | 344 | 'show_option_all' => false, |
345 | 345 | 'show_option_none' => false |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | |
348 | 348 | return $output; |
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_html_select( $args = array() ) { |
|
351 | +function wpinv_html_select($args = array()) { |
|
352 | 352 | $defaults = array( |
353 | 353 | 'options' => array(), |
354 | 354 | 'name' => null, |
@@ -357,8 +357,8 @@ discard block |
||
357 | 357 | 'selected' => 0, |
358 | 358 | 'placeholder' => null, |
359 | 359 | 'multiple' => false, |
360 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
361 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
360 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
361 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
362 | 362 | 'data' => array(), |
363 | 363 | 'onchange' => null, |
364 | 364 | 'required' => false, |
@@ -366,74 +366,74 @@ discard block |
||
366 | 366 | 'readonly' => false, |
367 | 367 | ); |
368 | 368 | |
369 | - $args = wp_parse_args( $args, $defaults ); |
|
369 | + $args = wp_parse_args($args, $defaults); |
|
370 | 370 | |
371 | 371 | $data_elements = ''; |
372 | - foreach ( $args['data'] as $key => $value ) { |
|
373 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
372 | + foreach ($args['data'] as $key => $value) { |
|
373 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
374 | 374 | } |
375 | 375 | |
376 | - if( $args['multiple'] ) { |
|
376 | + if ($args['multiple']) { |
|
377 | 377 | $multiple = ' MULTIPLE'; |
378 | 378 | } else { |
379 | 379 | $multiple = ''; |
380 | 380 | } |
381 | 381 | |
382 | - if( $args['placeholder'] ) { |
|
382 | + if ($args['placeholder']) { |
|
383 | 383 | $placeholder = $args['placeholder']; |
384 | 384 | } else { |
385 | 385 | $placeholder = ''; |
386 | 386 | } |
387 | 387 | |
388 | 388 | $options = ''; |
389 | - if( !empty( $args['onchange'] ) ) { |
|
390 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
389 | + if (!empty($args['onchange'])) { |
|
390 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
391 | 391 | } |
392 | 392 | |
393 | - if( !empty( $args['required'] ) ) { |
|
393 | + if (!empty($args['required'])) { |
|
394 | 394 | $options .= ' required="required"'; |
395 | 395 | } |
396 | 396 | |
397 | - if( !empty( $args['disabled'] ) ) { |
|
397 | + if (!empty($args['disabled'])) { |
|
398 | 398 | $options .= ' disabled'; |
399 | 399 | } |
400 | 400 | |
401 | - if( !empty( $args['readonly'] ) ) { |
|
401 | + if (!empty($args['readonly'])) { |
|
402 | 402 | $options .= ' readonly'; |
403 | 403 | } |
404 | 404 | |
405 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
406 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
405 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
406 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
407 | 407 | |
408 | - if ( $args['show_option_all'] ) { |
|
409 | - if( $args['multiple'] ) { |
|
410 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
408 | + if ($args['show_option_all']) { |
|
409 | + if ($args['multiple']) { |
|
410 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
411 | 411 | } else { |
412 | - $selected = selected( $args['selected'], 0, false ); |
|
412 | + $selected = selected($args['selected'], 0, false); |
|
413 | 413 | } |
414 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
414 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
415 | 415 | } |
416 | 416 | |
417 | - if ( !empty( $args['options'] ) ) { |
|
417 | + if (!empty($args['options'])) { |
|
418 | 418 | |
419 | - if ( $args['show_option_none'] ) { |
|
420 | - if( $args['multiple'] ) { |
|
421 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
419 | + if ($args['show_option_none']) { |
|
420 | + if ($args['multiple']) { |
|
421 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
422 | 422 | } else { |
423 | - $selected = selected( $args['selected'] === "", true, false ); |
|
423 | + $selected = selected($args['selected'] === "", true, false); |
|
424 | 424 | } |
425 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
425 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
426 | 426 | } |
427 | 427 | |
428 | - foreach( $args['options'] as $key => $option ) { |
|
428 | + foreach ($args['options'] as $key => $option) { |
|
429 | 429 | |
430 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
431 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
430 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
431 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
432 | 432 | } else { |
433 | - $selected = selected( $args['selected'], $key, false ); |
|
433 | + $selected = selected($args['selected'], $key, false); |
|
434 | 434 | } |
435 | 435 | |
436 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
436 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | return $output; |
443 | 443 | } |
444 | 444 | |
445 | -function wpinv_item_dropdown( $args = array() ) { |
|
445 | +function wpinv_item_dropdown($args = array()) { |
|
446 | 446 | $defaults = array( |
447 | 447 | 'name' => 'wpi_item', |
448 | 448 | 'id' => 'wpi_item', |
@@ -450,14 +450,14 @@ discard block |
||
450 | 450 | 'multiple' => false, |
451 | 451 | 'selected' => 0, |
452 | 452 | 'number' => 100, |
453 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
454 | - 'data' => array( 'search-type' => 'item' ), |
|
453 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
454 | + 'data' => array('search-type' => 'item'), |
|
455 | 455 | 'show_option_all' => false, |
456 | 456 | 'show_option_none' => false, |
457 | 457 | 'show_recurring' => false, |
458 | 458 | ); |
459 | 459 | |
460 | - $args = wp_parse_args( $args, $defaults ); |
|
460 | + $args = wp_parse_args($args, $defaults); |
|
461 | 461 | |
462 | 462 | $item_args = array( |
463 | 463 | 'post_type' => 'wpi_item', |
@@ -466,44 +466,44 @@ discard block |
||
466 | 466 | 'posts_per_page' => $args['number'] |
467 | 467 | ); |
468 | 468 | |
469 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
469 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
470 | 470 | |
471 | - $items = get_posts( $item_args ); |
|
471 | + $items = get_posts($item_args); |
|
472 | 472 | $options = array(); |
473 | - if ( $items ) { |
|
474 | - foreach ( $items as $item ) { |
|
475 | - $title = esc_html( $item->post_title ); |
|
473 | + if ($items) { |
|
474 | + foreach ($items as $item) { |
|
475 | + $title = esc_html($item->post_title); |
|
476 | 476 | |
477 | - if ( !empty( $args['show_recurring'] ) ) { |
|
478 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
477 | + if (!empty($args['show_recurring'])) { |
|
478 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
479 | 479 | } |
480 | 480 | |
481 | - $options[ absint( $item->ID ) ] = $title; |
|
481 | + $options[absint($item->ID)] = $title; |
|
482 | 482 | } |
483 | 483 | } |
484 | 484 | |
485 | 485 | // This ensures that any selected items are included in the drop down |
486 | - if( is_array( $args['selected'] ) ) { |
|
487 | - foreach( $args['selected'] as $item ) { |
|
488 | - if( ! in_array( $item, $options ) ) { |
|
489 | - $title = get_the_title( $item ); |
|
490 | - if ( !empty( $args['show_recurring'] ) ) { |
|
491 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
486 | + if (is_array($args['selected'])) { |
|
487 | + foreach ($args['selected'] as $item) { |
|
488 | + if (!in_array($item, $options)) { |
|
489 | + $title = get_the_title($item); |
|
490 | + if (!empty($args['show_recurring'])) { |
|
491 | + $title .= wpinv_get_item_suffix($item, false); |
|
492 | 492 | } |
493 | 493 | $options[$item] = $title; |
494 | 494 | } |
495 | 495 | } |
496 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
497 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
498 | - $title = get_the_title( $args['selected'] ); |
|
499 | - if ( !empty( $args['show_recurring'] ) ) { |
|
500 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
496 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
497 | + if (!in_array($args['selected'], $options)) { |
|
498 | + $title = get_the_title($args['selected']); |
|
499 | + if (!empty($args['show_recurring'])) { |
|
500 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
501 | 501 | } |
502 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
502 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | - $output = wpinv_html_select( array( |
|
506 | + $output = wpinv_html_select(array( |
|
507 | 507 | 'name' => $args['name'], |
508 | 508 | 'selected' => $args['selected'], |
509 | 509 | 'id' => $args['id'], |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | 'show_option_all' => $args['show_option_all'], |
515 | 515 | 'show_option_none' => $args['show_option_none'], |
516 | 516 | 'data' => $args['data'], |
517 | - ) ); |
|
517 | + )); |
|
518 | 518 | |
519 | 519 | return $output; |
520 | 520 | } |
@@ -534,16 +534,16 @@ discard block |
||
534 | 534 | ); |
535 | 535 | |
536 | 536 | $options = array(); |
537 | - if ( $items ) { |
|
538 | - foreach ( $items as $item ) { |
|
539 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
537 | + if ($items) { |
|
538 | + foreach ($items as $item) { |
|
539 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | 543 | return $options; |
544 | 544 | } |
545 | 545 | |
546 | -function wpinv_html_checkbox( $args = array() ) { |
|
546 | +function wpinv_html_checkbox($args = array()) { |
|
547 | 547 | $defaults = array( |
548 | 548 | 'name' => null, |
549 | 549 | 'current' => null, |
@@ -554,17 +554,17 @@ discard block |
||
554 | 554 | ) |
555 | 555 | ); |
556 | 556 | |
557 | - $args = wp_parse_args( $args, $defaults ); |
|
557 | + $args = wp_parse_args($args, $defaults); |
|
558 | 558 | |
559 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
559 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
560 | 560 | $options = ''; |
561 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
561 | + if (!empty($args['options']['disabled'])) { |
|
562 | 562 | $options .= ' disabled="disabled"'; |
563 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
563 | + } elseif (!empty($args['options']['readonly'])) { |
|
564 | 564 | $options .= ' readonly'; |
565 | 565 | } |
566 | 566 | |
567 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
567 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
568 | 568 | |
569 | 569 | return $output; |
570 | 570 | } |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | /** |
573 | 573 | * Displays a hidden field. |
574 | 574 | */ |
575 | -function getpaid_hidden_field( $name, $value ) { |
|
576 | - $name = sanitize_text_field( $name ); |
|
577 | - $value = esc_attr( $value ); |
|
575 | +function getpaid_hidden_field($name, $value) { |
|
576 | + $name = sanitize_text_field($name); |
|
577 | + $value = esc_attr($value); |
|
578 | 578 | |
579 | 579 | echo "<input type='hidden' name='$name' value='$value' />"; |
580 | 580 | } |
@@ -582,31 +582,31 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * Displays a submit field. |
584 | 584 | */ |
585 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
586 | - $name = sanitize_text_field( $name ); |
|
587 | - $value = esc_attr( $value ); |
|
588 | - $class = esc_attr( $class ); |
|
585 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
586 | + $name = sanitize_text_field($name); |
|
587 | + $value = esc_attr($value); |
|
588 | + $class = esc_attr($class); |
|
589 | 589 | |
590 | 590 | echo "<input type='submit' name='$name' value='$value' class='btn $class' />"; |
591 | 591 | } |
592 | 592 | |
593 | -function wpinv_html_text( $args = array() ) { |
|
593 | +function wpinv_html_text($args = array()) { |
|
594 | 594 | // Backwards compatibility |
595 | - if ( func_num_args() > 1 ) { |
|
595 | + if (func_num_args() > 1) { |
|
596 | 596 | $args = func_get_args(); |
597 | 597 | |
598 | 598 | $name = $args[0]; |
599 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
600 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
601 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
599 | + $value = isset($args[1]) ? $args[1] : ''; |
|
600 | + $label = isset($args[2]) ? $args[2] : ''; |
|
601 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $defaults = array( |
605 | 605 | 'id' => '', |
606 | - 'name' => isset( $name ) ? $name : 'text', |
|
607 | - 'value' => isset( $value ) ? $value : null, |
|
608 | - 'label' => isset( $label ) ? $label : null, |
|
609 | - 'desc' => isset( $desc ) ? $desc : null, |
|
606 | + 'name' => isset($name) ? $name : 'text', |
|
607 | + 'value' => isset($value) ? $value : null, |
|
608 | + 'label' => isset($label) ? $label : null, |
|
609 | + 'desc' => isset($desc) ? $desc : null, |
|
610 | 610 | 'placeholder' => '', |
611 | 611 | 'class' => 'regular-text', |
612 | 612 | 'disabled' => false, |
@@ -616,41 +616,41 @@ discard block |
||
616 | 616 | 'data' => false |
617 | 617 | ); |
618 | 618 | |
619 | - $args = wp_parse_args( $args, $defaults ); |
|
619 | + $args = wp_parse_args($args, $defaults); |
|
620 | 620 | |
621 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
621 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
622 | 622 | $options = ''; |
623 | - if( $args['required'] ) { |
|
623 | + if ($args['required']) { |
|
624 | 624 | $options .= ' required="required"'; |
625 | 625 | } |
626 | - if( $args['readonly'] ) { |
|
626 | + if ($args['readonly']) { |
|
627 | 627 | $options .= ' readonly'; |
628 | 628 | } |
629 | - if( $args['readonly'] ) { |
|
629 | + if ($args['readonly']) { |
|
630 | 630 | $options .= ' readonly'; |
631 | 631 | } |
632 | 632 | |
633 | 633 | $data = ''; |
634 | - if ( !empty( $args['data'] ) ) { |
|
635 | - foreach ( $args['data'] as $key => $value ) { |
|
636 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
634 | + if (!empty($args['data'])) { |
|
635 | + foreach ($args['data'] as $key => $value) { |
|
636 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
641 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
642 | - if ( ! empty( $args['desc'] ) ) { |
|
643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
640 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
641 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
642 | + if (!empty($args['desc'])) { |
|
643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
644 | 644 | } |
645 | 645 | |
646 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
646 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
647 | 647 | |
648 | 648 | $output .= '</span>'; |
649 | 649 | |
650 | 650 | return $output; |
651 | 651 | } |
652 | 652 | |
653 | -function wpinv_html_textarea( $args = array() ) { |
|
653 | +function wpinv_html_textarea($args = array()) { |
|
654 | 654 | $defaults = array( |
655 | 655 | 'name' => 'textarea', |
656 | 656 | 'value' => null, |
@@ -661,31 +661,31 @@ discard block |
||
661 | 661 | 'placeholder' => '', |
662 | 662 | ); |
663 | 663 | |
664 | - $args = wp_parse_args( $args, $defaults ); |
|
664 | + $args = wp_parse_args($args, $defaults); |
|
665 | 665 | |
666 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
666 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
667 | 667 | $disabled = ''; |
668 | - if( $args['disabled'] ) { |
|
668 | + if ($args['disabled']) { |
|
669 | 669 | $disabled = ' disabled="disabled"'; |
670 | 670 | } |
671 | 671 | |
672 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
673 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
674 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
672 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
673 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
674 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
675 | 675 | |
676 | - if ( ! empty( $args['desc'] ) ) { |
|
677 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
676 | + if (!empty($args['desc'])) { |
|
677 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
678 | 678 | } |
679 | 679 | $output .= '</span>'; |
680 | 680 | |
681 | 681 | return $output; |
682 | 682 | } |
683 | 683 | |
684 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
684 | +function wpinv_html_ajax_user_search($args = array()) { |
|
685 | 685 | $defaults = array( |
686 | 686 | 'name' => 'user_id', |
687 | 687 | 'value' => null, |
688 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
688 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
689 | 689 | 'label' => null, |
690 | 690 | 'desc' => null, |
691 | 691 | 'class' => '', |
@@ -694,13 +694,13 @@ discard block |
||
694 | 694 | 'data' => false |
695 | 695 | ); |
696 | 696 | |
697 | - $args = wp_parse_args( $args, $defaults ); |
|
697 | + $args = wp_parse_args($args, $defaults); |
|
698 | 698 | |
699 | 699 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
700 | 700 | |
701 | 701 | $output = '<span class="wpinv_user_search_wrap">'; |
702 | - $output .= wpinv_html_text( $args ); |
|
703 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
702 | + $output .= wpinv_html_text($args); |
|
703 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
704 | 704 | $output .= '</span>'; |
705 | 705 | |
706 | 706 | return $output; |
@@ -711,20 +711,20 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @param string $template the template that is currently being used. |
713 | 713 | */ |
714 | -function wpinv_template( $template ) { |
|
714 | +function wpinv_template($template) { |
|
715 | 715 | global $post; |
716 | 716 | |
717 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
717 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
718 | 718 | |
719 | 719 | // If the user can view this invoice, display it. |
720 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
720 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
721 | 721 | |
722 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
722 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
723 | 723 | |
724 | 724 | // Else display an error message. |
725 | 725 | } else { |
726 | 726 | |
727 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
727 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
728 | 728 | |
729 | 729 | } |
730 | 730 | |
@@ -732,24 +732,24 @@ discard block |
||
732 | 732 | |
733 | 733 | return $template; |
734 | 734 | } |
735 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
735 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
736 | 736 | |
737 | 737 | function wpinv_get_business_address() { |
738 | 738 | $business_address = wpinv_store_address(); |
739 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
739 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
740 | 740 | |
741 | 741 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
742 | 742 | |
743 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
743 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
747 | 747 | * Displays the company address. |
748 | 748 | */ |
749 | 749 | function wpinv_display_from_address() { |
750 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
750 | + wpinv_get_template('invoice/company-address.php'); |
|
751 | 751 | } |
752 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
752 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
753 | 753 | |
754 | 754 | /** |
755 | 755 | * Generates a watermark text for an invoice. |
@@ -757,9 +757,9 @@ discard block |
||
757 | 757 | * @param WPInv_Invoice $invoice |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_watermark( $invoice ) { |
|
761 | - $watermark = wpinv_get_watermark( $invoice ); |
|
762 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
760 | +function wpinv_watermark($invoice) { |
|
761 | + $watermark = wpinv_get_watermark($invoice); |
|
762 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -768,37 +768,37 @@ discard block |
||
768 | 768 | * @param WPInv_Invoice $invoice |
769 | 769 | * @return string |
770 | 770 | */ |
771 | -function wpinv_get_watermark( $invoice ) { |
|
771 | +function wpinv_get_watermark($invoice) { |
|
772 | 772 | return $invoice->get_status_nicename(); |
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
776 | 776 | * @deprecated |
777 | 777 | */ |
778 | -function wpinv_display_invoice_details( $invoice ) { |
|
779 | - return getpaid_invoice_meta( $invoice ); |
|
778 | +function wpinv_display_invoice_details($invoice) { |
|
779 | + return getpaid_invoice_meta($invoice); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | /** |
783 | 783 | * Displays invoice meta. |
784 | 784 | */ |
785 | -function getpaid_invoice_meta( $invoice ) { |
|
785 | +function getpaid_invoice_meta($invoice) { |
|
786 | 786 | |
787 | - $invoice = new WPInv_Invoice( $invoice ); |
|
787 | + $invoice = new WPInv_Invoice($invoice); |
|
788 | 788 | |
789 | 789 | // Ensure that we have an invoice. |
790 | - if ( 0 == $invoice->get_id() ) { |
|
790 | + if (0 == $invoice->get_id()) { |
|
791 | 791 | return; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // Get the invoice meta. |
795 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
795 | + $meta = getpaid_get_invoice_meta($invoice); |
|
796 | 796 | |
797 | 797 | // Display the meta. |
798 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
798 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
799 | 799 | |
800 | 800 | } |
801 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
801 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
802 | 802 | |
803 | 803 | /** |
804 | 804 | * Retrieves the address markup to use on Invoices. |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | * @param string $separator How to separate address lines. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
813 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
814 | 814 | |
815 | 815 | // Retrieve the address markup... |
816 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
817 | - $format = wpinv_get_full_address_format( $country ); |
|
816 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
817 | + $format = wpinv_get_full_address_format($country); |
|
818 | 818 | |
819 | 819 | // ... and the replacements. |
820 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
820 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
821 | 821 | |
822 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
822 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
823 | 823 | |
824 | 824 | // Remove unavailable tags. |
825 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
825 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
826 | 826 | |
827 | 827 | // Clean up white space. |
828 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
829 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
828 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
829 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
830 | 830 | |
831 | 831 | // Break newlines apart and remove empty lines/trim commas and white space. |
832 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
832 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
833 | 833 | |
834 | 834 | // Add html breaks. |
835 | - $formatted_address = implode( $separator, $formatted_address ); |
|
835 | + $formatted_address = implode($separator, $formatted_address); |
|
836 | 836 | |
837 | 837 | // We're done! |
838 | 838 | return $formatted_address; |
@@ -844,88 +844,88 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @param WPInv_Invoice $invoice |
846 | 846 | */ |
847 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
848 | - if ( ! empty( $invoice ) ) { |
|
849 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
847 | +function wpinv_display_to_address($invoice = 0) { |
|
848 | + if (!empty($invoice)) { |
|
849 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
850 | 850 | } |
851 | 851 | } |
852 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
852 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
853 | 853 | |
854 | 854 | |
855 | 855 | /** |
856 | 856 | * Displays invoice line items. |
857 | 857 | */ |
858 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
858 | +function wpinv_display_line_items($invoice_id = 0) { |
|
859 | 859 | |
860 | 860 | // Prepare the invoice. |
861 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
861 | + $invoice = new WPInv_Invoice($invoice_id); |
|
862 | 862 | |
863 | 863 | // Abort if there is no invoice. |
864 | - if ( 0 == $invoice->get_id() ) { |
|
864 | + if (0 == $invoice->get_id()) { |
|
865 | 865 | return; |
866 | 866 | } |
867 | 867 | |
868 | 868 | // Line item columns. |
869 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
870 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
869 | + $columns = getpaid_invoice_item_columns($invoice); |
|
870 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
871 | 871 | |
872 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
872 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
873 | 873 | } |
874 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
874 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
875 | 875 | |
876 | 876 | /** |
877 | 877 | * Displays invoice notices on invoices. |
878 | 878 | */ |
879 | 879 | function wpinv_display_invoice_notice() { |
880 | 880 | |
881 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
882 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
881 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
882 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
883 | 883 | |
884 | - if ( empty( $label ) && empty( $notice ) ) { |
|
884 | + if (empty($label) && empty($notice)) { |
|
885 | 885 | return; |
886 | 886 | } |
887 | 887 | |
888 | 888 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
889 | 889 | |
890 | - if ( ! empty( $label ) ) { |
|
891 | - $label = sanitize_text_field( $label ); |
|
890 | + if (!empty($label)) { |
|
891 | + $label = sanitize_text_field($label); |
|
892 | 892 | echo "<h5>$label</h5>"; |
893 | 893 | } |
894 | 894 | |
895 | - if ( ! empty( $notice ) ) { |
|
896 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
895 | + if (!empty($notice)) { |
|
896 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
897 | 897 | } |
898 | 898 | |
899 | 899 | echo '</div>'; |
900 | 900 | } |
901 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
901 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
902 | 902 | |
903 | 903 | /** |
904 | 904 | * @param WPInv_Invoice $invoice |
905 | 905 | */ |
906 | -function wpinv_display_invoice_notes( $invoice ) { |
|
906 | +function wpinv_display_invoice_notes($invoice) { |
|
907 | 907 | |
908 | 908 | // Retrieve the notes. |
909 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
909 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
910 | 910 | |
911 | 911 | // Abort if we have non. |
912 | - if ( empty( $notes ) ) { |
|
912 | + if (empty($notes)) { |
|
913 | 913 | return; |
914 | 914 | } |
915 | 915 | |
916 | 916 | // Echo the note. |
917 | 917 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
918 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) .'</h2>'; |
|
918 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>'; |
|
919 | 919 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
920 | 920 | |
921 | - foreach( $notes as $note ) { |
|
922 | - wpinv_get_invoice_note_line_item( $note ); |
|
921 | + foreach ($notes as $note) { |
|
922 | + wpinv_get_invoice_note_line_item($note); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | echo '</ul>'; |
926 | 926 | echo '</div>'; |
927 | 927 | } |
928 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
928 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
929 | 929 | |
930 | 930 | /** |
931 | 931 | * Loads scripts on our invoice templates. |
@@ -933,31 +933,31 @@ discard block |
||
933 | 933 | function wpinv_display_style() { |
934 | 934 | |
935 | 935 | // Make sure that all scripts have been loaded. |
936 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
937 | - do_action( 'wp_enqueue_scripts' ); |
|
936 | + if (!did_action('wp_enqueue_scripts')) { |
|
937 | + do_action('wp_enqueue_scripts'); |
|
938 | 938 | } |
939 | 939 | |
940 | 940 | // Register the invoices style. |
941 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
941 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
942 | 942 | |
943 | 943 | // Load required styles |
944 | - wp_print_styles( 'wpinv-single-style' ); |
|
945 | - wp_print_styles( 'ayecode-ui' ); |
|
944 | + wp_print_styles('wpinv-single-style'); |
|
945 | + wp_print_styles('ayecode-ui'); |
|
946 | 946 | |
947 | 947 | // Maybe load custom css. |
948 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
948 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
949 | 949 | |
950 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
951 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
952 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
950 | + if (isset($custom_css) && !empty($custom_css)) { |
|
951 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
952 | + $custom_css = str_replace('>', '>', $custom_css); |
|
953 | 953 | echo '<style type="text/css">'; |
954 | 954 | echo $custom_css; |
955 | 955 | echo '</style>'; |
956 | 956 | } |
957 | 957 | |
958 | 958 | } |
959 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
960 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
959 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
960 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
961 | 961 | |
962 | 962 | |
963 | 963 | /** |
@@ -969,41 +969,41 @@ discard block |
||
969 | 969 | // Retrieve the current invoice. |
970 | 970 | $invoice_id = getpaid_get_current_invoice_id(); |
971 | 971 | |
972 | - if ( empty( $invoice_id ) ) { |
|
972 | + if (empty($invoice_id)) { |
|
973 | 973 | |
974 | 974 | return aui()->alert( |
975 | 975 | array( |
976 | 976 | 'type' => 'warning', |
977 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
977 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
978 | 978 | ) |
979 | 979 | ); |
980 | 980 | |
981 | 981 | } |
982 | 982 | |
983 | 983 | // Can the user view this invoice? |
984 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
984 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
985 | 985 | |
986 | 986 | return aui()->alert( |
987 | 987 | array( |
988 | 988 | 'type' => 'warning', |
989 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
989 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
990 | 990 | ) |
991 | 991 | ); |
992 | 992 | |
993 | 993 | } |
994 | 994 | |
995 | 995 | // Ensure that it is not yet paid for. |
996 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
996 | + $invoice = new WPInv_Invoice($invoice_id); |
|
997 | 997 | |
998 | 998 | // Maybe mark it as viewed. |
999 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
999 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
1000 | 1000 | |
1001 | - if ( $invoice->is_paid() ) { |
|
1001 | + if ($invoice->is_paid()) { |
|
1002 | 1002 | |
1003 | 1003 | return aui()->alert( |
1004 | 1004 | array( |
1005 | 1005 | 'type' => 'success', |
1006 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
1006 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
1007 | 1007 | ) |
1008 | 1008 | ); |
1009 | 1009 | |
@@ -1013,15 +1013,15 @@ discard block |
||
1013 | 1013 | $wpi_checkout_id = $invoice_id; |
1014 | 1014 | |
1015 | 1015 | // Retrieve appropriate payment form. |
1016 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
1017 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1016 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
1017 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1018 | 1018 | |
1019 | - if ( ! $payment_form->exists() ) { |
|
1019 | + if (!$payment_form->exists()) { |
|
1020 | 1020 | |
1021 | 1021 | return aui()->alert( |
1022 | 1022 | array( |
1023 | 1023 | 'type' => 'warning', |
1024 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1024 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1025 | 1025 | ) |
1026 | 1026 | ); |
1027 | 1027 | |
@@ -1030,29 +1030,29 @@ discard block |
||
1030 | 1030 | // Set the invoice. |
1031 | 1031 | $payment_form->invoice = $invoice; |
1032 | 1032 | |
1033 | - if ( ! $payment_form->is_default() ) { |
|
1033 | + if (!$payment_form->is_default()) { |
|
1034 | 1034 | |
1035 | 1035 | $items = array(); |
1036 | 1036 | $item_ids = array(); |
1037 | 1037 | |
1038 | - foreach ( $invoice->get_items() as $item ) { |
|
1039 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1038 | + foreach ($invoice->get_items() as $item) { |
|
1039 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1040 | 1040 | $item_ids[] = $item->get_id(); |
1041 | 1041 | $items[] = $item; |
1042 | 1042 | } |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - foreach ( $payment_form->get_items() as $item ) { |
|
1046 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1045 | + foreach ($payment_form->get_items() as $item) { |
|
1046 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1047 | 1047 | $item_ids[] = $item->get_id(); |
1048 | 1048 | $items[] = $item; |
1049 | 1049 | } |
1050 | 1050 | } |
1051 | 1051 | |
1052 | - $payment_form->set_items( $items ); |
|
1052 | + $payment_form->set_items($items); |
|
1053 | 1053 | |
1054 | 1054 | } else { |
1055 | - $payment_form->set_items( $invoice->get_items() ); |
|
1055 | + $payment_form->set_items($invoice->get_items()); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | // Generate the html. |
@@ -1061,7 +1061,7 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | function wpinv_empty_cart_message() { |
1064 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1064 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | /** |
@@ -1078,71 +1078,71 @@ discard block |
||
1078 | 1078 | ) |
1079 | 1079 | ); |
1080 | 1080 | } |
1081 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1081 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1082 | 1082 | |
1083 | 1083 | /** |
1084 | 1084 | * Filters the receipt page. |
1085 | 1085 | */ |
1086 | -function wpinv_filter_success_page_content( $content ) { |
|
1086 | +function wpinv_filter_success_page_content($content) { |
|
1087 | 1087 | |
1088 | 1088 | // Ensure this is our page. |
1089 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1089 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1090 | 1090 | |
1091 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1092 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1091 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1092 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1093 | 1093 | |
1094 | 1094 | } |
1095 | 1095 | |
1096 | 1096 | return $content; |
1097 | 1097 | } |
1098 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1098 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1099 | 1099 | |
1100 | -function wpinv_invoice_link( $invoice_id ) { |
|
1101 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1100 | +function wpinv_invoice_link($invoice_id) { |
|
1101 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1102 | 1102 | |
1103 | - if ( empty( $invoice ) ) { |
|
1103 | + if (empty($invoice)) { |
|
1104 | 1104 | return NULL; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1107 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1108 | 1108 | |
1109 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1109 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1113 | - if ( empty( $note ) ) { |
|
1112 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1113 | + if (empty($note)) { |
|
1114 | 1114 | return NULL; |
1115 | 1115 | } |
1116 | 1116 | |
1117 | - if ( is_int( $note ) ) { |
|
1118 | - $note = get_comment( $note ); |
|
1117 | + if (is_int($note)) { |
|
1118 | + $note = get_comment($note); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1121 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1122 | 1122 | return NULL; |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - $note_classes = array( 'note' ); |
|
1126 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1125 | + $note_classes = array('note'); |
|
1126 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1127 | 1127 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1128 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1129 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1128 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1129 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1130 | 1130 | |
1131 | 1131 | ob_start(); |
1132 | 1132 | ?> |
1133 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1133 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1134 | 1134 | <div class="note_content"> |
1135 | 1135 | |
1136 | - <?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?> |
|
1136 | + <?php echo wptexturize(wp_kses_post($note->comment_content)); ?> |
|
1137 | 1137 | |
1138 | - <?php if ( ! is_admin() ) : ?> |
|
1138 | + <?php if (!is_admin()) : ?> |
|
1139 | 1139 | <em class="small form-text text-muted mt-0"> |
1140 | 1140 | <?php |
1141 | 1141 | printf( |
1142 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1142 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1143 | 1143 | $note->comment_author, |
1144 | - getpaid_format_date_value( $note->comment_date ), |
|
1145 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1144 | + getpaid_format_date_value($note->comment_date), |
|
1145 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1146 | 1146 | ); |
1147 | 1147 | ?> |
1148 | 1148 | </em> |
@@ -1150,21 +1150,21 @@ discard block |
||
1150 | 1150 | |
1151 | 1151 | </div> |
1152 | 1152 | |
1153 | - <?php if ( is_admin() ) : ?> |
|
1153 | + <?php if (is_admin()) : ?> |
|
1154 | 1154 | |
1155 | 1155 | <p class="meta px-4 py-2"> |
1156 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1156 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1157 | 1157 | <?php |
1158 | 1158 | printf( |
1159 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1159 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
1160 | 1160 | $note->comment_author, |
1161 | - getpaid_format_date_value( $note->comment_date ), |
|
1162 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
1161 | + getpaid_format_date_value($note->comment_date), |
|
1162 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
1163 | 1163 | ); |
1164 | 1164 | ?> |
1165 | 1165 | </abbr> |
1166 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1167 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
1166 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1167 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
1168 | 1168 | <?php } ?> |
1169 | 1169 | </p> |
1170 | 1170 | |
@@ -1173,9 +1173,9 @@ discard block |
||
1173 | 1173 | </li> |
1174 | 1174 | <?php |
1175 | 1175 | $note_content = ob_get_clean(); |
1176 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1176 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1177 | 1177 | |
1178 | - if ( $echo ) { |
|
1178 | + if ($echo) { |
|
1179 | 1179 | echo $note_content; |
1180 | 1180 | } else { |
1181 | 1181 | return $note_content; |
@@ -1189,21 +1189,21 @@ discard block |
||
1189 | 1189 | * @return string |
1190 | 1190 | */ |
1191 | 1191 | function wpinv_get_policy_text() { |
1192 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1192 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1193 | 1193 | |
1194 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
1194 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1195 | 1195 | |
1196 | - if(!$privacy_page_id){ |
|
1197 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1196 | + if (!$privacy_page_id) { |
|
1197 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1200 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1201 | 1201 | |
1202 | 1202 | $find_replace = array( |
1203 | 1203 | '[wpinv_privacy_policy]' => $privacy_link, |
1204 | 1204 | ); |
1205 | 1205 | |
1206 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1206 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1207 | 1207 | |
1208 | 1208 | return wp_kses_post(wpautop($privacy_text)); |
1209 | 1209 | } |
@@ -1211,21 +1211,21 @@ discard block |
||
1211 | 1211 | function wpinv_oxygen_fix_conflict() { |
1212 | 1212 | global $ct_ignore_post_types; |
1213 | 1213 | |
1214 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1214 | + if (!is_array($ct_ignore_post_types)) { |
|
1215 | 1215 | $ct_ignore_post_types = array(); |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1218 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1219 | 1219 | |
1220 | - foreach ( $post_types as $post_type ) { |
|
1220 | + foreach ($post_types as $post_type) { |
|
1221 | 1221 | $ct_ignore_post_types[] = $post_type; |
1222 | 1222 | |
1223 | 1223 | // Ignore post type |
1224 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1224 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1228 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1227 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1228 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | /** |
@@ -1233,10 +1233,10 @@ discard block |
||
1233 | 1233 | * |
1234 | 1234 | * @param GetPaid_Payment_Form $form |
1235 | 1235 | */ |
1236 | -function getpaid_display_payment_form( $form ) { |
|
1236 | +function getpaid_display_payment_form($form) { |
|
1237 | 1237 | |
1238 | - if ( is_numeric( $form ) ) { |
|
1239 | - $form = new GetPaid_Payment_Form( $form ); |
|
1238 | + if (is_numeric($form)) { |
|
1239 | + $form = new GetPaid_Payment_Form($form); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $form->display(); |
@@ -1246,55 +1246,55 @@ discard block |
||
1246 | 1246 | /** |
1247 | 1247 | * Helper function to display a item payment form on the frontend. |
1248 | 1248 | */ |
1249 | -function getpaid_display_item_payment_form( $items ) { |
|
1249 | +function getpaid_display_item_payment_form($items) { |
|
1250 | 1250 | |
1251 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1252 | - $form->set_items( $items ); |
|
1251 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1252 | + $form->set_items($items); |
|
1253 | 1253 | |
1254 | - if ( 0 == count( $form->get_items() ) ) { |
|
1254 | + if (0 == count($form->get_items())) { |
|
1255 | 1255 | echo aui()->alert( |
1256 | 1256 | array( |
1257 | 1257 | 'type' => 'warning', |
1258 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1258 | + 'content' => __('No published items found', 'invoicing'), |
|
1259 | 1259 | ) |
1260 | 1260 | ); |
1261 | 1261 | return; |
1262 | 1262 | } |
1263 | 1263 | |
1264 | - $form_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1264 | + $form_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1265 | 1265 | $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />"; |
1266 | - $form->display( $form_items ); |
|
1266 | + $form->display($form_items); |
|
1267 | 1267 | } |
1268 | 1268 | |
1269 | 1269 | /** |
1270 | 1270 | * Helper function to display an invoice payment form on the frontend. |
1271 | 1271 | */ |
1272 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1272 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1273 | 1273 | |
1274 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1274 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1275 | 1275 | |
1276 | - if ( empty( $invoice ) ) { |
|
1276 | + if (empty($invoice)) { |
|
1277 | 1277 | echo aui()->alert( |
1278 | 1278 | array( |
1279 | 1279 | 'type' => 'warning', |
1280 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1280 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1281 | 1281 | ) |
1282 | 1282 | ); |
1283 | 1283 | return; |
1284 | 1284 | } |
1285 | 1285 | |
1286 | - if ( $invoice->is_paid() ) { |
|
1286 | + if ($invoice->is_paid()) { |
|
1287 | 1287 | echo aui()->alert( |
1288 | 1288 | array( |
1289 | 1289 | 'type' => 'warning', |
1290 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1290 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1291 | 1291 | ) |
1292 | 1292 | ); |
1293 | 1293 | return; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1297 | - $form->set_items( $invoice->get_items() ); |
|
1296 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1297 | + $form->set_items($invoice->get_items()); |
|
1298 | 1298 | |
1299 | 1299 | $form->display(); |
1300 | 1300 | } |
@@ -1302,23 +1302,23 @@ discard block |
||
1302 | 1302 | /** |
1303 | 1303 | * Helper function to convert item string to array. |
1304 | 1304 | */ |
1305 | -function getpaid_convert_items_to_array( $items ) { |
|
1306 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1305 | +function getpaid_convert_items_to_array($items) { |
|
1306 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1307 | 1307 | $prepared = array(); |
1308 | 1308 | |
1309 | - foreach ( $items as $item ) { |
|
1310 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1309 | + foreach ($items as $item) { |
|
1310 | + $data = array_map('trim', explode('|', $item)); |
|
1311 | 1311 | |
1312 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1312 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1313 | 1313 | continue; |
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | $quantity = 1; |
1317 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1317 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1318 | 1318 | $quantity = (float) $data[1]; |
1319 | 1319 | } |
1320 | 1320 | |
1321 | - $prepared[ $data[0] ] = $quantity; |
|
1321 | + $prepared[$data[0]] = $quantity; |
|
1322 | 1322 | |
1323 | 1323 | } |
1324 | 1324 | |
@@ -1328,13 +1328,13 @@ discard block |
||
1328 | 1328 | /** |
1329 | 1329 | * Helper function to convert item array to string. |
1330 | 1330 | */ |
1331 | -function getpaid_convert_items_to_string( $items ) { |
|
1331 | +function getpaid_convert_items_to_string($items) { |
|
1332 | 1332 | $prepared = array(); |
1333 | 1333 | |
1334 | - foreach ( $items as $item => $quantity ) { |
|
1334 | + foreach ($items as $item => $quantity) { |
|
1335 | 1335 | $prepared[] = "$item|$quantity"; |
1336 | 1336 | } |
1337 | - return implode( ',', $prepared ); |
|
1337 | + return implode(',', $prepared); |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | /** |
@@ -1342,21 +1342,21 @@ discard block |
||
1342 | 1342 | * |
1343 | 1343 | * Provide a label and one of $form, $items or $invoice. |
1344 | 1344 | */ |
1345 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1346 | - $label = sanitize_text_field( $label ); |
|
1345 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1346 | + $label = sanitize_text_field($label); |
|
1347 | 1347 | |
1348 | - if ( ! empty( $form ) ) { |
|
1349 | - $form = esc_attr( $form ); |
|
1348 | + if (!empty($form)) { |
|
1349 | + $form = esc_attr($form); |
|
1350 | 1350 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1351 | 1351 | } |
1352 | 1352 | |
1353 | - if ( ! empty( $items ) ) { |
|
1354 | - $items = esc_attr( $items ); |
|
1353 | + if (!empty($items)) { |
|
1354 | + $items = esc_attr($items); |
|
1355 | 1355 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - if ( ! empty( $invoice ) ) { |
|
1359 | - $invoice = esc_attr( $invoice ); |
|
1358 | + if (!empty($invoice)) { |
|
1359 | + $invoice = esc_attr($invoice); |
|
1360 | 1360 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1361 | 1361 | } |
1362 | 1362 | |
@@ -1367,17 +1367,17 @@ discard block |
||
1367 | 1367 | * |
1368 | 1368 | * @param WPInv_Invoice $invoice |
1369 | 1369 | */ |
1370 | -function getpaid_the_invoice_description( $invoice ) { |
|
1370 | +function getpaid_the_invoice_description($invoice) { |
|
1371 | 1371 | $description = $invoice->get_description(); |
1372 | 1372 | |
1373 | - if ( empty( $description ) ) { |
|
1373 | + if (empty($description)) { |
|
1374 | 1374 | return; |
1375 | 1375 | } |
1376 | 1376 | |
1377 | - $description = wp_kses_post( $description ); |
|
1377 | + $description = wp_kses_post($description); |
|
1378 | 1378 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text' style='margin-bottom: 20px; border-left: 2px solid #2196F3;'><em>$description</em></small>"; |
1379 | 1379 | } |
1380 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1380 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1381 | 1381 | |
1382 | 1382 | /** |
1383 | 1383 | * Render element on a form. |
@@ -1385,60 +1385,60 @@ discard block |
||
1385 | 1385 | * @param array $element |
1386 | 1386 | * @param GetPaid_Payment_Form $form |
1387 | 1387 | */ |
1388 | -function getpaid_payment_form_element( $element, $form ) { |
|
1388 | +function getpaid_payment_form_element($element, $form) { |
|
1389 | 1389 | |
1390 | 1390 | // Set up the args. |
1391 | - $element_type = trim( $element['type'] ); |
|
1391 | + $element_type = trim($element['type']); |
|
1392 | 1392 | $element['form'] = $form; |
1393 | - extract( $element ); |
|
1393 | + extract($element); |
|
1394 | 1394 | |
1395 | 1395 | // Try to locate the appropriate template. |
1396 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1396 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1397 | 1397 | |
1398 | 1398 | // Abort if this is not our element. |
1399 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1399 | + if (empty($located) || !file_exists($located)) { |
|
1400 | 1400 | return; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | // Generate the class and id of the element. |
1404 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1405 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1404 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1405 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1406 | 1406 | |
1407 | 1407 | // Echo the opening wrapper. |
1408 | 1408 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
1409 | 1409 | |
1410 | 1410 | // Fires before displaying a given element type's content. |
1411 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1411 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1412 | 1412 | |
1413 | 1413 | // Include the template for the element. |
1414 | 1414 | include $located; |
1415 | 1415 | |
1416 | 1416 | // Fires after displaying a given element type's content. |
1417 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1417 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1418 | 1418 | |
1419 | 1419 | // Echo the closing wrapper. |
1420 | 1420 | echo '</div>'; |
1421 | 1421 | } |
1422 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1422 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1423 | 1423 | |
1424 | 1424 | /** |
1425 | 1425 | * Render an element's edit page. |
1426 | 1426 | * |
1427 | 1427 | * @param WP_Post $post |
1428 | 1428 | */ |
1429 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1429 | +function getpaid_payment_form_edit_element_template($post) { |
|
1430 | 1430 | |
1431 | 1431 | // Retrieve all elements. |
1432 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1432 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1433 | 1433 | |
1434 | - foreach ( $all_elements as $element ) { |
|
1434 | + foreach ($all_elements as $element) { |
|
1435 | 1435 | |
1436 | 1436 | // Try to locate the appropriate template. |
1437 | - $element = sanitize_key( $element ); |
|
1438 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1437 | + $element = sanitize_key($element); |
|
1438 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1439 | 1439 | |
1440 | 1440 | // Continue if this is not our element. |
1441 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1441 | + if (empty($located) || !file_exists($located)) { |
|
1442 | 1442 | continue; |
1443 | 1443 | } |
1444 | 1444 | |
@@ -1449,7 +1449,7 @@ discard block |
||
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | } |
1452 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1452 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1453 | 1453 | |
1454 | 1454 | /** |
1455 | 1455 | * Render an element's preview. |
@@ -1458,16 +1458,16 @@ discard block |
||
1458 | 1458 | function getpaid_payment_form_render_element_preview_template() { |
1459 | 1459 | |
1460 | 1460 | // Retrieve all elements. |
1461 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1461 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1462 | 1462 | |
1463 | - foreach ( $all_elements as $element ) { |
|
1463 | + foreach ($all_elements as $element) { |
|
1464 | 1464 | |
1465 | 1465 | // Try to locate the appropriate template. |
1466 | - $element = sanitize_key( $element ); |
|
1467 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1466 | + $element = sanitize_key($element); |
|
1467 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1468 | 1468 | |
1469 | 1469 | // Continue if this is not our element. |
1470 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1470 | + if (empty($located) || !file_exists($located)) { |
|
1471 | 1471 | continue; |
1472 | 1472 | } |
1473 | 1473 | |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | } |
1481 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1481 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1482 | 1482 | |
1483 | 1483 | /** |
1484 | 1484 | * Shows a list of gateways that support recurring payments. |
@@ -1486,17 +1486,17 @@ discard block |
||
1486 | 1486 | function wpinv_get_recurring_gateways_text() { |
1487 | 1487 | $gateways = array(); |
1488 | 1488 | |
1489 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1490 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1491 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1489 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1490 | + if (wpinv_gateway_support_subscription($key)) { |
|
1491 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1492 | 1492 | } |
1493 | 1493 | } |
1494 | 1494 | |
1495 | - if ( empty( $gateways ) ) { |
|
1496 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
1495 | + if (empty($gateways)) { |
|
1496 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
1497 | 1497 | } |
1498 | 1498 | |
1499 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
1499 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
1500 | 1500 | |
1501 | 1501 | } |
1502 | 1502 | |
@@ -1506,7 +1506,7 @@ discard block |
||
1506 | 1506 | * @return GetPaid_Template |
1507 | 1507 | */ |
1508 | 1508 | function getpaid_template() { |
1509 | - return getpaid()->get( 'template' ); |
|
1509 | + return getpaid()->get('template'); |
|
1510 | 1510 | } |
1511 | 1511 | |
1512 | 1512 | /** |
@@ -1515,8 +1515,8 @@ discard block |
||
1515 | 1515 | * @param array args |
1516 | 1516 | * @return string |
1517 | 1517 | */ |
1518 | -function getpaid_paginate_links( $args ) { |
|
1519 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1518 | +function getpaid_paginate_links($args) { |
|
1519 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | /** |
@@ -1526,21 +1526,21 @@ discard block |
||
1526 | 1526 | * @param string state |
1527 | 1527 | * @return string |
1528 | 1528 | */ |
1529 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
1529 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
1530 | 1530 | |
1531 | - $states = wpinv_get_country_states( $country ); |
|
1532 | - $uniqid = uniqid( '_' ); |
|
1531 | + $states = wpinv_get_country_states($country); |
|
1532 | + $uniqid = uniqid('_'); |
|
1533 | 1533 | |
1534 | - if ( ! empty( $states ) ) { |
|
1534 | + if (!empty($states)) { |
|
1535 | 1535 | |
1536 | - return aui()->select( array( |
|
1536 | + return aui()->select(array( |
|
1537 | 1537 | 'options' => $states, |
1538 | - 'name' => esc_attr( $field_name ), |
|
1539 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1540 | - 'value' => sanitize_text_field( $state ), |
|
1538 | + 'name' => esc_attr($field_name), |
|
1539 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1540 | + 'value' => sanitize_text_field($state), |
|
1541 | 1541 | 'placeholder' => $placeholder, |
1542 | 1542 | 'required' => $required, |
1543 | - 'label' => wp_kses_post( $label ), |
|
1543 | + 'label' => wp_kses_post($label), |
|
1544 | 1544 | 'label_type' => 'vertical', |
1545 | 1545 | 'help_text' => $help_text, |
1546 | 1546 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1555,14 +1555,14 @@ discard block |
||
1555 | 1555 | |
1556 | 1556 | return aui()->input( |
1557 | 1557 | array( |
1558 | - 'name' => esc_attr( $field_name ), |
|
1559 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1558 | + 'name' => esc_attr($field_name), |
|
1559 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1560 | 1560 | 'placeholder' => $placeholder, |
1561 | 1561 | 'required' => $required, |
1562 | - 'label' => wp_kses_post( $label ), |
|
1562 | + 'label' => wp_kses_post($label), |
|
1563 | 1563 | 'label_type' => 'vertical', |
1564 | 1564 | 'help_text' => $help_text, |
1565 | - 'value' => sanitize_text_field( $state ), |
|
1565 | + 'value' => sanitize_text_field($state), |
|
1566 | 1566 | 'class' => 'getpaid-address-field wpinv_state', |
1567 | 1567 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1568 | 1568 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1580,16 +1580,16 @@ discard block |
||
1580 | 1580 | * @param array $element |
1581 | 1581 | * @return string |
1582 | 1582 | */ |
1583 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1583 | +function getpaid_get_form_element_grid_class($element) { |
|
1584 | 1584 | |
1585 | 1585 | $class = "col-12"; |
1586 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1586 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1587 | 1587 | |
1588 | - if ( $width == 'half' ) { |
|
1588 | + if ($width == 'half') { |
|
1589 | 1589 | $class = "col-12 col-md-6"; |
1590 | 1590 | } |
1591 | 1591 | |
1592 | - if ( $width == 'third' ) { |
|
1592 | + if ($width == 'third') { |
|
1593 | 1593 | $class = "col-12 col-md-4"; |
1594 | 1594 | } |
1595 | 1595 |