Passed
Pull Request — master (#217)
by Patrik
03:45
created
templates/emails/wpinv-email-completed_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_note.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 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
-do_action( 'wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note );
8
+do_action('wpinv_email_before_note_details', $invoice, $email_type, $sent_to_admin, $customer_note);
9 9
 
10
-if ( ! empty( $message_body ) ) {
11
-    echo wpautop( wptexturize( $message_body ) );
10
+if (!empty($message_body)) {
11
+    echo wpautop(wptexturize($message_body));
12 12
 }
13 13
 
14
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
18
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
19 19
 
20
-do_action( 'wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note );
20
+do_action('wpinv_email_after_note_details', $invoice, $email_type, $sent_to_admin, $customer_note);
21 21
 
22
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
23 22
\ No newline at end of file
23
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-overdue.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 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_footer', $invoice, $email_type, $sent_to_admin );
13 12
\ No newline at end of file
13
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
14 14
\ No newline at end of file
Please login to merge, or discard this patch.
templates/wpinv-subscriptions-history.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@
 block discarded – undo
29 29
     <table class="table table-bordered table-hover table-responsive wpi-user-subscriptions">
30 30
         <thead>
31 31
         <tr>
32
-            <th class="sub-no"><span class="nobr"><?php _e( 'No.', 'invoicing' ); ?></span></th>
33
-            <th class="sub-amount"><span class="nobr"><?php _e( 'Initial Amount', 'invoicing' ); ?></span></th>
34
-            <th class="sub-cycle"><span class="nobr"><?php _e( 'Billing Cycle', 'invoicing' ); ?></span></th>
35
-            <th class="sub-billed"><span class="nobr"><?php _e( 'Times Billed', 'invoicing' ); ?></span></th>
36
-            <th class="sub-status"><span class="nobr"><?php _e( 'Status', 'invoicing' ); ?></span></th>
37
-            <th class="sub-invoice"><span class="nobr"><?php _e( 'Invoice', 'invoicing' ); ?></span></th>
38
-            <th class="sub-item"><span class="nobr"><?php _e( 'Item', 'invoicing' ); ?></span></th>
39
-            <th class="sub-gateway"><span class="nobr"><?php _e( 'Gateway', 'invoicing' ); ?></span></th>
40
-            <th class="sub-expiry"><span class="nobr"><?php _e( 'Expires On', 'invoicing' ); ?></span></th>
41
-            <th class="sub-actions"><span class="nobr"><?php _e( 'Actions', 'invoicing' ); ?></span></th>
32
+            <th class="sub-no"><span class="nobr"><?php _e('No.', 'invoicing'); ?></span></th>
33
+            <th class="sub-amount"><span class="nobr"><?php _e('Initial Amount', 'invoicing'); ?></span></th>
34
+            <th class="sub-cycle"><span class="nobr"><?php _e('Billing Cycle', 'invoicing'); ?></span></th>
35
+            <th class="sub-billed"><span class="nobr"><?php _e('Times Billed', 'invoicing'); ?></span></th>
36
+            <th class="sub-status"><span class="nobr"><?php _e('Status', 'invoicing'); ?></span></th>
37
+            <th class="sub-invoice"><span class="nobr"><?php _e('Invoice', 'invoicing'); ?></span></th>
38
+            <th class="sub-item"><span class="nobr"><?php _e('Item', 'invoicing'); ?></span></th>
39
+            <th class="sub-gateway"><span class="nobr"><?php _e('Gateway', 'invoicing'); ?></span></th>
40
+            <th class="sub-expiry"><span class="nobr"><?php _e('Expires On', 'invoicing'); ?></span></th>
41
+            <th class="sub-actions"><span class="nobr"><?php _e('Actions', 'invoicing'); ?></span></th>
42 42
         </tr>
43 43
         </thead>
44 44
 
Please login to merge, or discard this patch.
includes/class-wpinv-cache-helper.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
      * Hook in methods.
15 15
      */
16 16
     public static function init() {
17
-        add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 );
18
-        add_action( 'admin_notices', array( __CLASS__, 'notices' ) );
17
+        add_action('init', array(__CLASS__, 'init_hooks'), 0);
18
+        add_action('admin_notices', array(__CLASS__, 'notices'));
19 19
     }
20 20
 
21 21
     public static function init_hooks() {
22
-        if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) {
23
-            $checkout_page = wpinv_get_option( 'checkout_page', '' );
24
-            $success_page  = wpinv_get_option( 'success_page', '' );
25
-            $failure_page  = wpinv_get_option( 'failure_page', '' );
26
-            $history_page  = wpinv_get_option( 'invoice_history_page', '' );
27
-            $subscr_page   = wpinv_get_option( 'invoice_subscription_page', '' );
28
-            if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) {
22
+        if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) {
23
+            $checkout_page = wpinv_get_option('checkout_page', '');
24
+            $success_page  = wpinv_get_option('success_page', '');
25
+            $failure_page  = wpinv_get_option('failure_page', '');
26
+            $history_page  = wpinv_get_option('invoice_history_page', '');
27
+            $subscr_page   = wpinv_get_option('invoice_subscription_page', '');
28
+            if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) {
29 29
                 return;
30 30
             }
31 31
 
@@ -39,34 +39,34 @@  discard block
 block discarded – undo
39 39
             $page_uris[] = 'p=' . $subscr_page;
40 40
 
41 41
             // Exclude permalinks
42
-            $checkout_page  = get_post( $checkout_page );
43
-            $success_page   = get_post( $success_page );
44
-            $failure_page   = get_post( $failure_page );
45
-            $history_page   = get_post( $history_page );
46
-            $subscr_page    = get_post( $subscr_page );
42
+            $checkout_page  = get_post($checkout_page);
43
+            $success_page   = get_post($success_page);
44
+            $failure_page   = get_post($failure_page);
45
+            $history_page   = get_post($history_page);
46
+            $subscr_page    = get_post($subscr_page);
47 47
 
48
-            if ( ! is_null( $checkout_page ) ) {
48
+            if (!is_null($checkout_page)) {
49 49
                 $page_uris[] = '/' . $checkout_page->post_name;
50 50
             }
51
-            if ( ! is_null( $success_page ) ) {
51
+            if (!is_null($success_page)) {
52 52
                 $page_uris[] = '/' . $success_page->post_name;
53 53
             }
54
-            if ( ! is_null( $failure_page ) ) {
54
+            if (!is_null($failure_page)) {
55 55
                 $page_uris[] = '/' . $failure_page->post_name;
56 56
             }
57
-            if ( ! is_null( $history_page ) ) {
57
+            if (!is_null($history_page)) {
58 58
                 $page_uris[] = '/' . $history_page->post_name;
59 59
             }
60
-            if ( ! is_null( $subscr_page ) ) {
60
+            if (!is_null($subscr_page)) {
61 61
                 $page_uris[] = '/' . $subscr_page->post_name;
62 62
             }
63 63
 
64
-            set_transient( 'wpinv_cache_excluded_uris', $page_uris );
64
+            set_transient('wpinv_cache_excluded_uris', $page_uris);
65 65
         }
66 66
 
67
-        if ( is_array( $page_uris ) ) {
68
-            foreach( $page_uris as $uri ) {
69
-                if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) {
67
+        if (is_array($page_uris)) {
68
+            foreach ($page_uris as $uri) {
69
+                if (strstr($_SERVER['REQUEST_URI'], $uri)) {
70 70
                     self::nocache();
71 71
                     break;
72 72
                 }
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
      * @access private
80 80
      */
81 81
     private static function nocache() {
82
-        if ( ! defined( 'DONOTCACHEPAGE' ) ) {
83
-            define( "DONOTCACHEPAGE", true );
82
+        if (!defined('DONOTCACHEPAGE')) {
83
+            define("DONOTCACHEPAGE", true);
84 84
         }
85
-        if ( ! defined( 'DONOTCACHEOBJECT' ) ) {
86
-            define( "DONOTCACHEOBJECT", true );
85
+        if (!defined('DONOTCACHEOBJECT')) {
86
+            define("DONOTCACHEOBJECT", true);
87 87
         }
88
-        if ( ! defined( 'DONOTCACHEDB' ) ) {
89
-            define( "DONOTCACHEDB", true );
88
+        if (!defined('DONOTCACHEDB')) {
89
+            define("DONOTCACHEDB", true);
90 90
         }
91 91
         nocache_headers();
92 92
     }
@@ -95,18 +95,18 @@  discard block
 block discarded – undo
95 95
      * notices function.
96 96
      */
97 97
     public static function notices() {
98
-        if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
98
+        if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) {
99 99
             return;
100 100
         }
101 101
 
102
-        $config   = w3_instance( 'W3_Config' );
103
-        $enabled  = $config->get_integer( 'dbcache.enabled' );
104
-        $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) );
102
+        $config   = w3_instance('W3_Config');
103
+        $enabled  = $config->get_integer('dbcache.enabled');
104
+        $settings = array_map('trim', $config->get_array('dbcache.reject.sql'));
105 105
 
106
-        if ( $enabled && ! in_array( '_wp_session_', $settings ) ) {
106
+        if ($enabled && !in_array('_wp_session_', $settings)) {
107 107
             ?>
108 108
             <div class="error">
109
-                <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p>
109
+                <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p>
110 110
             </div>
111 111
             <?php
112 112
         }
Please login to merge, or discard this patch.
includes/class-wpinv-shortcodes.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -16,41 +16,41 @@  discard block
 block discarded – undo
16 16
             'wpinv_subscriptions'  => __CLASS__ . '::subscriptions',
17 17
         );
18 18
 
19
-        foreach ( $shortcodes as $shortcode => $function ) {
20
-            add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function );
19
+        foreach ($shortcodes as $shortcode => $function) {
20
+            add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function);
21 21
         }
22 22
         
23
-        add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' );
23
+        add_shortcode('wpinv_messages', __CLASS__ . '::messages');
24 24
     }
25 25
 
26
-    public static function shortcode_wrapper( $function, $atts = array(), $content = null, $wrapper = array( 'class' => 'wpi-g', 'before' => null, 'after' => null ) ) {
26
+    public static function shortcode_wrapper($function, $atts = array(), $content = null, $wrapper = array('class' => 'wpi-g', 'before' => null, 'after' => null)) {
27 27
         ob_start();
28 28
 
29
-        echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before'];
30
-        call_user_func( $function, $atts, $content );
31
-        echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after'];
29
+        echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before'];
30
+        call_user_func($function, $atts, $content);
31
+        echo empty($wrapper['after']) ? '</div>' : $wrapper['after'];
32 32
 
33 33
         return ob_get_clean();
34 34
     }
35 35
 
36
-    public static function checkout( $atts = array(), $content = null ) {
37
-        return self::shortcode_wrapper( array( __CLASS__, 'checkout_output' ), $atts, $content );
36
+    public static function checkout($atts = array(), $content = null) {
37
+        return self::shortcode_wrapper(array(__CLASS__, 'checkout_output'), $atts, $content);
38 38
     }
39 39
     
40
-    public static function checkout_output( $atts = array(), $content = null ) {
41
-        do_action( 'wpinv_checkout_content_before' );
42
-        echo wpinv_checkout_form( $atts, $content );
43
-        do_action( 'wpinv_checkout_content_after' );
40
+    public static function checkout_output($atts = array(), $content = null) {
41
+        do_action('wpinv_checkout_content_before');
42
+        echo wpinv_checkout_form($atts, $content);
43
+        do_action('wpinv_checkout_content_after');
44 44
     }
45 45
 
46
-    public static function messages( $atts, $content = null ) {
46
+    public static function messages($atts, $content = null) {
47 47
         ob_start();
48 48
         wpinv_print_errors();
49 49
         return '<div class="wpinv">' . ob_get_clean() . '</div>';
50 50
     }
51 51
     
52
-    public static function history( $atts, $content = null ) {
53
-        return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts );
52
+    public static function history($atts, $content = null) {
53
+        return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts);
54 54
     }
55 55
 
56 56
     /**
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @param array $atts
60 60
      */
61
-    public static function history_output( $atts ) {
62
-        do_action( 'wpinv_before_user_invoice_history' );
63
-        wpinv_get_template_part( 'wpinv-invoice-history', $atts );
64
-        do_action( 'wpinv_after_user_invoice_history' );
61
+    public static function history_output($atts) {
62
+        do_action('wpinv_before_user_invoice_history');
63
+        wpinv_get_template_part('wpinv-invoice-history', $atts);
64
+        do_action('wpinv_after_user_invoice_history');
65 65
     }
66 66
     
67
-    public static function success( $atts, $content = null ) {
68
-        return self::shortcode_wrapper( array( __CLASS__, 'success_output' ), $atts, $content );
67
+    public static function success($atts, $content = null) {
68
+        return self::shortcode_wrapper(array(__CLASS__, 'success_output'), $atts, $content);
69 69
     }
70 70
     
71 71
     /**
@@ -73,31 +73,31 @@  discard block
 block discarded – undo
73 73
      *
74 74
      * @param array $atts
75 75
      */
76
-    public static function success_output( $atts, $content = null ) {
77
-        do_action( 'wpinv_success_content_before' );
78
-        echo wpinv_payment_receipt( $atts, $content );
79
-        do_action( 'wpinv_success_content_after' );
76
+    public static function success_output($atts, $content = null) {
77
+        do_action('wpinv_success_content_before');
78
+        echo wpinv_payment_receipt($atts, $content);
79
+        do_action('wpinv_success_content_after');
80 80
     }
81 81
 
82
-    public static function buy( $atts, $content = null ) {
83
-        $a = shortcode_atts( array(
82
+    public static function buy($atts, $content = null) {
83
+        $a = shortcode_atts(array(
84 84
             'items'     => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity
85
-            'title'     => __( 'Buy Now', 'invoicing' ), // the button title
85
+            'title'     => __('Buy Now', 'invoicing'), // the button title
86 86
             'post_id'   => '', // any related post_id
87
-        ), $atts );
87
+        ), $atts);
88 88
 
89
-        $post_id = isset( $a['post_id'] ) ? (int)$a['post_id'] : '';
89
+        $post_id = isset($a['post_id']) ? (int)$a['post_id'] : '';
90 90
 
91 91
         $html = '<div class="wpi-buy-button-wrapper wpi-g">';
92 92
         $html .= '<button class="button button-primary wpi-buy-button" type="button" onclick="wpi_buy(this,\'' . $a['items'] . '\',' . $post_id . ');">' . $a['title'] . '</button>';
93
-        $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false );
93
+        $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false);
94 94
         $html .= '</div>';
95 95
 
96 96
         return $html;
97 97
     }
98 98
     
99
-    public static function subscriptions( $atts, $content = null ) {
100
-        return self::shortcode_wrapper( array( __CLASS__, 'subscriptions_output' ), $atts );
99
+    public static function subscriptions($atts, $content = null) {
100
+        return self::shortcode_wrapper(array(__CLASS__, 'subscriptions_output'), $atts);
101 101
     }
102 102
 
103 103
     /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @param array $atts
107 107
      */
108
-    public static function subscriptions_output( $atts ) {
109
-        do_action( 'wpinv_before_user_subscriptions' );
110
-        wpinv_get_template_part( 'wpinv-subscriptions-history', $atts );
111
-        do_action( 'wpinv_after_user_subscriptions' );
108
+    public static function subscriptions_output($atts) {
109
+        do_action('wpinv_before_user_subscriptions');
110
+        wpinv_get_template_part('wpinv-subscriptions-history', $atts);
111
+        do_action('wpinv_after_user_subscriptions');
112 112
     }
113 113
 }
Please login to merge, or discard this patch.
includes/gateways/manual.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  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_action( 'wpinv_manual_cc_form', '__return_false' );
5
+add_action('wpinv_manual_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_manual_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_manual_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     /*
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
     );
42 42
 
43 43
     // Record the pending payment
44
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
44
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
45 45
     
46
-    if ( !empty( $invoice ) ) {        
47
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
48
-        wpinv_update_payment_status( $invoice, 'publish' );
46
+    if (!empty($invoice)) {        
47
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
48
+        wpinv_update_payment_status($invoice, 'publish');
49 49
         
50 50
         // Empty the shopping cart
51 51
         wpinv_empty_cart();
52 52
         
53
-        do_action( 'wpinv_send_to_success_page', $invoice->ID, $payment_data );
53
+        do_action('wpinv_send_to_success_page', $invoice->ID, $payment_data);
54 54
         
55
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
55
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
56 56
     } else {
57
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
57
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a manual (free or test) purchase. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
58 58
         // If errors are present, send the user back to the purchase page so they can be corrected
59
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
59
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
60 60
     }
61 61
 }
62
-add_action( 'wpinv_gateway_manual', 'wpinv_process_manual_payment' );
63 62
\ No newline at end of file
63
+add_action('wpinv_gateway_manual', 'wpinv_process_manual_payment');
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions-db.php 1 patch
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  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 5
 /**
6 6
  * The Subscriptions DB Class
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
             'transaction_id'    => '',
69 69
             'parent_payment_id' => 0,
70 70
             'product_id'        => 0,
71
-            'created'           => date( 'Y-m-d H:i:s' ),
72
-            'expiration'        => date( 'Y-m-d H:i:s' ),
71
+            'created'           => date('Y-m-d H:i:s'),
72
+            'expiration'        => date('Y-m-d H:i:s'),
73 73
             'trial_period'      => '',
74 74
             'status'            => '',
75 75
             'profile_id'        => '',
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
      * @access  public
83 83
      * @since   1.0.0
84 84
      */
85
-    public function get_subscriptions( $args = array() ) {
85
+    public function get_subscriptions($args = array()) {
86 86
         global $wpdb;
87 87
 
88 88
         $defaults = array(
89
-            'number'       => get_option( 'posts_per_page' ),
89
+            'number'       => get_option('posts_per_page'),
90 90
             'offset'       => 0,
91 91
             'search'       => '',
92 92
             'customer_id'  => 0,
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
             'order'        => 'DESC'
95 95
         );
96 96
 
97
-        $args  = wp_parse_args( $args, $defaults );
97
+        $args = wp_parse_args($args, $defaults);
98 98
 
99
-        if( $args['number'] < 1 ) {
99
+        if ($args['number'] < 1) {
100 100
             $args['number'] = 999999999999;
101 101
         }
102 102
 
103 103
         $where = ' WHERE 1=1 ';
104 104
 
105 105
         // specific customers
106
-        if( ! empty( $args['id'] ) ) {
106
+        if (!empty($args['id'])) {
107 107
 
108
-            if( is_array( $args['id'] ) ) {
109
-                $ids = implode( ',', array_map('intval', $args['id'] ) );
108
+            if (is_array($args['id'])) {
109
+                $ids = implode(',', array_map('intval', $args['id']));
110 110
             } else {
111
-                $ids = intval( $args['id'] );
111
+                $ids = intval($args['id']);
112 112
             }
113 113
 
114 114
             $where .= " AND `id` IN( {$ids} ) ";
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
         }
117 117
 
118 118
         // Specific products
119
-        if( ! empty( $args['product_id'] ) ) {
119
+        if (!empty($args['product_id'])) {
120 120
 
121
-            if( is_array( $args['product_id'] ) ) {
122
-                $product_ids = implode( ',', array_map('intval', $args['product_id'] ) );
121
+            if (is_array($args['product_id'])) {
122
+                $product_ids = implode(',', array_map('intval', $args['product_id']));
123 123
             } else {
124
-                $product_ids = intval( $args['product_id'] );
124
+                $product_ids = intval($args['product_id']);
125 125
             }
126 126
 
127 127
             $where .= " AND `product_id` IN( {$product_ids} ) ";
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
         }
130 130
 
131 131
         // Specific parent payments
132
-        if( ! empty( $args['parent_payment_id'] ) ) {
132
+        if (!empty($args['parent_payment_id'])) {
133 133
 
134
-            if( is_array( $args['parent_payment_id'] ) ) {
135
-                $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) );
134
+            if (is_array($args['parent_payment_id'])) {
135
+                $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id']));
136 136
             } else {
137
-                $parent_payment_ids = intval( $args['parent_payment_id'] );
137
+                $parent_payment_ids = intval($args['parent_payment_id']);
138 138
             }
139 139
 
140 140
             $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) ";
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
         }
143 143
 
144 144
         // Specific transaction IDs
145
-        if( ! empty( $args['transaction_id'] ) ) {
145
+        if (!empty($args['transaction_id'])) {
146 146
 
147
-            if( is_array( $args['transaction_id'] ) ) {
148
-                $transaction_ids = implode( "','", array_map('sanitize_text_field', $args['transaction_id'] ) );
147
+            if (is_array($args['transaction_id'])) {
148
+                $transaction_ids = implode("','", array_map('sanitize_text_field', $args['transaction_id']));
149 149
             } else {
150
-                $transaction_ids = sanitize_text_field( $args['transaction_id'] );
150
+                $transaction_ids = sanitize_text_field($args['transaction_id']);
151 151
             }
152 152
 
153 153
             $where .= " AND `transaction_id` IN ( '{$transaction_ids}' ) ";
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
         }
156 156
 
157 157
         // Subscriptoins for specific customers
158
-        if( ! empty( $args['customer_id'] ) ) {
158
+        if (!empty($args['customer_id'])) {
159 159
 
160
-            if( is_array( $args['customer_id'] ) ) {
161
-                $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) );
160
+            if (is_array($args['customer_id'])) {
161
+                $customer_ids = implode(',', array_map('intval', $args['customer_id']));
162 162
             } else {
163
-                $customer_ids = intval( $args['customer_id'] );
163
+                $customer_ids = intval($args['customer_id']);
164 164
             }
165 165
 
166 166
             $where .= " AND `customer_id` IN( {$customer_ids} ) ";
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
         }
169 169
 
170 170
         // Subscriptions for specific profile IDs
171
-        if( ! empty( $args['profile_id'] ) ) {
171
+        if (!empty($args['profile_id'])) {
172 172
 
173
-            if( is_array( $args['profile_id'] ) ) {
174
-                $profile_ids = implode( "','", array_map('sanitize_text_field', $args['profile_id'] ) );
173
+            if (is_array($args['profile_id'])) {
174
+                $profile_ids = implode("','", array_map('sanitize_text_field', $args['profile_id']));
175 175
             } else {
176
-                $profile_ids = sanitize_text_field( $args['profile_id'] );
176
+                $profile_ids = sanitize_text_field($args['profile_id']);
177 177
             }
178 178
 
179 179
             $where .= " AND `profile_id` IN( '{$profile_ids}' ) ";
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
         }
182 182
 
183 183
         // Subscriptions for specific statuses
184
-        if( ! empty( $args['status'] ) ) {
184
+        if (!empty($args['status'])) {
185 185
 
186
-            if( is_array( $args['status'] ) ) {
187
-                $statuses = implode( "','", array_map( 'sanitize_text_field', $args['status'] ) );
186
+            if (is_array($args['status'])) {
187
+                $statuses = implode("','", array_map('sanitize_text_field', $args['status']));
188 188
             } else {
189
-                $statuses = sanitize_text_field( $args['status'] );
189
+                $statuses = sanitize_text_field($args['status']);
190 190
             }
191 191
 
192 192
             $where .= " AND `status` IN( '{$statuses}' ) ";
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
         }
195 195
 
196 196
         // Subscriptions created for a specific date or in a date range
197
-        if( ! empty( $args['date'] ) ) {
197
+        if (!empty($args['date'])) {
198 198
 
199
-            if( is_array( $args['date'] ) ) {
199
+            if (is_array($args['date'])) {
200 200
 
201
-                if( ! empty( $args['date']['start'] ) ) {
201
+                if (!empty($args['date']['start'])) {
202 202
 
203
-                    $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
203
+                    $start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
204 204
 
205 205
                     $where .= " AND `created` >= '{$start}'";
206 206
 
207 207
                 }
208 208
 
209
-                if( ! empty( $args['date']['end'] ) ) {
209
+                if (!empty($args['date']['end'])) {
210 210
 
211
-                    $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
211
+                    $end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
212 212
 
213 213
                     $where .= " AND `created` <= '{$end}'";
214 214
 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
             } else {
218 218
 
219
-                $year  = date( 'Y', strtotime( $args['date'] ) );
220
-                $month = date( 'm', strtotime( $args['date'] ) );
221
-                $day   = date( 'd', strtotime( $args['date'] ) );
219
+                $year  = date('Y', strtotime($args['date']));
220
+                $month = date('m', strtotime($args['date']));
221
+                $day   = date('d', strtotime($args['date']));
222 222
 
223 223
                 $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )";
224 224
             }
@@ -226,21 +226,21 @@  discard block
 block discarded – undo
226 226
         }
227 227
 
228 228
         // Subscriptions with a specific expiration date or in an expiration date range
229
-        if( ! empty( $args['expiration'] ) ) {
229
+        if (!empty($args['expiration'])) {
230 230
 
231
-            if( is_array( $args['expiration'] ) ) {
231
+            if (is_array($args['expiration'])) {
232 232
 
233
-                if( ! empty( $args['expiration']['start'] ) ) {
233
+                if (!empty($args['expiration']['start'])) {
234 234
 
235
-                    $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) );
235
+                    $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start']));
236 236
 
237 237
                     $where .= " AND `expiration` >= '{$start}'";
238 238
 
239 239
                 }
240 240
 
241
-                if( ! empty( $args['expiration']['end'] ) ) {
241
+                if (!empty($args['expiration']['end'])) {
242 242
 
243
-                    $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) );
243
+                    $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end']));
244 244
 
245 245
                     $where .= " AND `expiration` <= '{$end}'";
246 246
 
@@ -248,73 +248,73 @@  discard block
 block discarded – undo
248 248
 
249 249
             } else {
250 250
 
251
-                $year  = date( 'Y', strtotime( $args['expiration'] ) );
252
-                $month = date( 'm', strtotime( $args['expiration'] ) );
253
-                $day   = date( 'd', strtotime( $args['expiration'] ) );
251
+                $year  = date('Y', strtotime($args['expiration']));
252
+                $month = date('m', strtotime($args['expiration']));
253
+                $day   = date('d', strtotime($args['expiration']));
254 254
 
255 255
                 $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )";
256 256
             }
257 257
 
258 258
         }
259 259
 
260
-        if ( ! empty( $args['search'] ) ) {
260
+        if (!empty($args['search'])) {
261 261
 
262
-            if( false !== strpos( 'id:', $args['search'] ) ) {
262
+            if (false !== strpos('id:', $args['search'])) {
263 263
 
264
-                $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) );
265
-                $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'";
264
+                $args['search'] = trim(str_replace('id:', '', $args['search']));
265
+                $where .= " AND `id` = '" . esc_sql($args['search']) . "'";
266 266
 
267
-            } else if( false !== strpos( $args['search'], 'txn:' ) ) {
267
+            } else if (false !== strpos($args['search'], 'txn:')) {
268 268
 
269
-                $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) );
270
-                $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'";
269
+                $args['search'] = trim(str_replace('txn:', '', $args['search']));
270
+                $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'";
271 271
 
272
-            } else if( false !== strpos( $args['search'], 'profile_id:' ) ) {
272
+            } else if (false !== strpos($args['search'], 'profile_id:')) {
273 273
 
274
-                $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) );
275
-                $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'";
274
+                $args['search'] = trim(str_replace('profile_id:', '', $args['search']));
275
+                $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'";
276 276
 
277
-            } else if( false !== strpos( $args['search'], 'product_id:' ) ) {
277
+            } else if (false !== strpos($args['search'], 'product_id:')) {
278 278
 
279
-                $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) );
280
-                $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'";
279
+                $args['search'] = trim(str_replace('product_id:', '', $args['search']));
280
+                $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'";
281 281
 
282
-            } else if( false !== strpos( $args['search'], 'customer_id:' ) ) {
282
+            } else if (false !== strpos($args['search'], 'customer_id:')) {
283 283
 
284
-                $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) );
285
-                $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'";
284
+                $args['search'] = trim(str_replace('customer_id:', '', $args['search']));
285
+                $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'";
286 286
 
287 287
             } else {
288 288
 
289
-                $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )";
289
+                $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )";
290 290
 
291 291
             }
292 292
 
293 293
         }
294 294
 
295
-        $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
295
+        $args['orderby'] = !array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
296 296
 
297
-        if( 'amount' == $args['orderby'] ) {
297
+        if ('amount' == $args['orderby']) {
298 298
             $args['orderby'] = 'amount+0';
299 299
         }
300 300
 
301
-        $cache_key = md5( 'wpinv_subscriptions_' . serialize( $args ) );
301
+        $cache_key = md5('wpinv_subscriptions_' . serialize($args));
302 302
 
303
-        $subscriptions = wp_cache_get( $cache_key, 'subscriptions' );
303
+        $subscriptions = wp_cache_get($cache_key, 'subscriptions');
304 304
 
305
-        $args['orderby'] = esc_sql( $args['orderby'] );
306
-        $args['order']   = esc_sql( $args['order'] );
305
+        $args['orderby'] = esc_sql($args['orderby']);
306
+        $args['order']   = esc_sql($args['order']);
307 307
 
308
-        if( $subscriptions === false ) {
309
-            $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ), OBJECT );
308
+        if ($subscriptions === false) {
309
+            $subscriptions = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])), OBJECT);
310 310
 
311
-            if( ! empty( $subscriptions ) ) {
311
+            if (!empty($subscriptions)) {
312 312
 
313
-                foreach( $subscriptions as $key => $subscription ) {
314
-                    $subscriptions[ $key ] = new WPInv_Subscription( $subscription );
313
+                foreach ($subscriptions as $key => $subscription) {
314
+                    $subscriptions[$key] = new WPInv_Subscription($subscription);
315 315
                 }
316 316
 
317
-                wp_cache_set( $cache_key, $subscriptions, 'subscriptions', 3600 );
317
+                wp_cache_set($cache_key, $subscriptions, 'subscriptions', 3600);
318 318
 
319 319
             }
320 320
 
@@ -329,19 +329,19 @@  discard block
 block discarded – undo
329 329
      * @access  public
330 330
      * @since   1.0.0
331 331
      */
332
-    public function count( $args = array() ) {
332
+    public function count($args = array()) {
333 333
 
334 334
         global $wpdb;
335 335
 
336 336
         $where = ' WHERE 1=1 ';
337 337
 
338 338
         // specific customers
339
-        if( ! empty( $args['id'] ) ) {
339
+        if (!empty($args['id'])) {
340 340
 
341
-            if( is_array( $args['id'] ) ) {
342
-                $ids = implode( ',', array_map('intval', $args['id'] ) );
341
+            if (is_array($args['id'])) {
342
+                $ids = implode(',', array_map('intval', $args['id']));
343 343
             } else {
344
-                $ids = intval( $args['id'] );
344
+                $ids = intval($args['id']);
345 345
             }
346 346
 
347 347
             $where .= " AND `id` IN( {$ids} ) ";
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
         }
350 350
 
351 351
         // Specific products
352
-        if( ! empty( $args['product_id'] ) ) {
352
+        if (!empty($args['product_id'])) {
353 353
 
354
-            if( is_array( $args['product_id'] ) ) {
355
-                $product_ids = implode( ',', array_map('intval', $args['product_id'] ) );
354
+            if (is_array($args['product_id'])) {
355
+                $product_ids = implode(',', array_map('intval', $args['product_id']));
356 356
             } else {
357
-                $product_ids = intval( $args['product_id'] );
357
+                $product_ids = intval($args['product_id']);
358 358
             }
359 359
 
360 360
             $where .= " AND `product_id` IN( {$product_ids} ) ";
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
         }
363 363
 
364 364
         // Specific parent payments
365
-        if( ! empty( $args['parent_payment_id'] ) ) {
365
+        if (!empty($args['parent_payment_id'])) {
366 366
 
367
-            if( is_array( $args['parent_payment_id'] ) ) {
368
-                $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) );
367
+            if (is_array($args['parent_payment_id'])) {
368
+                $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id']));
369 369
             } else {
370
-                $parent_payment_ids = intval( $args['parent_payment_id'] );
370
+                $parent_payment_ids = intval($args['parent_payment_id']);
371 371
             }
372 372
 
373 373
             $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) ";
@@ -375,12 +375,12 @@  discard block
 block discarded – undo
375 375
         }
376 376
 
377 377
         // Subscriptoins for specific customers
378
-        if( ! empty( $args['customer_id'] ) ) {
378
+        if (!empty($args['customer_id'])) {
379 379
 
380
-            if( is_array( $args['customer_id'] ) ) {
381
-                $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) );
380
+            if (is_array($args['customer_id'])) {
381
+                $customer_ids = implode(',', array_map('intval', $args['customer_id']));
382 382
             } else {
383
-                $customer_ids = intval( $args['customer_id'] );
383
+                $customer_ids = intval($args['customer_id']);
384 384
             }
385 385
 
386 386
             $where .= " AND `customer_id` IN( {$customer_ids} ) ";
@@ -388,12 +388,12 @@  discard block
 block discarded – undo
388 388
         }
389 389
 
390 390
         // Subscriptions for specific profile IDs
391
-        if( ! empty( $args['profile_id'] ) ) {
391
+        if (!empty($args['profile_id'])) {
392 392
 
393
-            if( is_array( $args['profile_id'] ) ) {
394
-                $profile_ids = implode( ',', array_map('intval', $args['profile_id'] ) );
393
+            if (is_array($args['profile_id'])) {
394
+                $profile_ids = implode(',', array_map('intval', $args['profile_id']));
395 395
             } else {
396
-                $profile_ids = intval( $args['profile_id'] );
396
+                $profile_ids = intval($args['profile_id']);
397 397
             }
398 398
 
399 399
             $where .= " AND `profile_id` IN( {$profile_ids} ) ";
@@ -401,12 +401,12 @@  discard block
 block discarded – undo
401 401
         }
402 402
 
403 403
         // Specific transaction IDs
404
-        if( ! empty( $args['transaction_id'] ) ) {
404
+        if (!empty($args['transaction_id'])) {
405 405
 
406
-            if( is_array( $args['transaction_id'] ) ) {
407
-                $transaction_ids = implode( ',', array_map('sanitize_text_field', $args['transaction_id'] ) );
406
+            if (is_array($args['transaction_id'])) {
407
+                $transaction_ids = implode(',', array_map('sanitize_text_field', $args['transaction_id']));
408 408
             } else {
409
-                $transaction_ids = sanitize_text_field( $args['transaction_id'] );
409
+                $transaction_ids = sanitize_text_field($args['transaction_id']);
410 410
             }
411 411
 
412 412
             $where .= " AND `transaction_id` IN( {$transaction_ids} ) ";
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
         }
415 415
 
416 416
         // Subscriptions for specific statuses
417
-        if( ! empty( $args['status'] ) ) {
417
+        if (!empty($args['status'])) {
418 418
 
419
-            if( is_array( $args['status'] ) ) {
420
-                $statuses = implode( ',', $args['status'] );
419
+            if (is_array($args['status'])) {
420
+                $statuses = implode(',', $args['status']);
421 421
                 $where  .= " AND `status` IN( {$statuses} ) ";
422 422
             } else {
423 423
                 $statuses = $args['status'];
@@ -429,21 +429,21 @@  discard block
 block discarded – undo
429 429
         }
430 430
 
431 431
         // Subscriptions created for a specific date or in a date range
432
-        if( ! empty( $args['date'] ) ) {
432
+        if (!empty($args['date'])) {
433 433
 
434
-            if( is_array( $args['date'] ) ) {
434
+            if (is_array($args['date'])) {
435 435
 
436
-                if( ! empty( $args['date']['start'] ) ) {
436
+                if (!empty($args['date']['start'])) {
437 437
 
438
-                    $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
438
+                    $start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
439 439
 
440 440
                     $where .= " AND `created` >= '{$start}'";
441 441
 
442 442
                 }
443 443
 
444
-                if( ! empty( $args['date']['end'] ) ) {
444
+                if (!empty($args['date']['end'])) {
445 445
 
446
-                    $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
446
+                    $end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
447 447
 
448 448
                     $where .= " AND `created` <= '{$end}'";
449 449
 
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 
452 452
             } else {
453 453
 
454
-                $year  = date( 'Y', strtotime( $args['date'] ) );
455
-                $month = date( 'm', strtotime( $args['date'] ) );
456
-                $day   = date( 'd', strtotime( $args['date'] ) );
454
+                $year  = date('Y', strtotime($args['date']));
455
+                $month = date('m', strtotime($args['date']));
456
+                $day   = date('d', strtotime($args['date']));
457 457
 
458 458
                 $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )";
459 459
             }
@@ -461,21 +461,21 @@  discard block
 block discarded – undo
461 461
         }
462 462
 
463 463
         // Subscriptions with a specific expiration date or in an expiration date range
464
-        if( ! empty( $args['expiration'] ) ) {
464
+        if (!empty($args['expiration'])) {
465 465
 
466
-            if( is_array( $args['expiration'] ) ) {
466
+            if (is_array($args['expiration'])) {
467 467
 
468
-                if( ! empty( $args['expiration']['start'] ) ) {
468
+                if (!empty($args['expiration']['start'])) {
469 469
 
470
-                    $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) );
470
+                    $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start']));
471 471
 
472 472
                     $where .= " AND `expiration` >= '{$start}'";
473 473
 
474 474
                 }
475 475
 
476
-                if( ! empty( $args['expiration']['end'] ) ) {
476
+                if (!empty($args['expiration']['end'])) {
477 477
 
478
-                    $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) );
478
+                    $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end']));
479 479
 
480 480
                     $where .= " AND `expiration` <= '{$end}'";
481 481
 
@@ -483,64 +483,64 @@  discard block
 block discarded – undo
483 483
 
484 484
             } else {
485 485
 
486
-                $year  = date( 'Y', strtotime( $args['expiration'] ) );
487
-                $month = date( 'm', strtotime( $args['expiration'] ) );
488
-                $day   = date( 'd', strtotime( $args['expiration'] ) );
486
+                $year  = date('Y', strtotime($args['expiration']));
487
+                $month = date('m', strtotime($args['expiration']));
488
+                $day   = date('d', strtotime($args['expiration']));
489 489
 
490 490
                 $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )";
491 491
             }
492 492
 
493 493
         }
494 494
 
495
-        if ( ! empty( $args['search'] ) ) {
495
+        if (!empty($args['search'])) {
496 496
 
497
-            if( false !== strpos( 'id:', $args['search'] ) ) {
497
+            if (false !== strpos('id:', $args['search'])) {
498 498
 
499
-                $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) );
500
-                $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'";
499
+                $args['search'] = trim(str_replace('id:', '', $args['search']));
500
+                $where .= " AND `id` = '" . esc_sql($args['search']) . "'";
501 501
 
502
-            } else if( false !== strpos( $args['search'], 'txn:' ) ) {
502
+            } else if (false !== strpos($args['search'], 'txn:')) {
503 503
 
504
-                $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) );
505
-                $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'";
504
+                $args['search'] = trim(str_replace('txn:', '', $args['search']));
505
+                $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'";
506 506
 
507
-            } else if( false !== strpos( $args['search'], 'profile_id:' ) ) {
507
+            } else if (false !== strpos($args['search'], 'profile_id:')) {
508 508
 
509
-                $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) );
510
-                $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'";
509
+                $args['search'] = trim(str_replace('profile_id:', '', $args['search']));
510
+                $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'";
511 511
 
512
-            } else if( false !== strpos( $args['search'], 'product_id:' ) ) {
512
+            } else if (false !== strpos($args['search'], 'product_id:')) {
513 513
 
514
-                $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) );
515
-                $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'";
514
+                $args['search'] = trim(str_replace('product_id:', '', $args['search']));
515
+                $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'";
516 516
 
517
-            } else if( false !== strpos( $args['search'], 'customer_id:' ) ) {
517
+            } else if (false !== strpos($args['search'], 'customer_id:')) {
518 518
 
519
-                $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) );
520
-                $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'";
519
+                $args['search'] = trim(str_replace('customer_id:', '', $args['search']));
520
+                $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'";
521 521
 
522 522
             } else {
523 523
 
524
-                $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )";
524
+                $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )";
525 525
 
526 526
             }
527 527
 
528 528
         }
529 529
 
530
-        $cache_key = md5( 'wpinv_subscriptions_count' . serialize( $args ) );
530
+        $cache_key = md5('wpinv_subscriptions_count' . serialize($args));
531 531
 
532
-        $count = wp_cache_get( $cache_key, 'subscriptions' );
532
+        $count = wp_cache_get($cache_key, 'subscriptions');
533 533
 
534
-        if( $count === false ) {
534
+        if ($count === false) {
535 535
 
536 536
             $sql   = "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};";
537
-            $count = $wpdb->get_var( $sql );
537
+            $count = $wpdb->get_var($sql);
538 538
 
539
-            wp_cache_set( $cache_key, $count, 'subscriptions', 3600 );
539
+            wp_cache_set($cache_key, $count, 'subscriptions', 3600);
540 540
 
541 541
         }
542 542
 
543
-        return absint( $count );
543
+        return absint($count);
544 544
 
545 545
     }
546 546
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     public function create_table() {
554 554
         global $wpdb;
555 555
 
556
-        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
556
+        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
557 557
 
558 558
         $sql = "CREATE TABLE " . $this->table_name . " (
559 559
         id bigint(20) NOT NULL AUTO_INCREMENT,
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
         KEY customer_and_status ( customer_id, status)
579 579
         ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
580 580
 
581
-        dbDelta( $sql );
581
+        dbDelta($sql);
582 582
 
583
-        update_option( $this->table_name . '_db_version', $this->version );
583
+        update_option($this->table_name . '_db_version', $this->version);
584 584
     }
585 585
 
586 586
 }
587 587
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
 
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) exit;
11
+if (!defined('ABSPATH')) exit;
12 12
 
13 13
 
14 14
 // Load WP_List_Table if not loaded
15
-if( ! class_exists( 'WP_List_Table' ) ) {
15
+if (!class_exists('WP_List_Table')) {
16 16
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17 17
 }
18 18
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	public $pending_count   = 0;
36 36
 	public $expired_count   = 0;
37 37
 	public $completed_count = 0;
38
-	public $trialling_count  = 0;
38
+	public $trialling_count = 0;
39 39
 	public $cancelled_count = 0;
40 40
 	public $failing_count   = 0;
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 * @since       1.0.0
47 47
 	 * @return      void
48 48
 	 */
49
-	function __construct(){
49
+	function __construct() {
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
53
+		parent::__construct(array(
54 54
 			'singular'  => 'subscription',
55 55
 			'plural'    => 'subscriptions',
56 56
 			'ajax'      => false
57
-		) );
57
+		));
58 58
 
59 59
 		$this->get_subscription_counts();
60 60
 
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_views() {
71 71
 
72
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
72
+		$current         = isset($_GET['status']) ? $_GET['status'] : '';
73
+		$total_count     = '&nbsp;<span class="count">(' . $this->total_count . ')</span>';
74 74
 		$active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75 75
 		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
-		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
76
+		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count . ')</span>';
77 77
 		$completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
-		$trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
-		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
78
+		$trialling_count = '&nbsp;<span class="count">(' . $this->trialling_count . ')</span>';
79
+		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count . ')</span>';
80
+		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count . ')</span>';
81 81
 
82 82
 		$views = array(
83
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
-			'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
-			'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
-			'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
-			'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
-			'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
83
+			'all'       => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array('status', 'paged')), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'invoicing') . $total_count),
84
+			'active'    => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'active', 'paged' => FALSE)), $current === 'active' ? ' class="current"' : '', __('Active', 'invoicing') . $active_count),
85
+			'pending'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'pending', 'paged' => FALSE)), $current === 'pending' ? ' class="current"' : '', __('Pending', 'invoicing') . $pending_count),
86
+			'expired'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'expired', 'paged' => FALSE)), $current === 'expired' ? ' class="current"' : '', __('Expired', 'invoicing') . $expired_count),
87
+			'completed' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'completed', 'paged' => FALSE)), $current === 'completed' ? ' class="current"' : '', __('Completed', 'invoicing') . $completed_count),
88
+			'trialling'  => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'trialling', 'paged' => FALSE)), $current === 'trialling' ? ' class="current"' : '', __('Trialling', 'invoicing') . $trialling_count),
89
+			'cancelled' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'cancelled', 'paged' => FALSE)), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'invoicing') . $cancelled_count),
90
+			'failing'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'failing', 'paged' => FALSE)), $current === 'failing' ? ' class="current"' : '', __('Failing', 'invoicing') . $failing_count),
91 91
 		);
92 92
 
93
-		return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
93
+		return apply_filters('wpinv_recurring_subscriptions_table_views', $views);
94 94
 	}
95 95
 
96 96
 	/**
@@ -104,27 +104,27 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return void
106 106
 	 */
107
-	public function search_box( $text, $input_id ) {
107
+	public function search_box($text, $input_id) {
108 108
 
109
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
109
+		if (empty($_REQUEST['s']) && !$this->has_items()) {
110 110
 			return;
111 111
 		}
112 112
 
113 113
 		$input_id = $input_id . '-search-input';
114 114
 
115
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
116
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
115
+		if (!empty($_REQUEST['orderby'])) {
116
+			echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
117 117
 		}
118 118
 
119
-		if ( ! empty( $_REQUEST['order'] ) ) {
120
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
119
+		if (!empty($_REQUEST['order'])) {
120
+			echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />';
121 121
 		}
122 122
 ?>
123 123
 		<p class="search-box">
124
-			<?php do_action( 'wpinv_recurring_subscription_search_box' ); ?>
124
+			<?php do_action('wpinv_recurring_subscription_search_box'); ?>
125 125
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
126 126
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
127
-			<?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/>
127
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/>
128 128
 		</p>
129 129
 <?php
130 130
 	}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @since       1.0.0
137 137
 	 * @return      string
138 138
 	 */
139
-	function column_default( $item, $column_name ) {
139
+	function column_default($item, $column_name) {
140 140
 		return $item->$column_name;
141 141
 	}
142 142
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      * @since       1.0.0
148 148
      * @return      string
149 149
      */
150
-    function column_sub_id( $item ) {
151
-        return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>';
150
+    function column_sub_id($item) {
151
+        return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" target="_blank">' . $item->id . '</a>';
152 152
     }
153 153
 
154 154
 	/**
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	function column_customer_id( $item ) {
162
-		$subscriber = get_userdata( $item->customer_id );
163
-		$customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
161
+	function column_customer_id($item) {
162
+		$subscriber = get_userdata($item->customer_id);
163
+		$customer   = !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email;
164 164
 
165
-		return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
165
+		return '<a href="' . esc_url(get_edit_user_link($item->customer_id)) . '" target="_blank">' . $customer . '</a>';
166 166
 	}
167 167
 
168 168
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @since       1.0.0
173 173
 	 * @return      string
174 174
 	 */
175
-	function column_status( $item ) {
175
+	function column_status($item) {
176 176
 		return $item->get_status_label();
177 177
 	}
178 178
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @since       1.0.0
184 184
 	 * @return      string
185 185
 	 */
186
-	function column_period( $item ) {
186
+	function column_period($item) {
187 187
 
188
-		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
188
+		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->period, $item->frequency);
189 189
 
190
-		return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
190
+		return wpinv_price(wpinv_format_amount($item->recurring_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)) . ' / ' . $period;
191 191
 	}
192 192
 
193 193
 	/**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @since       1.0.0
198 198
 	 * @return      string
199 199
 	 */
200
-	function column_bill_times( $item ) {
201
-		return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times );
200
+	function column_bill_times($item) {
201
+		return $item->get_times_billed() . ' / ' . (($item->bill_times == 0) ? 'Until Cancelled' : $item->bill_times);
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @since       1.0.0
209 209
 	 * @return      string
210 210
 	 */
211
-	function column_initial_amount( $item ) {
212
-		return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
211
+	function column_initial_amount($item) {
212
+		return wpinv_price(wpinv_format_amount($item->initial_amount), wpinv_get_invoice_currency_code($item->parent_payment_id));
213 213
 	}
214 214
 
215 215
 	/**
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 * @since       1.0.0
220 220
 	 * @return      string
221 221
 	 */
222
-	function column_renewal_date( $item ) {
223
-		return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
222
+	function column_renewal_date($item) {
223
+		return $renewal_date = !empty($item->expiration) ? date_i18n(get_option('date_format'), strtotime($item->expiration)) : __('N/A', 'invoicing');
224 224
 	}
225 225
 
226 226
 	/**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @since       1.0.0
231 231
 	 * @return      string
232 232
 	 */
233
-	function column_parent_payment_id( $item ) {
234
-		return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
233
+	function column_parent_payment_id($item) {
234
+		return '<a href="' . get_edit_post_link($item->parent_payment_id) . '" target="_blank">' . wpinv_get_invoice_number($item->parent_payment_id) . '</a>';
235 235
 	}
236 236
 
237 237
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * @since       1.0.0
242 242
 	 * @return      string
243 243
 	 */
244
-	function column_product_id( $item ) {
245
-		return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
244
+	function column_product_id($item) {
245
+		return '<a href="' . esc_url(admin_url('post.php?action=edit&post=' . $item->product_id)) . '" target="_blank">' . get_the_title($item->product_id) . '</a>';
246 246
 	}
247 247
 
248 248
 	/**
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @since       2.0
253 253
 	 * @return      string
254 254
 	 */
255
-	function column_actions( $item ) {
256
-		return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
255
+	function column_actions($item) {
256
+		return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" title="' . esc_attr(__('View or edit subscription', 'invoicing')) . '" target="_blank">' . __('View', 'invoicing') . '</a>';
257 257
 	}
258 258
 
259 259
 
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @return      array
266 266
 	 */
267 267
 
268
-	function get_columns(){
268
+	function get_columns() {
269 269
 		$columns = array(
270
-			'sub_id'            => __( 'ID', 'invoicing' ),
271
-			'customer_id'       => __( 'Customer', 'invoicing' ),
272
-			'status'            => __( 'Status', 'invoicing' ),
273
-			'period'            => __( 'Billing Cycle', 'invoicing' ),
274
-			'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
-			'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
-			'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
-			'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
-			'product_id'        => __( 'Item', 'invoicing' ),
279
-			'actions'           => __( 'Actions', 'invoicing' ),
270
+			'sub_id'            => __('ID', 'invoicing'),
271
+			'customer_id'       => __('Customer', 'invoicing'),
272
+			'status'            => __('Status', 'invoicing'),
273
+			'period'            => __('Billing Cycle', 'invoicing'),
274
+			'initial_amount'    => __('Initial Amount', 'invoicing'),
275
+			'bill_times'        => __('Times Billed', 'invoicing'),
276
+			'renewal_date'      => __('Renewal Date', 'invoicing'),
277
+			'parent_payment_id' => __('Invoice', 'invoicing'),
278
+			'product_id'        => __('Item', 'invoicing'),
279
+			'actions'           => __('Actions', 'invoicing'),
280 280
 		);
281 281
 
282
-		return apply_filters( 'wpinv_report_subscription_columns', $columns );
282
+		return apply_filters('wpinv_report_subscription_columns', $columns);
283 283
 	}
284 284
 
285 285
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return      int
291 291
 	 */
292 292
 	function get_paged() {
293
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
293
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
294 294
 	}
295 295
 
296 296
 	/**
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 		$db = new WPInv_Subscriptions_DB;
308 308
 
309
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
309
+		$search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
310 310
 
311 311
 		$this->total_count     = $db->count();
312
-		$this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
-		$this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
-		$this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
-		$this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
-		$this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
-		$this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
-		$this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
312
+		$this->active_count    = $db->count(array('status' => 'active', 'search' => $search));
313
+		$this->pending_count   = $db->count(array('status' => 'pending', 'search' => $search));
314
+		$this->expired_count   = $db->count(array('status' => 'expired', 'search' => $search));
315
+		$this->trialling_count = $db->count(array('status' => 'trialling', 'search' => $search));
316
+		$this->cancelled_count = $db->count(array('status' => 'cancelled', 'search' => $search));
317
+		$this->completed_count = $db->count(array('status' => 'completed', 'search' => $search));
318
+		$this->failing_count   = $db->count(array('status' => 'failing', 'search' => $search));
319 319
 
320 320
 	}
321 321
 
@@ -336,28 +336,28 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$columns  = $this->get_columns();
338 338
 		$hidden   = array(); // No hidden columns
339
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
339
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
340 340
 		$sortable = $this->get_sortable_columns();
341 341
 
342
-		$this->_column_headers = array( $columns, $hidden, $sortable );
342
+		$this->_column_headers = array($columns, $hidden, $sortable);
343 343
 
344 344
 		$current_page = $this->get_pagenum();
345 345
 
346 346
 		$db     = new WPInv_Subscriptions_DB;
347
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
347
+		$search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
348 348
 		$args   = array(
349 349
 			'number' => $this->per_page,
350
-			'offset' => $this->per_page * ( $this->get_paged() - 1 ),
350
+			'offset' => $this->per_page * ($this->get_paged() - 1),
351 351
 			'search' => $search
352 352
 		);
353 353
 
354
-		if ( 'any' !== $status ) {
354
+		if ('any' !== $status) {
355 355
 			$args['status'] = $status;
356 356
 		}
357 357
 
358
-		$this->items = $db->get_subscriptions( $args );
358
+		$this->items = $db->get_subscriptions($args);
359 359
 
360
-		switch ( $status ) {
360
+		switch ($status) {
361 361
 			case 'active':
362 362
 				$total_items = $this->active_count;
363 363
 				break;
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 				break;
386 386
 		}
387 387
 
388
-		$this->set_pagination_args( array(
388
+		$this->set_pagination_args(array(
389 389
 			'total_items' => $total_items,
390 390
 			'per_page'    => $this->per_page,
391
-			'total_pages' => ceil( $total_items / $this->per_page )
392
-		) );
391
+			'total_pages' => ceil($total_items / $this->per_page)
392
+		));
393 393
 	}
394 394
 }
Please login to merge, or discard this patch.