@@ -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' => -1, |
| 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 | $attr = ''; |
| 561 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 561 | + if (!empty($args['options']['disabled'])) { |
|
| 562 | 562 | $attr .= ' disabled="disabled"'; |
| 563 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 563 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 564 | 564 | $attr .= ' readonly'; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 567 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 568 | 568 | |
| 569 | 569 | return $output; |
| 570 | 570 | } |
@@ -572,34 +572,34 @@ discard block |
||
| 572 | 572 | /** |
| 573 | 573 | * Displays a hidden field. |
| 574 | 574 | */ |
| 575 | -function getpaid_hidden_field( $name, $value ) { |
|
| 576 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value=' " . esc_attr( $value ) . "' />"; |
|
| 575 | +function getpaid_hidden_field($name, $value) { |
|
| 576 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value=' " . esc_attr($value) . "' />"; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | /** |
| 580 | 580 | * Displays a submit field. |
| 581 | 581 | */ |
| 582 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
| 583 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
| 582 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
| 583 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | -function wpinv_html_text( $args = array() ) { |
|
| 586 | +function wpinv_html_text($args = array()) { |
|
| 587 | 587 | // Backwards compatibility |
| 588 | - if ( func_num_args() > 1 ) { |
|
| 588 | + if (func_num_args() > 1) { |
|
| 589 | 589 | $args = func_get_args(); |
| 590 | 590 | |
| 591 | 591 | $name = $args[0]; |
| 592 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 593 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 594 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 592 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 593 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 594 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | $defaults = array( |
| 598 | 598 | 'id' => '', |
| 599 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 600 | - 'value' => isset( $value ) ? $value : null, |
|
| 601 | - 'label' => isset( $label ) ? $label : null, |
|
| 602 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 599 | + 'name' => isset($name) ? $name : 'text', |
|
| 600 | + 'value' => isset($value) ? $value : null, |
|
| 601 | + 'label' => isset($label) ? $label : null, |
|
| 602 | + 'desc' => isset($desc) ? $desc : null, |
|
| 603 | 603 | 'placeholder' => '', |
| 604 | 604 | 'class' => 'regular-text', |
| 605 | 605 | 'disabled' => false, |
@@ -609,41 +609,41 @@ discard block |
||
| 609 | 609 | 'data' => false |
| 610 | 610 | ); |
| 611 | 611 | |
| 612 | - $args = wp_parse_args( $args, $defaults ); |
|
| 612 | + $args = wp_parse_args($args, $defaults); |
|
| 613 | 613 | |
| 614 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 614 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 615 | 615 | $options = ''; |
| 616 | - if( $args['required'] ) { |
|
| 616 | + if ($args['required']) { |
|
| 617 | 617 | $options .= ' required="required"'; |
| 618 | 618 | } |
| 619 | - if( $args['readonly'] ) { |
|
| 619 | + if ($args['readonly']) { |
|
| 620 | 620 | $options .= ' readonly'; |
| 621 | 621 | } |
| 622 | - if( $args['readonly'] ) { |
|
| 622 | + if ($args['readonly']) { |
|
| 623 | 623 | $options .= ' readonly'; |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | $data = ''; |
| 627 | - if ( !empty( $args['data'] ) ) { |
|
| 628 | - foreach ( $args['data'] as $key => $value ) { |
|
| 629 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 627 | + if (!empty($args['data'])) { |
|
| 628 | + foreach ($args['data'] as $key => $value) { |
|
| 629 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 634 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 635 | - if ( ! empty( $args['desc'] ) ) { |
|
| 636 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 633 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 634 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 635 | + if (!empty($args['desc'])) { |
|
| 636 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - $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 ) . '/>'; |
|
| 639 | + $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) . '/>'; |
|
| 640 | 640 | |
| 641 | 641 | $output .= '</span>'; |
| 642 | 642 | |
| 643 | 643 | return $output; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | -function wpinv_html_textarea( $args = array() ) { |
|
| 646 | +function wpinv_html_textarea($args = array()) { |
|
| 647 | 647 | $defaults = array( |
| 648 | 648 | 'name' => 'textarea', |
| 649 | 649 | 'value' => null, |
@@ -654,31 +654,31 @@ discard block |
||
| 654 | 654 | 'placeholder' => '', |
| 655 | 655 | ); |
| 656 | 656 | |
| 657 | - $args = wp_parse_args( $args, $defaults ); |
|
| 657 | + $args = wp_parse_args($args, $defaults); |
|
| 658 | 658 | |
| 659 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 659 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 660 | 660 | $disabled = ''; |
| 661 | - if( $args['disabled'] ) { |
|
| 661 | + if ($args['disabled']) { |
|
| 662 | 662 | $disabled = ' disabled="disabled"'; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 666 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 667 | - $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>'; |
|
| 665 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 666 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 667 | + $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>'; |
|
| 668 | 668 | |
| 669 | - if ( ! empty( $args['desc'] ) ) { |
|
| 670 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 669 | + if (!empty($args['desc'])) { |
|
| 670 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 671 | 671 | } |
| 672 | 672 | $output .= '</span>'; |
| 673 | 673 | |
| 674 | 674 | return $output; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 677 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 678 | 678 | $defaults = array( |
| 679 | 679 | 'name' => 'user_id', |
| 680 | 680 | 'value' => null, |
| 681 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 681 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 682 | 682 | 'label' => null, |
| 683 | 683 | 'desc' => null, |
| 684 | 684 | 'class' => '', |
@@ -687,13 +687,13 @@ discard block |
||
| 687 | 687 | 'data' => false |
| 688 | 688 | ); |
| 689 | 689 | |
| 690 | - $args = wp_parse_args( $args, $defaults ); |
|
| 690 | + $args = wp_parse_args($args, $defaults); |
|
| 691 | 691 | |
| 692 | 692 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 693 | 693 | |
| 694 | 694 | $output = '<span class="wpinv_user_search_wrap">'; |
| 695 | - $output .= wpinv_html_text( $args ); |
|
| 696 | - $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>'; |
|
| 695 | + $output .= wpinv_html_text($args); |
|
| 696 | + $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>'; |
|
| 697 | 697 | $output .= '</span>'; |
| 698 | 698 | |
| 699 | 699 | return $output; |
@@ -704,20 +704,20 @@ discard block |
||
| 704 | 704 | * |
| 705 | 705 | * @param string $template the template that is currently being used. |
| 706 | 706 | */ |
| 707 | -function wpinv_template( $template ) { |
|
| 707 | +function wpinv_template($template) { |
|
| 708 | 708 | global $post; |
| 709 | 709 | |
| 710 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 710 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 711 | 711 | |
| 712 | 712 | // If the user can view this invoice, display it. |
| 713 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 713 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 714 | 714 | |
| 715 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 715 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 716 | 716 | |
| 717 | 717 | // Else display an error message. |
| 718 | 718 | } else { |
| 719 | 719 | |
| 720 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 720 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 721 | 721 | |
| 722 | 722 | } |
| 723 | 723 | |
@@ -725,24 +725,24 @@ discard block |
||
| 725 | 725 | |
| 726 | 726 | return $template; |
| 727 | 727 | } |
| 728 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 728 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 729 | 729 | |
| 730 | 730 | function wpinv_get_business_address() { |
| 731 | 731 | $business_address = wpinv_store_address(); |
| 732 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 732 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 733 | 733 | |
| 734 | 734 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 735 | 735 | |
| 736 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 736 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | /** |
| 740 | 740 | * Displays the company address. |
| 741 | 741 | */ |
| 742 | 742 | function wpinv_display_from_address() { |
| 743 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 743 | + wpinv_get_template('invoice/company-address.php'); |
|
| 744 | 744 | } |
| 745 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 745 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 746 | 746 | |
| 747 | 747 | /** |
| 748 | 748 | * Generates a watermark text for an invoice. |
@@ -750,9 +750,9 @@ discard block |
||
| 750 | 750 | * @param WPInv_Invoice $invoice |
| 751 | 751 | * @return string |
| 752 | 752 | */ |
| 753 | -function wpinv_watermark( $invoice ) { |
|
| 754 | - $watermark = wpinv_get_watermark( $invoice ); |
|
| 755 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
| 753 | +function wpinv_watermark($invoice) { |
|
| 754 | + $watermark = wpinv_get_watermark($invoice); |
|
| 755 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | /** |
@@ -761,37 +761,37 @@ discard block |
||
| 761 | 761 | * @param WPInv_Invoice $invoice |
| 762 | 762 | * @return string |
| 763 | 763 | */ |
| 764 | -function wpinv_get_watermark( $invoice ) { |
|
| 764 | +function wpinv_get_watermark($invoice) { |
|
| 765 | 765 | return $invoice->get_status_nicename(); |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | /** |
| 769 | 769 | * @deprecated |
| 770 | 770 | */ |
| 771 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 772 | - return getpaid_invoice_meta( $invoice ); |
|
| 771 | +function wpinv_display_invoice_details($invoice) { |
|
| 772 | + return getpaid_invoice_meta($invoice); |
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | /** |
| 776 | 776 | * Displays invoice meta. |
| 777 | 777 | */ |
| 778 | -function getpaid_invoice_meta( $invoice ) { |
|
| 778 | +function getpaid_invoice_meta($invoice) { |
|
| 779 | 779 | |
| 780 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 780 | + $invoice = new WPInv_Invoice($invoice); |
|
| 781 | 781 | |
| 782 | 782 | // Ensure that we have an invoice. |
| 783 | - if ( 0 == $invoice->get_id() ) { |
|
| 783 | + if (0 == $invoice->get_id()) { |
|
| 784 | 784 | return; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | // Get the invoice meta. |
| 788 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
| 788 | + $meta = getpaid_get_invoice_meta($invoice); |
|
| 789 | 789 | |
| 790 | 790 | // Display the meta. |
| 791 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 791 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 792 | 792 | |
| 793 | 793 | } |
| 794 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 794 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * Retrieves the address markup to use on Invoices. |
@@ -803,29 +803,29 @@ discard block |
||
| 803 | 803 | * @param string $separator How to separate address lines. |
| 804 | 804 | * @return string |
| 805 | 805 | */ |
| 806 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 806 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 807 | 807 | |
| 808 | 808 | // Retrieve the address markup... |
| 809 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 810 | - $format = wpinv_get_full_address_format( $country ); |
|
| 809 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 810 | + $format = wpinv_get_full_address_format($country); |
|
| 811 | 811 | |
| 812 | 812 | // ... and the replacements. |
| 813 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 813 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 814 | 814 | |
| 815 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 815 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 816 | 816 | |
| 817 | 817 | // Remove unavailable tags. |
| 818 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 818 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 819 | 819 | |
| 820 | 820 | // Clean up white space. |
| 821 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 822 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 821 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 822 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 823 | 823 | |
| 824 | 824 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 825 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 825 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 826 | 826 | |
| 827 | 827 | // Add html breaks. |
| 828 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 828 | + $formatted_address = implode($separator, $formatted_address); |
|
| 829 | 829 | |
| 830 | 830 | // We're done! |
| 831 | 831 | return $formatted_address; |
@@ -837,119 +837,119 @@ discard block |
||
| 837 | 837 | * |
| 838 | 838 | * @param WPInv_Invoice $invoice |
| 839 | 839 | */ |
| 840 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 841 | - if ( ! empty( $invoice ) ) { |
|
| 842 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 840 | +function wpinv_display_to_address($invoice = 0) { |
|
| 841 | + if (!empty($invoice)) { |
|
| 842 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 845 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 846 | 846 | |
| 847 | 847 | |
| 848 | 848 | /** |
| 849 | 849 | * Displays invoice line items. |
| 850 | 850 | */ |
| 851 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 851 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 852 | 852 | |
| 853 | 853 | // Prepare the invoice. |
| 854 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 854 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 855 | 855 | |
| 856 | 856 | // Abort if there is no invoice. |
| 857 | - if ( 0 == $invoice->get_id() ) { |
|
| 857 | + if (0 == $invoice->get_id()) { |
|
| 858 | 858 | return; |
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | // Line item columns. |
| 862 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 863 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 862 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 863 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 864 | 864 | |
| 865 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 865 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 866 | 866 | } |
| 867 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 867 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 868 | 868 | |
| 869 | 869 | /** |
| 870 | 870 | * Displays invoice subscriptions. |
| 871 | 871 | * |
| 872 | 872 | * @param WPInv_Invoice $invoice |
| 873 | 873 | */ |
| 874 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
| 874 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
| 875 | 875 | |
| 876 | 876 | // Subscriptions. |
| 877 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 877 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 878 | 878 | |
| 879 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
| 879 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
| 880 | 880 | return; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 883 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
| 884 | 884 | |
| 885 | 885 | // Display related subscriptions. |
| 886 | - if ( is_array( $subscriptions ) ) { |
|
| 887 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
| 888 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
| 886 | + if (is_array($subscriptions)) { |
|
| 887 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
| 888 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
| 892 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
| 893 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
| 891 | + if ($main_subscription->get_total_payments() > 1) { |
|
| 892 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
| 893 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | } |
| 897 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
| 898 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
| 897 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
| 898 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
| 899 | 899 | |
| 900 | 900 | /** |
| 901 | 901 | * Displays invoice notices on invoices. |
| 902 | 902 | */ |
| 903 | 903 | function wpinv_display_invoice_notice() { |
| 904 | 904 | |
| 905 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 906 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 905 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 906 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 907 | 907 | |
| 908 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 908 | + if (empty($label) && empty($notice)) { |
|
| 909 | 909 | return; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | 912 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 913 | 913 | |
| 914 | - if ( ! empty( $label ) ) { |
|
| 915 | - $label = esc_html( $label ); |
|
| 914 | + if (!empty($label)) { |
|
| 915 | + $label = esc_html($label); |
|
| 916 | 916 | echo "<h5>$label</h5>"; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - if ( ! empty( $notice ) ) { |
|
| 920 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>'; |
|
| 919 | + if (!empty($notice)) { |
|
| 920 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>'; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | echo '</div>'; |
| 924 | 924 | } |
| 925 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 925 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | 928 | * @param WPInv_Invoice $invoice |
| 929 | 929 | */ |
| 930 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 930 | +function wpinv_display_invoice_notes($invoice) { |
|
| 931 | 931 | |
| 932 | 932 | // Retrieve the notes. |
| 933 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 933 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 934 | 934 | |
| 935 | 935 | // Abort if we have non. |
| 936 | - if ( empty( $notes ) ) { |
|
| 936 | + if (empty($notes)) { |
|
| 937 | 937 | return; |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | // Echo the note. |
| 941 | 941 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
| 942 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __( 'Notes', 'invoicing' ) .'</h2>'; |
|
| 942 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . __('Notes', 'invoicing') . '</h2>'; |
|
| 943 | 943 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
| 944 | 944 | |
| 945 | - foreach( $notes as $note ) { |
|
| 946 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 945 | + foreach ($notes as $note) { |
|
| 946 | + wpinv_get_invoice_note_line_item($note); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | echo '</ul>'; |
| 950 | 950 | echo '</div>'; |
| 951 | 951 | } |
| 952 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 952 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 953 | 953 | |
| 954 | 954 | /** |
| 955 | 955 | * Loads scripts on our invoice templates. |
@@ -957,32 +957,32 @@ discard block |
||
| 957 | 957 | function wpinv_display_style() { |
| 958 | 958 | |
| 959 | 959 | // Make sure that all scripts have been loaded. |
| 960 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 961 | - do_action( 'wp_enqueue_scripts' ); |
|
| 960 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 961 | + do_action('wp_enqueue_scripts'); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | // Register the invoices style. |
| 965 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 965 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 966 | 966 | |
| 967 | 967 | // Load required styles |
| 968 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 969 | - wp_print_styles( 'ayecode-ui' ); |
|
| 968 | + wp_print_styles('wpinv-single-style'); |
|
| 969 | + wp_print_styles('ayecode-ui'); |
|
| 970 | 970 | |
| 971 | 971 | // Maybe load custom css. |
| 972 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 972 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 973 | 973 | |
| 974 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 975 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 976 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 974 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 975 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 976 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 977 | 977 | echo '<style type="text/css">'; |
| 978 | - echo wp_kses_post( $custom_css ); |
|
| 978 | + echo wp_kses_post($custom_css); |
|
| 979 | 979 | echo '</style>'; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | wp_site_icon(); |
| 983 | 983 | } |
| 984 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 985 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 984 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 985 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 986 | 986 | |
| 987 | 987 | |
| 988 | 988 | /** |
@@ -994,41 +994,41 @@ discard block |
||
| 994 | 994 | // Retrieve the current invoice. |
| 995 | 995 | $invoice_id = getpaid_get_current_invoice_id(); |
| 996 | 996 | |
| 997 | - if ( empty( $invoice_id ) ) { |
|
| 997 | + if (empty($invoice_id)) { |
|
| 998 | 998 | |
| 999 | 999 | return aui()->alert( |
| 1000 | 1000 | array( |
| 1001 | 1001 | 'type' => 'warning', |
| 1002 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 1002 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 1003 | 1003 | ) |
| 1004 | 1004 | ); |
| 1005 | 1005 | |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | // Can the user view this invoice? |
| 1009 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 1009 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 1010 | 1010 | |
| 1011 | 1011 | return aui()->alert( |
| 1012 | 1012 | array( |
| 1013 | 1013 | 'type' => 'warning', |
| 1014 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 1014 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 1015 | 1015 | ) |
| 1016 | 1016 | ); |
| 1017 | 1017 | |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | // Ensure that it is not yet paid for. |
| 1021 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1021 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1022 | 1022 | |
| 1023 | 1023 | // Maybe mark it as viewed. |
| 1024 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 1024 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 1025 | 1025 | |
| 1026 | - if ( $invoice->is_paid() ) { |
|
| 1026 | + if ($invoice->is_paid()) { |
|
| 1027 | 1027 | |
| 1028 | 1028 | return aui()->alert( |
| 1029 | 1029 | array( |
| 1030 | 1030 | 'type' => 'success', |
| 1031 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 1031 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 1032 | 1032 | ) |
| 1033 | 1033 | ); |
| 1034 | 1034 | |
@@ -1038,15 +1038,15 @@ discard block |
||
| 1038 | 1038 | $wpi_checkout_id = $invoice_id; |
| 1039 | 1039 | |
| 1040 | 1040 | // Retrieve appropriate payment form. |
| 1041 | - $payment_form = new GetPaid_Payment_Form( $invoice->get_meta( 'force_payment_form' ) ); |
|
| 1042 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1041 | + $payment_form = new GetPaid_Payment_Form($invoice->get_meta('force_payment_form')); |
|
| 1042 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1043 | 1043 | |
| 1044 | - if ( ! $payment_form->exists() ) { |
|
| 1044 | + if (!$payment_form->exists()) { |
|
| 1045 | 1045 | |
| 1046 | 1046 | return aui()->alert( |
| 1047 | 1047 | array( |
| 1048 | 1048 | 'type' => 'warning', |
| 1049 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1049 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1050 | 1050 | ) |
| 1051 | 1051 | ); |
| 1052 | 1052 | |
@@ -1055,29 +1055,29 @@ discard block |
||
| 1055 | 1055 | // Set the invoice. |
| 1056 | 1056 | $payment_form->invoice = $invoice; |
| 1057 | 1057 | |
| 1058 | - if ( ! $payment_form->is_default() ) { |
|
| 1058 | + if (!$payment_form->is_default()) { |
|
| 1059 | 1059 | |
| 1060 | 1060 | $items = array(); |
| 1061 | 1061 | $item_ids = array(); |
| 1062 | 1062 | |
| 1063 | - foreach ( $invoice->get_items() as $item ) { |
|
| 1064 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1063 | + foreach ($invoice->get_items() as $item) { |
|
| 1064 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1065 | 1065 | $item_ids[] = $item->get_id(); |
| 1066 | 1066 | $items[] = $item; |
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - foreach ( $payment_form->get_items() as $item ) { |
|
| 1071 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
| 1070 | + foreach ($payment_form->get_items() as $item) { |
|
| 1071 | + if (!in_array($item->get_id(), $item_ids)) { |
|
| 1072 | 1072 | $item_ids[] = $item->get_id(); |
| 1073 | 1073 | $items[] = $item; |
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | - $payment_form->set_items( $items ); |
|
| 1077 | + $payment_form->set_items($items); |
|
| 1078 | 1078 | |
| 1079 | 1079 | } else { |
| 1080 | - $payment_form->set_items( $invoice->get_items() ); |
|
| 1080 | + $payment_form->set_items($invoice->get_items()); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | // Generate the html. |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | function wpinv_empty_cart_message() { |
| 1089 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1089 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | /** |
@@ -1103,76 +1103,76 @@ discard block |
||
| 1103 | 1103 | ) |
| 1104 | 1104 | ); |
| 1105 | 1105 | } |
| 1106 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1106 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1107 | 1107 | |
| 1108 | 1108 | /** |
| 1109 | 1109 | * Filters the receipt page. |
| 1110 | 1110 | */ |
| 1111 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1111 | +function wpinv_filter_success_page_content($content) { |
|
| 1112 | 1112 | |
| 1113 | 1113 | // Maybe abort early. |
| 1114 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
| 1114 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
| 1115 | 1115 | return $content; |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | // Ensure this is our page. |
| 1119 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1119 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1120 | 1120 | |
| 1121 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1122 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1121 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1122 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1123 | 1123 | |
| 1124 | 1124 | } |
| 1125 | 1125 | |
| 1126 | 1126 | return $content; |
| 1127 | 1127 | } |
| 1128 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1128 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1129 | 1129 | |
| 1130 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1131 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1130 | +function wpinv_invoice_link($invoice_id) { |
|
| 1131 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1132 | 1132 | |
| 1133 | - if ( empty( $invoice ) ) { |
|
| 1133 | + if (empty($invoice)) { |
|
| 1134 | 1134 | return NULL; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1137 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1138 | 1138 | |
| 1139 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1139 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1143 | - if ( empty( $note ) ) { |
|
| 1142 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1143 | + if (empty($note)) { |
|
| 1144 | 1144 | return NULL; |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - if ( is_int( $note ) ) { |
|
| 1148 | - $note = get_comment( $note ); |
|
| 1147 | + if (is_int($note)) { |
|
| 1148 | + $note = get_comment($note); |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1151 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1152 | 1152 | return NULL; |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - $note_classes = array( 'note' ); |
|
| 1156 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1155 | + $note_classes = array('note'); |
|
| 1156 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1157 | 1157 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1158 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1159 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1158 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1159 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1160 | 1160 | |
| 1161 | 1161 | ob_start(); |
| 1162 | 1162 | ?> |
| 1163 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
| 1163 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
| 1164 | 1164 | <div class="note_content"> |
| 1165 | 1165 | |
| 1166 | - <?php echo wptexturize( wp_kses_post( $note->comment_content ) ); ?> |
|
| 1166 | + <?php echo wptexturize(wp_kses_post($note->comment_content)); ?> |
|
| 1167 | 1167 | |
| 1168 | - <?php if ( ! is_admin() ) : ?> |
|
| 1168 | + <?php if (!is_admin()) : ?> |
|
| 1169 | 1169 | <em class="small form-text text-muted mt-0"> |
| 1170 | 1170 | <?php |
| 1171 | 1171 | printf( |
| 1172 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1172 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1173 | 1173 | $note->comment_author, |
| 1174 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1175 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1174 | + getpaid_format_date_value($note->comment_date), |
|
| 1175 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1176 | 1176 | ); |
| 1177 | 1177 | ?> |
| 1178 | 1178 | </em> |
@@ -1180,21 +1180,21 @@ discard block |
||
| 1180 | 1180 | |
| 1181 | 1181 | </div> |
| 1182 | 1182 | |
| 1183 | - <?php if ( is_admin() ) : ?> |
|
| 1183 | + <?php if (is_admin()) : ?> |
|
| 1184 | 1184 | |
| 1185 | 1185 | <p class="meta px-4 py-2"> |
| 1186 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1186 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1187 | 1187 | <?php |
| 1188 | 1188 | printf( |
| 1189 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1189 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1190 | 1190 | $note->comment_author, |
| 1191 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1192 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1191 | + getpaid_format_date_value($note->comment_date), |
|
| 1192 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1193 | 1193 | ); |
| 1194 | 1194 | ?> |
| 1195 | 1195 | </abbr> |
| 1196 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1197 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1196 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1197 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 1198 | 1198 | <?php } ?> |
| 1199 | 1199 | </p> |
| 1200 | 1200 | |
@@ -1203,10 +1203,10 @@ discard block |
||
| 1203 | 1203 | </li> |
| 1204 | 1204 | <?php |
| 1205 | 1205 | $note_content = ob_get_clean(); |
| 1206 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1206 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1207 | 1207 | |
| 1208 | - if ( $echo ) { |
|
| 1209 | - echo wp_kses_post( $note_content ); |
|
| 1208 | + if ($echo) { |
|
| 1209 | + echo wp_kses_post($note_content); |
|
| 1210 | 1210 | } else { |
| 1211 | 1211 | return $note_content; |
| 1212 | 1212 | } |
@@ -1219,21 +1219,21 @@ discard block |
||
| 1219 | 1219 | * @return string |
| 1220 | 1220 | */ |
| 1221 | 1221 | function wpinv_get_policy_text() { |
| 1222 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1222 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1223 | 1223 | |
| 1224 | - $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]' )); |
|
| 1224 | + $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]')); |
|
| 1225 | 1225 | |
| 1226 | - if(!$privacy_page_id){ |
|
| 1227 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1226 | + if (!$privacy_page_id) { |
|
| 1227 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - $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' ); |
|
| 1230 | + $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'); |
|
| 1231 | 1231 | |
| 1232 | 1232 | $find_replace = array( |
| 1233 | 1233 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1234 | 1234 | ); |
| 1235 | 1235 | |
| 1236 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1236 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1237 | 1237 | |
| 1238 | 1238 | return wp_kses_post(wpautop($privacy_text)); |
| 1239 | 1239 | } |
@@ -1241,21 +1241,21 @@ discard block |
||
| 1241 | 1241 | function wpinv_oxygen_fix_conflict() { |
| 1242 | 1242 | global $ct_ignore_post_types; |
| 1243 | 1243 | |
| 1244 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1244 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1245 | 1245 | $ct_ignore_post_types = array(); |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
| 1248 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
| 1249 | 1249 | |
| 1250 | - foreach ( $post_types as $post_type ) { |
|
| 1250 | + foreach ($post_types as $post_type) { |
|
| 1251 | 1251 | $ct_ignore_post_types[] = $post_type; |
| 1252 | 1252 | |
| 1253 | 1253 | // Ignore post type |
| 1254 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1254 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1258 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1257 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1258 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | /** |
@@ -1263,10 +1263,10 @@ discard block |
||
| 1263 | 1263 | * |
| 1264 | 1264 | * @param GetPaid_Payment_Form $form |
| 1265 | 1265 | */ |
| 1266 | -function getpaid_display_payment_form( $form ) { |
|
| 1266 | +function getpaid_display_payment_form($form) { |
|
| 1267 | 1267 | |
| 1268 | - if ( is_numeric( $form ) ) { |
|
| 1269 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 1268 | + if (is_numeric($form)) { |
|
| 1269 | + $form = new GetPaid_Payment_Form($form); |
|
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | 1272 | $form->display(); |
@@ -1276,58 +1276,58 @@ discard block |
||
| 1276 | 1276 | /** |
| 1277 | 1277 | * Helper function to display a item payment form on the frontend. |
| 1278 | 1278 | */ |
| 1279 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1279 | +function getpaid_display_item_payment_form($items) { |
|
| 1280 | 1280 | |
| 1281 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1282 | - $form->set_items( $items ); |
|
| 1281 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1282 | + $form->set_items($items); |
|
| 1283 | 1283 | |
| 1284 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1284 | + if (0 == count($form->get_items())) { |
|
| 1285 | 1285 | echo aui()->alert( |
| 1286 | 1286 | array( |
| 1287 | 1287 | 'type' => 'warning', |
| 1288 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1288 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1289 | 1289 | ) |
| 1290 | 1290 | ); |
| 1291 | 1291 | return; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
| 1295 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
| 1294 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
| 1295 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
| 1296 | 1296 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
| 1297 | 1297 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
| 1298 | 1298 | |
| 1299 | - $form->display( $extra_items ); |
|
| 1299 | + $form->display($extra_items); |
|
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | /** |
| 1303 | 1303 | * Helper function to display an invoice payment form on the frontend. |
| 1304 | 1304 | */ |
| 1305 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1305 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1306 | 1306 | |
| 1307 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1307 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1308 | 1308 | |
| 1309 | - if ( empty( $invoice ) ) { |
|
| 1309 | + if (empty($invoice)) { |
|
| 1310 | 1310 | echo aui()->alert( |
| 1311 | 1311 | array( |
| 1312 | 1312 | 'type' => 'warning', |
| 1313 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1313 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1314 | 1314 | ) |
| 1315 | 1315 | ); |
| 1316 | 1316 | return; |
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | - if ( $invoice->is_paid() ) { |
|
| 1319 | + if ($invoice->is_paid()) { |
|
| 1320 | 1320 | echo aui()->alert( |
| 1321 | 1321 | array( |
| 1322 | 1322 | 'type' => 'warning', |
| 1323 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1323 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1324 | 1324 | ) |
| 1325 | 1325 | ); |
| 1326 | 1326 | return; |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1330 | - $form->set_items( $invoice->get_items() ); |
|
| 1329 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1330 | + $form->set_items($invoice->get_items()); |
|
| 1331 | 1331 | |
| 1332 | 1332 | $form->display(); |
| 1333 | 1333 | } |
@@ -1335,23 +1335,23 @@ discard block |
||
| 1335 | 1335 | /** |
| 1336 | 1336 | * Helper function to convert item string to array. |
| 1337 | 1337 | */ |
| 1338 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1339 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1338 | +function getpaid_convert_items_to_array($items) { |
|
| 1339 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1340 | 1340 | $prepared = array(); |
| 1341 | 1341 | |
| 1342 | - foreach ( $items as $item ) { |
|
| 1343 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1342 | + foreach ($items as $item) { |
|
| 1343 | + $data = array_map('trim', explode('|', $item)); |
|
| 1344 | 1344 | |
| 1345 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1345 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1346 | 1346 | continue; |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | 1349 | $quantity = 1; |
| 1350 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1350 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1351 | 1351 | $quantity = (float) $data[1]; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | - $prepared[ $data[0] ] = $quantity; |
|
| 1354 | + $prepared[$data[0]] = $quantity; |
|
| 1355 | 1355 | |
| 1356 | 1356 | } |
| 1357 | 1357 | |
@@ -1361,13 +1361,13 @@ discard block |
||
| 1361 | 1361 | /** |
| 1362 | 1362 | * Helper function to convert item array to string. |
| 1363 | 1363 | */ |
| 1364 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1364 | +function getpaid_convert_items_to_string($items) { |
|
| 1365 | 1365 | $prepared = array(); |
| 1366 | 1366 | |
| 1367 | - foreach ( $items as $item => $quantity ) { |
|
| 1367 | + foreach ($items as $item => $quantity) { |
|
| 1368 | 1368 | $prepared[] = "$item|$quantity"; |
| 1369 | 1369 | } |
| 1370 | - return implode( ',', $prepared ); |
|
| 1370 | + return implode(',', $prepared); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | 1373 | /** |
@@ -1375,21 +1375,21 @@ discard block |
||
| 1375 | 1375 | * |
| 1376 | 1376 | * Provide a label and one of $form, $items or $invoice. |
| 1377 | 1377 | */ |
| 1378 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1379 | - $label = sanitize_text_field( $label ); |
|
| 1378 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1379 | + $label = sanitize_text_field($label); |
|
| 1380 | 1380 | |
| 1381 | - if ( ! empty( $form ) ) { |
|
| 1382 | - $form = esc_attr( $form ); |
|
| 1381 | + if (!empty($form)) { |
|
| 1382 | + $form = esc_attr($form); |
|
| 1383 | 1383 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - if ( ! empty( $items ) ) { |
|
| 1387 | - $items = esc_attr( $items ); |
|
| 1386 | + if (!empty($items)) { |
|
| 1387 | + $items = esc_attr($items); |
|
| 1388 | 1388 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | - if ( ! empty( $invoice ) ) { |
|
| 1392 | - $invoice = esc_attr( $invoice ); |
|
| 1391 | + if (!empty($invoice)) { |
|
| 1392 | + $invoice = esc_attr($invoice); |
|
| 1393 | 1393 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
| 1394 | 1394 | } |
| 1395 | 1395 | |
@@ -1400,18 +1400,18 @@ discard block |
||
| 1400 | 1400 | * |
| 1401 | 1401 | * @param WPInv_Invoice $invoice |
| 1402 | 1402 | */ |
| 1403 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1403 | +function getpaid_the_invoice_description($invoice) { |
|
| 1404 | 1404 | $description = $invoice->get_description(); |
| 1405 | 1405 | |
| 1406 | - if ( empty( $description ) ) { |
|
| 1406 | + if (empty($description)) { |
|
| 1407 | 1407 | return; |
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | - $description = wp_kses_post( wpautop( $description ) ); |
|
| 1410 | + $description = wp_kses_post(wpautop($description)); |
|
| 1411 | 1411 | 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>"; |
| 1412 | 1412 | } |
| 1413 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1414 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
| 1413 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1414 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
| 1415 | 1415 | |
| 1416 | 1416 | /** |
| 1417 | 1417 | * Render element on a form. |
@@ -1419,60 +1419,60 @@ discard block |
||
| 1419 | 1419 | * @param array $element |
| 1420 | 1420 | * @param GetPaid_Payment_Form $form |
| 1421 | 1421 | */ |
| 1422 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1422 | +function getpaid_payment_form_element($element, $form) { |
|
| 1423 | 1423 | |
| 1424 | 1424 | // Set up the args. |
| 1425 | - $element_type = trim( $element['type'] ); |
|
| 1425 | + $element_type = trim($element['type']); |
|
| 1426 | 1426 | $element['form'] = $form; |
| 1427 | - extract( $element ); |
|
| 1427 | + extract($element); |
|
| 1428 | 1428 | |
| 1429 | 1429 | // Try to locate the appropriate template. |
| 1430 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1430 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1431 | 1431 | |
| 1432 | 1432 | // Abort if this is not our element. |
| 1433 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1433 | + if (empty($located) || !file_exists($located)) { |
|
| 1434 | 1434 | return; |
| 1435 | 1435 | } |
| 1436 | 1436 | |
| 1437 | 1437 | // Generate the class and id of the element. |
| 1438 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1439 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1438 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1439 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1440 | 1440 | |
| 1441 | 1441 | // Echo the opening wrapper. |
| 1442 | 1442 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
| 1443 | 1443 | |
| 1444 | 1444 | // Fires before displaying a given element type's content. |
| 1445 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1445 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1446 | 1446 | |
| 1447 | 1447 | // Include the template for the element. |
| 1448 | 1448 | include $located; |
| 1449 | 1449 | |
| 1450 | 1450 | // Fires after displaying a given element type's content. |
| 1451 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1451 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1452 | 1452 | |
| 1453 | 1453 | // Echo the closing wrapper. |
| 1454 | 1454 | echo '</div>'; |
| 1455 | 1455 | } |
| 1456 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1456 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1457 | 1457 | |
| 1458 | 1458 | /** |
| 1459 | 1459 | * Render an element's edit page. |
| 1460 | 1460 | * |
| 1461 | 1461 | * @param WP_Post $post |
| 1462 | 1462 | */ |
| 1463 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1463 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1464 | 1464 | |
| 1465 | 1465 | // Retrieve all elements. |
| 1466 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1466 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1467 | 1467 | |
| 1468 | - foreach ( $all_elements as $element ) { |
|
| 1468 | + foreach ($all_elements as $element) { |
|
| 1469 | 1469 | |
| 1470 | 1470 | // Try to locate the appropriate template. |
| 1471 | - $element = esc_attr( sanitize_key( $element ) ); |
|
| 1472 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1471 | + $element = esc_attr(sanitize_key($element)); |
|
| 1472 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1473 | 1473 | |
| 1474 | 1474 | // Continue if this is not our element. |
| 1475 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1475 | + if (empty($located) || !file_exists($located)) { |
|
| 1476 | 1476 | continue; |
| 1477 | 1477 | } |
| 1478 | 1478 | |
@@ -1483,7 +1483,7 @@ discard block |
||
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | } |
| 1486 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1486 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1487 | 1487 | |
| 1488 | 1488 | /** |
| 1489 | 1489 | * Render an element's preview. |
@@ -1492,16 +1492,16 @@ discard block |
||
| 1492 | 1492 | function getpaid_payment_form_render_element_preview_template() { |
| 1493 | 1493 | |
| 1494 | 1494 | // Retrieve all elements. |
| 1495 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1495 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1496 | 1496 | |
| 1497 | - foreach ( $all_elements as $element ) { |
|
| 1497 | + foreach ($all_elements as $element) { |
|
| 1498 | 1498 | |
| 1499 | 1499 | // Try to locate the appropriate template. |
| 1500 | - $element = sanitize_key( $element ); |
|
| 1501 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1500 | + $element = sanitize_key($element); |
|
| 1501 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1502 | 1502 | |
| 1503 | 1503 | // Continue if this is not our element. |
| 1504 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1504 | + if (empty($located) || !file_exists($located)) { |
|
| 1505 | 1505 | continue; |
| 1506 | 1506 | } |
| 1507 | 1507 | |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | 1514 | } |
| 1515 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1515 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1516 | 1516 | |
| 1517 | 1517 | /** |
| 1518 | 1518 | * Shows a list of gateways that support recurring payments. |
@@ -1520,17 +1520,17 @@ discard block |
||
| 1520 | 1520 | function wpinv_get_recurring_gateways_text() { |
| 1521 | 1521 | $gateways = array(); |
| 1522 | 1522 | |
| 1523 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1524 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1525 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1523 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1524 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1525 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - if ( empty( $gateways ) ) { |
|
| 1530 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
| 1529 | + if (empty($gateways)) { |
|
| 1530 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
| 1533 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
| 1534 | 1534 | |
| 1535 | 1535 | } |
| 1536 | 1536 | |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | * @return GetPaid_Template |
| 1541 | 1541 | */ |
| 1542 | 1542 | function getpaid_template() { |
| 1543 | - return getpaid()->get( 'template' ); |
|
| 1543 | + return getpaid()->get('template'); |
|
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | /** |
@@ -1549,8 +1549,8 @@ discard block |
||
| 1549 | 1549 | * @param array args |
| 1550 | 1550 | * @return string |
| 1551 | 1551 | */ |
| 1552 | -function getpaid_paginate_links( $args ) { |
|
| 1553 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
| 1552 | +function getpaid_paginate_links($args) { |
|
| 1553 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
| 1554 | 1554 | } |
| 1555 | 1555 | |
| 1556 | 1556 | /** |
@@ -1560,21 +1560,21 @@ discard block |
||
| 1560 | 1560 | * @param string state |
| 1561 | 1561 | * @return string |
| 1562 | 1562 | */ |
| 1563 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
| 1563 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
| 1564 | 1564 | |
| 1565 | - $states = wpinv_get_country_states( $country ); |
|
| 1566 | - $uniqid = uniqid( '_' ); |
|
| 1565 | + $states = wpinv_get_country_states($country); |
|
| 1566 | + $uniqid = uniqid('_'); |
|
| 1567 | 1567 | |
| 1568 | - if ( ! empty( $states ) ) { |
|
| 1568 | + if (!empty($states)) { |
|
| 1569 | 1569 | |
| 1570 | - return aui()->select( array( |
|
| 1570 | + return aui()->select(array( |
|
| 1571 | 1571 | 'options' => $states, |
| 1572 | - 'name' => esc_attr( $field_name ), |
|
| 1573 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1574 | - 'value' => sanitize_text_field( $state ), |
|
| 1572 | + 'name' => esc_attr($field_name), |
|
| 1573 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1574 | + 'value' => sanitize_text_field($state), |
|
| 1575 | 1575 | 'placeholder' => $placeholder, |
| 1576 | 1576 | 'required' => $required, |
| 1577 | - 'label' => wp_kses_post( $label ), |
|
| 1577 | + 'label' => wp_kses_post($label), |
|
| 1578 | 1578 | 'label_type' => 'vertical', |
| 1579 | 1579 | 'help_text' => $help_text, |
| 1580 | 1580 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1589,14 +1589,14 @@ discard block |
||
| 1589 | 1589 | |
| 1590 | 1590 | return aui()->input( |
| 1591 | 1591 | array( |
| 1592 | - 'name' => esc_attr( $field_name ), |
|
| 1593 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1592 | + 'name' => esc_attr($field_name), |
|
| 1593 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1594 | 1594 | 'placeholder' => $placeholder, |
| 1595 | 1595 | 'required' => $required, |
| 1596 | - 'label' => wp_kses_post( $label ), |
|
| 1596 | + 'label' => wp_kses_post($label), |
|
| 1597 | 1597 | 'label_type' => 'vertical', |
| 1598 | 1598 | 'help_text' => $help_text, |
| 1599 | - 'value' => sanitize_text_field( $state ), |
|
| 1599 | + 'value' => sanitize_text_field($state), |
|
| 1600 | 1600 | 'class' => 'getpaid-address-field wpinv_state', |
| 1601 | 1601 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
| 1602 | 1602 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1614,16 +1614,16 @@ discard block |
||
| 1614 | 1614 | * @param array $element |
| 1615 | 1615 | * @return string |
| 1616 | 1616 | */ |
| 1617 | -function getpaid_get_form_element_grid_class( $element ) { |
|
| 1617 | +function getpaid_get_form_element_grid_class($element) { |
|
| 1618 | 1618 | |
| 1619 | 1619 | $class = "col-12"; |
| 1620 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
| 1620 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
| 1621 | 1621 | |
| 1622 | - if ( $width == 'half' ) { |
|
| 1622 | + if ($width == 'half') { |
|
| 1623 | 1623 | $class .= " col-md-6"; |
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | - if ( $width == 'third' ) { |
|
| 1626 | + if ($width == 'third') { |
|
| 1627 | 1627 | $class .= " col-md-4"; |
| 1628 | 1628 | } |
| 1629 | 1629 | |
@@ -1638,15 +1638,15 @@ discard block |
||
| 1638 | 1638 | * |
| 1639 | 1639 | * @return string |
| 1640 | 1640 | */ |
| 1641 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
| 1641 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
| 1642 | 1642 | |
| 1643 | 1643 | return add_query_arg( |
| 1644 | 1644 | array( |
| 1645 | 1645 | 'getpaid_embed' => 1, |
| 1646 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
| 1647 | - 'item' => $items ? urlencode( $items ) : false |
|
| 1646 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
| 1647 | + 'item' => $items ? urlencode($items) : false |
|
| 1648 | 1648 | ), |
| 1649 | - home_url( 'index.php' ) |
|
| 1649 | + home_url('index.php') |
|
| 1650 | 1650 | ); |
| 1651 | 1651 | |
| 1652 | 1652 | } |
@@ -1656,13 +1656,13 @@ discard block |
||
| 1656 | 1656 | * |
| 1657 | 1657 | * @return string |
| 1658 | 1658 | */ |
| 1659 | -function getpaid_filter_embed_template( $template ) { |
|
| 1659 | +function getpaid_filter_embed_template($template) { |
|
| 1660 | 1660 | |
| 1661 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
| 1662 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
| 1661 | + if (isset($_GET['getpaid_embed'])) { |
|
| 1662 | + wpinv_get_template('payment-forms/embed.php'); |
|
| 1663 | 1663 | exit; |
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | return $template; |
| 1667 | 1667 | } |
| 1668 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
| 1668 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
|
@@ -195,13 +195,13 @@ discard block |
||
| 195 | 195 | $name = isset( $option['name'] ) ? $option['name'] : ''; |
| 196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
| 197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
| 198 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 198 | + $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 199 | 199 | |
| 200 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 201 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 202 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 203 | - unset( $option['desc'] ); |
|
| 204 | - } |
|
| 200 | + if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 201 | + $tip = wpinv_clean( $option['desc'] ); |
|
| 202 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
| 203 | + unset( $option['desc'] ); |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | 206 | // Loop through all tabs. |
| 207 | 207 | add_settings_field( |
@@ -228,9 +228,9 @@ discard block |
||
| 228 | 228 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
| 229 | 229 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
| 230 | 230 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
| 231 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 232 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 233 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 231 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 232 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 233 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 234 | 234 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
| 235 | 235 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
| 236 | 236 | ) |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @return array |
| 245 | 245 | */ |
| 246 | 246 | function wpinv_get_registered_settings() { |
| 247 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 247 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -263,18 +263,18 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | function wpinv_settings_sanitize( $input = array() ) { |
| 265 | 265 | |
| 266 | - $wpinv_options = wpinv_get_options(); |
|
| 267 | - $raw_referrer = wp_get_raw_referer(); |
|
| 266 | + $wpinv_options = wpinv_get_options(); |
|
| 267 | + $raw_referrer = wp_get_raw_referer(); |
|
| 268 | 268 | |
| 269 | 269 | if ( empty( $raw_referrer ) ) { |
| 270 | - return array_merge( $wpinv_options, $input ); |
|
| 270 | + return array_merge( $wpinv_options, $input ); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | wp_parse_str( $raw_referrer, $referrer ); |
| 274 | 274 | |
| 275 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 276 | - return array_merge( $wpinv_options, $input ); |
|
| 277 | - } |
|
| 275 | + if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 276 | + return array_merge( $wpinv_options, $input ); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | $settings = wpinv_get_registered_settings(); |
| 280 | 280 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // General filter |
| 299 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 299 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 300 | 300 | |
| 301 | - // Key specific filter. |
|
| 302 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 301 | + // Key specific filter. |
|
| 302 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | foreach ( $new_rates as $rate ) { |
| 344 | 344 | |
| 345 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 346 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 347 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 348 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 349 | - $rate['global'] = empty( $rate['state'] ); |
|
| 350 | - $tax_rates[] = $rate; |
|
| 345 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 346 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 347 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 348 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 349 | + $rate['global'] = empty( $rate['state'] ); |
|
| 350 | + $tax_rates[] = $rate; |
|
| 351 | 351 | |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | update_option( 'wpinv_tax_rates', $tax_rates ); |
| 355 | 355 | |
@@ -362,11 +362,11 @@ discard block |
||
| 362 | 362 | $tabs['general'] = __( 'General', 'invoicing' ); |
| 363 | 363 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
| 364 | 364 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
| 365 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 365 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 366 | 366 | |
| 367 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 368 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 369 | - } |
|
| 367 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 368 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 369 | + } |
|
| 370 | 370 | |
| 371 | 371 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
| 372 | 372 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -405,14 +405,14 @@ discard block |
||
| 405 | 405 | ) ), |
| 406 | 406 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
| 407 | 407 | 'main' => __( 'Tax Settings', 'invoicing' ), |
| 408 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 409 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 408 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 409 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 410 | 410 | ) ), |
| 411 | 411 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
| 412 | 412 | 'main' => __( 'Email Settings', 'invoicing' ), |
| 413 | - ) ), |
|
| 413 | + ) ), |
|
| 414 | 414 | |
| 415 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 415 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 416 | 416 | |
| 417 | 417 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
| 418 | 418 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -432,46 +432,46 @@ discard block |
||
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 435 | - $pages_options = array(); |
|
| 435 | + $pages_options = array(); |
|
| 436 | 436 | |
| 437 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 438 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 439 | - } |
|
| 437 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 438 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 439 | + } |
|
| 440 | 440 | |
| 441 | - $pages = get_pages(); |
|
| 442 | - if ( $pages ) { |
|
| 443 | - foreach ( $pages as $page ) { |
|
| 444 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 441 | + $pages = get_pages(); |
|
| 442 | + if ( $pages ) { |
|
| 443 | + foreach ( $pages as $page ) { |
|
| 444 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 445 | 445 | $pages_options[ $page->ID ] = $title; |
| 446 | - } |
|
| 447 | - } |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | 448 | |
| 449 | - return $pages_options; |
|
| 449 | + return $pages_options; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | function wpinv_header_callback( $args ) { |
| 453 | - if ( !empty( $args['desc'] ) ) { |
|
| 453 | + if ( !empty( $args['desc'] ) ) { |
|
| 454 | 454 | echo wp_kses_post( $args['desc'] ); |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | function wpinv_hidden_callback( $args ) { |
| 459 | 459 | |
| 460 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 461 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 460 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 461 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 462 | 462 | |
| 463 | - if ( isset( $args['set_value'] ) ) { |
|
| 464 | - $value = $args['set_value']; |
|
| 465 | - } |
|
| 463 | + if ( isset( $args['set_value'] ) ) { |
|
| 464 | + $value = $args['set_value']; |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 468 | - $args['readonly'] = true; |
|
| 469 | - $name = ''; |
|
| 470 | - } else { |
|
| 471 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 472 | - } |
|
| 467 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 468 | + $args['readonly'] = true; |
|
| 469 | + $name = ''; |
|
| 470 | + } else { |
|
| 471 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 474 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 475 | 475 | |
| 476 | 476 | } |
| 477 | 477 | |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | function wpinv_checkbox_callback( $args ) { |
| 482 | 482 | |
| 483 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 484 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 485 | - $id = esc_attr( $args['id'] ); |
|
| 483 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 484 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 485 | + $id = esc_attr( $args['id'] ); |
|
| 486 | 486 | |
| 487 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 488 | - ?> |
|
| 487 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 488 | + ?> |
|
| 489 | 489 | <fieldset> |
| 490 | 490 | <label> |
| 491 | 491 | <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -497,75 +497,75 @@ discard block |
||
| 497 | 497 | |
| 498 | 498 | function wpinv_multicheck_callback( $args ) { |
| 499 | 499 | |
| 500 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 501 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 500 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 501 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 502 | 502 | |
| 503 | - if ( ! empty( $args['options'] ) ) { |
|
| 503 | + if ( ! empty( $args['options'] ) ) { |
|
| 504 | 504 | |
| 505 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 506 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 505 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 506 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 507 | 507 | |
| 508 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 508 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
| 509 | 509 | foreach( $args['options'] as $key => $option ): |
| 510 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 511 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 512 | - $enabled = $sanitize_key; |
|
| 513 | - } else { |
|
| 514 | - $enabled = NULL; |
|
| 515 | - } |
|
| 516 | - 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 ) . '/> '; |
|
| 517 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 518 | - endforeach; |
|
| 519 | - echo '</div>'; |
|
| 520 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 521 | - } |
|
| 510 | + $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 511 | + if ( in_array( $sanitize_key, $value ) ) { |
|
| 512 | + $enabled = $sanitize_key; |
|
| 513 | + } else { |
|
| 514 | + $enabled = NULL; |
|
| 515 | + } |
|
| 516 | + 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 ) . '/> '; |
|
| 517 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 518 | + endforeach; |
|
| 519 | + echo '</div>'; |
|
| 520 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 521 | + } |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | function wpinv_payment_icons_callback( $args ) { |
| 525 | 525 | |
| 526 | 526 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 527 | - $value = wpinv_get_option( $args['id'], false); |
|
| 527 | + $value = wpinv_get_option( $args['id'], false); |
|
| 528 | 528 | |
| 529 | - if ( ! empty( $args['options'] ) ) { |
|
| 530 | - foreach( $args['options'] as $key => $option ) { |
|
| 529 | + if ( ! empty( $args['options'] ) ) { |
|
| 530 | + foreach( $args['options'] as $key => $option ) { |
|
| 531 | 531 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 532 | 532 | |
| 533 | - if( empty( $value ) ) { |
|
| 534 | - $enabled = $option; |
|
| 535 | - } else { |
|
| 536 | - $enabled = NULL; |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 540 | - |
|
| 541 | - 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 ) . '/> '; |
|
| 542 | - |
|
| 543 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 544 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 545 | - } else { |
|
| 546 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 547 | - |
|
| 548 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 549 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 550 | - } else { |
|
| 551 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 552 | - $content_dir = WP_CONTENT_DIR; |
|
| 553 | - |
|
| 554 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 555 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 556 | - $image = wp_normalize_path( $image ); |
|
| 557 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 564 | - } |
|
| 565 | - echo $option . '</label>'; |
|
| 566 | - } |
|
| 567 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 568 | - } |
|
| 533 | + if( empty( $value ) ) { |
|
| 534 | + $enabled = $option; |
|
| 535 | + } else { |
|
| 536 | + $enabled = NULL; |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 540 | + |
|
| 541 | + 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 ) . '/> '; |
|
| 542 | + |
|
| 543 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 544 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 545 | + } else { |
|
| 546 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 547 | + |
|
| 548 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 549 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 550 | + } else { |
|
| 551 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 552 | + $content_dir = WP_CONTENT_DIR; |
|
| 553 | + |
|
| 554 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 555 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 556 | + $image = wp_normalize_path( $image ); |
|
| 557 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 564 | + } |
|
| 565 | + echo $option . '</label>'; |
|
| 566 | + } |
|
| 567 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | */ |
| 574 | 574 | function wpinv_radio_callback( $args ) { |
| 575 | 575 | |
| 576 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 577 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 578 | - ?> |
|
| 576 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 577 | + $std = wpinv_get_option( $args['id'], $std ); |
|
| 578 | + ?> |
|
| 579 | 579 | <fieldset> |
| 580 | 580 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
| 581 | 581 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | </ul> |
| 590 | 590 | </fieldset> |
| 591 | 591 | <?php |
| 592 | - getpaid_settings_description_callback( $args ); |
|
| 592 | + getpaid_settings_description_callback( $args ); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -597,10 +597,10 @@ discard block |
||
| 597 | 597 | */ |
| 598 | 598 | function getpaid_settings_description_callback( $args ) { |
| 599 | 599 | |
| 600 | - if ( ! empty( $args['desc'] ) ) { |
|
| 601 | - $description = wp_kses_post( $args['desc'] ); |
|
| 602 | - echo "<p class='description'>$description</p>"; |
|
| 603 | - } |
|
| 600 | + if ( ! empty( $args['desc'] ) ) { |
|
| 601 | + $description = wp_kses_post( $args['desc'] ); |
|
| 602 | + echo "<p class='description'>$description</p>"; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | 605 | } |
| 606 | 606 | |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | */ |
| 610 | 610 | function wpinv_gateways_callback() { |
| 611 | 611 | |
| 612 | - ?> |
|
| 612 | + ?> |
|
| 613 | 613 | </td> |
| 614 | 614 | </tr> |
| 615 | 615 | <tr class="bsui"> |
@@ -623,22 +623,22 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 625 | 625 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
| 626 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 627 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 626 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 627 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 628 | 628 | |
| 629 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 629 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 630 | 630 | |
| 631 | - foreach ( $args['options'] as $key => $option ) : |
|
| 632 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 631 | + foreach ( $args['options'] as $key => $option ) : |
|
| 632 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 633 | 633 | $selected = selected( $key, $args['selected'], false ); |
| 634 | 634 | } else { |
| 635 | 635 | $selected = selected( $key, $value, false ); |
| 636 | 636 | } |
| 637 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 638 | - endforeach; |
|
| 637 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 638 | + endforeach; |
|
| 639 | 639 | |
| 640 | - echo '</select>'; |
|
| 641 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 640 | + echo '</select>'; |
|
| 641 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -649,29 +649,29 @@ discard block |
||
| 649 | 649 | */ |
| 650 | 650 | function wpinv_settings_attrs_helper( $args ) { |
| 651 | 651 | |
| 652 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 653 | - $id = esc_attr( $args['id'] ); |
|
| 654 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 652 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 653 | + $id = esc_attr( $args['id'] ); |
|
| 654 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
| 655 | 655 | |
| 656 | - if ( ! empty( $args['faux'] ) ) { |
|
| 657 | - $args['readonly'] = true; |
|
| 658 | - $name = ''; |
|
| 659 | - } else { |
|
| 660 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 661 | - $name = "wpinv_settings[$id]"; |
|
| 662 | - } |
|
| 656 | + if ( ! empty( $args['faux'] ) ) { |
|
| 657 | + $args['readonly'] = true; |
|
| 658 | + $name = ''; |
|
| 659 | + } else { |
|
| 660 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 661 | + $name = "wpinv_settings[$id]"; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 665 | - $class = esc_attr( $args['class'] ); |
|
| 666 | - $style = esc_attr( $args['style'] ); |
|
| 667 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 664 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 665 | + $class = esc_attr( $args['class'] ); |
|
| 666 | + $style = esc_attr( $args['style'] ); |
|
| 667 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 668 | 668 | |
| 669 | - $onchange = ''; |
|
| 669 | + $onchange = ''; |
|
| 670 | 670 | if ( ! empty( $args['onchange'] ) ) { |
| 671 | 671 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 674 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | /** |
@@ -679,9 +679,9 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | function wpinv_text_callback( $args ) { |
| 681 | 681 | |
| 682 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 682 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 683 | 683 | |
| 684 | - ?> |
|
| 684 | + ?> |
|
| 685 | 685 | <label style="width: 100%;"> |
| 686 | 686 | <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
| 687 | 687 | <?php echo wp_kses_post( $desc ); ?> |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | */ |
| 696 | 696 | function wpinv_number_callback( $args ) { |
| 697 | 697 | |
| 698 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 699 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 698 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 699 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 700 | 700 | |
| 701 | - ?> |
|
| 701 | + ?> |
|
| 702 | 702 | <label style="width: 100%;"> |
| 703 | 703 | <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
| 704 | 704 | <?php echo wp_kses_post( $desc ); ?> |
@@ -710,34 +710,34 @@ discard block |
||
| 710 | 710 | function wpinv_textarea_callback( $args ) { |
| 711 | 711 | |
| 712 | 712 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 713 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 714 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 713 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 714 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 715 | 715 | |
| 716 | 716 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 717 | 717 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 718 | 718 | |
| 719 | - echo '<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>'; |
|
| 720 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 719 | + echo '<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>'; |
|
| 720 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 721 | 721 | |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | function wpinv_password_callback( $args ) { |
| 725 | 725 | |
| 726 | 726 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 727 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 728 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 727 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 728 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 729 | 729 | |
| 730 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 731 | - echo '<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 ) . '"/>'; |
|
| 732 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 730 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 731 | + echo '<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 ) . '"/>'; |
|
| 732 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 733 | 733 | |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | function wpinv_missing_callback($args) { |
| 737 | - printf( |
|
| 738 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 739 | - '<strong>' . $args['id'] . '</strong>' |
|
| 740 | - ); |
|
| 737 | + printf( |
|
| 738 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 739 | + '<strong>' . $args['id'] . '</strong>' |
|
| 740 | + ); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | /** |
@@ -745,14 +745,14 @@ discard block |
||
| 745 | 745 | */ |
| 746 | 746 | function wpinv_select_callback( $args ) { |
| 747 | 747 | |
| 748 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 749 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 750 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 751 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 753 | - $rand = uniqid( 'random_id' ); |
|
| 748 | + $desc = wp_kses_post( $args['desc'] ); |
|
| 749 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 750 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
| 751 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | + $value = wpinv_get_option( $args['id'], $value ); |
|
| 753 | + $rand = uniqid( 'random_id' ); |
|
| 754 | 754 | |
| 755 | - ?> |
|
| 755 | + ?> |
|
| 756 | 756 | <label style="width: 100%;"> |
| 757 | 757 | <select <?php echo $attr; ?> data-allow-clear="true"> |
| 758 | 758 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -785,42 +785,42 @@ discard block |
||
| 785 | 785 | function wpinv_color_select_callback( $args ) { |
| 786 | 786 | |
| 787 | 787 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 788 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 789 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 788 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 789 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 790 | 790 | |
| 791 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 791 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 792 | 792 | |
| 793 | - foreach ( $args['options'] as $option => $color ) { |
|
| 794 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 795 | - } |
|
| 793 | + foreach ( $args['options'] as $option => $color ) { |
|
| 794 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | - echo '</select>'; |
|
| 798 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 797 | + echo '</select>'; |
|
| 798 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 799 | 799 | |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | function wpinv_rich_editor_callback( $args ) { |
| 803 | - global $wp_version; |
|
| 803 | + global $wp_version; |
|
| 804 | 804 | |
| 805 | 805 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 806 | 806 | |
| 807 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 808 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 807 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 808 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 809 | 809 | |
| 810 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 811 | - $value = $std; |
|
| 812 | - } |
|
| 810 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 811 | + $value = $std; |
|
| 812 | + } |
|
| 813 | 813 | |
| 814 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 814 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 815 | 815 | |
| 816 | - echo '<div class="getpaid-settings-editor-input">'; |
|
| 817 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 818 | - 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 ) ); |
|
| 819 | - } else { |
|
| 820 | - echo '<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>'; |
|
| 821 | - } |
|
| 816 | + echo '<div class="getpaid-settings-editor-input">'; |
|
| 817 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 818 | + 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 ) ); |
|
| 819 | + } else { |
|
| 820 | + echo '<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>'; |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 823 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
@@ -828,51 +828,51 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 830 | 830 | |
| 831 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 832 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 831 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 832 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 833 | 833 | |
| 834 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 835 | - echo '<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 ) ) . '"/>'; |
|
| 836 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 837 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 834 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 835 | + echo '<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 ) ) . '"/>'; |
|
| 836 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 837 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 838 | 838 | |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | function wpinv_color_callback( $args ) { |
| 842 | 842 | |
| 843 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 844 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 843 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 844 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 845 | 845 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 846 | 846 | |
| 847 | - echo '<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( $std ) . '" />'; |
|
| 848 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 847 | + echo '<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( $std ) . '" />'; |
|
| 848 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 849 | 849 | |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | function wpinv_country_states_callback($args) { |
| 853 | 853 | |
| 854 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 855 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 854 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 855 | + $value = wpinv_get_option( $args['id'], $std ); |
|
| 856 | 856 | |
| 857 | 857 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 858 | 858 | |
| 859 | - if ( isset( $args['placeholder'] ) ) { |
|
| 860 | - $placeholder = $args['placeholder']; |
|
| 861 | - } else { |
|
| 862 | - $placeholder = ''; |
|
| 863 | - } |
|
| 859 | + if ( isset( $args['placeholder'] ) ) { |
|
| 860 | + $placeholder = $args['placeholder']; |
|
| 861 | + } else { |
|
| 862 | + $placeholder = ''; |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - $states = wpinv_get_country_states(); |
|
| 865 | + $states = wpinv_get_country_states(); |
|
| 866 | 866 | |
| 867 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 868 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 867 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 868 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 869 | 869 | |
| 870 | - foreach ( $states as $option => $name ) { |
|
| 871 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 872 | - } |
|
| 870 | + foreach ( $states as $option => $name ) { |
|
| 871 | + echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 872 | + } |
|
| 873 | 873 | |
| 874 | - echo '</select>'; |
|
| 875 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 874 | + echo '</select>'; |
|
| 875 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 876 | 876 | |
| 877 | 877 | } |
| 878 | 878 | |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | */ |
| 882 | 882 | function wpinv_tax_rates_callback() { |
| 883 | 883 | |
| 884 | - ?> |
|
| 884 | + ?> |
|
| 885 | 885 | </td> |
| 886 | 886 | </tr> |
| 887 | 887 | <tr class="bsui"> |
@@ -896,17 +896,17 @@ discard block |
||
| 896 | 896 | * Displays a tax rate' edit row. |
| 897 | 897 | */ |
| 898 | 898 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
| 899 | - ob_start(); |
|
| 899 | + ob_start(); |
|
| 900 | 900 | |
| 901 | - $key = sanitize_key( $key ); |
|
| 902 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 903 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 901 | + $key = sanitize_key( $key ); |
|
| 902 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 903 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 904 | 904 | |
| 905 | - if ( $echo ) { |
|
| 906 | - echo ob_get_clean(); |
|
| 907 | - } else { |
|
| 908 | - return ob_get_clean(); |
|
| 909 | - } |
|
| 905 | + if ( $echo ) { |
|
| 906 | + echo ob_get_clean(); |
|
| 907 | + } else { |
|
| 908 | + return ob_get_clean(); |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | 911 | } |
| 912 | 912 | |
@@ -934,14 +934,14 @@ discard block |
||
| 934 | 934 | </td> |
| 935 | 935 | <td> |
| 936 | 936 | <a href="<?php |
| 937 | - echo esc_url( |
|
| 938 | - wp_nonce_url( |
|
| 939 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 940 | - 'getpaid-nonce', |
|
| 941 | - 'getpaid-nonce' |
|
| 942 | - ) |
|
| 943 | - ); |
|
| 944 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 937 | + echo esc_url( |
|
| 938 | + wp_nonce_url( |
|
| 939 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 940 | + 'getpaid-nonce', |
|
| 941 | + 'getpaid-nonce' |
|
| 942 | + ) |
|
| 943 | + ); |
|
| 944 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 945 | 945 | </td> |
| 946 | 946 | </tr> |
| 947 | 947 | <tr> |
@@ -951,14 +951,14 @@ discard block |
||
| 951 | 951 | </td> |
| 952 | 952 | <td> |
| 953 | 953 | <a href="<?php |
| 954 | - echo esc_url( |
|
| 955 | - wp_nonce_url( |
|
| 956 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 957 | - 'getpaid-nonce', |
|
| 958 | - 'getpaid-nonce' |
|
| 959 | - ) |
|
| 960 | - ); |
|
| 961 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 954 | + echo esc_url( |
|
| 955 | + wp_nonce_url( |
|
| 956 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 957 | + 'getpaid-nonce', |
|
| 958 | + 'getpaid-nonce' |
|
| 959 | + ) |
|
| 960 | + ); |
|
| 961 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 962 | 962 | </td> |
| 963 | 963 | </tr> |
| 964 | 964 | <tr> |
@@ -968,14 +968,14 @@ discard block |
||
| 968 | 968 | </td> |
| 969 | 969 | <td> |
| 970 | 970 | <a href="<?php |
| 971 | - echo esc_url( |
|
| 972 | - wp_nonce_url( |
|
| 973 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 974 | - 'getpaid-nonce', |
|
| 975 | - 'getpaid-nonce' |
|
| 976 | - ) |
|
| 977 | - ); |
|
| 978 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 971 | + echo esc_url( |
|
| 972 | + wp_nonce_url( |
|
| 973 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 974 | + 'getpaid-nonce', |
|
| 975 | + 'getpaid-nonce' |
|
| 976 | + ) |
|
| 977 | + ); |
|
| 978 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 979 | 979 | </td> |
| 980 | 980 | </tr> |
| 981 | 981 | |
@@ -986,14 +986,14 @@ discard block |
||
| 986 | 986 | </td> |
| 987 | 987 | <td> |
| 988 | 988 | <a href="<?php |
| 989 | - echo esc_url( |
|
| 990 | - wp_nonce_url( |
|
| 991 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 992 | - 'getpaid-nonce', |
|
| 993 | - 'getpaid-nonce' |
|
| 994 | - ) |
|
| 995 | - ); |
|
| 996 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 989 | + echo esc_url( |
|
| 990 | + wp_nonce_url( |
|
| 991 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 992 | + 'getpaid-nonce', |
|
| 993 | + 'getpaid-nonce' |
|
| 994 | + ) |
|
| 995 | + ); |
|
| 996 | + ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 997 | 997 | </td> |
| 998 | 998 | </tr> |
| 999 | 999 | |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | </td> |
| 1005 | 1005 | <td> |
| 1006 | 1006 | <a href="<?php |
| 1007 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1008 | - ?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a> |
|
| 1007 | + echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1008 | + ?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a> |
|
| 1009 | 1009 | </td> |
| 1010 | 1010 | </tr> |
| 1011 | 1011 | |
@@ -1019,19 +1019,19 @@ discard block |
||
| 1019 | 1019 | |
| 1020 | 1020 | |
| 1021 | 1021 | function wpinv_descriptive_text_callback( $args ) { |
| 1022 | - echo wp_kses_post( $args['desc'] ); |
|
| 1022 | + echo wp_kses_post( $args['desc'] ); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | function wpinv_raw_html_callback( $args ) { |
| 1026 | - echo $args['desc']; |
|
| 1026 | + echo $args['desc']; |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | function wpinv_hook_callback( $args ) { |
| 1030 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1030 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | function wpinv_set_settings_cap() { |
| 1034 | - return wpinv_get_capability(); |
|
| 1034 | + return wpinv_get_capability(); |
|
| 1035 | 1035 | } |
| 1036 | 1036 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 1037 | 1037 | |
@@ -1055,15 +1055,15 @@ discard block |
||
| 1055 | 1055 | */ |
| 1056 | 1056 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
| 1057 | 1057 | |
| 1058 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1059 | - $link = sprintf( |
|
| 1060 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1061 | - $url, |
|
| 1062 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1063 | - ); |
|
| 1058 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
| 1059 | + $link = sprintf( |
|
| 1060 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
| 1061 | + $url, |
|
| 1062 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1063 | + ); |
|
| 1064 | 1064 | |
| 1065 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1065 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1066 | 1066 | |
| 1067 | - return "$description $link"; |
|
| 1067 | + return "$description $link"; |
|
| 1068 | 1068 | |
| 1069 | 1069 | } |
@@ -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 ( empty( $wpinv_options ) ) { |
|
| 47 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
| 46 | + if (empty($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,49 +190,49 @@ 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 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
| 198 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
| 199 | 199 | |
| 200 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
| 201 | - $tip = wpinv_clean( $option['desc'] ); |
|
| 200 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
| 201 | + $tip = wpinv_clean($option['desc']); |
|
| 202 | 202 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
| 203 | - unset( $option['desc'] ); |
|
| 203 | + unset($option['desc']); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Loop through all tabs. |
| 207 | 207 | add_settings_field( |
| 208 | 208 | 'wpinv_settings[' . $option['id'] . ']', |
| 209 | 209 | $name, |
| 210 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
| 210 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
| 211 | 211 | $section, |
| 212 | 212 | $section, |
| 213 | 213 | array( |
| 214 | 214 | 'section' => $section, |
| 215 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
| 216 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
| 215 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
| 216 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
| 217 | 217 | 'name' => $name, |
| 218 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
| 219 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
| 220 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
| 221 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
| 222 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
| 223 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
| 224 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
| 225 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
| 226 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
| 227 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
| 228 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
| 229 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
| 230 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
| 231 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
| 232 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
| 233 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
| 234 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 235 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 218 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
| 219 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
| 220 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
| 221 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
| 222 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
| 223 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
| 224 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
| 225 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
| 226 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
| 227 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
| 228 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
| 229 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
| 230 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
| 231 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
| 232 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
| 233 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
| 234 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
| 235 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
| 236 | 236 | ) |
| 237 | 237 | ); |
| 238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | * @return array |
| 245 | 245 | */ |
| 246 | 246 | function wpinv_get_registered_settings() { |
| 247 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
| 247 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | * @return array |
| 254 | 254 | */ |
| 255 | 255 | function getpaid_get_integration_settings() { |
| 256 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
| 256 | + return apply_filters('getpaid_integration_settings', array()); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -261,126 +261,126 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return array |
| 263 | 263 | */ |
| 264 | -function wpinv_settings_sanitize( $input = array() ) { |
|
| 264 | +function wpinv_settings_sanitize($input = array()) { |
|
| 265 | 265 | |
| 266 | 266 | $wpinv_options = wpinv_get_options(); |
| 267 | 267 | $raw_referrer = wp_get_raw_referer(); |
| 268 | 268 | |
| 269 | - if ( empty( $raw_referrer ) ) { |
|
| 270 | - return array_merge( $wpinv_options, $input ); |
|
| 269 | + if (empty($raw_referrer)) { |
|
| 270 | + return array_merge($wpinv_options, $input); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - wp_parse_str( $raw_referrer, $referrer ); |
|
| 273 | + wp_parse_str($raw_referrer, $referrer); |
|
| 274 | 274 | |
| 275 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
| 276 | - return array_merge( $wpinv_options, $input ); |
|
| 275 | + if (in_array('gp-setup', $referrer)) { |
|
| 276 | + return array_merge($wpinv_options, $input); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $settings = wpinv_get_registered_settings(); |
| 280 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
| 281 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
| 280 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
| 281 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
| 282 | 282 | |
| 283 | 283 | $input = $input ? $input : array(); |
| 284 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
| 285 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
| 284 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
| 285 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
| 286 | 286 | |
| 287 | 287 | // Loop through each setting being saved and pass it through a sanitization filter |
| 288 | - foreach ( $input as $key => $value ) { |
|
| 288 | + foreach ($input as $key => $value) { |
|
| 289 | 289 | |
| 290 | 290 | // Get the setting type (checkbox, select, etc) |
| 291 | - $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false; |
|
| 291 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
| 292 | 292 | |
| 293 | - if ( $type ) { |
|
| 293 | + if ($type) { |
|
| 294 | 294 | // Field type specific filter |
| 295 | - $input[$key] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
| 295 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | // General filter |
| 299 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
| 299 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
| 300 | 300 | |
| 301 | 301 | // Key specific filter. |
| 302 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
| 302 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Loop through the whitelist and unset any that are empty for the tab being saved |
| 306 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
| 307 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
| 306 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
| 307 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
| 308 | 308 | |
| 309 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
| 309 | + $found_settings = array_merge($main_settings, $section_settings); |
|
| 310 | 310 | |
| 311 | - if ( ! empty( $found_settings ) ) { |
|
| 312 | - foreach ( $found_settings as $key => $value ) { |
|
| 311 | + if (!empty($found_settings)) { |
|
| 312 | + foreach ($found_settings as $key => $value) { |
|
| 313 | 313 | |
| 314 | 314 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
| 315 | - if ( is_numeric( $key ) ) { |
|
| 315 | + if (is_numeric($key)) { |
|
| 316 | 316 | $key = $value['id']; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
| 320 | - unset( $wpinv_options[ $key ] ); |
|
| 319 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
| 320 | + unset($wpinv_options[$key]); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Merge our new settings with the existing |
| 326 | - $output = array_merge( $wpinv_options, $input ); |
|
| 326 | + $output = array_merge($wpinv_options, $input); |
|
| 327 | 327 | |
| 328 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
| 328 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
| 329 | 329 | |
| 330 | 330 | return $output; |
| 331 | 331 | } |
| 332 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
| 333 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
| 332 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
| 333 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
| 334 | 334 | |
| 335 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
| 336 | - if( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 335 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
| 336 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 337 | 337 | return $input; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
| 340 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
| 341 | 341 | $tax_rates = array(); |
| 342 | 342 | |
| 343 | - foreach ( $new_rates as $rate ) { |
|
| 343 | + foreach ($new_rates as $rate) { |
|
| 344 | 344 | |
| 345 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
| 346 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
| 347 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
| 348 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
| 349 | - $rate['global'] = empty( $rate['state'] ); |
|
| 345 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
| 346 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
| 347 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
| 348 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
| 349 | + $rate['global'] = empty($rate['state']); |
|
| 350 | 350 | $tax_rates[] = $rate; |
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
| 354 | + update_option('wpinv_tax_rates', $tax_rates); |
|
| 355 | 355 | |
| 356 | 356 | return $input; |
| 357 | 357 | } |
| 358 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
| 358 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
| 359 | 359 | |
| 360 | 360 | function wpinv_get_settings_tabs() { |
| 361 | 361 | $tabs = array(); |
| 362 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
| 363 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
| 364 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
| 365 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
| 362 | + $tabs['general'] = __('General', 'invoicing'); |
|
| 363 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
| 364 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
| 365 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
| 366 | 366 | |
| 367 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
| 368 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
| 367 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
| 368 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
| 372 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
| 373 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
| 371 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
| 372 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
| 373 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
| 374 | 374 | |
| 375 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
| 375 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
| 378 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
| 379 | 379 | $tabs = false; |
| 380 | 380 | $sections = wpinv_get_registered_settings_sections(); |
| 381 | 381 | |
| 382 | - if( $tab && ! empty( $sections[ $tab ] ) ) { |
|
| 383 | - $tabs = $sections[ $tab ]; |
|
| 382 | + if ($tab && !empty($sections[$tab])) { |
|
| 383 | + $tabs = $sections[$tab]; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | return $tabs; |
@@ -389,148 +389,148 @@ discard block |
||
| 389 | 389 | function wpinv_get_registered_settings_sections() { |
| 390 | 390 | static $sections = false; |
| 391 | 391 | |
| 392 | - if ( false !== $sections ) { |
|
| 392 | + if (false !== $sections) { |
|
| 393 | 393 | return $sections; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | $sections = array( |
| 397 | - 'general' => apply_filters( 'wpinv_settings_sections_general', array( |
|
| 398 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
| 399 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
| 400 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
| 401 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
| 402 | - ) ), |
|
| 403 | - 'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array( |
|
| 404 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
| 405 | - ) ), |
|
| 406 | - 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
|
| 407 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
| 408 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
| 409 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
| 410 | - ) ), |
|
| 411 | - 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
|
| 412 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
| 413 | - ) ), |
|
| 414 | - |
|
| 415 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
| 416 | - |
|
| 417 | - 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
|
| 418 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
| 419 | - ) ), |
|
| 420 | - 'misc' => apply_filters( 'wpinv_settings_sections_misc', array( |
|
| 421 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
| 422 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
| 423 | - ) ), |
|
| 424 | - 'tools' => apply_filters( 'wpinv_settings_sections_tools', array( |
|
| 425 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
| 426 | - ) ), |
|
| 397 | + 'general' => apply_filters('wpinv_settings_sections_general', array( |
|
| 398 | + 'main' => __('General Settings', 'invoicing'), |
|
| 399 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
| 400 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
| 401 | + 'labels' => __('Label Texts', 'invoicing'), |
|
| 402 | + )), |
|
| 403 | + 'gateways' => apply_filters('wpinv_settings_sections_gateways', array( |
|
| 404 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
| 405 | + )), |
|
| 406 | + 'taxes' => apply_filters('wpinv_settings_sections_taxes', array( |
|
| 407 | + 'main' => __('Tax Settings', 'invoicing'), |
|
| 408 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
| 409 | + 'vat' => __('EU VAT Settings', 'invoicing') |
|
| 410 | + )), |
|
| 411 | + 'emails' => apply_filters('wpinv_settings_sections_emails', array( |
|
| 412 | + 'main' => __('Email Settings', 'invoicing'), |
|
| 413 | + )), |
|
| 414 | + |
|
| 415 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
| 416 | + |
|
| 417 | + 'privacy' => apply_filters('wpinv_settings_sections_privacy', array( |
|
| 418 | + 'main' => __('Privacy policy', 'invoicing'), |
|
| 419 | + )), |
|
| 420 | + 'misc' => apply_filters('wpinv_settings_sections_misc', array( |
|
| 421 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
| 422 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
| 423 | + )), |
|
| 424 | + 'tools' => apply_filters('wpinv_settings_sections_tools', array( |
|
| 425 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
| 426 | + )), |
|
| 427 | 427 | ); |
| 428 | 428 | |
| 429 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
| 429 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
| 430 | 430 | |
| 431 | 431 | return $sections; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | -function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
|
| 434 | +function wpinv_get_pages($with_slug = false, $default_label = NULL) { |
|
| 435 | 435 | $pages_options = array(); |
| 436 | 436 | |
| 437 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 438 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 437 | + if ($default_label !== NULL && $default_label !== false) { |
|
| 438 | + $pages_options = array('' => $default_label); // Blank option |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $pages = get_pages(); |
| 442 | - if ( $pages ) { |
|
| 443 | - foreach ( $pages as $page ) { |
|
| 442 | + if ($pages) { |
|
| 443 | + foreach ($pages as $page) { |
|
| 444 | 444 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
| 445 | - $pages_options[ $page->ID ] = $title; |
|
| 445 | + $pages_options[$page->ID] = $title; |
|
| 446 | 446 | } |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | return $pages_options; |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | -function wpinv_header_callback( $args ) { |
|
| 453 | - if ( !empty( $args['desc'] ) ) { |
|
| 454 | - echo wp_kses_post( $args['desc'] ); |
|
| 452 | +function wpinv_header_callback($args) { |
|
| 453 | + if (!empty($args['desc'])) { |
|
| 454 | + echo wp_kses_post($args['desc']); |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | -function wpinv_hidden_callback( $args ) { |
|
| 458 | +function wpinv_hidden_callback($args) { |
|
| 459 | 459 | |
| 460 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 461 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 460 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 461 | + $value = wpinv_get_option($args['id'], $std); |
|
| 462 | 462 | |
| 463 | - if ( isset( $args['set_value'] ) ) { |
|
| 463 | + if (isset($args['set_value'])) { |
|
| 464 | 464 | $value = $args['set_value']; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 467 | + if (isset($args['faux']) && true === $args['faux']) { |
|
| 468 | 468 | $args['readonly'] = true; |
| 469 | - $name = ''; |
|
| 469 | + $name = ''; |
|
| 470 | 470 | } else { |
| 471 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 471 | + $name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"'; |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 474 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />'; |
|
| 475 | 475 | |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | /** |
| 479 | 479 | * Displays a checkbox settings callback. |
| 480 | 480 | */ |
| 481 | -function wpinv_checkbox_callback( $args ) { |
|
| 481 | +function wpinv_checkbox_callback($args) { |
|
| 482 | 482 | |
| 483 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 484 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 485 | - $id = esc_attr( $args['id'] ); |
|
| 483 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 484 | + $std = wpinv_get_option($args['id'], $std); |
|
| 485 | + $id = esc_attr($args['id']); |
|
| 486 | 486 | |
| 487 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
| 487 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
| 488 | 488 | ?> |
| 489 | 489 | <fieldset> |
| 490 | 490 | <label> |
| 491 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
|
| 492 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
| 491 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox"> |
|
| 492 | + <?php echo wp_kses_post($args['desc']); ?> |
|
| 493 | 493 | </label> |
| 494 | 494 | </fieldset> |
| 495 | 495 | <?php |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | -function wpinv_multicheck_callback( $args ) { |
|
| 498 | +function wpinv_multicheck_callback($args) { |
|
| 499 | 499 | |
| 500 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 501 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 500 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 501 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 502 | 502 | |
| 503 | - if ( ! empty( $args['options'] ) ) { |
|
| 503 | + if (!empty($args['options'])) { |
|
| 504 | 504 | |
| 505 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
| 506 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 505 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
| 506 | + $value = wpinv_get_option($args['id'], $std); |
|
| 507 | 507 | |
| 508 | 508 | echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
| 509 | - foreach( $args['options'] as $key => $option ): |
|
| 510 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
| 511 | - if ( in_array( $sanitize_key, $value ) ) { |
|
| 509 | + foreach ($args['options'] as $key => $option): |
|
| 510 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
| 511 | + if (in_array($sanitize_key, $value)) { |
|
| 512 | 512 | $enabled = $sanitize_key; |
| 513 | 513 | } else { |
| 514 | 514 | $enabled = NULL; |
| 515 | 515 | } |
| 516 | - 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 ) . '/> '; |
|
| 517 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
| 516 | + 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) . '/> '; |
|
| 517 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>'; |
|
| 518 | 518 | endforeach; |
| 519 | 519 | echo '</div>'; |
| 520 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 520 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 521 | 521 | } |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | -function wpinv_payment_icons_callback( $args ) { |
|
| 524 | +function wpinv_payment_icons_callback($args) { |
|
| 525 | 525 | |
| 526 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 527 | - $value = wpinv_get_option( $args['id'], false); |
|
| 526 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 527 | + $value = wpinv_get_option($args['id'], false); |
|
| 528 | 528 | |
| 529 | - if ( ! empty( $args['options'] ) ) { |
|
| 530 | - foreach( $args['options'] as $key => $option ) { |
|
| 531 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 529 | + if (!empty($args['options'])) { |
|
| 530 | + foreach ($args['options'] as $key => $option) { |
|
| 531 | + $sanitize_key = wpinv_sanitize_key($key); |
|
| 532 | 532 | |
| 533 | - if( empty( $value ) ) { |
|
| 533 | + if (empty($value)) { |
|
| 534 | 534 | $enabled = $option; |
| 535 | 535 | } else { |
| 536 | 536 | $enabled = NULL; |
@@ -538,67 +538,67 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
| 540 | 540 | |
| 541 | - 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 ) . '/> '; |
|
| 541 | + 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) . '/> '; |
|
| 542 | 542 | |
| 543 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 544 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 543 | + if (wpinv_string_is_image_url($key)) { |
|
| 544 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 545 | 545 | } else { |
| 546 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 546 | + $card = strtolower(str_replace(' ', '', $option)); |
|
| 547 | 547 | |
| 548 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 549 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 548 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
| 549 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
| 550 | 550 | } else { |
| 551 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 551 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
| 552 | 552 | $content_dir = WP_CONTENT_DIR; |
| 553 | 553 | |
| 554 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 554 | + if (function_exists('wp_normalize_path')) { |
|
| 555 | 555 | // Replaces backslashes with forward slashes for Windows systems |
| 556 | - $image = wp_normalize_path( $image ); |
|
| 557 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 556 | + $image = wp_normalize_path($image); |
|
| 557 | + $content_dir = wp_normalize_path($content_dir); |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 560 | + $image = str_replace($content_dir, content_url(), $image); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 563 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 564 | 564 | } |
| 565 | 565 | echo $option . '</label>'; |
| 566 | 566 | } |
| 567 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 567 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
| 572 | 572 | * Displays a radio settings field. |
| 573 | 573 | */ |
| 574 | -function wpinv_radio_callback( $args ) { |
|
| 574 | +function wpinv_radio_callback($args) { |
|
| 575 | 575 | |
| 576 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 577 | - $std = wpinv_get_option( $args['id'], $std ); |
|
| 576 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 577 | + $std = wpinv_get_option($args['id'], $std); |
|
| 578 | 578 | ?> |
| 579 | 579 | <fieldset> |
| 580 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
| 581 | - <?php foreach( $args['options'] as $key => $option ) : ?> |
|
| 580 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
| 581 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
| 582 | 582 | <li> |
| 583 | 583 | <label> |
| 584 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
| 585 | - <?php echo wp_kses_post( $option ); ?> |
|
| 584 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
| 585 | + <?php echo wp_kses_post($option); ?> |
|
| 586 | 586 | </label> |
| 587 | 587 | </li> |
| 588 | 588 | <?php endforeach; ?> |
| 589 | 589 | </ul> |
| 590 | 590 | </fieldset> |
| 591 | 591 | <?php |
| 592 | - getpaid_settings_description_callback( $args ); |
|
| 592 | + getpaid_settings_description_callback($args); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
| 596 | 596 | * Displays a description if available. |
| 597 | 597 | */ |
| 598 | -function getpaid_settings_description_callback( $args ) { |
|
| 598 | +function getpaid_settings_description_callback($args) { |
|
| 599 | 599 | |
| 600 | - if ( ! empty( $args['desc'] ) ) { |
|
| 601 | - $description = wp_kses_post( $args['desc'] ); |
|
| 600 | + if (!empty($args['desc'])) { |
|
| 601 | + $description = wp_kses_post($args['desc']); |
|
| 602 | 602 | echo "<p class='description'>$description</p>"; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -614,31 +614,31 @@ discard block |
||
| 614 | 614 | </tr> |
| 615 | 615 | <tr class="bsui"> |
| 616 | 616 | <td colspan="2" class="p-0"> |
| 617 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
| 617 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
| 618 | 618 | |
| 619 | 619 | <?php |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | function wpinv_gateway_select_callback($args) { |
| 623 | 623 | |
| 624 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 625 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
| 626 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 627 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 624 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 625 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
| 626 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 627 | + $value = wpinv_get_option($args['id'], $std); |
|
| 628 | 628 | |
| 629 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
| 629 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >'; |
|
| 630 | 630 | |
| 631 | - foreach ( $args['options'] as $key => $option ) : |
|
| 632 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 633 | - $selected = selected( $key, $args['selected'], false ); |
|
| 631 | + foreach ($args['options'] as $key => $option) : |
|
| 632 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
| 633 | + $selected = selected($key, $args['selected'], false); |
|
| 634 | 634 | } else { |
| 635 | - $selected = selected( $key, $value, false ); |
|
| 635 | + $selected = selected($key, $value, false); |
|
| 636 | 636 | } |
| 637 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 637 | + echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>'; |
|
| 638 | 638 | endforeach; |
| 639 | 639 | |
| 640 | 640 | echo '</select>'; |
| 641 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 641 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | /** |
@@ -647,28 +647,28 @@ discard block |
||
| 647 | 647 | * @param array $args |
| 648 | 648 | * @return string |
| 649 | 649 | */ |
| 650 | -function wpinv_settings_attrs_helper( $args ) { |
|
| 650 | +function wpinv_settings_attrs_helper($args) { |
|
| 651 | 651 | |
| 652 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 653 | - $id = esc_attr( $args['id'] ); |
|
| 654 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
| 652 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 653 | + $id = esc_attr($args['id']); |
|
| 654 | + $placeholder = esc_attr($args['placeholder']); |
|
| 655 | 655 | |
| 656 | - if ( ! empty( $args['faux'] ) ) { |
|
| 656 | + if (!empty($args['faux'])) { |
|
| 657 | 657 | $args['readonly'] = true; |
| 658 | 658 | $name = ''; |
| 659 | 659 | } else { |
| 660 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 660 | + $value = wpinv_get_option($args['id'], $value); |
|
| 661 | 661 | $name = "wpinv_settings[$id]"; |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
| 665 | - $class = esc_attr( $args['class'] ); |
|
| 666 | - $style = esc_attr( $args['style'] ); |
|
| 667 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
| 664 | + $value = is_scalar($value) ? esc_attr($value) : ''; |
|
| 665 | + $class = esc_attr($args['class']); |
|
| 666 | + $style = esc_attr($args['style']); |
|
| 667 | + $readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"'; |
|
| 668 | 668 | |
| 669 | 669 | $onchange = ''; |
| 670 | - if ( ! empty( $args['onchange'] ) ) { |
|
| 671 | - $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 670 | + if (!empty($args['onchange'])) { |
|
| 671 | + $onchange = ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | /** |
| 678 | 678 | * Displays a text input settings callback. |
| 679 | 679 | */ |
| 680 | -function wpinv_text_callback( $args ) { |
|
| 680 | +function wpinv_text_callback($args) { |
|
| 681 | 681 | |
| 682 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 682 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 683 | 683 | |
| 684 | 684 | ?> |
| 685 | 685 | <label style="width: 100%;"> |
| 686 | - <input type="text" <?php echo wpinv_settings_attrs_helper( $args ); ?>> |
|
| 687 | - <?php echo wp_kses_post( $desc ); ?> |
|
| 686 | + <input type="text" <?php echo wpinv_settings_attrs_helper($args); ?>> |
|
| 687 | + <?php echo wp_kses_post($desc); ?> |
|
| 688 | 688 | </label> |
| 689 | 689 | <?php |
| 690 | 690 | |
@@ -693,49 +693,49 @@ discard block |
||
| 693 | 693 | /** |
| 694 | 694 | * Displays a number input settings callback. |
| 695 | 695 | */ |
| 696 | -function wpinv_number_callback( $args ) { |
|
| 696 | +function wpinv_number_callback($args) { |
|
| 697 | 697 | |
| 698 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 699 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 698 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 699 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 700 | 700 | |
| 701 | 701 | ?> |
| 702 | 702 | <label style="width: 100%;"> |
| 703 | - <input type="number" step="<?php echo floatval( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php echo $attr; ?>> |
|
| 704 | - <?php echo wp_kses_post( $desc ); ?> |
|
| 703 | + <input type="number" step="<?php echo floatval($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php echo $attr; ?>> |
|
| 704 | + <?php echo wp_kses_post($desc); ?> |
|
| 705 | 705 | </label> |
| 706 | 706 | <?php |
| 707 | 707 | |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | -function wpinv_textarea_callback( $args ) { |
|
| 710 | +function wpinv_textarea_callback($args) { |
|
| 711 | 711 | |
| 712 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 713 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 714 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 712 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 713 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 714 | + $value = wpinv_get_option($args['id'], $std); |
|
| 715 | 715 | |
| 716 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 717 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
| 716 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 717 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
| 718 | 718 | |
| 719 | - echo '<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>'; |
|
| 720 | - echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 719 | + echo '<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>'; |
|
| 720 | + echo '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 721 | 721 | |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | -function wpinv_password_callback( $args ) { |
|
| 724 | +function wpinv_password_callback($args) { |
|
| 725 | 725 | |
| 726 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 727 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 728 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 726 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 727 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 728 | + $value = wpinv_get_option($args['id'], $std); |
|
| 729 | 729 | |
| 730 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 731 | - echo '<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 ) . '"/>'; |
|
| 732 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 730 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 731 | + echo '<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) . '"/>'; |
|
| 732 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 733 | 733 | |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | function wpinv_missing_callback($args) { |
| 737 | 737 | printf( |
| 738 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 738 | + __('The callback function used for the %s setting is missing.', 'invoicing'), |
|
| 739 | 739 | '<strong>' . $args['id'] . '</strong>' |
| 740 | 740 | ); |
| 741 | 741 | } |
@@ -743,35 +743,35 @@ discard block |
||
| 743 | 743 | /** |
| 744 | 744 | * Displays a number input settings callback. |
| 745 | 745 | */ |
| 746 | -function wpinv_select_callback( $args ) { |
|
| 746 | +function wpinv_select_callback($args) { |
|
| 747 | 747 | |
| 748 | - $desc = wp_kses_post( $args['desc'] ); |
|
| 749 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
| 750 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
| 751 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 752 | - $value = wpinv_get_option( $args['id'], $value ); |
|
| 753 | - $rand = uniqid( 'random_id' ); |
|
| 748 | + $desc = wp_kses_post($args['desc']); |
|
| 749 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
| 750 | + $attr = wpinv_settings_attrs_helper($args); |
|
| 751 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 752 | + $value = wpinv_get_option($args['id'], $value); |
|
| 753 | + $rand = uniqid('random_id'); |
|
| 754 | 754 | |
| 755 | 755 | ?> |
| 756 | 756 | <label style="width: 100%;"> |
| 757 | 757 | <select <?php echo $attr; ?> data-allow-clear="true"> |
| 758 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
| 759 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option> |
|
| 760 | - <?php endforeach;?> |
|
| 758 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
| 759 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option> |
|
| 760 | + <?php endforeach; ?> |
|
| 761 | 761 | </select> |
| 762 | 762 | |
| 763 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
| 764 | - <a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a> |
|
| 763 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
| 764 | + <a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a> |
|
| 765 | 765 | <?php endif; ?> |
| 766 | 766 | |
| 767 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
| 768 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a> |
|
| 767 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
| 768 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a> |
|
| 769 | 769 | <div id='<?php echo $rand; ?>' style='display:none;'> |
| 770 | 770 | <div> |
| 771 | - <h3><?php _e( 'Original Content', 'invoicing' ) ?></h3> |
|
| 772 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea> |
|
| 773 | - <h3><?php _e( 'Current Content', 'invoicing' ) ?></h3> |
|
| 774 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea> |
|
| 771 | + <h3><?php _e('Original Content', 'invoicing') ?></h3> |
|
| 772 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea> |
|
| 773 | + <h3><?php _e('Current Content', 'invoicing') ?></h3> |
|
| 774 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea> |
|
| 775 | 775 | </div> |
| 776 | 776 | </div> |
| 777 | 777 | <?php endif; ?> |
@@ -782,81 +782,81 @@ discard block |
||
| 782 | 782 | |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | -function wpinv_color_select_callback( $args ) { |
|
| 785 | +function wpinv_color_select_callback($args) { |
|
| 786 | 786 | |
| 787 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 788 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 789 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 787 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 788 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 789 | + $value = wpinv_get_option($args['id'], $std); |
|
| 790 | 790 | |
| 791 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 791 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
| 792 | 792 | |
| 793 | - foreach ( $args['options'] as $option => $color ) { |
|
| 794 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 793 | + foreach ($args['options'] as $option => $color) { |
|
| 794 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | echo '</select>'; |
| 798 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 798 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 799 | 799 | |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | -function wpinv_rich_editor_callback( $args ) { |
|
| 802 | +function wpinv_rich_editor_callback($args) { |
|
| 803 | 803 | global $wp_version; |
| 804 | 804 | |
| 805 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 805 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 806 | 806 | |
| 807 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 808 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 807 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 808 | + $value = wpinv_get_option($args['id'], $std); |
|
| 809 | 809 | |
| 810 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 810 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
| 811 | 811 | $value = $std; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 814 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
| 815 | 815 | |
| 816 | 816 | echo '<div class="getpaid-settings-editor-input">'; |
| 817 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 818 | - 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 ) ); |
|
| 817 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
| 818 | + 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)); |
|
| 819 | 819 | } else { |
| 820 | - echo '<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>'; |
|
| 820 | + echo '<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>'; |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 823 | + echo '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | -function wpinv_upload_callback( $args ) { |
|
| 827 | +function wpinv_upload_callback($args) { |
|
| 828 | 828 | |
| 829 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 829 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 830 | 830 | |
| 831 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 832 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 831 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 832 | + $value = wpinv_get_option($args['id'], $std); |
|
| 833 | 833 | |
| 834 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 835 | - echo '<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 ) ) . '"/>'; |
|
| 836 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 837 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 834 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
| 835 | + echo '<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)) . '"/>'; |
|
| 836 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>'; |
|
| 837 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 838 | 838 | |
| 839 | 839 | } |
| 840 | 840 | |
| 841 | -function wpinv_color_callback( $args ) { |
|
| 841 | +function wpinv_color_callback($args) { |
|
| 842 | 842 | |
| 843 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 844 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 845 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 843 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 844 | + $value = wpinv_get_option($args['id'], $std); |
|
| 845 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 846 | 846 | |
| 847 | - echo '<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( $std ) . '" />'; |
|
| 848 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 847 | + echo '<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($std) . '" />'; |
|
| 848 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 849 | 849 | |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | function wpinv_country_states_callback($args) { |
| 853 | 853 | |
| 854 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 855 | - $value = wpinv_get_option( $args['id'], $std ); |
|
| 854 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
| 855 | + $value = wpinv_get_option($args['id'], $std); |
|
| 856 | 856 | |
| 857 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 857 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
| 858 | 858 | |
| 859 | - if ( isset( $args['placeholder'] ) ) { |
|
| 859 | + if (isset($args['placeholder'])) { |
|
| 860 | 860 | $placeholder = $args['placeholder']; |
| 861 | 861 | } else { |
| 862 | 862 | $placeholder = ''; |
@@ -864,15 +864,15 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | $states = wpinv_get_country_states(); |
| 866 | 866 | |
| 867 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 868 | - echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 867 | + $class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
| 868 | + echo '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
| 869 | 869 | |
| 870 | - foreach ( $states as $option => $name ) { |
|
| 871 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
| 870 | + foreach ($states as $option => $name) { |
|
| 871 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | echo '</select>'; |
| 875 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 875 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
| 876 | 876 | |
| 877 | 877 | } |
| 878 | 878 | |
@@ -886,7 +886,7 @@ discard block |
||
| 886 | 886 | </tr> |
| 887 | 887 | <tr class="bsui"> |
| 888 | 888 | <td colspan="2" class="p-0"> |
| 889 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
| 889 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
| 890 | 890 | |
| 891 | 891 | <?php |
| 892 | 892 | |
@@ -895,14 +895,14 @@ discard block |
||
| 895 | 895 | /** |
| 896 | 896 | * Displays a tax rate' edit row. |
| 897 | 897 | */ |
| 898 | -function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
|
| 898 | +function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) { |
|
| 899 | 899 | ob_start(); |
| 900 | 900 | |
| 901 | - $key = sanitize_key( $key ); |
|
| 902 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
| 903 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
| 901 | + $key = sanitize_key($key); |
|
| 902 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
| 903 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
| 904 | 904 | |
| 905 | - if ( $echo ) { |
|
| 905 | + if ($echo) { |
|
| 906 | 906 | echo ob_get_clean(); |
| 907 | 907 | } else { |
| 908 | 908 | return ob_get_clean(); |
@@ -915,136 +915,136 @@ discard block |
||
| 915 | 915 | ob_start(); ?> |
| 916 | 916 | </td><tr> |
| 917 | 917 | <td colspan="2" class="wpinv_tools_tdbox"> |
| 918 | - <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 919 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
| 918 | + <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?> |
|
| 919 | + <?php do_action('wpinv_tools_before'); ?> |
|
| 920 | 920 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
| 921 | 921 | <thead> |
| 922 | 922 | <tr> |
| 923 | - <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th> |
|
| 924 | - <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th> |
|
| 925 | - <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th> |
|
| 923 | + <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th> |
|
| 924 | + <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th> |
|
| 925 | + <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th> |
|
| 926 | 926 | </tr> |
| 927 | 927 | </thead> |
| 928 | 928 | |
| 929 | 929 | <tbody> |
| 930 | 930 | <tr> |
| 931 | - <td><?php _e( 'Check Pages', 'invoicing' );?></td> |
|
| 931 | + <td><?php _e('Check Pages', 'invoicing'); ?></td> |
|
| 932 | 932 | <td> |
| 933 | - <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
| 933 | + <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
| 934 | 934 | </td> |
| 935 | 935 | <td> |
| 936 | 936 | <a href="<?php |
| 937 | 937 | echo esc_url( |
| 938 | 938 | wp_nonce_url( |
| 939 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
| 939 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
| 940 | 940 | 'getpaid-nonce', |
| 941 | 941 | 'getpaid-nonce' |
| 942 | 942 | ) |
| 943 | 943 | ); |
| 944 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 944 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 945 | 945 | </td> |
| 946 | 946 | </tr> |
| 947 | 947 | <tr> |
| 948 | - <td><?php _e( 'Create Database Tables', 'invoicing' );?></td> |
|
| 948 | + <td><?php _e('Create Database Tables', 'invoicing'); ?></td> |
|
| 949 | 949 | <td> |
| 950 | - <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
| 950 | + <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
| 951 | 951 | </td> |
| 952 | 952 | <td> |
| 953 | 953 | <a href="<?php |
| 954 | 954 | echo esc_url( |
| 955 | 955 | wp_nonce_url( |
| 956 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
| 956 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
| 957 | 957 | 'getpaid-nonce', |
| 958 | 958 | 'getpaid-nonce' |
| 959 | 959 | ) |
| 960 | 960 | ); |
| 961 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 961 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 962 | 962 | </td> |
| 963 | 963 | </tr> |
| 964 | 964 | <tr> |
| 965 | - <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td> |
|
| 965 | + <td><?php _e('Migrate old invoices', 'invoicing'); ?></td> |
|
| 966 | 966 | <td> |
| 967 | - <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> |
|
| 967 | + <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> |
|
| 968 | 968 | </td> |
| 969 | 969 | <td> |
| 970 | 970 | <a href="<?php |
| 971 | 971 | echo esc_url( |
| 972 | 972 | wp_nonce_url( |
| 973 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
| 973 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
| 974 | 974 | 'getpaid-nonce', |
| 975 | 975 | 'getpaid-nonce' |
| 976 | 976 | ) |
| 977 | 977 | ); |
| 978 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
| 978 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 979 | 979 | </td> |
| 980 | 980 | </tr> |
| 981 | 981 | |
| 982 | 982 | <tr> |
| 983 | - <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td> |
|
| 983 | + <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td> |
|
| 984 | 984 | <td> |
| 985 | - <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
| 985 | + <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
| 986 | 986 | </td> |
| 987 | 987 | <td> |
| 988 | 988 | <a href="<?php |
| 989 | 989 | echo esc_url( |
| 990 | 990 | wp_nonce_url( |
| 991 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
| 991 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
| 992 | 992 | 'getpaid-nonce', |
| 993 | 993 | 'getpaid-nonce' |
| 994 | 994 | ) |
| 995 | 995 | ); |
| 996 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
| 996 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a> |
|
| 997 | 997 | </td> |
| 998 | 998 | </tr> |
| 999 | 999 | |
| 1000 | 1000 | <tr> |
| 1001 | - <td><?php _e( 'Set-up Wizard', 'invoicing' );?></td> |
|
| 1001 | + <td><?php _e('Set-up Wizard', 'invoicing'); ?></td> |
|
| 1002 | 1002 | <td> |
| 1003 | - <small><?php _e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
| 1003 | + <small><?php _e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
| 1004 | 1004 | </td> |
| 1005 | 1005 | <td> |
| 1006 | 1006 | <a href="<?php |
| 1007 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
| 1008 | - ?>" class="button button-primary"><?php _e( 'Launch', 'invoicing' );?></a> |
|
| 1007 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
| 1008 | + ?>" class="button button-primary"><?php _e('Launch', 'invoicing'); ?></a> |
|
| 1009 | 1009 | </td> |
| 1010 | 1010 | </tr> |
| 1011 | 1011 | |
| 1012 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
| 1012 | + <?php do_action('wpinv_tools_row'); ?> |
|
| 1013 | 1013 | </tbody> |
| 1014 | 1014 | </table> |
| 1015 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
| 1015 | + <?php do_action('wpinv_tools_after'); ?> |
|
| 1016 | 1016 | <?php |
| 1017 | 1017 | echo ob_get_clean(); |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | |
| 1021 | -function wpinv_descriptive_text_callback( $args ) { |
|
| 1022 | - echo wp_kses_post( $args['desc'] ); |
|
| 1021 | +function wpinv_descriptive_text_callback($args) { |
|
| 1022 | + echo wp_kses_post($args['desc']); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | -function wpinv_raw_html_callback( $args ) { |
|
| 1025 | +function wpinv_raw_html_callback($args) { |
|
| 1026 | 1026 | echo $args['desc']; |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | -function wpinv_hook_callback( $args ) { |
|
| 1030 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1029 | +function wpinv_hook_callback($args) { |
|
| 1030 | + do_action('wpinv_' . $args['id'], $args); |
|
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | function wpinv_set_settings_cap() { |
| 1034 | 1034 | return wpinv_get_capability(); |
| 1035 | 1035 | } |
| 1036 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
| 1036 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
| 1037 | 1037 | |
| 1038 | 1038 | |
| 1039 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
| 1040 | - $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1041 | - $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
| 1039 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
| 1040 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1041 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
| 1042 | 1042 | |
| 1043 | - if ( $old != $new ) { |
|
| 1044 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
| 1043 | + if ($old != $new) { |
|
| 1044 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
| 1045 | 1045 | } |
| 1046 | 1046 | } |
| 1047 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
| 1047 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
| 1048 | 1048 | |
| 1049 | 1049 | /** |
| 1050 | 1050 | * Returns the merge tags help text. |
@@ -1053,16 +1053,16 @@ discard block |
||
| 1053 | 1053 | * |
| 1054 | 1054 | * @return string |
| 1055 | 1055 | */ |
| 1056 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
| 1056 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
| 1057 | 1057 | |
| 1058 | 1058 | $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
| 1059 | 1059 | $link = sprintf( |
| 1060 | 1060 | '<strong><a href="%s" target="_blank">%s</a></strong>', |
| 1061 | 1061 | $url, |
| 1062 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
| 1062 | + esc_html__('View available merge tags.', 'wpinv-quotes') |
|
| 1063 | 1063 | ); |
| 1064 | 1064 | |
| 1065 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
| 1065 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
| 1066 | 1066 | |
| 1067 | 1067 | return "$description $link"; |
| 1068 | 1068 | |
@@ -13,732 +13,732 @@ discard block |
||
| 13 | 13 | class GetPaid_Post_Types_Admin { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Hook in methods. |
|
| 17 | - */ |
|
| 18 | - public static function init() { |
|
| 19 | - |
|
| 20 | - // Init metaboxes. |
|
| 21 | - GetPaid_Metaboxes::init(); |
|
| 22 | - |
|
| 23 | - // Filter the post updated messages. |
|
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | - |
|
| 26 | - // Filter post actions. |
|
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | - |
|
| 30 | - // Invoice table columns. |
|
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 35 | - |
|
| 36 | - // Items table columns. |
|
| 37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 43 | - |
|
| 44 | - // Payment forms columns. |
|
| 45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 48 | - |
|
| 49 | - // Discount table columns. |
|
| 50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 52 | - |
|
| 53 | - // Deleting posts. |
|
| 54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 56 | - |
|
| 57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Post updated messages. |
|
| 62 | - */ |
|
| 63 | - public static function post_updated_messages( $messages ) { |
|
| 64 | - global $post; |
|
| 65 | - |
|
| 66 | - $messages['wpi_discount'] = array( |
|
| 67 | - 0 => '', |
|
| 68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 78 | - ); |
|
| 79 | - |
|
| 80 | - $messages['wpi_payment_form'] = array( |
|
| 81 | - 0 => '', |
|
| 82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 92 | - ); |
|
| 93 | - |
|
| 94 | - return $messages; |
|
| 95 | - |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Post row actions. |
|
| 100 | - */ |
|
| 101 | - public static function post_row_actions( $actions, $post ) { |
|
| 102 | - |
|
| 103 | - $post = get_post( $post ); |
|
| 104 | - |
|
| 105 | - // We do not want to edit the default payment form. |
|
| 106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 107 | - |
|
| 108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | - unset( $actions['trash'] ); |
|
| 110 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $actions['duplicate'] = sprintf( |
|
| 114 | - '<a href="%1$s">%2$s</a>', |
|
| 115 | - esc_url( |
|
| 116 | - wp_nonce_url( |
|
| 117 | - add_query_arg( |
|
| 118 | - array( |
|
| 119 | - 'getpaid-admin-action' => 'duplicate_form', |
|
| 120 | - 'form_id' => $post->ID |
|
| 121 | - ) |
|
| 122 | - ), |
|
| 123 | - 'getpaid-nonce', |
|
| 124 | - 'getpaid-nonce' |
|
| 125 | - ) |
|
| 126 | - ), |
|
| 127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 128 | - ); |
|
| 129 | - |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // Link to item payment form. |
|
| 133 | - if ( 'wpi_item' == $post->post_type ) { |
|
| 134 | - |
|
| 135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 136 | - |
|
| 137 | - $actions['buy'] = sprintf( |
|
| 138 | - '<a href="%1$s">%2$s</a>', |
|
| 139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $actions; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 16 | + * Hook in methods. |
|
| 17 | + */ |
|
| 18 | + public static function init() { |
|
| 19 | + |
|
| 20 | + // Init metaboxes. |
|
| 21 | + GetPaid_Metaboxes::init(); |
|
| 22 | + |
|
| 23 | + // Filter the post updated messages. |
|
| 24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | + |
|
| 26 | + // Filter post actions. |
|
| 27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | + |
|
| 30 | + // Invoice table columns. |
|
| 31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | + add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | + add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 35 | + |
|
| 36 | + // Items table columns. |
|
| 37 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 43 | + |
|
| 44 | + // Payment forms columns. |
|
| 45 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 48 | + |
|
| 49 | + // Discount table columns. |
|
| 50 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 52 | + |
|
| 53 | + // Deleting posts. |
|
| 54 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 56 | + |
|
| 57 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Post updated messages. |
|
| 62 | + */ |
|
| 63 | + public static function post_updated_messages( $messages ) { |
|
| 64 | + global $post; |
|
| 65 | + |
|
| 66 | + $messages['wpi_discount'] = array( |
|
| 67 | + 0 => '', |
|
| 68 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 78 | + ); |
|
| 79 | + |
|
| 80 | + $messages['wpi_payment_form'] = array( |
|
| 81 | + 0 => '', |
|
| 82 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 92 | + ); |
|
| 93 | + |
|
| 94 | + return $messages; |
|
| 95 | + |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Post row actions. |
|
| 100 | + */ |
|
| 101 | + public static function post_row_actions( $actions, $post ) { |
|
| 102 | + |
|
| 103 | + $post = get_post( $post ); |
|
| 104 | + |
|
| 105 | + // We do not want to edit the default payment form. |
|
| 106 | + if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 107 | + |
|
| 108 | + if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | + unset( $actions['trash'] ); |
|
| 110 | + unset( $actions['inline hide-if-no-js'] ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $actions['duplicate'] = sprintf( |
|
| 114 | + '<a href="%1$s">%2$s</a>', |
|
| 115 | + esc_url( |
|
| 116 | + wp_nonce_url( |
|
| 117 | + add_query_arg( |
|
| 118 | + array( |
|
| 119 | + 'getpaid-admin-action' => 'duplicate_form', |
|
| 120 | + 'form_id' => $post->ID |
|
| 121 | + ) |
|
| 122 | + ), |
|
| 123 | + 'getpaid-nonce', |
|
| 124 | + 'getpaid-nonce' |
|
| 125 | + ) |
|
| 126 | + ), |
|
| 127 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 128 | + ); |
|
| 129 | + |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // Link to item payment form. |
|
| 133 | + if ( 'wpi_item' == $post->post_type ) { |
|
| 134 | + |
|
| 135 | + if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 136 | + |
|
| 137 | + $actions['buy'] = sprintf( |
|
| 138 | + '<a href="%1$s">%2$s</a>', |
|
| 139 | + esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | + esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $actions; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | 151 | * Remove bulk edit option from admin side quote listing |
| 152 | 152 | * |
| 153 | 153 | * @since 1.0.0 |
| 154 | 154 | * @param array $actions post actions |
| 155 | - * @param WP_Post $post |
|
| 155 | + * @param WP_Post $post |
|
| 156 | 156 | * @return array $actions actions without edit option |
| 157 | 157 | */ |
| 158 | 158 | public static function filter_invoice_row_actions( $actions, $post ) { |
| 159 | 159 | |
| 160 | 160 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
| 161 | 161 | |
| 162 | - $actions = array(); |
|
| 163 | - $invoice = new WPInv_Invoice( $post ); |
|
| 164 | - |
|
| 165 | - $actions['edit'] = sprintf( |
|
| 166 | - '<a href="%1$s">%2$s</a>', |
|
| 167 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 168 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 169 | - ); |
|
| 170 | - |
|
| 171 | - if ( ! $invoice->is_draft() ) { |
|
| 172 | - |
|
| 173 | - $actions['view'] = sprintf( |
|
| 174 | - '<a href="%1$s">%2$s</a>', |
|
| 175 | - esc_url( $invoice->get_view_url() ), |
|
| 176 | - sprintf( |
|
| 177 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 178 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 179 | - ) |
|
| 180 | - ); |
|
| 181 | - |
|
| 182 | - $actions['send'] = sprintf( |
|
| 183 | - '<a href="%1$s">%2$s</a>', |
|
| 184 | - esc_url( |
|
| 185 | - wp_nonce_url( |
|
| 186 | - add_query_arg( |
|
| 187 | - array( |
|
| 188 | - 'getpaid-admin-action' => 'send_invoice', |
|
| 189 | - 'invoice_id' => $invoice->get_id() |
|
| 190 | - ) |
|
| 191 | - ), |
|
| 192 | - 'getpaid-nonce', |
|
| 193 | - 'getpaid-nonce' |
|
| 194 | - ) |
|
| 195 | - ), |
|
| 196 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 197 | - ); |
|
| 198 | - |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - $actions['duplicate'] = sprintf( |
|
| 202 | - '<a href="%1$s">%2$s</a>', |
|
| 203 | - esc_url( |
|
| 204 | - wp_nonce_url( |
|
| 205 | - add_query_arg( |
|
| 206 | - array( |
|
| 207 | - 'getpaid-admin-action' => 'duplicate_invoice', |
|
| 208 | - 'invoice_id' => $post->ID |
|
| 209 | - ) |
|
| 210 | - ), |
|
| 211 | - 'getpaid-nonce', |
|
| 212 | - 'getpaid-nonce' |
|
| 213 | - ) |
|
| 214 | - ), |
|
| 215 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 216 | - ); |
|
| 162 | + $actions = array(); |
|
| 163 | + $invoice = new WPInv_Invoice( $post ); |
|
| 164 | + |
|
| 165 | + $actions['edit'] = sprintf( |
|
| 166 | + '<a href="%1$s">%2$s</a>', |
|
| 167 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 168 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 169 | + ); |
|
| 170 | + |
|
| 171 | + if ( ! $invoice->is_draft() ) { |
|
| 172 | + |
|
| 173 | + $actions['view'] = sprintf( |
|
| 174 | + '<a href="%1$s">%2$s</a>', |
|
| 175 | + esc_url( $invoice->get_view_url() ), |
|
| 176 | + sprintf( |
|
| 177 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 178 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 179 | + ) |
|
| 180 | + ); |
|
| 181 | + |
|
| 182 | + $actions['send'] = sprintf( |
|
| 183 | + '<a href="%1$s">%2$s</a>', |
|
| 184 | + esc_url( |
|
| 185 | + wp_nonce_url( |
|
| 186 | + add_query_arg( |
|
| 187 | + array( |
|
| 188 | + 'getpaid-admin-action' => 'send_invoice', |
|
| 189 | + 'invoice_id' => $invoice->get_id() |
|
| 190 | + ) |
|
| 191 | + ), |
|
| 192 | + 'getpaid-nonce', |
|
| 193 | + 'getpaid-nonce' |
|
| 194 | + ) |
|
| 195 | + ), |
|
| 196 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 197 | + ); |
|
| 198 | + |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + $actions['duplicate'] = sprintf( |
|
| 202 | + '<a href="%1$s">%2$s</a>', |
|
| 203 | + esc_url( |
|
| 204 | + wp_nonce_url( |
|
| 205 | + add_query_arg( |
|
| 206 | + array( |
|
| 207 | + 'getpaid-admin-action' => 'duplicate_invoice', |
|
| 208 | + 'invoice_id' => $post->ID |
|
| 209 | + ) |
|
| 210 | + ), |
|
| 211 | + 'getpaid-nonce', |
|
| 212 | + 'getpaid-nonce' |
|
| 213 | + ) |
|
| 214 | + ), |
|
| 215 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 216 | + ); |
|
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | return $actions; |
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Returns an array of invoice table columns. |
|
| 225 | - */ |
|
| 226 | - public static function invoice_columns( $columns ) { |
|
| 227 | - |
|
| 228 | - $columns = array( |
|
| 229 | - 'cb' => $columns['cb'], |
|
| 230 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 231 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 232 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 233 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 234 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 235 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 236 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 237 | - ); |
|
| 238 | - |
|
| 239 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Displays invoice table columns. |
|
| 244 | - */ |
|
| 245 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 246 | - |
|
| 247 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 248 | - |
|
| 249 | - switch ( $column_name ) { |
|
| 250 | - |
|
| 251 | - case 'invoice_date' : |
|
| 252 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 253 | - $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 254 | - echo "<span title='$date_time'>$date</span>"; |
|
| 255 | - break; |
|
| 256 | - |
|
| 257 | - case 'payment_date' : |
|
| 258 | - |
|
| 259 | - if ( $invoice->is_paid() ) { |
|
| 260 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 261 | - $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 262 | - echo "<span title='$date_time'>$date</span>"; |
|
| 263 | - } else { |
|
| 264 | - echo "—"; |
|
| 265 | - } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Returns an array of invoice table columns. |
|
| 225 | + */ |
|
| 226 | + public static function invoice_columns( $columns ) { |
|
| 227 | + |
|
| 228 | + $columns = array( |
|
| 229 | + 'cb' => $columns['cb'], |
|
| 230 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
| 231 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 232 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 233 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 234 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 235 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 236 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 237 | + ); |
|
| 238 | + |
|
| 239 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Displays invoice table columns. |
|
| 244 | + */ |
|
| 245 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 246 | + |
|
| 247 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 248 | + |
|
| 249 | + switch ( $column_name ) { |
|
| 250 | + |
|
| 251 | + case 'invoice_date' : |
|
| 252 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 253 | + $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 254 | + echo "<span title='$date_time'>$date</span>"; |
|
| 255 | + break; |
|
| 256 | + |
|
| 257 | + case 'payment_date' : |
|
| 258 | + |
|
| 259 | + if ( $invoice->is_paid() ) { |
|
| 260 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 261 | + $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 262 | + echo "<span title='$date_time'>$date</span>"; |
|
| 263 | + } else { |
|
| 264 | + echo "—"; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - break; |
|
| 267 | + break; |
|
| 268 | 268 | |
| 269 | - case 'amount' : |
|
| 269 | + case 'amount' : |
|
| 270 | 270 | |
| 271 | - $amount = $invoice->get_total(); |
|
| 272 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 271 | + $amount = $invoice->get_total(); |
|
| 272 | + $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 273 | 273 | |
| 274 | - if ( $invoice->is_refunded() ) { |
|
| 275 | - $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
| 276 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
| 277 | - } else { |
|
| 274 | + if ( $invoice->is_refunded() ) { |
|
| 275 | + $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
| 276 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
| 277 | + } else { |
|
| 278 | 278 | |
| 279 | - $discount = $invoice->get_total_discount(); |
|
| 279 | + $discount = $invoice->get_total_discount(); |
|
| 280 | 280 | |
| 281 | - if ( ! empty( $discount ) ) { |
|
| 282 | - $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
| 283 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
| 284 | - } else { |
|
| 285 | - echo wp_kses_post( $formated_amount ); |
|
| 286 | - } |
|
| 281 | + if ( ! empty( $discount ) ) { |
|
| 282 | + $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
| 283 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
| 284 | + } else { |
|
| 285 | + echo wp_kses_post( $formated_amount ); |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - break; |
|
| 290 | + break; |
|
| 291 | 291 | |
| 292 | - case 'status' : |
|
| 293 | - $status = esc_html( $invoice->get_status() ); |
|
| 294 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 292 | + case 'status' : |
|
| 293 | + $status = esc_html( $invoice->get_status() ); |
|
| 294 | + $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 295 | 295 | |
| 296 | - // If it is paid, show the gateway title. |
|
| 297 | - if ( $invoice->is_paid() ) { |
|
| 298 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 299 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 296 | + // If it is paid, show the gateway title. |
|
| 297 | + if ( $invoice->is_paid() ) { |
|
| 298 | + $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 299 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 300 | 300 | |
| 301 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
| 302 | - } else { |
|
| 303 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
| 304 | - } |
|
| 301 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
| 302 | + } else { |
|
| 303 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - // If it is not paid, display the overdue and view status. |
|
| 307 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 306 | + // If it is not paid, display the overdue and view status. |
|
| 307 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 308 | 308 | |
| 309 | - // Invoice view status. |
|
| 310 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 311 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 312 | - } else { |
|
| 313 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 314 | - } |
|
| 309 | + // Invoice view status. |
|
| 310 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 311 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 312 | + } else { |
|
| 313 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - // Display the overview status. |
|
| 317 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 318 | - $due_date = $invoice->get_due_date(); |
|
| 319 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 316 | + // Display the overview status. |
|
| 317 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 318 | + $due_date = $invoice->get_due_date(); |
|
| 319 | + $fomatted = getpaid_format_date( $due_date ); |
|
| 320 | 320 | |
| 321 | - if ( ! empty( $fomatted ) ) { |
|
| 322 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 323 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
| 324 | - } |
|
| 325 | - } |
|
| 321 | + if ( ! empty( $fomatted ) ) { |
|
| 322 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 323 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | - } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - break; |
|
| 329 | + break; |
|
| 330 | 330 | |
| 331 | - case 'recurring': |
|
| 331 | + case 'recurring': |
|
| 332 | 332 | |
| 333 | - if ( $invoice->is_recurring() ) { |
|
| 334 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 335 | - } else { |
|
| 336 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 337 | - } |
|
| 338 | - break; |
|
| 333 | + if ( $invoice->is_recurring() ) { |
|
| 334 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 335 | + } else { |
|
| 336 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 337 | + } |
|
| 338 | + break; |
|
| 339 | 339 | |
| 340 | - case 'number' : |
|
| 340 | + case 'number' : |
|
| 341 | 341 | |
| 342 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 343 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
| 344 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 342 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 343 | + $invoice_number = esc_html( $invoice->get_number() ); |
|
| 344 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 345 | 345 | |
| 346 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
| 346 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
| 347 | 347 | |
| 348 | - break; |
|
| 348 | + break; |
|
| 349 | 349 | |
| 350 | - case 'customer' : |
|
| 350 | + case 'customer' : |
|
| 351 | 351 | |
| 352 | - $customer_name = $invoice->get_user_full_name(); |
|
| 352 | + $customer_name = $invoice->get_user_full_name(); |
|
| 353 | 353 | |
| 354 | - if ( empty( $customer_name ) ) { |
|
| 355 | - $customer_name = $invoice->get_email(); |
|
| 356 | - } |
|
| 354 | + if ( empty( $customer_name ) ) { |
|
| 355 | + $customer_name = $invoice->get_email(); |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - if ( ! empty( $customer_name ) ) { |
|
| 359 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 360 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 361 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
| 362 | - } else { |
|
| 363 | - echo '<div>—</div>'; |
|
| 364 | - } |
|
| 358 | + if ( ! empty( $customer_name ) ) { |
|
| 359 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 360 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 361 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
| 362 | + } else { |
|
| 363 | + echo '<div>—</div>'; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - break; |
|
| 366 | + break; |
|
| 367 | 367 | |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - } |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - /** |
|
| 373 | - * Displays invoice bulk actions. |
|
| 374 | - */ |
|
| 375 | - public static function invoice_bulk_actions( $actions ) { |
|
| 376 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 377 | - return $actions; |
|
| 378 | - } |
|
| 372 | + /** |
|
| 373 | + * Displays invoice bulk actions. |
|
| 374 | + */ |
|
| 375 | + public static function invoice_bulk_actions( $actions ) { |
|
| 376 | + $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 377 | + return $actions; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - /** |
|
| 381 | - * Processes invoice bulk actions. |
|
| 382 | - */ |
|
| 383 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 380 | + /** |
|
| 381 | + * Processes invoice bulk actions. |
|
| 382 | + */ |
|
| 383 | + public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 384 | 384 | |
| 385 | - if ( $action == 'resend-invoice' ) { |
|
| 386 | - foreach ( $post_ids as $post_id ) { |
|
| 387 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 388 | - } |
|
| 389 | - } |
|
| 385 | + if ( $action == 'resend-invoice' ) { |
|
| 386 | + foreach ( $post_ids as $post_id ) { |
|
| 387 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - return $redirect_url; |
|
| 391 | + return $redirect_url; |
|
| 392 | 392 | |
| 393 | - } |
|
| 393 | + } |
|
| 394 | 394 | |
| 395 | - /** |
|
| 396 | - * Returns an array of payment forms table columns. |
|
| 397 | - */ |
|
| 398 | - public static function payment_form_columns( $columns ) { |
|
| 395 | + /** |
|
| 396 | + * Returns an array of payment forms table columns. |
|
| 397 | + */ |
|
| 398 | + public static function payment_form_columns( $columns ) { |
|
| 399 | 399 | |
| 400 | - $columns = array( |
|
| 401 | - 'cb' => $columns['cb'], |
|
| 402 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 403 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 404 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 405 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 406 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 407 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 408 | - ); |
|
| 400 | + $columns = array( |
|
| 401 | + 'cb' => $columns['cb'], |
|
| 402 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 403 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 404 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 405 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 406 | + 'items' => __( 'Items', 'invoicing' ), |
|
| 407 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 408 | + ); |
|
| 409 | 409 | |
| 410 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 410 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 411 | 411 | |
| 412 | - } |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - /** |
|
| 415 | - * Displays payment form table columns. |
|
| 416 | - */ |
|
| 417 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 414 | + /** |
|
| 415 | + * Displays payment form table columns. |
|
| 416 | + */ |
|
| 417 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 418 | 418 | |
| 419 | - // Retrieve the payment form. |
|
| 420 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 419 | + // Retrieve the payment form. |
|
| 420 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
| 421 | 421 | |
| 422 | - switch ( $column_name ) { |
|
| 422 | + switch ( $column_name ) { |
|
| 423 | 423 | |
| 424 | - case 'earnings' : |
|
| 425 | - echo wpinv_price( $form->get_earned() ); |
|
| 426 | - break; |
|
| 424 | + case 'earnings' : |
|
| 425 | + echo wpinv_price( $form->get_earned() ); |
|
| 426 | + break; |
|
| 427 | 427 | |
| 428 | - case 'refunds' : |
|
| 429 | - echo wpinv_price( $form->get_refunded() ); |
|
| 430 | - break; |
|
| 428 | + case 'refunds' : |
|
| 429 | + echo wpinv_price( $form->get_refunded() ); |
|
| 430 | + break; |
|
| 431 | 431 | |
| 432 | - case 'refunds' : |
|
| 433 | - echo wpinv_price( $form->get_refunded() ); |
|
| 434 | - break; |
|
| 432 | + case 'refunds' : |
|
| 433 | + echo wpinv_price( $form->get_refunded() ); |
|
| 434 | + break; |
|
| 435 | 435 | |
| 436 | - case 'shortcode' : |
|
| 436 | + case 'shortcode' : |
|
| 437 | 437 | |
| 438 | - if ( $form->is_default() ) { |
|
| 439 | - echo '—'; |
|
| 440 | - } else { |
|
| 441 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 442 | - } |
|
| 438 | + if ( $form->is_default() ) { |
|
| 439 | + echo '—'; |
|
| 440 | + } else { |
|
| 441 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 442 | + } |
|
| 443 | 443 | |
| 444 | - break; |
|
| 444 | + break; |
|
| 445 | 445 | |
| 446 | - case 'items' : |
|
| 446 | + case 'items' : |
|
| 447 | 447 | |
| 448 | - $items = $form->get_items(); |
|
| 448 | + $items = $form->get_items(); |
|
| 449 | 449 | |
| 450 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 451 | - echo '—'; |
|
| 452 | - return; |
|
| 453 | - } |
|
| 450 | + if ( $form->is_default() || empty( $items ) ) { |
|
| 451 | + echo '—'; |
|
| 452 | + return; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - $_items = array(); |
|
| 455 | + $_items = array(); |
|
| 456 | 456 | |
| 457 | - foreach ( $items as $item ) { |
|
| 458 | - $url = $item->get_edit_url(); |
|
| 457 | + foreach ( $items as $item ) { |
|
| 458 | + $url = $item->get_edit_url(); |
|
| 459 | 459 | |
| 460 | - if ( empty( $url ) ) { |
|
| 461 | - $_items[] = esc_html( $item->get_name() ); |
|
| 462 | - } else { |
|
| 463 | - $_items[] = sprintf( |
|
| 464 | - '<a href="%s">%s</a>', |
|
| 465 | - esc_url( $url ), |
|
| 466 | - esc_html( $item->get_name() ) |
|
| 467 | - ); |
|
| 468 | - } |
|
| 460 | + if ( empty( $url ) ) { |
|
| 461 | + $_items[] = esc_html( $item->get_name() ); |
|
| 462 | + } else { |
|
| 463 | + $_items[] = sprintf( |
|
| 464 | + '<a href="%s">%s</a>', |
|
| 465 | + esc_url( $url ), |
|
| 466 | + esc_html( $item->get_name() ) |
|
| 467 | + ); |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - echo implode( '<br>', $_items ); |
|
| 472 | + echo implode( '<br>', $_items ); |
|
| 473 | 473 | |
| 474 | - break; |
|
| 474 | + break; |
|
| 475 | 475 | |
| 476 | - } |
|
| 476 | + } |
|
| 477 | 477 | |
| 478 | - } |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - /** |
|
| 481 | - * Filters post states. |
|
| 482 | - */ |
|
| 483 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 480 | + /** |
|
| 481 | + * Filters post states. |
|
| 482 | + */ |
|
| 483 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
| 484 | 484 | |
| 485 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 486 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 487 | - } |
|
| 485 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 486 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - return $post_states; |
|
| 490 | - |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * Returns an array of coupon table columns. |
|
| 495 | - */ |
|
| 496 | - public static function discount_columns( $columns ) { |
|
| 497 | - |
|
| 498 | - $columns = array( |
|
| 499 | - 'cb' => $columns['cb'], |
|
| 500 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 501 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 502 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 503 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 504 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 505 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 506 | - ); |
|
| 507 | - |
|
| 508 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * Filters post states. |
|
| 513 | - */ |
|
| 514 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 515 | - |
|
| 516 | - if ( 'wpi_discount' == $post->post_type ) { |
|
| 517 | - |
|
| 518 | - $discount = new WPInv_Discount( $post ); |
|
| 519 | - |
|
| 520 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 521 | - |
|
| 522 | - if ( $status != 'publish' ) { |
|
| 523 | - return array( |
|
| 524 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 525 | - ); |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - return array(); |
|
| 529 | - |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - return $post_states; |
|
| 533 | - |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * Returns an array of items table columns. |
|
| 538 | - */ |
|
| 539 | - public static function item_columns( $columns ) { |
|
| 540 | - |
|
| 541 | - $columns = array( |
|
| 542 | - 'cb' => $columns['cb'], |
|
| 543 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 544 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 545 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 546 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 547 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 548 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 549 | - ); |
|
| 550 | - |
|
| 551 | - if ( ! wpinv_use_taxes() ) { |
|
| 552 | - unset( $columns['vat_rule'] ); |
|
| 553 | - unset( $columns['vat_class'] ); |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * Returns an array of sortable items table columns. |
|
| 561 | - */ |
|
| 562 | - public static function sortable_item_columns( $columns ) { |
|
| 563 | - |
|
| 564 | - return array_merge( |
|
| 565 | - $columns, |
|
| 566 | - array( |
|
| 567 | - 'price' => 'price', |
|
| 568 | - 'vat_rule' => 'vat_rule', |
|
| 569 | - 'vat_class' => 'vat_class', |
|
| 570 | - 'type' => 'type', |
|
| 571 | - ) |
|
| 572 | - ); |
|
| 573 | - |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * Displays items table columns. |
|
| 578 | - */ |
|
| 579 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 489 | + return $post_states; |
|
| 490 | + |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * Returns an array of coupon table columns. |
|
| 495 | + */ |
|
| 496 | + public static function discount_columns( $columns ) { |
|
| 497 | + |
|
| 498 | + $columns = array( |
|
| 499 | + 'cb' => $columns['cb'], |
|
| 500 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 501 | + 'code' => __( 'Code', 'invoicing' ), |
|
| 502 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 503 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 504 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 505 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 506 | + ); |
|
| 507 | + |
|
| 508 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + /** |
|
| 512 | + * Filters post states. |
|
| 513 | + */ |
|
| 514 | + public static function filter_discount_state( $post_states, $post ) { |
|
| 515 | + |
|
| 516 | + if ( 'wpi_discount' == $post->post_type ) { |
|
| 517 | + |
|
| 518 | + $discount = new WPInv_Discount( $post ); |
|
| 519 | + |
|
| 520 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 521 | + |
|
| 522 | + if ( $status != 'publish' ) { |
|
| 523 | + return array( |
|
| 524 | + 'discount_status' => wpinv_discount_status( $status ), |
|
| 525 | + ); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + return array(); |
|
| 529 | + |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + return $post_states; |
|
| 533 | + |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * Returns an array of items table columns. |
|
| 538 | + */ |
|
| 539 | + public static function item_columns( $columns ) { |
|
| 540 | + |
|
| 541 | + $columns = array( |
|
| 542 | + 'cb' => $columns['cb'], |
|
| 543 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 544 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 545 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 546 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 547 | + 'type' => __( 'Type', 'invoicing' ), |
|
| 548 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 549 | + ); |
|
| 550 | + |
|
| 551 | + if ( ! wpinv_use_taxes() ) { |
|
| 552 | + unset( $columns['vat_rule'] ); |
|
| 553 | + unset( $columns['vat_class'] ); |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * Returns an array of sortable items table columns. |
|
| 561 | + */ |
|
| 562 | + public static function sortable_item_columns( $columns ) { |
|
| 563 | + |
|
| 564 | + return array_merge( |
|
| 565 | + $columns, |
|
| 566 | + array( |
|
| 567 | + 'price' => 'price', |
|
| 568 | + 'vat_rule' => 'vat_rule', |
|
| 569 | + 'vat_class' => 'vat_class', |
|
| 570 | + 'type' => 'type', |
|
| 571 | + ) |
|
| 572 | + ); |
|
| 573 | + |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * Displays items table columns. |
|
| 578 | + */ |
|
| 579 | + public static function display_item_columns( $column_name, $post_id ) { |
|
| 580 | 580 | |
| 581 | - $item = new WPInv_Item( $post_id ); |
|
| 581 | + $item = new WPInv_Item( $post_id ); |
|
| 582 | 582 | |
| 583 | - switch ( $column_name ) { |
|
| 583 | + switch ( $column_name ) { |
|
| 584 | 584 | |
| 585 | - case 'price' : |
|
| 585 | + case 'price' : |
|
| 586 | 586 | |
| 587 | - if ( ! $item->is_recurring() ) { |
|
| 588 | - echo wp_kses_post( $item->get_the_price() ); |
|
| 589 | - break; |
|
| 590 | - } |
|
| 587 | + if ( ! $item->is_recurring() ) { |
|
| 588 | + echo wp_kses_post( $item->get_the_price() ); |
|
| 589 | + break; |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - $price = wp_sprintf( |
|
| 593 | - __( '%s / %s', 'invoicing' ), |
|
| 594 | - $item->get_the_price(), |
|
| 595 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 596 | - ); |
|
| 592 | + $price = wp_sprintf( |
|
| 593 | + __( '%s / %s', 'invoicing' ), |
|
| 594 | + $item->get_the_price(), |
|
| 595 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 596 | + ); |
|
| 597 | 597 | |
| 598 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 599 | - echo wp_kses_post( $price ); |
|
| 600 | - break; |
|
| 601 | - } |
|
| 598 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 599 | + echo wp_kses_post( $price ); |
|
| 600 | + break; |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 603 | + echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 604 | 604 | |
| 605 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) .'</span>'; |
|
| 606 | - break; |
|
| 605 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) .'</span>'; |
|
| 606 | + break; |
|
| 607 | 607 | |
| 608 | - case 'vat_rule' : |
|
| 609 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 610 | - break; |
|
| 608 | + case 'vat_rule' : |
|
| 609 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 610 | + break; |
|
| 611 | 611 | |
| 612 | - case 'vat_class' : |
|
| 613 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 614 | - break; |
|
| 612 | + case 'vat_class' : |
|
| 613 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 614 | + break; |
|
| 615 | 615 | |
| 616 | - case 'shortcode' : |
|
| 616 | + case 'shortcode' : |
|
| 617 | 617 | |
| 618 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 619 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 620 | - } else { |
|
| 621 | - echo "—"; |
|
| 622 | - } |
|
| 618 | + if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 619 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 620 | + } else { |
|
| 621 | + echo "—"; |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - break; |
|
| 624 | + break; |
|
| 625 | 625 | |
| 626 | - case 'type' : |
|
| 627 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 628 | - break; |
|
| 626 | + case 'type' : |
|
| 627 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 628 | + break; |
|
| 629 | 629 | |
| 630 | - } |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - } |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | - /** |
|
| 635 | - * Lets users filter items using taxes. |
|
| 636 | - */ |
|
| 637 | - public static function add_item_filters( $post_type ) { |
|
| 634 | + /** |
|
| 635 | + * Lets users filter items using taxes. |
|
| 636 | + */ |
|
| 637 | + public static function add_item_filters( $post_type ) { |
|
| 638 | 638 | |
| 639 | - // Abort if we're not dealing with items. |
|
| 640 | - if ( $post_type != 'wpi_item' ) { |
|
| 641 | - return; |
|
| 642 | - } |
|
| 639 | + // Abort if we're not dealing with items. |
|
| 640 | + if ( $post_type != 'wpi_item' ) { |
|
| 641 | + return; |
|
| 642 | + } |
|
| 643 | 643 | |
| 644 | - // Filter by vat rules. |
|
| 645 | - if ( wpinv_use_taxes() ) { |
|
| 644 | + // Filter by vat rules. |
|
| 645 | + if ( wpinv_use_taxes() ) { |
|
| 646 | 646 | |
| 647 | - // Sanitize selected vat rule. |
|
| 648 | - $vat_rule = ''; |
|
| 649 | - $vat_rules = getpaid_get_tax_rules(); |
|
| 650 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
| 651 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - // Filter by VAT rule. |
|
| 655 | - echo wpinv_html_select( |
|
| 656 | - array( |
|
| 657 | - 'options' => array_merge( |
|
| 658 | - array( |
|
| 659 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
| 660 | - ), |
|
| 661 | - $vat_rules |
|
| 662 | - ), |
|
| 663 | - 'name' => 'vat_rule', |
|
| 664 | - 'id' => 'vat_rule', |
|
| 665 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 666 | - 'show_option_all' => false, |
|
| 667 | - 'show_option_none' => false, |
|
| 668 | - ) |
|
| 669 | - ); |
|
| 670 | - |
|
| 671 | - // Filter by VAT class. |
|
| 647 | + // Sanitize selected vat rule. |
|
| 648 | + $vat_rule = ''; |
|
| 649 | + $vat_rules = getpaid_get_tax_rules(); |
|
| 650 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
| 651 | + $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + // Filter by VAT rule. |
|
| 655 | + echo wpinv_html_select( |
|
| 656 | + array( |
|
| 657 | + 'options' => array_merge( |
|
| 658 | + array( |
|
| 659 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
| 660 | + ), |
|
| 661 | + $vat_rules |
|
| 662 | + ), |
|
| 663 | + 'name' => 'vat_rule', |
|
| 664 | + 'id' => 'vat_rule', |
|
| 665 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 666 | + 'show_option_all' => false, |
|
| 667 | + 'show_option_none' => false, |
|
| 668 | + ) |
|
| 669 | + ); |
|
| 670 | + |
|
| 671 | + // Filter by VAT class. |
|
| 672 | 672 | |
| 673 | - // Sanitize selected vat rule. |
|
| 674 | - $vat_class = ''; |
|
| 675 | - $vat_classes = getpaid_get_tax_classes(); |
|
| 676 | - if ( isset( $_GET['vat_class'] ) ) { |
|
| 677 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - echo wpinv_html_select( |
|
| 681 | - array( |
|
| 682 | - 'options' => array_merge( |
|
| 683 | - array( |
|
| 684 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
| 685 | - ), |
|
| 686 | - $vat_classes |
|
| 687 | - ), |
|
| 688 | - 'name' => 'vat_class', |
|
| 689 | - 'id' => 'vat_class', |
|
| 690 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 691 | - 'show_option_all' => false, |
|
| 692 | - 'show_option_none' => false, |
|
| 693 | - ) |
|
| 694 | - ); |
|
| 695 | - |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - // Filter by item type. |
|
| 699 | - $type = ''; |
|
| 700 | - if ( isset( $_GET['type'] ) ) { |
|
| 701 | - $type = sanitize_text_field( $_GET['type'] ); |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - echo wpinv_html_select( |
|
| 705 | - array( |
|
| 706 | - 'options' => array_merge( |
|
| 707 | - array( |
|
| 708 | - '' => __( 'All item types', 'invoicing' ) |
|
| 709 | - ), |
|
| 710 | - wpinv_get_item_types() |
|
| 711 | - ), |
|
| 712 | - 'name' => 'type', |
|
| 713 | - 'id' => 'type', |
|
| 714 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 715 | - 'show_option_all' => false, |
|
| 716 | - 'show_option_none' => false, |
|
| 717 | - ) |
|
| 718 | - ); |
|
| 719 | - |
|
| 720 | - } |
|
| 721 | - |
|
| 722 | - /** |
|
| 723 | - * Filters the item query. |
|
| 724 | - */ |
|
| 725 | - public static function filter_item_query( $query ) { |
|
| 726 | - |
|
| 727 | - // modify the query only if it admin and main query. |
|
| 728 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 729 | - return $query; |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - // we want to modify the query for our items. |
|
| 733 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 734 | - return $query; |
|
| 735 | - } |
|
| 736 | - |
|
| 737 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 738 | - $query->query_vars['meta_query'] = array(); |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - // Filter vat rule type |
|
| 673 | + // Sanitize selected vat rule. |
|
| 674 | + $vat_class = ''; |
|
| 675 | + $vat_classes = getpaid_get_tax_classes(); |
|
| 676 | + if ( isset( $_GET['vat_class'] ) ) { |
|
| 677 | + $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + echo wpinv_html_select( |
|
| 681 | + array( |
|
| 682 | + 'options' => array_merge( |
|
| 683 | + array( |
|
| 684 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
| 685 | + ), |
|
| 686 | + $vat_classes |
|
| 687 | + ), |
|
| 688 | + 'name' => 'vat_class', |
|
| 689 | + 'id' => 'vat_class', |
|
| 690 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 691 | + 'show_option_all' => false, |
|
| 692 | + 'show_option_none' => false, |
|
| 693 | + ) |
|
| 694 | + ); |
|
| 695 | + |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + // Filter by item type. |
|
| 699 | + $type = ''; |
|
| 700 | + if ( isset( $_GET['type'] ) ) { |
|
| 701 | + $type = sanitize_text_field( $_GET['type'] ); |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + echo wpinv_html_select( |
|
| 705 | + array( |
|
| 706 | + 'options' => array_merge( |
|
| 707 | + array( |
|
| 708 | + '' => __( 'All item types', 'invoicing' ) |
|
| 709 | + ), |
|
| 710 | + wpinv_get_item_types() |
|
| 711 | + ), |
|
| 712 | + 'name' => 'type', |
|
| 713 | + 'id' => 'type', |
|
| 714 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 715 | + 'show_option_all' => false, |
|
| 716 | + 'show_option_none' => false, |
|
| 717 | + ) |
|
| 718 | + ); |
|
| 719 | + |
|
| 720 | + } |
|
| 721 | + |
|
| 722 | + /** |
|
| 723 | + * Filters the item query. |
|
| 724 | + */ |
|
| 725 | + public static function filter_item_query( $query ) { |
|
| 726 | + |
|
| 727 | + // modify the query only if it admin and main query. |
|
| 728 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 729 | + return $query; |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + // we want to modify the query for our items. |
|
| 733 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 734 | + return $query; |
|
| 735 | + } |
|
| 736 | + |
|
| 737 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 738 | + $query->query_vars['meta_query'] = array(); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + // Filter vat rule type |
|
| 742 | 742 | if ( ! empty( $_GET['vat_rule'] ) ) { |
| 743 | 743 | $query->query_vars['meta_query'][] = array( |
| 744 | 744 | 'key' => '_wpinv_vat_rule', |
@@ -763,97 +763,97 @@ discard block |
||
| 763 | 763 | 'value' => sanitize_text_field( $_GET['type'] ), |
| 764 | 764 | 'compare' => '=' |
| 765 | 765 | ); |
| 766 | - } |
|
| 767 | - |
|
| 768 | - } |
|
| 769 | - |
|
| 770 | - /** |
|
| 771 | - * Reorders items. |
|
| 772 | - */ |
|
| 773 | - public static function reorder_items( $vars ) { |
|
| 774 | - global $typenow; |
|
| 775 | - |
|
| 776 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 777 | - return $vars; |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - // By item type. |
|
| 781 | - if ( 'type' == $vars['orderby'] ) { |
|
| 782 | - return array_merge( |
|
| 783 | - $vars, |
|
| 784 | - array( |
|
| 785 | - 'meta_key' => '_wpinv_type', |
|
| 786 | - 'orderby' => 'meta_value' |
|
| 787 | - ) |
|
| 788 | - ); |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - // By vat class. |
|
| 792 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
| 793 | - return array_merge( |
|
| 794 | - $vars, |
|
| 795 | - array( |
|
| 796 | - 'meta_key' => '_wpinv_vat_class', |
|
| 797 | - 'orderby' => 'meta_value' |
|
| 798 | - ) |
|
| 799 | - ); |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - // By vat rule. |
|
| 803 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 804 | - return array_merge( |
|
| 805 | - $vars, |
|
| 806 | - array( |
|
| 807 | - 'meta_key' => '_wpinv_vat_rule', |
|
| 808 | - 'orderby' => 'meta_value' |
|
| 809 | - ) |
|
| 810 | - ); |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - // By price. |
|
| 814 | - if ( 'price' == $vars['orderby'] ) { |
|
| 815 | - return array_merge( |
|
| 816 | - $vars, |
|
| 817 | - array( |
|
| 818 | - 'meta_key' => '_wpinv_price', |
|
| 819 | - 'orderby' => 'meta_value_num' |
|
| 820 | - ) |
|
| 821 | - ); |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - return $vars; |
|
| 825 | - |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - /** |
|
| 829 | - * Fired when deleting a post. |
|
| 830 | - */ |
|
| 831 | - public static function delete_post( $post_id ) { |
|
| 832 | - |
|
| 833 | - switch ( get_post_type( $post_id ) ) { |
|
| 834 | - |
|
| 835 | - case 'wpi_item' : |
|
| 836 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 837 | - break; |
|
| 838 | - |
|
| 839 | - case 'wpi_payment_form' : |
|
| 840 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 841 | - break; |
|
| 842 | - |
|
| 843 | - case 'wpi_discount' : |
|
| 844 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 845 | - break; |
|
| 846 | - |
|
| 847 | - case 'wpi_invoice' : |
|
| 848 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 849 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 850 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 851 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 852 | - break; |
|
| 853 | - } |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - /** |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + } |
|
| 769 | + |
|
| 770 | + /** |
|
| 771 | + * Reorders items. |
|
| 772 | + */ |
|
| 773 | + public static function reorder_items( $vars ) { |
|
| 774 | + global $typenow; |
|
| 775 | + |
|
| 776 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 777 | + return $vars; |
|
| 778 | + } |
|
| 779 | + |
|
| 780 | + // By item type. |
|
| 781 | + if ( 'type' == $vars['orderby'] ) { |
|
| 782 | + return array_merge( |
|
| 783 | + $vars, |
|
| 784 | + array( |
|
| 785 | + 'meta_key' => '_wpinv_type', |
|
| 786 | + 'orderby' => 'meta_value' |
|
| 787 | + ) |
|
| 788 | + ); |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + // By vat class. |
|
| 792 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
| 793 | + return array_merge( |
|
| 794 | + $vars, |
|
| 795 | + array( |
|
| 796 | + 'meta_key' => '_wpinv_vat_class', |
|
| 797 | + 'orderby' => 'meta_value' |
|
| 798 | + ) |
|
| 799 | + ); |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + // By vat rule. |
|
| 803 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 804 | + return array_merge( |
|
| 805 | + $vars, |
|
| 806 | + array( |
|
| 807 | + 'meta_key' => '_wpinv_vat_rule', |
|
| 808 | + 'orderby' => 'meta_value' |
|
| 809 | + ) |
|
| 810 | + ); |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + // By price. |
|
| 814 | + if ( 'price' == $vars['orderby'] ) { |
|
| 815 | + return array_merge( |
|
| 816 | + $vars, |
|
| 817 | + array( |
|
| 818 | + 'meta_key' => '_wpinv_price', |
|
| 819 | + 'orderby' => 'meta_value_num' |
|
| 820 | + ) |
|
| 821 | + ); |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + return $vars; |
|
| 825 | + |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + /** |
|
| 829 | + * Fired when deleting a post. |
|
| 830 | + */ |
|
| 831 | + public static function delete_post( $post_id ) { |
|
| 832 | + |
|
| 833 | + switch ( get_post_type( $post_id ) ) { |
|
| 834 | + |
|
| 835 | + case 'wpi_item' : |
|
| 836 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 837 | + break; |
|
| 838 | + |
|
| 839 | + case 'wpi_payment_form' : |
|
| 840 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 841 | + break; |
|
| 842 | + |
|
| 843 | + case 'wpi_discount' : |
|
| 844 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 845 | + break; |
|
| 846 | + |
|
| 847 | + case 'wpi_invoice' : |
|
| 848 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 849 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 850 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
| 851 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 852 | + break; |
|
| 853 | + } |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | 857 | * Add a post display state for special GetPaid pages in the page list table. |
| 858 | 858 | * |
| 859 | 859 | * @param array $post_states An array of post display states. |
@@ -867,22 +867,22 @@ discard block |
||
| 867 | 867 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 870 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 871 | 871 | |
| 872 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 873 | - $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
| 874 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 875 | - $label |
|
| 876 | - ); |
|
| 877 | - } |
|
| 872 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 873 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
| 874 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 875 | + $label |
|
| 876 | + ); |
|
| 877 | + } |
|
| 878 | 878 | |
| 879 | - } |
|
| 879 | + } |
|
| 880 | 880 | |
| 881 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 881 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 882 | 882 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 885 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 886 | 886 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
| 887 | 887 | } |
| 888 | 888 | |
@@ -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 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
| 21 | 21 | GetPaid_Metaboxes::init(); |
| 22 | 22 | |
| 23 | 23 | // Filter the post updated messages. |
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
| 25 | 25 | |
| 26 | 26 | // Filter post actions. |
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
| 28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Invoice table columns. |
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
| 32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
| 33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
| 34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
| 35 | 35 | |
| 36 | 36 | // Items table columns. |
| 37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
| 38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
| 39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
| 40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
| 41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
| 42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
| 43 | 43 | |
| 44 | 44 | // Payment forms columns. |
| 45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
| 46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
| 47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
| 48 | 48 | |
| 49 | 49 | // Discount table columns. |
| 50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
| 51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
| 52 | 52 | |
| 53 | 53 | // Deleting posts. |
| 54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
| 55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
| 56 | 56 | |
| 57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Post updated messages. |
| 62 | 62 | */ |
| 63 | - public static function post_updated_messages( $messages ) { |
|
| 63 | + public static function post_updated_messages($messages) { |
|
| 64 | 64 | global $post; |
| 65 | 65 | |
| 66 | 66 | $messages['wpi_discount'] = array( |
| 67 | 67 | 0 => '', |
| 68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 68 | + 1 => __('Discount updated.', 'invoicing'), |
|
| 69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 71 | + 4 => __('Discount updated.', 'invoicing'), |
|
| 72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 73 | + 6 => __('Discount updated.', 'invoicing'), |
|
| 74 | + 7 => __('Discount saved.', 'invoicing'), |
|
| 75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
| 76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | $messages['wpi_payment_form'] = array( |
| 81 | 81 | 0 => '', |
| 82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
| 83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
| 86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
| 88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
| 89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
| 90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | return $messages; |
@@ -98,19 +98,19 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Post row actions. |
| 100 | 100 | */ |
| 101 | - public static function post_row_actions( $actions, $post ) { |
|
| 101 | + public static function post_row_actions($actions, $post) { |
|
| 102 | 102 | |
| 103 | - $post = get_post( $post ); |
|
| 103 | + $post = get_post($post); |
|
| 104 | 104 | |
| 105 | 105 | // We do not want to edit the default payment form. |
| 106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 106 | + if ('wpi_payment_form' == $post->post_type) { |
|
| 107 | 107 | |
| 108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | - unset( $actions['trash'] ); |
|
| 110 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 108 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
| 109 | + unset($actions['trash']); |
|
| 110 | + unset($actions['inline hide-if-no-js']); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $actions['duplicate'] = sprintf( |
|
| 113 | + $actions['duplicate'] = sprintf( |
|
| 114 | 114 | '<a href="%1$s">%2$s</a>', |
| 115 | 115 | esc_url( |
| 116 | 116 | wp_nonce_url( |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | 'getpaid-nonce' |
| 125 | 125 | ) |
| 126 | 126 | ), |
| 127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 127 | + esc_html(__('Duplicate', 'invoicing')) |
|
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Link to item payment form. |
| 133 | - if ( 'wpi_item' == $post->post_type ) { |
|
| 133 | + if ('wpi_item' == $post->post_type) { |
|
| 134 | 134 | |
| 135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 135 | + if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) { |
|
| 136 | 136 | |
| 137 | - $actions['buy'] = sprintf( |
|
| 137 | + $actions['buy'] = sprintf( |
|
| 138 | 138 | '<a href="%1$s">%2$s</a>', |
| 139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 139 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
| 140 | + esc_html(__('Buy', 'invoicing')) |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | } |
@@ -155,31 +155,31 @@ discard block |
||
| 155 | 155 | * @param WP_Post $post |
| 156 | 156 | * @return array $actions actions without edit option |
| 157 | 157 | */ |
| 158 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
| 158 | + public static function filter_invoice_row_actions($actions, $post) { |
|
| 159 | 159 | |
| 160 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 160 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
| 161 | 161 | |
| 162 | 162 | $actions = array(); |
| 163 | - $invoice = new WPInv_Invoice( $post ); |
|
| 163 | + $invoice = new WPInv_Invoice($post); |
|
| 164 | 164 | |
| 165 | - $actions['edit'] = sprintf( |
|
| 165 | + $actions['edit'] = sprintf( |
|
| 166 | 166 | '<a href="%1$s">%2$s</a>', |
| 167 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 168 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 167 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
| 168 | + esc_html(__('Edit', 'invoicing')) |
|
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | - if ( ! $invoice->is_draft() ) { |
|
| 171 | + if (!$invoice->is_draft()) { |
|
| 172 | 172 | |
| 173 | - $actions['view'] = sprintf( |
|
| 173 | + $actions['view'] = sprintf( |
|
| 174 | 174 | '<a href="%1$s">%2$s</a>', |
| 175 | - esc_url( $invoice->get_view_url() ), |
|
| 175 | + esc_url($invoice->get_view_url()), |
|
| 176 | 176 | sprintf( |
| 177 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 178 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 177 | + esc_html(__('View %s', 'invoicing')), |
|
| 178 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
| 179 | 179 | ) |
| 180 | 180 | ); |
| 181 | 181 | |
| 182 | - $actions['send'] = sprintf( |
|
| 182 | + $actions['send'] = sprintf( |
|
| 183 | 183 | '<a href="%1$s">%2$s</a>', |
| 184 | 184 | esc_url( |
| 185 | 185 | wp_nonce_url( |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | 'getpaid-nonce' |
| 194 | 194 | ) |
| 195 | 195 | ), |
| 196 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 196 | + esc_html(__('Send to Customer', 'invoicing')) |
|
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $actions['duplicate'] = sprintf( |
|
| 201 | + $actions['duplicate'] = sprintf( |
|
| 202 | 202 | '<a href="%1$s">%2$s</a>', |
| 203 | 203 | esc_url( |
| 204 | 204 | wp_nonce_url( |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | 'getpaid-nonce' |
| 213 | 213 | ) |
| 214 | 214 | ), |
| 215 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 215 | + esc_html(__('Duplicate', 'invoicing')) |
|
| 216 | 216 | ); |
| 217 | 217 | |
| 218 | 218 | } |
@@ -223,42 +223,42 @@ discard block |
||
| 223 | 223 | /** |
| 224 | 224 | * Returns an array of invoice table columns. |
| 225 | 225 | */ |
| 226 | - public static function invoice_columns( $columns ) { |
|
| 226 | + public static function invoice_columns($columns) { |
|
| 227 | 227 | |
| 228 | 228 | $columns = array( |
| 229 | 229 | 'cb' => $columns['cb'], |
| 230 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 231 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 232 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 233 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 234 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 235 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 236 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 230 | + 'number' => __('Invoice', 'invoicing'), |
|
| 231 | + 'customer' => __('Customer', 'invoicing'), |
|
| 232 | + 'invoice_date' => __('Created', 'invoicing'), |
|
| 233 | + 'payment_date' => __('Completed', 'invoicing'), |
|
| 234 | + 'amount' => __('Amount', 'invoicing'), |
|
| 235 | + 'recurring' => __('Recurring', 'invoicing'), |
|
| 236 | + 'status' => __('Status', 'invoicing'), |
|
| 237 | 237 | ); |
| 238 | 238 | |
| 239 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 239 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | 243 | * Displays invoice table columns. |
| 244 | 244 | */ |
| 245 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 245 | + public static function display_invoice_columns($column_name, $post_id) { |
|
| 246 | 246 | |
| 247 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 247 | + $invoice = new WPInv_Invoice($post_id); |
|
| 248 | 248 | |
| 249 | - switch ( $column_name ) { |
|
| 249 | + switch ($column_name) { |
|
| 250 | 250 | |
| 251 | 251 | case 'invoice_date' : |
| 252 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 253 | - $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 252 | + $date_time = esc_attr($invoice->get_created_date()); |
|
| 253 | + $date = esc_html(getpaid_format_date_value($date_time, "—", true)); |
|
| 254 | 254 | echo "<span title='$date_time'>$date</span>"; |
| 255 | 255 | break; |
| 256 | 256 | |
| 257 | 257 | case 'payment_date' : |
| 258 | 258 | |
| 259 | - if ( $invoice->is_paid() ) { |
|
| 260 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 261 | - $date = esc_html( getpaid_format_date_value( $date_time, "—", true ) ); |
|
| 259 | + if ($invoice->is_paid()) { |
|
| 260 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
| 261 | + $date = esc_html(getpaid_format_date_value($date_time, "—", true)); |
|
| 262 | 262 | echo "<span title='$date_time'>$date</span>"; |
| 263 | 263 | } else { |
| 264 | 264 | echo "—"; |
@@ -269,20 +269,20 @@ discard block |
||
| 269 | 269 | case 'amount' : |
| 270 | 270 | |
| 271 | 271 | $amount = $invoice->get_total(); |
| 272 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 272 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
| 273 | 273 | |
| 274 | - if ( $invoice->is_refunded() ) { |
|
| 275 | - $refunded_amount = wp_kses_post( wpinv_price( 0, $invoice->get_currency() ) ); |
|
| 274 | + if ($invoice->is_refunded()) { |
|
| 275 | + $refunded_amount = wp_kses_post(wpinv_price(0, $invoice->get_currency())); |
|
| 276 | 276 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
| 277 | 277 | } else { |
| 278 | 278 | |
| 279 | 279 | $discount = $invoice->get_total_discount(); |
| 280 | 280 | |
| 281 | - if ( ! empty( $discount ) ) { |
|
| 282 | - $new_amount = wp_kses_post( wpinv_price( $amount + $discount, $invoice->get_currency() ) ); |
|
| 281 | + if (!empty($discount)) { |
|
| 282 | + $new_amount = wp_kses_post(wpinv_price($amount + $discount, $invoice->get_currency())); |
|
| 283 | 283 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
| 284 | 284 | } else { |
| 285 | - echo wp_kses_post( $formated_amount ); |
|
| 285 | + echo wp_kses_post($formated_amount); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | } |
@@ -290,13 +290,13 @@ discard block |
||
| 290 | 290 | break; |
| 291 | 291 | |
| 292 | 292 | case 'status' : |
| 293 | - $status = esc_html( $invoice->get_status() ); |
|
| 294 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 293 | + $status = esc_html($invoice->get_status()); |
|
| 294 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
| 295 | 295 | |
| 296 | 296 | // If it is paid, show the gateway title. |
| 297 | - if ( $invoice->is_paid() ) { |
|
| 298 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 299 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 297 | + if ($invoice->is_paid()) { |
|
| 298 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
| 299 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
| 300 | 300 | |
| 301 | 301 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
| 302 | 302 | } else { |
@@ -304,22 +304,22 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | // If it is not paid, display the overdue and view status. |
| 307 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 307 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 308 | 308 | |
| 309 | 309 | // Invoice view status. |
| 310 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 311 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 310 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
| 311 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 312 | 312 | } else { |
| 313 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
| 313 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | // Display the overview status. |
| 317 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 317 | + if (wpinv_get_option('overdue_active')) { |
|
| 318 | 318 | $due_date = $invoice->get_due_date(); |
| 319 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 319 | + $fomatted = getpaid_format_date($due_date); |
|
| 320 | 320 | |
| 321 | - if ( ! empty( $fomatted ) ) { |
|
| 322 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
| 321 | + if (!empty($fomatted)) { |
|
| 322 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
| 323 | 323 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
| 324 | 324 | } |
| 325 | 325 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | case 'recurring': |
| 332 | 332 | |
| 333 | - if ( $invoice->is_recurring() ) { |
|
| 333 | + if ($invoice->is_recurring()) { |
|
| 334 | 334 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
| 335 | 335 | } else { |
| 336 | 336 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -339,9 +339,9 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | case 'number' : |
| 341 | 341 | |
| 342 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 343 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
| 344 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 342 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
| 343 | + $invoice_number = esc_html($invoice->get_number()); |
|
| 344 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
| 345 | 345 | |
| 346 | 346 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
| 347 | 347 | |
@@ -351,13 +351,13 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | $customer_name = $invoice->get_user_full_name(); |
| 353 | 353 | |
| 354 | - if ( empty( $customer_name ) ) { |
|
| 354 | + if (empty($customer_name)) { |
|
| 355 | 355 | $customer_name = $invoice->get_email(); |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - if ( ! empty( $customer_name ) ) { |
|
| 359 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 360 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 358 | + if (!empty($customer_name)) { |
|
| 359 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
| 360 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
| 361 | 361 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
| 362 | 362 | } else { |
| 363 | 363 | echo '<div>—</div>'; |
@@ -372,19 +372,19 @@ discard block |
||
| 372 | 372 | /** |
| 373 | 373 | * Displays invoice bulk actions. |
| 374 | 374 | */ |
| 375 | - public static function invoice_bulk_actions( $actions ) { |
|
| 376 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 375 | + public static function invoice_bulk_actions($actions) { |
|
| 376 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
| 377 | 377 | return $actions; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
| 381 | 381 | * Processes invoice bulk actions. |
| 382 | 382 | */ |
| 383 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 383 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
| 384 | 384 | |
| 385 | - if ( $action == 'resend-invoice' ) { |
|
| 386 | - foreach ( $post_ids as $post_id ) { |
|
| 387 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 385 | + if ($action == 'resend-invoice') { |
|
| 386 | + foreach ($post_ids as $post_id) { |
|
| 387 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
@@ -395,50 +395,50 @@ discard block |
||
| 395 | 395 | /** |
| 396 | 396 | * Returns an array of payment forms table columns. |
| 397 | 397 | */ |
| 398 | - public static function payment_form_columns( $columns ) { |
|
| 398 | + public static function payment_form_columns($columns) { |
|
| 399 | 399 | |
| 400 | 400 | $columns = array( |
| 401 | 401 | 'cb' => $columns['cb'], |
| 402 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 403 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 404 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 405 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 406 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 407 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 402 | + 'title' => __('Name', 'invoicing'), |
|
| 403 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 404 | + 'earnings' => __('Revenue', 'invoicing'), |
|
| 405 | + 'refunds' => __('Refunded', 'invoicing'), |
|
| 406 | + 'items' => __('Items', 'invoicing'), |
|
| 407 | + 'date' => __('Date', 'invoicing'), |
|
| 408 | 408 | ); |
| 409 | 409 | |
| 410 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 410 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
| 411 | 411 | |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
| 415 | 415 | * Displays payment form table columns. |
| 416 | 416 | */ |
| 417 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 417 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
| 418 | 418 | |
| 419 | 419 | // Retrieve the payment form. |
| 420 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 420 | + $form = new GetPaid_Payment_Form($post_id); |
|
| 421 | 421 | |
| 422 | - switch ( $column_name ) { |
|
| 422 | + switch ($column_name) { |
|
| 423 | 423 | |
| 424 | 424 | case 'earnings' : |
| 425 | - echo wpinv_price( $form->get_earned() ); |
|
| 425 | + echo wpinv_price($form->get_earned()); |
|
| 426 | 426 | break; |
| 427 | 427 | |
| 428 | 428 | case 'refunds' : |
| 429 | - echo wpinv_price( $form->get_refunded() ); |
|
| 429 | + echo wpinv_price($form->get_refunded()); |
|
| 430 | 430 | break; |
| 431 | 431 | |
| 432 | 432 | case 'refunds' : |
| 433 | - echo wpinv_price( $form->get_refunded() ); |
|
| 433 | + echo wpinv_price($form->get_refunded()); |
|
| 434 | 434 | break; |
| 435 | 435 | |
| 436 | 436 | case 'shortcode' : |
| 437 | 437 | |
| 438 | - if ( $form->is_default() ) { |
|
| 438 | + if ($form->is_default()) { |
|
| 439 | 439 | echo '—'; |
| 440 | 440 | } else { |
| 441 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 441 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | break; |
@@ -447,29 +447,29 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | $items = $form->get_items(); |
| 449 | 449 | |
| 450 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 450 | + if ($form->is_default() || empty($items)) { |
|
| 451 | 451 | echo '—'; |
| 452 | 452 | return; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | $_items = array(); |
| 456 | 456 | |
| 457 | - foreach ( $items as $item ) { |
|
| 457 | + foreach ($items as $item) { |
|
| 458 | 458 | $url = $item->get_edit_url(); |
| 459 | 459 | |
| 460 | - if ( empty( $url ) ) { |
|
| 461 | - $_items[] = esc_html( $item->get_name() ); |
|
| 460 | + if (empty($url)) { |
|
| 461 | + $_items[] = esc_html($item->get_name()); |
|
| 462 | 462 | } else { |
| 463 | 463 | $_items[] = sprintf( |
| 464 | 464 | '<a href="%s">%s</a>', |
| 465 | - esc_url( $url ), |
|
| 466 | - esc_html( $item->get_name() ) |
|
| 465 | + esc_url($url), |
|
| 466 | + esc_html($item->get_name()) |
|
| 467 | 467 | ); |
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | - echo implode( '<br>', $_items ); |
|
| 472 | + echo implode('<br>', $_items); |
|
| 473 | 473 | |
| 474 | 474 | break; |
| 475 | 475 | |
@@ -480,10 +480,10 @@ discard block |
||
| 480 | 480 | /** |
| 481 | 481 | * Filters post states. |
| 482 | 482 | */ |
| 483 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 483 | + public static function filter_payment_form_state($post_states, $post) { |
|
| 484 | 484 | |
| 485 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
| 486 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
| 485 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
| 486 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | return $post_states; |
@@ -493,35 +493,35 @@ discard block |
||
| 493 | 493 | /** |
| 494 | 494 | * Returns an array of coupon table columns. |
| 495 | 495 | */ |
| 496 | - public static function discount_columns( $columns ) { |
|
| 496 | + public static function discount_columns($columns) { |
|
| 497 | 497 | |
| 498 | 498 | $columns = array( |
| 499 | 499 | 'cb' => $columns['cb'], |
| 500 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 501 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 502 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 503 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 504 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 505 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 500 | + 'title' => __('Name', 'invoicing'), |
|
| 501 | + 'code' => __('Code', 'invoicing'), |
|
| 502 | + 'amount' => __('Amount', 'invoicing'), |
|
| 503 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
| 504 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 505 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
| 506 | 506 | ); |
| 507 | 507 | |
| 508 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 508 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | /** |
| 512 | 512 | * Filters post states. |
| 513 | 513 | */ |
| 514 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 514 | + public static function filter_discount_state($post_states, $post) { |
|
| 515 | 515 | |
| 516 | - if ( 'wpi_discount' == $post->post_type ) { |
|
| 516 | + if ('wpi_discount' == $post->post_type) { |
|
| 517 | 517 | |
| 518 | - $discount = new WPInv_Discount( $post ); |
|
| 518 | + $discount = new WPInv_Discount($post); |
|
| 519 | 519 | |
| 520 | 520 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
| 521 | 521 | |
| 522 | - if ( $status != 'publish' ) { |
|
| 522 | + if ($status != 'publish') { |
|
| 523 | 523 | return array( |
| 524 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 524 | + 'discount_status' => wpinv_discount_status($status), |
|
| 525 | 525 | ); |
| 526 | 526 | } |
| 527 | 527 | |
@@ -536,30 +536,30 @@ discard block |
||
| 536 | 536 | /** |
| 537 | 537 | * Returns an array of items table columns. |
| 538 | 538 | */ |
| 539 | - public static function item_columns( $columns ) { |
|
| 539 | + public static function item_columns($columns) { |
|
| 540 | 540 | |
| 541 | 541 | $columns = array( |
| 542 | 542 | 'cb' => $columns['cb'], |
| 543 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 544 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 545 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
| 546 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
| 547 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 548 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 543 | + 'title' => __('Name', 'invoicing'), |
|
| 544 | + 'price' => __('Price', 'invoicing'), |
|
| 545 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
| 546 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
| 547 | + 'type' => __('Type', 'invoicing'), |
|
| 548 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 549 | 549 | ); |
| 550 | 550 | |
| 551 | - if ( ! wpinv_use_taxes() ) { |
|
| 552 | - unset( $columns['vat_rule'] ); |
|
| 553 | - unset( $columns['vat_class'] ); |
|
| 551 | + if (!wpinv_use_taxes()) { |
|
| 552 | + unset($columns['vat_rule']); |
|
| 553 | + unset($columns['vat_class']); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 556 | + return apply_filters('wpi_item_table_columns', $columns); |
|
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** |
| 560 | 560 | * Returns an array of sortable items table columns. |
| 561 | 561 | */ |
| 562 | - public static function sortable_item_columns( $columns ) { |
|
| 562 | + public static function sortable_item_columns($columns) { |
|
| 563 | 563 | |
| 564 | 564 | return array_merge( |
| 565 | 565 | $columns, |
@@ -576,47 +576,47 @@ discard block |
||
| 576 | 576 | /** |
| 577 | 577 | * Displays items table columns. |
| 578 | 578 | */ |
| 579 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 579 | + public static function display_item_columns($column_name, $post_id) { |
|
| 580 | 580 | |
| 581 | - $item = new WPInv_Item( $post_id ); |
|
| 581 | + $item = new WPInv_Item($post_id); |
|
| 582 | 582 | |
| 583 | - switch ( $column_name ) { |
|
| 583 | + switch ($column_name) { |
|
| 584 | 584 | |
| 585 | 585 | case 'price' : |
| 586 | 586 | |
| 587 | - if ( ! $item->is_recurring() ) { |
|
| 588 | - echo wp_kses_post( $item->get_the_price() ); |
|
| 587 | + if (!$item->is_recurring()) { |
|
| 588 | + echo wp_kses_post($item->get_the_price()); |
|
| 589 | 589 | break; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | $price = wp_sprintf( |
| 593 | - __( '%s / %s', 'invoicing' ), |
|
| 593 | + __('%s / %s', 'invoicing'), |
|
| 594 | 594 | $item->get_the_price(), |
| 595 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 595 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
| 596 | 596 | ); |
| 597 | 597 | |
| 598 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 599 | - echo wp_kses_post( $price ); |
|
| 598 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
| 599 | + echo wp_kses_post($price); |
|
| 600 | 600 | break; |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 603 | + echo wp_kses_post($item->get_the_initial_price()); |
|
| 604 | 604 | |
| 605 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) .'</span>'; |
|
| 605 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
| 606 | 606 | break; |
| 607 | 607 | |
| 608 | 608 | case 'vat_rule' : |
| 609 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
| 609 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
| 610 | 610 | break; |
| 611 | 611 | |
| 612 | 612 | case 'vat_class' : |
| 613 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
| 613 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
| 614 | 614 | break; |
| 615 | 615 | |
| 616 | 616 | case 'shortcode' : |
| 617 | 617 | |
| 618 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 619 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 618 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
| 619 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 620 | 620 | } else { |
| 621 | 621 | echo "—"; |
| 622 | 622 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | break; |
| 625 | 625 | |
| 626 | 626 | case 'type' : |
| 627 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 627 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
| 628 | 628 | break; |
| 629 | 629 | |
| 630 | 630 | } |
@@ -634,21 +634,21 @@ discard block |
||
| 634 | 634 | /** |
| 635 | 635 | * Lets users filter items using taxes. |
| 636 | 636 | */ |
| 637 | - public static function add_item_filters( $post_type ) { |
|
| 637 | + public static function add_item_filters($post_type) { |
|
| 638 | 638 | |
| 639 | 639 | // Abort if we're not dealing with items. |
| 640 | - if ( $post_type != 'wpi_item' ) { |
|
| 640 | + if ($post_type != 'wpi_item') { |
|
| 641 | 641 | return; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | // Filter by vat rules. |
| 645 | - if ( wpinv_use_taxes() ) { |
|
| 645 | + if (wpinv_use_taxes()) { |
|
| 646 | 646 | |
| 647 | 647 | // Sanitize selected vat rule. |
| 648 | 648 | $vat_rule = ''; |
| 649 | 649 | $vat_rules = getpaid_get_tax_rules(); |
| 650 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
| 651 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); |
|
| 650 | + if (isset($_GET['vat_rule'])) { |
|
| 651 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | // Filter by VAT rule. |
@@ -656,13 +656,13 @@ discard block |
||
| 656 | 656 | array( |
| 657 | 657 | 'options' => array_merge( |
| 658 | 658 | array( |
| 659 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
| 659 | + '' => __('All VAT rules', 'invoicing') |
|
| 660 | 660 | ), |
| 661 | 661 | $vat_rules |
| 662 | 662 | ), |
| 663 | 663 | 'name' => 'vat_rule', |
| 664 | 664 | 'id' => 'vat_rule', |
| 665 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
| 665 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
| 666 | 666 | 'show_option_all' => false, |
| 667 | 667 | 'show_option_none' => false, |
| 668 | 668 | ) |
@@ -673,21 +673,21 @@ discard block |
||
| 673 | 673 | // Sanitize selected vat rule. |
| 674 | 674 | $vat_class = ''; |
| 675 | 675 | $vat_classes = getpaid_get_tax_classes(); |
| 676 | - if ( isset( $_GET['vat_class'] ) ) { |
|
| 677 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); |
|
| 676 | + if (isset($_GET['vat_class'])) { |
|
| 677 | + $vat_class = sanitize_text_field($_GET['vat_class']); |
|
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | echo wpinv_html_select( |
| 681 | 681 | array( |
| 682 | 682 | 'options' => array_merge( |
| 683 | 683 | array( |
| 684 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
| 684 | + '' => __('All VAT classes', 'invoicing') |
|
| 685 | 685 | ), |
| 686 | 686 | $vat_classes |
| 687 | 687 | ), |
| 688 | 688 | 'name' => 'vat_class', |
| 689 | 689 | 'id' => 'vat_class', |
| 690 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
| 690 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
| 691 | 691 | 'show_option_all' => false, |
| 692 | 692 | 'show_option_none' => false, |
| 693 | 693 | ) |
@@ -696,22 +696,22 @@ discard block |
||
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | // Filter by item type. |
| 699 | - $type = ''; |
|
| 700 | - if ( isset( $_GET['type'] ) ) { |
|
| 701 | - $type = sanitize_text_field( $_GET['type'] ); |
|
| 699 | + $type = ''; |
|
| 700 | + if (isset($_GET['type'])) { |
|
| 701 | + $type = sanitize_text_field($_GET['type']); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | echo wpinv_html_select( |
| 705 | 705 | array( |
| 706 | 706 | 'options' => array_merge( |
| 707 | 707 | array( |
| 708 | - '' => __( 'All item types', 'invoicing' ) |
|
| 708 | + '' => __('All item types', 'invoicing') |
|
| 709 | 709 | ), |
| 710 | 710 | wpinv_get_item_types() |
| 711 | 711 | ), |
| 712 | 712 | 'name' => 'type', |
| 713 | 713 | 'id' => 'type', |
| 714 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
| 714 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
| 715 | 715 | 'show_option_all' => false, |
| 716 | 716 | 'show_option_none' => false, |
| 717 | 717 | ) |
@@ -722,45 +722,45 @@ discard block |
||
| 722 | 722 | /** |
| 723 | 723 | * Filters the item query. |
| 724 | 724 | */ |
| 725 | - public static function filter_item_query( $query ) { |
|
| 725 | + public static function filter_item_query($query) { |
|
| 726 | 726 | |
| 727 | 727 | // modify the query only if it admin and main query. |
| 728 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
| 728 | + if (!(is_admin() && $query->is_main_query())) { |
|
| 729 | 729 | return $query; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | // we want to modify the query for our items. |
| 733 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
| 733 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
| 734 | 734 | return $query; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 737 | + if (empty($query->query_vars['meta_query'])) { |
|
| 738 | 738 | $query->query_vars['meta_query'] = array(); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // Filter vat rule type |
| 742 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
| 742 | + if (!empty($_GET['vat_rule'])) { |
|
| 743 | 743 | $query->query_vars['meta_query'][] = array( |
| 744 | 744 | 'key' => '_wpinv_vat_rule', |
| 745 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
| 745 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
| 746 | 746 | 'compare' => '=' |
| 747 | 747 | ); |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | // Filter vat class |
| 751 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
| 751 | + if (!empty($_GET['vat_class'])) { |
|
| 752 | 752 | $query->query_vars['meta_query'][] = array( |
| 753 | 753 | 'key' => '_wpinv_vat_class', |
| 754 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
| 754 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
| 755 | 755 | 'compare' => '=' |
| 756 | 756 | ); |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | // Filter item type |
| 760 | - if ( ! empty( $_GET['type'] ) ) { |
|
| 760 | + if (!empty($_GET['type'])) { |
|
| 761 | 761 | $query->query_vars['meta_query'][] = array( |
| 762 | 762 | 'key' => '_wpinv_type', |
| 763 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
| 763 | + 'value' => sanitize_text_field($_GET['type']), |
|
| 764 | 764 | 'compare' => '=' |
| 765 | 765 | ); |
| 766 | 766 | } |
@@ -770,15 +770,15 @@ discard block |
||
| 770 | 770 | /** |
| 771 | 771 | * Reorders items. |
| 772 | 772 | */ |
| 773 | - public static function reorder_items( $vars ) { |
|
| 773 | + public static function reorder_items($vars) { |
|
| 774 | 774 | global $typenow; |
| 775 | 775 | |
| 776 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 776 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
| 777 | 777 | return $vars; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | // By item type. |
| 781 | - if ( 'type' == $vars['orderby'] ) { |
|
| 781 | + if ('type' == $vars['orderby']) { |
|
| 782 | 782 | return array_merge( |
| 783 | 783 | $vars, |
| 784 | 784 | array( |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | // By vat class. |
| 792 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
| 792 | + if ('vat_class' == $vars['orderby']) { |
|
| 793 | 793 | return array_merge( |
| 794 | 794 | $vars, |
| 795 | 795 | array( |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | // By vat rule. |
| 803 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
| 803 | + if ('vat_rule' == $vars['orderby']) { |
|
| 804 | 804 | return array_merge( |
| 805 | 805 | $vars, |
| 806 | 806 | array( |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | // By price. |
| 814 | - if ( 'price' == $vars['orderby'] ) { |
|
| 814 | + if ('price' == $vars['orderby']) { |
|
| 815 | 815 | return array_merge( |
| 816 | 816 | $vars, |
| 817 | 817 | array( |
@@ -828,27 +828,27 @@ discard block |
||
| 828 | 828 | /** |
| 829 | 829 | * Fired when deleting a post. |
| 830 | 830 | */ |
| 831 | - public static function delete_post( $post_id ) { |
|
| 831 | + public static function delete_post($post_id) { |
|
| 832 | 832 | |
| 833 | - switch ( get_post_type( $post_id ) ) { |
|
| 833 | + switch (get_post_type($post_id)) { |
|
| 834 | 834 | |
| 835 | 835 | case 'wpi_item' : |
| 836 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
| 836 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
| 837 | 837 | break; |
| 838 | 838 | |
| 839 | 839 | case 'wpi_payment_form' : |
| 840 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
| 840 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
| 841 | 841 | break; |
| 842 | 842 | |
| 843 | 843 | case 'wpi_discount' : |
| 844 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
| 844 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
| 845 | 845 | break; |
| 846 | 846 | |
| 847 | 847 | case 'wpi_invoice' : |
| 848 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 849 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
| 850 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 851 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 848 | + $invoice = new WPInv_Invoice($post_id); |
|
| 849 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
| 850 | + $invoice->get_data_store()->delete_items($invoice); |
|
| 851 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
| 852 | 852 | break; |
| 853 | 853 | } |
| 854 | 854 | } |
@@ -861,29 +861,29 @@ discard block |
||
| 861 | 861 | * |
| 862 | 862 | * @return mixed |
| 863 | 863 | */ |
| 864 | - public static function add_display_post_states( $post_states, $post ) { |
|
| 864 | + public static function add_display_post_states($post_states, $post) { |
|
| 865 | 865 | |
| 866 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
| 867 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
| 866 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
| 867 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 870 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
| 871 | 871 | |
| 872 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 872 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
| 873 | 873 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
| 874 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 874 | + __('GetPaid %s History Page', 'invoicing'), |
|
| 875 | 875 | $label |
| 876 | 876 | ); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 882 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
| 881 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
| 882 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 886 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
| 885 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
| 886 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | return $post_states; |