@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,7 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if ( !defined('ABSPATH') ) { |
|
| 4 | 4 | die('-1'); |
| 5 | +} |
|
| 5 | 6 | |
| 6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
| 7 | 8 | |
@@ -1,18 +1,18 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // don't load directly |
| 3 | -if ( !defined('ABSPATH') ) |
|
| 3 | +if (!defined('ABSPATH')) |
|
| 4 | 4 | die('-1'); |
| 5 | 5 | |
| 6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 7 | 7 | |
| 8 | -if ( ! empty( $message_body ) ) { |
|
| 9 | - echo wpautop( wptexturize( $message_body ) ); |
|
| 8 | +if (!empty($message_body)) { |
|
| 9 | + echo wpautop(wptexturize($message_body)); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin ); |
|
| 12 | +do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin); |
|
| 13 | 13 | |
| 14 | -do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin ); |
|
| 14 | +do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin); |
|
| 15 | 15 | |
| 16 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 19 | 18 | \ No newline at end of file |
| 19 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
| 20 | 20 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
| 6 | 8 | if ( empty( $user ) ) { |
@@ -159,11 +159,11 @@ |
||
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | - return 'manage_options'; |
|
| 164 | - }; |
|
| 162 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 163 | + return 'manage_options'; |
|
| 164 | + }; |
|
| 165 | 165 | |
| 166 | - return $capalibilty; |
|
| 166 | + return $capalibilty; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | -function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) { |
|
| 6 | - if ( empty( $user ) ) { |
|
| 5 | +function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC') { |
|
| 6 | + if (empty($user)) { |
|
| 7 | 7 | $user = get_current_user_id(); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | - if ( empty( $user ) ) { |
|
| 10 | + if (empty($user)) { |
|
| 11 | 11 | return false; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | - $args = apply_filters( 'wpinv_get_users_invoices_args', array( 'user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order ) ); |
|
| 14 | + $args = apply_filters('wpinv_get_users_invoices_args', array('user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order)); |
|
| 15 | 15 | |
| 16 | - return wpinv_get_invoices( $args ); |
|
| 16 | + return wpinv_get_invoices($args); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 19 | +function wpinv_dropdown_users($args = '') { |
|
| 20 | 20 | $defaults = array( |
| 21 | 21 | 'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '', |
| 22 | 22 | 'orderby' => 'display_name', 'order' => 'ASC', |
@@ -27,18 +27,18 @@ discard block |
||
| 27 | 27 | 'option_none_value' => -1 |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0; |
|
| 30 | + $defaults['selected'] = is_author() ? get_query_var('author') : 0; |
|
| 31 | 31 | |
| 32 | - $r = wp_parse_args( $args, $defaults ); |
|
| 32 | + $r = wp_parse_args($args, $defaults); |
|
| 33 | 33 | |
| 34 | - $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) ); |
|
| 34 | + $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who')); |
|
| 35 | 35 | |
| 36 | - $fields = array( 'ID', 'user_login', 'user_email' ); |
|
| 36 | + $fields = array('ID', 'user_login', 'user_email'); |
|
| 37 | 37 | |
| 38 | - $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name'; |
|
| 39 | - if ( 'display_name_with_login' === $show ) { |
|
| 38 | + $show = !empty($r['show']) ? $r['show'] : 'display_name'; |
|
| 39 | + if ('display_name_with_login' === $show) { |
|
| 40 | 40 | $fields[] = 'display_name'; |
| 41 | - } else if ( 'display_name_with_email' === $show ) { |
|
| 41 | + } else if ('display_name_with_email' === $show) { |
|
| 42 | 42 | $fields[] = 'display_name'; |
| 43 | 43 | } else { |
| 44 | 44 | $fields[] = $show; |
@@ -50,99 +50,99 @@ discard block |
||
| 50 | 50 | $show_option_none = $r['show_option_none']; |
| 51 | 51 | $option_none_value = $r['option_none_value']; |
| 52 | 52 | |
| 53 | - $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r ); |
|
| 53 | + $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r); |
|
| 54 | 54 | |
| 55 | - $users = get_users( $query_args ); |
|
| 55 | + $users = get_users($query_args); |
|
| 56 | 56 | |
| 57 | 57 | $output = ''; |
| 58 | - if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) { |
|
| 59 | - $name = esc_attr( $r['name'] ); |
|
| 60 | - if ( $r['multi'] && ! $r['id'] ) { |
|
| 58 | + if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) { |
|
| 59 | + $name = esc_attr($r['name']); |
|
| 60 | + if ($r['multi'] && !$r['id']) { |
|
| 61 | 61 | $id = ''; |
| 62 | 62 | } else { |
| 63 | - $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'"; |
|
| 63 | + $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'"; |
|
| 64 | 64 | } |
| 65 | 65 | $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n"; |
| 66 | 66 | |
| 67 | - if ( $show_option_all ) { |
|
| 67 | + if ($show_option_all) { |
|
| 68 | 68 | $output .= "\t<option value='0'>$show_option_all</option>\n"; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if ( $show_option_none ) { |
|
| 72 | - $_selected = selected( $option_none_value, $r['selected'], false ); |
|
| 73 | - $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n"; |
|
| 71 | + if ($show_option_none) { |
|
| 72 | + $_selected = selected($option_none_value, $r['selected'], false); |
|
| 73 | + $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n"; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) { |
|
| 76 | + if ($r['include_selected'] && ($r['selected'] > 0)) { |
|
| 77 | 77 | $found_selected = false; |
| 78 | 78 | $r['selected'] = (int) $r['selected']; |
| 79 | - foreach ( (array) $users as $user ) { |
|
| 79 | + foreach ((array) $users as $user) { |
|
| 80 | 80 | $user->ID = (int) $user->ID; |
| 81 | - if ( $user->ID === $r['selected'] ) { |
|
| 81 | + if ($user->ID === $r['selected']) { |
|
| 82 | 82 | $found_selected = true; |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( ! $found_selected ) { |
|
| 87 | - $users[] = get_userdata( $r['selected'] ); |
|
| 86 | + if (!$found_selected) { |
|
| 87 | + $users[] = get_userdata($r['selected']); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - foreach ( (array) $users as $user ) { |
|
| 92 | - if ( 'display_name_with_login' === $show ) { |
|
| 91 | + foreach ((array) $users as $user) { |
|
| 92 | + if ('display_name_with_login' === $show) { |
|
| 93 | 93 | /* translators: 1: display name, 2: user_login */ |
| 94 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login ); |
|
| 95 | - } elseif ( 'display_name_with_email' === $show ) { |
|
| 94 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login); |
|
| 95 | + } elseif ('display_name_with_email' === $show) { |
|
| 96 | 96 | /* translators: 1: display name, 2: user_email */ |
| 97 | - if ( $user->display_name == $user->user_email ) { |
|
| 97 | + if ($user->display_name == $user->user_email) { |
|
| 98 | 98 | $display = $user->display_name; |
| 99 | 99 | } else { |
| 100 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email ); |
|
| 100 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email); |
|
| 101 | 101 | } |
| 102 | - } elseif ( ! empty( $user->$show ) ) { |
|
| 102 | + } elseif (!empty($user->$show)) { |
|
| 103 | 103 | $display = $user->$show; |
| 104 | 104 | } else { |
| 105 | 105 | $display = '(' . $user->user_login . ')'; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - $_selected = selected( $user->ID, $r['selected'], false ); |
|
| 109 | - $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n"; |
|
| 108 | + $_selected = selected($user->ID, $r['selected'], false); |
|
| 109 | + $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n"; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $output .= "</select>"; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $html = apply_filters( 'wpinv_dropdown_users', $output ); |
|
| 115 | + $html = apply_filters('wpinv_dropdown_users', $output); |
|
| 116 | 116 | |
| 117 | - if ( $r['echo'] ) { |
|
| 117 | + if ($r['echo']) { |
|
| 118 | 118 | echo $html; |
| 119 | 119 | } |
| 120 | 120 | return $html; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | -function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) { |
|
| 124 | - if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) { |
|
| 125 | - wpinv_login_user( $user_id ); |
|
| 123 | +function wpinv_guest_redirect($redirect_to, $user_id = 0) { |
|
| 124 | + if ((int) wpinv_get_option('guest_checkout') && $user_id > 0) { |
|
| 125 | + wpinv_login_user($user_id); |
|
| 126 | 126 | } else { |
| 127 | - $redirect_to = wp_login_url( $redirect_to ); |
|
| 127 | + $redirect_to = wp_login_url($redirect_to); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id ); |
|
| 130 | + $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id); |
|
| 131 | 131 | |
| 132 | - wp_redirect( $redirect_to ); |
|
| 132 | + wp_redirect($redirect_to); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -function wpinv_login_user( $user_id ) { |
|
| 136 | - if ( is_user_logged_in() ) { |
|
| 135 | +function wpinv_login_user($user_id) { |
|
| 136 | + if (is_user_logged_in()) { |
|
| 137 | 137 | return true; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - $user = get_user_by( 'id', $user_id ); |
|
| 140 | + $user = get_user_by('id', $user_id); |
|
| 141 | 141 | |
| 142 | - if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) { |
|
| 143 | - wp_set_current_user( $user_id, $user->user_login ); |
|
| 144 | - wp_set_auth_cookie( $user_id ); |
|
| 145 | - do_action( 'wp_login', $user->user_login ); |
|
| 142 | + if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) { |
|
| 143 | + wp_set_current_user($user_id, $user->user_login); |
|
| 144 | + wp_set_auth_cookie($user_id); |
|
| 145 | + do_action('wp_login', $user->user_login); |
|
| 146 | 146 | |
| 147 | 147 | return true; |
| 148 | 148 | } |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | * @return string capability to check against |
| 158 | 158 | * @param string $capalibilty Optional. The alternative capability to check against. |
| 159 | 159 | */ |
| 160 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
| 160 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
| 161 | 161 | |
| 162 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 162 | + if (current_user_can('manage_options')) { |
|
| 163 | 163 | return 'manage_options'; |
| 164 | 164 | }; |
| 165 | 165 | |
@@ -173,5 +173,5 @@ discard block |
||
| 173 | 173 | * @return bool |
| 174 | 174 | */ |
| 175 | 175 | function wpinv_current_user_can_manage_invoicing() { |
| 176 | - return current_user_can( wpinv_get_capability() ); |
|
| 176 | + return current_user_can(wpinv_get_capability()); |
|
| 177 | 177 | } |
| 178 | 178 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | * Hook in methods. |
| 15 | 15 | */ |
| 16 | 16 | public static function init() { |
| 17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
| 18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
| 17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
| 18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | public static function init_hooks() { |
| 22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
| 23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
| 24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
| 25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
| 26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
| 27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
| 28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
| 22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
| 23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
| 24 | + $success_page = wpinv_get_option('success_page', ''); |
|
| 25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
| 26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
| 27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
| 28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
| 39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
| 40 | 40 | |
| 41 | 41 | // Exclude permalinks |
| 42 | - $checkout_page = get_post( $checkout_page ); |
|
| 43 | - $success_page = get_post( $success_page ); |
|
| 44 | - $failure_page = get_post( $failure_page ); |
|
| 45 | - $history_page = get_post( $history_page ); |
|
| 46 | - $subscr_page = get_post( $subscr_page ); |
|
| 42 | + $checkout_page = get_post($checkout_page); |
|
| 43 | + $success_page = get_post($success_page); |
|
| 44 | + $failure_page = get_post($failure_page); |
|
| 45 | + $history_page = get_post($history_page); |
|
| 46 | + $subscr_page = get_post($subscr_page); |
|
| 47 | 47 | |
| 48 | - if ( ! is_null( $checkout_page ) ) { |
|
| 48 | + if (!is_null($checkout_page)) { |
|
| 49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
| 50 | 50 | } |
| 51 | - if ( ! is_null( $success_page ) ) { |
|
| 51 | + if (!is_null($success_page)) { |
|
| 52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
| 53 | 53 | } |
| 54 | - if ( ! is_null( $failure_page ) ) { |
|
| 54 | + if (!is_null($failure_page)) { |
|
| 55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
| 56 | 56 | } |
| 57 | - if ( ! is_null( $history_page ) ) { |
|
| 57 | + if (!is_null($history_page)) { |
|
| 58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
| 59 | 59 | } |
| 60 | - if ( ! is_null( $subscr_page ) ) { |
|
| 60 | + if (!is_null($subscr_page)) { |
|
| 61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
| 64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if ( is_array( $page_uris ) ) { |
|
| 68 | - foreach( $page_uris as $uri ) { |
|
| 69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
| 67 | + if (is_array($page_uris)) { |
|
| 68 | + foreach ($page_uris as $uri) { |
|
| 69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
| 70 | 70 | self::nocache(); |
| 71 | 71 | break; |
| 72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * @access private |
| 80 | 80 | */ |
| 81 | 81 | private static function nocache() { |
| 82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
| 83 | - define( "DONOTCACHEPAGE", true ); |
|
| 82 | + if (!defined('DONOTCACHEPAGE')) { |
|
| 83 | + define("DONOTCACHEPAGE", true); |
|
| 84 | 84 | } |
| 85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
| 86 | - define( "DONOTCACHEOBJECT", true ); |
|
| 85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
| 86 | + define("DONOTCACHEOBJECT", true); |
|
| 87 | 87 | } |
| 88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
| 89 | - define( "DONOTCACHEDB", true ); |
|
| 88 | + if (!defined('DONOTCACHEDB')) { |
|
| 89 | + define("DONOTCACHEDB", true); |
|
| 90 | 90 | } |
| 91 | 91 | nocache_headers(); |
| 92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
| 95 | 95 | * notices function. |
| 96 | 96 | */ |
| 97 | 97 | public static function notices() { |
| 98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
| 98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
| 99 | 99 | return; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $config = w3_instance( 'W3_Config' ); |
|
| 103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
| 104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
| 102 | + $config = w3_instance('W3_Config'); |
|
| 103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
| 104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
| 105 | 105 | |
| 106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
| 106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
| 107 | 107 | ?> |
| 108 | 108 | <div class="error"> |
| 109 | - <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p> |
|
| 109 | + <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p> |
|
| 110 | 110 | </div> |
| 111 | 111 | <?php |
| 112 | 112 | } |
@@ -180,8 +180,11 @@ discard block |
||
| 180 | 180 | <label for="tablecell"> |
| 181 | 181 | <?php if( 'trialling' == $sub->status ) : ?> |
| 182 | 182 | <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
| 183 | - <?php else: ?> |
|
| 184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
| 183 | + <?php else { |
|
| 184 | + : ?> |
|
| 185 | + <?php _e( 'Expiration Date:', 'invoicing' ); |
|
| 186 | +} |
|
| 187 | +?> |
|
| 185 | 188 | <?php endif; ?> |
| 186 | 189 | </label> |
| 187 | 190 | </td> |
@@ -251,7 +254,10 @@ discard block |
||
| 251 | 254 | </thead> |
| 252 | 255 | <tbody> |
| 253 | 256 | <?php if ( ! empty( $payments ) ) : ?> |
| 254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
| 257 | + <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) { |
|
| 258 | + continue; |
|
| 259 | +} |
|
| 260 | +?> |
|
| 255 | 261 | <tr> |
| 256 | 262 | <td><?php echo $payment->ID; ?></td> |
| 257 | 263 | <td><?php echo $invoice->get_total( true ); ?></td> |
@@ -268,9 +274,12 @@ discard block |
||
| 268 | 274 | </td> |
| 269 | 275 | </tr> |
| 270 | 276 | <?php endforeach; ?> |
| 271 | - <?php else: ?> |
|
| 277 | + <?php else { |
|
| 278 | + : ?> |
|
| 272 | 279 | <tr> |
| 273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
| 280 | + <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); |
|
| 281 | +} |
|
| 282 | +?></td> |
|
| 274 | 283 | </tr> |
| 275 | 284 | <?php endif; ?> |
| 276 | 285 | </tbody> |
@@ -8,23 +8,23 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function wpinv_subscriptions_page() { |
| 10 | 10 | |
| 11 | - if ( ! empty( $_GET['id'] ) ) { |
|
| 11 | + if ( ! empty( $_GET['id'] ) ) { |
|
| 12 | 12 | |
| 13 | 13 | wpinv_recurring_subscription_details(); |
| 14 | 14 | |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | |
| 17 | - } |
|
| 18 | - ?> |
|
| 17 | + } |
|
| 18 | + ?> |
|
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | |
| 21 | 21 | <h1> |
| 22 | 22 | <?php _e( 'Subscriptions', 'invoicing' ); ?> |
| 23 | 23 | </h1> |
| 24 | 24 | <?php |
| 25 | - $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
| 26 | - $subscribers_table->prepare_items(); |
|
| 27 | - ?> |
|
| 25 | + $subscribers_table = new WPInv_Subscription_Reports_Table(); |
|
| 26 | + $subscribers_table->prepare_items(); |
|
| 27 | + ?> |
|
| 28 | 28 | |
| 29 | 29 | <form id="subscribers-filter" method="get"> |
| 30 | 30 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function wpinv_recurring_subscription_details() { |
| 49 | 49 | |
| 50 | - $render = true; |
|
| 50 | + $render = true; |
|
| 51 | 51 | |
| 52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 54 | - } |
|
| 52 | + if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | + die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 56 | + if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 57 | 57 | die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $sub_id = (int) $_GET['id']; |
|
| 61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
| 60 | + $sub_id = (int) $_GET['id']; |
|
| 61 | + $sub = new WPInv_Subscription( $sub_id ); |
|
| 62 | 62 | |
| 63 | - if ( empty( $sub ) ) { |
|
| 64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 65 | - } |
|
| 63 | + if ( empty( $sub ) ) { |
|
| 64 | + die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - ?> |
|
| 67 | + ?> |
|
| 68 | 68 | <div class="wrap"> |
| 69 | 69 | <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
| 70 | 70 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | </td> |
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 95 | - ?> |
|
| 91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | + $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | + $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | + printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 95 | + ?> |
|
| 96 | 96 | </td> |
| 97 | 97 | </tr> |
| 98 | 98 | <tr> |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | ?> |
| 136 | 136 | <a href="<?php echo esc_url( add_query_arg( array( |
| 137 | - 'post' => $sub->product_id, |
|
| 138 | - 'action' => 'edit' |
|
| 139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 137 | + 'post' => $sub->product_id, |
|
| 138 | + 'action' => 'edit' |
|
| 139 | + ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 140 | 140 | </td> |
| 141 | 141 | </tr> |
| 142 | 142 | <tr> |
@@ -299,56 +299,56 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function wpinv_recurring_process_subscription_update() { |
| 301 | 301 | |
| 302 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 303 | - return; |
|
| 304 | - } |
|
| 302 | + if( empty( $_POST['sub_id'] ) ) { |
|
| 303 | + return; |
|
| 304 | + } |
|
| 305 | 305 | |
| 306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 307 | - return; |
|
| 308 | - } |
|
| 306 | + if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 307 | + return; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 311 | - return; |
|
| 312 | - } |
|
| 310 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
| 311 | + return; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 316 | - } |
|
| 314 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 320 | - $product_id = absint( $_POST['product_id'] ); |
|
| 321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 322 | - $subscription->update( array( |
|
| 323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 324 | - 'profile_id' => $profile_id, |
|
| 325 | - 'product_id' => $product_id, |
|
| 326 | - 'transaction_id' => $transaction_id, |
|
| 327 | - ) ); |
|
| 318 | + $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 319 | + $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 320 | + $product_id = absint( $_POST['product_id'] ); |
|
| 321 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 322 | + $subscription->update( array( |
|
| 323 | + 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 324 | + 'profile_id' => $profile_id, |
|
| 325 | + 'product_id' => $product_id, |
|
| 326 | + 'transaction_id' => $transaction_id, |
|
| 327 | + ) ); |
|
| 328 | 328 | |
| 329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
| 329 | + $status = sanitize_text_field( $_POST['status'] ); |
|
| 330 | 330 | |
| 331 | - switch( $status ) { |
|
| 331 | + switch( $status ) { |
|
| 332 | 332 | |
| 333 | - case 'cancelled' : |
|
| 333 | + case 'cancelled' : |
|
| 334 | 334 | |
| 335 | - $subscription->cancel(); |
|
| 336 | - break; |
|
| 335 | + $subscription->cancel(); |
|
| 336 | + break; |
|
| 337 | 337 | |
| 338 | - case 'expired' : |
|
| 338 | + case 'expired' : |
|
| 339 | 339 | |
| 340 | - $subscription->expire(); |
|
| 341 | - break; |
|
| 340 | + $subscription->expire(); |
|
| 341 | + break; |
|
| 342 | 342 | |
| 343 | - case 'completed' : |
|
| 343 | + case 'completed' : |
|
| 344 | 344 | |
| 345 | - $subscription->complete(); |
|
| 346 | - break; |
|
| 345 | + $subscription->complete(); |
|
| 346 | + break; |
|
| 347 | 347 | |
| 348 | - } |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 351 | - exit; |
|
| 350 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 351 | + exit; |
|
| 352 | 352 | |
| 353 | 353 | } |
| 354 | 354 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
@@ -362,30 +362,30 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
| 364 | 364 | |
| 365 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 366 | - return; |
|
| 367 | - } |
|
| 365 | + if( empty( $_POST['sub_id'] ) ) { |
|
| 366 | + return; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 370 | - return; |
|
| 371 | - } |
|
| 369 | + if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 370 | + return; |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 374 | - return; |
|
| 375 | - } |
|
| 373 | + if( ! current_user_can( 'manage_invoicing') ) { |
|
| 374 | + return; |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 379 | - } |
|
| 377 | + if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 378 | + wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 381 | + $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 382 | 382 | |
| 383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 383 | + delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 384 | 384 | |
| 385 | - $subscription->delete(); |
|
| 385 | + $subscription->delete(); |
|
| 386 | 386 | |
| 387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 388 | - exit; |
|
| 387 | + wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 388 | + exit; |
|
| 389 | 389 | |
| 390 | 390 | } |
| 391 | 391 | add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function wpinv_subscriptions_page() { |
| 10 | 10 | |
| 11 | - if ( ! empty( $_GET['id'] ) ) { |
|
| 11 | + if (!empty($_GET['id'])) { |
|
| 12 | 12 | |
| 13 | 13 | wpinv_recurring_subscription_details(); |
| 14 | 14 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | |
| 21 | 21 | <h1> |
| 22 | - <?php _e( 'Subscriptions', 'invoicing' ); ?> |
|
| 22 | + <?php _e('Subscriptions', 'invoicing'); ?> |
|
| 23 | 23 | </h1> |
| 24 | 24 | <?php |
| 25 | 25 | $subscribers_table = new WPInv_Subscription_Reports_Table(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | <input type="hidden" name="post_type" value="download" /> |
| 32 | 32 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 33 | 33 | <?php $subscribers_table->views(); ?> |
| 34 | - <?php $subscribers_table->search_box( __( 'Search', 'wpinvoicing' ), 'subscriptions' ); ?> |
|
| 34 | + <?php $subscribers_table->search_box(__('Search', 'wpinvoicing'), 'subscriptions'); ?> |
|
| 35 | 35 | <?php $subscribers_table->display(); ?> |
| 36 | 36 | |
| 37 | 37 | </form> |
@@ -49,34 +49,34 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $render = true; |
| 51 | 51 | |
| 52 | - if ( ! current_user_can( 'manage_invoicing' ) ) { |
|
| 53 | - die( __( 'You are not permitted to view this data.', 'invoicing' ) ); |
|
| 52 | + if (!current_user_can('manage_invoicing')) { |
|
| 53 | + die(__('You are not permitted to view this data.', 'invoicing')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 57 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 56 | + if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { |
|
| 57 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $sub_id = (int) $_GET['id']; |
| 61 | - $sub = new WPInv_Subscription( $sub_id ); |
|
| 61 | + $sub = new WPInv_Subscription($sub_id); |
|
| 62 | 62 | |
| 63 | - if ( empty( $sub ) ) { |
|
| 64 | - die( __( 'Invalid subscription ID Provided.', 'invoicing' ) ); |
|
| 63 | + if (empty($sub)) { |
|
| 64 | + die(__('Invalid subscription ID Provided.', 'invoicing')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | ?> |
| 68 | 68 | <div class="wrap"> |
| 69 | - <h2><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
| 69 | + <h2><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
| 70 | 70 | |
| 71 | - <?php if ( $sub ) : ?> |
|
| 71 | + <?php if ($sub) : ?> |
|
| 72 | 72 | |
| 73 | 73 | <div id="wpinv-item-card-wrapper"> |
| 74 | 74 | |
| 75 | - <?php do_action( 'wpinv_subscription_card_top', $sub ); ?> |
|
| 75 | + <?php do_action('wpinv_subscription_card_top', $sub); ?> |
|
| 76 | 76 | |
| 77 | 77 | <div class="info-wrapper item-section"> |
| 78 | 78 | |
| 79 | - <form id="edit-item-info" method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $sub->id ); ?>"> |
|
| 79 | + <form id="edit-item-info" method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . $sub->id); ?>"> |
|
| 80 | 80 | |
| 81 | 81 | <div class="item-info"> |
| 82 | 82 | |
@@ -84,124 +84,124 @@ discard block |
||
| 84 | 84 | <tbody> |
| 85 | 85 | <tr> |
| 86 | 86 | <td class="row-title"> |
| 87 | - <label for="tablecell"><?php _e( 'Billing Cycle:', 'invoicing' ); ?></label> |
|
| 87 | + <label for="tablecell"><?php _e('Billing Cycle:', 'invoicing'); ?></label> |
|
| 88 | 88 | </td> |
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | - $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $sub->period, $sub->frequency ); |
|
| 92 | - $billing = wpinv_price( wpinv_format_amount( $sub->recurring_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ) . ' / ' . $frequency; |
|
| 93 | - $initial = wpinv_price( wpinv_format_amount( $sub->initial_amount ), wpinv_get_invoice_currency_code( $sub->parent_payment_id ) ); |
|
| 94 | - printf( _x( '%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing' ), $initial, $billing ); |
|
| 91 | + $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($sub->period, $sub->frequency); |
|
| 92 | + $billing = wpinv_price(wpinv_format_amount($sub->recurring_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)) . ' / ' . $frequency; |
|
| 93 | + $initial = wpinv_price(wpinv_format_amount($sub->initial_amount), wpinv_get_invoice_currency_code($sub->parent_payment_id)); |
|
| 94 | + printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); |
|
| 95 | 95 | ?> |
| 96 | 96 | </td> |
| 97 | 97 | </tr> |
| 98 | 98 | <tr> |
| 99 | 99 | <td class="row-title"> |
| 100 | - <label for="tablecell"><?php _e( 'Times Billed:', 'invoicing' ); ?></label> |
|
| 100 | + <label for="tablecell"><?php _e('Times Billed:', 'invoicing'); ?></label> |
|
| 101 | 101 | </td> |
| 102 | - <td><?php echo $sub->get_times_billed() . ' / ' . ( ( $sub->bill_times == 0 ) ? 'Until Cancelled' : $sub->bill_times ); ?></td> |
|
| 102 | + <td><?php echo $sub->get_times_billed() . ' / ' . (($sub->bill_times == 0) ? 'Until Cancelled' : $sub->bill_times); ?></td> |
|
| 103 | 103 | </tr> |
| 104 | 104 | <tr> |
| 105 | 105 | <td class="row-title"> |
| 106 | - <label for="tablecell"><?php _e( 'Customer:', 'invoicing' ); ?></label> |
|
| 106 | + <label for="tablecell"><?php _e('Customer:', 'invoicing'); ?></label> |
|
| 107 | 107 | </td> |
| 108 | 108 | <td> |
| 109 | - <?php $subscriber = get_userdata( $sub->customer_id ); ?> |
|
| 110 | - <a href="<?php echo esc_url( get_edit_user_link( $sub->customer_id ) ); ?>" target="_blank"><?php echo ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 109 | + <?php $subscriber = get_userdata($sub->customer_id); ?> |
|
| 110 | + <a href="<?php echo esc_url(get_edit_user_link($sub->customer_id)); ?>" target="_blank"><?php echo !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; ?></a> |
|
| 111 | 111 | </td> |
| 112 | 112 | </tr> |
| 113 | 113 | <tr> |
| 114 | 114 | <td class="row-title"> |
| 115 | - <label for="tablecell"><?php _e( 'Initial Invoice:', 'invoicing' ); ?></label> |
|
| 115 | + <label for="tablecell"><?php _e('Initial Invoice:', 'invoicing'); ?></label> |
|
| 116 | 116 | </td> |
| 117 | 117 | <td> |
| 118 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $sub->parent_payment_id ) ); ?>"><?php echo wpinv_get_invoice_number( $sub->parent_payment_id ); ?></a> <?php echo wp_sprintf( __( '( ID: %s )', 'invoicing' ), '<a title="' . esc_attr( __( 'View invoice details', 'invoicing' ) ) . '" href="' . get_edit_post_link( $sub->parent_payment_id ) . '" target="_blank">' . $sub->parent_payment_id . '</a>' ); ?></td> |
|
| 118 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($sub->parent_payment_id)); ?>"><?php echo wpinv_get_invoice_number($sub->parent_payment_id); ?></a> <?php echo wp_sprintf(__('( ID: %s )', 'invoicing'), '<a title="' . esc_attr(__('View invoice details', 'invoicing')) . '" href="' . get_edit_post_link($sub->parent_payment_id) . '" target="_blank">' . $sub->parent_payment_id . '</a>'); ?></td> |
|
| 119 | 119 | </tr> |
| 120 | 120 | <tr> |
| 121 | 121 | <td class="row-title"> |
| 122 | - <label for="tablecell"><?php _e( 'Item:', 'invoicing' ); ?></label> |
|
| 122 | + <label for="tablecell"><?php _e('Item:', 'invoicing'); ?></label> |
|
| 123 | 123 | </td> |
| 124 | 124 | <td> |
| 125 | 125 | <?php |
| 126 | - echo wpinv_item_dropdown( array( |
|
| 126 | + echo wpinv_item_dropdown(array( |
|
| 127 | 127 | 'name' => 'product_id', |
| 128 | 128 | 'id' => 'wpinv_invoice_item', |
| 129 | 129 | 'with_packages' => false, |
| 130 | 130 | 'show_recurring' => true, |
| 131 | 131 | 'selected' => $sub->product_id, |
| 132 | 132 | 'class' => 'wpinv-sub-product-id wpi_select2', |
| 133 | - ) ); |
|
| 133 | + )); |
|
| 134 | 134 | |
| 135 | 135 | ?> |
| 136 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 136 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 137 | 137 | 'post' => $sub->product_id, |
| 138 | 138 | 'action' => 'edit' |
| 139 | - ), admin_url( 'post.php' ) ) ); ?>" target="_blank"><?php _e( 'View Item', 'invoicing' ) ; ?></a> |
|
| 139 | + ), admin_url('post.php'))); ?>" target="_blank"><?php _e('View Item', 'invoicing'); ?></a> |
|
| 140 | 140 | </td> |
| 141 | 141 | </tr> |
| 142 | 142 | <tr> |
| 143 | 143 | <td class="row-title"> |
| 144 | - <label for="tablecell"><?php _e( 'Payment Method:', 'invoicing' ); ?></label> |
|
| 144 | + <label for="tablecell"><?php _e('Payment Method:', 'invoicing'); ?></label> |
|
| 145 | 145 | </td> |
| 146 | - <td><?php echo wpinv_get_gateway_admin_label( wpinv_get_payment_gateway( $sub->parent_payment_id ) ); ?></td> |
|
| 146 | + <td><?php echo wpinv_get_gateway_admin_label(wpinv_get_payment_gateway($sub->parent_payment_id)); ?></td> |
|
| 147 | 147 | </tr> |
| 148 | 148 | <tr> |
| 149 | 149 | <td class="row-title"> |
| 150 | - <label for="tablecell"><?php _e( 'Profile ID:', 'invoicing' ); ?></label> |
|
| 150 | + <label for="tablecell"><?php _e('Profile ID:', 'invoicing'); ?></label> |
|
| 151 | 151 | </td> |
| 152 | 152 | <td> |
| 153 | 153 | <span class="wpinv-sub-profile-id"> |
| 154 | - <?php echo apply_filters( 'wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub ); ?> |
|
| 154 | + <?php echo apply_filters('wpinv_subscription_profile_link_' . $sub->gateway, $sub->profile_id, $sub); ?> |
|
| 155 | 155 | </span> |
| 156 | - <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr( $sub->profile_id ); ?>" /> |
|
| 156 | + <input type="text" name="profile_id" class="hidden wpinv-sub-profile-id" value="<?php echo esc_attr($sub->profile_id); ?>" /> |
|
| 157 | 157 | <span> – </span> |
| 158 | - <a href="#" class="wpinv-edit-sub-profile-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 158 | + <a href="#" class="wpinv-edit-sub-profile-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 159 | 159 | </td> |
| 160 | 160 | </tr> |
| 161 | 161 | <tr> |
| 162 | 162 | <td class="row-title"> |
| 163 | - <label for="tablecell"><?php _e( 'Transaction ID:', 'invoicing' ); ?></label> |
|
| 163 | + <label for="tablecell"><?php _e('Transaction ID:', 'invoicing'); ?></label> |
|
| 164 | 164 | </td> |
| 165 | 165 | <td> |
| 166 | - <span class="wpinv-sub-transaction-id"><?php echo apply_filters( 'wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub ); ?></span> |
|
| 167 | - <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr( $sub->get_transaction_id() ); ?>" /> |
|
| 166 | + <span class="wpinv-sub-transaction-id"><?php echo apply_filters('wpinv_subscription_transaction_link_' . $sub->gateway, $sub->get_transaction_id(), $sub); ?></span> |
|
| 167 | + <input type="text" name="transaction_id" class="hidden wpinv-sub-transaction-id" value="<?php echo esc_attr($sub->get_transaction_id()); ?>" /> |
|
| 168 | 168 | <span> – </span> |
| 169 | - <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e( 'Edit', 'invoicing' ); ?></a> |
|
| 169 | + <a href="#" class="wpinv-edit-sub-transaction-id"><?php _e('Edit', 'invoicing'); ?></a> |
|
| 170 | 170 | </td> |
| 171 | 171 | </tr> |
| 172 | 172 | <tr> |
| 173 | 173 | <td class="row-title"> |
| 174 | - <label for="tablecell"><?php _e( 'Date Created:', 'invoicing' ); ?></label> |
|
| 174 | + <label for="tablecell"><?php _e('Date Created:', 'invoicing'); ?></label> |
|
| 175 | 175 | </td> |
| 176 | - <td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->created, current_time( 'timestamp' ) ) ); ?></td> |
|
| 176 | + <td><?php echo date_i18n(get_option('date_format'), strtotime($sub->created, current_time('timestamp'))); ?></td> |
|
| 177 | 177 | </tr> |
| 178 | 178 | <tr> |
| 179 | 179 | <td class="row-title"> |
| 180 | 180 | <label for="tablecell"> |
| 181 | - <?php if( 'trialling' == $sub->status ) : ?> |
|
| 182 | - <?php _e( 'Trialling Until:', 'invoicing' ); ?> |
|
| 181 | + <?php if ('trialling' == $sub->status) : ?> |
|
| 182 | + <?php _e('Trialling Until:', 'invoicing'); ?> |
|
| 183 | 183 | <?php else: ?> |
| 184 | - <?php _e( 'Expiration Date:', 'invoicing' ); ?> |
|
| 184 | + <?php _e('Expiration Date:', 'invoicing'); ?> |
|
| 185 | 185 | <?php endif; ?> |
| 186 | 186 | </label> |
| 187 | 187 | </td> |
| 188 | 188 | <td> |
| 189 | - <span class="wpinv-sub-expiration"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $sub->expiration, current_time( 'timestamp' ) ) ); ?></span> |
|
| 189 | + <span class="wpinv-sub-expiration"><?php echo date_i18n(get_option('date_format'), strtotime($sub->expiration, current_time('timestamp'))); ?></span> |
|
| 190 | 190 | </td> |
| 191 | 191 | </tr> |
| 192 | 192 | <tr> |
| 193 | 193 | <td class="row-title"> |
| 194 | - <label for="tablecell"><?php _e( 'Subscription Status:', 'invoicing' ); ?></label> |
|
| 194 | + <label for="tablecell"><?php _e('Subscription Status:', 'invoicing'); ?></label> |
|
| 195 | 195 | </td> |
| 196 | 196 | <td> |
| 197 | 197 | <select name="status" class="wpi_select2"> |
| 198 | - <option value="pending"<?php selected( 'pending', $sub->status ); ?>><?php _e( 'Pending', 'invoicing' ); ?></option> |
|
| 199 | - <option value="active"<?php selected( 'active', $sub->status ); ?>><?php _e( 'Active', 'invoicing' ); ?></option> |
|
| 200 | - <option value="cancelled"<?php selected( 'cancelled', $sub->status ); ?>><?php _e( 'Cancelled', 'invoicing' ); ?></option> |
|
| 201 | - <option value="expired"<?php selected( 'expired', $sub->status ); ?>><?php _e( 'Expired', 'invoicing' ); ?></option> |
|
| 202 | - <option value="trialling"<?php selected( 'trialling', $sub->status ); ?>><?php _e( 'Trialling', 'invoicing' ); ?></option> |
|
| 203 | - <option value="failing"<?php selected( 'failing', $sub->status ); ?>><?php _e( 'Failing', 'invoicing' ); ?></option> |
|
| 204 | - <option value="completed"<?php selected( 'completed', $sub->status ); ?>><?php _e( 'Completed', 'invoicing' ); ?></option> |
|
| 198 | + <option value="pending"<?php selected('pending', $sub->status); ?>><?php _e('Pending', 'invoicing'); ?></option> |
|
| 199 | + <option value="active"<?php selected('active', $sub->status); ?>><?php _e('Active', 'invoicing'); ?></option> |
|
| 200 | + <option value="cancelled"<?php selected('cancelled', $sub->status); ?>><?php _e('Cancelled', 'invoicing'); ?></option> |
|
| 201 | + <option value="expired"<?php selected('expired', $sub->status); ?>><?php _e('Expired', 'invoicing'); ?></option> |
|
| 202 | + <option value="trialling"<?php selected('trialling', $sub->status); ?>><?php _e('Trialling', 'invoicing'); ?></option> |
|
| 203 | + <option value="failing"<?php selected('failing', $sub->status); ?>><?php _e('Failing', 'invoicing'); ?></option> |
|
| 204 | + <option value="completed"<?php selected('completed', $sub->status); ?>><?php _e('Completed', 'invoicing'); ?></option> |
|
| 205 | 205 | </select> |
| 206 | 206 | </td> |
| 207 | 207 | </tr> |
@@ -209,79 +209,79 @@ discard block |
||
| 209 | 209 | </table> |
| 210 | 210 | </div> |
| 211 | 211 | <div id="wpinv-sub-notices"> |
| 212 | - <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e( 'Changing the product assigned will not automatically adjust any pricing.', 'invoicing' ); ?></p></div> |
|
| 213 | - <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e( 'Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing' ); ?></p></div> |
|
| 212 | + <div class="notice notice-info inline hidden" id="wpinv-sub-product-update-notice"><p><?php _e('Changing the product assigned will not automatically adjust any pricing.', 'invoicing'); ?></p></div> |
|
| 213 | + <div class="notice notice-warning inline hidden" id="wpinv-sub-profile-id-update-notice"><p><?php _e('Changing the profile ID can result in renewals not being processed. Do this with caution.', 'invoicing'); ?></p></div> |
|
| 214 | 214 | </div> |
| 215 | 215 | <div id="item-edit-actions" class="edit-item" style="float:right; margin: 10px 0 0; display: block;"> |
| 216 | - <?php wp_nonce_field( 'wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true ); ?> |
|
| 217 | - <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e( 'Update Subscription', 'invoicing' ); ?>"/> |
|
| 218 | - <input type="hidden" name="sub_id" value="<?php echo absint( $sub->id ); ?>" /> |
|
| 219 | - <?php if( $sub->can_cancel() ) : ?> |
|
| 220 | - <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e( 'Cancel Subscription', 'invoicing' ); ?></a> |
|
| 216 | + <?php wp_nonce_field('wpinv-recurring-update', 'wpinv-recurring-update-nonce', false, true); ?> |
|
| 217 | + <input type="submit" name="wpinv_update_subscription" id="wpinv_update_subscription" class="button button-primary" value="<?php _e('Update Subscription', 'invoicing'); ?>"/> |
|
| 218 | + <input type="hidden" name="sub_id" value="<?php echo absint($sub->id); ?>" /> |
|
| 219 | + <?php if ($sub->can_cancel()) : ?> |
|
| 220 | + <a class="button button-primary" href="<?php echo $sub->get_cancel_url(); ?>" ><?php _e('Cancel Subscription', 'invoicing'); ?></a> |
|
| 221 | 221 | <?php endif; ?> |
| 222 | - <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e( 'Delete Subscription', 'invoicing' ); ?>"/> |
|
| 222 | + <input type="submit" name="wpinv_delete_subscription" class="wpinv-delete-subscription button" value="<?php _e('Delete Subscription', 'invoicing'); ?>"/> |
|
| 223 | 223 | </div> |
| 224 | 224 | |
| 225 | 225 | </form> |
| 226 | 226 | </div> |
| 227 | 227 | |
| 228 | - <?php do_action( 'wpinv_subscription_before_stats', $sub ); ?> |
|
| 228 | + <?php do_action('wpinv_subscription_before_stats', $sub); ?> |
|
| 229 | 229 | |
| 230 | - <?php do_action( 'wpinv_subscription_before_tables_wrapper', $sub ); ?> |
|
| 230 | + <?php do_action('wpinv_subscription_before_tables_wrapper', $sub); ?> |
|
| 231 | 231 | |
| 232 | 232 | <div id="item-tables-wrapper" class="item-section"> |
| 233 | 233 | |
| 234 | - <?php do_action( 'wpinv_subscription_before_tables', $sub ); ?> |
|
| 234 | + <?php do_action('wpinv_subscription_before_tables', $sub); ?> |
|
| 235 | 235 | |
| 236 | - <h3><?php _e( 'Renewal Payments:', 'invoicing' ); ?></h3> |
|
| 236 | + <h3><?php _e('Renewal Payments:', 'invoicing'); ?></h3> |
|
| 237 | 237 | <?php $payments = $sub->get_child_payments(); ?> |
| 238 | - <?php if ( 'manual' == $sub->gateway ) : ?> |
|
| 239 | - <p><strong><?php _e( 'Note:', 'invoicing' ); ?></strong> <?php _e( 'Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing' ); ?></p> |
|
| 238 | + <?php if ('manual' == $sub->gateway) : ?> |
|
| 239 | + <p><strong><?php _e('Note:', 'invoicing'); ?></strong> <?php _e('Subscriptions purchased with the Test Payment gateway will not renew automatically.', 'invoicing'); ?></p> |
|
| 240 | 240 | <?php endif; ?> |
| 241 | 241 | <table class="wp-list-table widefat striped payments"> |
| 242 | 242 | <thead> |
| 243 | 243 | <tr> |
| 244 | - <th><?php _e( 'ID', 'invoicing' ); ?></th> |
|
| 245 | - <th><?php _e( 'Amount', 'invoicing' ); ?></th> |
|
| 246 | - <th><?php _e( 'Date', 'invoicing' ); ?></th> |
|
| 247 | - <th><?php _e( 'Status', 'invoicing' ); ?></th> |
|
| 248 | - <th><?php _e( 'Invoice', 'invoicing' ); ?></th> |
|
| 249 | - <th class="column-wpi_actions"><?php _e( 'Actions', 'invoicing' ); ?></th> |
|
| 244 | + <th><?php _e('ID', 'invoicing'); ?></th> |
|
| 245 | + <th><?php _e('Amount', 'invoicing'); ?></th> |
|
| 246 | + <th><?php _e('Date', 'invoicing'); ?></th> |
|
| 247 | + <th><?php _e('Status', 'invoicing'); ?></th> |
|
| 248 | + <th><?php _e('Invoice', 'invoicing'); ?></th> |
|
| 249 | + <th class="column-wpi_actions"><?php _e('Actions', 'invoicing'); ?></th> |
|
| 250 | 250 | </tr> |
| 251 | 251 | </thead> |
| 252 | 252 | <tbody> |
| 253 | - <?php if ( ! empty( $payments ) ) : ?> |
|
| 254 | - <?php foreach ( $payments as $payment ) : $invoice = wpinv_get_invoice( $payment->ID ); if ( empty( $invoice->ID ) ) continue; ?> |
|
| 253 | + <?php if (!empty($payments)) : ?> |
|
| 254 | + <?php foreach ($payments as $payment) : $invoice = wpinv_get_invoice($payment->ID); if (empty($invoice->ID)) continue; ?> |
|
| 255 | 255 | <tr> |
| 256 | 256 | <td><?php echo $payment->ID; ?></td> |
| 257 | - <td><?php echo $invoice->get_total( true ); ?></td> |
|
| 257 | + <td><?php echo $invoice->get_total(true); ?></td> |
|
| 258 | 258 | <td><?php echo $invoice->get_invoice_date(); ?></td> |
| 259 | - <td><?php echo $invoice->get_status( true ); ?></td> |
|
| 259 | + <td><?php echo $invoice->get_status(true); ?></td> |
|
| 260 | 260 | <td> |
| 261 | - <a target="_blank" title="<?php _e( 'View invoice', 'invoicing' ); ?>" href="<?php echo esc_url( get_permalink( $payment->ID ) ); ?>"><?php echo $invoice->get_number(); ?></a> |
|
| 262 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
| 261 | + <a target="_blank" title="<?php _e('View invoice', 'invoicing'); ?>" href="<?php echo esc_url(get_permalink($payment->ID)); ?>"><?php echo $invoice->get_number(); ?></a> |
|
| 262 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
| 263 | 263 | </td> |
| 264 | 264 | <td class="column-wpi_actions"> |
| 265 | - <a title="<?php echo esc_attr( wp_sprintf( __( 'View details for invoice: %s', 'invoicing' ), $invoice->get_number() ) ); ?>" href="<?php echo get_edit_post_link( $payment->ID ); ?>"><?php _e( 'View Details', 'invoicing' ); ?> |
|
| 265 | + <a title="<?php echo esc_attr(wp_sprintf(__('View details for invoice: %s', 'invoicing'), $invoice->get_number())); ?>" href="<?php echo get_edit_post_link($payment->ID); ?>"><?php _e('View Details', 'invoicing'); ?> |
|
| 266 | 266 | </a> |
| 267 | - <?php do_action( 'wpinv_subscription_payments_actions', $sub, $payment ); ?> |
|
| 267 | + <?php do_action('wpinv_subscription_payments_actions', $sub, $payment); ?> |
|
| 268 | 268 | </td> |
| 269 | 269 | </tr> |
| 270 | 270 | <?php endforeach; ?> |
| 271 | 271 | <?php else: ?> |
| 272 | 272 | <tr> |
| 273 | - <td colspan="5"><?php _e( 'No Invoices Found.', 'invoicing' ); ?></td> |
|
| 273 | + <td colspan="5"><?php _e('No Invoices Found.', 'invoicing'); ?></td> |
|
| 274 | 274 | </tr> |
| 275 | 275 | <?php endif; ?> |
| 276 | 276 | </tbody> |
| 277 | 277 | <tfoot></tfoot> |
| 278 | 278 | </table> |
| 279 | 279 | |
| 280 | - <?php do_action( 'wpinv_subscription_after_tables', $sub ); ?> |
|
| 280 | + <?php do_action('wpinv_subscription_after_tables', $sub); ?> |
|
| 281 | 281 | |
| 282 | 282 | </div> |
| 283 | 283 | |
| 284 | - <?php do_action( 'wpinv_subscription_card_bottom', $sub ); ?> |
|
| 284 | + <?php do_action('wpinv_subscription_card_bottom', $sub); ?> |
|
| 285 | 285 | </div> |
| 286 | 286 | |
| 287 | 287 | <?php endif; ?> |
@@ -299,36 +299,36 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function wpinv_recurring_process_subscription_update() { |
| 301 | 301 | |
| 302 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 302 | + if (empty($_POST['sub_id'])) { |
|
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if( empty( $_POST['wpinv_update_subscription'] ) ) { |
|
| 306 | + if (empty($_POST['wpinv_update_subscription'])) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 310 | + if (!current_user_can('manage_invoicing')) { |
|
| 311 | 311 | return; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 315 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 314 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 315 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $profile_id = sanitize_text_field( $_POST['profile_id'] ); |
|
| 319 | - $transaction_id = sanitize_text_field( $_POST['transaction_id'] ); |
|
| 320 | - $product_id = absint( $_POST['product_id'] ); |
|
| 321 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 322 | - $subscription->update( array( |
|
| 323 | - 'status' => sanitize_text_field( $_POST['status'] ), |
|
| 318 | + $profile_id = sanitize_text_field($_POST['profile_id']); |
|
| 319 | + $transaction_id = sanitize_text_field($_POST['transaction_id']); |
|
| 320 | + $product_id = absint($_POST['product_id']); |
|
| 321 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 322 | + $subscription->update(array( |
|
| 323 | + 'status' => sanitize_text_field($_POST['status']), |
|
| 324 | 324 | 'profile_id' => $profile_id, |
| 325 | 325 | 'product_id' => $product_id, |
| 326 | 326 | 'transaction_id' => $transaction_id, |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | |
| 329 | - $status = sanitize_text_field( $_POST['status'] ); |
|
| 329 | + $status = sanitize_text_field($_POST['status']); |
|
| 330 | 330 | |
| 331 | - switch( $status ) { |
|
| 331 | + switch ($status) { |
|
| 332 | 332 | |
| 333 | 333 | case 'cancelled' : |
| 334 | 334 | |
@@ -347,11 +347,11 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id ) ); |
|
| 350 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=updated&id=' . $subscription->id)); |
|
| 351 | 351 | exit; |
| 352 | 352 | |
| 353 | 353 | } |
| 354 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_update', 1 ); |
|
| 354 | +add_action('admin_init', 'wpinv_recurring_process_subscription_update', 1); |
|
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * Handles subscription deletion |
@@ -362,30 +362,30 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function wpinv_recurring_process_subscription_deletion() { |
| 364 | 364 | |
| 365 | - if( empty( $_POST['sub_id'] ) ) { |
|
| 365 | + if (empty($_POST['sub_id'])) { |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if( empty( $_POST['wpinv_delete_subscription'] ) ) { |
|
| 369 | + if (empty($_POST['wpinv_delete_subscription'])) { |
|
| 370 | 370 | return; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if( ! current_user_can( 'manage_invoicing') ) { |
|
| 373 | + if (!current_user_can('manage_invoicing')) { |
|
| 374 | 374 | return; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if( ! wp_verify_nonce( $_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update' ) ) { |
|
| 378 | - wp_die( __( 'Nonce verification failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
| 377 | + if (!wp_verify_nonce($_POST['wpinv-recurring-update-nonce'], 'wpinv-recurring-update')) { |
|
| 378 | + wp_die(__('Nonce verification failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - $subscription = new WPInv_Subscription( absint( $_POST['sub_id'] ) ); |
|
| 381 | + $subscription = new WPInv_Subscription(absint($_POST['sub_id'])); |
|
| 382 | 382 | |
| 383 | - delete_post_meta( $subscription->parent_payment_id, '_wpinv_subscription_payment' ); |
|
| 383 | + delete_post_meta($subscription->parent_payment_id, '_wpinv_subscription_payment'); |
|
| 384 | 384 | |
| 385 | 385 | $subscription->delete(); |
| 386 | 386 | |
| 387 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=deleted' ) ); |
|
| 387 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=deleted')); |
|
| 388 | 388 | exit; |
| 389 | 389 | |
| 390 | 390 | } |
| 391 | -add_action( 'admin_init', 'wpinv_recurring_process_subscription_deletion', 2 ); |
|
| 391 | +add_action('admin_init', 'wpinv_recurring_process_subscription_deletion', 2); |
|
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | |
| 80 | 80 | if(empty($count)){ |
| 81 | 81 | $output .= __('No Invoice(s)','invoicing'); |
| 82 | - }else{ |
|
| 82 | + } else{ |
|
| 83 | 83 | $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
| 84 | 84 | $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
| 85 | 85 | $output .= "<a href='$link_url' >$link_text</a>"; |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Admin_Users { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Admin_Users ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) { |
|
| 19 | 19 | self::$instance = new WPInv_Admin_Users; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function __construct() { |
| 26 | - add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column') ); |
|
| 27 | - add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content') , 10, 3 ); |
|
| 26 | + add_filter('manage_users_columns', array($this, 'wpinv_add_user_column')); |
|
| 27 | + add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return mixed |
| 36 | 36 | */ |
| 37 | - public function wpinv_add_user_column( $column ) { |
|
| 38 | - $column['wpinvoicing'] = __('Invoicing','invoicing'); |
|
| 37 | + public function wpinv_add_user_column($column) { |
|
| 38 | + $column['wpinvoicing'] = __('Invoicing', 'invoicing'); |
|
| 39 | 39 | return $column; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -48,10 +48,10 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - function wpinv_user_column_content( $val, $column_name, $user_id ) { |
|
| 51 | + function wpinv_user_column_content($val, $column_name, $user_id) { |
|
| 52 | 52 | switch ($column_name) { |
| 53 | 53 | case 'wpinvoicing' : |
| 54 | - return $this->get_user_invoices( $user_id ); |
|
| 54 | + return $this->get_user_invoices($user_id); |
|
| 55 | 55 | break; |
| 56 | 56 | default: |
| 57 | 57 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function get_user_invoices($user_id){ |
|
| 68 | + public function get_user_invoices($user_id) { |
|
| 69 | 69 | $output = ''; |
| 70 | 70 | $wp_query_args = array( |
| 71 | 71 | 'post_type' => 'wpi_invoice', |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id); |
| 79 | 79 | |
| 80 | - $invoices = new WP_Query( $wp_query_args ); |
|
| 81 | - $count = absint( $invoices->found_posts ); |
|
| 80 | + $invoices = new WP_Query($wp_query_args); |
|
| 81 | + $count = absint($invoices->found_posts); |
|
| 82 | 82 | |
| 83 | - if(empty($count)){ |
|
| 84 | - $output .= __('No Invoice(s)','invoicing'); |
|
| 85 | - }else{ |
|
| 86 | - $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) ); |
|
| 87 | - $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count ); |
|
| 83 | + if (empty($count)) { |
|
| 84 | + $output .= __('No Invoice(s)', 'invoicing'); |
|
| 85 | + } else { |
|
| 86 | + $link_url = admin_url("edit.php?post_type=wpi_invoice&author=" . absint($user_id)); |
|
| 87 | + $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count); |
|
| 88 | 88 | $output .= "<a href='$link_url' >$link_text</a>"; |
| 89 | 89 | } |
| 90 | 90 | |