@@ -13,720 +13,720 @@ 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 | - return $actions;  | 
                                                        |
| 133 | - }  | 
                                                        |
| 134 | -  | 
                                                        |
| 135 | - /**  | 
                                                        |
| 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 | + return $actions;  | 
                                                        |
| 133 | + }  | 
                                                        |
| 134 | +  | 
                                                        |
| 135 | + /**  | 
                                                        |
| 136 | 136 | * Remove bulk edit option from admin side quote listing  | 
                                                        
| 137 | 137 | *  | 
                                                        
| 138 | 138 | * @since 1.0.0  | 
                                                        
| 139 | 139 | * @param array $actions post actions  | 
                                                        
| 140 | - * @param WP_Post $post  | 
                                                        |
| 140 | + * @param WP_Post $post  | 
                                                        |
| 141 | 141 | * @return array $actions actions without edit option  | 
                                                        
| 142 | 142 | */  | 
                                                        
| 143 | 143 |      public static function filter_invoice_row_actions( $actions, $post ) { | 
                                                        
| 144 | 144 | |
| 145 | 145 |          if ( getpaid_is_invoice_post_type( $post->post_type ) ) { | 
                                                        
| 146 | 146 | |
| 147 | - $actions = array();  | 
                                                        |
| 148 | - $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 149 | -  | 
                                                        |
| 150 | - $actions['edit'] = sprintf(  | 
                                                        |
| 151 | - '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 152 | - esc_url( get_edit_post_link( $invoice->get_id() ) ),  | 
                                                        |
| 153 | - esc_html( __( 'Edit', 'invoicing' ) )  | 
                                                        |
| 154 | - );  | 
                                                        |
| 155 | -  | 
                                                        |
| 156 | -			if ( ! $invoice->is_draft() ) { | 
                                                        |
| 157 | -  | 
                                                        |
| 158 | - $actions['view'] = sprintf(  | 
                                                        |
| 159 | - '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 160 | - esc_url( $invoice->get_view_url() ),  | 
                                                        |
| 161 | - sprintf(  | 
                                                        |
| 162 | - esc_html( __( 'View %s', 'invoicing' ) ),  | 
                                                        |
| 163 | - getpaid_get_post_type_label( $invoice->get_post_type(), false )  | 
                                                        |
| 164 | - )  | 
                                                        |
| 165 | - );  | 
                                                        |
| 166 | -  | 
                                                        |
| 167 | - $actions['send'] = sprintf(  | 
                                                        |
| 168 | - '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 169 | - esc_url(  | 
                                                        |
| 170 | - wp_nonce_url(  | 
                                                        |
| 171 | - add_query_arg(  | 
                                                        |
| 172 | - array(  | 
                                                        |
| 173 | - 'getpaid-admin-action' => 'send_invoice',  | 
                                                        |
| 174 | - 'invoice_id' => $invoice->get_id()  | 
                                                        |
| 175 | - )  | 
                                                        |
| 176 | - ),  | 
                                                        |
| 177 | - 'getpaid-nonce',  | 
                                                        |
| 178 | - 'getpaid-nonce'  | 
                                                        |
| 179 | - )  | 
                                                        |
| 180 | - ),  | 
                                                        |
| 181 | - esc_html( __( 'Send to Customer', 'invoicing' ) )  | 
                                                        |
| 182 | - );  | 
                                                        |
| 183 | -  | 
                                                        |
| 184 | - }  | 
                                                        |
| 185 | -  | 
                                                        |
| 186 | - $actions['duplicate'] = sprintf(  | 
                                                        |
| 187 | - '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 188 | - esc_url(  | 
                                                        |
| 189 | - wp_nonce_url(  | 
                                                        |
| 190 | - add_query_arg(  | 
                                                        |
| 191 | - array(  | 
                                                        |
| 192 | - 'getpaid-admin-action' => 'duplicate_invoice',  | 
                                                        |
| 193 | - 'invoice_id' => $post->ID  | 
                                                        |
| 194 | - )  | 
                                                        |
| 195 | - ),  | 
                                                        |
| 196 | - 'getpaid-nonce',  | 
                                                        |
| 197 | - 'getpaid-nonce'  | 
                                                        |
| 198 | - )  | 
                                                        |
| 199 | - ),  | 
                                                        |
| 200 | - esc_html( __( 'Duplicate', 'invoicing' ) )  | 
                                                        |
| 201 | - );  | 
                                                        |
| 147 | + $actions = array();  | 
                                                        |
| 148 | + $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 149 | +  | 
                                                        |
| 150 | + $actions['edit'] = sprintf(  | 
                                                        |
| 151 | + '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 152 | + esc_url( get_edit_post_link( $invoice->get_id() ) ),  | 
                                                        |
| 153 | + esc_html( __( 'Edit', 'invoicing' ) )  | 
                                                        |
| 154 | + );  | 
                                                        |
| 155 | +  | 
                                                        |
| 156 | +            if ( ! $invoice->is_draft() ) { | 
                                                        |
| 157 | +  | 
                                                        |
| 158 | + $actions['view'] = sprintf(  | 
                                                        |
| 159 | + '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 160 | + esc_url( $invoice->get_view_url() ),  | 
                                                        |
| 161 | + sprintf(  | 
                                                        |
| 162 | + esc_html( __( 'View %s', 'invoicing' ) ),  | 
                                                        |
| 163 | + getpaid_get_post_type_label( $invoice->get_post_type(), false )  | 
                                                        |
| 164 | + )  | 
                                                        |
| 165 | + );  | 
                                                        |
| 166 | +  | 
                                                        |
| 167 | + $actions['send'] = sprintf(  | 
                                                        |
| 168 | + '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 169 | + esc_url(  | 
                                                        |
| 170 | + wp_nonce_url(  | 
                                                        |
| 171 | + add_query_arg(  | 
                                                        |
| 172 | + array(  | 
                                                        |
| 173 | + 'getpaid-admin-action' => 'send_invoice',  | 
                                                        |
| 174 | + 'invoice_id' => $invoice->get_id()  | 
                                                        |
| 175 | + )  | 
                                                        |
| 176 | + ),  | 
                                                        |
| 177 | + 'getpaid-nonce',  | 
                                                        |
| 178 | + 'getpaid-nonce'  | 
                                                        |
| 179 | + )  | 
                                                        |
| 180 | + ),  | 
                                                        |
| 181 | + esc_html( __( 'Send to Customer', 'invoicing' ) )  | 
                                                        |
| 182 | + );  | 
                                                        |
| 183 | +  | 
                                                        |
| 184 | + }  | 
                                                        |
| 185 | +  | 
                                                        |
| 186 | + $actions['duplicate'] = sprintf(  | 
                                                        |
| 187 | + '<a href="%1$s">%2$s</a>',  | 
                                                        |
| 188 | + esc_url(  | 
                                                        |
| 189 | + wp_nonce_url(  | 
                                                        |
| 190 | + add_query_arg(  | 
                                                        |
| 191 | + array(  | 
                                                        |
| 192 | + 'getpaid-admin-action' => 'duplicate_invoice',  | 
                                                        |
| 193 | + 'invoice_id' => $post->ID  | 
                                                        |
| 194 | + )  | 
                                                        |
| 195 | + ),  | 
                                                        |
| 196 | + 'getpaid-nonce',  | 
                                                        |
| 197 | + 'getpaid-nonce'  | 
                                                        |
| 198 | + )  | 
                                                        |
| 199 | + ),  | 
                                                        |
| 200 | + esc_html( __( 'Duplicate', 'invoicing' ) )  | 
                                                        |
| 201 | + );  | 
                                                        |
| 202 | 202 | |
| 203 | 203 | }  | 
                                                        
| 204 | 204 | |
| 205 | 205 | return $actions;  | 
                                                        
| 206 | - }  | 
                                                        |
| 207 | -  | 
                                                        |
| 208 | - /**  | 
                                                        |
| 209 | - * Returns an array of invoice table columns.  | 
                                                        |
| 210 | - */  | 
                                                        |
| 211 | -	public static function invoice_columns( $columns ) { | 
                                                        |
| 212 | -  | 
                                                        |
| 213 | - $columns = array(  | 
                                                        |
| 214 | - 'cb' => $columns['cb'],  | 
                                                        |
| 215 | - 'number' => __( 'Invoice', 'invoicing' ),  | 
                                                        |
| 216 | - 'customer' => __( 'Customer', 'invoicing' ),  | 
                                                        |
| 217 | - 'invoice_date' => __( 'Created', 'invoicing' ),  | 
                                                        |
| 218 | - 'payment_date' => __( 'Completed', 'invoicing' ),  | 
                                                        |
| 219 | - 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 220 | - 'recurring' => __( 'Recurring', 'invoicing' ),  | 
                                                        |
| 221 | - 'status' => __( 'Status', 'invoicing' ),  | 
                                                        |
| 222 | - );  | 
                                                        |
| 223 | -  | 
                                                        |
| 224 | - return apply_filters( 'wpi_invoice_table_columns', $columns );  | 
                                                        |
| 225 | - }  | 
                                                        |
| 226 | -  | 
                                                        |
| 227 | - /**  | 
                                                        |
| 228 | - * Displays invoice table columns.  | 
                                                        |
| 229 | - */  | 
                                                        |
| 230 | -	public static function display_invoice_columns( $column_name, $post_id ) { | 
                                                        |
| 231 | -  | 
                                                        |
| 232 | - $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 233 | -  | 
                                                        |
| 234 | -		switch ( $column_name ) { | 
                                                        |
| 235 | -  | 
                                                        |
| 236 | - case 'invoice_date' :  | 
                                                        |
| 237 | - $date_time = esc_attr( $invoice->get_created_date() );  | 
                                                        |
| 238 | - $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 239 | - echo "<span title='$date_time'>$date</span>";  | 
                                                        |
| 240 | - break;  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | - case 'payment_date' :  | 
                                                        |
| 243 | -  | 
                                                        |
| 244 | -				if ( $invoice->is_paid() ) { | 
                                                        |
| 245 | - $date_time = esc_attr( $invoice->get_completed_date() );  | 
                                                        |
| 246 | - $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 247 | - echo "<span title='$date_time'>$date</span>";  | 
                                                        |
| 248 | -				} else { | 
                                                        |
| 249 | - echo "—";  | 
                                                        |
| 250 | - }  | 
                                                        |
| 206 | + }  | 
                                                        |
| 207 | +  | 
                                                        |
| 208 | + /**  | 
                                                        |
| 209 | + * Returns an array of invoice table columns.  | 
                                                        |
| 210 | + */  | 
                                                        |
| 211 | +    public static function invoice_columns( $columns ) { | 
                                                        |
| 212 | +  | 
                                                        |
| 213 | + $columns = array(  | 
                                                        |
| 214 | + 'cb' => $columns['cb'],  | 
                                                        |
| 215 | + 'number' => __( 'Invoice', 'invoicing' ),  | 
                                                        |
| 216 | + 'customer' => __( 'Customer', 'invoicing' ),  | 
                                                        |
| 217 | + 'invoice_date' => __( 'Created', 'invoicing' ),  | 
                                                        |
| 218 | + 'payment_date' => __( 'Completed', 'invoicing' ),  | 
                                                        |
| 219 | + 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 220 | + 'recurring' => __( 'Recurring', 'invoicing' ),  | 
                                                        |
| 221 | + 'status' => __( 'Status', 'invoicing' ),  | 
                                                        |
| 222 | + );  | 
                                                        |
| 223 | +  | 
                                                        |
| 224 | + return apply_filters( 'wpi_invoice_table_columns', $columns );  | 
                                                        |
| 225 | + }  | 
                                                        |
| 226 | +  | 
                                                        |
| 227 | + /**  | 
                                                        |
| 228 | + * Displays invoice table columns.  | 
                                                        |
| 229 | + */  | 
                                                        |
| 230 | +    public static function display_invoice_columns( $column_name, $post_id ) { | 
                                                        |
| 231 | +  | 
                                                        |
| 232 | + $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 233 | +  | 
                                                        |
| 234 | +        switch ( $column_name ) { | 
                                                        |
| 235 | +  | 
                                                        |
| 236 | + case 'invoice_date' :  | 
                                                        |
| 237 | + $date_time = esc_attr( $invoice->get_created_date() );  | 
                                                        |
| 238 | + $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 239 | + echo "<span title='$date_time'>$date</span>";  | 
                                                        |
| 240 | + break;  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | + case 'payment_date' :  | 
                                                        |
| 243 | +  | 
                                                        |
| 244 | +                if ( $invoice->is_paid() ) { | 
                                                        |
| 245 | + $date_time = esc_attr( $invoice->get_completed_date() );  | 
                                                        |
| 246 | + $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 247 | + echo "<span title='$date_time'>$date</span>";  | 
                                                        |
| 248 | +                } else { | 
                                                        |
| 249 | + echo "—";  | 
                                                        |
| 250 | + }  | 
                                                        |
| 251 | 251 | |
| 252 | - break;  | 
                                                        |
| 252 | + break;  | 
                                                        |
| 253 | 253 | |
| 254 | - case 'amount' :  | 
                                                        |
| 254 | + case 'amount' :  | 
                                                        |
| 255 | 255 | |
| 256 | - $amount = $invoice->get_total();  | 
                                                        |
| 257 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() );  | 
                                                        |
| 256 | + $amount = $invoice->get_total();  | 
                                                        |
| 257 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() );  | 
                                                        |
| 258 | 258 | |
| 259 | -				if ( $invoice->is_refunded() ) { | 
                                                        |
| 260 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() );  | 
                                                        |
| 261 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>";  | 
                                                        |
| 262 | -				} else { | 
                                                        |
| 259 | +                if ( $invoice->is_refunded() ) { | 
                                                        |
| 260 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() );  | 
                                                        |
| 261 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>";  | 
                                                        |
| 262 | +                } else { | 
                                                        |
| 263 | 263 | |
| 264 | - $discount = $invoice->get_total_discount();  | 
                                                        |
| 264 | + $discount = $invoice->get_total_discount();  | 
                                                        |
| 265 | 265 | |
| 266 | -					if ( ! empty( $discount ) ) { | 
                                                        |
| 267 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );  | 
                                                        |
| 268 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>";  | 
                                                        |
| 269 | -					} else { | 
                                                        |
| 270 | - echo $formated_amount;  | 
                                                        |
| 271 | - }  | 
                                                        |
| 266 | +                    if ( ! empty( $discount ) ) { | 
                                                        |
| 267 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );  | 
                                                        |
| 268 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>";  | 
                                                        |
| 269 | +                    } else { | 
                                                        |
| 270 | + echo $formated_amount;  | 
                                                        |
| 271 | + }  | 
                                                        |
| 272 | 272 | |
| 273 | - }  | 
                                                        |
| 273 | + }  | 
                                                        |
| 274 | 274 | |
| 275 | - break;  | 
                                                        |
| 275 | + break;  | 
                                                        |
| 276 | 276 | |
| 277 | - case 'status' :  | 
                                                        |
| 278 | - $status = esc_html( $invoice->get_status() );  | 
                                                        |
| 279 | - $status_label = esc_html( $invoice->get_status_nicename() );  | 
                                                        |
| 277 | + case 'status' :  | 
                                                        |
| 278 | + $status = esc_html( $invoice->get_status() );  | 
                                                        |
| 279 | + $status_label = esc_html( $invoice->get_status_nicename() );  | 
                                                        |
| 280 | 280 | |
| 281 | - // If it is paid, show the gateway title.  | 
                                                        |
| 282 | -				if ( $invoice->is_paid() ) { | 
                                                        |
| 283 | - $gateway = esc_html( $invoice->get_gateway_title() );  | 
                                                        |
| 284 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );  | 
                                                        |
| 281 | + // If it is paid, show the gateway title.  | 
                                                        |
| 282 | +                if ( $invoice->is_paid() ) { | 
                                                        |
| 283 | + $gateway = esc_html( $invoice->get_gateway_title() );  | 
                                                        |
| 284 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );  | 
                                                        |
| 285 | 285 | |
| 286 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";  | 
                                                        |
| 287 | -				} else { | 
                                                        |
| 288 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";  | 
                                                        |
| 289 | - }  | 
                                                        |
| 286 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";  | 
                                                        |
| 287 | +                } else { | 
                                                        |
| 288 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";  | 
                                                        |
| 289 | + }  | 
                                                        |
| 290 | 290 | |
| 291 | - // If it is not paid, display the overdue and view status.  | 
                                                        |
| 292 | -				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { | 
                                                        |
| 291 | + // If it is not paid, display the overdue and view status.  | 
                                                        |
| 292 | +                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { | 
                                                        |
| 293 | 293 | |
| 294 | - // Invoice view status.  | 
                                                        |
| 295 | -					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { | 
                                                        |
| 296 | - echo '  <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 297 | -					} else { | 
                                                        |
| 298 | - echo '  <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 299 | - }  | 
                                                        |
| 294 | + // Invoice view status.  | 
                                                        |
| 295 | +                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { | 
                                                        |
| 296 | + echo '  <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 297 | +                    } else { | 
                                                        |
| 298 | + echo '  <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 299 | + }  | 
                                                        |
| 300 | 300 | |
| 301 | - // Display the overview status.  | 
                                                        |
| 302 | -					if ( wpinv_get_option( 'overdue_active' ) ) { | 
                                                        |
| 303 | - $due_date = $invoice->get_due_date();  | 
                                                        |
| 304 | - $fomatted = getpaid_format_date( $due_date );  | 
                                                        |
| 301 | + // Display the overview status.  | 
                                                        |
| 302 | +                    if ( wpinv_get_option( 'overdue_active' ) ) { | 
                                                        |
| 303 | + $due_date = $invoice->get_due_date();  | 
                                                        |
| 304 | + $fomatted = getpaid_format_date( $due_date );  | 
                                                        |
| 305 | 305 | |
| 306 | -						if ( ! empty( $fomatted ) ) { | 
                                                        |
| 307 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );  | 
                                                        |
| 308 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";  | 
                                                        |
| 309 | - }  | 
                                                        |
| 310 | - }  | 
                                                        |
| 306 | +                        if ( ! empty( $fomatted ) ) { | 
                                                        |
| 307 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );  | 
                                                        |
| 308 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";  | 
                                                        |
| 309 | + }  | 
                                                        |
| 310 | + }  | 
                                                        |
| 311 | 311 | |
| 312 | - }  | 
                                                        |
| 312 | + }  | 
                                                        |
| 313 | 313 | |
| 314 | - break;  | 
                                                        |
| 314 | + break;  | 
                                                        |
| 315 | 315 | |
| 316 | - case 'recurring':  | 
                                                        |
| 316 | + case 'recurring':  | 
                                                        |
| 317 | 317 | |
| 318 | -				if ( $invoice->is_recurring() ) { | 
                                                        |
| 319 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>';  | 
                                                        |
| 320 | -				} else { | 
                                                        |
| 321 | - echo '<i class="fa fa-times" style="color:#616161;"></i>';  | 
                                                        |
| 322 | - }  | 
                                                        |
| 323 | - break;  | 
                                                        |
| 318 | +                if ( $invoice->is_recurring() ) { | 
                                                        |
| 319 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>';  | 
                                                        |
| 320 | +                } else { | 
                                                        |
| 321 | + echo '<i class="fa fa-times" style="color:#616161;"></i>';  | 
                                                        |
| 322 | + }  | 
                                                        |
| 323 | + break;  | 
                                                        |
| 324 | 324 | |
| 325 | - case 'number' :  | 
                                                        |
| 325 | + case 'number' :  | 
                                                        |
| 326 | 326 | |
| 327 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) );  | 
                                                        |
| 328 | - $invoice_number = esc_html( $invoice->get_number() );  | 
                                                        |
| 329 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );  | 
                                                        |
| 327 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) );  | 
                                                        |
| 328 | + $invoice_number = esc_html( $invoice->get_number() );  | 
                                                        |
| 329 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );  | 
                                                        |
| 330 | 330 | |
| 331 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";  | 
                                                        |
| 331 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";  | 
                                                        |
| 332 | 332 | |
| 333 | - break;  | 
                                                        |
| 333 | + break;  | 
                                                        |
| 334 | 334 | |
| 335 | - case 'customer' :  | 
                                                        |
| 335 | + case 'customer' :  | 
                                                        |
| 336 | 336 | |
| 337 | - $customer_name = $invoice->get_user_full_name();  | 
                                                        |
| 337 | + $customer_name = $invoice->get_user_full_name();  | 
                                                        |
| 338 | 338 | |
| 339 | -				if ( empty( $customer_name ) ) { | 
                                                        |
| 340 | - $customer_name = $invoice->get_email();  | 
                                                        |
| 341 | - }  | 
                                                        |
| 339 | +                if ( empty( $customer_name ) ) { | 
                                                        |
| 340 | + $customer_name = $invoice->get_email();  | 
                                                        |
| 341 | + }  | 
                                                        |
| 342 | 342 | |
| 343 | -				if ( ! empty( $customer_name ) ) { | 
                                                        |
| 344 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );  | 
                                                        |
| 345 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );  | 
                                                        |
| 346 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";  | 
                                                        |
| 347 | -				} else { | 
                                                        |
| 348 | - echo '<div>—</div>';  | 
                                                        |
| 349 | - }  | 
                                                        |
| 343 | +                if ( ! empty( $customer_name ) ) { | 
                                                        |
| 344 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );  | 
                                                        |
| 345 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );  | 
                                                        |
| 346 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";  | 
                                                        |
| 347 | +                } else { | 
                                                        |
| 348 | + echo '<div>—</div>';  | 
                                                        |
| 349 | + }  | 
                                                        |
| 350 | 350 | |
| 351 | - break;  | 
                                                        |
| 351 | + break;  | 
                                                        |
| 352 | 352 | |
| 353 | - }  | 
                                                        |
| 353 | + }  | 
                                                        |
| 354 | 354 | |
| 355 | - }  | 
                                                        |
| 355 | + }  | 
                                                        |
| 356 | 356 | |
| 357 | - /**  | 
                                                        |
| 358 | - * Displays invoice bulk actions.  | 
                                                        |
| 359 | - */  | 
                                                        |
| 360 | -	public static function invoice_bulk_actions( $actions ) { | 
                                                        |
| 361 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );  | 
                                                        |
| 362 | - return $actions;  | 
                                                        |
| 363 | - }  | 
                                                        |
| 357 | + /**  | 
                                                        |
| 358 | + * Displays invoice bulk actions.  | 
                                                        |
| 359 | + */  | 
                                                        |
| 360 | +    public static function invoice_bulk_actions( $actions ) { | 
                                                        |
| 361 | + $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );  | 
                                                        |
| 362 | + return $actions;  | 
                                                        |
| 363 | + }  | 
                                                        |
| 364 | 364 | |
| 365 | - /**  | 
                                                        |
| 366 | - * Processes invoice bulk actions.  | 
                                                        |
| 367 | - */  | 
                                                        |
| 368 | -	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { | 
                                                        |
| 365 | + /**  | 
                                                        |
| 366 | + * Processes invoice bulk actions.  | 
                                                        |
| 367 | + */  | 
                                                        |
| 368 | +    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { | 
                                                        |
| 369 | 369 | |
| 370 | -		if ( $action == 'resend-invoice' ) { | 
                                                        |
| 370 | +        if ( $action == 'resend-invoice' ) { | 
                                                        |
| 371 | 371 | |
| 372 | - $success = false;  | 
                                                        |
| 373 | -			foreach ( $post_ids as $post_id ) { | 
                                                        |
| 374 | - $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );  | 
                                                        |
| 375 | - }  | 
                                                        |
| 372 | + $success = false;  | 
                                                        |
| 373 | +            foreach ( $post_ids as $post_id ) { | 
                                                        |
| 374 | + $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );  | 
                                                        |
| 375 | + }  | 
                                                        |
| 376 | 376 | |
| 377 | -			if ( $success ) { | 
                                                        |
| 378 | - getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );  | 
                                                        |
| 379 | -			} else { | 
                                                        |
| 380 | - getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );  | 
                                                        |
| 381 | - }  | 
                                                        |
| 377 | +            if ( $success ) { | 
                                                        |
| 378 | + getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );  | 
                                                        |
| 379 | +            } else { | 
                                                        |
| 380 | + getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );  | 
                                                        |
| 381 | + }  | 
                                                        |
| 382 | 382 | |
| 383 | - }  | 
                                                        |
| 383 | + }  | 
                                                        |
| 384 | 384 | |
| 385 | - return $redirect_url;  | 
                                                        |
| 385 | + return $redirect_url;  | 
                                                        |
| 386 | 386 | |
| 387 | - }  | 
                                                        |
| 387 | + }  | 
                                                        |
| 388 | 388 | |
| 389 | - /**  | 
                                                        |
| 390 | - * Returns an array of payment forms table columns.  | 
                                                        |
| 391 | - */  | 
                                                        |
| 392 | -	public static function payment_form_columns( $columns ) { | 
                                                        |
| 389 | + /**  | 
                                                        |
| 390 | + * Returns an array of payment forms table columns.  | 
                                                        |
| 391 | + */  | 
                                                        |
| 392 | +    public static function payment_form_columns( $columns ) { | 
                                                        |
| 393 | 393 | |
| 394 | - $columns = array(  | 
                                                        |
| 395 | - 'cb' => $columns['cb'],  | 
                                                        |
| 396 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 397 | - 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 398 | - 'earnings' => __( 'Revenue', 'invoicing' ),  | 
                                                        |
| 399 | - 'refunds' => __( 'Refunded', 'invoicing' ),  | 
                                                        |
| 400 | - 'items' => __( 'Items', 'invoicing' ),  | 
                                                        |
| 401 | - 'date' => __( 'Date', 'invoicing' ),  | 
                                                        |
| 402 | - );  | 
                                                        |
| 394 | + $columns = array(  | 
                                                        |
| 395 | + 'cb' => $columns['cb'],  | 
                                                        |
| 396 | + 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 397 | + 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 398 | + 'earnings' => __( 'Revenue', 'invoicing' ),  | 
                                                        |
| 399 | + 'refunds' => __( 'Refunded', 'invoicing' ),  | 
                                                        |
| 400 | + 'items' => __( 'Items', 'invoicing' ),  | 
                                                        |
| 401 | + 'date' => __( 'Date', 'invoicing' ),  | 
                                                        |
| 402 | + );  | 
                                                        |
| 403 | 403 | |
| 404 | - return apply_filters( 'wpi_payment_form_table_columns', $columns );  | 
                                                        |
| 404 | + return apply_filters( 'wpi_payment_form_table_columns', $columns );  | 
                                                        |
| 405 | 405 | |
| 406 | - }  | 
                                                        |
| 406 | + }  | 
                                                        |
| 407 | 407 | |
| 408 | - /**  | 
                                                        |
| 409 | - * Displays payment form table columns.  | 
                                                        |
| 410 | - */  | 
                                                        |
| 411 | -	public static function display_payment_form_columns( $column_name, $post_id ) { | 
                                                        |
| 408 | + /**  | 
                                                        |
| 409 | + * Displays payment form table columns.  | 
                                                        |
| 410 | + */  | 
                                                        |
| 411 | +    public static function display_payment_form_columns( $column_name, $post_id ) { | 
                                                        |
| 412 | 412 | |
| 413 | - // Retrieve the payment form.  | 
                                                        |
| 414 | - $form = new GetPaid_Payment_Form( $post_id );  | 
                                                        |
| 413 | + // Retrieve the payment form.  | 
                                                        |
| 414 | + $form = new GetPaid_Payment_Form( $post_id );  | 
                                                        |
| 415 | 415 | |
| 416 | -		switch ( $column_name ) { | 
                                                        |
| 416 | +        switch ( $column_name ) { | 
                                                        |
| 417 | 417 | |
| 418 | - case 'earnings' :  | 
                                                        |
| 419 | - echo wpinv_price( $form->get_earned() );  | 
                                                        |
| 420 | - break;  | 
                                                        |
| 418 | + case 'earnings' :  | 
                                                        |
| 419 | + echo wpinv_price( $form->get_earned() );  | 
                                                        |
| 420 | + break;  | 
                                                        |
| 421 | 421 | |
| 422 | - case 'refunds' :  | 
                                                        |
| 423 | - echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 424 | - break;  | 
                                                        |
| 422 | + case 'refunds' :  | 
                                                        |
| 423 | + echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 424 | + break;  | 
                                                        |
| 425 | 425 | |
| 426 | - case 'refunds' :  | 
                                                        |
| 427 | - echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 428 | - break;  | 
                                                        |
| 426 | + case 'refunds' :  | 
                                                        |
| 427 | + echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 428 | + break;  | 
                                                        |
| 429 | 429 | |
| 430 | - case 'shortcode' :  | 
                                                        |
| 430 | + case 'shortcode' :  | 
                                                        |
| 431 | 431 | |
| 432 | -				if ( $form->is_default() ) { | 
                                                        |
| 433 | - echo '—';  | 
                                                        |
| 434 | -				} else { | 
                                                        |
| 435 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';  | 
                                                        |
| 436 | - }  | 
                                                        |
| 432 | +                if ( $form->is_default() ) { | 
                                                        |
| 433 | + echo '—';  | 
                                                        |
| 434 | +                } else { | 
                                                        |
| 435 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';  | 
                                                        |
| 436 | + }  | 
                                                        |
| 437 | 437 | |
| 438 | - break;  | 
                                                        |
| 438 | + break;  | 
                                                        |
| 439 | 439 | |
| 440 | - case 'items' :  | 
                                                        |
| 440 | + case 'items' :  | 
                                                        |
| 441 | 441 | |
| 442 | - $items = $form->get_items();  | 
                                                        |
| 442 | + $items = $form->get_items();  | 
                                                        |
| 443 | 443 | |
| 444 | -				if ( $form->is_default() || empty( $items ) ) { | 
                                                        |
| 445 | - echo '—';  | 
                                                        |
| 446 | - return;  | 
                                                        |
| 447 | - }  | 
                                                        |
| 444 | +                if ( $form->is_default() || empty( $items ) ) { | 
                                                        |
| 445 | + echo '—';  | 
                                                        |
| 446 | + return;  | 
                                                        |
| 447 | + }  | 
                                                        |
| 448 | 448 | |
| 449 | - $_items = array();  | 
                                                        |
| 449 | + $_items = array();  | 
                                                        |
| 450 | 450 | |
| 451 | -				foreach ( $items as $item ) { | 
                                                        |
| 452 | - $url = $item->get_edit_url();  | 
                                                        |
| 451 | +                foreach ( $items as $item ) { | 
                                                        |
| 452 | + $url = $item->get_edit_url();  | 
                                                        |
| 453 | 453 | |
| 454 | -					if ( empty( $url ) ) { | 
                                                        |
| 455 | - $_items[] = esc_html( $item->get_name() );  | 
                                                        |
| 456 | -					} else { | 
                                                        |
| 457 | - $_items[] = sprintf(  | 
                                                        |
| 458 | - '<a href="%s">%s</a>',  | 
                                                        |
| 459 | - esc_url( $url ),  | 
                                                        |
| 460 | - esc_html( $item->get_name() )  | 
                                                        |
| 461 | - );  | 
                                                        |
| 462 | - }  | 
                                                        |
| 454 | +                    if ( empty( $url ) ) { | 
                                                        |
| 455 | + $_items[] = esc_html( $item->get_name() );  | 
                                                        |
| 456 | +                    } else { | 
                                                        |
| 457 | + $_items[] = sprintf(  | 
                                                        |
| 458 | + '<a href="%s">%s</a>',  | 
                                                        |
| 459 | + esc_url( $url ),  | 
                                                        |
| 460 | + esc_html( $item->get_name() )  | 
                                                        |
| 461 | + );  | 
                                                        |
| 462 | + }  | 
                                                        |
| 463 | 463 | |
| 464 | - }  | 
                                                        |
| 464 | + }  | 
                                                        |
| 465 | 465 | |
| 466 | - echo implode( '<br>', $_items );  | 
                                                        |
| 466 | + echo implode( '<br>', $_items );  | 
                                                        |
| 467 | 467 | |
| 468 | - break;  | 
                                                        |
| 468 | + break;  | 
                                                        |
| 469 | 469 | |
| 470 | - }  | 
                                                        |
| 470 | + }  | 
                                                        |
| 471 | 471 | |
| 472 | - }  | 
                                                        |
| 472 | + }  | 
                                                        |
| 473 | 473 | |
| 474 | - /**  | 
                                                        |
| 475 | - * Filters post states.  | 
                                                        |
| 476 | - */  | 
                                                        |
| 477 | -	public static function filter_payment_form_state( $post_states, $post ) { | 
                                                        |
| 474 | + /**  | 
                                                        |
| 475 | + * Filters post states.  | 
                                                        |
| 476 | + */  | 
                                                        |
| 477 | +    public static function filter_payment_form_state( $post_states, $post ) { | 
                                                        |
| 478 | 478 | |
| 479 | -		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { | 
                                                        |
| 480 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );  | 
                                                        |
| 481 | - }  | 
                                                        |
| 479 | +        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { | 
                                                        |
| 480 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );  | 
                                                        |
| 481 | + }  | 
                                                        |
| 482 | 482 | |
| 483 | - return $post_states;  | 
                                                        |
| 484 | -  | 
                                                        |
| 485 | - }  | 
                                                        |
| 486 | -  | 
                                                        |
| 487 | - /**  | 
                                                        |
| 488 | - * Returns an array of coupon table columns.  | 
                                                        |
| 489 | - */  | 
                                                        |
| 490 | -	public static function discount_columns( $columns ) { | 
                                                        |
| 491 | -  | 
                                                        |
| 492 | - $columns = array(  | 
                                                        |
| 493 | - 'cb' => $columns['cb'],  | 
                                                        |
| 494 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 495 | - 'code' => __( 'Code', 'invoicing' ),  | 
                                                        |
| 496 | - 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 497 | - 'usage' => __( 'Usage / Limit', 'invoicing' ),  | 
                                                        |
| 498 | - 'start_date' => __( 'Start Date', 'invoicing' ),  | 
                                                        |
| 499 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ),  | 
                                                        |
| 500 | - );  | 
                                                        |
| 501 | -  | 
                                                        |
| 502 | - return apply_filters( 'wpi_discount_table_columns', $columns );  | 
                                                        |
| 503 | - }  | 
                                                        |
| 504 | -  | 
                                                        |
| 505 | - /**  | 
                                                        |
| 506 | - * Filters post states.  | 
                                                        |
| 507 | - */  | 
                                                        |
| 508 | -	public static function filter_discount_state( $post_states, $post ) { | 
                                                        |
| 509 | -  | 
                                                        |
| 510 | -		if ( 'wpi_discount' == $post->post_type ) { | 
                                                        |
| 511 | -  | 
                                                        |
| 512 | - $discount = new WPInv_Discount( $post );  | 
                                                        |
| 513 | -  | 
                                                        |
| 514 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status();  | 
                                                        |
| 515 | -  | 
                                                        |
| 516 | -			if ( $status != 'publish' ) { | 
                                                        |
| 517 | - return array(  | 
                                                        |
| 518 | - 'discount_status' => wpinv_discount_status( $status ),  | 
                                                        |
| 519 | - );  | 
                                                        |
| 520 | - }  | 
                                                        |
| 521 | -  | 
                                                        |
| 522 | - return array();  | 
                                                        |
| 523 | -  | 
                                                        |
| 524 | - }  | 
                                                        |
| 525 | -  | 
                                                        |
| 526 | - return $post_states;  | 
                                                        |
| 527 | -  | 
                                                        |
| 528 | - }  | 
                                                        |
| 529 | -  | 
                                                        |
| 530 | - /**  | 
                                                        |
| 531 | - * Returns an array of items table columns.  | 
                                                        |
| 532 | - */  | 
                                                        |
| 533 | -	public static function item_columns( $columns ) { | 
                                                        |
| 534 | -  | 
                                                        |
| 535 | - $columns = array(  | 
                                                        |
| 536 | - 'cb' => $columns['cb'],  | 
                                                        |
| 537 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 538 | - 'price' => __( 'Price', 'invoicing' ),  | 
                                                        |
| 539 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ),  | 
                                                        |
| 540 | - 'vat_class' => __( 'VAT class', 'invoicing' ),  | 
                                                        |
| 541 | - 'type' => __( 'Type', 'invoicing' ),  | 
                                                        |
| 542 | - 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 543 | - );  | 
                                                        |
| 544 | -  | 
                                                        |
| 545 | -		if ( ! wpinv_use_taxes() ) { | 
                                                        |
| 546 | - unset( $columns['vat_rule'] );  | 
                                                        |
| 547 | - unset( $columns['vat_class'] );  | 
                                                        |
| 548 | - }  | 
                                                        |
| 549 | -  | 
                                                        |
| 550 | - return apply_filters( 'wpi_item_table_columns', $columns );  | 
                                                        |
| 551 | - }  | 
                                                        |
| 552 | -  | 
                                                        |
| 553 | - /**  | 
                                                        |
| 554 | - * Returns an array of sortable items table columns.  | 
                                                        |
| 555 | - */  | 
                                                        |
| 556 | -	public static function sortable_item_columns( $columns ) { | 
                                                        |
| 557 | -  | 
                                                        |
| 558 | - return array_merge(  | 
                                                        |
| 559 | - $columns,  | 
                                                        |
| 560 | - array(  | 
                                                        |
| 561 | - 'price' => 'price',  | 
                                                        |
| 562 | - 'vat_rule' => 'vat_rule',  | 
                                                        |
| 563 | - 'vat_class' => 'vat_class',  | 
                                                        |
| 564 | - 'type' => 'type',  | 
                                                        |
| 565 | - )  | 
                                                        |
| 566 | - );  | 
                                                        |
| 567 | -  | 
                                                        |
| 568 | - }  | 
                                                        |
| 569 | -  | 
                                                        |
| 570 | - /**  | 
                                                        |
| 571 | - * Displays items table columns.  | 
                                                        |
| 572 | - */  | 
                                                        |
| 573 | -	public static function display_item_columns( $column_name, $post_id ) { | 
                                                        |
| 483 | + return $post_states;  | 
                                                        |
| 484 | +  | 
                                                        |
| 485 | + }  | 
                                                        |
| 486 | +  | 
                                                        |
| 487 | + /**  | 
                                                        |
| 488 | + * Returns an array of coupon table columns.  | 
                                                        |
| 489 | + */  | 
                                                        |
| 490 | +    public static function discount_columns( $columns ) { | 
                                                        |
| 491 | +  | 
                                                        |
| 492 | + $columns = array(  | 
                                                        |
| 493 | + 'cb' => $columns['cb'],  | 
                                                        |
| 494 | + 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 495 | + 'code' => __( 'Code', 'invoicing' ),  | 
                                                        |
| 496 | + 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 497 | + 'usage' => __( 'Usage / Limit', 'invoicing' ),  | 
                                                        |
| 498 | + 'start_date' => __( 'Start Date', 'invoicing' ),  | 
                                                        |
| 499 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ),  | 
                                                        |
| 500 | + );  | 
                                                        |
| 501 | +  | 
                                                        |
| 502 | + return apply_filters( 'wpi_discount_table_columns', $columns );  | 
                                                        |
| 503 | + }  | 
                                                        |
| 504 | +  | 
                                                        |
| 505 | + /**  | 
                                                        |
| 506 | + * Filters post states.  | 
                                                        |
| 507 | + */  | 
                                                        |
| 508 | +    public static function filter_discount_state( $post_states, $post ) { | 
                                                        |
| 509 | +  | 
                                                        |
| 510 | +        if ( 'wpi_discount' == $post->post_type ) { | 
                                                        |
| 511 | +  | 
                                                        |
| 512 | + $discount = new WPInv_Discount( $post );  | 
                                                        |
| 513 | +  | 
                                                        |
| 514 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status();  | 
                                                        |
| 515 | +  | 
                                                        |
| 516 | +            if ( $status != 'publish' ) { | 
                                                        |
| 517 | + return array(  | 
                                                        |
| 518 | + 'discount_status' => wpinv_discount_status( $status ),  | 
                                                        |
| 519 | + );  | 
                                                        |
| 520 | + }  | 
                                                        |
| 521 | +  | 
                                                        |
| 522 | + return array();  | 
                                                        |
| 523 | +  | 
                                                        |
| 524 | + }  | 
                                                        |
| 525 | +  | 
                                                        |
| 526 | + return $post_states;  | 
                                                        |
| 527 | +  | 
                                                        |
| 528 | + }  | 
                                                        |
| 529 | +  | 
                                                        |
| 530 | + /**  | 
                                                        |
| 531 | + * Returns an array of items table columns.  | 
                                                        |
| 532 | + */  | 
                                                        |
| 533 | +    public static function item_columns( $columns ) { | 
                                                        |
| 534 | +  | 
                                                        |
| 535 | + $columns = array(  | 
                                                        |
| 536 | + 'cb' => $columns['cb'],  | 
                                                        |
| 537 | + 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 538 | + 'price' => __( 'Price', 'invoicing' ),  | 
                                                        |
| 539 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ),  | 
                                                        |
| 540 | + 'vat_class' => __( 'VAT class', 'invoicing' ),  | 
                                                        |
| 541 | + 'type' => __( 'Type', 'invoicing' ),  | 
                                                        |
| 542 | + 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 543 | + );  | 
                                                        |
| 544 | +  | 
                                                        |
| 545 | +        if ( ! wpinv_use_taxes() ) { | 
                                                        |
| 546 | + unset( $columns['vat_rule'] );  | 
                                                        |
| 547 | + unset( $columns['vat_class'] );  | 
                                                        |
| 548 | + }  | 
                                                        |
| 549 | +  | 
                                                        |
| 550 | + return apply_filters( 'wpi_item_table_columns', $columns );  | 
                                                        |
| 551 | + }  | 
                                                        |
| 552 | +  | 
                                                        |
| 553 | + /**  | 
                                                        |
| 554 | + * Returns an array of sortable items table columns.  | 
                                                        |
| 555 | + */  | 
                                                        |
| 556 | +    public static function sortable_item_columns( $columns ) { | 
                                                        |
| 557 | +  | 
                                                        |
| 558 | + return array_merge(  | 
                                                        |
| 559 | + $columns,  | 
                                                        |
| 560 | + array(  | 
                                                        |
| 561 | + 'price' => 'price',  | 
                                                        |
| 562 | + 'vat_rule' => 'vat_rule',  | 
                                                        |
| 563 | + 'vat_class' => 'vat_class',  | 
                                                        |
| 564 | + 'type' => 'type',  | 
                                                        |
| 565 | + )  | 
                                                        |
| 566 | + );  | 
                                                        |
| 567 | +  | 
                                                        |
| 568 | + }  | 
                                                        |
| 569 | +  | 
                                                        |
| 570 | + /**  | 
                                                        |
| 571 | + * Displays items table columns.  | 
                                                        |
| 572 | + */  | 
                                                        |
| 573 | +    public static function display_item_columns( $column_name, $post_id ) { | 
                                                        |
| 574 | 574 | |
| 575 | - $item = new WPInv_Item( $post_id );  | 
                                                        |
| 575 | + $item = new WPInv_Item( $post_id );  | 
                                                        |
| 576 | 576 | |
| 577 | -		switch ( $column_name ) { | 
                                                        |
| 577 | +        switch ( $column_name ) { | 
                                                        |
| 578 | 578 | |
| 579 | - case 'price' :  | 
                                                        |
| 579 | + case 'price' :  | 
                                                        |
| 580 | 580 | |
| 581 | -				if ( ! $item->is_recurring() ) { | 
                                                        |
| 582 | - echo $item->get_the_price();  | 
                                                        |
| 583 | - break;  | 
                                                        |
| 584 | - }  | 
                                                        |
| 581 | +                if ( ! $item->is_recurring() ) { | 
                                                        |
| 582 | + echo $item->get_the_price();  | 
                                                        |
| 583 | + break;  | 
                                                        |
| 584 | + }  | 
                                                        |
| 585 | 585 | |
| 586 | - $price = wp_sprintf(  | 
                                                        |
| 587 | - __( '%s / %s', 'invoicing' ),  | 
                                                        |
| 588 | - $item->get_the_price(),  | 
                                                        |
| 589 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )  | 
                                                        |
| 590 | - );  | 
                                                        |
| 586 | + $price = wp_sprintf(  | 
                                                        |
| 587 | + __( '%s / %s', 'invoicing' ),  | 
                                                        |
| 588 | + $item->get_the_price(),  | 
                                                        |
| 589 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )  | 
                                                        |
| 590 | + );  | 
                                                        |
| 591 | 591 | |
| 592 | -				if ( $item->get_the_price() == $item->get_the_initial_price() ) { | 
                                                        |
| 593 | - echo $price;  | 
                                                        |
| 594 | - break;  | 
                                                        |
| 595 | - }  | 
                                                        |
| 592 | +                if ( $item->get_the_price() == $item->get_the_initial_price() ) { | 
                                                        |
| 593 | + echo $price;  | 
                                                        |
| 594 | + break;  | 
                                                        |
| 595 | + }  | 
                                                        |
| 596 | 596 | |
| 597 | - echo $item->get_the_initial_price();  | 
                                                        |
| 597 | + echo $item->get_the_initial_price();  | 
                                                        |
| 598 | 598 | |
| 599 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>';  | 
                                                        |
| 600 | - break;  | 
                                                        |
| 599 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>';  | 
                                                        |
| 600 | + break;  | 
                                                        |
| 601 | 601 | |
| 602 | - case 'vat_rule' :  | 
                                                        |
| 603 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() );  | 
                                                        |
| 604 | - break;  | 
                                                        |
| 602 | + case 'vat_rule' :  | 
                                                        |
| 603 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() );  | 
                                                        |
| 604 | + break;  | 
                                                        |
| 605 | 605 | |
| 606 | - case 'vat_class' :  | 
                                                        |
| 607 | - echo getpaid_get_tax_class_label( $item->get_vat_class() );  | 
                                                        |
| 608 | - break;  | 
                                                        |
| 606 | + case 'vat_class' :  | 
                                                        |
| 607 | + echo getpaid_get_tax_class_label( $item->get_vat_class() );  | 
                                                        |
| 608 | + break;  | 
                                                        |
| 609 | 609 | |
| 610 | - case 'shortcode' :  | 
                                                        |
| 611 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';  | 
                                                        |
| 612 | - break;  | 
                                                        |
| 610 | + case 'shortcode' :  | 
                                                        |
| 611 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';  | 
                                                        |
| 612 | + break;  | 
                                                        |
| 613 | 613 | |
| 614 | - case 'type' :  | 
                                                        |
| 615 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';  | 
                                                        |
| 616 | - break;  | 
                                                        |
| 614 | + case 'type' :  | 
                                                        |
| 615 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';  | 
                                                        |
| 616 | + break;  | 
                                                        |
| 617 | 617 | |
| 618 | - }  | 
                                                        |
| 618 | + }  | 
                                                        |
| 619 | 619 | |
| 620 | - }  | 
                                                        |
| 620 | + }  | 
                                                        |
| 621 | 621 | |
| 622 | - /**  | 
                                                        |
| 623 | - * Lets users filter items using taxes.  | 
                                                        |
| 624 | - */  | 
                                                        |
| 625 | -	public static function add_item_filters( $post_type ) { | 
                                                        |
| 622 | + /**  | 
                                                        |
| 623 | + * Lets users filter items using taxes.  | 
                                                        |
| 624 | + */  | 
                                                        |
| 625 | +    public static function add_item_filters( $post_type ) { | 
                                                        |
| 626 | 626 | |
| 627 | - // Abort if we're not dealing with items.  | 
                                                        |
| 628 | -		if ( $post_type != 'wpi_item' ) { | 
                                                        |
| 629 | - return;  | 
                                                        |
| 630 | - }  | 
                                                        |
| 627 | + // Abort if we're not dealing with items.  | 
                                                        |
| 628 | +        if ( $post_type != 'wpi_item' ) { | 
                                                        |
| 629 | + return;  | 
                                                        |
| 630 | + }  | 
                                                        |
| 631 | 631 | |
| 632 | - // Filter by vat rules.  | 
                                                        |
| 633 | -		if ( wpinv_use_taxes() ) { | 
                                                        |
| 632 | + // Filter by vat rules.  | 
                                                        |
| 633 | +        if ( wpinv_use_taxes() ) { | 
                                                        |
| 634 | 634 | |
| 635 | - // Sanitize selected vat rule.  | 
                                                        |
| 636 | - $vat_rule = '';  | 
                                                        |
| 637 | - $vat_rules = getpaid_get_tax_rules();  | 
                                                        |
| 638 | -			if ( isset( $_GET['vat_rule'] ) ) { | 
                                                        |
| 639 | - $vat_rule = $_GET['vat_rule'];  | 
                                                        |
| 640 | - }  | 
                                                        |
| 641 | -  | 
                                                        |
| 642 | - // Filter by VAT rule.  | 
                                                        |
| 643 | - echo wpinv_html_select(  | 
                                                        |
| 644 | - array(  | 
                                                        |
| 645 | - 'options' => array_merge(  | 
                                                        |
| 646 | - array(  | 
                                                        |
| 647 | - '' => __( 'All VAT rules', 'invoicing' )  | 
                                                        |
| 648 | - ),  | 
                                                        |
| 649 | - $vat_rules  | 
                                                        |
| 650 | - ),  | 
                                                        |
| 651 | - 'name' => 'vat_rule',  | 
                                                        |
| 652 | - 'id' => 'vat_rule',  | 
                                                        |
| 653 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',  | 
                                                        |
| 654 | - 'show_option_all' => false,  | 
                                                        |
| 655 | - 'show_option_none' => false,  | 
                                                        |
| 656 | - )  | 
                                                        |
| 657 | - );  | 
                                                        |
| 658 | -  | 
                                                        |
| 659 | - // Filter by VAT class.  | 
                                                        |
| 635 | + // Sanitize selected vat rule.  | 
                                                        |
| 636 | + $vat_rule = '';  | 
                                                        |
| 637 | + $vat_rules = getpaid_get_tax_rules();  | 
                                                        |
| 638 | +            if ( isset( $_GET['vat_rule'] ) ) { | 
                                                        |
| 639 | + $vat_rule = $_GET['vat_rule'];  | 
                                                        |
| 640 | + }  | 
                                                        |
| 641 | +  | 
                                                        |
| 642 | + // Filter by VAT rule.  | 
                                                        |
| 643 | + echo wpinv_html_select(  | 
                                                        |
| 644 | + array(  | 
                                                        |
| 645 | + 'options' => array_merge(  | 
                                                        |
| 646 | + array(  | 
                                                        |
| 647 | + '' => __( 'All VAT rules', 'invoicing' )  | 
                                                        |
| 648 | + ),  | 
                                                        |
| 649 | + $vat_rules  | 
                                                        |
| 650 | + ),  | 
                                                        |
| 651 | + 'name' => 'vat_rule',  | 
                                                        |
| 652 | + 'id' => 'vat_rule',  | 
                                                        |
| 653 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',  | 
                                                        |
| 654 | + 'show_option_all' => false,  | 
                                                        |
| 655 | + 'show_option_none' => false,  | 
                                                        |
| 656 | + )  | 
                                                        |
| 657 | + );  | 
                                                        |
| 658 | +  | 
                                                        |
| 659 | + // Filter by VAT class.  | 
                                                        |
| 660 | 660 | |
| 661 | - // Sanitize selected vat rule.  | 
                                                        |
| 662 | - $vat_class = '';  | 
                                                        |
| 663 | - $vat_classes = getpaid_get_tax_classes();  | 
                                                        |
| 664 | -			if ( isset( $_GET['vat_class'] ) ) { | 
                                                        |
| 665 | - $vat_class = $_GET['vat_class'];  | 
                                                        |
| 666 | - }  | 
                                                        |
| 667 | -  | 
                                                        |
| 668 | - echo wpinv_html_select(  | 
                                                        |
| 669 | - array(  | 
                                                        |
| 670 | - 'options' => array_merge(  | 
                                                        |
| 671 | - array(  | 
                                                        |
| 672 | - '' => __( 'All VAT classes', 'invoicing' )  | 
                                                        |
| 673 | - ),  | 
                                                        |
| 674 | - $vat_classes  | 
                                                        |
| 675 | - ),  | 
                                                        |
| 676 | - 'name' => 'vat_class',  | 
                                                        |
| 677 | - 'id' => 'vat_class',  | 
                                                        |
| 678 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',  | 
                                                        |
| 679 | - 'show_option_all' => false,  | 
                                                        |
| 680 | - 'show_option_none' => false,  | 
                                                        |
| 681 | - )  | 
                                                        |
| 682 | - );  | 
                                                        |
| 683 | -  | 
                                                        |
| 684 | - }  | 
                                                        |
| 685 | -  | 
                                                        |
| 686 | - // Filter by item type.  | 
                                                        |
| 687 | - $type = '';  | 
                                                        |
| 688 | -		if ( isset( $_GET['type'] ) ) { | 
                                                        |
| 689 | - $type = $_GET['type'];  | 
                                                        |
| 690 | - }  | 
                                                        |
| 691 | -  | 
                                                        |
| 692 | - echo wpinv_html_select(  | 
                                                        |
| 693 | - array(  | 
                                                        |
| 694 | - 'options' => array_merge(  | 
                                                        |
| 695 | - array(  | 
                                                        |
| 696 | - '' => __( 'All item types', 'invoicing' )  | 
                                                        |
| 697 | - ),  | 
                                                        |
| 698 | - wpinv_get_item_types()  | 
                                                        |
| 699 | - ),  | 
                                                        |
| 700 | - 'name' => 'type',  | 
                                                        |
| 701 | - 'id' => 'type',  | 
                                                        |
| 702 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '',  | 
                                                        |
| 703 | - 'show_option_all' => false,  | 
                                                        |
| 704 | - 'show_option_none' => false,  | 
                                                        |
| 705 | - )  | 
                                                        |
| 706 | - );  | 
                                                        |
| 707 | -  | 
                                                        |
| 708 | - }  | 
                                                        |
| 709 | -  | 
                                                        |
| 710 | - /**  | 
                                                        |
| 711 | - * Filters the item query.  | 
                                                        |
| 712 | - */  | 
                                                        |
| 713 | -	public static function filter_item_query( $query ) { | 
                                                        |
| 714 | -  | 
                                                        |
| 715 | - // modify the query only if it admin and main query.  | 
                                                        |
| 716 | -		if ( ! ( is_admin() && $query->is_main_query() ) ){  | 
                                                        |
| 717 | - return $query;  | 
                                                        |
| 718 | - }  | 
                                                        |
| 719 | -  | 
                                                        |
| 720 | - // we want to modify the query for our items.  | 
                                                        |
| 721 | -		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ | 
                                                        |
| 722 | - return $query;  | 
                                                        |
| 723 | - }  | 
                                                        |
| 724 | -  | 
                                                        |
| 725 | -		if ( empty( $query->query_vars['meta_query'] ) ) { | 
                                                        |
| 726 | - $query->query_vars['meta_query'] = array();  | 
                                                        |
| 727 | - }  | 
                                                        |
| 728 | -  | 
                                                        |
| 729 | - // Filter vat rule type  | 
                                                        |
| 661 | + // Sanitize selected vat rule.  | 
                                                        |
| 662 | + $vat_class = '';  | 
                                                        |
| 663 | + $vat_classes = getpaid_get_tax_classes();  | 
                                                        |
| 664 | +            if ( isset( $_GET['vat_class'] ) ) { | 
                                                        |
| 665 | + $vat_class = $_GET['vat_class'];  | 
                                                        |
| 666 | + }  | 
                                                        |
| 667 | +  | 
                                                        |
| 668 | + echo wpinv_html_select(  | 
                                                        |
| 669 | + array(  | 
                                                        |
| 670 | + 'options' => array_merge(  | 
                                                        |
| 671 | + array(  | 
                                                        |
| 672 | + '' => __( 'All VAT classes', 'invoicing' )  | 
                                                        |
| 673 | + ),  | 
                                                        |
| 674 | + $vat_classes  | 
                                                        |
| 675 | + ),  | 
                                                        |
| 676 | + 'name' => 'vat_class',  | 
                                                        |
| 677 | + 'id' => 'vat_class',  | 
                                                        |
| 678 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',  | 
                                                        |
| 679 | + 'show_option_all' => false,  | 
                                                        |
| 680 | + 'show_option_none' => false,  | 
                                                        |
| 681 | + )  | 
                                                        |
| 682 | + );  | 
                                                        |
| 683 | +  | 
                                                        |
| 684 | + }  | 
                                                        |
| 685 | +  | 
                                                        |
| 686 | + // Filter by item type.  | 
                                                        |
| 687 | + $type = '';  | 
                                                        |
| 688 | +        if ( isset( $_GET['type'] ) ) { | 
                                                        |
| 689 | + $type = $_GET['type'];  | 
                                                        |
| 690 | + }  | 
                                                        |
| 691 | +  | 
                                                        |
| 692 | + echo wpinv_html_select(  | 
                                                        |
| 693 | + array(  | 
                                                        |
| 694 | + 'options' => array_merge(  | 
                                                        |
| 695 | + array(  | 
                                                        |
| 696 | + '' => __( 'All item types', 'invoicing' )  | 
                                                        |
| 697 | + ),  | 
                                                        |
| 698 | + wpinv_get_item_types()  | 
                                                        |
| 699 | + ),  | 
                                                        |
| 700 | + 'name' => 'type',  | 
                                                        |
| 701 | + 'id' => 'type',  | 
                                                        |
| 702 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '',  | 
                                                        |
| 703 | + 'show_option_all' => false,  | 
                                                        |
| 704 | + 'show_option_none' => false,  | 
                                                        |
| 705 | + )  | 
                                                        |
| 706 | + );  | 
                                                        |
| 707 | +  | 
                                                        |
| 708 | + }  | 
                                                        |
| 709 | +  | 
                                                        |
| 710 | + /**  | 
                                                        |
| 711 | + * Filters the item query.  | 
                                                        |
| 712 | + */  | 
                                                        |
| 713 | +    public static function filter_item_query( $query ) { | 
                                                        |
| 714 | +  | 
                                                        |
| 715 | + // modify the query only if it admin and main query.  | 
                                                        |
| 716 | +        if ( ! ( is_admin() && $query->is_main_query() ) ){  | 
                                                        |
| 717 | + return $query;  | 
                                                        |
| 718 | + }  | 
                                                        |
| 719 | +  | 
                                                        |
| 720 | + // we want to modify the query for our items.  | 
                                                        |
| 721 | +        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ | 
                                                        |
| 722 | + return $query;  | 
                                                        |
| 723 | + }  | 
                                                        |
| 724 | +  | 
                                                        |
| 725 | +        if ( empty( $query->query_vars['meta_query'] ) ) { | 
                                                        |
| 726 | + $query->query_vars['meta_query'] = array();  | 
                                                        |
| 727 | + }  | 
                                                        |
| 728 | +  | 
                                                        |
| 729 | + // Filter vat rule type  | 
                                                        |
| 730 | 730 |          if ( ! empty( $_GET['vat_rule'] ) ) { | 
                                                        
| 731 | 731 | $query->query_vars['meta_query'][] = array(  | 
                                                        
| 732 | 732 | 'key' => '_wpinv_vat_rule',  | 
                                                        
@@ -751,97 +751,97 @@ discard block  | 
                                                    ||
| 751 | 751 | 'value' => sanitize_text_field( $_GET['type'] ),  | 
                                                        
| 752 | 752 | 'compare' => '='  | 
                                                        
| 753 | 753 | );  | 
                                                        
| 754 | - }  | 
                                                        |
| 755 | -  | 
                                                        |
| 756 | - }  | 
                                                        |
| 757 | -  | 
                                                        |
| 758 | - /**  | 
                                                        |
| 759 | - * Reorders items.  | 
                                                        |
| 760 | - */  | 
                                                        |
| 761 | -	public static function reorder_items( $vars ) { | 
                                                        |
| 762 | - global $typenow;  | 
                                                        |
| 763 | -  | 
                                                        |
| 764 | -		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { | 
                                                        |
| 765 | - return $vars;  | 
                                                        |
| 766 | - }  | 
                                                        |
| 767 | -  | 
                                                        |
| 768 | - // By item type.  | 
                                                        |
| 769 | -		if ( 'type' == $vars['orderby'] ) { | 
                                                        |
| 770 | - return array_merge(  | 
                                                        |
| 771 | - $vars,  | 
                                                        |
| 772 | - array(  | 
                                                        |
| 773 | - 'meta_key' => '_wpinv_type',  | 
                                                        |
| 774 | - 'orderby' => 'meta_value'  | 
                                                        |
| 775 | - )  | 
                                                        |
| 776 | - );  | 
                                                        |
| 777 | - }  | 
                                                        |
| 778 | -  | 
                                                        |
| 779 | - // By vat class.  | 
                                                        |
| 780 | -		if ( 'vat_class' == $vars['orderby'] ) { | 
                                                        |
| 781 | - return array_merge(  | 
                                                        |
| 782 | - $vars,  | 
                                                        |
| 783 | - array(  | 
                                                        |
| 784 | - 'meta_key' => '_wpinv_vat_class',  | 
                                                        |
| 785 | - 'orderby' => 'meta_value'  | 
                                                        |
| 786 | - )  | 
                                                        |
| 787 | - );  | 
                                                        |
| 788 | - }  | 
                                                        |
| 789 | -  | 
                                                        |
| 790 | - // By vat rule.  | 
                                                        |
| 791 | -		if ( 'vat_rule' == $vars['orderby'] ) { | 
                                                        |
| 792 | - return array_merge(  | 
                                                        |
| 793 | - $vars,  | 
                                                        |
| 794 | - array(  | 
                                                        |
| 795 | - 'meta_key' => '_wpinv_vat_rule',  | 
                                                        |
| 796 | - 'orderby' => 'meta_value'  | 
                                                        |
| 797 | - )  | 
                                                        |
| 798 | - );  | 
                                                        |
| 799 | - }  | 
                                                        |
| 800 | -  | 
                                                        |
| 801 | - // By price.  | 
                                                        |
| 802 | -		if ( 'price' == $vars['orderby'] ) { | 
                                                        |
| 803 | - return array_merge(  | 
                                                        |
| 804 | - $vars,  | 
                                                        |
| 805 | - array(  | 
                                                        |
| 806 | - 'meta_key' => '_wpinv_price',  | 
                                                        |
| 807 | - 'orderby' => 'meta_value_num'  | 
                                                        |
| 808 | - )  | 
                                                        |
| 809 | - );  | 
                                                        |
| 810 | - }  | 
                                                        |
| 811 | -  | 
                                                        |
| 812 | - return $vars;  | 
                                                        |
| 813 | -  | 
                                                        |
| 814 | - }  | 
                                                        |
| 815 | -  | 
                                                        |
| 816 | - /**  | 
                                                        |
| 817 | - * Fired when deleting a post.  | 
                                                        |
| 818 | - */  | 
                                                        |
| 819 | -	public static function delete_post( $post_id ) { | 
                                                        |
| 820 | -  | 
                                                        |
| 821 | -		switch ( get_post_type( $post_id ) ) { | 
                                                        |
| 822 | -  | 
                                                        |
| 823 | - case 'wpi_item' :  | 
                                                        |
| 824 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );  | 
                                                        |
| 825 | - break;  | 
                                                        |
| 826 | -  | 
                                                        |
| 827 | - case 'wpi_payment_form' :  | 
                                                        |
| 828 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );  | 
                                                        |
| 829 | - break;  | 
                                                        |
| 830 | -  | 
                                                        |
| 831 | - case 'wpi_discount' :  | 
                                                        |
| 832 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );  | 
                                                        |
| 833 | - break;  | 
                                                        |
| 834 | -  | 
                                                        |
| 835 | - case 'wpi_invoice' :  | 
                                                        |
| 836 | - $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 837 | - do_action( "getpaid_before_delete_invoice", $invoice );  | 
                                                        |
| 838 | - $invoice->get_data_store()->delete_items( $invoice );  | 
                                                        |
| 839 | - $invoice->get_data_store()->delete_special_fields( $invoice );  | 
                                                        |
| 840 | - break;  | 
                                                        |
| 841 | - }  | 
                                                        |
| 842 | - }  | 
                                                        |
| 843 | -  | 
                                                        |
| 844 | - /**  | 
                                                        |
| 754 | + }  | 
                                                        |
| 755 | +  | 
                                                        |
| 756 | + }  | 
                                                        |
| 757 | +  | 
                                                        |
| 758 | + /**  | 
                                                        |
| 759 | + * Reorders items.  | 
                                                        |
| 760 | + */  | 
                                                        |
| 761 | +    public static function reorder_items( $vars ) { | 
                                                        |
| 762 | + global $typenow;  | 
                                                        |
| 763 | +  | 
                                                        |
| 764 | +        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { | 
                                                        |
| 765 | + return $vars;  | 
                                                        |
| 766 | + }  | 
                                                        |
| 767 | +  | 
                                                        |
| 768 | + // By item type.  | 
                                                        |
| 769 | +        if ( 'type' == $vars['orderby'] ) { | 
                                                        |
| 770 | + return array_merge(  | 
                                                        |
| 771 | + $vars,  | 
                                                        |
| 772 | + array(  | 
                                                        |
| 773 | + 'meta_key' => '_wpinv_type',  | 
                                                        |
| 774 | + 'orderby' => 'meta_value'  | 
                                                        |
| 775 | + )  | 
                                                        |
| 776 | + );  | 
                                                        |
| 777 | + }  | 
                                                        |
| 778 | +  | 
                                                        |
| 779 | + // By vat class.  | 
                                                        |
| 780 | +        if ( 'vat_class' == $vars['orderby'] ) { | 
                                                        |
| 781 | + return array_merge(  | 
                                                        |
| 782 | + $vars,  | 
                                                        |
| 783 | + array(  | 
                                                        |
| 784 | + 'meta_key' => '_wpinv_vat_class',  | 
                                                        |
| 785 | + 'orderby' => 'meta_value'  | 
                                                        |
| 786 | + )  | 
                                                        |
| 787 | + );  | 
                                                        |
| 788 | + }  | 
                                                        |
| 789 | +  | 
                                                        |
| 790 | + // By vat rule.  | 
                                                        |
| 791 | +        if ( 'vat_rule' == $vars['orderby'] ) { | 
                                                        |
| 792 | + return array_merge(  | 
                                                        |
| 793 | + $vars,  | 
                                                        |
| 794 | + array(  | 
                                                        |
| 795 | + 'meta_key' => '_wpinv_vat_rule',  | 
                                                        |
| 796 | + 'orderby' => 'meta_value'  | 
                                                        |
| 797 | + )  | 
                                                        |
| 798 | + );  | 
                                                        |
| 799 | + }  | 
                                                        |
| 800 | +  | 
                                                        |
| 801 | + // By price.  | 
                                                        |
| 802 | +        if ( 'price' == $vars['orderby'] ) { | 
                                                        |
| 803 | + return array_merge(  | 
                                                        |
| 804 | + $vars,  | 
                                                        |
| 805 | + array(  | 
                                                        |
| 806 | + 'meta_key' => '_wpinv_price',  | 
                                                        |
| 807 | + 'orderby' => 'meta_value_num'  | 
                                                        |
| 808 | + )  | 
                                                        |
| 809 | + );  | 
                                                        |
| 810 | + }  | 
                                                        |
| 811 | +  | 
                                                        |
| 812 | + return $vars;  | 
                                                        |
| 813 | +  | 
                                                        |
| 814 | + }  | 
                                                        |
| 815 | +  | 
                                                        |
| 816 | + /**  | 
                                                        |
| 817 | + * Fired when deleting a post.  | 
                                                        |
| 818 | + */  | 
                                                        |
| 819 | +    public static function delete_post( $post_id ) { | 
                                                        |
| 820 | +  | 
                                                        |
| 821 | +        switch ( get_post_type( $post_id ) ) { | 
                                                        |
| 822 | +  | 
                                                        |
| 823 | + case 'wpi_item' :  | 
                                                        |
| 824 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );  | 
                                                        |
| 825 | + break;  | 
                                                        |
| 826 | +  | 
                                                        |
| 827 | + case 'wpi_payment_form' :  | 
                                                        |
| 828 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );  | 
                                                        |
| 829 | + break;  | 
                                                        |
| 830 | +  | 
                                                        |
| 831 | + case 'wpi_discount' :  | 
                                                        |
| 832 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );  | 
                                                        |
| 833 | + break;  | 
                                                        |
| 834 | +  | 
                                                        |
| 835 | + case 'wpi_invoice' :  | 
                                                        |
| 836 | + $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 837 | + do_action( "getpaid_before_delete_invoice", $invoice );  | 
                                                        |
| 838 | + $invoice->get_data_store()->delete_items( $invoice );  | 
                                                        |
| 839 | + $invoice->get_data_store()->delete_special_fields( $invoice );  | 
                                                        |
| 840 | + break;  | 
                                                        |
| 841 | + }  | 
                                                        |
| 842 | + }  | 
                                                        |
| 843 | +  | 
                                                        |
| 844 | + /**  | 
                                                        |
| 845 | 845 | * Add a post display state for special GetPaid pages in the page list table.  | 
                                                        
| 846 | 846 | *  | 
                                                        
| 847 | 847 | * @param array $post_states An array of post display states.  | 
                                                        
@@ -855,22 +855,22 @@ discard block  | 
                                                    ||
| 855 | 855 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );  | 
                                                        
| 856 | 856 | }  | 
                                                        
| 857 | 857 | |
| 858 | -		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { | 
                                                        |
| 858 | +        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { | 
                                                        |
| 859 | 859 | |
| 860 | -			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { | 
                                                        |
| 861 | -				$post_states["getpaid_{$post_type}_history_page"] = sprintf( | 
                                                        |
| 862 | - __( 'GetPaid %s History Page', 'invoicing' ),  | 
                                                        |
| 863 | - $label  | 
                                                        |
| 864 | - );  | 
                                                        |
| 865 | - }  | 
                                                        |
| 860 | +            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { | 
                                                        |
| 861 | +                $post_states["getpaid_{$post_type}_history_page"] = sprintf( | 
                                                        |
| 862 | + __( 'GetPaid %s History Page', 'invoicing' ),  | 
                                                        |
| 863 | + $label  | 
                                                        |
| 864 | + );  | 
                                                        |
| 865 | + }  | 
                                                        |
| 866 | 866 | |
| 867 | - }  | 
                                                        |
| 867 | + }  | 
                                                        |
| 868 | 868 | |
| 869 | -		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { | 
                                                        |
| 869 | +        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { | 
                                                        |
| 870 | 870 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );  | 
                                                        
| 871 | 871 | }  | 
                                                        
| 872 | 872 | |
| 873 | -		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { | 
                                                        |
| 873 | +        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { | 
                                                        |
| 874 | 874 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );  | 
                                                        
| 875 | 875 | }  | 
                                                        
| 876 | 876 | |
@@ -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,7 +124,7 @@ 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 | }  | 
                                                        
@@ -140,31 +140,31 @@ discard block  | 
                                                    ||
| 140 | 140 | * @param WP_Post $post  | 
                                                        
| 141 | 141 | * @return array $actions actions without edit option  | 
                                                        
| 142 | 142 | */  | 
                                                        
| 143 | -    public static function filter_invoice_row_actions( $actions, $post ) { | 
                                                        |
| 143 | +    public static function filter_invoice_row_actions($actions, $post) { | 
                                                        |
| 144 | 144 | |
| 145 | -        if ( getpaid_is_invoice_post_type( $post->post_type ) ) { | 
                                                        |
| 145 | +        if (getpaid_is_invoice_post_type($post->post_type)) { | 
                                                        |
| 146 | 146 | |
| 147 | 147 | $actions = array();  | 
                                                        
| 148 | - $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 148 | + $invoice = new WPInv_Invoice($post);  | 
                                                        |
| 149 | 149 | |
| 150 | - $actions['edit'] = sprintf(  | 
                                                        |
| 150 | + $actions['edit'] = sprintf(  | 
                                                        |
| 151 | 151 | '<a href="%1$s">%2$s</a>',  | 
                                                        
| 152 | - esc_url( get_edit_post_link( $invoice->get_id() ) ),  | 
                                                        |
| 153 | - esc_html( __( 'Edit', 'invoicing' ) )  | 
                                                        |
| 152 | + esc_url(get_edit_post_link($invoice->get_id())),  | 
                                                        |
| 153 | +				esc_html(__('Edit', 'invoicing')) | 
                                                        |
| 154 | 154 | );  | 
                                                        
| 155 | 155 | |
| 156 | -			if ( ! $invoice->is_draft() ) { | 
                                                        |
| 156 | +			if (!$invoice->is_draft()) { | 
                                                        |
| 157 | 157 | |
| 158 | - $actions['view'] = sprintf(  | 
                                                        |
| 158 | + $actions['view'] = sprintf(  | 
                                                        |
| 159 | 159 | '<a href="%1$s">%2$s</a>',  | 
                                                        
| 160 | - esc_url( $invoice->get_view_url() ),  | 
                                                        |
| 160 | + esc_url($invoice->get_view_url()),  | 
                                                        |
| 161 | 161 | sprintf(  | 
                                                        
| 162 | - esc_html( __( 'View %s', 'invoicing' ) ),  | 
                                                        |
| 163 | - getpaid_get_post_type_label( $invoice->get_post_type(), false )  | 
                                                        |
| 162 | +						esc_html(__('View %s', 'invoicing')), | 
                                                        |
| 163 | + getpaid_get_post_type_label($invoice->get_post_type(), false)  | 
                                                        |
| 164 | 164 | )  | 
                                                        
| 165 | 165 | );  | 
                                                        
| 166 | 166 | |
| 167 | - $actions['send'] = sprintf(  | 
                                                        |
| 167 | + $actions['send'] = sprintf(  | 
                                                        |
| 168 | 168 | '<a href="%1$s">%2$s</a>',  | 
                                                        
| 169 | 169 | esc_url(  | 
                                                        
| 170 | 170 | wp_nonce_url(  | 
                                                        
@@ -178,12 +178,12 @@ discard block  | 
                                                    ||
| 178 | 178 | 'getpaid-nonce'  | 
                                                        
| 179 | 179 | )  | 
                                                        
| 180 | 180 | ),  | 
                                                        
| 181 | - esc_html( __( 'Send to Customer', 'invoicing' ) )  | 
                                                        |
| 181 | +					esc_html(__('Send to Customer', 'invoicing')) | 
                                                        |
| 182 | 182 | );  | 
                                                        
| 183 | 183 | |
| 184 | 184 | }  | 
                                                        
| 185 | 185 | |
| 186 | - $actions['duplicate'] = sprintf(  | 
                                                        |
| 186 | + $actions['duplicate'] = sprintf(  | 
                                                        |
| 187 | 187 | '<a href="%1$s">%2$s</a>',  | 
                                                        
| 188 | 188 | esc_url(  | 
                                                        
| 189 | 189 | wp_nonce_url(  | 
                                                        
@@ -197,7 +197,7 @@ discard block  | 
                                                    ||
| 197 | 197 | 'getpaid-nonce'  | 
                                                        
| 198 | 198 | )  | 
                                                        
| 199 | 199 | ),  | 
                                                        
| 200 | - esc_html( __( 'Duplicate', 'invoicing' ) )  | 
                                                        |
| 200 | +				esc_html(__('Duplicate', 'invoicing')) | 
                                                        |
| 201 | 201 | );  | 
                                                        
| 202 | 202 | |
| 203 | 203 | }  | 
                                                        
@@ -208,42 +208,42 @@ discard block  | 
                                                    ||
| 208 | 208 | /**  | 
                                                        
| 209 | 209 | * Returns an array of invoice table columns.  | 
                                                        
| 210 | 210 | */  | 
                                                        
| 211 | -	public static function invoice_columns( $columns ) { | 
                                                        |
| 211 | +	public static function invoice_columns($columns) { | 
                                                        |
| 212 | 212 | |
| 213 | 213 | $columns = array(  | 
                                                        
| 214 | 214 | 'cb' => $columns['cb'],  | 
                                                        
| 215 | - 'number' => __( 'Invoice', 'invoicing' ),  | 
                                                        |
| 216 | - 'customer' => __( 'Customer', 'invoicing' ),  | 
                                                        |
| 217 | - 'invoice_date' => __( 'Created', 'invoicing' ),  | 
                                                        |
| 218 | - 'payment_date' => __( 'Completed', 'invoicing' ),  | 
                                                        |
| 219 | - 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 220 | - 'recurring' => __( 'Recurring', 'invoicing' ),  | 
                                                        |
| 221 | - 'status' => __( 'Status', 'invoicing' ),  | 
                                                        |
| 215 | +			'number'            => __('Invoice', 'invoicing'), | 
                                                        |
| 216 | +			'customer'          => __('Customer', 'invoicing'), | 
                                                        |
| 217 | +			'invoice_date'      => __('Created', 'invoicing'), | 
                                                        |
| 218 | +			'payment_date'      => __('Completed', 'invoicing'), | 
                                                        |
| 219 | +			'amount'            => __('Amount', 'invoicing'), | 
                                                        |
| 220 | +			'recurring'         => __('Recurring', 'invoicing'), | 
                                                        |
| 221 | +			'status'            => __('Status', 'invoicing'), | 
                                                        |
| 222 | 222 | );  | 
                                                        
| 223 | 223 | |
| 224 | - return apply_filters( 'wpi_invoice_table_columns', $columns );  | 
                                                        |
| 224 | +		return apply_filters('wpi_invoice_table_columns', $columns); | 
                                                        |
| 225 | 225 | }  | 
                                                        
| 226 | 226 | |
| 227 | 227 | /**  | 
                                                        
| 228 | 228 | * Displays invoice table columns.  | 
                                                        
| 229 | 229 | */  | 
                                                        
| 230 | -	public static function display_invoice_columns( $column_name, $post_id ) { | 
                                                        |
| 230 | +	public static function display_invoice_columns($column_name, $post_id) { | 
                                                        |
| 231 | 231 | |
| 232 | - $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 232 | + $invoice = new WPInv_Invoice($post_id);  | 
                                                        |
| 233 | 233 | |
| 234 | -		switch ( $column_name ) { | 
                                                        |
| 234 | +		switch ($column_name) { | 
                                                        |
| 235 | 235 | |
| 236 | 236 | case 'invoice_date' :  | 
                                                        
| 237 | - $date_time = esc_attr( $invoice->get_created_date() );  | 
                                                        |
| 238 | - $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 237 | + $date_time = esc_attr($invoice->get_created_date());  | 
                                                        |
| 238 | + $date = getpaid_format_date_value($date_time, "—", true);  | 
                                                        |
| 239 | 239 | echo "<span title='$date_time'>$date</span>";  | 
                                                        
| 240 | 240 | break;  | 
                                                        
| 241 | 241 | |
| 242 | 242 | case 'payment_date' :  | 
                                                        
| 243 | 243 | |
| 244 | -				if ( $invoice->is_paid() ) { | 
                                                        |
| 245 | - $date_time = esc_attr( $invoice->get_completed_date() );  | 
                                                        |
| 246 | - $date = getpaid_format_date_value( $date_time, "—", true );  | 
                                                        |
| 244 | +				if ($invoice->is_paid()) { | 
                                                        |
| 245 | + $date_time = esc_attr($invoice->get_completed_date());  | 
                                                        |
| 246 | + $date = getpaid_format_date_value($date_time, "—", true);  | 
                                                        |
| 247 | 247 | echo "<span title='$date_time'>$date</span>";  | 
                                                        
| 248 | 248 |  				} else { | 
                                                        
| 249 | 249 | echo "—";  | 
                                                        
@@ -254,17 +254,17 @@ discard block  | 
                                                    ||
| 254 | 254 | case 'amount' :  | 
                                                        
| 255 | 255 | |
| 256 | 256 | $amount = $invoice->get_total();  | 
                                                        
| 257 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() );  | 
                                                        |
| 257 | + $formated_amount = wpinv_price($amount, $invoice->get_currency());  | 
                                                        |
| 258 | 258 | |
| 259 | -				if ( $invoice->is_refunded() ) { | 
                                                        |
| 260 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() );  | 
                                                        |
| 259 | +				if ($invoice->is_refunded()) { | 
                                                        |
| 260 | + $refunded_amount = wpinv_price(0, $invoice->get_currency());  | 
                                                        |
| 261 | 261 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>";  | 
                                                        
| 262 | 262 |  				} else { | 
                                                        
| 263 | 263 | |
| 264 | 264 | $discount = $invoice->get_total_discount();  | 
                                                        
| 265 | 265 | |
| 266 | -					if ( ! empty( $discount ) ) { | 
                                                        |
| 267 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );  | 
                                                        |
| 266 | +					if (!empty($discount)) { | 
                                                        |
| 267 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency());  | 
                                                        |
| 268 | 268 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>";  | 
                                                        
| 269 | 269 |  					} else { | 
                                                        
| 270 | 270 | echo $formated_amount;  | 
                                                        
@@ -275,13 +275,13 @@ discard block  | 
                                                    ||
| 275 | 275 | break;  | 
                                                        
| 276 | 276 | |
| 277 | 277 | case 'status' :  | 
                                                        
| 278 | - $status = esc_html( $invoice->get_status() );  | 
                                                        |
| 279 | - $status_label = esc_html( $invoice->get_status_nicename() );  | 
                                                        |
| 278 | + $status = esc_html($invoice->get_status());  | 
                                                        |
| 279 | + $status_label = esc_html($invoice->get_status_nicename());  | 
                                                        |
| 280 | 280 | |
| 281 | 281 | // If it is paid, show the gateway title.  | 
                                                        
| 282 | -				if ( $invoice->is_paid() ) { | 
                                                        |
| 283 | - $gateway = esc_html( $invoice->get_gateway_title() );  | 
                                                        |
| 284 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );  | 
                                                        |
| 282 | +				if ($invoice->is_paid()) { | 
                                                        |
| 283 | + $gateway = esc_html($invoice->get_gateway_title());  | 
                                                        |
| 284 | +					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); | 
                                                        |
| 285 | 285 | |
| 286 | 286 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";  | 
                                                        
| 287 | 287 |  				} else { | 
                                                        
@@ -289,22 +289,22 @@ discard block  | 
                                                    ||
| 289 | 289 | }  | 
                                                        
| 290 | 290 | |
| 291 | 291 | // If it is not paid, display the overdue and view status.  | 
                                                        
| 292 | -				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { | 
                                                        |
| 292 | +				if (!$invoice->is_paid() && !$invoice->is_refunded()) { | 
                                                        |
| 293 | 293 | |
| 294 | 294 | // Invoice view status.  | 
                                                        
| 295 | -					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { | 
                                                        |
| 296 | - echo '  <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 295 | +					if (wpinv_is_invoice_viewed($invoice->get_id())) { | 
                                                        |
| 296 | +						echo '  <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; | 
                                                        |
| 297 | 297 |  					} else { | 
                                                        
| 298 | - echo '  <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';  | 
                                                        |
| 298 | +						echo '  <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; | 
                                                        |
| 299 | 299 | }  | 
                                                        
| 300 | 300 | |
| 301 | 301 | // Display the overview status.  | 
                                                        
| 302 | -					if ( wpinv_get_option( 'overdue_active' ) ) { | 
                                                        |
| 302 | +					if (wpinv_get_option('overdue_active')) { | 
                                                        |
| 303 | 303 | $due_date = $invoice->get_due_date();  | 
                                                        
| 304 | - $fomatted = getpaid_format_date( $due_date );  | 
                                                        |
| 304 | + $fomatted = getpaid_format_date($due_date);  | 
                                                        |
| 305 | 305 | |
| 306 | -						if ( ! empty( $fomatted ) ) { | 
                                                        |
| 307 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );  | 
                                                        |
| 306 | +						if (!empty($fomatted)) { | 
                                                        |
| 307 | +							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); | 
                                                        |
| 308 | 308 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";  | 
                                                        
| 309 | 309 | }  | 
                                                        
| 310 | 310 | }  | 
                                                        
@@ -315,7 +315,7 @@ discard block  | 
                                                    ||
| 315 | 315 | |
| 316 | 316 | case 'recurring':  | 
                                                        
| 317 | 317 | |
| 318 | -				if ( $invoice->is_recurring() ) { | 
                                                        |
| 318 | +				if ($invoice->is_recurring()) { | 
                                                        |
| 319 | 319 | echo '<i class="fa fa-check" style="color:#43850a;"></i>';  | 
                                                        
| 320 | 320 |  				} else { | 
                                                        
| 321 | 321 | echo '<i class="fa fa-times" style="color:#616161;"></i>';  | 
                                                        
@@ -324,9 +324,9 @@ discard block  | 
                                                    ||
| 324 | 324 | |
| 325 | 325 | case 'number' :  | 
                                                        
| 326 | 326 | |
| 327 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) );  | 
                                                        |
| 328 | - $invoice_number = esc_html( $invoice->get_number() );  | 
                                                        |
| 329 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );  | 
                                                        |
| 327 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id()));  | 
                                                        |
| 328 | + $invoice_number = esc_html($invoice->get_number());  | 
                                                        |
| 329 | +				$invoice_details = esc_attr__('View Invoice Details', 'invoicing'); | 
                                                        |
| 330 | 330 | |
| 331 | 331 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";  | 
                                                        
| 332 | 332 | |
@@ -336,13 +336,13 @@ discard block  | 
                                                    ||
| 336 | 336 | |
| 337 | 337 | $customer_name = $invoice->get_user_full_name();  | 
                                                        
| 338 | 338 | |
| 339 | -				if ( empty( $customer_name ) ) { | 
                                                        |
| 339 | +				if (empty($customer_name)) { | 
                                                        |
| 340 | 340 | $customer_name = $invoice->get_email();  | 
                                                        
| 341 | 341 | }  | 
                                                        
| 342 | 342 | |
| 343 | -				if ( ! empty( $customer_name ) ) { | 
                                                        |
| 344 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );  | 
                                                        |
| 345 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );  | 
                                                        |
| 343 | +				if (!empty($customer_name)) { | 
                                                        |
| 344 | +					$customer_details = esc_attr__('View Customer Details', 'invoicing'); | 
                                                        |
| 345 | +					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); | 
                                                        |
| 346 | 346 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";  | 
                                                        
| 347 | 347 |  				} else { | 
                                                        
| 348 | 348 | echo '<div>—</div>';  | 
                                                        
@@ -357,27 +357,27 @@ discard block  | 
                                                    ||
| 357 | 357 | /**  | 
                                                        
| 358 | 358 | * Displays invoice bulk actions.  | 
                                                        
| 359 | 359 | */  | 
                                                        
| 360 | -	public static function invoice_bulk_actions( $actions ) { | 
                                                        |
| 361 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );  | 
                                                        |
| 360 | +	public static function invoice_bulk_actions($actions) { | 
                                                        |
| 361 | +		$actions['resend-invoice'] = __('Send to Customer', 'invoicing'); | 
                                                        |
| 362 | 362 | return $actions;  | 
                                                        
| 363 | 363 | }  | 
                                                        
| 364 | 364 | |
| 365 | 365 | /**  | 
                                                        
| 366 | 366 | * Processes invoice bulk actions.  | 
                                                        
| 367 | 367 | */  | 
                                                        
| 368 | -	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { | 
                                                        |
| 368 | +	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { | 
                                                        |
| 369 | 369 | |
| 370 | -		if ( $action == 'resend-invoice' ) { | 
                                                        |
| 370 | +		if ($action == 'resend-invoice') { | 
                                                        |
| 371 | 371 | |
| 372 | 372 | $success = false;  | 
                                                        
| 373 | -			foreach ( $post_ids as $post_id ) { | 
                                                        |
| 374 | - $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );  | 
                                                        |
| 373 | +			foreach ($post_ids as $post_id) { | 
                                                        |
| 374 | +				$success = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); | 
                                                        |
| 375 | 375 | }  | 
                                                        
| 376 | 376 | |
| 377 | -			if ( $success ) { | 
                                                        |
| 378 | - getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );  | 
                                                        |
| 377 | +			if ($success) { | 
                                                        |
| 378 | +				getpaid_admin()->show_success(__('Invoices were successfully sent', 'invoicing')); | 
                                                        |
| 379 | 379 |  			} else { | 
                                                        
| 380 | - getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );  | 
                                                        |
| 380 | +				getpaid_admin()->show_error(__('Could not send some invoices', 'invoicing')); | 
                                                        |
| 381 | 381 | }  | 
                                                        
| 382 | 382 | |
| 383 | 383 | }  | 
                                                        
@@ -389,50 +389,50 @@ discard block  | 
                                                    ||
| 389 | 389 | /**  | 
                                                        
| 390 | 390 | * Returns an array of payment forms table columns.  | 
                                                        
| 391 | 391 | */  | 
                                                        
| 392 | -	public static function payment_form_columns( $columns ) { | 
                                                        |
| 392 | +	public static function payment_form_columns($columns) { | 
                                                        |
| 393 | 393 | |
| 394 | 394 | $columns = array(  | 
                                                        
| 395 | 395 | 'cb' => $columns['cb'],  | 
                                                        
| 396 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 397 | - 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 398 | - 'earnings' => __( 'Revenue', 'invoicing' ),  | 
                                                        |
| 399 | - 'refunds' => __( 'Refunded', 'invoicing' ),  | 
                                                        |
| 400 | - 'items' => __( 'Items', 'invoicing' ),  | 
                                                        |
| 401 | - 'date' => __( 'Date', 'invoicing' ),  | 
                                                        |
| 396 | +			'title'             => __('Name', 'invoicing'), | 
                                                        |
| 397 | +			'shortcode'         => __('Shortcode', 'invoicing'), | 
                                                        |
| 398 | +			'earnings'          => __('Revenue', 'invoicing'), | 
                                                        |
| 399 | +			'refunds'           => __('Refunded', 'invoicing'), | 
                                                        |
| 400 | +			'items'             => __('Items', 'invoicing'), | 
                                                        |
| 401 | +			'date'              => __('Date', 'invoicing'), | 
                                                        |
| 402 | 402 | );  | 
                                                        
| 403 | 403 | |
| 404 | - return apply_filters( 'wpi_payment_form_table_columns', $columns );  | 
                                                        |
| 404 | +		return apply_filters('wpi_payment_form_table_columns', $columns); | 
                                                        |
| 405 | 405 | |
| 406 | 406 | }  | 
                                                        
| 407 | 407 | |
| 408 | 408 | /**  | 
                                                        
| 409 | 409 | * Displays payment form table columns.  | 
                                                        
| 410 | 410 | */  | 
                                                        
| 411 | -	public static function display_payment_form_columns( $column_name, $post_id ) { | 
                                                        |
| 411 | +	public static function display_payment_form_columns($column_name, $post_id) { | 
                                                        |
| 412 | 412 | |
| 413 | 413 | // Retrieve the payment form.  | 
                                                        
| 414 | - $form = new GetPaid_Payment_Form( $post_id );  | 
                                                        |
| 414 | + $form = new GetPaid_Payment_Form($post_id);  | 
                                                        |
| 415 | 415 | |
| 416 | -		switch ( $column_name ) { | 
                                                        |
| 416 | +		switch ($column_name) { | 
                                                        |
| 417 | 417 | |
| 418 | 418 | case 'earnings' :  | 
                                                        
| 419 | - echo wpinv_price( $form->get_earned() );  | 
                                                        |
| 419 | + echo wpinv_price($form->get_earned());  | 
                                                        |
| 420 | 420 | break;  | 
                                                        
| 421 | 421 | |
| 422 | 422 | case 'refunds' :  | 
                                                        
| 423 | - echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 423 | + echo wpinv_price($form->get_refunded());  | 
                                                        |
| 424 | 424 | break;  | 
                                                        
| 425 | 425 | |
| 426 | 426 | case 'refunds' :  | 
                                                        
| 427 | - echo wpinv_price( $form->get_refunded() );  | 
                                                        |
| 427 | + echo wpinv_price($form->get_refunded());  | 
                                                        |
| 428 | 428 | break;  | 
                                                        
| 429 | 429 | |
| 430 | 430 | case 'shortcode' :  | 
                                                        
| 431 | 431 | |
| 432 | -				if ( $form->is_default() ) { | 
                                                        |
| 432 | +				if ($form->is_default()) { | 
                                                        |
| 433 | 433 | echo '—';  | 
                                                        
| 434 | 434 |  				} else { | 
                                                        
| 435 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';  | 
                                                        |
| 435 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';  | 
                                                        |
| 436 | 436 | }  | 
                                                        
| 437 | 437 | |
| 438 | 438 | break;  | 
                                                        
@@ -441,29 +441,29 @@ discard block  | 
                                                    ||
| 441 | 441 | |
| 442 | 442 | $items = $form->get_items();  | 
                                                        
| 443 | 443 | |
| 444 | -				if ( $form->is_default() || empty( $items ) ) { | 
                                                        |
| 444 | +				if ($form->is_default() || empty($items)) { | 
                                                        |
| 445 | 445 | echo '—';  | 
                                                        
| 446 | 446 | return;  | 
                                                        
| 447 | 447 | }  | 
                                                        
| 448 | 448 | |
| 449 | 449 | $_items = array();  | 
                                                        
| 450 | 450 | |
| 451 | -				foreach ( $items as $item ) { | 
                                                        |
| 451 | +				foreach ($items as $item) { | 
                                                        |
| 452 | 452 | $url = $item->get_edit_url();  | 
                                                        
| 453 | 453 | |
| 454 | -					if ( empty( $url ) ) { | 
                                                        |
| 455 | - $_items[] = esc_html( $item->get_name() );  | 
                                                        |
| 454 | +					if (empty($url)) { | 
                                                        |
| 455 | + $_items[] = esc_html($item->get_name());  | 
                                                        |
| 456 | 456 |  					} else { | 
                                                        
| 457 | 457 | $_items[] = sprintf(  | 
                                                        
| 458 | 458 | '<a href="%s">%s</a>',  | 
                                                        
| 459 | - esc_url( $url ),  | 
                                                        |
| 460 | - esc_html( $item->get_name() )  | 
                                                        |
| 459 | + esc_url($url),  | 
                                                        |
| 460 | + esc_html($item->get_name())  | 
                                                        |
| 461 | 461 | );  | 
                                                        
| 462 | 462 | }  | 
                                                        
| 463 | 463 | |
| 464 | 464 | }  | 
                                                        
| 465 | 465 | |
| 466 | - echo implode( '<br>', $_items );  | 
                                                        |
| 466 | +				echo implode('<br>', $_items); | 
                                                        |
| 467 | 467 | |
| 468 | 468 | break;  | 
                                                        
| 469 | 469 | |
@@ -474,10 +474,10 @@ discard block  | 
                                                    ||
| 474 | 474 | /**  | 
                                                        
| 475 | 475 | * Filters post states.  | 
                                                        
| 476 | 476 | */  | 
                                                        
| 477 | -	public static function filter_payment_form_state( $post_states, $post ) { | 
                                                        |
| 477 | +	public static function filter_payment_form_state($post_states, $post) { | 
                                                        |
| 478 | 478 | |
| 479 | -		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { | 
                                                        |
| 480 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );  | 
                                                        |
| 479 | +		if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { | 
                                                        |
| 480 | +			$post_states['default_form'] = __('Default Payment Form', 'invoicing'); | 
                                                        |
| 481 | 481 | }  | 
                                                        
| 482 | 482 | |
| 483 | 483 | return $post_states;  | 
                                                        
@@ -487,35 +487,35 @@ discard block  | 
                                                    ||
| 487 | 487 | /**  | 
                                                        
| 488 | 488 | * Returns an array of coupon table columns.  | 
                                                        
| 489 | 489 | */  | 
                                                        
| 490 | -	public static function discount_columns( $columns ) { | 
                                                        |
| 490 | +	public static function discount_columns($columns) { | 
                                                        |
| 491 | 491 | |
| 492 | 492 | $columns = array(  | 
                                                        
| 493 | 493 | 'cb' => $columns['cb'],  | 
                                                        
| 494 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 495 | - 'code' => __( 'Code', 'invoicing' ),  | 
                                                        |
| 496 | - 'amount' => __( 'Amount', 'invoicing' ),  | 
                                                        |
| 497 | - 'usage' => __( 'Usage / Limit', 'invoicing' ),  | 
                                                        |
| 498 | - 'start_date' => __( 'Start Date', 'invoicing' ),  | 
                                                        |
| 499 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ),  | 
                                                        |
| 494 | +			'title'             => __('Name', 'invoicing'), | 
                                                        |
| 495 | +			'code'              => __('Code', 'invoicing'), | 
                                                        |
| 496 | +			'amount'            => __('Amount', 'invoicing'), | 
                                                        |
| 497 | +			'usage'             => __('Usage / Limit', 'invoicing'), | 
                                                        |
| 498 | +			'start_date'        => __('Start Date', 'invoicing'), | 
                                                        |
| 499 | +			'expiry_date'       => __('Expiry Date', 'invoicing'), | 
                                                        |
| 500 | 500 | );  | 
                                                        
| 501 | 501 | |
| 502 | - return apply_filters( 'wpi_discount_table_columns', $columns );  | 
                                                        |
| 502 | +		return apply_filters('wpi_discount_table_columns', $columns); | 
                                                        |
| 503 | 503 | }  | 
                                                        
| 504 | 504 | |
| 505 | 505 | /**  | 
                                                        
| 506 | 506 | * Filters post states.  | 
                                                        
| 507 | 507 | */  | 
                                                        
| 508 | -	public static function filter_discount_state( $post_states, $post ) { | 
                                                        |
| 508 | +	public static function filter_discount_state($post_states, $post) { | 
                                                        |
| 509 | 509 | |
| 510 | -		if ( 'wpi_discount' == $post->post_type ) { | 
                                                        |
| 510 | +		if ('wpi_discount' == $post->post_type) { | 
                                                        |
| 511 | 511 | |
| 512 | - $discount = new WPInv_Discount( $post );  | 
                                                        |
| 512 | + $discount = new WPInv_Discount($post);  | 
                                                        |
| 513 | 513 | |
| 514 | 514 | $status = $discount->is_expired() ? 'expired' : $discount->get_status();  | 
                                                        
| 515 | 515 | |
| 516 | -			if ( $status != 'publish' ) { | 
                                                        |
| 516 | +			if ($status != 'publish') { | 
                                                        |
| 517 | 517 | return array(  | 
                                                        
| 518 | - 'discount_status' => wpinv_discount_status( $status ),  | 
                                                        |
| 518 | + 'discount_status' => wpinv_discount_status($status),  | 
                                                        |
| 519 | 519 | );  | 
                                                        
| 520 | 520 | }  | 
                                                        
| 521 | 521 | |
@@ -530,30 +530,30 @@ discard block  | 
                                                    ||
| 530 | 530 | /**  | 
                                                        
| 531 | 531 | * Returns an array of items table columns.  | 
                                                        
| 532 | 532 | */  | 
                                                        
| 533 | -	public static function item_columns( $columns ) { | 
                                                        |
| 533 | +	public static function item_columns($columns) { | 
                                                        |
| 534 | 534 | |
| 535 | 535 | $columns = array(  | 
                                                        
| 536 | 536 | 'cb' => $columns['cb'],  | 
                                                        
| 537 | - 'title' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 538 | - 'price' => __( 'Price', 'invoicing' ),  | 
                                                        |
| 539 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ),  | 
                                                        |
| 540 | - 'vat_class' => __( 'VAT class', 'invoicing' ),  | 
                                                        |
| 541 | - 'type' => __( 'Type', 'invoicing' ),  | 
                                                        |
| 542 | - 'shortcode' => __( 'Shortcode', 'invoicing' ),  | 
                                                        |
| 537 | +			'title'             => __('Name', 'invoicing'), | 
                                                        |
| 538 | +			'price'             => __('Price', 'invoicing'), | 
                                                        |
| 539 | +			'vat_rule'          => __('VAT rule', 'invoicing'), | 
                                                        |
| 540 | +			'vat_class'         => __('VAT class', 'invoicing'), | 
                                                        |
| 541 | +			'type'              => __('Type', 'invoicing'), | 
                                                        |
| 542 | +			'shortcode'         => __('Shortcode', 'invoicing'), | 
                                                        |
| 543 | 543 | );  | 
                                                        
| 544 | 544 | |
| 545 | -		if ( ! wpinv_use_taxes() ) { | 
                                                        |
| 546 | - unset( $columns['vat_rule'] );  | 
                                                        |
| 547 | - unset( $columns['vat_class'] );  | 
                                                        |
| 545 | +		if (!wpinv_use_taxes()) { | 
                                                        |
| 546 | + unset($columns['vat_rule']);  | 
                                                        |
| 547 | + unset($columns['vat_class']);  | 
                                                        |
| 548 | 548 | }  | 
                                                        
| 549 | 549 | |
| 550 | - return apply_filters( 'wpi_item_table_columns', $columns );  | 
                                                        |
| 550 | +		return apply_filters('wpi_item_table_columns', $columns); | 
                                                        |
| 551 | 551 | }  | 
                                                        
| 552 | 552 | |
| 553 | 553 | /**  | 
                                                        
| 554 | 554 | * Returns an array of sortable items table columns.  | 
                                                        
| 555 | 555 | */  | 
                                                        
| 556 | -	public static function sortable_item_columns( $columns ) { | 
                                                        |
| 556 | +	public static function sortable_item_columns($columns) { | 
                                                        |
| 557 | 557 | |
| 558 | 558 | return array_merge(  | 
                                                        
| 559 | 559 | $columns,  | 
                                                        
@@ -570,49 +570,49 @@ discard block  | 
                                                    ||
| 570 | 570 | /**  | 
                                                        
| 571 | 571 | * Displays items table columns.  | 
                                                        
| 572 | 572 | */  | 
                                                        
| 573 | -	public static function display_item_columns( $column_name, $post_id ) { | 
                                                        |
| 573 | +	public static function display_item_columns($column_name, $post_id) { | 
                                                        |
| 574 | 574 | |
| 575 | - $item = new WPInv_Item( $post_id );  | 
                                                        |
| 575 | + $item = new WPInv_Item($post_id);  | 
                                                        |
| 576 | 576 | |
| 577 | -		switch ( $column_name ) { | 
                                                        |
| 577 | +		switch ($column_name) { | 
                                                        |
| 578 | 578 | |
| 579 | 579 | case 'price' :  | 
                                                        
| 580 | 580 | |
| 581 | -				if ( ! $item->is_recurring() ) { | 
                                                        |
| 581 | +				if (!$item->is_recurring()) { | 
                                                        |
| 582 | 582 | echo $item->get_the_price();  | 
                                                        
| 583 | 583 | break;  | 
                                                        
| 584 | 584 | }  | 
                                                        
| 585 | 585 | |
| 586 | 586 | $price = wp_sprintf(  | 
                                                        
| 587 | - __( '%s / %s', 'invoicing' ),  | 
                                                        |
| 587 | +					__('%s / %s', 'invoicing'), | 
                                                        |
| 588 | 588 | $item->get_the_price(),  | 
                                                        
| 589 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )  | 
                                                        |
| 589 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')  | 
                                                        |
| 590 | 590 | );  | 
                                                        
| 591 | 591 | |
| 592 | -				if ( $item->get_the_price() == $item->get_the_initial_price() ) { | 
                                                        |
| 592 | +				if ($item->get_the_price() == $item->get_the_initial_price()) { | 
                                                        |
| 593 | 593 | echo $price;  | 
                                                        
| 594 | 594 | break;  | 
                                                        
| 595 | 595 | }  | 
                                                        
| 596 | 596 | |
| 597 | 597 | echo $item->get_the_initial_price();  | 
                                                        
| 598 | 598 | |
| 599 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>';  | 
                                                        |
| 599 | +				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; | 
                                                        |
| 600 | 600 | break;  | 
                                                        
| 601 | 601 | |
| 602 | 602 | case 'vat_rule' :  | 
                                                        
| 603 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() );  | 
                                                        |
| 603 | + echo getpaid_get_tax_rule_label($item->get_vat_rule());  | 
                                                        |
| 604 | 604 | break;  | 
                                                        
| 605 | 605 | |
| 606 | 606 | case 'vat_class' :  | 
                                                        
| 607 | - echo getpaid_get_tax_class_label( $item->get_vat_class() );  | 
                                                        |
| 607 | + echo getpaid_get_tax_class_label($item->get_vat_class());  | 
                                                        |
| 608 | 608 | break;  | 
                                                        
| 609 | 609 | |
| 610 | 610 | case 'shortcode' :  | 
                                                        
| 611 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';  | 
                                                        |
| 611 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';  | 
                                                        |
| 612 | 612 | break;  | 
                                                        
| 613 | 613 | |
| 614 | 614 | case 'type' :  | 
                                                        
| 615 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';  | 
                                                        |
| 615 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';  | 
                                                        |
| 616 | 616 | break;  | 
                                                        
| 617 | 617 | |
| 618 | 618 | }  | 
                                                        
@@ -622,21 +622,21 @@ discard block  | 
                                                    ||
| 622 | 622 | /**  | 
                                                        
| 623 | 623 | * Lets users filter items using taxes.  | 
                                                        
| 624 | 624 | */  | 
                                                        
| 625 | -	public static function add_item_filters( $post_type ) { | 
                                                        |
| 625 | +	public static function add_item_filters($post_type) { | 
                                                        |
| 626 | 626 | |
| 627 | 627 | // Abort if we're not dealing with items.  | 
                                                        
| 628 | -		if ( $post_type != 'wpi_item' ) { | 
                                                        |
| 628 | +		if ($post_type != 'wpi_item') { | 
                                                        |
| 629 | 629 | return;  | 
                                                        
| 630 | 630 | }  | 
                                                        
| 631 | 631 | |
| 632 | 632 | // Filter by vat rules.  | 
                                                        
| 633 | -		if ( wpinv_use_taxes() ) { | 
                                                        |
| 633 | +		if (wpinv_use_taxes()) { | 
                                                        |
| 634 | 634 | |
| 635 | 635 | // Sanitize selected vat rule.  | 
                                                        
| 636 | 636 | $vat_rule = '';  | 
                                                        
| 637 | 637 | $vat_rules = getpaid_get_tax_rules();  | 
                                                        
| 638 | -			if ( isset( $_GET['vat_rule'] ) ) { | 
                                                        |
| 639 | - $vat_rule = $_GET['vat_rule'];  | 
                                                        |
| 638 | +			if (isset($_GET['vat_rule'])) { | 
                                                        |
| 639 | + $vat_rule = $_GET['vat_rule'];  | 
                                                        |
| 640 | 640 | }  | 
                                                        
| 641 | 641 | |
| 642 | 642 | // Filter by VAT rule.  | 
                                                        
@@ -644,13 +644,13 @@ discard block  | 
                                                    ||
| 644 | 644 | array(  | 
                                                        
| 645 | 645 | 'options' => array_merge(  | 
                                                        
| 646 | 646 | array(  | 
                                                        
| 647 | - '' => __( 'All VAT rules', 'invoicing' )  | 
                                                        |
| 647 | +							'' => __('All VAT rules', 'invoicing') | 
                                                        |
| 648 | 648 | ),  | 
                                                        
| 649 | 649 | $vat_rules  | 
                                                        
| 650 | 650 | ),  | 
                                                        
| 651 | 651 | 'name' => 'vat_rule',  | 
                                                        
| 652 | 652 | 'id' => 'vat_rule',  | 
                                                        
| 653 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',  | 
                                                        |
| 653 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',  | 
                                                        |
| 654 | 654 | 'show_option_all' => false,  | 
                                                        
| 655 | 655 | 'show_option_none' => false,  | 
                                                        
| 656 | 656 | )  | 
                                                        
@@ -661,21 +661,21 @@ discard block  | 
                                                    ||
| 661 | 661 | // Sanitize selected vat rule.  | 
                                                        
| 662 | 662 | $vat_class = '';  | 
                                                        
| 663 | 663 | $vat_classes = getpaid_get_tax_classes();  | 
                                                        
| 664 | -			if ( isset( $_GET['vat_class'] ) ) { | 
                                                        |
| 665 | - $vat_class = $_GET['vat_class'];  | 
                                                        |
| 664 | +			if (isset($_GET['vat_class'])) { | 
                                                        |
| 665 | + $vat_class = $_GET['vat_class'];  | 
                                                        |
| 666 | 666 | }  | 
                                                        
| 667 | 667 | |
| 668 | 668 | echo wpinv_html_select(  | 
                                                        
| 669 | 669 | array(  | 
                                                        
| 670 | 670 | 'options' => array_merge(  | 
                                                        
| 671 | 671 | array(  | 
                                                        
| 672 | - '' => __( 'All VAT classes', 'invoicing' )  | 
                                                        |
| 672 | +							'' => __('All VAT classes', 'invoicing') | 
                                                        |
| 673 | 673 | ),  | 
                                                        
| 674 | 674 | $vat_classes  | 
                                                        
| 675 | 675 | ),  | 
                                                        
| 676 | 676 | 'name' => 'vat_class',  | 
                                                        
| 677 | 677 | 'id' => 'vat_class',  | 
                                                        
| 678 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',  | 
                                                        |
| 678 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',  | 
                                                        |
| 679 | 679 | 'show_option_all' => false,  | 
                                                        
| 680 | 680 | 'show_option_none' => false,  | 
                                                        
| 681 | 681 | )  | 
                                                        
@@ -684,22 +684,22 @@ discard block  | 
                                                    ||
| 684 | 684 | }  | 
                                                        
| 685 | 685 | |
| 686 | 686 | // Filter by item type.  | 
                                                        
| 687 | - $type = '';  | 
                                                        |
| 688 | -		if ( isset( $_GET['type'] ) ) { | 
                                                        |
| 689 | - $type = $_GET['type'];  | 
                                                        |
| 687 | + $type = '';  | 
                                                        |
| 688 | +		if (isset($_GET['type'])) { | 
                                                        |
| 689 | + $type = $_GET['type'];  | 
                                                        |
| 690 | 690 | }  | 
                                                        
| 691 | 691 | |
| 692 | 692 | echo wpinv_html_select(  | 
                                                        
| 693 | 693 | array(  | 
                                                        
| 694 | 694 | 'options' => array_merge(  | 
                                                        
| 695 | 695 | array(  | 
                                                        
| 696 | - '' => __( 'All item types', 'invoicing' )  | 
                                                        |
| 696 | +						'' => __('All item types', 'invoicing') | 
                                                        |
| 697 | 697 | ),  | 
                                                        
| 698 | 698 | wpinv_get_item_types()  | 
                                                        
| 699 | 699 | ),  | 
                                                        
| 700 | 700 | 'name' => 'type',  | 
                                                        
| 701 | 701 | 'id' => 'type',  | 
                                                        
| 702 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '',  | 
                                                        |
| 702 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '',  | 
                                                        |
| 703 | 703 | 'show_option_all' => false,  | 
                                                        
| 704 | 704 | 'show_option_none' => false,  | 
                                                        
| 705 | 705 | )  | 
                                                        
@@ -710,45 +710,45 @@ discard block  | 
                                                    ||
| 710 | 710 | /**  | 
                                                        
| 711 | 711 | * Filters the item query.  | 
                                                        
| 712 | 712 | */  | 
                                                        
| 713 | -	public static function filter_item_query( $query ) { | 
                                                        |
| 713 | +	public static function filter_item_query($query) { | 
                                                        |
| 714 | 714 | |
| 715 | 715 | // modify the query only if it admin and main query.  | 
                                                        
| 716 | -		if ( ! ( is_admin() && $query->is_main_query() ) ){  | 
                                                        |
| 716 | +		if (!(is_admin() && $query->is_main_query())) {  | 
                                                        |
| 717 | 717 | return $query;  | 
                                                        
| 718 | 718 | }  | 
                                                        
| 719 | 719 | |
| 720 | 720 | // we want to modify the query for our items.  | 
                                                        
| 721 | -		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ | 
                                                        |
| 721 | +		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { | 
                                                        |
| 722 | 722 | return $query;  | 
                                                        
| 723 | 723 | }  | 
                                                        
| 724 | 724 | |
| 725 | -		if ( empty( $query->query_vars['meta_query'] ) ) { | 
                                                        |
| 725 | +		if (empty($query->query_vars['meta_query'])) { | 
                                                        |
| 726 | 726 | $query->query_vars['meta_query'] = array();  | 
                                                        
| 727 | 727 | }  | 
                                                        
| 728 | 728 | |
| 729 | 729 | // Filter vat rule type  | 
                                                        
| 730 | -        if ( ! empty( $_GET['vat_rule'] ) ) { | 
                                                        |
| 730 | +        if (!empty($_GET['vat_rule'])) { | 
                                                        |
| 731 | 731 | $query->query_vars['meta_query'][] = array(  | 
                                                        
| 732 | 732 | 'key' => '_wpinv_vat_rule',  | 
                                                        
| 733 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ),  | 
                                                        |
| 733 | + 'value' => sanitize_text_field($_GET['vat_rule']),  | 
                                                        |
| 734 | 734 | 'compare' => '='  | 
                                                        
| 735 | 735 | );  | 
                                                        
| 736 | 736 | }  | 
                                                        
| 737 | 737 | |
| 738 | 738 | // Filter vat class  | 
                                                        
| 739 | -        if ( ! empty( $_GET['vat_class'] ) ) { | 
                                                        |
| 739 | +        if (!empty($_GET['vat_class'])) { | 
                                                        |
| 740 | 740 | $query->query_vars['meta_query'][] = array(  | 
                                                        
| 741 | 741 | 'key' => '_wpinv_vat_class',  | 
                                                        
| 742 | - 'value' => sanitize_text_field( $_GET['vat_class'] ),  | 
                                                        |
| 742 | + 'value' => sanitize_text_field($_GET['vat_class']),  | 
                                                        |
| 743 | 743 | 'compare' => '='  | 
                                                        
| 744 | 744 | );  | 
                                                        
| 745 | 745 | }  | 
                                                        
| 746 | 746 | |
| 747 | 747 | // Filter item type  | 
                                                        
| 748 | -        if ( ! empty( $_GET['type'] ) ) { | 
                                                        |
| 748 | +        if (!empty($_GET['type'])) { | 
                                                        |
| 749 | 749 | $query->query_vars['meta_query'][] = array(  | 
                                                        
| 750 | 750 | 'key' => '_wpinv_type',  | 
                                                        
| 751 | - 'value' => sanitize_text_field( $_GET['type'] ),  | 
                                                        |
| 751 | + 'value' => sanitize_text_field($_GET['type']),  | 
                                                        |
| 752 | 752 | 'compare' => '='  | 
                                                        
| 753 | 753 | );  | 
                                                        
| 754 | 754 | }  | 
                                                        
@@ -758,15 +758,15 @@ discard block  | 
                                                    ||
| 758 | 758 | /**  | 
                                                        
| 759 | 759 | * Reorders items.  | 
                                                        
| 760 | 760 | */  | 
                                                        
| 761 | -	public static function reorder_items( $vars ) { | 
                                                        |
| 761 | +	public static function reorder_items($vars) { | 
                                                        |
| 762 | 762 | global $typenow;  | 
                                                        
| 763 | 763 | |
| 764 | -		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { | 
                                                        |
| 764 | +		if ('wpi_item' !== $typenow || empty($vars['orderby'])) { | 
                                                        |
| 765 | 765 | return $vars;  | 
                                                        
| 766 | 766 | }  | 
                                                        
| 767 | 767 | |
| 768 | 768 | // By item type.  | 
                                                        
| 769 | -		if ( 'type' == $vars['orderby'] ) { | 
                                                        |
| 769 | +		if ('type' == $vars['orderby']) { | 
                                                        |
| 770 | 770 | return array_merge(  | 
                                                        
| 771 | 771 | $vars,  | 
                                                        
| 772 | 772 | array(  | 
                                                        
@@ -777,7 +777,7 @@ discard block  | 
                                                    ||
| 777 | 777 | }  | 
                                                        
| 778 | 778 | |
| 779 | 779 | // By vat class.  | 
                                                        
| 780 | -		if ( 'vat_class' == $vars['orderby'] ) { | 
                                                        |
| 780 | +		if ('vat_class' == $vars['orderby']) { | 
                                                        |
| 781 | 781 | return array_merge(  | 
                                                        
| 782 | 782 | $vars,  | 
                                                        
| 783 | 783 | array(  | 
                                                        
@@ -788,7 +788,7 @@ discard block  | 
                                                    ||
| 788 | 788 | }  | 
                                                        
| 789 | 789 | |
| 790 | 790 | // By vat rule.  | 
                                                        
| 791 | -		if ( 'vat_rule' == $vars['orderby'] ) { | 
                                                        |
| 791 | +		if ('vat_rule' == $vars['orderby']) { | 
                                                        |
| 792 | 792 | return array_merge(  | 
                                                        
| 793 | 793 | $vars,  | 
                                                        
| 794 | 794 | array(  | 
                                                        
@@ -799,7 +799,7 @@ discard block  | 
                                                    ||
| 799 | 799 | }  | 
                                                        
| 800 | 800 | |
| 801 | 801 | // By price.  | 
                                                        
| 802 | -		if ( 'price' == $vars['orderby'] ) { | 
                                                        |
| 802 | +		if ('price' == $vars['orderby']) { | 
                                                        |
| 803 | 803 | return array_merge(  | 
                                                        
| 804 | 804 | $vars,  | 
                                                        
| 805 | 805 | array(  | 
                                                        
@@ -816,27 +816,27 @@ discard block  | 
                                                    ||
| 816 | 816 | /**  | 
                                                        
| 817 | 817 | * Fired when deleting a post.  | 
                                                        
| 818 | 818 | */  | 
                                                        
| 819 | -	public static function delete_post( $post_id ) { | 
                                                        |
| 819 | +	public static function delete_post($post_id) { | 
                                                        |
| 820 | 820 | |
| 821 | -		switch ( get_post_type( $post_id ) ) { | 
                                                        |
| 821 | +		switch (get_post_type($post_id)) { | 
                                                        |
| 822 | 822 | |
| 823 | 823 | case 'wpi_item' :  | 
                                                        
| 824 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );  | 
                                                        |
| 824 | +				do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); | 
                                                        |
| 825 | 825 | break;  | 
                                                        
| 826 | 826 | |
| 827 | 827 | case 'wpi_payment_form' :  | 
                                                        
| 828 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );  | 
                                                        |
| 828 | +				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); | 
                                                        |
| 829 | 829 | break;  | 
                                                        
| 830 | 830 | |
| 831 | 831 | case 'wpi_discount' :  | 
                                                        
| 832 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );  | 
                                                        |
| 832 | +				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); | 
                                                        |
| 833 | 833 | break;  | 
                                                        
| 834 | 834 | |
| 835 | 835 | case 'wpi_invoice' :  | 
                                                        
| 836 | - $invoice = new WPInv_Invoice( $post_id );  | 
                                                        |
| 837 | - do_action( "getpaid_before_delete_invoice", $invoice );  | 
                                                        |
| 838 | - $invoice->get_data_store()->delete_items( $invoice );  | 
                                                        |
| 839 | - $invoice->get_data_store()->delete_special_fields( $invoice );  | 
                                                        |
| 836 | + $invoice = new WPInv_Invoice($post_id);  | 
                                                        |
| 837 | +				do_action("getpaid_before_delete_invoice", $invoice); | 
                                                        |
| 838 | + $invoice->get_data_store()->delete_items($invoice);  | 
                                                        |
| 839 | + $invoice->get_data_store()->delete_special_fields($invoice);  | 
                                                        |
| 840 | 840 | break;  | 
                                                        
| 841 | 841 | }  | 
                                                        
| 842 | 842 | }  | 
                                                        
@@ -849,29 +849,29 @@ discard block  | 
                                                    ||
| 849 | 849 | *  | 
                                                        
| 850 | 850 | * @return mixed  | 
                                                        
| 851 | 851 | */  | 
                                                        
| 852 | -    public static function add_display_post_states( $post_states, $post ) { | 
                                                        |
| 852 | +    public static function add_display_post_states($post_states, $post) { | 
                                                        |
| 853 | 853 | |
| 854 | -        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { | 
                                                        |
| 855 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );  | 
                                                        |
| 854 | +        if (wpinv_get_option('success_page', 0) == $post->ID) { | 
                                                        |
| 855 | +            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); | 
                                                        |
| 856 | 856 | }  | 
                                                        
| 857 | 857 | |
| 858 | -		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { | 
                                                        |
| 858 | +		foreach (getpaid_get_invoice_post_types() as $post_type => $label) { | 
                                                        |
| 859 | 859 | |
| 860 | -			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { | 
                                                        |
| 860 | +			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { | 
                                                        |
| 861 | 861 |  				$post_states["getpaid_{$post_type}_history_page"] = sprintf( | 
                                                        
| 862 | - __( 'GetPaid %s History Page', 'invoicing' ),  | 
                                                        |
| 862 | +					__('GetPaid %s History Page', 'invoicing'), | 
                                                        |
| 863 | 863 | $label  | 
                                                        
| 864 | 864 | );  | 
                                                        
| 865 | 865 | }  | 
                                                        
| 866 | 866 | |
| 867 | 867 | }  | 
                                                        
| 868 | 868 | |
| 869 | -		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { | 
                                                        |
| 870 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );  | 
                                                        |
| 869 | +		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { | 
                                                        |
| 870 | +            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); | 
                                                        |
| 871 | 871 | }  | 
                                                        
| 872 | 872 | |
| 873 | -		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { | 
                                                        |
| 874 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );  | 
                                                        |
| 873 | +		if (wpinv_get_option('checkout_page', 0) == $post->ID) { | 
                                                        |
| 874 | +            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); | 
                                                        |
| 875 | 875 | }  | 
                                                        
| 876 | 876 | |
| 877 | 877 | return $post_states;  | 
                                                        
@@ -14,91 +14,91 @@ discard block  | 
                                                    ||
| 14 | 14 |  class GetPaid_Admin { | 
                                                        
| 15 | 15 | |
| 16 | 16 | /**  | 
                                                        
| 17 | - * Local path to this plugins admin directory  | 
                                                        |
| 18 | - *  | 
                                                        |
| 19 | - * @var string  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - public $admin_path;  | 
                                                        |
| 22 | -  | 
                                                        |
| 23 | - /**  | 
                                                        |
| 24 | - * Web path to this plugins admin directory  | 
                                                        |
| 25 | - *  | 
                                                        |
| 26 | - * @var string  | 
                                                        |
| 27 | - */  | 
                                                        |
| 28 | - public $admin_url;  | 
                                                        |
| 17 | + * Local path to this plugins admin directory  | 
                                                        |
| 18 | + *  | 
                                                        |
| 19 | + * @var string  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + public $admin_path;  | 
                                                        |
| 22 | +  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * Web path to this plugins admin directory  | 
                                                        |
| 25 | + *  | 
                                                        |
| 26 | + * @var string  | 
                                                        |
| 27 | + */  | 
                                                        |
| 28 | + public $admin_url;  | 
                                                        |
| 29 | 29 | |
| 30 | - /**  | 
                                                        |
| 31 | - * Reports components.  | 
                                                        |
| 32 | - *  | 
                                                        |
| 33 | - * @var GetPaid_Reports  | 
                                                        |
| 34 | - */  | 
                                                        |
| 30 | + /**  | 
                                                        |
| 31 | + * Reports components.  | 
                                                        |
| 32 | + *  | 
                                                        |
| 33 | + * @var GetPaid_Reports  | 
                                                        |
| 34 | + */  | 
                                                        |
| 35 | 35 | public $reports;  | 
                                                        
| 36 | 36 | |
| 37 | 37 | /**  | 
                                                        
| 38 | - * Class constructor.  | 
                                                        |
| 39 | - */  | 
                                                        |
| 40 | -	public function __construct(){ | 
                                                        |
| 38 | + * Class constructor.  | 
                                                        |
| 39 | + */  | 
                                                        |
| 40 | +    public function __construct(){ | 
                                                        |
| 41 | 41 | |
| 42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ );  | 
                                                        
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ );  | 
                                                        |
| 44 | - $this->reports = new GetPaid_Reports();  | 
                                                        |
| 43 | + $this->admin_url = plugins_url( '/', __FILE__ );  | 
                                                        |
| 44 | + $this->reports = new GetPaid_Reports();  | 
                                                        |
| 45 | 45 | |
| 46 | 46 |          if ( is_admin() ) { | 
                                                        
| 47 | - $this->init_admin_hooks();  | 
                                                        |
| 47 | + $this->init_admin_hooks();  | 
                                                        |
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | 50 | }  | 
                                                        
| 51 | 51 | |
| 52 | 52 | /**  | 
                                                        
| 53 | - * Init action and filter hooks  | 
                                                        |
| 54 | - *  | 
                                                        |
| 55 | - */  | 
                                                        |
| 56 | -	private function init_admin_hooks() { | 
                                                        |
| 53 | + * Init action and filter hooks  | 
                                                        |
| 54 | + *  | 
                                                        |
| 55 | + */  | 
                                                        |
| 56 | +    private function init_admin_hooks() { | 
                                                        |
| 57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );  | 
                                                        
| 58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );  | 
                                                        
| 59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );  | 
                                                        
| 60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect') );  | 
                                                        
| 61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );  | 
                                                        
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) );  | 
                                                        |
| 63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );  | 
                                                        |
| 64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );  | 
                                                        |
| 65 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );  | 
                                                        |
| 66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );  | 
                                                        |
| 67 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );  | 
                                                        |
| 62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) );  | 
                                                        |
| 63 | + add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );  | 
                                                        |
| 64 | + add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );  | 
                                                        |
| 65 | + add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );  | 
                                                        |
| 66 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );  | 
                                                        |
| 67 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );  | 
                                                        |
| 68 | 68 | add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );  | 
                                                        
| 69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );  | 
                                                        |
| 70 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );  | 
                                                        |
| 71 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );  | 
                                                        |
| 72 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );  | 
                                                        |
| 73 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );  | 
                                                        |
| 74 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );  | 
                                                        |
| 75 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );  | 
                                                        |
| 76 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );  | 
                                                        |
| 77 | - do_action( 'getpaid_init_admin_hooks', $this );  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | - // Setup/welcome  | 
                                                        |
| 80 | -		if ( ! empty( $_GET['page'] ) ) { | 
                                                        |
| 81 | -			switch ( $_GET['page'] ) { | 
                                                        |
| 82 | - case 'gp-setup' :  | 
                                                        |
| 83 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );  | 
                                                        |
| 84 | - break;  | 
                                                        |
| 85 | - }  | 
                                                        |
| 86 | - }  | 
                                                        |
| 87 | -  | 
                                                        |
| 88 | - }  | 
                                                        |
| 89 | -  | 
                                                        |
| 90 | - /**  | 
                                                        |
| 91 | - * Register admin scripts  | 
                                                        |
| 92 | - *  | 
                                                        |
| 93 | - */  | 
                                                        |
| 94 | -	public function enqeue_scripts() { | 
                                                        |
| 69 | + add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );  | 
                                                        |
| 70 | + add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );  | 
                                                        |
| 71 | + add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );  | 
                                                        |
| 72 | + add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );  | 
                                                        |
| 73 | + add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );  | 
                                                        |
| 74 | + add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );  | 
                                                        |
| 75 | + add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );  | 
                                                        |
| 76 | + add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );  | 
                                                        |
| 77 | + do_action( 'getpaid_init_admin_hooks', $this );  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | + // Setup/welcome  | 
                                                        |
| 80 | +        if ( ! empty( $_GET['page'] ) ) { | 
                                                        |
| 81 | +            switch ( $_GET['page'] ) { | 
                                                        |
| 82 | + case 'gp-setup' :  | 
                                                        |
| 83 | + include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );  | 
                                                        |
| 84 | + break;  | 
                                                        |
| 85 | + }  | 
                                                        |
| 86 | + }  | 
                                                        |
| 87 | +  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | +  | 
                                                        |
| 90 | + /**  | 
                                                        |
| 91 | + * Register admin scripts  | 
                                                        |
| 92 | + *  | 
                                                        |
| 93 | + */  | 
                                                        |
| 94 | +    public function enqeue_scripts() { | 
                                                        |
| 95 | 95 | global $current_screen, $pagenow;  | 
                                                        
| 96 | 96 | |
| 97 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 98 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';  | 
                                                        |
| 97 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 98 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';  | 
                                                        |
| 99 | 99 | |
| 100 | 100 |          if ( ! empty( $current_screen->post_type ) ) { | 
                                                        
| 101 | - $page = $current_screen->post_type;  | 
                                                        |
| 101 | + $page = $current_screen->post_type;  | 
                                                        |
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
| 104 | 104 | // General styles.  | 
                                                        
@@ -119,54 +119,54 @@ discard block  | 
                                                    ||
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | 121 | // Payment form scripts.  | 
                                                        
| 122 | -		if ( 'wpi_payment_form' == $page && $editing ) { | 
                                                        |
| 122 | +        if ( 'wpi_payment_form' == $page && $editing ) { | 
                                                        |
| 123 | 123 | $this->load_payment_form_scripts();  | 
                                                        
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
| 126 | -		if ( $page == 'wpinv-subscriptions' ) { | 
                                                        |
| 127 | - wp_enqueue_script( 'postbox' );  | 
                                                        |
| 128 | - }  | 
                                                        |
| 126 | +        if ( $page == 'wpinv-subscriptions' ) { | 
                                                        |
| 127 | + wp_enqueue_script( 'postbox' );  | 
                                                        |
| 128 | + }  | 
                                                        |
| 129 | 129 | |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
| 132 | 132 | /**  | 
                                                        
| 133 | - * Returns admin js translations.  | 
                                                        |
| 134 | - *  | 
                                                        |
| 135 | - */  | 
                                                        |
| 136 | -	protected function get_admin_i18() { | 
                                                        |
| 133 | + * Returns admin js translations.  | 
                                                        |
| 134 | + *  | 
                                                        |
| 135 | + */  | 
                                                        |
| 136 | +    protected function get_admin_i18() { | 
                                                        |
| 137 | 137 | global $post;  | 
                                                        
| 138 | 138 | |
| 139 | - $date_range = array(  | 
                                                        |
| 140 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'  | 
                                                        |
| 141 | - );  | 
                                                        |
| 139 | + $date_range = array(  | 
                                                        |
| 140 | + 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'  | 
                                                        |
| 141 | + );  | 
                                                        |
| 142 | 142 | |
| 143 | -		if ( $date_range['period'] == 'custom' ) { | 
                                                        |
| 143 | +        if ( $date_range['period'] == 'custom' ) { | 
                                                        |
| 144 | 144 | |
| 145 | -			if ( isset( $_GET['from'] ) ) { | 
                                                        |
| 146 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );  | 
                                                        |
| 147 | - }  | 
                                                        |
| 145 | +            if ( isset( $_GET['from'] ) ) { | 
                                                        |
| 146 | + $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );  | 
                                                        |
| 147 | + }  | 
                                                        |
| 148 | 148 | |
| 149 | -			if ( isset( $_GET['to'] ) ) { | 
                                                        |
| 150 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );  | 
                                                        |
| 151 | - }  | 
                                                        |
| 149 | +            if ( isset( $_GET['to'] ) ) { | 
                                                        |
| 150 | + $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );  | 
                                                        |
| 151 | + }  | 
                                                        |
| 152 | 152 | |
| 153 | - }  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | 154 | |
| 155 | 155 | $i18n = array(  | 
                                                        
| 156 | 156 | 'ajax_url' => admin_url( 'admin-ajax.php' ),  | 
                                                        
| 157 | 157 | 'post_ID' => isset( $post->ID ) ? $post->ID : '',  | 
                                                        
| 158 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ),  | 
                                                        |
| 159 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ),  | 
                                                        |
| 160 | - 'rest_root' => esc_url_raw( rest_url() ),  | 
                                                        |
| 161 | - 'date_range' => $date_range,  | 
                                                        |
| 158 | + 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ),  | 
                                                        |
| 159 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ),  | 
                                                        |
| 160 | + 'rest_root' => esc_url_raw( rest_url() ),  | 
                                                        |
| 161 | + 'date_range' => $date_range,  | 
                                                        |
| 162 | 162 | 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ),  | 
                                                        
| 163 | 163 | 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),  | 
                                                        
| 164 | 164 | 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ),  | 
                                                        
| 165 | 165 | 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ),  | 
                                                        
| 166 | 166 | 'tax' => wpinv_tax_amount(),  | 
                                                        
| 167 | 167 | 'discount' => 0,  | 
                                                        
| 168 | - 'currency_symbol' => wpinv_currency_symbol(),  | 
                                                        |
| 169 | - 'currency' => wpinv_get_currency(),  | 
                                                        |
| 168 | + 'currency_symbol' => wpinv_currency_symbol(),  | 
                                                        |
| 169 | + 'currency' => wpinv_get_currency(),  | 
                                                        |
| 170 | 170 | 'currency_pos' => wpinv_currency_position(),  | 
                                                        
| 171 | 171 | 'thousand_sep' => wpinv_thousands_separator(),  | 
                                                        
| 172 | 172 | 'decimal_sep' => wpinv_decimal_separator(),  | 
                                                        
@@ -186,118 +186,118 @@ discard block  | 
                                                    ||
| 186 | 186 | 'item_description' => __( 'Item Description', 'invoicing' ),  | 
                                                        
| 187 | 187 | 'invoice_description' => __( 'Invoice Description', 'invoicing' ),  | 
                                                        
| 188 | 188 | 'discount_description' => __( 'Discount Description', 'invoicing' ),  | 
                                                        
| 189 | - 'searching' => __( 'Searching', 'invoicing' ),  | 
                                                        |
| 190 | - 'loading' => __( 'Loading...', 'invoicing' ),  | 
                                                        |
| 191 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ),  | 
                                                        |
| 192 | - 'search_items' => __( 'Enter item name', 'invoicing' ),  | 
                                                        |
| 189 | + 'searching' => __( 'Searching', 'invoicing' ),  | 
                                                        |
| 190 | + 'loading' => __( 'Loading...', 'invoicing' ),  | 
                                                        |
| 191 | + 'search_customers' => __( 'Enter customer name or email', 'invoicing' ),  | 
                                                        |
| 192 | + 'search_items' => __( 'Enter item name', 'invoicing' ),  | 
                                                        |
| 193 | 193 | );  | 
                                                        
| 194 | 194 | |
| 195 | -		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { | 
                                                        |
| 195 | +        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { | 
                                                        |
| 196 | 196 | |
| 197 | - $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 198 | - $i18n['save_invoice'] = sprintf(  | 
                                                        |
| 199 | - __( 'Save %s', 'invoicing' ),  | 
                                                        |
| 200 | - ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 201 | - );  | 
                                                        |
| 197 | + $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 198 | + $i18n['save_invoice'] = sprintf(  | 
                                                        |
| 199 | + __( 'Save %s', 'invoicing' ),  | 
                                                        |
| 200 | + ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 201 | + );  | 
                                                        |
| 202 | 202 | |
| 203 | - $i18n['invoice_description'] = sprintf(  | 
                                                        |
| 204 | - __( '%s Description', 'invoicing' ),  | 
                                                        |
| 205 | - ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 206 | - );  | 
                                                        |
| 203 | + $i18n['invoice_description'] = sprintf(  | 
                                                        |
| 204 | + __( '%s Description', 'invoicing' ),  | 
                                                        |
| 205 | + ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 206 | + );  | 
                                                        |
| 207 | 207 | |
| 208 | - }  | 
                                                        |
| 209 | - return $i18n;  | 
                                                        |
| 210 | - }  | 
                                                        |
| 208 | + }  | 
                                                        |
| 209 | + return $i18n;  | 
                                                        |
| 210 | + }  | 
                                                        |
| 211 | 211 | |
| 212 | - /**  | 
                                                        |
| 213 | - * Change the admin footer text on GetPaid admin pages.  | 
                                                        |
| 214 | - *  | 
                                                        |
| 215 | - * @since 2.0.0  | 
                                                        |
| 216 | - * @param string $footer_text  | 
                                                        |
| 217 | - * @return string  | 
                                                        |
| 218 | - */  | 
                                                        |
| 219 | -	public function admin_footer_text( $footer_text ) { | 
                                                        |
| 220 | - global $current_screen;  | 
                                                        |
| 212 | + /**  | 
                                                        |
| 213 | + * Change the admin footer text on GetPaid admin pages.  | 
                                                        |
| 214 | + *  | 
                                                        |
| 215 | + * @since 2.0.0  | 
                                                        |
| 216 | + * @param string $footer_text  | 
                                                        |
| 217 | + * @return string  | 
                                                        |
| 218 | + */  | 
                                                        |
| 219 | +    public function admin_footer_text( $footer_text ) { | 
                                                        |
| 220 | + global $current_screen;  | 
                                                        |
| 221 | 221 | |
| 222 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 222 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 223 | 223 | |
| 224 | 224 |          if ( ! empty( $current_screen->post_type ) ) { | 
                                                        
| 225 | - $page = $current_screen->post_type;  | 
                                                        |
| 225 | + $page = $current_screen->post_type;  | 
                                                        |
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | 228 | // General styles.  | 
                                                        
| 229 | 229 |          if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { | 
                                                        
| 230 | 230 | |
| 231 | - // Change the footer text  | 
                                                        |
| 232 | -			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { | 
                                                        |
| 233 | -  | 
                                                        |
| 234 | - $rating_url = esc_url(  | 
                                                        |
| 235 | - wp_nonce_url(  | 
                                                        |
| 236 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),  | 
                                                        |
| 237 | - 'getpaid-nonce',  | 
                                                        |
| 238 | - 'getpaid-nonce'  | 
                                                        |
| 239 | - )  | 
                                                        |
| 240 | - );  | 
                                                        |
| 241 | -  | 
                                                        |
| 242 | - $footer_text = sprintf(  | 
                                                        |
| 243 | - /* translators: %s: five stars */  | 
                                                        |
| 244 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),  | 
                                                        |
| 245 | - "<a href='$rating_url'>★★★★★</a>"  | 
                                                        |
| 246 | - );  | 
                                                        |
| 247 | -  | 
                                                        |
| 248 | -			} else { | 
                                                        |
| 249 | -  | 
                                                        |
| 250 | - $footer_text = sprintf(  | 
                                                        |
| 251 | - /* translators: %s: GetPaid */  | 
                                                        |
| 252 | - __( 'Thank you for using %s!', 'invoicing' ),  | 
                                                        |
| 253 | - "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"  | 
                                                        |
| 254 | - );  | 
                                                        |
| 255 | -  | 
                                                        |
| 256 | - }  | 
                                                        |
| 257 | -  | 
                                                        |
| 258 | - }  | 
                                                        |
| 259 | -  | 
                                                        |
| 260 | - return $footer_text;  | 
                                                        |
| 261 | - }  | 
                                                        |
| 262 | -  | 
                                                        |
| 263 | - /**  | 
                                                        |
| 264 | - * Redirects to wp.org to rate the plugin.  | 
                                                        |
| 265 | - *  | 
                                                        |
| 266 | - * @since 2.0.0  | 
                                                        |
| 267 | - */  | 
                                                        |
| 268 | -	public function redirect_to_wordpress_rating_page() { | 
                                                        |
| 269 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );  | 
                                                        |
| 270 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );  | 
                                                        |
| 271 | - exit;  | 
                                                        |
| 272 | - }  | 
                                                        |
| 273 | -  | 
                                                        |
| 274 | - /**  | 
                                                        |
| 275 | - * Loads payment form js.  | 
                                                        |
| 276 | - *  | 
                                                        |
| 277 | - */  | 
                                                        |
| 278 | -	protected function load_payment_form_scripts() { | 
                                                        |
| 231 | + // Change the footer text  | 
                                                        |
| 232 | +            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { | 
                                                        |
| 233 | +  | 
                                                        |
| 234 | + $rating_url = esc_url(  | 
                                                        |
| 235 | + wp_nonce_url(  | 
                                                        |
| 236 | + admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),  | 
                                                        |
| 237 | + 'getpaid-nonce',  | 
                                                        |
| 238 | + 'getpaid-nonce'  | 
                                                        |
| 239 | + )  | 
                                                        |
| 240 | + );  | 
                                                        |
| 241 | +  | 
                                                        |
| 242 | + $footer_text = sprintf(  | 
                                                        |
| 243 | + /* translators: %s: five stars */  | 
                                                        |
| 244 | + __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),  | 
                                                        |
| 245 | + "<a href='$rating_url'>★★★★★</a>"  | 
                                                        |
| 246 | + );  | 
                                                        |
| 247 | +  | 
                                                        |
| 248 | +            } else { | 
                                                        |
| 249 | +  | 
                                                        |
| 250 | + $footer_text = sprintf(  | 
                                                        |
| 251 | + /* translators: %s: GetPaid */  | 
                                                        |
| 252 | + __( 'Thank you for using %s!', 'invoicing' ),  | 
                                                        |
| 253 | + "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"  | 
                                                        |
| 254 | + );  | 
                                                        |
| 255 | +  | 
                                                        |
| 256 | + }  | 
                                                        |
| 257 | +  | 
                                                        |
| 258 | + }  | 
                                                        |
| 259 | +  | 
                                                        |
| 260 | + return $footer_text;  | 
                                                        |
| 261 | + }  | 
                                                        |
| 262 | +  | 
                                                        |
| 263 | + /**  | 
                                                        |
| 264 | + * Redirects to wp.org to rate the plugin.  | 
                                                        |
| 265 | + *  | 
                                                        |
| 266 | + * @since 2.0.0  | 
                                                        |
| 267 | + */  | 
                                                        |
| 268 | +    public function redirect_to_wordpress_rating_page() { | 
                                                        |
| 269 | + update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );  | 
                                                        |
| 270 | + wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );  | 
                                                        |
| 271 | + exit;  | 
                                                        |
| 272 | + }  | 
                                                        |
| 273 | +  | 
                                                        |
| 274 | + /**  | 
                                                        |
| 275 | + * Loads payment form js.  | 
                                                        |
| 276 | + *  | 
                                                        |
| 277 | + */  | 
                                                        |
| 278 | +    protected function load_payment_form_scripts() { | 
                                                        |
| 279 | 279 | global $post;  | 
                                                        
| 280 | 280 | |
| 281 | 281 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );  | 
                                                        
| 282 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );  | 
                                                        |
| 283 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );  | 
                                                        |
| 282 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );  | 
                                                        |
| 283 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );  | 
                                                        |
| 284 | 284 | |
| 285 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );  | 
                                                        |
| 286 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );  | 
                                                        |
| 285 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );  | 
                                                        |
| 286 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );  | 
                                                        |
| 287 | 287 | |
| 288 | - wp_localize_script(  | 
                                                        |
| 288 | + wp_localize_script(  | 
                                                        |
| 289 | 289 | 'wpinv-admin-payment-form-script',  | 
                                                        
| 290 | 290 | 'wpinvPaymentFormAdmin',  | 
                                                        
| 291 | 291 | array(  | 
                                                        
| 292 | - 'elements' => wpinv_get_data( 'payment-form-elements' ),  | 
                                                        |
| 293 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ),  | 
                                                        |
| 294 | - 'currency' => wpinv_currency_symbol(),  | 
                                                        |
| 295 | - 'position' => wpinv_currency_position(),  | 
                                                        |
| 296 | - 'decimals' => (int) wpinv_decimals(),  | 
                                                        |
| 297 | - 'thousands_sep' => wpinv_thousands_separator(),  | 
                                                        |
| 298 | - 'decimals_sep' => wpinv_decimal_separator(),  | 
                                                        |
| 299 | - 'form_items' => gepaid_get_form_items( $post->ID ),  | 
                                                        |
| 300 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(),  | 
                                                        |
| 292 | + 'elements' => wpinv_get_data( 'payment-form-elements' ),  | 
                                                        |
| 293 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ),  | 
                                                        |
| 294 | + 'currency' => wpinv_currency_symbol(),  | 
                                                        |
| 295 | + 'position' => wpinv_currency_position(),  | 
                                                        |
| 296 | + 'decimals' => (int) wpinv_decimals(),  | 
                                                        |
| 297 | + 'thousands_sep' => wpinv_thousands_separator(),  | 
                                                        |
| 298 | + 'decimals_sep' => wpinv_decimal_separator(),  | 
                                                        |
| 299 | + 'form_items' => gepaid_get_form_items( $post->ID ),  | 
                                                        |
| 300 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(),  | 
                                                        |
| 301 | 301 | )  | 
                                                        
| 302 | 302 | );  | 
                                                        
| 303 | 303 | |
@@ -306,20 +306,20 @@ discard block  | 
                                                    ||
| 306 | 306 | }  | 
                                                        
| 307 | 307 | |
| 308 | 308 | /**  | 
                                                        
| 309 | - * Add our classes to admin pages.  | 
                                                        |
| 309 | + * Add our classes to admin pages.  | 
                                                        |
| 310 | 310 | *  | 
                                                        
| 311 | 311 | * @param string $classes  | 
                                                        
| 312 | 312 | * @return string  | 
                                                        
| 313 | - *  | 
                                                        |
| 314 | - */  | 
                                                        |
| 313 | + *  | 
                                                        |
| 314 | + */  | 
                                                        |
| 315 | 315 |      public function admin_body_class( $classes ) { | 
                                                        
| 316 | - global $pagenow, $post, $current_screen;  | 
                                                        |
| 316 | + global $pagenow, $post, $current_screen;  | 
                                                        |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        
| 320 | 320 | |
| 321 | 321 |          if ( ! empty( $current_screen->post_type ) ) { | 
                                                        
| 322 | - $page = $current_screen->post_type;  | 
                                                        |
| 322 | + $page = $current_screen->post_type;  | 
                                                        |
| 323 | 323 | }  | 
                                                        
| 324 | 324 | |
| 325 | 325 |          if ( false !== stripos( $page, 'wpi' ) ) { | 
                                                        
@@ -328,68 +328,68 @@ discard block  | 
                                                    ||
| 328 | 328 | |
| 329 | 329 |          if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { | 
                                                        
| 330 | 330 | $classes .= ' wpinv-cpt wpinv';  | 
                                                        
| 331 | - }  | 
                                                        |
| 331 | + }  | 
                                                        |
| 332 | 332 | |
| 333 | -		if ( getpaid_is_invoice_post_type( $page ) ) { | 
                                                        |
| 333 | +        if ( getpaid_is_invoice_post_type( $page ) ) { | 
                                                        |
| 334 | 334 | $classes .= ' getpaid-is-invoice-cpt';  | 
                                                        
| 335 | 335 | }  | 
                                                        
| 336 | 336 | |
| 337 | - return $classes;  | 
                                                        |
| 337 | + return $classes;  | 
                                                        |
| 338 | 338 | }  | 
                                                        
| 339 | 339 | |
| 340 | 340 | /**  | 
                                                        
| 341 | - * Maybe show the AyeCode Connect Notice.  | 
                                                        |
| 342 | - */  | 
                                                        |
| 343 | -	public function init_ayecode_connect_helper(){ | 
                                                        |
| 341 | + * Maybe show the AyeCode Connect Notice.  | 
                                                        |
| 342 | + */  | 
                                                        |
| 343 | +    public function init_ayecode_connect_helper(){ | 
                                                        |
| 344 | 344 | |
| 345 | - // Register with the deactivation survey class.  | 
                                                        |
| 346 | - AyeCode_Deactivation_Survey::instance(array(  | 
                                                        |
| 347 | - 'slug' => 'invoicing',  | 
                                                        |
| 348 | - 'version' => WPINV_VERSION,  | 
                                                        |
| 349 | - 'support_url' => 'https://wpgetpaid.com/support/',  | 
                                                        |
| 350 | - 'documentation_url' => 'https://docs.wpgetpaid.com/',  | 
                                                        |
| 351 | - 'activated' => (int) get_option( 'gepaid_installed_on' ),  | 
                                                        |
| 352 | - ));  | 
                                                        |
| 345 | + // Register with the deactivation survey class.  | 
                                                        |
| 346 | + AyeCode_Deactivation_Survey::instance(array(  | 
                                                        |
| 347 | + 'slug' => 'invoicing',  | 
                                                        |
| 348 | + 'version' => WPINV_VERSION,  | 
                                                        |
| 349 | + 'support_url' => 'https://wpgetpaid.com/support/',  | 
                                                        |
| 350 | + 'documentation_url' => 'https://docs.wpgetpaid.com/',  | 
                                                        |
| 351 | + 'activated' => (int) get_option( 'gepaid_installed_on' ),  | 
                                                        |
| 352 | + ));  | 
                                                        |
| 353 | 353 | |
| 354 | 354 | new AyeCode_Connect_Helper(  | 
                                                        
| 355 | 355 | array(  | 
                                                        
| 356 | -				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), | 
                                                        |
| 357 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ),  | 
                                                        |
| 358 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),  | 
                                                        |
| 359 | -				'connect_button'    => __("Connect Site","invoicing"), | 
                                                        |
| 360 | -				'connecting_button'    => __("Connecting...","invoicing"), | 
                                                        |
| 361 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ),  | 
                                                        |
| 362 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ),  | 
                                                        |
| 356 | +                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), | 
                                                        |
| 357 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ),  | 
                                                        |
| 358 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),  | 
                                                        |
| 359 | +                'connect_button'    => __("Connect Site","invoicing"), | 
                                                        |
| 360 | +                'connecting_button'    => __("Connecting...","invoicing"), | 
                                                        |
| 361 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ),  | 
                                                        |
| 362 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ),  | 
                                                        |
| 363 | 363 | ),  | 
                                                        
| 364 | 364 | array( 'wpi-addons' )  | 
                                                        
| 365 | 365 | );  | 
                                                        
| 366 | 366 | |
| 367 | 367 | }  | 
                                                        
| 368 | 368 | |
| 369 | - /**  | 
                                                        |
| 370 | - * Redirect users to settings on activation.  | 
                                                        |
| 371 | - *  | 
                                                        |
| 372 | - * @return void  | 
                                                        |
| 373 | - */  | 
                                                        |
| 374 | -	public function activation_redirect() { | 
                                                        |
| 369 | + /**  | 
                                                        |
| 370 | + * Redirect users to settings on activation.  | 
                                                        |
| 371 | + *  | 
                                                        |
| 372 | + * @return void  | 
                                                        |
| 373 | + */  | 
                                                        |
| 374 | +    public function activation_redirect() { | 
                                                        |
| 375 | 375 | |
| 376 | - $redirected = get_option( 'wpinv_redirected_to_settings' );  | 
                                                        |
| 376 | + $redirected = get_option( 'wpinv_redirected_to_settings' );  | 
                                                        |
| 377 | 377 | |
| 378 | -		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { | 
                                                        |
| 379 | - return;  | 
                                                        |
| 380 | - }  | 
                                                        |
| 378 | +        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { | 
                                                        |
| 379 | + return;  | 
                                                        |
| 380 | + }  | 
                                                        |
| 381 | 381 | |
| 382 | - // Bail if activating from network, or bulk  | 
                                                        |
| 383 | -		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | 
                                                        |
| 384 | - return;  | 
                                                        |
| 385 | - }  | 
                                                        |
| 382 | + // Bail if activating from network, or bulk  | 
                                                        |
| 383 | +        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | 
                                                        |
| 384 | + return;  | 
                                                        |
| 385 | + }  | 
                                                        |
| 386 | 386 | |
| 387 | - update_option( 'wpinv_redirected_to_settings', 1 );  | 
                                                        |
| 387 | + update_option( 'wpinv_redirected_to_settings', 1 );  | 
                                                        |
| 388 | 388 | |
| 389 | 389 | wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );  | 
                                                        
| 390 | 390 | exit;  | 
                                                        
| 391 | 391 | |
| 392 | - }  | 
                                                        |
| 392 | + }  | 
                                                        |
| 393 | 393 | |
| 394 | 394 | /**  | 
                                                        
| 395 | 395 | * Fires an admin action after verifying that a user can fire them.  | 
                                                        
@@ -403,539 +403,539 @@ discard block  | 
                                                    ||
| 403 | 403 | |
| 404 | 404 | }  | 
                                                        
| 405 | 405 | |
| 406 | - /**  | 
                                                        |
| 406 | + /**  | 
                                                        |
| 407 | 407 | * Duplicate invoice.  | 
                                                        
| 408 | - *  | 
                                                        |
| 409 | - * @param array $args  | 
                                                        |
| 408 | + *  | 
                                                        |
| 409 | + * @param array $args  | 
                                                        |
| 410 | 410 | */  | 
                                                        
| 411 | 411 |      public function duplicate_invoice( $args ) { | 
                                                        
| 412 | 412 | |
| 413 | -		if ( empty( $args['invoice_id'] ) ) { | 
                                                        |
| 414 | - return;  | 
                                                        |
| 415 | - }  | 
                                                        |
| 413 | +        if ( empty( $args['invoice_id'] ) ) { | 
                                                        |
| 414 | + return;  | 
                                                        |
| 415 | + }  | 
                                                        |
| 416 | 416 | |
| 417 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );  | 
                                                        |
| 417 | + $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );  | 
                                                        |
| 418 | 418 | |
| 419 | -		if ( ! $invoice->exists() ) { | 
                                                        |
| 420 | - return;  | 
                                                        |
| 421 | - }  | 
                                                        |
| 419 | +        if ( ! $invoice->exists() ) { | 
                                                        |
| 420 | + return;  | 
                                                        |
| 421 | + }  | 
                                                        |
| 422 | 422 | |
| 423 | - $new_invoice = getpaid_duplicate_invoice( $invoice );  | 
                                                        |
| 424 | - $new_invoice->save();  | 
                                                        |
| 423 | + $new_invoice = getpaid_duplicate_invoice( $invoice );  | 
                                                        |
| 424 | + $new_invoice->save();  | 
                                                        |
| 425 | 425 | |
| 426 | -		if ( $new_invoice->exists() ) { | 
                                                        |
| 426 | +        if ( $new_invoice->exists() ) { | 
                                                        |
| 427 | 427 | |
| 428 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );  | 
                                                        |
| 428 | + getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );  | 
                                                        |
| 429 | 429 | |
| 430 | - wp_safe_redirect(  | 
                                                        |
| 431 | - add_query_arg(  | 
                                                        |
| 432 | - array(  | 
                                                        |
| 433 | - 'action' => 'edit',  | 
                                                        |
| 434 | - 'post' => $new_invoice->get_id(),  | 
                                                        |
| 435 | - ),  | 
                                                        |
| 436 | - admin_url( 'post.php' )  | 
                                                        |
| 437 | - )  | 
                                                        |
| 438 | - );  | 
                                                        |
| 439 | - exit;  | 
                                                        |
| 430 | + wp_safe_redirect(  | 
                                                        |
| 431 | + add_query_arg(  | 
                                                        |
| 432 | + array(  | 
                                                        |
| 433 | + 'action' => 'edit',  | 
                                                        |
| 434 | + 'post' => $new_invoice->get_id(),  | 
                                                        |
| 435 | + ),  | 
                                                        |
| 436 | + admin_url( 'post.php' )  | 
                                                        |
| 437 | + )  | 
                                                        |
| 438 | + );  | 
                                                        |
| 439 | + exit;  | 
                                                        |
| 440 | 440 | |
| 441 | - }  | 
                                                        |
| 441 | + }  | 
                                                        |
| 442 | 442 | |
| 443 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );  | 
                                                        |
| 443 | + getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );  | 
                                                        |
| 444 | 444 | |
| 445 | - }  | 
                                                        |
| 445 | + }  | 
                                                        |
| 446 | 446 | |
| 447 | - /**  | 
                                                        |
| 447 | + /**  | 
                                                        |
| 448 | 448 | * Sends a payment reminder to a customer.  | 
                                                        
| 449 | - *  | 
                                                        |
| 450 | - * @param array $args  | 
                                                        |
| 449 | + *  | 
                                                        |
| 450 | + * @param array $args  | 
                                                        |
| 451 | 451 | */  | 
                                                        
| 452 | 452 |      public function duplicate_payment_form( $args ) { | 
                                                        
| 453 | 453 | |
| 454 | -		if ( empty( $args['form_id'] ) ) { | 
                                                        |
| 455 | - return;  | 
                                                        |
| 456 | - }  | 
                                                        |
| 457 | -  | 
                                                        |
| 458 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] );  | 
                                                        |
| 454 | +        if ( empty( $args['form_id'] ) ) { | 
                                                        |
| 455 | + return;  | 
                                                        |
| 456 | + }  | 
                                                        |
| 459 | 457 | |
| 460 | -		if ( ! $form->exists() ) { | 
                                                        |
| 461 | - return;  | 
                                                        |
| 462 | - }  | 
                                                        |
| 458 | + $form = new GetPaid_Payment_Form( (int) $args['form_id'] );  | 
                                                        |
| 463 | 459 | |
| 464 | - $new_form = new GetPaid_Payment_Form();  | 
                                                        |
| 465 | - $new_form->set_author( $form->get_author( 'edit' ) );  | 
                                                        |
| 466 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );  | 
                                                        |
| 467 | - $new_form->set_elements( $form->get_elements( 'edit' ) );  | 
                                                        |
| 468 | - $new_form->set_items( $form->get_items( 'edit' ) );  | 
                                                        |
| 469 | - $new_form->save();  | 
                                                        |
| 460 | +        if ( ! $form->exists() ) { | 
                                                        |
| 461 | + return;  | 
                                                        |
| 462 | + }  | 
                                                        |
| 470 | 463 | |
| 471 | -		if ( $new_form->exists() ) { | 
                                                        |
| 472 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );  | 
                                                        |
| 473 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' );  | 
                                                        |
| 474 | -		} else { | 
                                                        |
| 475 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );  | 
                                                        |
| 476 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );  | 
                                                        |
| 477 | - }  | 
                                                        |
| 464 | + $new_form = new GetPaid_Payment_Form();  | 
                                                        |
| 465 | + $new_form->set_author( $form->get_author( 'edit' ) );  | 
                                                        |
| 466 | + $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );  | 
                                                        |
| 467 | + $new_form->set_elements( $form->get_elements( 'edit' ) );  | 
                                                        |
| 468 | + $new_form->set_items( $form->get_items( 'edit' ) );  | 
                                                        |
| 469 | + $new_form->save();  | 
                                                        |
| 470 | +  | 
                                                        |
| 471 | +        if ( $new_form->exists() ) { | 
                                                        |
| 472 | + $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );  | 
                                                        |
| 473 | + $url = get_edit_post_link( $new_form->get_id(), 'edit' );  | 
                                                        |
| 474 | +        } else { | 
                                                        |
| 475 | + $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );  | 
                                                        |
| 476 | + $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );  | 
                                                        |
| 477 | + }  | 
                                                        |
| 478 | 478 | |
| 479 | - wp_redirect( $url );  | 
                                                        |
| 480 | - exit;  | 
                                                        |
| 481 | - }  | 
                                                        |
| 479 | + wp_redirect( $url );  | 
                                                        |
| 480 | + exit;  | 
                                                        |
| 481 | + }  | 
                                                        |
| 482 | 482 | |
| 483 | - /**  | 
                                                        |
| 483 | + /**  | 
                                                        |
| 484 | 484 | * Sends a payment reminder to a customer.  | 
                                                        
| 485 | - *  | 
                                                        |
| 486 | - * @param array $args  | 
                                                        |
| 485 | + *  | 
                                                        |
| 486 | + * @param array $args  | 
                                                        |
| 487 | 487 | */  | 
                                                        
| 488 | 488 |      public function send_customer_invoice( $args ) { | 
                                                        
| 489 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );  | 
                                                        |
| 489 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );  | 
                                                        |
| 490 | 490 | |
| 491 | -		if ( $sent ) { | 
                                                        |
| 492 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 493 | -		} else { | 
                                                        |
| 494 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );  | 
                                                        |
| 495 | - }  | 
                                                        |
| 491 | +        if ( $sent ) { | 
                                                        |
| 492 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 493 | +        } else { | 
                                                        |
| 494 | + $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );  | 
                                                        |
| 495 | + }  | 
                                                        |
| 496 | 496 | |
| 497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 498 | - exit;  | 
                                                        |
| 499 | - }  | 
                                                        |
| 497 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 498 | + exit;  | 
                                                        |
| 499 | + }  | 
                                                        |
| 500 | 500 | |
| 501 | - /**  | 
                                                        |
| 501 | + /**  | 
                                                        |
| 502 | 502 | * Sends a payment reminder to a customer.  | 
                                                        
| 503 | - *  | 
                                                        |
| 504 | - * @param array $args  | 
                                                        |
| 503 | + *  | 
                                                        |
| 504 | + * @param array $args  | 
                                                        |
| 505 | 505 | */  | 
                                                        
| 506 | 506 |      public function send_customer_payment_reminder( $args ) { | 
                                                        
| 507 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );  | 
                                                        |
| 507 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );  | 
                                                        |
| 508 | 508 | |
| 509 | -		if ( $sent ) { | 
                                                        |
| 510 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 511 | -		} else { | 
                                                        |
| 512 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );  | 
                                                        |
| 513 | - }  | 
                                                        |
| 509 | +        if ( $sent ) { | 
                                                        |
| 510 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 511 | +        } else { | 
                                                        |
| 512 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );  | 
                                                        |
| 513 | + }  | 
                                                        |
| 514 | 514 | |
| 515 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 516 | - exit;  | 
                                                        |
| 517 | - }  | 
                                                        |
| 515 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 516 | + exit;  | 
                                                        |
| 517 | + }  | 
                                                        |
| 518 | 518 | |
| 519 | - /**  | 
                                                        |
| 519 | + /**  | 
                                                        |
| 520 | 520 | * Resets tax rates.  | 
                                                        
| 521 | - *  | 
                                                        |
| 521 | + *  | 
                                                        |
| 522 | 522 | */  | 
                                                        
| 523 | 523 |      public function admin_reset_tax_rates() { | 
                                                        
| 524 | 524 | |
| 525 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );  | 
                                                        |
| 526 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 527 | - exit;  | 
                                                        |
| 525 | + update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );  | 
                                                        |
| 526 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 527 | + exit;  | 
                                                        |
| 528 | 528 | |
| 529 | - }  | 
                                                        |
| 529 | + }  | 
                                                        |
| 530 | 530 | |
| 531 | - /**  | 
                                                        |
| 531 | + /**  | 
                                                        |
| 532 | 532 | * Resets admin pages.  | 
                                                        
| 533 | - *  | 
                                                        |
| 533 | + *  | 
                                                        |
| 534 | 534 | */  | 
                                                        
| 535 | 535 |      public function admin_create_missing_pages() { | 
                                                        
| 536 | - $installer = new GetPaid_Installer();  | 
                                                        |
| 537 | - $installer->create_pages();  | 
                                                        |
| 538 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );  | 
                                                        |
| 539 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 540 | - exit;  | 
                                                        |
| 541 | - }  | 
                                                        |
| 542 | -  | 
                                                        |
| 543 | - /**  | 
                                                        |
| 536 | + $installer = new GetPaid_Installer();  | 
                                                        |
| 537 | + $installer->create_pages();  | 
                                                        |
| 538 | + $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );  | 
                                                        |
| 539 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 540 | + exit;  | 
                                                        |
| 541 | + }  | 
                                                        |
| 542 | +  | 
                                                        |
| 543 | + /**  | 
                                                        |
| 544 | 544 | * Creates an missing admin tables.  | 
                                                        
| 545 | - *  | 
                                                        |
| 545 | + *  | 
                                                        |
| 546 | 546 | */  | 
                                                        
| 547 | 547 |      public function admin_create_missing_tables() { | 
                                                        
| 548 | - global $wpdb;  | 
                                                        |
| 549 | - $installer = new GetPaid_Installer();  | 
                                                        |
| 548 | + global $wpdb;  | 
                                                        |
| 549 | + $installer = new GetPaid_Installer();  | 
                                                        |
| 550 | 550 | |
| 551 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { | 
                                                        |
| 552 | - $installer->create_subscriptions_table();  | 
                                                        |
| 551 | +        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { | 
                                                        |
| 552 | + $installer->create_subscriptions_table();  | 
                                                        |
| 553 | 553 | |
| 554 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 555 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 556 | - }  | 
                                                        |
| 557 | - }  | 
                                                        |
| 554 | +            if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 555 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 556 | + }  | 
                                                        |
| 557 | + }  | 
                                                        |
| 558 | 558 | |
| 559 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { | 
                                                        |
| 560 | - $installer->create_invoices_table();  | 
                                                        |
| 559 | +        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { | 
                                                        |
| 560 | + $installer->create_invoices_table();  | 
                                                        |
| 561 | 561 | |
| 562 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 563 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 564 | - }  | 
                                                        |
| 565 | - }  | 
                                                        |
| 562 | +            if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 563 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 564 | + }  | 
                                                        |
| 565 | + }  | 
                                                        |
| 566 | 566 | |
| 567 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { | 
                                                        |
| 568 | - $installer->create_invoice_items_table();  | 
                                                        |
| 567 | +        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { | 
                                                        |
| 568 | + $installer->create_invoice_items_table();  | 
                                                        |
| 569 | 569 | |
| 570 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 571 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 572 | - }  | 
                                                        |
| 573 | - }  | 
                                                        |
| 570 | +            if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 571 | + $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 572 | + }  | 
                                                        |
| 573 | + }  | 
                                                        |
| 574 | 574 | |
| 575 | -		if ( ! $this->has_notices() ) { | 
                                                        |
| 576 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );  | 
                                                        |
| 577 | - }  | 
                                                        |
| 575 | +        if ( ! $this->has_notices() ) { | 
                                                        |
| 576 | + $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );  | 
                                                        |
| 577 | + }  | 
                                                        |
| 578 | 578 | |
| 579 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 580 | - exit;  | 
                                                        |
| 581 | - }  | 
                                                        |
| 579 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 580 | + exit;  | 
                                                        |
| 581 | + }  | 
                                                        |
| 582 | 582 | |
| 583 | - /**  | 
                                                        |
| 583 | + /**  | 
                                                        |
| 584 | 584 | * Migrates old invoices to the new database tables.  | 
                                                        
| 585 | - *  | 
                                                        |
| 585 | + *  | 
                                                        |
| 586 | 586 | */  | 
                                                        
| 587 | 587 |      public function admin_migrate_old_invoices() { | 
                                                        
| 588 | 588 | |
| 589 | - // Migrate the invoices.  | 
                                                        |
| 590 | - $installer = new GetPaid_Installer();  | 
                                                        |
| 591 | - $installer->migrate_old_invoices();  | 
                                                        |
| 589 | + // Migrate the invoices.  | 
                                                        |
| 590 | + $installer = new GetPaid_Installer();  | 
                                                        |
| 591 | + $installer->migrate_old_invoices();  | 
                                                        |
| 592 | 592 | |
| 593 | - // Show an admin message.  | 
                                                        |
| 594 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );  | 
                                                        |
| 593 | + // Show an admin message.  | 
                                                        |
| 594 | + $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );  | 
                                                        |
| 595 | 595 | |
| 596 | - // Redirect the admin.  | 
                                                        |
| 597 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 598 | - exit;  | 
                                                        |
| 596 | + // Redirect the admin.  | 
                                                        |
| 597 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 598 | + exit;  | 
                                                        |
| 599 | 599 | |
| 600 | - }  | 
                                                        |
| 600 | + }  | 
                                                        |
| 601 | 601 | |
| 602 | - /**  | 
                                                        |
| 602 | + /**  | 
                                                        |
| 603 | 603 | * Download customers.  | 
                                                        
| 604 | - *  | 
                                                        |
| 604 | + *  | 
                                                        |
| 605 | 605 | */  | 
                                                        
| 606 | 606 |      public function admin_download_customers() { | 
                                                        
| 607 | - global $wpdb;  | 
                                                        |
| 607 | + global $wpdb;  | 
                                                        |
| 608 | 608 | |
| 609 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );  | 
                                                        |
| 609 | + $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );  | 
                                                        |
| 610 | 610 | |
| 611 | - header( "Content-Type:text/csv" );  | 
                                                        |
| 612 | - header( "Content-Disposition:attachment;filename=customers.csv" );  | 
                                                        |
| 611 | + header( "Content-Type:text/csv" );  | 
                                                        |
| 612 | + header( "Content-Disposition:attachment;filename=customers.csv" );  | 
                                                        |
| 613 | 613 | |
| 614 | - $post_types = '';  | 
                                                        |
| 614 | + $post_types = '';  | 
                                                        |
| 615 | 615 | |
| 616 | -		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { | 
                                                        |
| 617 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );  | 
                                                        |
| 618 | - }  | 
                                                        |
| 616 | +        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { | 
                                                        |
| 617 | + $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );  | 
                                                        |
| 618 | + }  | 
                                                        |
| 619 | 619 | |
| 620 | - $post_types = rtrim( $post_types, ' OR' );  | 
                                                        |
| 620 | + $post_types = rtrim( $post_types, ' OR' );  | 
                                                        |
| 621 | 621 | |
| 622 | - $customers = $wpdb->get_col(  | 
                                                        |
| 623 | - $wpdb->prepare(  | 
                                                        |
| 624 | - "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"  | 
                                                        |
| 625 | - )  | 
                                                        |
| 626 | - );  | 
                                                        |
| 622 | + $customers = $wpdb->get_col(  | 
                                                        |
| 623 | + $wpdb->prepare(  | 
                                                        |
| 624 | + "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"  | 
                                                        |
| 625 | + )  | 
                                                        |
| 626 | + );  | 
                                                        |
| 627 | 627 | |
| 628 | - $columns = array(  | 
                                                        |
| 629 | - 'name' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 630 | - 'email' => __( 'Email', 'invoicing' ),  | 
                                                        |
| 631 | - 'country' => __( 'Country', 'invoicing' ),  | 
                                                        |
| 632 | - 'state' => __( 'State', 'invoicing' ),  | 
                                                        |
| 633 | - 'city' => __( 'City', 'invoicing' ),  | 
                                                        |
| 634 | - 'zip' => __( 'ZIP', 'invoicing' ),  | 
                                                        |
| 635 | - 'address' => __( 'Address', 'invoicing' ),  | 
                                                        |
| 636 | - 'phone' => __( 'Phone', 'invoicing' ),  | 
                                                        |
| 637 | - 'company' => __( 'Company', 'invoicing' ),  | 
                                                        |
| 638 | - 'company_id' => __( 'Company ID', 'invoicing' ),  | 
                                                        |
| 639 | - 'invoices' => __( 'Invoices', 'invoicing' ),  | 
                                                        |
| 640 | - 'total_raw' => __( 'Total Spend', 'invoicing' ),  | 
                                                        |
| 641 | - 'signup' => __( 'Date created', 'invoicing' ),  | 
                                                        |
| 642 | - );  | 
                                                        |
| 628 | + $columns = array(  | 
                                                        |
| 629 | + 'name' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 630 | + 'email' => __( 'Email', 'invoicing' ),  | 
                                                        |
| 631 | + 'country' => __( 'Country', 'invoicing' ),  | 
                                                        |
| 632 | + 'state' => __( 'State', 'invoicing' ),  | 
                                                        |
| 633 | + 'city' => __( 'City', 'invoicing' ),  | 
                                                        |
| 634 | + 'zip' => __( 'ZIP', 'invoicing' ),  | 
                                                        |
| 635 | + 'address' => __( 'Address', 'invoicing' ),  | 
                                                        |
| 636 | + 'phone' => __( 'Phone', 'invoicing' ),  | 
                                                        |
| 637 | + 'company' => __( 'Company', 'invoicing' ),  | 
                                                        |
| 638 | + 'company_id' => __( 'Company ID', 'invoicing' ),  | 
                                                        |
| 639 | + 'invoices' => __( 'Invoices', 'invoicing' ),  | 
                                                        |
| 640 | + 'total_raw' => __( 'Total Spend', 'invoicing' ),  | 
                                                        |
| 641 | + 'signup' => __( 'Date created', 'invoicing' ),  | 
                                                        |
| 642 | + );  | 
                                                        |
| 643 | 643 | |
| 644 | - // Output the csv column headers.  | 
                                                        |
| 645 | - fputcsv( $output, array_values( $columns ) );  | 
                                                        |
| 644 | + // Output the csv column headers.  | 
                                                        |
| 645 | + fputcsv( $output, array_values( $columns ) );  | 
                                                        |
| 646 | 646 | |
| 647 | - // Loop through  | 
                                                        |
| 648 | - $table = new WPInv_Customers_Table();  | 
                                                        |
| 649 | -		foreach ( $customers as $customer_id ) { | 
                                                        |
| 647 | + // Loop through  | 
                                                        |
| 648 | + $table = new WPInv_Customers_Table();  | 
                                                        |
| 649 | +        foreach ( $customers as $customer_id ) { | 
                                                        |
| 650 | 650 | |
| 651 | - $user = get_user_by( 'id', $customer_id );  | 
                                                        |
| 652 | - $row = array();  | 
                                                        |
| 653 | -			if ( empty( $user ) ) { | 
                                                        |
| 654 | - continue;  | 
                                                        |
| 655 | - }  | 
                                                        |
| 651 | + $user = get_user_by( 'id', $customer_id );  | 
                                                        |
| 652 | + $row = array();  | 
                                                        |
| 653 | +            if ( empty( $user ) ) { | 
                                                        |
| 654 | + continue;  | 
                                                        |
| 655 | + }  | 
                                                        |
| 656 | 656 | |
| 657 | -			foreach ( array_keys( $columns ) as $column ) { | 
                                                        |
| 657 | +            foreach ( array_keys( $columns ) as $column ) { | 
                                                        |
| 658 | 658 | |
| 659 | - $method = 'column_' . $column;  | 
                                                        |
| 659 | + $method = 'column_' . $column;  | 
                                                        |
| 660 | 660 | |
| 661 | -				if ( 'name' == $column ) { | 
                                                        |
| 662 | - $value = esc_html( $user->display_name );  | 
                                                        |
| 663 | -				} else if( 'email' == $column ) { | 
                                                        |
| 664 | - $value = sanitize_email( $user->user_email );  | 
                                                        |
| 665 | -				} else if ( is_callable( array( $table, $method ) ) ) { | 
                                                        |
| 666 | - $value = strip_tags( $table->$method( $user ) );  | 
                                                        |
| 667 | - }  | 
                                                        |
| 661 | +                if ( 'name' == $column ) { | 
                                                        |
| 662 | + $value = esc_html( $user->display_name );  | 
                                                        |
| 663 | +                } else if( 'email' == $column ) { | 
                                                        |
| 664 | + $value = sanitize_email( $user->user_email );  | 
                                                        |
| 665 | +                } else if ( is_callable( array( $table, $method ) ) ) { | 
                                                        |
| 666 | + $value = strip_tags( $table->$method( $user ) );  | 
                                                        |
| 667 | + }  | 
                                                        |
| 668 | 668 | |
| 669 | -				if ( empty( $value ) ) { | 
                                                        |
| 670 | - $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );  | 
                                                        |
| 671 | - }  | 
                                                        |
| 669 | +                if ( empty( $value ) ) { | 
                                                        |
| 670 | + $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );  | 
                                                        |
| 671 | + }  | 
                                                        |
| 672 | 672 | |
| 673 | - $row[] = $value;  | 
                                                        |
| 673 | + $row[] = $value;  | 
                                                        |
| 674 | 674 | |
| 675 | - }  | 
                                                        |
| 675 | + }  | 
                                                        |
| 676 | 676 | |
| 677 | - fputcsv( $output, $row );  | 
                                                        |
| 678 | - }  | 
                                                        |
| 677 | + fputcsv( $output, $row );  | 
                                                        |
| 678 | + }  | 
                                                        |
| 679 | 679 | |
| 680 | - fclose( $output );  | 
                                                        |
| 681 | - exit;  | 
                                                        |
| 680 | + fclose( $output );  | 
                                                        |
| 681 | + exit;  | 
                                                        |
| 682 | 682 | |
| 683 | - }  | 
                                                        |
| 683 | + }  | 
                                                        |
| 684 | 684 | |
| 685 | - /**  | 
                                                        |
| 685 | + /**  | 
                                                        |
| 686 | 686 | * Installs a plugin.  | 
                                                        
| 687 | - *  | 
                                                        |
| 688 | - * @param array $data  | 
                                                        |
| 687 | + *  | 
                                                        |
| 688 | + * @param array $data  | 
                                                        |
| 689 | 689 | */  | 
                                                        
| 690 | 690 |      public function admin_install_plugin( $data ) { | 
                                                        
| 691 | 691 | |
| 692 | -		if ( ! empty( $data['plugins'] ) ) { | 
                                                        |
| 693 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        |
| 694 | - wp_cache_flush();  | 
                                                        |
| 692 | +        if ( ! empty( $data['plugins'] ) ) { | 
                                                        |
| 693 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        |
| 694 | + wp_cache_flush();  | 
                                                        |
| 695 | 695 | |
| 696 | -			foreach ( $data['plugins'] as $slug => $file ) { | 
                                                        |
| 697 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );  | 
                                                        |
| 698 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 699 | - $installed = $upgrader->install( $plugin_zip );  | 
                                                        |
| 696 | +            foreach ( $data['plugins'] as $slug => $file ) { | 
                                                        |
| 697 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );  | 
                                                        |
| 698 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 699 | + $installed = $upgrader->install( $plugin_zip );  | 
                                                        |
| 700 | 700 | |
| 701 | -				if ( ! is_wp_error( $installed ) && $installed ) { | 
                                                        |
| 702 | - activate_plugin( $file, '', false, true );  | 
                                                        |
| 703 | -				} else { | 
                                                        |
| 704 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );  | 
                                                        |
| 705 | - }  | 
                                                        |
| 701 | +                if ( ! is_wp_error( $installed ) && $installed ) { | 
                                                        |
| 702 | + activate_plugin( $file, '', false, true );  | 
                                                        |
| 703 | +                } else { | 
                                                        |
| 704 | + wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );  | 
                                                        |
| 705 | + }  | 
                                                        |
| 706 | 706 | |
| 707 | - }  | 
                                                        |
| 707 | + }  | 
                                                        |
| 708 | 708 | |
| 709 | - }  | 
                                                        |
| 709 | + }  | 
                                                        |
| 710 | 710 | |
| 711 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );  | 
                                                        |
| 712 | - wp_safe_redirect( $redirect );  | 
                                                        |
| 713 | - exit;  | 
                                                        |
| 711 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );  | 
                                                        |
| 712 | + wp_safe_redirect( $redirect );  | 
                                                        |
| 713 | + exit;  | 
                                                        |
| 714 | 714 | |
| 715 | - }  | 
                                                        |
| 715 | + }  | 
                                                        |
| 716 | 716 | |
| 717 | - /**  | 
                                                        |
| 717 | + /**  | 
                                                        |
| 718 | 718 | * Connects a gateway.  | 
                                                        
| 719 | - *  | 
                                                        |
| 720 | - * @param array $data  | 
                                                        |
| 719 | + *  | 
                                                        |
| 720 | + * @param array $data  | 
                                                        |
| 721 | 721 | */  | 
                                                        
| 722 | 722 |      public function admin_connect_gateway( $data ) { | 
                                                        
| 723 | 723 | |
| 724 | -		if ( ! empty( $data['plugin'] ) ) { | 
                                                        |
| 724 | +        if ( ! empty( $data['plugin'] ) ) { | 
                                                        |
| 725 | 725 | |
| 726 | - $gateway = sanitize_key( $data['plugin'] );  | 
                                                        |
| 727 | -			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 726 | + $gateway = sanitize_key( $data['plugin'] );  | 
                                                        |
| 727 | +            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 728 | 728 | |
| 729 | -			if ( ! empty( $connect_url ) ) { | 
                                                        |
| 730 | - wp_redirect( $connect_url );  | 
                                                        |
| 731 | - exit;  | 
                                                        |
| 732 | - }  | 
                                                        |
| 729 | +            if ( ! empty( $connect_url ) ) { | 
                                                        |
| 730 | + wp_redirect( $connect_url );  | 
                                                        |
| 731 | + exit;  | 
                                                        |
| 732 | + }  | 
                                                        |
| 733 | 733 | |
| 734 | -			if ( 'stripe' == $data['plugin'] ) { | 
                                                        |
| 735 | - require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 736 | - include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        |
| 737 | - wp_cache_flush();  | 
                                                        |
| 734 | +            if ( 'stripe' == $data['plugin'] ) { | 
                                                        |
| 735 | + require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 736 | + include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        |
| 737 | + wp_cache_flush();  | 
                                                        |
| 738 | 738 | |
| 739 | -				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { | 
                                                        |
| 740 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );  | 
                                                        |
| 741 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 742 | - $upgrader->install( $plugin_zip );  | 
                                                        |
| 743 | - }  | 
                                                        |
| 739 | +                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { | 
                                                        |
| 740 | + $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );  | 
                                                        |
| 741 | + $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 742 | + $upgrader->install( $plugin_zip );  | 
                                                        |
| 743 | + }  | 
                                                        |
| 744 | 744 | |
| 745 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );  | 
                                                        |
| 746 | - }  | 
                                                        |
| 745 | + activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );  | 
                                                        |
| 746 | + }  | 
                                                        |
| 747 | 747 | |
| 748 | -			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 749 | -			if ( ! empty( $connect_url ) ) { | 
                                                        |
| 750 | - wp_redirect( $connect_url );  | 
                                                        |
| 751 | - exit;  | 
                                                        |
| 752 | - }  | 
                                                        |
| 748 | +            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 749 | +            if ( ! empty( $connect_url ) ) { | 
                                                        |
| 750 | + wp_redirect( $connect_url );  | 
                                                        |
| 751 | + exit;  | 
                                                        |
| 752 | + }  | 
                                                        |
| 753 | 753 | |
| 754 | - }  | 
                                                        |
| 754 | + }  | 
                                                        |
| 755 | 755 | |
| 756 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );  | 
                                                        |
| 757 | - wp_safe_redirect( $redirect );  | 
                                                        |
| 758 | - exit;  | 
                                                        |
| 756 | + $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );  | 
                                                        |
| 757 | + wp_safe_redirect( $redirect );  | 
                                                        |
| 758 | + exit;  | 
                                                        |
| 759 | 759 | |
| 760 | - }  | 
                                                        |
| 760 | + }  | 
                                                        |
| 761 | 761 | |
| 762 | - /**  | 
                                                        |
| 762 | + /**  | 
                                                        |
| 763 | 763 | * Recalculates discounts.  | 
                                                        
| 764 | - *  | 
                                                        |
| 764 | + *  | 
                                                        |
| 765 | 765 | */  | 
                                                        
| 766 | 766 |      public function admin_recalculate_discounts() { | 
                                                        
| 767 | - global $wpdb;  | 
                                                        |
| 767 | + global $wpdb;  | 
                                                        |
| 768 | 768 | |
| 769 | - // Fetch all invoices that have discount codes.  | 
                                                        |
| 770 | - $table = $wpdb->prefix . 'getpaid_invoices';  | 
                                                        |
| 771 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );  | 
                                                        |
| 769 | + // Fetch all invoices that have discount codes.  | 
                                                        |
| 770 | + $table = $wpdb->prefix . 'getpaid_invoices';  | 
                                                        |
| 771 | + $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );  | 
                                                        |
| 772 | 772 | |
| 773 | -		foreach ( $invoices as $invoice ) { | 
                                                        |
| 773 | +        foreach ( $invoices as $invoice ) { | 
                                                        |
| 774 | 774 | |
| 775 | - $invoice = new WPInv_Invoice( $invoice );  | 
                                                        |
| 775 | + $invoice = new WPInv_Invoice( $invoice );  | 
                                                        |
| 776 | 776 | |
| 777 | -			if ( ! $invoice->exists() ) { | 
                                                        |
| 778 | - continue;  | 
                                                        |
| 779 | - }  | 
                                                        |
| 777 | +            if ( ! $invoice->exists() ) { | 
                                                        |
| 778 | + continue;  | 
                                                        |
| 779 | + }  | 
                                                        |
| 780 | 780 | |
| 781 | - // Abort if the discount does not exist or does not apply here.  | 
                                                        |
| 782 | - $discount = new WPInv_Discount( $invoice->get_discount_code() );  | 
                                                        |
| 783 | -			if ( ! $discount->exists() ) { | 
                                                        |
| 784 | - continue;  | 
                                                        |
| 785 | - }  | 
                                                        |
| 781 | + // Abort if the discount does not exist or does not apply here.  | 
                                                        |
| 782 | + $discount = new WPInv_Discount( $invoice->get_discount_code() );  | 
                                                        |
| 783 | +            if ( ! $discount->exists() ) { | 
                                                        |
| 784 | + continue;  | 
                                                        |
| 785 | + }  | 
                                                        |
| 786 | 786 | |
| 787 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );  | 
                                                        |
| 788 | - $invoice->recalculate_total();  | 
                                                        |
| 787 | + $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );  | 
                                                        |
| 788 | + $invoice->recalculate_total();  | 
                                                        |
| 789 | 789 | |
| 790 | -			if ( $invoice->get_total_discount() > 0 ) { | 
                                                        |
| 791 | - $invoice->save();  | 
                                                        |
| 792 | - }  | 
                                                        |
| 790 | +            if ( $invoice->get_total_discount() > 0 ) { | 
                                                        |
| 791 | + $invoice->save();  | 
                                                        |
| 792 | + }  | 
                                                        |
| 793 | 793 | |
| 794 | - }  | 
                                                        |
| 794 | + }  | 
                                                        |
| 795 | 795 | |
| 796 | - // Show an admin message.  | 
                                                        |
| 797 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );  | 
                                                        |
| 796 | + // Show an admin message.  | 
                                                        |
| 797 | + $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );  | 
                                                        |
| 798 | 798 | |
| 799 | - // Redirect the admin.  | 
                                                        |
| 800 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 801 | - exit;  | 
                                                        |
| 799 | + // Redirect the admin.  | 
                                                        |
| 800 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 801 | + exit;  | 
                                                        |
| 802 | 802 | |
| 803 | - }  | 
                                                        |
| 803 | + }  | 
                                                        |
| 804 | 804 | |
| 805 | 805 | /**  | 
                                                        
| 806 | - * Returns an array of admin notices.  | 
                                                        |
| 807 | - *  | 
                                                        |
| 808 | - * @since 1.0.19  | 
                                                        |
| 806 | + * Returns an array of admin notices.  | 
                                                        |
| 807 | + *  | 
                                                        |
| 808 | + * @since 1.0.19  | 
                                                        |
| 809 | 809 | * @return array  | 
                                                        
| 810 | - */  | 
                                                        |
| 811 | -	public function get_notices() { | 
                                                        |
| 812 | - $notices = get_option( 'wpinv_admin_notices' );  | 
                                                        |
| 810 | + */  | 
                                                        |
| 811 | +    public function get_notices() { | 
                                                        |
| 812 | + $notices = get_option( 'wpinv_admin_notices' );  | 
                                                        |
| 813 | 813 | return is_array( $notices ) ? $notices : array();  | 
                                                        
| 814 | - }  | 
                                                        |
| 814 | + }  | 
                                                        |
| 815 | 815 | |
| 816 | - /**  | 
                                                        |
| 817 | - * Checks if we have any admin notices.  | 
                                                        |
| 818 | - *  | 
                                                        |
| 819 | - * @since 2.0.4  | 
                                                        |
| 816 | + /**  | 
                                                        |
| 817 | + * Checks if we have any admin notices.  | 
                                                        |
| 818 | + *  | 
                                                        |
| 819 | + * @since 2.0.4  | 
                                                        |
| 820 | 820 | * @return array  | 
                                                        
| 821 | - */  | 
                                                        |
| 822 | -	public function has_notices() { | 
                                                        |
| 823 | - return count( $this->get_notices() ) > 0;  | 
                                                        |
| 824 | - }  | 
                                                        |
| 825 | -  | 
                                                        |
| 826 | - /**  | 
                                                        |
| 827 | - * Clears all admin notices  | 
                                                        |
| 828 | - *  | 
                                                        |
| 829 | - * @access public  | 
                                                        |
| 830 | - * @since 1.0.19  | 
                                                        |
| 831 | - */  | 
                                                        |
| 832 | -	public function clear_notices() { | 
                                                        |
| 833 | - delete_option( 'wpinv_admin_notices' );  | 
                                                        |
| 834 | - }  | 
                                                        |
| 835 | -  | 
                                                        |
| 836 | - /**  | 
                                                        |
| 837 | - * Saves a new admin notice  | 
                                                        |
| 838 | - *  | 
                                                        |
| 839 | - * @access public  | 
                                                        |
| 840 | - * @since 1.0.19  | 
                                                        |
| 841 | - */  | 
                                                        |
| 842 | -	public function save_notice( $type, $message ) { | 
                                                        |
| 843 | - $notices = $this->get_notices();  | 
                                                        |
| 844 | -  | 
                                                        |
| 845 | -		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { | 
                                                        |
| 846 | - $notices[ $type ] = array();  | 
                                                        |
| 847 | - }  | 
                                                        |
| 848 | -  | 
                                                        |
| 849 | - $notices[ $type ][] = $message;  | 
                                                        |
| 850 | -  | 
                                                        |
| 851 | - update_option( 'wpinv_admin_notices', $notices );  | 
                                                        |
| 852 | - }  | 
                                                        |
| 853 | -  | 
                                                        |
| 854 | - /**  | 
                                                        |
| 855 | - * Displays a success notice  | 
                                                        |
| 856 | - *  | 
                                                        |
| 857 | - * @param string $msg The message to qeue.  | 
                                                        |
| 858 | - * @access public  | 
                                                        |
| 859 | - * @since 1.0.19  | 
                                                        |
| 860 | - */  | 
                                                        |
| 861 | -	public function show_success( $msg ) { | 
                                                        |
| 862 | - $this->save_notice( 'success', $msg );  | 
                                                        |
| 863 | - }  | 
                                                        |
| 864 | -  | 
                                                        |
| 865 | - /**  | 
                                                        |
| 866 | - * Displays a error notice  | 
                                                        |
| 867 | - *  | 
                                                        |
| 868 | - * @access public  | 
                                                        |
| 869 | - * @param string $msg The message to qeue.  | 
                                                        |
| 870 | - * @since 1.0.19  | 
                                                        |
| 871 | - */  | 
                                                        |
| 872 | -	public function show_error( $msg ) { | 
                                                        |
| 873 | - $this->save_notice( 'error', $msg );  | 
                                                        |
| 874 | - }  | 
                                                        |
| 875 | -  | 
                                                        |
| 876 | - /**  | 
                                                        |
| 877 | - * Displays a warning notice  | 
                                                        |
| 878 | - *  | 
                                                        |
| 879 | - * @access public  | 
                                                        |
| 880 | - * @param string $msg The message to qeue.  | 
                                                        |
| 881 | - * @since 1.0.19  | 
                                                        |
| 882 | - */  | 
                                                        |
| 883 | -	public function show_warning( $msg ) { | 
                                                        |
| 884 | - $this->save_notice( 'warning', $msg );  | 
                                                        |
| 885 | - }  | 
                                                        |
| 886 | -  | 
                                                        |
| 887 | - /**  | 
                                                        |
| 888 | - * Displays a info notice  | 
                                                        |
| 889 | - *  | 
                                                        |
| 890 | - * @access public  | 
                                                        |
| 891 | - * @param string $msg The message to qeue.  | 
                                                        |
| 892 | - * @since 1.0.19  | 
                                                        |
| 893 | - */  | 
                                                        |
| 894 | -	public function show_info( $msg ) { | 
                                                        |
| 895 | - $this->save_notice( 'info', $msg );  | 
                                                        |
| 896 | - }  | 
                                                        |
| 897 | -  | 
                                                        |
| 898 | - /**  | 
                                                        |
| 899 | - * Show notices  | 
                                                        |
| 900 | - *  | 
                                                        |
| 901 | - * @access public  | 
                                                        |
| 902 | - * @since 1.0.19  | 
                                                        |
| 903 | - */  | 
                                                        |
| 904 | -	public function show_notices() { | 
                                                        |
| 821 | + */  | 
                                                        |
| 822 | +    public function has_notices() { | 
                                                        |
| 823 | + return count( $this->get_notices() ) > 0;  | 
                                                        |
| 824 | + }  | 
                                                        |
| 825 | +  | 
                                                        |
| 826 | + /**  | 
                                                        |
| 827 | + * Clears all admin notices  | 
                                                        |
| 828 | + *  | 
                                                        |
| 829 | + * @access public  | 
                                                        |
| 830 | + * @since 1.0.19  | 
                                                        |
| 831 | + */  | 
                                                        |
| 832 | +    public function clear_notices() { | 
                                                        |
| 833 | + delete_option( 'wpinv_admin_notices' );  | 
                                                        |
| 834 | + }  | 
                                                        |
| 835 | +  | 
                                                        |
| 836 | + /**  | 
                                                        |
| 837 | + * Saves a new admin notice  | 
                                                        |
| 838 | + *  | 
                                                        |
| 839 | + * @access public  | 
                                                        |
| 840 | + * @since 1.0.19  | 
                                                        |
| 841 | + */  | 
                                                        |
| 842 | +    public function save_notice( $type, $message ) { | 
                                                        |
| 843 | + $notices = $this->get_notices();  | 
                                                        |
| 844 | +  | 
                                                        |
| 845 | +        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { | 
                                                        |
| 846 | + $notices[ $type ] = array();  | 
                                                        |
| 847 | + }  | 
                                                        |
| 848 | +  | 
                                                        |
| 849 | + $notices[ $type ][] = $message;  | 
                                                        |
| 850 | +  | 
                                                        |
| 851 | + update_option( 'wpinv_admin_notices', $notices );  | 
                                                        |
| 852 | + }  | 
                                                        |
| 853 | +  | 
                                                        |
| 854 | + /**  | 
                                                        |
| 855 | + * Displays a success notice  | 
                                                        |
| 856 | + *  | 
                                                        |
| 857 | + * @param string $msg The message to qeue.  | 
                                                        |
| 858 | + * @access public  | 
                                                        |
| 859 | + * @since 1.0.19  | 
                                                        |
| 860 | + */  | 
                                                        |
| 861 | +    public function show_success( $msg ) { | 
                                                        |
| 862 | + $this->save_notice( 'success', $msg );  | 
                                                        |
| 863 | + }  | 
                                                        |
| 864 | +  | 
                                                        |
| 865 | + /**  | 
                                                        |
| 866 | + * Displays a error notice  | 
                                                        |
| 867 | + *  | 
                                                        |
| 868 | + * @access public  | 
                                                        |
| 869 | + * @param string $msg The message to qeue.  | 
                                                        |
| 870 | + * @since 1.0.19  | 
                                                        |
| 871 | + */  | 
                                                        |
| 872 | +    public function show_error( $msg ) { | 
                                                        |
| 873 | + $this->save_notice( 'error', $msg );  | 
                                                        |
| 874 | + }  | 
                                                        |
| 875 | +  | 
                                                        |
| 876 | + /**  | 
                                                        |
| 877 | + * Displays a warning notice  | 
                                                        |
| 878 | + *  | 
                                                        |
| 879 | + * @access public  | 
                                                        |
| 880 | + * @param string $msg The message to qeue.  | 
                                                        |
| 881 | + * @since 1.0.19  | 
                                                        |
| 882 | + */  | 
                                                        |
| 883 | +    public function show_warning( $msg ) { | 
                                                        |
| 884 | + $this->save_notice( 'warning', $msg );  | 
                                                        |
| 885 | + }  | 
                                                        |
| 886 | +  | 
                                                        |
| 887 | + /**  | 
                                                        |
| 888 | + * Displays a info notice  | 
                                                        |
| 889 | + *  | 
                                                        |
| 890 | + * @access public  | 
                                                        |
| 891 | + * @param string $msg The message to qeue.  | 
                                                        |
| 892 | + * @since 1.0.19  | 
                                                        |
| 893 | + */  | 
                                                        |
| 894 | +    public function show_info( $msg ) { | 
                                                        |
| 895 | + $this->save_notice( 'info', $msg );  | 
                                                        |
| 896 | + }  | 
                                                        |
| 897 | +  | 
                                                        |
| 898 | + /**  | 
                                                        |
| 899 | + * Show notices  | 
                                                        |
| 900 | + *  | 
                                                        |
| 901 | + * @access public  | 
                                                        |
| 902 | + * @since 1.0.19  | 
                                                        |
| 903 | + */  | 
                                                        |
| 904 | +    public function show_notices() { | 
                                                        |
| 905 | 905 | |
| 906 | 906 | $notices = $this->get_notices();  | 
                                                        
| 907 | 907 | $this->clear_notices();  | 
                                                        
| 908 | 908 | |
| 909 | -		foreach ( $notices as $type => $messages ) { | 
                                                        |
| 909 | +        foreach ( $notices as $type => $messages ) { | 
                                                        |
| 910 | 910 | |
| 911 | -			if ( ! is_array( $messages ) ) { | 
                                                        |
| 912 | - continue;  | 
                                                        |
| 913 | - }  | 
                                                        |
| 911 | +            if ( ! is_array( $messages ) ) { | 
                                                        |
| 912 | + continue;  | 
                                                        |
| 913 | + }  | 
                                                        |
| 914 | 914 | |
| 915 | 915 | $type = sanitize_key( $type );  | 
                                                        
| 916 | -			foreach ( $messages as $message ) { | 
                                                        |
| 916 | +            foreach ( $messages as $message ) { | 
                                                        |
| 917 | 917 | $message = wp_kses_post( $message );  | 
                                                        
| 918 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";  | 
                                                        |
| 918 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";  | 
                                                        |
| 919 | 919 | }  | 
                                                        
| 920 | 920 | |
| 921 | 921 | }  | 
                                                        
| 922 | 922 | |
| 923 | -		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { | 
                                                        |
| 924 | -  | 
                                                        |
| 925 | -			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { | 
                                                        |
| 926 | - $url = wp_nonce_url(  | 
                                                        |
| 927 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),  | 
                                                        |
| 928 | - 'getpaid-nonce',  | 
                                                        |
| 929 | - 'getpaid-nonce'  | 
                                                        |
| 930 | - );  | 
                                                        |
| 931 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );  | 
                                                        |
| 932 | - $message2 = __( 'Generate Pages', 'invoicing' );  | 
                                                        |
| 933 | - echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";  | 
                                                        |
| 934 | - break;  | 
                                                        |
| 935 | - }  | 
                                                        |
| 923 | +        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { | 
                                                        |
| 924 | +  | 
                                                        |
| 925 | +            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { | 
                                                        |
| 926 | + $url = wp_nonce_url(  | 
                                                        |
| 927 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),  | 
                                                        |
| 928 | + 'getpaid-nonce',  | 
                                                        |
| 929 | + 'getpaid-nonce'  | 
                                                        |
| 930 | + );  | 
                                                        |
| 931 | + $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );  | 
                                                        |
| 932 | + $message2 = __( 'Generate Pages', 'invoicing' );  | 
                                                        |
| 933 | + echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";  | 
                                                        |
| 934 | + break;  | 
                                                        |
| 935 | + }  | 
                                                        |
| 936 | 936 | |
| 937 | - }  | 
                                                        |
| 937 | + }  | 
                                                        |
| 938 | 938 | |
| 939 | - }  | 
                                                        |
| 939 | + }  | 
                                                        |
| 940 | 940 | |
| 941 | 941 | }  | 
                                                        
@@ -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 | * The main admin class.  | 
                                                        
@@ -37,13 +37,13 @@ discard block  | 
                                                    ||
| 37 | 37 | /**  | 
                                                        
| 38 | 38 | * Class constructor.  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | -	public function __construct(){ | 
                                                        |
| 40 | +	public function __construct() { | 
                                                        |
| 41 | 41 | |
| 42 | - $this->admin_path = plugin_dir_path( __FILE__ );  | 
                                                        |
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ );  | 
                                                        |
| 42 | + $this->admin_path = plugin_dir_path(__FILE__);  | 
                                                        |
| 43 | +		$this->admin_url   = plugins_url('/', __FILE__); | 
                                                        |
| 44 | 44 | $this->reports = new GetPaid_Reports();  | 
                                                        
| 45 | 45 | |
| 46 | -        if ( is_admin() ) { | 
                                                        |
| 46 | +        if (is_admin()) { | 
                                                        |
| 47 | 47 | $this->init_admin_hooks();  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
@@ -54,33 +54,33 @@ discard block  | 
                                                    ||
| 54 | 54 | *  | 
                                                        
| 55 | 55 | */  | 
                                                        
| 56 | 56 |  	private function init_admin_hooks() { | 
                                                        
| 57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );  | 
                                                        |
| 58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );  | 
                                                        |
| 59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );  | 
                                                        |
| 60 | - add_action( 'admin_init', array( $this, 'activation_redirect') );  | 
                                                        |
| 61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );  | 
                                                        |
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) );  | 
                                                        |
| 63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );  | 
                                                        |
| 64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );  | 
                                                        |
| 65 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );  | 
                                                        |
| 66 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );  | 
                                                        |
| 67 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );  | 
                                                        |
| 68 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );  | 
                                                        |
| 69 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );  | 
                                                        |
| 70 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );  | 
                                                        |
| 71 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );  | 
                                                        |
| 72 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );  | 
                                                        |
| 73 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );  | 
                                                        |
| 74 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );  | 
                                                        |
| 75 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );  | 
                                                        |
| 76 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );  | 
                                                        |
| 77 | - do_action( 'getpaid_init_admin_hooks', $this );  | 
                                                        |
| 57 | +        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); | 
                                                        |
| 58 | +        add_filter('admin_body_class', array($this, 'admin_body_class')); | 
                                                        |
| 59 | +        add_action('admin_init', array($this, 'init_ayecode_connect_helper')); | 
                                                        |
| 60 | +        add_action('admin_init', array($this, 'activation_redirect')); | 
                                                        |
| 61 | +        add_action('admin_init', array($this, 'maybe_do_admin_action')); | 
                                                        |
| 62 | +		add_action('admin_notices', array($this, 'show_notices')); | 
                                                        |
| 63 | +		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); | 
                                                        |
| 64 | +		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); | 
                                                        |
| 65 | +		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); | 
                                                        |
| 66 | +		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); | 
                                                        |
| 67 | +		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); | 
                                                        |
| 68 | +        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); | 
                                                        |
| 69 | +		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); | 
                                                        |
| 70 | +		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); | 
                                                        |
| 71 | +		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); | 
                                                        |
| 72 | +		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); | 
                                                        |
| 73 | +		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); | 
                                                        |
| 74 | +		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); | 
                                                        |
| 75 | +		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); | 
                                                        |
| 76 | +		add_filter('admin_footer_text', array($this, 'admin_footer_text')); | 
                                                        |
| 77 | +		do_action('getpaid_init_admin_hooks', $this); | 
                                                        |
| 78 | 78 | |
| 79 | 79 | // Setup/welcome  | 
                                                        
| 80 | -		if ( ! empty( $_GET['page'] ) ) { | 
                                                        |
| 81 | -			switch ( $_GET['page'] ) { | 
                                                        |
| 80 | +		if (!empty($_GET['page'])) { | 
                                                        |
| 81 | +			switch ($_GET['page']) { | 
                                                        |
| 82 | 82 | case 'gp-setup' :  | 
                                                        
| 83 | - include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );  | 
                                                        |
| 83 | + include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');  | 
                                                        |
| 84 | 84 | break;  | 
                                                        
| 85 | 85 | }  | 
                                                        
| 86 | 86 | }  | 
                                                        
@@ -94,37 +94,37 @@ discard block  | 
                                                    ||
| 94 | 94 |  	public function enqeue_scripts() { | 
                                                        
| 95 | 95 | global $current_screen, $pagenow;  | 
                                                        
| 96 | 96 | |
| 97 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 97 | + $page = isset($_GET['page']) ? $_GET['page'] : '';  | 
                                                        |
| 98 | 98 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';  | 
                                                        
| 99 | 99 | |
| 100 | -        if ( ! empty( $current_screen->post_type ) ) { | 
                                                        |
| 100 | +        if (!empty($current_screen->post_type)) { | 
                                                        |
| 101 | 101 | $page = $current_screen->post_type;  | 
                                                        
| 102 | 102 | }  | 
                                                        
| 103 | 103 | |
| 104 | 104 | // General styles.  | 
                                                        
| 105 | -        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page ) { | 
                                                        |
| 105 | +        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page) { | 
                                                        |
| 106 | 106 | |
| 107 | 107 | // Styles.  | 
                                                        
| 108 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );  | 
                                                        |
| 109 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );  | 
                                                        |
| 110 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );  | 
                                                        |
| 108 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');  | 
                                                        |
| 109 | +            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); | 
                                                        |
| 110 | +            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); | 
                                                        |
| 111 | 111 | |
| 112 | 112 | // Scripts.  | 
                                                        
| 113 | -            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); | 
                                                        |
| 113 | +            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); | 
                                                        |
| 114 | 114 | |
| 115 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );  | 
                                                        |
| 116 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version );  | 
                                                        |
| 117 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );  | 
                                                        |
| 115 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');  | 
                                                        |
| 116 | +            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); | 
                                                        |
| 117 | +            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); | 
                                                        |
| 118 | 118 | |
| 119 | 119 | }  | 
                                                        
| 120 | 120 | |
| 121 | 121 | // Payment form scripts.  | 
                                                        
| 122 | -		if ( 'wpi_payment_form' == $page && $editing ) { | 
                                                        |
| 122 | +		if ('wpi_payment_form' == $page && $editing) { | 
                                                        |
| 123 | 123 | $this->load_payment_form_scripts();  | 
                                                        
| 124 | 124 | }  | 
                                                        
| 125 | 125 | |
| 126 | -		if ( $page == 'wpinv-subscriptions' ) { | 
                                                        |
| 127 | - wp_enqueue_script( 'postbox' );  | 
                                                        |
| 126 | +		if ($page == 'wpinv-subscriptions') { | 
                                                        |
| 127 | +			wp_enqueue_script('postbox'); | 
                                                        |
| 128 | 128 | }  | 
                                                        
| 129 | 129 | |
| 130 | 130 | }  | 
                                                        
@@ -137,32 +137,32 @@ discard block  | 
                                                    ||
| 137 | 137 | global $post;  | 
                                                        
| 138 | 138 | |
| 139 | 139 | $date_range = array(  | 
                                                        
| 140 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'  | 
                                                        |
| 140 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'  | 
                                                        |
| 141 | 141 | );  | 
                                                        
| 142 | 142 | |
| 143 | -		if ( $date_range['period'] == 'custom' ) { | 
                                                        |
| 143 | +		if ($date_range['period'] == 'custom') { | 
                                                        |
| 144 | 144 | |
| 145 | -			if ( isset( $_GET['from'] ) ) { | 
                                                        |
| 146 | - $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );  | 
                                                        |
| 145 | +			if (isset($_GET['from'])) { | 
                                                        |
| 146 | +				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); | 
                                                        |
| 147 | 147 | }  | 
                                                        
| 148 | 148 | |
| 149 | -			if ( isset( $_GET['to'] ) ) { | 
                                                        |
| 150 | - $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );  | 
                                                        |
| 149 | +			if (isset($_GET['to'])) { | 
                                                        |
| 150 | +				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); | 
                                                        |
| 151 | 151 | }  | 
                                                        
| 152 | 152 | |
| 153 | 153 | }  | 
                                                        
| 154 | 154 | |
| 155 | 155 | $i18n = array(  | 
                                                        
| 156 | - 'ajax_url' => admin_url( 'admin-ajax.php' ),  | 
                                                        |
| 157 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '',  | 
                                                        |
| 158 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ),  | 
                                                        |
| 159 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ),  | 
                                                        |
| 160 | - 'rest_root' => esc_url_raw( rest_url() ),  | 
                                                        |
| 156 | +            'ajax_url'                  => admin_url('admin-ajax.php'), | 
                                                        |
| 157 | + 'post_ID' => isset($post->ID) ? $post->ID : '',  | 
                                                        |
| 158 | +			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'), | 
                                                        |
| 159 | +			'rest_nonce'                => wp_create_nonce('wp_rest'), | 
                                                        |
| 160 | + 'rest_root' => esc_url_raw(rest_url()),  | 
                                                        |
| 161 | 161 | 'date_range' => $date_range,  | 
                                                        
| 162 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ),  | 
                                                        |
| 163 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),  | 
                                                        |
| 164 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ),  | 
                                                        |
| 165 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ),  | 
                                                        |
| 162 | +            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'), | 
                                                        |
| 163 | +            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), | 
                                                        |
| 164 | +            'invoice_item_nonce'        => wp_create_nonce('invoice-item'), | 
                                                        |
| 165 | +            'billing_details_nonce'     => wp_create_nonce('get-billing-details'), | 
                                                        |
| 166 | 166 | 'tax' => wpinv_tax_amount(),  | 
                                                        
| 167 | 167 | 'discount' => 0,  | 
                                                        
| 168 | 168 | 'currency_symbol' => wpinv_currency_symbol(),  | 
                                                        
@@ -171,38 +171,38 @@ discard block  | 
                                                    ||
| 171 | 171 | 'thousand_sep' => wpinv_thousands_separator(),  | 
                                                        
| 172 | 172 | 'decimal_sep' => wpinv_decimal_separator(),  | 
                                                        
| 173 | 173 | 'decimals' => wpinv_decimals(),  | 
                                                        
| 174 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ),  | 
                                                        |
| 175 | - 'status_publish' => wpinv_status_nicename( 'publish' ),  | 
                                                        |
| 176 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ),  | 
                                                        |
| 177 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),  | 
                                                        |
| 178 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ),  | 
                                                        |
| 179 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),  | 
                                                        |
| 180 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),  | 
                                                        |
| 181 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ),  | 
                                                        |
| 182 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),  | 
                                                        |
| 183 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),  | 
                                                        |
| 184 | - 'action_edit' => __( 'Edit', 'invoicing' ),  | 
                                                        |
| 185 | - 'action_cancel' => __( 'Cancel', 'invoicing' ),  | 
                                                        |
| 186 | - 'item_description' => __( 'Item Description', 'invoicing' ),  | 
                                                        |
| 187 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ),  | 
                                                        |
| 188 | - 'discount_description' => __( 'Discount Description', 'invoicing' ),  | 
                                                        |
| 189 | - 'searching' => __( 'Searching', 'invoicing' ),  | 
                                                        |
| 190 | - 'loading' => __( 'Loading...', 'invoicing' ),  | 
                                                        |
| 191 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ),  | 
                                                        |
| 192 | - 'search_items' => __( 'Enter item name', 'invoicing' ),  | 
                                                        |
| 174 | +            'save_invoice'              => __('Save Invoice', 'invoicing'), | 
                                                        |
| 175 | +            'status_publish'            => wpinv_status_nicename('publish'), | 
                                                        |
| 176 | +            'status_pending'            => wpinv_status_nicename('wpi-pending'), | 
                                                        |
| 177 | +            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'), | 
                                                        |
| 178 | +            'status_pending'            => wpinv_status_nicename('wpi-pending'), | 
                                                        |
| 179 | +            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), | 
                                                        |
| 180 | +            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), | 
                                                        |
| 181 | +            'AreYouSure'                => __('Are you sure?', 'invoicing'), | 
                                                        |
| 182 | +            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), | 
                                                        |
| 183 | +            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'), | 
                                                        |
| 184 | +            'action_edit'               => __('Edit', 'invoicing'), | 
                                                        |
| 185 | +            'action_cancel'             => __('Cancel', 'invoicing'), | 
                                                        |
| 186 | +            'item_description'          => __('Item Description', 'invoicing'), | 
                                                        |
| 187 | +            'invoice_description'       => __('Invoice Description', 'invoicing'), | 
                                                        |
| 188 | +            'discount_description'      => __('Discount Description', 'invoicing'), | 
                                                        |
| 189 | +			'searching'                 => __('Searching', 'invoicing'), | 
                                                        |
| 190 | +			'loading'                   => __('Loading...', 'invoicing'), | 
                                                        |
| 191 | +			'search_customers'          => __('Enter customer name or email', 'invoicing'), | 
                                                        |
| 192 | +			'search_items'              => __('Enter item name', 'invoicing'), | 
                                                        |
| 193 | 193 | );  | 
                                                        
| 194 | 194 | |
| 195 | -		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { | 
                                                        |
| 195 | +		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { | 
                                                        |
| 196 | 196 | |
| 197 | - $invoice = new WPInv_Invoice( $post );  | 
                                                        |
| 197 | + $invoice = new WPInv_Invoice($post);  | 
                                                        |
| 198 | 198 | $i18n['save_invoice'] = sprintf(  | 
                                                        
| 199 | - __( 'Save %s', 'invoicing' ),  | 
                                                        |
| 200 | - ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 199 | +				__('Save %s', 'invoicing'), | 
                                                        |
| 200 | + ucfirst($invoice->get_invoice_quote_type())  | 
                                                        |
| 201 | 201 | );  | 
                                                        
| 202 | 202 | |
| 203 | 203 | $i18n['invoice_description'] = sprintf(  | 
                                                        
| 204 | - __( '%s Description', 'invoicing' ),  | 
                                                        |
| 205 | - ucfirst( $invoice->get_invoice_quote_type() )  | 
                                                        |
| 204 | +				__('%s Description', 'invoicing'), | 
                                                        |
| 205 | + ucfirst($invoice->get_invoice_quote_type())  | 
                                                        |
| 206 | 206 | );  | 
                                                        
| 207 | 207 | |
| 208 | 208 | }  | 
                                                        
@@ -216,24 +216,24 @@ discard block  | 
                                                    ||
| 216 | 216 | * @param string $footer_text  | 
                                                        
| 217 | 217 | * @return string  | 
                                                        
| 218 | 218 | */  | 
                                                        
| 219 | -	public function admin_footer_text( $footer_text ) { | 
                                                        |
| 219 | +	public function admin_footer_text($footer_text) { | 
                                                        |
| 220 | 220 | global $current_screen;  | 
                                                        
| 221 | 221 | |
| 222 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 222 | + $page = isset($_GET['page']) ? $_GET['page'] : '';  | 
                                                        |
| 223 | 223 | |
| 224 | -        if ( ! empty( $current_screen->post_type ) ) { | 
                                                        |
| 224 | +        if (!empty($current_screen->post_type)) { | 
                                                        |
| 225 | 225 | $page = $current_screen->post_type;  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | 228 | // General styles.  | 
                                                        
| 229 | -        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { | 
                                                        |
| 229 | +        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { | 
                                                        |
| 230 | 230 | |
| 231 | 231 | // Change the footer text  | 
                                                        
| 232 | -			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { | 
                                                        |
| 232 | +			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { | 
                                                        |
| 233 | 233 | |
| 234 | - $rating_url = esc_url(  | 
                                                        |
| 234 | + $rating_url = esc_url(  | 
                                                        |
| 235 | 235 | wp_nonce_url(  | 
                                                        
| 236 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),  | 
                                                        |
| 236 | +						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), | 
                                                        |
| 237 | 237 | 'getpaid-nonce',  | 
                                                        
| 238 | 238 | 'getpaid-nonce'  | 
                                                        
| 239 | 239 | )  | 
                                                        
@@ -241,7 +241,7 @@ discard block  | 
                                                    ||
| 241 | 241 | |
| 242 | 242 | $footer_text = sprintf(  | 
                                                        
| 243 | 243 | /* translators: %s: five stars */  | 
                                                        
| 244 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),  | 
                                                        |
| 244 | +					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), | 
                                                        |
| 245 | 245 | "<a href='$rating_url'>★★★★★</a>"  | 
                                                        
| 246 | 246 | );  | 
                                                        
| 247 | 247 | |
@@ -249,7 +249,7 @@ discard block  | 
                                                    ||
| 249 | 249 | |
| 250 | 250 | $footer_text = sprintf(  | 
                                                        
| 251 | 251 | /* translators: %s: GetPaid */  | 
                                                        
| 252 | - __( 'Thank you for using %s!', 'invoicing' ),  | 
                                                        |
| 252 | +					__('Thank you for using %s!', 'invoicing'), | 
                                                        |
| 253 | 253 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"  | 
                                                        
| 254 | 254 | );  | 
                                                        
| 255 | 255 | |
@@ -266,8 +266,8 @@ discard block  | 
                                                    ||
| 266 | 266 | * @since 2.0.0  | 
                                                        
| 267 | 267 | */  | 
                                                        
| 268 | 268 |  	public function redirect_to_wordpress_rating_page() { | 
                                                        
| 269 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );  | 
                                                        |
| 270 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );  | 
                                                        |
| 269 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);  | 
                                                        |
| 270 | +		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); | 
                                                        |
| 271 | 271 | exit;  | 
                                                        
| 272 | 272 | }  | 
                                                        
| 273 | 273 | |
@@ -278,30 +278,30 @@ discard block  | 
                                                    ||
| 278 | 278 |  	protected function load_payment_form_scripts() { | 
                                                        
| 279 | 279 | global $post;  | 
                                                        
| 280 | 280 | |
| 281 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );  | 
                                                        |
| 282 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );  | 
                                                        |
| 283 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );  | 
                                                        |
| 281 | +        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); | 
                                                        |
| 282 | +		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); | 
                                                        |
| 283 | +		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); | 
                                                        |
| 284 | 284 | |
| 285 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );  | 
                                                        |
| 286 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );  | 
                                                        |
| 285 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');  | 
                                                        |
| 286 | +		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version); | 
                                                        |
| 287 | 287 | |
| 288 | 288 | wp_localize_script(  | 
                                                        
| 289 | 289 | 'wpinv-admin-payment-form-script',  | 
                                                        
| 290 | 290 | 'wpinvPaymentFormAdmin',  | 
                                                        
| 291 | 291 | array(  | 
                                                        
| 292 | - 'elements' => wpinv_get_data( 'payment-form-elements' ),  | 
                                                        |
| 293 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ),  | 
                                                        |
| 292 | +				'elements'      => wpinv_get_data('payment-form-elements'), | 
                                                        |
| 293 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID),  | 
                                                        |
| 294 | 294 | 'currency' => wpinv_currency_symbol(),  | 
                                                        
| 295 | 295 | 'position' => wpinv_currency_position(),  | 
                                                        
| 296 | 296 | 'decimals' => (int) wpinv_decimals(),  | 
                                                        
| 297 | 297 | 'thousands_sep' => wpinv_thousands_separator(),  | 
                                                        
| 298 | 298 | 'decimals_sep' => wpinv_decimal_separator(),  | 
                                                        
| 299 | - 'form_items' => gepaid_get_form_items( $post->ID ),  | 
                                                        |
| 299 | + 'form_items' => gepaid_get_form_items($post->ID),  | 
                                                        |
| 300 | 300 | 'is_default' => $post->ID == wpinv_get_default_payment_form(),  | 
                                                        
| 301 | 301 | )  | 
                                                        
| 302 | 302 | );  | 
                                                        
| 303 | 303 | |
| 304 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' );  | 
                                                        |
| 304 | +        wp_enqueue_script('wpinv-admin-payment-form-script'); | 
                                                        |
| 305 | 305 | |
| 306 | 306 | }  | 
                                                        
| 307 | 307 | |
@@ -312,25 +312,25 @@ discard block  | 
                                                    ||
| 312 | 312 | * @return string  | 
                                                        
| 313 | 313 | *  | 
                                                        
| 314 | 314 | */  | 
                                                        
| 315 | -    public function admin_body_class( $classes ) { | 
                                                        |
| 315 | +    public function admin_body_class($classes) { | 
                                                        |
| 316 | 316 | global $pagenow, $post, $current_screen;  | 
                                                        
| 317 | 317 | |
| 318 | 318 | |
| 319 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : '';  | 
                                                        |
| 319 | + $page = isset($_GET['page']) ? $_GET['page'] : '';  | 
                                                        |
| 320 | 320 | |
| 321 | -        if ( ! empty( $current_screen->post_type ) ) { | 
                                                        |
| 321 | +        if (!empty($current_screen->post_type)) { | 
                                                        |
| 322 | 322 | $page = $current_screen->post_type;  | 
                                                        
| 323 | 323 | }  | 
                                                        
| 324 | 324 | |
| 325 | -        if ( false !== stripos( $page, 'wpi' ) ) { | 
                                                        |
| 326 | - $classes .= ' wpi-' . sanitize_key( $page );  | 
                                                        |
| 325 | +        if (false !== stripos($page, 'wpi')) { | 
                                                        |
| 326 | + $classes .= ' wpi-' . sanitize_key($page);  | 
                                                        |
| 327 | 327 | }  | 
                                                        
| 328 | 328 | |
| 329 | -        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { | 
                                                        |
| 329 | +        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { | 
                                                        |
| 330 | 330 | $classes .= ' wpinv-cpt wpinv';  | 
                                                        
| 331 | 331 | }  | 
                                                        
| 332 | 332 | |
| 333 | -		if ( getpaid_is_invoice_post_type( $page ) ) { | 
                                                        |
| 333 | +		if (getpaid_is_invoice_post_type($page)) { | 
                                                        |
| 334 | 334 | $classes .= ' getpaid-is-invoice-cpt';  | 
                                                        
| 335 | 335 | }  | 
                                                        
| 336 | 336 | |
@@ -340,7 +340,7 @@ discard block  | 
                                                    ||
| 340 | 340 | /**  | 
                                                        
| 341 | 341 | * Maybe show the AyeCode Connect Notice.  | 
                                                        
| 342 | 342 | */  | 
                                                        
| 343 | -	public function init_ayecode_connect_helper(){ | 
                                                        |
| 343 | +	public function init_ayecode_connect_helper() { | 
                                                        |
| 344 | 344 | |
| 345 | 345 | // Register with the deactivation survey class.  | 
                                                        
| 346 | 346 | AyeCode_Deactivation_Survey::instance(array(  | 
                                                        
@@ -348,20 +348,20 @@ discard block  | 
                                                    ||
| 348 | 348 | 'version' => WPINV_VERSION,  | 
                                                        
| 349 | 349 | 'support_url' => 'https://wpgetpaid.com/support/',  | 
                                                        
| 350 | 350 | 'documentation_url' => 'https://docs.wpgetpaid.com/',  | 
                                                        
| 351 | - 'activated' => (int) get_option( 'gepaid_installed_on' ),  | 
                                                        |
| 351 | +			'activated'         => (int) get_option('gepaid_installed_on'), | 
                                                        |
| 352 | 352 | ));  | 
                                                        
| 353 | 353 | |
| 354 | 354 | new AyeCode_Connect_Helper(  | 
                                                        
| 355 | 355 | array(  | 
                                                        
| 356 | -				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), | 
                                                        |
| 357 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ),  | 
                                                        |
| 358 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),  | 
                                                        |
| 359 | -				'connect_button'    => __("Connect Site","invoicing"), | 
                                                        |
| 360 | -				'connecting_button'    => __("Connecting...","invoicing"), | 
                                                        |
| 361 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ),  | 
                                                        |
| 362 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ),  | 
                                                        |
| 356 | +				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), | 
                                                        |
| 357 | +				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"), | 
                                                        |
| 358 | +				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), | 
                                                        |
| 359 | +				'connect_button'    => __("Connect Site", "invoicing"), | 
                                                        |
| 360 | +				'connecting_button'    => __("Connecting...", "invoicing"), | 
                                                        |
| 361 | +				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"), | 
                                                        |
| 362 | +				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"), | 
                                                        |
| 363 | 363 | ),  | 
                                                        
| 364 | - array( 'wpi-addons' )  | 
                                                        |
| 364 | +            array('wpi-addons') | 
                                                        |
| 365 | 365 | );  | 
                                                        
| 366 | 366 | |
| 367 | 367 | }  | 
                                                        
@@ -373,20 +373,20 @@ discard block  | 
                                                    ||
| 373 | 373 | */  | 
                                                        
| 374 | 374 |  	public function activation_redirect() { | 
                                                        
| 375 | 375 | |
| 376 | - $redirected = get_option( 'wpinv_redirected_to_settings' );  | 
                                                        |
| 376 | +		$redirected = get_option('wpinv_redirected_to_settings'); | 
                                                        |
| 377 | 377 | |
| 378 | -		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { | 
                                                        |
| 378 | +		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { | 
                                                        |
| 379 | 379 | return;  | 
                                                        
| 380 | 380 | }  | 
                                                        
| 381 | 381 | |
| 382 | 382 | // Bail if activating from network, or bulk  | 
                                                        
| 383 | -		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { | 
                                                        |
| 383 | +		if (is_network_admin() || isset($_GET['activate-multi'])) { | 
                                                        |
| 384 | 384 | return;  | 
                                                        
| 385 | 385 | }  | 
                                                        
| 386 | 386 | |
| 387 | - update_option( 'wpinv_redirected_to_settings', 1 );  | 
                                                        |
| 387 | +	    update_option('wpinv_redirected_to_settings', 1); | 
                                                        |
| 388 | 388 | |
| 389 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );  | 
                                                        |
| 389 | +        wp_safe_redirect(admin_url('index.php?page=gp-setup')); | 
                                                        |
| 390 | 390 | exit;  | 
                                                        
| 391 | 391 | |
| 392 | 392 | }  | 
                                                        
@@ -396,9 +396,9 @@ discard block  | 
                                                    ||
| 396 | 396 | */  | 
                                                        
| 397 | 397 |      public function maybe_do_admin_action() { | 
                                                        
| 398 | 398 | |
| 399 | -        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { | 
                                                        |
| 400 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );  | 
                                                        |
| 401 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );  | 
                                                        |
| 399 | +        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { | 
                                                        |
| 400 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']);  | 
                                                        |
| 401 | +            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); | 
                                                        |
| 402 | 402 | }  | 
                                                        
| 403 | 403 | |
| 404 | 404 | }  | 
                                                        
@@ -408,24 +408,24 @@ discard block  | 
                                                    ||
| 408 | 408 | *  | 
                                                        
| 409 | 409 | * @param array $args  | 
                                                        
| 410 | 410 | */  | 
                                                        
| 411 | -    public function duplicate_invoice( $args ) { | 
                                                        |
| 411 | +    public function duplicate_invoice($args) { | 
                                                        |
| 412 | 412 | |
| 413 | -		if ( empty( $args['invoice_id'] ) ) { | 
                                                        |
| 413 | +		if (empty($args['invoice_id'])) { | 
                                                        |
| 414 | 414 | return;  | 
                                                        
| 415 | 415 | }  | 
                                                        
| 416 | 416 | |
| 417 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );  | 
                                                        |
| 417 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']);  | 
                                                        |
| 418 | 418 | |
| 419 | -		if ( ! $invoice->exists() ) { | 
                                                        |
| 419 | +		if (!$invoice->exists()) { | 
                                                        |
| 420 | 420 | return;  | 
                                                        
| 421 | 421 | }  | 
                                                        
| 422 | 422 | |
| 423 | - $new_invoice = getpaid_duplicate_invoice( $invoice );  | 
                                                        |
| 423 | + $new_invoice = getpaid_duplicate_invoice($invoice);  | 
                                                        |
| 424 | 424 | $new_invoice->save();  | 
                                                        
| 425 | 425 | |
| 426 | -		if ( $new_invoice->exists() ) { | 
                                                        |
| 426 | +		if ($new_invoice->exists()) { | 
                                                        |
| 427 | 427 | |
| 428 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );  | 
                                                        |
| 428 | +			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box')); | 
                                                        |
| 429 | 429 | |
| 430 | 430 | wp_safe_redirect(  | 
                                                        
| 431 | 431 | add_query_arg(  | 
                                                        
@@ -433,14 +433,14 @@ discard block  | 
                                                    ||
| 433 | 433 | 'action' => 'edit',  | 
                                                        
| 434 | 434 | 'post' => $new_invoice->get_id(),  | 
                                                        
| 435 | 435 | ),  | 
                                                        
| 436 | - admin_url( 'post.php' )  | 
                                                        |
| 436 | +					admin_url('post.php') | 
                                                        |
| 437 | 437 | )  | 
                                                        
| 438 | 438 | );  | 
                                                        
| 439 | 439 | exit;  | 
                                                        
| 440 | 440 | |
| 441 | 441 | }  | 
                                                        
| 442 | 442 | |
| 443 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );  | 
                                                        |
| 443 | +		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box')); | 
                                                        |
| 444 | 444 | |
| 445 | 445 | }  | 
                                                        
| 446 | 446 | |
@@ -449,34 +449,34 @@ discard block  | 
                                                    ||
| 449 | 449 | *  | 
                                                        
| 450 | 450 | * @param array $args  | 
                                                        
| 451 | 451 | */  | 
                                                        
| 452 | -    public function duplicate_payment_form( $args ) { | 
                                                        |
| 452 | +    public function duplicate_payment_form($args) { | 
                                                        |
| 453 | 453 | |
| 454 | -		if ( empty( $args['form_id'] ) ) { | 
                                                        |
| 454 | +		if (empty($args['form_id'])) { | 
                                                        |
| 455 | 455 | return;  | 
                                                        
| 456 | 456 | }  | 
                                                        
| 457 | 457 | |
| 458 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] );  | 
                                                        |
| 458 | + $form = new GetPaid_Payment_Form((int) $args['form_id']);  | 
                                                        |
| 459 | 459 | |
| 460 | -		if ( ! $form->exists() ) { | 
                                                        |
| 460 | +		if (!$form->exists()) { | 
                                                        |
| 461 | 461 | return;  | 
                                                        
| 462 | 462 | }  | 
                                                        
| 463 | 463 | |
| 464 | 464 | $new_form = new GetPaid_Payment_Form();  | 
                                                        
| 465 | - $new_form->set_author( $form->get_author( 'edit' ) );  | 
                                                        |
| 466 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );  | 
                                                        |
| 467 | - $new_form->set_elements( $form->get_elements( 'edit' ) );  | 
                                                        |
| 468 | - $new_form->set_items( $form->get_items( 'edit' ) );  | 
                                                        |
| 465 | +		$new_form->set_author($form->get_author('edit')); | 
                                                        |
| 466 | +		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); | 
                                                        |
| 467 | +		$new_form->set_elements($form->get_elements('edit')); | 
                                                        |
| 468 | +		$new_form->set_items($form->get_items('edit')); | 
                                                        |
| 469 | 469 | $new_form->save();  | 
                                                        
| 470 | 470 | |
| 471 | -		if ( $new_form->exists() ) { | 
                                                        |
| 472 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );  | 
                                                        |
| 473 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' );  | 
                                                        |
| 471 | +		if ($new_form->exists()) { | 
                                                        |
| 472 | +			$this->show_success(__('Form duplicated successfully', 'invoicing')); | 
                                                        |
| 473 | + $url = get_edit_post_link($new_form->get_id(), 'edit');  | 
                                                        |
| 474 | 474 |  		} else { | 
                                                        
| 475 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );  | 
                                                        |
| 476 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );  | 
                                                        |
| 475 | +			$this->show_error(__('Unable to duplicate form', 'invoicing')); | 
                                                        |
| 476 | +			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); | 
                                                        |
| 477 | 477 | }  | 
                                                        
| 478 | 478 | |
| 479 | - wp_redirect( $url );  | 
                                                        |
| 479 | + wp_redirect($url);  | 
                                                        |
| 480 | 480 | exit;  | 
                                                        
| 481 | 481 | }  | 
                                                        
| 482 | 482 | |
@@ -485,16 +485,16 @@ discard block  | 
                                                    ||
| 485 | 485 | *  | 
                                                        
| 486 | 486 | * @param array $args  | 
                                                        
| 487 | 487 | */  | 
                                                        
| 488 | -    public function send_customer_invoice( $args ) { | 
                                                        |
| 489 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );  | 
                                                        |
| 488 | +    public function send_customer_invoice($args) { | 
                                                        |
| 489 | +		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); | 
                                                        |
| 490 | 490 | |
| 491 | -		if ( $sent ) { | 
                                                        |
| 492 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 491 | +		if ($sent) { | 
                                                        |
| 492 | +			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); | 
                                                        |
| 493 | 493 |  		} else { | 
                                                        
| 494 | - $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );  | 
                                                        |
| 494 | +			$this->show_error(__('Could not send the invoice to the customer', 'invoicing')); | 
                                                        |
| 495 | 495 | }  | 
                                                        
| 496 | 496 | |
| 497 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 497 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); | 
                                                        |
| 498 | 498 | exit;  | 
                                                        
| 499 | 499 | }  | 
                                                        
| 500 | 500 | |
@@ -503,16 +503,16 @@ discard block  | 
                                                    ||
| 503 | 503 | *  | 
                                                        
| 504 | 504 | * @param array $args  | 
                                                        
| 505 | 505 | */  | 
                                                        
| 506 | -    public function send_customer_payment_reminder( $args ) { | 
                                                        |
| 507 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );  | 
                                                        |
| 506 | +    public function send_customer_payment_reminder($args) { | 
                                                        |
| 507 | +		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); | 
                                                        |
| 508 | 508 | |
| 509 | -		if ( $sent ) { | 
                                                        |
| 510 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );  | 
                                                        |
| 509 | +		if ($sent) { | 
                                                        |
| 510 | +			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); | 
                                                        |
| 511 | 511 |  		} else { | 
                                                        
| 512 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );  | 
                                                        |
| 512 | +			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); | 
                                                        |
| 513 | 513 | }  | 
                                                        
| 514 | 514 | |
| 515 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );  | 
                                                        |
| 515 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); | 
                                                        |
| 516 | 516 | exit;  | 
                                                        
| 517 | 517 | }  | 
                                                        
| 518 | 518 | |
@@ -522,8 +522,8 @@ discard block  | 
                                                    ||
| 522 | 522 | */  | 
                                                        
| 523 | 523 |      public function admin_reset_tax_rates() { | 
                                                        
| 524 | 524 | |
| 525 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );  | 
                                                        |
| 526 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 525 | +		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); | 
                                                        |
| 526 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); | 
                                                        |
| 527 | 527 | exit;  | 
                                                        
| 528 | 528 | |
| 529 | 529 | }  | 
                                                        
@@ -535,8 +535,8 @@ discard block  | 
                                                    ||
| 535 | 535 |      public function admin_create_missing_pages() { | 
                                                        
| 536 | 536 | $installer = new GetPaid_Installer();  | 
                                                        
| 537 | 537 | $installer->create_pages();  | 
                                                        
| 538 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );  | 
                                                        |
| 539 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 538 | +		$this->show_success(__('GetPaid pages updated.', 'invoicing')); | 
                                                        |
| 539 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); | 
                                                        |
| 540 | 540 | exit;  | 
                                                        
| 541 | 541 | }  | 
                                                        
| 542 | 542 | |
@@ -548,35 +548,35 @@ discard block  | 
                                                    ||
| 548 | 548 | global $wpdb;  | 
                                                        
| 549 | 549 | $installer = new GetPaid_Installer();  | 
                                                        
| 550 | 550 | |
| 551 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) { | 
                                                        |
| 551 | +		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') { | 
                                                        |
| 552 | 552 | $installer->create_subscriptions_table();  | 
                                                        
| 553 | 553 | |
| 554 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 555 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 554 | +			if ($wpdb->last_error !== '') { | 
                                                        |
| 555 | +				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); | 
                                                        |
| 556 | 556 | }  | 
                                                        
| 557 | 557 | }  | 
                                                        
| 558 | 558 | |
| 559 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) { | 
                                                        |
| 559 | +		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') { | 
                                                        |
| 560 | 560 | $installer->create_invoices_table();  | 
                                                        
| 561 | 561 | |
| 562 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 563 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 562 | +			if ($wpdb->last_error !== '') { | 
                                                        |
| 563 | +				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); | 
                                                        |
| 564 | 564 | }  | 
                                                        
| 565 | 565 | }  | 
                                                        
| 566 | 566 | |
| 567 | -		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) { | 
                                                        |
| 567 | +		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') { | 
                                                        |
| 568 | 568 | $installer->create_invoice_items_table();  | 
                                                        
| 569 | 569 | |
| 570 | -			if ( $wpdb->last_error !== '' ) { | 
                                                        |
| 571 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );  | 
                                                        |
| 570 | +			if ($wpdb->last_error !== '') { | 
                                                        |
| 571 | +				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); | 
                                                        |
| 572 | 572 | }  | 
                                                        
| 573 | 573 | }  | 
                                                        
| 574 | 574 | |
| 575 | -		if ( ! $this->has_notices() ) { | 
                                                        |
| 576 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );  | 
                                                        |
| 575 | +		if (!$this->has_notices()) { | 
                                                        |
| 576 | +			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); | 
                                                        |
| 577 | 577 | }  | 
                                                        
| 578 | 578 | |
| 579 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 579 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); | 
                                                        |
| 580 | 580 | exit;  | 
                                                        
| 581 | 581 | }  | 
                                                        
| 582 | 582 | |
@@ -591,10 +591,10 @@ discard block  | 
                                                    ||
| 591 | 591 | $installer->migrate_old_invoices();  | 
                                                        
| 592 | 592 | |
| 593 | 593 | // Show an admin message.  | 
                                                        
| 594 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );  | 
                                                        |
| 594 | +		$this->show_success(__('Your invoices have been migrated.', 'invoicing')); | 
                                                        |
| 595 | 595 | |
| 596 | 596 | // Redirect the admin.  | 
                                                        
| 597 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 597 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); | 
                                                        |
| 598 | 598 | exit;  | 
                                                        
| 599 | 599 | |
| 600 | 600 | }  | 
                                                        
@@ -606,18 +606,18 @@ discard block  | 
                                                    ||
| 606 | 606 |      public function admin_download_customers() { | 
                                                        
| 607 | 607 | global $wpdb;  | 
                                                        
| 608 | 608 | |
| 609 | - $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );  | 
                                                        |
| 609 | +		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing')); | 
                                                        |
| 610 | 610 | |
| 611 | - header( "Content-Type:text/csv" );  | 
                                                        |
| 612 | - header( "Content-Disposition:attachment;filename=customers.csv" );  | 
                                                        |
| 611 | +		header("Content-Type:text/csv"); | 
                                                        |
| 612 | +		header("Content-Disposition:attachment;filename=customers.csv"); | 
                                                        |
| 613 | 613 | |
| 614 | 614 | $post_types = '';  | 
                                                        
| 615 | 615 | |
| 616 | -		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) { | 
                                                        |
| 617 | - $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );  | 
                                                        |
| 616 | +		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) { | 
                                                        |
| 617 | +			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type); | 
                                                        |
| 618 | 618 | }  | 
                                                        
| 619 | 619 | |
| 620 | - $post_types = rtrim( $post_types, ' OR' );  | 
                                                        |
| 620 | + $post_types = rtrim($post_types, ' OR');  | 
                                                        |
| 621 | 621 | |
| 622 | 622 | $customers = $wpdb->get_col(  | 
                                                        
| 623 | 623 | $wpdb->prepare(  | 
                                                        
@@ -626,58 +626,58 @@ discard block  | 
                                                    ||
| 626 | 626 | );  | 
                                                        
| 627 | 627 | |
| 628 | 628 | $columns = array(  | 
                                                        
| 629 | - 'name' => __( 'Name', 'invoicing' ),  | 
                                                        |
| 630 | - 'email' => __( 'Email', 'invoicing' ),  | 
                                                        |
| 631 | - 'country' => __( 'Country', 'invoicing' ),  | 
                                                        |
| 632 | - 'state' => __( 'State', 'invoicing' ),  | 
                                                        |
| 633 | - 'city' => __( 'City', 'invoicing' ),  | 
                                                        |
| 634 | - 'zip' => __( 'ZIP', 'invoicing' ),  | 
                                                        |
| 635 | - 'address' => __( 'Address', 'invoicing' ),  | 
                                                        |
| 636 | - 'phone' => __( 'Phone', 'invoicing' ),  | 
                                                        |
| 637 | - 'company' => __( 'Company', 'invoicing' ),  | 
                                                        |
| 638 | - 'company_id' => __( 'Company ID', 'invoicing' ),  | 
                                                        |
| 639 | - 'invoices' => __( 'Invoices', 'invoicing' ),  | 
                                                        |
| 640 | - 'total_raw' => __( 'Total Spend', 'invoicing' ),  | 
                                                        |
| 641 | - 'signup' => __( 'Date created', 'invoicing' ),  | 
                                                        |
| 629 | +			'name'     => __('Name', 'invoicing'), | 
                                                        |
| 630 | +			'email'    => __('Email', 'invoicing'), | 
                                                        |
| 631 | +			'country'  => __('Country', 'invoicing'), | 
                                                        |
| 632 | +			'state'    => __('State', 'invoicing'), | 
                                                        |
| 633 | +			'city'     => __('City', 'invoicing'), | 
                                                        |
| 634 | +			'zip'      => __('ZIP', 'invoicing'), | 
                                                        |
| 635 | +			'address'  => __('Address', 'invoicing'), | 
                                                        |
| 636 | +			'phone'    => __('Phone', 'invoicing'), | 
                                                        |
| 637 | +			'company'  => __('Company', 'invoicing'), | 
                                                        |
| 638 | +			'company_id'  => __('Company ID', 'invoicing'), | 
                                                        |
| 639 | +			'invoices' => __('Invoices', 'invoicing'), | 
                                                        |
| 640 | +			'total_raw' => __('Total Spend', 'invoicing'), | 
                                                        |
| 641 | +			'signup'   => __('Date created', 'invoicing'), | 
                                                        |
| 642 | 642 | );  | 
                                                        
| 643 | 643 | |
| 644 | 644 | // Output the csv column headers.  | 
                                                        
| 645 | - fputcsv( $output, array_values( $columns ) );  | 
                                                        |
| 645 | + fputcsv($output, array_values($columns));  | 
                                                        |
| 646 | 646 | |
| 647 | 647 | // Loop through  | 
                                                        
| 648 | 648 | $table = new WPInv_Customers_Table();  | 
                                                        
| 649 | -		foreach ( $customers as $customer_id ) { | 
                                                        |
| 649 | +		foreach ($customers as $customer_id) { | 
                                                        |
| 650 | 650 | |
| 651 | - $user = get_user_by( 'id', $customer_id );  | 
                                                        |
| 651 | +			$user = get_user_by('id', $customer_id); | 
                                                        |
| 652 | 652 | $row = array();  | 
                                                        
| 653 | -			if ( empty( $user ) ) { | 
                                                        |
| 653 | +			if (empty($user)) { | 
                                                        |
| 654 | 654 | continue;  | 
                                                        
| 655 | 655 | }  | 
                                                        
| 656 | 656 | |
| 657 | -			foreach ( array_keys( $columns ) as $column ) { | 
                                                        |
| 657 | +			foreach (array_keys($columns) as $column) { | 
                                                        |
| 658 | 658 | |
| 659 | 659 | $method = 'column_' . $column;  | 
                                                        
| 660 | 660 | |
| 661 | -				if ( 'name' == $column ) { | 
                                                        |
| 662 | - $value = esc_html( $user->display_name );  | 
                                                        |
| 663 | -				} else if( 'email' == $column ) { | 
                                                        |
| 664 | - $value = sanitize_email( $user->user_email );  | 
                                                        |
| 665 | -				} else if ( is_callable( array( $table, $method ) ) ) { | 
                                                        |
| 666 | - $value = strip_tags( $table->$method( $user ) );  | 
                                                        |
| 661 | +				if ('name' == $column) { | 
                                                        |
| 662 | + $value = esc_html($user->display_name);  | 
                                                        |
| 663 | +				} else if ('email' == $column) { | 
                                                        |
| 664 | + $value = sanitize_email($user->user_email);  | 
                                                        |
| 665 | +				} else if (is_callable(array($table, $method))) { | 
                                                        |
| 666 | + $value = strip_tags($table->$method($user));  | 
                                                        |
| 667 | 667 | }  | 
                                                        
| 668 | 668 | |
| 669 | -				if ( empty( $value ) ) { | 
                                                        |
| 670 | - $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );  | 
                                                        |
| 669 | +				if (empty($value)) { | 
                                                        |
| 670 | + $value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));  | 
                                                        |
| 671 | 671 | }  | 
                                                        
| 672 | 672 | |
| 673 | 673 | $row[] = $value;  | 
                                                        
| 674 | 674 | |
| 675 | 675 | }  | 
                                                        
| 676 | 676 | |
| 677 | - fputcsv( $output, $row );  | 
                                                        |
| 677 | + fputcsv($output, $row);  | 
                                                        |
| 678 | 678 | }  | 
                                                        
| 679 | 679 | |
| 680 | - fclose( $output );  | 
                                                        |
| 680 | + fclose($output);  | 
                                                        |
| 681 | 681 | exit;  | 
                                                        
| 682 | 682 | |
| 683 | 683 | }  | 
                                                        
@@ -687,29 +687,29 @@ discard block  | 
                                                    ||
| 687 | 687 | *  | 
                                                        
| 688 | 688 | * @param array $data  | 
                                                        
| 689 | 689 | */  | 
                                                        
| 690 | -    public function admin_install_plugin( $data ) { | 
                                                        |
| 690 | +    public function admin_install_plugin($data) { | 
                                                        |
| 691 | 691 | |
| 692 | -		if ( ! empty( $data['plugins'] ) ) { | 
                                                        |
| 692 | +		if (!empty($data['plugins'])) { | 
                                                        |
| 693 | 693 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        
| 694 | 694 | wp_cache_flush();  | 
                                                        
| 695 | 695 | |
| 696 | -			foreach ( $data['plugins'] as $slug => $file ) { | 
                                                        |
| 697 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );  | 
                                                        |
| 698 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 699 | - $installed = $upgrader->install( $plugin_zip );  | 
                                                        |
| 696 | +			foreach ($data['plugins'] as $slug => $file) { | 
                                                        |
| 697 | +				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); | 
                                                        |
| 698 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());  | 
                                                        |
| 699 | + $installed = $upgrader->install($plugin_zip);  | 
                                                        |
| 700 | 700 | |
| 701 | -				if ( ! is_wp_error( $installed ) && $installed ) { | 
                                                        |
| 702 | - activate_plugin( $file, '', false, true );  | 
                                                        |
| 701 | +				if (!is_wp_error($installed) && $installed) { | 
                                                        |
| 702 | + activate_plugin($file, '', false, true);  | 
                                                        |
| 703 | 703 |  				} else { | 
                                                        
| 704 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );  | 
                                                        |
| 704 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);  | 
                                                        |
| 705 | 705 | }  | 
                                                        
| 706 | 706 | |
| 707 | 707 | }  | 
                                                        
| 708 | 708 | |
| 709 | 709 | }  | 
                                                        
| 710 | 710 | |
| 711 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );  | 
                                                        |
| 712 | - wp_safe_redirect( $redirect );  | 
                                                        |
| 711 | +		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); | 
                                                        |
| 712 | + wp_safe_redirect($redirect);  | 
                                                        |
| 713 | 713 | exit;  | 
                                                        
| 714 | 714 | |
| 715 | 715 | }  | 
                                                        
@@ -719,42 +719,42 @@ discard block  | 
                                                    ||
| 719 | 719 | *  | 
                                                        
| 720 | 720 | * @param array $data  | 
                                                        
| 721 | 721 | */  | 
                                                        
| 722 | -    public function admin_connect_gateway( $data ) { | 
                                                        |
| 722 | +    public function admin_connect_gateway($data) { | 
                                                        |
| 723 | 723 | |
| 724 | -		if ( ! empty( $data['plugin'] ) ) { | 
                                                        |
| 724 | +		if (!empty($data['plugin'])) { | 
                                                        |
| 725 | 725 | |
| 726 | - $gateway = sanitize_key( $data['plugin'] );  | 
                                                        |
| 727 | -			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 726 | + $gateway = sanitize_key($data['plugin']);  | 
                                                        |
| 727 | +			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); | 
                                                        |
| 728 | 728 | |
| 729 | -			if ( ! empty( $connect_url ) ) { | 
                                                        |
| 730 | - wp_redirect( $connect_url );  | 
                                                        |
| 729 | +			if (!empty($connect_url)) { | 
                                                        |
| 730 | + wp_redirect($connect_url);  | 
                                                        |
| 731 | 731 | exit;  | 
                                                        
| 732 | 732 | }  | 
                                                        
| 733 | 733 | |
| 734 | -			if ( 'stripe' == $data['plugin'] ) { | 
                                                        |
| 734 | +			if ('stripe' == $data['plugin']) { | 
                                                        |
| 735 | 735 | require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        
| 736 | 736 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';  | 
                                                        
| 737 | 737 | wp_cache_flush();  | 
                                                        
| 738 | 738 | |
| 739 | -				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { | 
                                                        |
| 740 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );  | 
                                                        |
| 741 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );  | 
                                                        |
| 742 | - $upgrader->install( $plugin_zip );  | 
                                                        |
| 739 | +				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { | 
                                                        |
| 740 | +					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); | 
                                                        |
| 741 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin());  | 
                                                        |
| 742 | + $upgrader->install($plugin_zip);  | 
                                                        |
| 743 | 743 | }  | 
                                                        
| 744 | 744 | |
| 745 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );  | 
                                                        |
| 745 | +				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); | 
                                                        |
| 746 | 746 | }  | 
                                                        
| 747 | 747 | |
| 748 | -			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); | 
                                                        |
| 749 | -			if ( ! empty( $connect_url ) ) { | 
                                                        |
| 750 | - wp_redirect( $connect_url );  | 
                                                        |
| 748 | +			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); | 
                                                        |
| 749 | +			if (!empty($connect_url)) { | 
                                                        |
| 750 | + wp_redirect($connect_url);  | 
                                                        |
| 751 | 751 | exit;  | 
                                                        
| 752 | 752 | }  | 
                                                        
| 753 | 753 | |
| 754 | 754 | }  | 
                                                        
| 755 | 755 | |
| 756 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );  | 
                                                        |
| 757 | - wp_safe_redirect( $redirect );  | 
                                                        |
| 756 | +		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); | 
                                                        |
| 757 | + wp_safe_redirect($redirect);  | 
                                                        |
| 758 | 758 | exit;  | 
                                                        
| 759 | 759 | |
| 760 | 760 | }  | 
                                                        
@@ -768,36 +768,36 @@ discard block  | 
                                                    ||
| 768 | 768 | |
| 769 | 769 | // Fetch all invoices that have discount codes.  | 
                                                        
| 770 | 770 | $table = $wpdb->prefix . 'getpaid_invoices';  | 
                                                        
| 771 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );  | 
                                                        |
| 771 | +		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); | 
                                                        |
| 772 | 772 | |
| 773 | -		foreach ( $invoices as $invoice ) { | 
                                                        |
| 773 | +		foreach ($invoices as $invoice) { | 
                                                        |
| 774 | 774 | |
| 775 | - $invoice = new WPInv_Invoice( $invoice );  | 
                                                        |
| 775 | + $invoice = new WPInv_Invoice($invoice);  | 
                                                        |
| 776 | 776 | |
| 777 | -			if ( ! $invoice->exists() ) { | 
                                                        |
| 777 | +			if (!$invoice->exists()) { | 
                                                        |
| 778 | 778 | continue;  | 
                                                        
| 779 | 779 | }  | 
                                                        
| 780 | 780 | |
| 781 | 781 | // Abort if the discount does not exist or does not apply here.  | 
                                                        
| 782 | - $discount = new WPInv_Discount( $invoice->get_discount_code() );  | 
                                                        |
| 783 | -			if ( ! $discount->exists() ) { | 
                                                        |
| 782 | + $discount = new WPInv_Discount($invoice->get_discount_code());  | 
                                                        |
| 783 | +			if (!$discount->exists()) { | 
                                                        |
| 784 | 784 | continue;  | 
                                                        
| 785 | 785 | }  | 
                                                        
| 786 | 786 | |
| 787 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );  | 
                                                        |
| 787 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));  | 
                                                        |
| 788 | 788 | $invoice->recalculate_total();  | 
                                                        
| 789 | 789 | |
| 790 | -			if ( $invoice->get_total_discount() > 0 ) { | 
                                                        |
| 790 | +			if ($invoice->get_total_discount() > 0) { | 
                                                        |
| 791 | 791 | $invoice->save();  | 
                                                        
| 792 | 792 | }  | 
                                                        
| 793 | 793 | |
| 794 | 794 | }  | 
                                                        
| 795 | 795 | |
| 796 | 796 | // Show an admin message.  | 
                                                        
| 797 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );  | 
                                                        |
| 797 | +		$this->show_success(__('Discounts have been recalculated.', 'invoicing')); | 
                                                        |
| 798 | 798 | |
| 799 | 799 | // Redirect the admin.  | 
                                                        
| 800 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );  | 
                                                        |
| 800 | +		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); | 
                                                        |
| 801 | 801 | exit;  | 
                                                        
| 802 | 802 | |
| 803 | 803 | }  | 
                                                        
@@ -809,8 +809,8 @@ discard block  | 
                                                    ||
| 809 | 809 | * @return array  | 
                                                        
| 810 | 810 | */  | 
                                                        
| 811 | 811 |  	public function get_notices() { | 
                                                        
| 812 | - $notices = get_option( 'wpinv_admin_notices' );  | 
                                                        |
| 813 | - return is_array( $notices ) ? $notices : array();  | 
                                                        |
| 812 | +		$notices = get_option('wpinv_admin_notices'); | 
                                                        |
| 813 | + return is_array($notices) ? $notices : array();  | 
                                                        |
| 814 | 814 | }  | 
                                                        
| 815 | 815 | |
| 816 | 816 | /**  | 
                                                        
@@ -820,7 +820,7 @@ discard block  | 
                                                    ||
| 820 | 820 | * @return array  | 
                                                        
| 821 | 821 | */  | 
                                                        
| 822 | 822 |  	public function has_notices() { | 
                                                        
| 823 | - return count( $this->get_notices() ) > 0;  | 
                                                        |
| 823 | + return count($this->get_notices()) > 0;  | 
                                                        |
| 824 | 824 | }  | 
                                                        
| 825 | 825 | |
| 826 | 826 | /**  | 
                                                        
@@ -830,7 +830,7 @@ discard block  | 
                                                    ||
| 830 | 830 | * @since 1.0.19  | 
                                                        
| 831 | 831 | */  | 
                                                        
| 832 | 832 |  	public function clear_notices() { | 
                                                        
| 833 | - delete_option( 'wpinv_admin_notices' );  | 
                                                        |
| 833 | +		delete_option('wpinv_admin_notices'); | 
                                                        |
| 834 | 834 | }  | 
                                                        
| 835 | 835 | |
| 836 | 836 | /**  | 
                                                        
@@ -839,16 +839,16 @@ discard block  | 
                                                    ||
| 839 | 839 | * @access public  | 
                                                        
| 840 | 840 | * @since 1.0.19  | 
                                                        
| 841 | 841 | */  | 
                                                        
| 842 | -	public function save_notice( $type, $message ) { | 
                                                        |
| 842 | +	public function save_notice($type, $message) { | 
                                                        |
| 843 | 843 | $notices = $this->get_notices();  | 
                                                        
| 844 | 844 | |
| 845 | -		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { | 
                                                        |
| 846 | - $notices[ $type ] = array();  | 
                                                        |
| 845 | +		if (empty($notices[$type]) || !is_array($notices[$type])) { | 
                                                        |
| 846 | + $notices[$type] = array();  | 
                                                        |
| 847 | 847 | }  | 
                                                        
| 848 | 848 | |
| 849 | - $notices[ $type ][] = $message;  | 
                                                        |
| 849 | + $notices[$type][] = $message;  | 
                                                        |
| 850 | 850 | |
| 851 | - update_option( 'wpinv_admin_notices', $notices );  | 
                                                        |
| 851 | +		update_option('wpinv_admin_notices', $notices); | 
                                                        |
| 852 | 852 | }  | 
                                                        
| 853 | 853 | |
| 854 | 854 | /**  | 
                                                        
@@ -858,8 +858,8 @@ discard block  | 
                                                    ||
| 858 | 858 | * @access public  | 
                                                        
| 859 | 859 | * @since 1.0.19  | 
                                                        
| 860 | 860 | */  | 
                                                        
| 861 | -	public function show_success( $msg ) { | 
                                                        |
| 862 | - $this->save_notice( 'success', $msg );  | 
                                                        |
| 861 | +	public function show_success($msg) { | 
                                                        |
| 862 | +		$this->save_notice('success', $msg); | 
                                                        |
| 863 | 863 | }  | 
                                                        
| 864 | 864 | |
| 865 | 865 | /**  | 
                                                        
@@ -869,8 +869,8 @@ discard block  | 
                                                    ||
| 869 | 869 | * @param string $msg The message to qeue.  | 
                                                        
| 870 | 870 | * @since 1.0.19  | 
                                                        
| 871 | 871 | */  | 
                                                        
| 872 | -	public function show_error( $msg ) { | 
                                                        |
| 873 | - $this->save_notice( 'error', $msg );  | 
                                                        |
| 872 | +	public function show_error($msg) { | 
                                                        |
| 873 | +		$this->save_notice('error', $msg); | 
                                                        |
| 874 | 874 | }  | 
                                                        
| 875 | 875 | |
| 876 | 876 | /**  | 
                                                        
@@ -880,8 +880,8 @@ discard block  | 
                                                    ||
| 880 | 880 | * @param string $msg The message to qeue.  | 
                                                        
| 881 | 881 | * @since 1.0.19  | 
                                                        
| 882 | 882 | */  | 
                                                        
| 883 | -	public function show_warning( $msg ) { | 
                                                        |
| 884 | - $this->save_notice( 'warning', $msg );  | 
                                                        |
| 883 | +	public function show_warning($msg) { | 
                                                        |
| 884 | +		$this->save_notice('warning', $msg); | 
                                                        |
| 885 | 885 | }  | 
                                                        
| 886 | 886 | |
| 887 | 887 | /**  | 
                                                        
@@ -891,8 +891,8 @@ discard block  | 
                                                    ||
| 891 | 891 | * @param string $msg The message to qeue.  | 
                                                        
| 892 | 892 | * @since 1.0.19  | 
                                                        
| 893 | 893 | */  | 
                                                        
| 894 | -	public function show_info( $msg ) { | 
                                                        |
| 895 | - $this->save_notice( 'info', $msg );  | 
                                                        |
| 894 | +	public function show_info($msg) { | 
                                                        |
| 895 | +		$this->save_notice('info', $msg); | 
                                                        |
| 896 | 896 | }  | 
                                                        
| 897 | 897 | |
| 898 | 898 | /**  | 
                                                        
@@ -906,30 +906,30 @@ discard block  | 
                                                    ||
| 906 | 906 | $notices = $this->get_notices();  | 
                                                        
| 907 | 907 | $this->clear_notices();  | 
                                                        
| 908 | 908 | |
| 909 | -		foreach ( $notices as $type => $messages ) { | 
                                                        |
| 909 | +		foreach ($notices as $type => $messages) { | 
                                                        |
| 910 | 910 | |
| 911 | -			if ( ! is_array( $messages ) ) { | 
                                                        |
| 911 | +			if (!is_array($messages)) { | 
                                                        |
| 912 | 912 | continue;  | 
                                                        
| 913 | 913 | }  | 
                                                        
| 914 | 914 | |
| 915 | - $type = sanitize_key( $type );  | 
                                                        |
| 916 | -			foreach ( $messages as $message ) { | 
                                                        |
| 917 | - $message = wp_kses_post( $message );  | 
                                                        |
| 915 | + $type = sanitize_key($type);  | 
                                                        |
| 916 | +			foreach ($messages as $message) { | 
                                                        |
| 917 | + $message = wp_kses_post($message);  | 
                                                        |
| 918 | 918 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";  | 
                                                        
| 919 | 919 | }  | 
                                                        
| 920 | 920 | |
| 921 | 921 | }  | 
                                                        
| 922 | 922 | |
| 923 | -		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { | 
                                                        |
| 923 | +		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { | 
                                                        |
| 924 | 924 | |
| 925 | -			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { | 
                                                        |
| 926 | - $url = wp_nonce_url(  | 
                                                        |
| 927 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),  | 
                                                        |
| 925 | +			if (!is_numeric(wpinv_get_option($page, false))) { | 
                                                        |
| 926 | + $url = wp_nonce_url(  | 
                                                        |
| 927 | +					add_query_arg('getpaid-admin-action', 'create_missing_pages'), | 
                                                        |
| 928 | 928 | 'getpaid-nonce',  | 
                                                        
| 929 | 929 | 'getpaid-nonce'  | 
                                                        
| 930 | 930 | );  | 
                                                        
| 931 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );  | 
                                                        |
| 932 | - $message2 = __( 'Generate Pages', 'invoicing' );  | 
                                                        |
| 931 | +				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); | 
                                                        |
| 932 | +				$message2 = __('Generate Pages', 'invoicing'); | 
                                                        |
| 933 | 933 | echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";  | 
                                                        
| 934 | 934 | break;  | 
                                                        
| 935 | 935 | }  |