Passed
Push — master ( 797927...011c37 )
by Stiofan
06:37
created
templates/emails/wpinv-email-cancelled_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-new_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-refunded_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-onhold_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-user_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-processing_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-failed_invoice.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,209 +82,209 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
137
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
138
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
137
+        if (!class_exists('WPInv_EUVat')) {
138
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
139 139
         }
140 140
         
141
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
142
-        if ( !empty( $gateways ) ) {
143
-            foreach ( $gateways as $gateway ) {
144
-                if ( $gateway == 'manual' ) {
141
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
142
+        if (!empty($gateways)) {
143
+            foreach ($gateways as $gateway) {
144
+                if ($gateway == 'manual') {
145 145
                     continue;
146 146
                 }
147 147
                 
148 148
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
149 149
                 
150
-                if ( file_exists( $gateway_file ) ) {
151
-                    require_once( $gateway_file );
150
+                if (file_exists($gateway_file)) {
151
+                    require_once($gateway_file);
152 152
                 }
153 153
             }
154 154
         }
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
156 156
         
157
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
159
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
160
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
157
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
159
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
160
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
161 161
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
162
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
163
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
164
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
165
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
162
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
163
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
164
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
165
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
167 167
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
168 168
         }
169 169
         
170 170
         // include css inliner
171
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
172
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
171
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
172
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
173 173
         }
174 174
         
175
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
175
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
176 176
     }
177 177
     
178 178
     public function init() {
179 179
     }
180 180
     
181 181
     public function admin_init() {
182
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
182
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
183 183
         }
184 184
         
185
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
185
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
186 186
     }
187 187
 
188 188
     public function activation_redirect() {
189 189
         // Bail if no activation redirect
190
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
190
+        if (!get_transient('_wpinv_activation_redirect')) {
191 191
             return;
192 192
         }
193 193
 
194 194
         // Delete the redirect transient
195
-        delete_transient( '_wpinv_activation_redirect' );
195
+        delete_transient('_wpinv_activation_redirect');
196 196
 
197 197
         // Bail if activating from network, or bulk
198
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
198
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
199 199
             return;
200 200
         }
201 201
 
202
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
202
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
203 203
         exit;
204 204
     }
205 205
     
206 206
     public function enqueue_scripts() {
207
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
207
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
208 208
         
209
-        wp_deregister_style( 'font-awesome' );
210
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
211
-        wp_enqueue_style( 'font-awesome' );
209
+        wp_deregister_style('font-awesome');
210
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
211
+        wp_enqueue_style('font-awesome');
212 212
         
213
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
214
-        wp_enqueue_style( 'wpinv_front_style' );
213
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
214
+        wp_enqueue_style('wpinv_front_style');
215 215
                
216 216
         // Register scripts
217
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
218
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
217
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
218
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
219 219
         
220 220
         $localize                         = array();
221
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
222
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
221
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
222
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
223 223
         $localize['currency_symbol']      = wpinv_currency_symbol();
224 224
         $localize['currency_pos']         = wpinv_currency_position();
225 225
         $localize['thousand_sep']         = wpinv_thousands_separator();
226 226
         $localize['decimal_sep']          = wpinv_decimal_separator();
227 227
         $localize['decimals']             = wpinv_decimals();
228
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
228
+        $localize['txtComplete']          = __('Complete', 'invoicing');
229 229
         
230
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
230
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
231 231
         
232
-        wp_enqueue_script( 'jquery-blockui' );
232
+        wp_enqueue_script('jquery-blockui');
233 233
         $autofill_api = wpinv_get_option('address_autofill_api');
234 234
         $autofill_active = wpinv_get_option('address_autofill_active');
235
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
236
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
237
-                wp_dequeue_script( 'google-maps-api' );
235
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
236
+            if (wp_script_is('google-maps-api', 'enqueued')) {
237
+                wp_dequeue_script('google-maps-api');
238 238
             }
239
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
240
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
239
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
240
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
241 241
         }
242
-        wp_enqueue_script( 'wpinv-front-script' );
243
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
242
+        wp_enqueue_script('wpinv-front-script');
243
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
244 244
     }
245 245
 
246 246
     public function admin_enqueue_scripts() {
247 247
         global $post, $pagenow;
248 248
         
249 249
         $post_type  = wpinv_admin_post_type();
250
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
251
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
250
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
251
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
252 252
 
253
-        wp_deregister_style( 'font-awesome' );
254
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
255
-        wp_enqueue_style( 'font-awesome' );
253
+        wp_deregister_style('font-awesome');
254
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
255
+        wp_enqueue_style('font-awesome');
256 256
         
257 257
         $jquery_ui_css = false;
258
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
258
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
259 259
             $jquery_ui_css = true;
260
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
260
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
261 261
             $jquery_ui_css = true;
262 262
         }
263
-        if ( $jquery_ui_css ) {
264
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
265
-            wp_enqueue_style( 'jquery-ui-css' );
263
+        if ($jquery_ui_css) {
264
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
265
+            wp_enqueue_style('jquery-ui-css');
266 266
         }
267 267
 
268
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
269
-        wp_enqueue_style( 'wpinv_meta_box_style' );
268
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
269
+        wp_enqueue_style('wpinv_meta_box_style');
270 270
         
271
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
272
-        wp_enqueue_style( 'wpinv_admin_style' );
271
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
272
+        wp_enqueue_style('wpinv_admin_style');
273 273
 
274
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
275
-        if ( $page == 'wpinv-subscriptions' ) {
276
-            wp_enqueue_script( 'jquery-ui-datepicker' );
274
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
275
+        if ($page == 'wpinv-subscriptions') {
276
+            wp_enqueue_script('jquery-ui-datepicker');
277 277
         }
278
-        $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue );
278
+        $enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue);
279 279
         
280
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
281
-            wp_enqueue_script( 'jquery-ui-datepicker' );
280
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
281
+            wp_enqueue_script('jquery-ui-datepicker');
282 282
         }
283 283
 
284
-        wp_enqueue_style( 'wp-color-picker' );
285
-        wp_enqueue_script( 'wp-color-picker' );
284
+        wp_enqueue_style('wp-color-picker');
285
+        wp_enqueue_script('wp-color-picker');
286 286
         
287
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
287
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
288 288
 
289 289
         if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
290 290
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
             }
296 296
         }
297 297
 
298
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
299
-        wp_enqueue_script( 'wpinv-admin-script' );
298
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
299
+        wp_enqueue_script('wpinv-admin-script');
300 300
         
301 301
         $localize                               = array();
302
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
303
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
304
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
305
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
306
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
307
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
308
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
302
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
303
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
304
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
305
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
306
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
307
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
308
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
309 309
         $localize['tax']                        = wpinv_tax_amount();
310 310
         $localize['discount']                   = wpinv_discount_amount();
311 311
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -313,69 +313,69 @@  discard block
 block discarded – undo
313 313
         $localize['thousand_sep']               = wpinv_thousands_separator();
314 314
         $localize['decimal_sep']                = wpinv_decimal_separator();
315 315
         $localize['decimals']                   = wpinv_decimals();
316
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
317
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
318
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
319
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
320
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
321
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
322
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
323
-        $localize['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' );
324
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
325
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
326
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
327
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
328
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
329
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
316
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
317
+        $localize['status_publish']             = wpinv_status_nicename('publish');
318
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
319
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
320
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
321
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
322
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
323
+        $localize['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');
324
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
325
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
326
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
327
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
328
+        $localize['action_edit']                = __('Edit', 'invoicing');
329
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
330 330
 
331
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
331
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
332 332
 
333
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
333
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
334 334
 
335
-        if ( $page == 'wpinv-subscriptions' ) {
336
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
337
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
335
+        if ($page == 'wpinv-subscriptions') {
336
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION);
337
+            wp_enqueue_script('wpinv-sub-admin-script');
338 338
         }
339 339
     }
340 340
     
341
-    public function admin_body_class( $classes ) {
341
+    public function admin_body_class($classes) {
342 342
         global $pagenow, $post, $current_screen;
343 343
         
344
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
344
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
345 345
             $classes .= ' wpinv-cpt';
346 346
         }
347 347
         
348
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
348
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
349 349
 
350
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
351
-        if ( $add_class ) {
352
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
350
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
351
+        if ($add_class) {
352
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
353 353
         }
354 354
         
355 355
         $settings_class = array();
356
-        if ( $page == 'wpinv-settings' ) {
357
-            if ( !empty( $_REQUEST['tab'] ) ) {
358
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
356
+        if ($page == 'wpinv-settings') {
357
+            if (!empty($_REQUEST['tab'])) {
358
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
359 359
             }
360 360
             
361
-            if ( !empty( $_REQUEST['section'] ) ) {
362
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
361
+            if (!empty($_REQUEST['section'])) {
362
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
363 363
             }
364 364
             
365
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
365
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
366 366
         }
367 367
         
368
-        if ( !empty( $settings_class ) ) {
369
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
368
+        if (!empty($settings_class)) {
369
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
370 370
         }
371 371
         
372 372
         $post_type = wpinv_admin_post_type();
373 373
 
374
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
374
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
375 375
             return $classes .= ' wpinv';
376 376
         }
377 377
         
378
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
378
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
379 379
             $classes .= ' wpi-editable-n';
380 380
         }
381 381
 
@@ -387,20 +387,20 @@  discard block
 block discarded – undo
387 387
     }
388 388
     
389 389
     public function wpinv_actions() {
390
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
391
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
390
+        if (isset($_REQUEST['wpi_action'])) {
391
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
392 392
         }
393 393
     }
394 394
     
395
-    public function pre_get_posts( $wp_query ) {
396
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
397
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
395
+    public function pre_get_posts($wp_query) {
396
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
397
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
398 398
         }
399 399
         
400 400
         return $wp_query;
401 401
     }
402 402
     
403 403
     public function bp_invoicing_init() {
404
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
404
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
405 405
     }
406 406
 }
407 407
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/authorizenet.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -648,6 +648,9 @@
 block discarded – undo
648 648
 }
649 649
 add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1 );
650 650
 
651
+/**
652
+ * @param WPInv_Invoice $invoice
653
+ */
651 654
 function wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
652 655
     if ( $transaction_id == $invoice_id ) {
653 656
         $link = $transaction_id;
Please login to merge, or discard this patch.
Spacing   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -1,60 +1,60 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_filter( 'wpinv_authorizenet_support_subscription', '__return_true' );
5
+add_filter('wpinv_authorizenet_support_subscription', '__return_true');
6 6
 
7
-function wpinv_authorizenet_cc_form( $invoice_id ) {
8
-    $invoice = wpinv_get_invoice( $invoice_id );
9
-    $cc_owner = !empty( $invoice ) ? esc_attr( $invoice->get_user_full_name() ) : '';
7
+function wpinv_authorizenet_cc_form($invoice_id) {
8
+    $invoice = wpinv_get_invoice($invoice_id);
9
+    $cc_owner = !empty($invoice) ? esc_attr($invoice->get_user_full_name()) : '';
10 10
     ?>
11 11
     <div id="authorizenet_cc_form" class="form-horizontal wpi-cc-form panel panel-default">
12
-        <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Card Details', 'invoicing' ) ;?></h3></div>
12
+        <div class="panel-heading"><h3 class="panel-title"><?php _e('Card Details', 'invoicing'); ?></h3></div>
13 13
         <div class="panel-body">
14 14
             <div class="form-group required">
15
-              <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e( 'Card Owner', 'invoicing' ) ;?></label>
15
+              <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e('Card Owner', 'invoicing'); ?></label>
16 16
               <div class="col-sm-5">
17
-                <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e( 'Card Owner', 'invoicing' ) ;?>" value="<?php echo $cc_owner;?>" name="authorizenet[cc_owner]">
17
+                <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e('Card Owner', 'invoicing'); ?>" value="<?php echo $cc_owner; ?>" name="authorizenet[cc_owner]">
18 18
               </div>
19 19
             </div>
20 20
             <div class="form-group required">
21
-              <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e( 'Card Number', 'invoicing' ) ;?></label>
21
+              <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e('Card Number', 'invoicing'); ?></label>
22 22
               <div class="col-sm-5">
23
-                <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e( 'Card Number', 'invoicing' ) ;?>" value="" name="authorizenet[cc_number]">
23
+                <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e('Card Number', 'invoicing'); ?>" value="" name="authorizenet[cc_number]">
24 24
               </div>
25 25
             </div>
26 26
             <div class="form-group required">
27
-              <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e( 'Card Expiry Date', 'invoicing' ) ;?></label>
27
+              <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e('Card Expiry Date', 'invoicing'); ?></label>
28 28
               <div class="col-sm-2">
29 29
                 <select class="form-control" id="auth-input-cc-expire-date" name="authorizenet[cc_expire_month]">
30
-                    <?php for ( $i = 1; $i <= 12; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
31
-                    <option value="<?php echo $value;?>"><?php echo $value;?></option>
30
+                    <?php for ($i = 1; $i <= 12; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
31
+                    <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
32 32
                     <?php } ?>
33 33
                 </select>
34 34
                </div>
35 35
                <div class="col-sm-3">
36 36
                 <select class="form-control" name="authorizenet[cc_expire_year]">
37
-                    <?php $year = date( 'Y' ); for ( $i = $year; $i <= ( $year + 10 ); $i++ ) { ?>
38
-                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
37
+                    <?php $year = date('Y'); for ($i = $year; $i <= ($year + 10); $i++) { ?>
38
+                    <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
39 39
                     <?php } ?>
40 40
                 </select>
41 41
               </div>
42 42
             </div>
43 43
             <div class="form-group required">
44
-              <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e( 'Card Security Code (CVV2)', 'invoicing' ) ;?></label>
44
+              <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e('Card Security Code (CVV2)', 'invoicing'); ?></label>
45 45
               <div class="col-sm-5">
46
-                <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e( 'Card Security Code (CVV2)', 'invoicing' ) ;?>" value="" name="authorizenet[cc_cvv2]"">
46
+                <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e('Card Security Code (CVV2)', 'invoicing'); ?>" value="" name="authorizenet[cc_cvv2]"">
47 47
               </div>
48 48
             </div>
49 49
       </div>
50 50
     </div>
51 51
     <?php
52 52
 }
53
-add_action( 'wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1 );
53
+add_action('wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1);
54 54
 
55
-function wpinv_process_authorizenet_payment( $purchase_data ) {
56
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
57
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
55
+function wpinv_process_authorizenet_payment($purchase_data) {
56
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
57
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
58 58
     }
59 59
 
60 60
     // Collect payment data
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
     );
73 73
 
74 74
     // Record the pending payment
75
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
75
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
76 76
 
77
-    if ( !empty( $invoice ) ) {
78
-        $authorizenet_card  = !empty( $_POST['authorizenet'] ) ? $_POST['authorizenet'] : array();
77
+    if (!empty($invoice)) {
78
+        $authorizenet_card  = !empty($_POST['authorizenet']) ? $_POST['authorizenet'] : array();
79 79
         $card_defaults      = array(
80 80
             'cc_owner'          => $invoice->get_user_full_name(),
81 81
             'cc_number'         => false,
@@ -83,178 +83,178 @@  discard block
 block discarded – undo
83 83
             'cc_expire_year'    => false,
84 84
             'cc_cvv2'           => false,
85 85
         );
86
-        $authorizenet_card = wp_parse_args( $authorizenet_card, $card_defaults );
86
+        $authorizenet_card = wp_parse_args($authorizenet_card, $card_defaults);
87 87
 
88
-        if ( empty( $authorizenet_card['cc_owner'] ) ) {
89
-            wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing'));
88
+        if (empty($authorizenet_card['cc_owner'])) {
89
+            wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing'));
90 90
         }
91
-        if ( empty( $authorizenet_card['cc_number'] ) ) {
92
-            wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing'));
91
+        if (empty($authorizenet_card['cc_number'])) {
92
+            wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing'));
93 93
         }
94
-        if ( empty( $authorizenet_card['cc_expire_month'] ) ) {
95
-            wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing'));
94
+        if (empty($authorizenet_card['cc_expire_month'])) {
95
+            wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing'));
96 96
         }
97
-        if ( empty( $authorizenet_card['cc_expire_year'] ) ) {
98
-            wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing'));
97
+        if (empty($authorizenet_card['cc_expire_year'])) {
98
+            wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing'));
99 99
         }
100
-        if ( empty( $authorizenet_card['cc_cvv2'] ) ) {
101
-            wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) );
100
+        if (empty($authorizenet_card['cc_cvv2'])) {
101
+            wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing'));
102 102
         }
103 103
 
104 104
         $errors = wpinv_get_errors();
105 105
 
106
-        if ( empty( $errors ) ) {
106
+        if (empty($errors)) {
107 107
             $invoice_id = $invoice->ID;
108 108
             $quantities_enabled = wpinv_item_quantities_enabled();
109 109
             $use_taxes          = wpinv_use_taxes();
110 110
 
111 111
             $authorizeAIM = wpinv_authorizenet_AIM();
112
-            $authorizeAIM->first_name       = wpinv_utf8_substr( $invoice->get_first_name(), 0, 50 );
113
-            $authorizeAIM->last_name        = wpinv_utf8_substr( $invoice->get_last_name(), 0, 50 );
114
-            $authorizeAIM->company          = wpinv_utf8_substr( $invoice->company, 0, 50 );
115
-            $authorizeAIM->address          = wpinv_utf8_substr( wp_strip_all_tags( $invoice->get_address(), true ), 0, 60 );
116
-            $authorizeAIM->city             = wpinv_utf8_substr( $invoice->city, 0, 40 );
117
-            $authorizeAIM->state            = wpinv_utf8_substr( $invoice->state, 0, 40 );
118
-            $authorizeAIM->zip              = wpinv_utf8_substr( $invoice->zip, 0, 40 );
119
-            $authorizeAIM->country          = wpinv_utf8_substr( $invoice->country, 0, 60 );
120
-            $authorizeAIM->phone            = wpinv_utf8_substr( $invoice->phone, 0, 25 );
121
-            $authorizeAIM->email            = wpinv_utf8_substr( $invoice->get_email(), 0, 255 );
122
-            $authorizeAIM->amount           = wpinv_sanitize_amount( $invoice->get_total() );
123
-            $authorizeAIM->card_num         = str_replace( ' ', '', sanitize_text_field( $authorizenet_card['cc_number'] ) );
124
-            $authorizeAIM->exp_date         = sanitize_text_field( $authorizenet_card['cc_expire_month'] ) . sanitize_text_field( $authorizenet_card['cc_expire_year'] );
125
-            $authorizeAIM->card_code        = sanitize_text_field( $authorizenet_card['cc_cvv2'] );
112
+            $authorizeAIM->first_name       = wpinv_utf8_substr($invoice->get_first_name(), 0, 50);
113
+            $authorizeAIM->last_name        = wpinv_utf8_substr($invoice->get_last_name(), 0, 50);
114
+            $authorizeAIM->company          = wpinv_utf8_substr($invoice->company, 0, 50);
115
+            $authorizeAIM->address          = wpinv_utf8_substr(wp_strip_all_tags($invoice->get_address(), true), 0, 60);
116
+            $authorizeAIM->city             = wpinv_utf8_substr($invoice->city, 0, 40);
117
+            $authorizeAIM->state            = wpinv_utf8_substr($invoice->state, 0, 40);
118
+            $authorizeAIM->zip              = wpinv_utf8_substr($invoice->zip, 0, 40);
119
+            $authorizeAIM->country          = wpinv_utf8_substr($invoice->country, 0, 60);
120
+            $authorizeAIM->phone            = wpinv_utf8_substr($invoice->phone, 0, 25);
121
+            $authorizeAIM->email            = wpinv_utf8_substr($invoice->get_email(), 0, 255);
122
+            $authorizeAIM->amount           = wpinv_sanitize_amount($invoice->get_total());
123
+            $authorizeAIM->card_num         = str_replace(' ', '', sanitize_text_field($authorizenet_card['cc_number']));
124
+            $authorizeAIM->exp_date         = sanitize_text_field($authorizenet_card['cc_expire_month']) . sanitize_text_field($authorizenet_card['cc_expire_year']);
125
+            $authorizeAIM->card_code        = sanitize_text_field($authorizenet_card['cc_cvv2']);
126 126
             $authorizeAIM->invoice_num      = $invoice->ID;
127 127
 
128 128
             $item_desc = array();
129
-            foreach ( $invoice->get_cart_details() as $item ) {            
130
-                $quantity       = $quantities_enabled && !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1;
131
-                $item_name      = wpinv_utf8_substr( $item['name'], 0, 31 );
132
-                $item_desc[]    = $item_name . ' (' . $quantity . 'x ' . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')';
129
+            foreach ($invoice->get_cart_details() as $item) {            
130
+                $quantity       = $quantities_enabled && !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
131
+                $item_name      = wpinv_utf8_substr($item['name'], 0, 31);
132
+                $item_desc[]    = $item_name . ' (' . $quantity . 'x ' . wpinv_price(wpinv_format_amount($item['item_price'])) . ')';
133 133
 
134
-                $authorizeAIM->addLineItem( $item['id'], $item_name, '', $quantity, $item['item_price'], ( $use_taxes && !empty( $item['tax'] ) && $item['tax'] > 0 ? 'Y' : 'N' ) );
134
+                $authorizeAIM->addLineItem($item['id'], $item_name, '', $quantity, $item['item_price'], ($use_taxes && !empty($item['tax']) && $item['tax'] > 0 ? 'Y' : 'N'));
135 135
             }
136 136
 
137
-            $item_desc = '#' . $invoice->get_number() . ': ' . implode( ', ', $item_desc );
137
+            $item_desc = '#' . $invoice->get_number() . ': ' . implode(', ', $item_desc);
138 138
 
139
-            if ( $use_taxes && $invoice->get_tax() > 0 ) {
140
-                $authorizeAIM->tax  = $invoice->get_tax();
139
+            if ($use_taxes && $invoice->get_tax() > 0) {
140
+                $authorizeAIM->tax = $invoice->get_tax();
141 141
 
142
-                $item_desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) );
142
+                $item_desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true));
143 143
             }
144 144
 
145
-            if ( $invoice->get_discount() > 0 ) {
146
-                $item_desc .= ', ' . wp_sprintf( __( 'Discount: %s', 'invoicing' ), $invoice->get_discount( true ) );
145
+            if ($invoice->get_discount() > 0) {
146
+                $item_desc .= ', ' . wp_sprintf(__('Discount: %s', 'invoicing'), $invoice->get_discount(true));
147 147
             }
148 148
 
149
-            $item_description = wpinv_utf8_substr( $item_desc, 0, 255 );
150
-            $item_description = html_entity_decode( $item_desc , ENT_QUOTES, 'UTF-8' );
149
+            $item_description = wpinv_utf8_substr($item_desc, 0, 255);
150
+            $item_description = html_entity_decode($item_desc, ENT_QUOTES, 'UTF-8');
151 151
 
152
-            $authorizeAIM->description  = wpinv_utf8_substr( $item_description, 0, 255 );
152
+            $authorizeAIM->description = wpinv_utf8_substr($item_description, 0, 255);
153 153
 
154 154
             $is_recurring = $invoice->is_recurring(); // Recurring payment.
155 155
 
156
-            if ( $is_recurring ) {
156
+            if ($is_recurring) {
157 157
                 $authorizeAIM->recurring_billing = true;
158 158
             }
159 159
 
160 160
             try {
161
-                if ( $is_recurring ) {
161
+                if ($is_recurring) {
162 162
                     $response = $authorizeAIM->authorizeOnly();
163 163
                 } else {
164 164
                     $response = $authorizeAIM->authorizeAndCapture();
165 165
                 }
166 166
 
167
-                if ( $response->approved || $response->held ) {
168
-                    if ( $response->approved ) {
169
-                        wpinv_update_payment_status( $invoice_id, 'publish' );
167
+                if ($response->approved || $response->held) {
168
+                    if ($response->approved) {
169
+                        wpinv_update_payment_status($invoice_id, 'publish');
170 170
                     }
171
-                    wpinv_set_payment_transaction_id( $invoice_id, $response->transaction_id );
171
+                    wpinv_set_payment_transaction_id($invoice_id, $response->transaction_id);
172 172
 
173
-                    wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment response: %s', 'invoicing' ), $response->response_reason_text ), '', '', true );
174
-                    wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing' ), $response->transaction_id, strtoupper( $response->transaction_type ), $response->authorization_code ), '', '', true );
173
+                    wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment response: %s', 'invoicing'), $response->response_reason_text), '', '', true);
174
+                    wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing'), $response->transaction_id, strtoupper($response->transaction_type), $response->authorization_code), '', '', true);
175 175
 
176
-                    do_action( 'wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card );
176
+                    do_action('wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card);
177 177
 
178 178
                     wpinv_clear_errors();
179 179
                     wpinv_empty_cart();
180 180
 
181
-                    wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
181
+                    wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
182 182
                 } else {
183
-                    if ( !empty( $response->response_reason_text ) ) {
184
-                        $error = __( $response->response_reason_text, 'invoicing' );
185
-                    } else if ( !empty( $response->error_message ) ) {
186
-                        $error = __( $response->error_message, 'invoicing' );
183
+                    if (!empty($response->response_reason_text)) {
184
+                        $error = __($response->response_reason_text, 'invoicing');
185
+                    } else if (!empty($response->error_message)) {
186
+                        $error = __($response->error_message, 'invoicing');
187 187
                     } else {
188
-                        $error = wp_sprintf( __( 'Error data: %s', 'invoicing' ), print_r( $response, true ) );
188
+                        $error = wp_sprintf(__('Error data: %s', 'invoicing'), print_r($response, true));
189 189
                     } 
190 190
 
191
-                    $error = wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $error );
191
+                    $error = wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $error);
192 192
 
193
-                    wpinv_set_error( 'payment_error', $error );
194
-                    wpinv_record_gateway_error( $error, $response );
195
-                    wpinv_insert_payment_note( $invoice_id, $error, '', '', true );
193
+                    wpinv_set_error('payment_error', $error);
194
+                    wpinv_record_gateway_error($error, $response);
195
+                    wpinv_insert_payment_note($invoice_id, $error, '', '', true);
196 196
 
197
-                    wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
197
+                    wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
198 198
                 }
199
-            } catch ( AuthorizeNetException $e ) {
200
-                wpinv_set_error( 'request_error', $e->getMessage() );
201
-                wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $e->getMessage() ) );
202
-                wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
199
+            } catch (AuthorizeNetException $e) {
200
+                wpinv_set_error('request_error', $e->getMessage());
201
+                wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $e->getMessage()));
202
+                wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
203 203
             }
204 204
         } else {
205
-            wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
205
+            wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
206 206
         }
207 207
     } else {
208
-        wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.net payment. Payment data: %s', 'invoicing' ), print_r( $payment_data, true ) ), $invoice );
209
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
208
+        wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.net payment. Payment data: %s', 'invoicing'), print_r($payment_data, true)), $invoice);
209
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
210 210
     }
211 211
 }
212
-add_action( 'wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment' );
212
+add_action('wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment');
213 213
 
214
-function wpinv_authorizenet_cancel_subscription( $subscription = '' ) {
215
-    if ( empty( $subscription->id ) ) {
214
+function wpinv_authorizenet_cancel_subscription($subscription = '') {
215
+    if (empty($subscription->id)) {
216 216
         return false;
217 217
     }
218 218
 
219 219
     try {
220 220
         $authnetXML = wpinv_authorizenet_XML();
221
-        $authnetXML->ARBCancelSubscriptionRequest( array( 'subscriptionId' => $subscription->id ) );
221
+        $authnetXML->ARBCancelSubscriptionRequest(array('subscriptionId' => $subscription->id));
222 222
 
223
-        if ( wpinv_is_test_mode( 'authorizenet' ) ) {
223
+        if (wpinv_is_test_mode('authorizenet')) {
224 224
             return true;
225 225
         }
226 226
 
227 227
         return $authnetXML->isSuccessful();
228
-    } catch( Exception $e ) {
229
-        wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) );
228
+    } catch (Exception $e) {
229
+        wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing'));
230 230
     }
231 231
 
232 232
     return false;
233 233
 }
234
-add_action( 'wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_authorizenet_cancel_subscription' );
234
+add_action('wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_authorizenet_cancel_subscription');
235 235
 
236
-function wpinv_authorizenet_valid_ipn( $md5_hash, $transaction_id, $amount ) {
237
-    $authorizenet_md5_hash = wpinv_get_option( 'authorizenet_md5_hash' );
238
-    if ( empty( $authorizenet_md5_hash ) ) {
236
+function wpinv_authorizenet_valid_ipn($md5_hash, $transaction_id, $amount) {
237
+    $authorizenet_md5_hash = wpinv_get_option('authorizenet_md5_hash');
238
+    if (empty($authorizenet_md5_hash)) {
239 239
         return true;
240 240
     }
241 241
 
242
-    $compare_md5 = strtoupper( md5( $authorizenet_md5_hash . $transaction_id . $amount ) );
242
+    $compare_md5 = strtoupper(md5($authorizenet_md5_hash . $transaction_id . $amount));
243 243
 
244
-    return hash_equals( $compare_md5, $md5_hash );
244
+    return hash_equals($compare_md5, $md5_hash);
245 245
 }
246 246
 
247 247
 function wpinv_authorizenet_AIM() {
248
-    if ( !class_exists( 'AuthorizeNetException' ) ) {
249
-        require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php';
248
+    if (!class_exists('AuthorizeNetException')) {
249
+        require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php';
250 250
     }
251 251
 
252
-    $authorizeAIM = new AuthorizeNetAIM( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ) );
252
+    $authorizeAIM = new AuthorizeNetAIM(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'));
253 253
 
254
-    if ( wpinv_is_test_mode( 'authorizenet' ) ) {
255
-        $authorizeAIM->setSandbox( true );
254
+    if (wpinv_is_test_mode('authorizenet')) {
255
+        $authorizeAIM->setSandbox(true);
256 256
     } else {
257
-        $authorizeAIM->setSandbox( false );
257
+        $authorizeAIM->setSandbox(false);
258 258
     }
259 259
 
260 260
     $authorizeAIM->customer_ip = wpinv_get_ip();
@@ -263,250 +263,250 @@  discard block
 block discarded – undo
263 263
 }
264 264
 
265 265
 function wpinv_authorizenet_XML() {
266
-    if ( !class_exists( 'AuthnetXML' ) ) {
267
-        require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php';
266
+    if (!class_exists('AuthnetXML')) {
267
+        require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php';
268 268
     }
269 269
     
270
-    $authnetXML = new AuthnetXML( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ), (bool)wpinv_is_test_mode( 'authorizenet' ) );
270
+    $authnetXML = new AuthnetXML(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'), (bool)wpinv_is_test_mode('authorizenet'));
271 271
     
272 272
     return $authnetXML;
273 273
 }
274 274
 
275
-function wpinv_authorizenet_handle_response( $response, $invoice, $card_info = array() ) {
276
-    if ( empty( $response ) || empty( $invoice ) ) {
275
+function wpinv_authorizenet_handle_response($response, $invoice, $card_info = array()) {
276
+    if (empty($response) || empty($invoice)) {
277 277
         return false;
278 278
     }
279 279
 
280
-    if ( $invoice->is_recurring() && !empty( $response->approved ) ) {
281
-        $subscription = wpinv_authorizenet_create_new_subscription( $invoice, $response, $card_info );
280
+    if ($invoice->is_recurring() && !empty($response->approved)) {
281
+        $subscription = wpinv_authorizenet_create_new_subscription($invoice, $response, $card_info);
282 282
         $success = false;
283
-        if ( wpinv_is_test_mode( 'authorizenet' ) ) {
283
+        if (wpinv_is_test_mode('authorizenet')) {
284 284
             $success = true;
285 285
         } else {
286 286
             $success = $subscription->isSuccessful();
287 287
         }
288 288
 
289
-        if ( !empty( $subscription ) && $success ) {
290
-            do_action( 'wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet' );
289
+        if (!empty($subscription) && $success) {
290
+            do_action('wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet');
291 291
 
292
-            wpinv_authorizenet_subscription_record_signup( $subscription, $invoice );
292
+            wpinv_authorizenet_subscription_record_signup($subscription, $invoice);
293 293
 
294
-            do_action( 'wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet' );
294
+            do_action('wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet');
295 295
         } else {
296
-            if ( isset( $subscription->messages->message ) ) {
296
+            if (isset($subscription->messages->message)) {
297 297
                 $error = $subscription->messages->message->code . ': ' . $subscription->messages->message->text;
298
-                wpinv_set_error( 'wpinv_authorize_recurring_error', $error, 'invoicing' );
298
+                wpinv_set_error('wpinv_authorize_recurring_error', $error, 'invoicing');
299 299
             } else {
300
-                $error = __( 'Your subscription cannot be created due to an error.', 'invoicing' );
301
-                wpinv_set_error( 'wpinv_authorize_recurring_error', $error );
300
+                $error = __('Your subscription cannot be created due to an error.', 'invoicing');
301
+                wpinv_set_error('wpinv_authorize_recurring_error', $error);
302 302
             }
303 303
 
304
-            wpinv_record_gateway_error( $error, $subscription );
304
+            wpinv_record_gateway_error($error, $subscription);
305 305
 
306
-            wpinv_insert_payment_note( $invoice->ID, wp_sprintf( __( 'Authorize.Net subscription error occurred. %s', 'invoicing' ), $error ), '', '', true );
306
+            wpinv_insert_payment_note($invoice->ID, wp_sprintf(__('Authorize.Net subscription error occurred. %s', 'invoicing'), $error), '', '', true);
307 307
         }
308 308
     }
309 309
 }
310
-add_action( 'wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3 );
310
+add_action('wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3);
311 311
 
312
-function wpinv_authorizenet_create_new_subscription( $invoice, $response = array(), $card_info = array() ) {
313
-    if ( empty( $invoice ) ) {
312
+function wpinv_authorizenet_create_new_subscription($invoice, $response = array(), $card_info = array()) {
313
+    if (empty($invoice)) {
314 314
         return false;
315 315
     }
316 316
 
317
-    $params = wpinv_authorizenet_generate_subscription_params( $invoice, $card_info, $response );
317
+    $params = wpinv_authorizenet_generate_subscription_params($invoice, $card_info, $response);
318 318
 
319 319
     try {
320 320
         $authnetXML = wpinv_authorizenet_XML();
321
-        $authnetXML->ARBCreateSubscriptionRequest( $params );
322
-    } catch( Exception $e ) {
321
+        $authnetXML->ARBCreateSubscriptionRequest($params);
322
+    } catch (Exception $e) {
323 323
         $authnetXML = array();
324
-        wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) );
324
+        wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing'));
325 325
     }
326 326
 
327 327
     return $authnetXML;
328 328
 }
329 329
 
330
-function wpinv_authorizenet_generate_subscription_params( $invoice, $card_info = array(), $response = array() ) {
331
-    if ( empty( $invoice ) ) {
330
+function wpinv_authorizenet_generate_subscription_params($invoice, $card_info = array(), $response = array()) {
331
+    if (empty($invoice)) {
332 332
         return false;
333 333
     }
334 334
 
335
-    $subscription_item = $invoice->get_recurring( true );
336
-    if ( empty( $subscription_item->ID ) ) {
335
+    $subscription_item = $invoice->get_recurring(true);
336
+    if (empty($subscription_item->ID)) {
337 337
         return false;
338 338
     }
339 339
 
340
-    $item = $invoice->get_recurring( true );
340
+    $item = $invoice->get_recurring(true);
341 341
 
342
-    if ( empty( $item ) ) {
342
+    if (empty($item)) {
343 343
         $name = '';
344 344
     }
345 345
 
346
-    if ( !( $name = $item->get_name() ) ) {
346
+    if (!($name = $item->get_name())) {
347 347
         $name = $item->post_name;
348 348
     }
349 349
 
350
-    $card_details       = wpinv_authorizenet_generate_card_info( $card_info );
350
+    $card_details       = wpinv_authorizenet_generate_card_info($card_info);
351 351
     $subscription_name  = $invoice->get_subscription_name();
352
-    $initial_amount     = wpinv_round_amount( $invoice->get_total() );
353
-    $recurring_amount   = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) );
352
+    $initial_amount     = wpinv_round_amount($invoice->get_total());
353
+    $recurring_amount   = wpinv_round_amount($invoice->get_recurring_details('total'));
354 354
     $interval           = $subscription_item->get_recurring_interval();
355 355
     $period             = $subscription_item->get_recurring_period();
356 356
     $bill_times         = (int)$subscription_item->get_recurring_limit();
357 357
     $bill_times         = $bill_times > 0 ? $bill_times : 9999;
358 358
 
359
-    $time_period        = wpinv_authorizenet_get_time_period( $interval, $period );
359
+    $time_period        = wpinv_authorizenet_get_time_period($interval, $period);
360 360
     $interval           = $time_period['interval'];
361 361
     $period             = $time_period['period'];
362 362
 
363 363
     $current_tz = date_default_timezone_get();
364
-    date_default_timezone_set( 'America/Denver' ); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts.
365
-    $today = date( 'Y-m-d' );
366
-    date_default_timezone_set( $current_tz );
364
+    date_default_timezone_set('America/Denver'); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts.
365
+    $today = date('Y-m-d');
366
+    date_default_timezone_set($current_tz);
367 367
 
368 368
     $free_trial = $invoice->is_free_trial();
369
-    if ( $free_trial && $subscription_item->has_free_trial() ) {
369
+    if ($free_trial && $subscription_item->has_free_trial()) {
370 370
         $trial_interval    = $subscription_item->get_trial_interval();
371
-        $trial_period      = $subscription_item->get_trial_period( true );
371
+        $trial_period      = $subscription_item->get_trial_period(true);
372 372
     }
373 373
 
374 374
     $subscription = array();
375 375
     $subscription['name'] = $subscription_name;
376 376
 
377 377
     $subscription['paymentSchedule'] = array(
378
-        'interval'         => array( 'length' => $interval, 'unit' => $period ),
378
+        'interval'         => array('length' => $interval, 'unit' => $period),
379 379
         'startDate'        => $today,
380 380
         'totalOccurrences' => $bill_times,
381
-        'trialOccurrences' => $free_trial || ( $initial_amount != $recurring_amount ) ? 1 : 0,
381
+        'trialOccurrences' => $free_trial || ($initial_amount != $recurring_amount) ? 1 : 0,
382 382
     );
383 383
 
384 384
     $subscription['amount'] = $recurring_amount;
385 385
     $subscription['trialAmount'] = $initial_amount;
386
-    $subscription['payment'] = array( 'creditCard' => $card_details );
387
-    $subscription['order'] = array( 'invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number() );
388
-    $subscription['customer'] = array( 'id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone );
386
+    $subscription['payment'] = array('creditCard' => $card_details);
387
+    $subscription['order'] = array('invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number());
388
+    $subscription['customer'] = array('id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone);
389 389
 
390 390
     $subscription['billTo'] = array(
391 391
         'firstName' => $invoice->get_first_name(),
392 392
         'lastName'  => $invoice->get_last_name(),
393 393
         'company'   => $invoice->company,
394
-        'address'   => wp_strip_all_tags( $invoice->get_address(), true ),
394
+        'address'   => wp_strip_all_tags($invoice->get_address(), true),
395 395
         'city'      => $invoice->city,
396 396
         'state'     => $invoice->state,
397 397
         'zip'       => $invoice->zip,
398 398
         'country'   => $invoice->country,
399 399
     );
400 400
 
401
-    $params = array( 'subscription' => $subscription );
401
+    $params = array('subscription' => $subscription);
402 402
 
403
-    return apply_filters( 'wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response );
403
+    return apply_filters('wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response);
404 404
 }
405 405
 
406
-function wpinv_authorizenet_generate_card_info( $card_info = array() ) {
407
-    $card_defaults      = array(
406
+function wpinv_authorizenet_generate_card_info($card_info = array()) {
407
+    $card_defaults = array(
408 408
         'cc_owner'          => null,
409 409
         'cc_number'         => null,
410 410
         'cc_expire_month'   => null,
411 411
         'cc_expire_year'    => null,
412 412
         'cc_cvv2'           => null,
413 413
     );
414
-    $card_info = wp_parse_args( $card_info, $card_defaults );
414
+    $card_info = wp_parse_args($card_info, $card_defaults);
415 415
 
416 416
     $card_details = array(
417
-        'cardNumber'     => str_replace( ' ', '', sanitize_text_field( $card_info['cc_number'] ) ),
418
-        'expirationDate' => sanitize_text_field( $card_info['cc_expire_month'] ) . sanitize_text_field( $card_info['cc_expire_year'] ),
419
-        'cardCode'       => sanitize_text_field( $card_info['cc_cvv2'] ),
417
+        'cardNumber'     => str_replace(' ', '', sanitize_text_field($card_info['cc_number'])),
418
+        'expirationDate' => sanitize_text_field($card_info['cc_expire_month']) . sanitize_text_field($card_info['cc_expire_year']),
419
+        'cardCode'       => sanitize_text_field($card_info['cc_cvv2']),
420 420
     );
421 421
 
422 422
     return $card_details;
423 423
 }
424 424
 
425
-function wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ) {
426
-    $parent_invoice_id = absint( $invoice->ID );
425
+function wpinv_authorizenet_subscription_record_signup($subscription, $invoice) {
426
+    $parent_invoice_id = absint($invoice->ID);
427 427
 
428
-    if( empty( $parent_invoice_id ) ) {
428
+    if (empty($parent_invoice_id)) {
429 429
         return;
430 430
     }
431 431
 
432
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
433
-    if ( empty( $invoice ) ) {
432
+    $invoice = wpinv_get_invoice($parent_invoice_id);
433
+    if (empty($invoice)) {
434 434
         return;
435 435
     }
436 436
 
437 437
     $subscriptionId     = (array)$subscription->subscriptionId;
438
-    $subscription_id    = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id;
438
+    $subscription_id    = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id;
439 439
 
440
-    $subscription = wpinv_get_authorizenet_subscription( $subscription, $parent_invoice_id );
440
+    $subscription = wpinv_get_authorizenet_subscription($subscription, $parent_invoice_id);
441 441
 
442
-    if ( false === $subscription ) {
442
+    if (false === $subscription) {
443 443
         return;
444 444
     }
445 445
 
446 446
     // Set payment to complete
447
-    wpinv_update_payment_status( $subscription->parent_payment_id, 'publish' );
447
+    wpinv_update_payment_status($subscription->parent_payment_id, 'publish');
448 448
     sleep(1);
449
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'Authorize.Net Subscription ID: %s', 'invoicing' ) , $subscription_id ), '', '', true );
450
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $subscription_id);
449
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('Authorize.Net Subscription ID: %s', 'invoicing'), $subscription_id), '', '', true);
450
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $subscription_id);
451 451
 
452 452
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
453
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
454
-    $created    = date_i18n( 'Y-m-d H:i:s' );
455
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
453
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
454
+    $created    = date_i18n('Y-m-d H:i:s');
455
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
456 456
 
457 457
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
458
-    $subscription->update( array( 'profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
458
+    $subscription->update(array('profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration));
459 459
 }
460 460
 
461
-function wpinv_authorizenet_validate_checkout( $valid_data, $post ) {
462
-    if ( !empty( $post['wpi-gateway'] ) && $post['wpi-gateway'] == 'authorizenet' ) {
461
+function wpinv_authorizenet_validate_checkout($valid_data, $post) {
462
+    if (!empty($post['wpi-gateway']) && $post['wpi-gateway'] == 'authorizenet') {
463 463
         $error = false;
464 464
         
465
-        if ( empty( $post['authorizenet']['cc_owner'] ) ) {
465
+        if (empty($post['authorizenet']['cc_owner'])) {
466 466
             $error = true;
467
-            wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing'));
467
+            wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing'));
468 468
         }
469
-        if ( empty( $post['authorizenet']['cc_number'] ) ) {
469
+        if (empty($post['authorizenet']['cc_number'])) {
470 470
             $error = true;
471
-            wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing'));
471
+            wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing'));
472 472
         }
473
-        if ( empty( $post['authorizenet']['cc_expire_month'] ) ) {
473
+        if (empty($post['authorizenet']['cc_expire_month'])) {
474 474
             $error = true;
475
-            wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing'));
475
+            wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing'));
476 476
         }
477
-        if ( empty( $post['authorizenet']['cc_expire_year'] ) ) {
477
+        if (empty($post['authorizenet']['cc_expire_year'])) {
478 478
             $error = true;
479
-            wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing'));
479
+            wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing'));
480 480
         }
481
-        if ( empty( $post['authorizenet']['cc_cvv2'] ) ) {
481
+        if (empty($post['authorizenet']['cc_cvv2'])) {
482 482
             $error = true;
483
-            wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) );
483
+            wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing'));
484 484
         }
485 485
 
486
-        if ( $error ) {
486
+        if ($error) {
487 487
             return;
488 488
         }
489 489
 
490 490
         $invoice = wpinv_get_invoice_cart();
491 491
 
492
-        if ( !empty( $invoice ) && $subscription_item = $invoice->get_recurring( true ) ) {
493
-            $subscription_item = $invoice->get_recurring( true );
492
+        if (!empty($invoice) && $subscription_item = $invoice->get_recurring(true)) {
493
+            $subscription_item = $invoice->get_recurring(true);
494 494
 
495 495
             $interval   = $subscription_item->get_recurring_interval();
496 496
             $period     = $subscription_item->get_recurring_period();
497 497
 
498
-            if ( $period == 'D' && ( $interval < 7 || $interval > 365 ) ) {
499
-                wpinv_set_error( 'authorizenet_subscription_error', __( 'Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing' ) );
498
+            if ($period == 'D' && ($interval < 7 || $interval > 365)) {
499
+                wpinv_set_error('authorizenet_subscription_error', __('Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing'));
500 500
             }
501 501
         }
502 502
     }
503 503
 }
504
-add_action( 'wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2 );
504
+add_action('wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2);
505 505
 
506
-function wpinv_authorizenet_get_time_period( $subscription_interval, $subscription_period ) {
507
-    $subscription_interval = absint( $subscription_interval );
506
+function wpinv_authorizenet_get_time_period($subscription_interval, $subscription_period) {
507
+    $subscription_interval = absint($subscription_interval);
508 508
 
509
-    switch( $subscription_period ) {
509
+    switch ($subscription_period) {
510 510
         case 'W':
511 511
         case 'week':
512 512
         case 'weeks':
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
         case 'M':
517 517
         case 'month':
518 518
         case 'months':
519
-            if ( $subscription_interval > 12 ) {
519
+            if ($subscription_interval > 12) {
520 520
                 $subscription_interval = 12;
521 521
             }
522 522
 
523 523
             $interval = $subscription_interval;
524 524
             $period   = 'months';
525 525
             
526
-            if ( !( $subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12 ) ) {
526
+            if (!($subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12)) {
527 527
                 $interval = $subscription_interval * 30;
528 528
                 $period   = 'days';
529 529
             }
@@ -540,30 +540,30 @@  discard block
 block discarded – undo
540 540
             break;
541 541
     }
542 542
 
543
-    return compact( 'interval', 'period' );
543
+    return compact('interval', 'period');
544 544
 }
545 545
 
546 546
 function wpinv_authorizenet_process_ipn() {
547
-    if ( !( !empty( $_REQUEST['wpi-gateway'] ) && $_REQUEST['wpi-gateway'] == 'authorizenet' ) ) {
547
+    if (!(!empty($_REQUEST['wpi-gateway']) && $_REQUEST['wpi-gateway'] == 'authorizenet')) {
548 548
         return;
549 549
     }
550 550
 
551
-    $subscription_id = !empty( $_POST['x_subscription_id'] ) ? intval( $_POST['x_subscription_id'] ) : false;
551
+    $subscription_id = !empty($_POST['x_subscription_id']) ? intval($_POST['x_subscription_id']) : false;
552 552
 
553
-    if ( $subscription_id ) {
554
-        $response_code  = intval( $_POST['x_response_code'] );
555
-        $reason_code    = intval( $_POST['x_response_reason_code'] );
553
+    if ($subscription_id) {
554
+        $response_code  = intval($_POST['x_response_code']);
555
+        $reason_code    = intval($_POST['x_response_reason_code']);
556 556
 
557
-        $subscription = new WPInv_Subscription( $subscription_id, true );
557
+        $subscription = new WPInv_Subscription($subscription_id, true);
558 558
 
559
-        if ( !$subscription->id ) {
559
+        if (!$subscription->id) {
560 560
             return;
561 561
         }
562 562
 
563
-        if ( 1 == $response_code ) {
563
+        if (1 == $response_code) {
564 564
             // Approved
565
-            $transaction_id = sanitize_text_field( $_POST['x_trans_id'] );
566
-            $renewal_amount = sanitize_text_field( $_POST['x_amount'] );
565
+            $transaction_id = sanitize_text_field($_POST['x_trans_id']);
566
+            $renewal_amount = sanitize_text_field($_POST['x_amount']);
567 567
 
568 568
             $args = array(
569 569
                 'amount'         => $renewal_amount,
@@ -571,63 +571,63 @@  discard block
 block discarded – undo
571 571
                 'gateway'        => 'authorizenet'
572 572
             );
573 573
 
574
-            $subscription->add_payment( $args );
574
+            $subscription->add_payment($args);
575 575
             $subscription->renew();
576 576
 
577
-            do_action( 'wpinv_recurring_authorizenet_silent_post_payment', $subscription );
578
-            do_action( 'wpinv_authorizenet_renewal_payment', $subscription );
579
-        } else if ( 2 == $response_code ) {
577
+            do_action('wpinv_recurring_authorizenet_silent_post_payment', $subscription);
578
+            do_action('wpinv_authorizenet_renewal_payment', $subscription);
579
+        } else if (2 == $response_code) {
580 580
             // Declined
581 581
             $subscription->failing();
582
-            do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription );
583
-            do_action( 'wpinv_authorizenet_renewal_error', $subscription );
584
-        } else if ( 3 == $response_code || 8 == $reason_code ) {
582
+            do_action('wpinv_authorizenet_renewal_payment_failed', $subscription);
583
+            do_action('wpinv_authorizenet_renewal_error', $subscription);
584
+        } else if (3 == $response_code || 8 == $reason_code) {
585 585
             // An expired card
586 586
             $subscription->failing();
587
-            do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription );
588
-            do_action( 'wpinv_authorizenet_renewal_error', $subscription );
587
+            do_action('wpinv_authorizenet_renewal_payment_failed', $subscription);
588
+            do_action('wpinv_authorizenet_renewal_error', $subscription);
589 589
         } else {
590 590
             // Other Error
591
-            do_action( 'wpinv_authorizenet_renewal_payment_error', $subscription );
591
+            do_action('wpinv_authorizenet_renewal_payment_error', $subscription);
592 592
         }
593 593
 
594 594
         exit;
595 595
     }
596 596
 }
597
-add_action( 'wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn' );
597
+add_action('wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn');
598 598
 
599 599
 /**
600 600
  * Retrieve the subscription
601 601
  */
602
-function wpinv_get_authorizenet_subscription( $subscription_data = array(), $invoice_id ) {
603
-    $parent_invoice_id = absint( $invoice_id );
602
+function wpinv_get_authorizenet_subscription($subscription_data = array(), $invoice_id) {
603
+    $parent_invoice_id = absint($invoice_id);
604 604
 
605
-    if ( empty( $subscription_data ) ) {
605
+    if (empty($subscription_data)) {
606 606
         return false;
607 607
     }
608 608
 
609
-    if ( empty( $parent_invoice_id ) ) {
609
+    if (empty($parent_invoice_id)) {
610 610
         return false;
611 611
     }
612 612
 
613
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
614
-    if ( empty( $invoice ) ) {
613
+    $invoice = wpinv_get_invoice($parent_invoice_id);
614
+    if (empty($invoice)) {
615 615
         return false;
616 616
     }
617 617
 
618 618
     $subscriptionId     = (array)$subscription_data->subscriptionId;
619
-    $subscription_id    = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id;
619
+    $subscription_id    = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id;
620 620
 
621
-    $subscription = new WPInv_Subscription( $subscription_id, true );
621
+    $subscription = new WPInv_Subscription($subscription_id, true);
622 622
 
623
-    if ( ! $subscription || $subscription->id < 1 ) {
623
+    if (!$subscription || $subscription->id < 1) {
624 624
         $subs_db      = new WPInv_Subscriptions_DB;
625
-        $subs         = $subs_db->get_subscriptions( array( 'parent_payment_id' => $parent_invoice_id, 'number' => 1 ) );
626
-        $subscription = reset( $subs );
625
+        $subs         = $subs_db->get_subscriptions(array('parent_payment_id' => $parent_invoice_id, 'number' => 1));
626
+        $subscription = reset($subs);
627 627
 
628
-        if ( $subscription && $subscription->id > 0 ) {
628
+        if ($subscription && $subscription->id > 0) {
629 629
             // Update the profile ID so it is set for future renewals
630
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $subscription_id ) ) );
630
+            $subscription->update(array('profile_id' => sanitize_text_field($subscription_id)));
631 631
         } else {
632 632
             // No subscription found with a matching payment ID, bail
633 633
             return false;
@@ -638,67 +638,67 @@  discard block
 block discarded – undo
638 638
 }
639 639
 
640 640
 function wpinv_is_authorizenet_valid_for_use() {
641
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_authorizenet_supported_currencies', array( 'AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR' ) ) );
641
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_authorizenet_supported_currencies', array('AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR')));
642 642
 }
643
-function wpinv_check_authorizenet_currency_support( $gateway_list ) {
644
-    if ( isset( $gateway_list['authorizenet'] ) && ! wpinv_is_authorizenet_valid_for_use() ) {
645
-        unset( $gateway_list['authorizenet'] );
643
+function wpinv_check_authorizenet_currency_support($gateway_list) {
644
+    if (isset($gateway_list['authorizenet']) && !wpinv_is_authorizenet_valid_for_use()) {
645
+        unset($gateway_list['authorizenet']);
646 646
     }
647 647
     return $gateway_list;
648 648
 }
649
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1 );
649
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1);
650 650
 
651
-function wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
652
-    if ( $transaction_id == $invoice_id ) {
651
+function wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice) {
652
+    if ($transaction_id == $invoice_id) {
653 653
         $link = $transaction_id;
654 654
     } else {
655
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
655
+        if (!empty($invoice) && !empty($invoice->mode)) {
656 656
             $mode = $invoice->mode;
657 657
         } else {
658
-            $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live';
658
+            $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live';
659 659
         }
660 660
 
661 661
         $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/';
662 662
         $url .= 'ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=' . $transaction_id;
663 663
 
664
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $transaction_id . '</a>';
664
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $transaction_id . '</a>';
665 665
     }
666 666
 
667
-    return apply_filters( 'wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice );
667
+    return apply_filters('wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice);
668 668
 }
669
-add_filter( 'wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3 );
669
+add_filter('wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3);
670 670
 
671
-function wpinv_authorizenet_transaction_id_link( $transaction_id, $subscription ) {
672
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
673
-        $invoice = wpinv_get_invoice( $invoice_id );
671
+function wpinv_authorizenet_transaction_id_link($transaction_id, $subscription) {
672
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
673
+        $invoice = wpinv_get_invoice($invoice_id);
674 674
 
675
-        if ( ! empty( $invoice ) ) {
676
-            return wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice );
675
+        if (!empty($invoice)) {
676
+            return wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice);
677 677
         }        
678 678
     }
679 679
     
680 680
     return $transaction_id;
681 681
 }
682
-add_filter( 'wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2 );
682
+add_filter('wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2);
683 683
 
684
-function wpinv_authorizenet_profile_id_link( $profile_id, $subscription ) {
684
+function wpinv_authorizenet_profile_id_link($profile_id, $subscription) {
685 685
     $link = $profile_id;
686 686
 
687
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
688
-        $invoice = wpinv_get_invoice( $invoice_id );
687
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
688
+        $invoice = wpinv_get_invoice($invoice_id);
689 689
 
690
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
690
+        if (!empty($invoice) && !empty($invoice->mode)) {
691 691
             $mode = $invoice->mode;
692 692
         } else {
693
-            $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live';
693
+            $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live';
694 694
         }
695 695
 
696 696
         $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/';
697 697
         $url .= 'ui/themes/sandbox/ARB/SubscriptionDetail.aspx?SubscrID=' . $profile_id;
698 698
 
699
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
699
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
700 700
     }
701 701
     
702
-    return apply_filters( 'wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription );
702
+    return apply_filters('wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription);
703 703
 }
704
-add_filter( 'wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2 );
705 704
\ No newline at end of file
705
+add_filter('wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2);
706 706
\ No newline at end of file
Please login to merge, or discard this patch.