Passed
Push — master ( e8d755...0d1e0e )
by Brian
05:32
created
includes/admin/admin-pages.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+        $anchor = __( 'Deactivate', 'invoicing' );
61
+        $title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64 64
     } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+        $anchor = __( 'Activate', 'invoicing' );
77
+        $title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+    $anchor = __( 'Delete', 'invoicing' );
95
+    $title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98 98
     $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
     
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
     
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
         check_ajax_referer( 'getpaid_form_nonce' );
260 260
 
261 261
         // Is the request set up correctly?
262
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
263
-			echo aui()->alert(
264
-				array(
265
-					'type'    => 'warning',
266
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
267
-				)
262
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
263
+            echo aui()->alert(
264
+                array(
265
+                    'type'    => 'warning',
266
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
267
+                )
268 268
             );
269 269
             exit;
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
273
+        if ( ! empty( $_GET['form'] ) ) {
274 274
             getpaid_display_payment_form( urldecode( $_GET['form'] ) );
275
-		} else if( ! empty( $_GET['invoice'] ) ) {
276
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
275
+        } else if( ! empty( $_GET['invoice'] ) ) {
276
+            getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
277 277
         } else {
278
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
-		    getpaid_display_item_payment_form( $items );
278
+            $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
+            getpaid_display_item_payment_form( $items );
280 280
         }
281 281
 
282 282
         exit;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         if ( is_wp_error( $error ) ) {
598 598
             $alert = $error->get_error_message();
599 599
             wp_send_json_success( compact( 'alert' ) );
600
-         }
600
+            }
601 601
 
602 602
         // Update totals.
603 603
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
     }
320 320
 
321 321
     /**
322
-	 * Output the metabox.
323
-	 *
324
-	 * @param WP_Post $post
325
-	 */
322
+     * Output the metabox.
323
+     *
324
+     * @param WP_Post $post
325
+     */
326 326
     public static function output2( $post ) {
327 327
 
328 328
         // Prepare the invoice.
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/plugin.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
  */
16 16
 
17 17
 if ( ! defined( 'ABSPATH' ) ) {
18
-	exit;
18
+    exit;
19 19
 }
20 20
 
21 21
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
22
-	// include the class if needed
23
-	include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" );
22
+    // include the class if needed
23
+    include_once( dirname( __FILE__ ) . "/wp-deactivation-survey.php" );
24 24
 }
25 25
 
26 26
 
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
 //});
37 37
 
38 38
 AyeCode_Deactivation_Survey::instance(array(
39
-	'slug'		=> 'ayecode-deactivation-survey-testing',
40
-	'version'	=> '1.0.0'
39
+    'slug'		=> 'ayecode-deactivation-survey-testing',
40
+    'version'	=> '1.0.0'
41 41
 ));
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,102 +1,102 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.3";
22
+        public $version = "1.0.3";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
82
-				'found-better-plugin'		=> 'I found a better plugin',
83
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
84
-				'other'						=> 'Other',
85
-			);
86
-
87
-			foreach($plugins as $plugin)
88
-			{
89
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
90
-				$plugin->url = home_url();
91
-				$plugin->activated = 0;
92
-			}
93
-
94
-			// Send plugin data
95
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
-
97
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
82
+                'found-better-plugin'		=> 'I found a better plugin',
83
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
84
+                'other'						=> 'Other',
85
+            );
86
+
87
+            foreach($plugins as $plugin)
88
+            {
89
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
90
+                $plugin->url = home_url();
91
+                $plugin->activated = 0;
92
+            }
93
+
94
+            // Send plugin data
95
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
96
+
97
+        }
98 98
 		
99 99
 
100
-	}
100
+    }
101 101
 
102 102
 }
103 103
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class InstalledVersions
13 13
 {
14 14
 private static $installed = array (
15
-  'root' => 
16
-  array (
15
+    'root' => 
16
+    array (
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
@@ -21,96 +21,96 @@  discard block
 block discarded – undo
21 21
     ),
22 22
     'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
23 23
     'name' => 'ayecode/invoicing',
24
-  ),
25
-  'versions' => 
26
-  array (
24
+    ),
25
+    'versions' => 
26
+    array (
27 27
     'ayecode/ayecode-connect-helper' => 
28 28
     array (
29
-      'pretty_version' => '1.0.3',
30
-      'version' => '1.0.3.0',
31
-      'aliases' => 
32
-      array (
33
-      ),
34
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
29
+        'pretty_version' => '1.0.3',
30
+        'version' => '1.0.3.0',
31
+        'aliases' => 
32
+        array (
33
+        ),
34
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37 37
     array (
38
-      'pretty_version' => 'dev-master',
39
-      'version' => 'dev-master',
40
-      'aliases' => 
41
-      array (
42
-      ),
43
-      'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.51',
48
-      'version' => '0.1.51.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'bcd4413ac3cc6513b852aabbe74f940a7dee0814',
47
+        'pretty_version' => '0.1.51',
48
+        'version' => '0.1.51.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'bcd4413ac3cc6513b852aabbe74f940a7dee0814',
53 53
     ),
54 54
     'ayecode/wp-deactivation-survey' => 
55 55
     array (
56
-      'pretty_version' => '1.0.3',
57
-      'version' => '1.0.3.0',
58
-      'aliases' => 
59
-      array (
60
-      ),
61
-      'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667',
56
+        'pretty_version' => '1.0.3',
57
+        'version' => '1.0.3.0',
58
+        'aliases' => 
59
+        array (
60
+        ),
61
+        'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667',
62 62
     ),
63 63
     'ayecode/wp-font-awesome-settings' => 
64 64
     array (
65
-      'pretty_version' => '1.0.12',
66
-      'version' => '1.0.12.0',
67
-      'aliases' => 
68
-      array (
69
-      ),
70
-      'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
65
+        'pretty_version' => '1.0.12',
66
+        'version' => '1.0.12.0',
67
+        'aliases' => 
68
+        array (
69
+        ),
70
+        'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
71 71
     ),
72 72
     'ayecode/wp-super-duper' => 
73 73
     array (
74
-      'pretty_version' => '1.0.26',
75
-      'version' => '1.0.26.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131',
74
+        'pretty_version' => '1.0.26',
75
+        'version' => '1.0.26.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131',
80 80
     ),
81 81
     'composer/installers' => 
82 82
     array (
83
-      'pretty_version' => 'v1.11.0',
84
-      'version' => '1.11.0.0',
85
-      'aliases' => 
86
-      array (
87
-      ),
88
-      'reference' => 'ae03311f45dfe194412081526be2e003960df74b',
83
+        'pretty_version' => 'v1.11.0',
84
+        'version' => '1.11.0.0',
85
+        'aliases' => 
86
+        array (
87
+        ),
88
+        'reference' => 'ae03311f45dfe194412081526be2e003960df74b',
89 89
     ),
90 90
     'maxmind-db/reader' => 
91 91
     array (
92
-      'pretty_version' => 'v1.6.0',
93
-      'version' => '1.6.0.0',
94
-      'aliases' => 
95
-      array (
96
-      ),
97
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
92
+        'pretty_version' => 'v1.6.0',
93
+        'version' => '1.6.0.0',
94
+        'aliases' => 
95
+        array (
96
+        ),
97
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
98 98
     ),
99 99
     'roundcube/plugin-installer' => 
100 100
     array (
101
-      'replaced' => 
102
-      array (
101
+        'replaced' => 
102
+        array (
103 103
         0 => '*',
104
-      ),
104
+        ),
105 105
     ),
106 106
     'shama/baton' => 
107 107
     array (
108
-      'replaced' => 
109
-      array (
108
+        'replaced' => 
109
+        array (
110 110
         0 => '*',
111
-      ),
111
+        ),
112
+    ),
112 113
     ),
113
-  ),
114 114
 );
115 115
 
116 116
 
Please login to merge, or discard this patch.
vendor/composer/installed.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php return array (
2
-  'root' => 
3
-  array (
2
+    'root' => 
3
+    array (
4 4
     'pretty_version' => 'dev-master',
5 5
     'version' => 'dev-master',
6 6
     'aliases' => 
@@ -8,94 +8,94 @@  discard block
 block discarded – undo
8 8
     ),
9 9
     'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
10 10
     'name' => 'ayecode/invoicing',
11
-  ),
12
-  'versions' => 
13
-  array (
11
+    ),
12
+    'versions' => 
13
+    array (
14 14
     'ayecode/ayecode-connect-helper' => 
15 15
     array (
16
-      'pretty_version' => '1.0.3',
17
-      'version' => '1.0.3.0',
18
-      'aliases' => 
19
-      array (
20
-      ),
21
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
16
+        'pretty_version' => '1.0.3',
17
+        'version' => '1.0.3.0',
18
+        'aliases' => 
19
+        array (
20
+        ),
21
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
22 22
     ),
23 23
     'ayecode/invoicing' => 
24 24
     array (
25
-      'pretty_version' => 'dev-master',
26
-      'version' => 'dev-master',
27
-      'aliases' => 
28
-      array (
29
-      ),
30
-      'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
25
+        'pretty_version' => 'dev-master',
26
+        'version' => 'dev-master',
27
+        'aliases' => 
28
+        array (
29
+        ),
30
+        'reference' => '63ce670a999b41e694ef7c693194e6a76bcb2048',
31 31
     ),
32 32
     'ayecode/wp-ayecode-ui' => 
33 33
     array (
34
-      'pretty_version' => '0.1.51',
35
-      'version' => '0.1.51.0',
36
-      'aliases' => 
37
-      array (
38
-      ),
39
-      'reference' => 'bcd4413ac3cc6513b852aabbe74f940a7dee0814',
34
+        'pretty_version' => '0.1.51',
35
+        'version' => '0.1.51.0',
36
+        'aliases' => 
37
+        array (
38
+        ),
39
+        'reference' => 'bcd4413ac3cc6513b852aabbe74f940a7dee0814',
40 40
     ),
41 41
     'ayecode/wp-deactivation-survey' => 
42 42
     array (
43
-      'pretty_version' => '1.0.3',
44
-      'version' => '1.0.3.0',
45
-      'aliases' => 
46
-      array (
47
-      ),
48
-      'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667',
43
+        'pretty_version' => '1.0.3',
44
+        'version' => '1.0.3.0',
45
+        'aliases' => 
46
+        array (
47
+        ),
48
+        'reference' => 'c4b0ba914835f17dca0cf69fe621c2db491d4667',
49 49
     ),
50 50
     'ayecode/wp-font-awesome-settings' => 
51 51
     array (
52
-      'pretty_version' => '1.0.12',
53
-      'version' => '1.0.12.0',
54
-      'aliases' => 
55
-      array (
56
-      ),
57
-      'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
52
+        'pretty_version' => '1.0.12',
53
+        'version' => '1.0.12.0',
54
+        'aliases' => 
55
+        array (
56
+        ),
57
+        'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288',
58 58
     ),
59 59
     'ayecode/wp-super-duper' => 
60 60
     array (
61
-      'pretty_version' => '1.0.26',
62
-      'version' => '1.0.26.0',
63
-      'aliases' => 
64
-      array (
65
-      ),
66
-      'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131',
61
+        'pretty_version' => '1.0.26',
62
+        'version' => '1.0.26.0',
63
+        'aliases' => 
64
+        array (
65
+        ),
66
+        'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131',
67 67
     ),
68 68
     'composer/installers' => 
69 69
     array (
70
-      'pretty_version' => 'v1.11.0',
71
-      'version' => '1.11.0.0',
72
-      'aliases' => 
73
-      array (
74
-      ),
75
-      'reference' => 'ae03311f45dfe194412081526be2e003960df74b',
70
+        'pretty_version' => 'v1.11.0',
71
+        'version' => '1.11.0.0',
72
+        'aliases' => 
73
+        array (
74
+        ),
75
+        'reference' => 'ae03311f45dfe194412081526be2e003960df74b',
76 76
     ),
77 77
     'maxmind-db/reader' => 
78 78
     array (
79
-      'pretty_version' => 'v1.6.0',
80
-      'version' => '1.6.0.0',
81
-      'aliases' => 
82
-      array (
83
-      ),
84
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
79
+        'pretty_version' => 'v1.6.0',
80
+        'version' => '1.6.0.0',
81
+        'aliases' => 
82
+        array (
83
+        ),
84
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
85 85
     ),
86 86
     'roundcube/plugin-installer' => 
87 87
     array (
88
-      'replaced' => 
89
-      array (
88
+        'replaced' => 
89
+        array (
90 90
         0 => '*',
91
-      ),
91
+        ),
92 92
     ),
93 93
     'shama/baton' => 
94 94
     array (
95
-      'replaced' => 
96
-      array (
95
+        'replaced' => 
96
+        array (
97 97
         0 => '*',
98
-      ),
98
+        ),
99
+    ),
99 100
     ),
100
-  ),
101 101
 );
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 1 patch
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -20,228 +20,228 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	/**
24
-	 * Upgrades the install.
25
-	 *
26
-	 * @param string $upgrade_from The current invoicing version.
27
-	 */
28
-	public function upgrade_db( $upgrade_from ) {
29
-
30
-		// Save the current invoicing version.
31
-		update_option( 'wpinv_version', WPINV_VERSION );
32
-
33
-		// Setup the invoice Custom Post Type.
34
-		GetPaid_Post_Types::register_post_types();
35
-
36
-		// Clear the permalinks
37
-		flush_rewrite_rules();
38
-
39
-		// Maybe create new/missing pages.
40
-		$this->create_pages();
41
-
42
-		// Maybe re(add) admin capabilities.
43
-		$this->add_capabilities();
44
-
45
-		// Maybe create the default payment form.
46
-		wpinv_get_default_payment_form();
47
-
48
-		// Create any missing database tables.
49
-		$method = "upgrade_from_$upgrade_from";
50
-
51
-		$installed = get_option( 'gepaid_installed_on' );
52
-
53
-		if ( empty( $installed ) ) {
54
-			update_option( 'gepaid_installed_on', time() );
55
-		}
56
-
57
-		if ( method_exists( $this, $method ) ) {
58
-			$this->$method();
59
-		}
60
-
61
-	}
62
-
63
-	/**
64
-	 * Do a fresh install.
65
-	 *
66
-	 */
67
-	public function upgrade_from_0() {
68
-		$this->create_subscriptions_table();
69
-		$this->create_invoices_table();
70
-		$this->create_invoice_items_table();
71
-
72
-		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
-	}
75
-
76
-	/**
77
-	 * Upgrade to 0.0.5
78
-	 *
79
-	 */
80
-	public function upgrade_from_004() {
81
-		global $wpdb;
82
-
83
-		// Invoices.
84
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
-
88
-			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
91
-			}
92
-
93
-		}
94
-
95
-		// Item meta key changes
96
-		$query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
97
-		$results = $wpdb->get_results( $query );
98
-
99
-		if ( ! empty( $results ) ) {
100
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
101
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
102
-			$wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
103
-
104
-			foreach ( $results as $row ) {
105
-				clean_post_cache( $row->post_id );
106
-			}
107
-
108
-		}
109
-
110
-		$this->upgrade_from_102();
111
-	}
112
-
113
-	/**
114
-	 * Upgrade to 1.0.3
115
-	 *
116
-	 */
117
-	public function upgrade_from_102() {
118
-		$this->create_subscriptions_table();
119
-		$this->upgrade_from_118();
120
-	}
121
-
122
-	/**
123
-	 * Upgrade to version 2.0.0.
124
-	 *
125
-	 */
126
-	public function upgrade_from_118() {
127
-		$this->create_invoices_table();
128
-		$this->create_invoice_items_table();
129
-		$this->migrate_old_invoices();
130
-	}
131
-
132
-	/**
133
-	 * Upgrade to version 2.0.8.
134
-	 *
135
-	 */
136
-	public function upgrade_from_207() {
137
-		global $wpdb;
138
-		$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
139
-	}
140
-
141
-	/**
142
-	 * Give administrators the capability to manage GetPaid.
143
-	 *
144
-	 */
145
-	public function add_capabilities() {
146
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
147
-	}
148
-
149
-	/**
150
-	 * Retreives GetPaid pages.
151
-	 *
152
-	 */
153
-	public static function get_pages() {
154
-
155
-		return apply_filters(
156
-			'wpinv_create_pages',
157
-			array(
158
-
159
-				// Checkout page.
160
-				'checkout_page' => array(
161
-					'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
162
-					'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
163
-					'content'   => '
23
+    /**
24
+     * Upgrades the install.
25
+     *
26
+     * @param string $upgrade_from The current invoicing version.
27
+     */
28
+    public function upgrade_db( $upgrade_from ) {
29
+
30
+        // Save the current invoicing version.
31
+        update_option( 'wpinv_version', WPINV_VERSION );
32
+
33
+        // Setup the invoice Custom Post Type.
34
+        GetPaid_Post_Types::register_post_types();
35
+
36
+        // Clear the permalinks
37
+        flush_rewrite_rules();
38
+
39
+        // Maybe create new/missing pages.
40
+        $this->create_pages();
41
+
42
+        // Maybe re(add) admin capabilities.
43
+        $this->add_capabilities();
44
+
45
+        // Maybe create the default payment form.
46
+        wpinv_get_default_payment_form();
47
+
48
+        // Create any missing database tables.
49
+        $method = "upgrade_from_$upgrade_from";
50
+
51
+        $installed = get_option( 'gepaid_installed_on' );
52
+
53
+        if ( empty( $installed ) ) {
54
+            update_option( 'gepaid_installed_on', time() );
55
+        }
56
+
57
+        if ( method_exists( $this, $method ) ) {
58
+            $this->$method();
59
+        }
60
+
61
+    }
62
+
63
+    /**
64
+     * Do a fresh install.
65
+     *
66
+     */
67
+    public function upgrade_from_0() {
68
+        $this->create_subscriptions_table();
69
+        $this->create_invoices_table();
70
+        $this->create_invoice_items_table();
71
+
72
+        // Save default tax rates.
73
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
+    }
75
+
76
+    /**
77
+     * Upgrade to 0.0.5
78
+     *
79
+     */
80
+    public function upgrade_from_004() {
81
+        global $wpdb;
82
+
83
+        // Invoices.
84
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
+        if ( ! empty( $results ) ) {
86
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
+
88
+            // Clean post cache
89
+            foreach ( $results as $row ) {
90
+                clean_post_cache( $row->ID );
91
+            }
92
+
93
+        }
94
+
95
+        // Item meta key changes
96
+        $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
97
+        $results = $wpdb->get_results( $query );
98
+
99
+        if ( ! empty( $results ) ) {
100
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
101
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
102
+            $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
103
+
104
+            foreach ( $results as $row ) {
105
+                clean_post_cache( $row->post_id );
106
+            }
107
+
108
+        }
109
+
110
+        $this->upgrade_from_102();
111
+    }
112
+
113
+    /**
114
+     * Upgrade to 1.0.3
115
+     *
116
+     */
117
+    public function upgrade_from_102() {
118
+        $this->create_subscriptions_table();
119
+        $this->upgrade_from_118();
120
+    }
121
+
122
+    /**
123
+     * Upgrade to version 2.0.0.
124
+     *
125
+     */
126
+    public function upgrade_from_118() {
127
+        $this->create_invoices_table();
128
+        $this->create_invoice_items_table();
129
+        $this->migrate_old_invoices();
130
+    }
131
+
132
+    /**
133
+     * Upgrade to version 2.0.8.
134
+     *
135
+     */
136
+    public function upgrade_from_207() {
137
+        global $wpdb;
138
+        $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoice_items MODIFY COLUMN quantity FLOAT(20);" );
139
+    }
140
+
141
+    /**
142
+     * Give administrators the capability to manage GetPaid.
143
+     *
144
+     */
145
+    public function add_capabilities() {
146
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
147
+    }
148
+
149
+    /**
150
+     * Retreives GetPaid pages.
151
+     *
152
+     */
153
+    public static function get_pages() {
154
+
155
+        return apply_filters(
156
+            'wpinv_create_pages',
157
+            array(
158
+
159
+                // Checkout page.
160
+                'checkout_page' => array(
161
+                    'name'      => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
162
+                    'title'     => _x( 'Checkout', 'Page title', 'invoicing' ),
163
+                    'content'   => '
164 164
 						<!-- wp:shortcode -->
165 165
 						[wpinv_checkout]
166 166
 						<!-- /wp:shortcode -->
167 167
 					',
168
-					'parent'    => '',
169
-				),
170
-
171
-				// Invoice history page.
172
-				'invoice_history_page' => array(
173
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
174
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
175
-					'content' => '
168
+                    'parent'    => '',
169
+                ),
170
+
171
+                // Invoice history page.
172
+                'invoice_history_page' => array(
173
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
174
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
175
+                    'content' => '
176 176
 					<!-- wp:shortcode -->
177 177
 					[wpinv_history]
178 178
 					<!-- /wp:shortcode -->
179 179
 				',
180
-					'parent'  => '',
181
-				),
182
-
183
-				// Success page content.
184
-				'success_page' => array(
185
-					'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
186
-					'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
187
-					'content'  => '
180
+                    'parent'  => '',
181
+                ),
182
+
183
+                // Success page content.
184
+                'success_page' => array(
185
+                    'name'     => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
186
+                    'title'    => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
187
+                    'content'  => '
188 188
 					<!-- wp:shortcode -->
189 189
 					[wpinv_receipt]
190 190
 					<!-- /wp:shortcode -->
191 191
 				',
192
-					'parent'   => 'gp-checkout',
193
-				),
194
-
195
-				// Failure page content.
196
-				'failure_page' => array(
197
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
198
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
199
-					'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
200
-					'parent'  => 'gp-checkout',
201
-				),
202
-
203
-				// Subscriptions history page.
204
-				'invoice_subscription_page' => array(
205
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
206
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
207
-					'content' => '
192
+                    'parent'   => 'gp-checkout',
193
+                ),
194
+
195
+                // Failure page content.
196
+                'failure_page' => array(
197
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
198
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
199
+                    'content' => __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ),
200
+                    'parent'  => 'gp-checkout',
201
+                ),
202
+
203
+                // Subscriptions history page.
204
+                'invoice_subscription_page' => array(
205
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
206
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
207
+                    'content' => '
208 208
 					<!-- wp:shortcode -->
209 209
 					[wpinv_subscriptions]
210 210
 					<!-- /wp:shortcode -->
211 211
 				',
212
-					'parent' => '',
213
-				),
212
+                    'parent' => '',
213
+                ),
214 214
 
215
-			)
216
-		);
215
+            )
216
+        );
217 217
 
218
-	}
218
+    }
219 219
 
220
-	/**
221
-	 * Re-create GetPaid pages.
222
-	 *
223
-	 */
224
-	public function create_pages() {
220
+    /**
221
+     * Re-create GetPaid pages.
222
+     *
223
+     */
224
+    public function create_pages() {
225 225
 
226
-		foreach ( self::get_pages() as $key => $page ) {
227
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
228
-		}
226
+        foreach ( self::get_pages() as $key => $page ) {
227
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
228
+        }
229 229
 
230
-	}
230
+    }
231 231
 
232
-	/**
233
-	 * Create subscriptions table.
234
-	 *
235
-	 */
236
-	public function create_subscriptions_table() {
232
+    /**
233
+     * Create subscriptions table.
234
+     *
235
+     */
236
+    public function create_subscriptions_table() {
237 237
 
238
-		global $wpdb;
238
+        global $wpdb;
239 239
 
240
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
240
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
241 241
 
242
-		// Create tables.
243
-		$charset_collate = $wpdb->get_charset_collate();
244
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
242
+        // Create tables.
243
+        $charset_collate = $wpdb->get_charset_collate();
244
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wpinv_subscriptions (
245 245
 			id bigint(20) unsigned NOT NULL auto_increment,
246 246
 			customer_id bigint(20) NOT NULL,
247 247
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -264,22 +264,22 @@  discard block
 block discarded – undo
264 264
 			KEY customer_and_status (customer_id, status)
265 265
 		  ) $charset_collate;";
266 266
 
267
-		dbDelta( $sql );
267
+        dbDelta( $sql );
268 268
 
269
-	}
269
+    }
270 270
 
271
-	/**
272
-	 * Create invoices table.
273
-	 *
274
-	 */
275
-	public function create_invoices_table() {
276
-		global $wpdb;
271
+    /**
272
+     * Create invoices table.
273
+     *
274
+     */
275
+    public function create_invoices_table() {
276
+        global $wpdb;
277 277
 
278
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
278
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
279 279
 
280
-		// Create tables.
281
-		$charset_collate = $wpdb->get_charset_collate();
282
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
280
+        // Create tables.
281
+        $charset_collate = $wpdb->get_charset_collate();
282
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoices (
283 283
 			post_id BIGINT(20) NOT NULL,
284 284
             `number` VARCHAR(100),
285 285
             `key` VARCHAR(100),
@@ -315,22 +315,22 @@  discard block
 block discarded – undo
315 315
 			KEY `key` (`key`)
316 316
 		  ) $charset_collate;";
317 317
 
318
-		dbDelta( $sql );
318
+        dbDelta( $sql );
319 319
 
320
-	}
320
+    }
321 321
 
322
-	/**
323
-	 * Create invoice items table.
324
-	 *
325
-	 */
326
-	public function create_invoice_items_table() {
327
-		global $wpdb;
322
+    /**
323
+     * Create invoice items table.
324
+     *
325
+     */
326
+    public function create_invoice_items_table() {
327
+        global $wpdb;
328 328
 
329
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
329
+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
330 330
 
331
-		// Create tables.
332
-		$charset_collate = $wpdb->get_charset_collate();
333
-		$sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
331
+        // Create tables.
332
+        $charset_collate = $wpdb->get_charset_collate();
333
+        $sql             = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}getpaid_invoice_items (
334 334
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
335 335
             post_id BIGINT(20) NOT NULL,
336 336
             item_id BIGINT(20) NOT NULL,
@@ -352,159 +352,159 @@  discard block
 block discarded – undo
352 352
 			KEY post_id (post_id)
353 353
 		  ) $charset_collate;";
354 354
 
355
-		dbDelta( $sql );
356
-
357
-	}
358
-
359
-	/**
360
-	 * Migrates old invoices to new invoices.
361
-	 *
362
-	 */
363
-	public function migrate_old_invoices() {
364
-		global $wpdb;
365
-
366
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
367
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
368
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
369
-		$invoices            = array_unique(
370
-			get_posts(
371
-				array(
372
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
373
-					'posts_per_page' => -1,
374
-					'fields'         => 'ids',
375
-					'post_status'    => array_keys( get_post_stati() ),
376
-					'exclude'        => (array) $migrated,
377
-				)
378
-			)
379
-		);
380
-
381
-		// Abort if we do not have any invoices.
382
-		if ( empty( $invoices ) ) {
383
-			return;
384
-		}
385
-
386
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
387
-
388
-		$invoice_rows = array();
389
-		foreach ( $invoices as $invoice ) {
390
-
391
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
392
-
393
-			if ( empty( $invoice->ID ) ) {
394
-				return;
395
-			}
396
-
397
-			$fields = array (
398
-				'post_id'        => $invoice->ID,
399
-				'number'         => $invoice->get_number(),
400
-				'key'            => $invoice->get_key(),
401
-				'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
402
-				'mode'           => $invoice->mode,
403
-				'user_ip'        => $invoice->get_ip(),
404
-				'first_name'     => $invoice->get_first_name(),
405
-				'last_name'      => $invoice->get_last_name(),
406
-				'address'        => $invoice->get_address(),
407
-				'city'           => $invoice->city,
408
-				'state'          => $invoice->state,
409
-				'country'        => $invoice->country,
410
-				'zip'            => $invoice->zip,
411
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
412
-				'gateway'        => $invoice->get_gateway(),
413
-				'transaction_id' => $invoice->get_transaction_id(),
414
-				'currency'       => $invoice->get_currency(),
415
-				'subtotal'       => $invoice->get_subtotal(),
416
-				'tax'            => $invoice->get_tax(),
417
-				'fees_total'     => $invoice->get_fees_total(),
418
-				'total'          => $invoice->get_total(),
419
-				'discount'       => $invoice->get_discount(),
420
-				'discount_code'  => $invoice->get_discount_code(),
421
-				'disable_taxes'  => $invoice->disable_taxes,
422
-				'due_date'       => $invoice->get_due_date(),
423
-				'completed_date' => $invoice->get_completed_date(),
424
-				'company'        => $invoice->company,
425
-				'vat_number'     => $invoice->vat_number,
426
-				'vat_rate'       => $invoice->vat_rate,
427
-				'custom_meta'    => $invoice->payment_meta
428
-			);
429
-
430
-			foreach ( $fields as $key => $val ) {
431
-				if ( is_null( $val ) ) {
432
-					$val = '';
433
-				}
434
-				$val = maybe_serialize( $val );
435
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
436
-			}
437
-
438
-			$fields = implode( ', ', $fields );
439
-			$invoice_rows[] = "($fields)";
440
-
441
-			$item_rows    = array();
442
-			$item_columns = array();
443
-			foreach ( $invoice->get_cart_details() as $details ) {
444
-				$fields = array(
445
-					'post_id'          => $invoice->ID,
446
-					'item_id'          => $details['id'],
447
-					'item_name'        => $details['name'],
448
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
449
-					'vat_rate'         => $details['vat_rate'],
450
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
451
-					'tax'              => $details['tax'],
452
-					'item_price'       => $details['item_price'],
453
-					'custom_price'     => $details['custom_price'],
454
-					'quantity'         => $details['quantity'],
455
-					'discount'         => $details['discount'],
456
-					'subtotal'         => $details['subtotal'],
457
-					'price'            => $details['price'],
458
-					'meta'             => $details['meta'],
459
-					'fees'             => $details['fees'],
460
-				);
461
-
462
-				$item_columns = array_keys ( $fields );
463
-
464
-				foreach ( $fields as $key => $val ) {
465
-					if ( is_null( $val ) ) {
466
-						$val = '';
467
-					}
468
-					$val = maybe_serialize( $val );
469
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
470
-				}
471
-
472
-				$fields = implode( ', ', $fields );
473
-				$item_rows[] = "($fields)";
474
-			}
475
-
476
-			$item_rows    = implode( ', ', $item_rows );
477
-			$item_columns = implode( ', ', $item_columns );
478
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
479
-		}
480
-
481
-		if ( empty( $invoice_rows ) ) {
482
-			return;
483
-		}
484
-
485
-		$invoice_rows = implode( ', ', $invoice_rows );
486
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
487
-
488
-	}
489
-
490
-	/**
491
-	 * Migrates old invoices to new invoices.
492
-	 *
493
-	 */
494
-	public static function rename_gateways_label() {
495
-		global $wpdb;
496
-
497
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
498
-
499
-			$wpdb->update(
500
-				$wpdb->prefix . 'getpaid_invoices',
501
-				array( 'gateway' => $gateway ),
502
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
503
-				'%s',
504
-				'%s'
505
-			);
506
-
507
-		}
508
-	}
355
+        dbDelta( $sql );
356
+
357
+    }
358
+
359
+    /**
360
+     * Migrates old invoices to new invoices.
361
+     *
362
+     */
363
+    public function migrate_old_invoices() {
364
+        global $wpdb;
365
+
366
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
367
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
368
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
369
+        $invoices            = array_unique(
370
+            get_posts(
371
+                array(
372
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
373
+                    'posts_per_page' => -1,
374
+                    'fields'         => 'ids',
375
+                    'post_status'    => array_keys( get_post_stati() ),
376
+                    'exclude'        => (array) $migrated,
377
+                )
378
+            )
379
+        );
380
+
381
+        // Abort if we do not have any invoices.
382
+        if ( empty( $invoices ) ) {
383
+            return;
384
+        }
385
+
386
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
387
+
388
+        $invoice_rows = array();
389
+        foreach ( $invoices as $invoice ) {
390
+
391
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
392
+
393
+            if ( empty( $invoice->ID ) ) {
394
+                return;
395
+            }
396
+
397
+            $fields = array (
398
+                'post_id'        => $invoice->ID,
399
+                'number'         => $invoice->get_number(),
400
+                'key'            => $invoice->get_key(),
401
+                'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
402
+                'mode'           => $invoice->mode,
403
+                'user_ip'        => $invoice->get_ip(),
404
+                'first_name'     => $invoice->get_first_name(),
405
+                'last_name'      => $invoice->get_last_name(),
406
+                'address'        => $invoice->get_address(),
407
+                'city'           => $invoice->city,
408
+                'state'          => $invoice->state,
409
+                'country'        => $invoice->country,
410
+                'zip'            => $invoice->zip,
411
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
412
+                'gateway'        => $invoice->get_gateway(),
413
+                'transaction_id' => $invoice->get_transaction_id(),
414
+                'currency'       => $invoice->get_currency(),
415
+                'subtotal'       => $invoice->get_subtotal(),
416
+                'tax'            => $invoice->get_tax(),
417
+                'fees_total'     => $invoice->get_fees_total(),
418
+                'total'          => $invoice->get_total(),
419
+                'discount'       => $invoice->get_discount(),
420
+                'discount_code'  => $invoice->get_discount_code(),
421
+                'disable_taxes'  => $invoice->disable_taxes,
422
+                'due_date'       => $invoice->get_due_date(),
423
+                'completed_date' => $invoice->get_completed_date(),
424
+                'company'        => $invoice->company,
425
+                'vat_number'     => $invoice->vat_number,
426
+                'vat_rate'       => $invoice->vat_rate,
427
+                'custom_meta'    => $invoice->payment_meta
428
+            );
429
+
430
+            foreach ( $fields as $key => $val ) {
431
+                if ( is_null( $val ) ) {
432
+                    $val = '';
433
+                }
434
+                $val = maybe_serialize( $val );
435
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
436
+            }
437
+
438
+            $fields = implode( ', ', $fields );
439
+            $invoice_rows[] = "($fields)";
440
+
441
+            $item_rows    = array();
442
+            $item_columns = array();
443
+            foreach ( $invoice->get_cart_details() as $details ) {
444
+                $fields = array(
445
+                    'post_id'          => $invoice->ID,
446
+                    'item_id'          => $details['id'],
447
+                    'item_name'        => $details['name'],
448
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
449
+                    'vat_rate'         => $details['vat_rate'],
450
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
451
+                    'tax'              => $details['tax'],
452
+                    'item_price'       => $details['item_price'],
453
+                    'custom_price'     => $details['custom_price'],
454
+                    'quantity'         => $details['quantity'],
455
+                    'discount'         => $details['discount'],
456
+                    'subtotal'         => $details['subtotal'],
457
+                    'price'            => $details['price'],
458
+                    'meta'             => $details['meta'],
459
+                    'fees'             => $details['fees'],
460
+                );
461
+
462
+                $item_columns = array_keys ( $fields );
463
+
464
+                foreach ( $fields as $key => $val ) {
465
+                    if ( is_null( $val ) ) {
466
+                        $val = '';
467
+                    }
468
+                    $val = maybe_serialize( $val );
469
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
470
+                }
471
+
472
+                $fields = implode( ', ', $fields );
473
+                $item_rows[] = "($fields)";
474
+            }
475
+
476
+            $item_rows    = implode( ', ', $item_rows );
477
+            $item_columns = implode( ', ', $item_columns );
478
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
479
+        }
480
+
481
+        if ( empty( $invoice_rows ) ) {
482
+            return;
483
+        }
484
+
485
+        $invoice_rows = implode( ', ', $invoice_rows );
486
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
487
+
488
+    }
489
+
490
+    /**
491
+     * Migrates old invoices to new invoices.
492
+     *
493
+     */
494
+    public static function rename_gateways_label() {
495
+        global $wpdb;
496
+
497
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
498
+
499
+            $wpdb->update(
500
+                $wpdb->prefix . 'getpaid_invoices',
501
+                array( 'gateway' => $gateway ),
502
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
503
+                '%s',
504
+                '%s'
505
+            );
506
+
507
+        }
508
+    }
509 509
 
510 510
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 1 patch
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -12,180 +12,180 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
117
+
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
125
+
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
131
+
132
+        $invoice = $submission->get_invoice();
133 133
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
138 138
 
139
-		return $invoice;
140
-	}
139
+        return $invoice;
140
+    }
141 141
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150 150
 
151
-		$submission = $this->payment_form_submission;
152
-		$data       = $submission->get_data();
151
+        $submission = $this->payment_form_submission;
152
+        $data       = $submission->get_data();
153 153
 
154
-		// Set-up the invoice details.
155
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
-		$invoice->set_user_id( $this->get_submission_customer() );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
154
+        // Set-up the invoice details.
155
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
+        $invoice->set_user_id( $this->get_submission_customer() );
157
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158 158
         $invoice->set_items( $items );
159 159
         $invoice->set_fees( $submission->get_fees() );
160 160
         $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $data['wpi-gateway'] );
161
+        $invoice->set_discounts( $submission->get_discounts() );
162
+        $invoice->set_gateway( $data['wpi-gateway'] );
163 163
 
164
-		$address_confirmed = $submission->get_field( 'confirm-address' );
165
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
164
+        $address_confirmed = $submission->get_field( 'confirm-address' );
165
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
166 166
 
167
-		if ( $submission->has_discount_code() ) {
167
+        if ( $submission->has_discount_code() ) {
168 168
             $invoice->set_discount_code( $submission->get_discount_code() );
169
-		}
170
-
171
-		getpaid_maybe_add_default_address( $invoice );
172
-		return $invoice;
173
-	}
174
-
175
-	/**
176
-	 * Retrieves the submission's customer.
177
-	 *
178
-	 * @return int The customer id.
179
-	 */
180
-	protected function get_submission_customer() {
181
-		$submission = $this->payment_form_submission;
182
-
183
-		// If this is an existing invoice...
184
-		if ( $submission->has_invoice() ) {
185
-			return $submission->get_invoice()->get_user_id();
186
-		}
187
-
188
-		// (Maybe) create the user.
169
+        }
170
+
171
+        getpaid_maybe_add_default_address( $invoice );
172
+        return $invoice;
173
+    }
174
+
175
+    /**
176
+     * Retrieves the submission's customer.
177
+     *
178
+     * @return int The customer id.
179
+     */
180
+    protected function get_submission_customer() {
181
+        $submission = $this->payment_form_submission;
182
+
183
+        // If this is an existing invoice...
184
+        if ( $submission->has_invoice() ) {
185
+            return $submission->get_invoice()->get_user_id();
186
+        }
187
+
188
+        // (Maybe) create the user.
189 189
         $user = get_current_user_id();
190 190
 
191 191
         if ( empty( $user ) ) {
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
         if ( empty( $user ) ) {
196 196
             $user = wpinv_create_user( $submission->get_billing_email() );
197 197
 
198
-			// (Maybe) send new user notification.
199
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
-				wp_send_new_user_notifications( $user, 'user' );
202
-			}
198
+            // (Maybe) send new user notification.
199
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
+                wp_send_new_user_notifications( $user, 'user' );
202
+            }
203 203
 
204 204
         }
205 205
 
@@ -209,34 +209,34 @@  discard block
 block discarded – undo
209 209
 
210 210
         if ( is_numeric( $user ) ) {
211 211
             return $user;
212
-		}
212
+        }
213 213
 
214
-		return $user->ID;
214
+        return $user->ID;
215 215
 
216
-	}
216
+    }
217 217
 
218
-	/**
218
+    /**
219 219
      * Prepares submission data for saving to the database.
220 220
      *
221
-	 * @return array
221
+     * @return array
222 222
      */
223 223
     public function prepare_submission_data_for_saving() {
224 224
 
225
-		$submission = $this->payment_form_submission;
225
+        $submission = $this->payment_form_submission;
226 226
 
227
-		// Prepared submission details.
227
+        // Prepared submission details.
228 228
         $prepared = array(
229
-			'all'  => array(),
230
-			'meta' => array(),
231
-		);
229
+            'all'  => array(),
230
+            'meta' => array(),
231
+        );
232 232
 
233 233
         // Raw submission details.
234
-		$data     = $submission->get_data();
234
+        $data     = $submission->get_data();
235 235
 
236
-		// Loop through the submitted details.
236
+        // Loop through the submitted details.
237 237
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
238 238
 
239
-			// Skip premade fields.
239
+            // Skip premade fields.
240 240
             if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) {
241 241
                 continue;
242 242
             }
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
             // Handle misc fields.
250 250
             if ( isset( $data[ $field['id'] ] ) ) {
251 251
 
252
-				if ( $field['type'] == 'checkbox' ) {
253
-					$value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
254
-				} else {
255
-					$value = wp_kses_post( $data[ $field['id'] ] );
256
-				}
252
+                if ( $field['type'] == 'checkbox' ) {
253
+                    $value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
254
+                } else {
255
+                    $value = wp_kses_post( $data[ $field['id'] ] );
256
+                }
257 257
 
258 258
                 $label = $field['id'];
259 259
 
@@ -261,189 +261,189 @@  discard block
 block discarded – undo
261 261
                     $label = $field['label'];
262 262
                 }
263 263
 
264
-				if ( ! empty( $field['add_meta'] ) ) {
265
-					$prepared['meta'][ wpinv_clean( $label ) ] = $value;
266
-				}
267
-				$prepared['all'][ wpinv_clean( $label ) ] = $value;
264
+                if ( ! empty( $field['add_meta'] ) ) {
265
+                    $prepared['meta'][ wpinv_clean( $label ) ] = $value;
266
+                }
267
+                $prepared['all'][ wpinv_clean( $label ) ] = $value;
268 268
 
269 269
             }
270 270
 
271
-		}
271
+        }
272 272
 
273
-		return $prepared;
273
+        return $prepared;
274 274
 
275
-	}
275
+    }
276 276
 
277
-	/**
277
+    /**
278 278
      * Retrieves address details.
279 279
      *
280
-	 * @return array
281
-	 * @param WPInv_Invoice $invoice
282
-	 * @param string $type
280
+     * @return array
281
+     * @param WPInv_Invoice $invoice
282
+     * @param string $type
283 283
      */
284 284
     public function prepare_address_details( $invoice, $type = 'billing' ) {
285 285
 
286
-		$data     = $this->payment_form_submission->get_data();
287
-		$type     = sanitize_key( $type );
288
-		$address  = array();
289
-		$prepared = array();
286
+        $data     = $this->payment_form_submission->get_data();
287
+        $type     = sanitize_key( $type );
288
+        $address  = array();
289
+        $prepared = array();
290 290
 
291
-		if ( ! empty( $data[ $type ] ) ) {
292
-			$address = $data[ $type ];
293
-		}
291
+        if ( ! empty( $data[ $type ] ) ) {
292
+            $address = $data[ $type ];
293
+        }
294 294
 
295
-		// Clean address details.
296
-		foreach ( $address as $key => $value ) {
297
-			$key             = sanitize_key( $key );
298
-			$key             = str_replace( 'wpinv_', '', $key );
299
-			$value           = wpinv_clean( $value );
300
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
301
-		}
295
+        // Clean address details.
296
+        foreach ( $address as $key => $value ) {
297
+            $key             = sanitize_key( $key );
298
+            $key             = str_replace( 'wpinv_', '', $key );
299
+            $value           = wpinv_clean( $value );
300
+            $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
301
+        }
302 302
 
303
-		// Filter address details.
304
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
303
+        // Filter address details.
304
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
305 305
 
306
-		// Remove non-whitelisted values.
307
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
306
+        // Remove non-whitelisted values.
307
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
308 308
 
309
-	}
309
+    }
310 310
 
311
-	/**
311
+    /**
312 312
      * Prepares the billing details.
313 313
      *
314
-	 * @return array
315
-	 * @param WPInv_Invoice $invoice
314
+     * @return array
315
+     * @param WPInv_Invoice $invoice
316 316
      */
317 317
     protected function prepare_billing_info( &$invoice ) {
318 318
 
319
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
319
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
320 320
 
321
-		// Update the invoice with the billing details.
322
-		$invoice->set_props( $billing_address );
321
+        // Update the invoice with the billing details.
322
+        $invoice->set_props( $billing_address );
323 323
 
324
-	}
324
+    }
325 325
 
326
-	/**
326
+    /**
327 327
      * Prepares the shipping details.
328 328
      *
329
-	 * @return array
330
-	 * @param WPInv_Invoice $invoice
329
+     * @return array
330
+     * @param WPInv_Invoice $invoice
331 331
      */
332 332
     protected function prepare_shipping_info( $invoice ) {
333 333
 
334
-		$data = $this->payment_form_submission->get_data();
334
+        $data = $this->payment_form_submission->get_data();
335 335
 
336
-		if ( empty( $data['same-shipping-address'] ) ) {
337
-			return $this->prepare_address_details( $invoice, 'shipping' );
338
-		}
336
+        if ( empty( $data['same-shipping-address'] ) ) {
337
+            return $this->prepare_address_details( $invoice, 'shipping' );
338
+        }
339 339
 
340
-		return $this->prepare_address_details( $invoice, 'billing' );
340
+        return $this->prepare_address_details( $invoice, 'billing' );
341 341
 
342
-	}
342
+    }
343 343
 
344
-	/**
345
-	 * Confirms the submission is valid and send users to the gateway.
346
-	 *
347
-	 * @param WPInv_Invoice $invoice
348
-	 * @param array $prepared_payment_form_data
349
-	 * @param array $shipping
350
-	 */
351
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
344
+    /**
345
+     * Confirms the submission is valid and send users to the gateway.
346
+     *
347
+     * @param WPInv_Invoice $invoice
348
+     * @param array $prepared_payment_form_data
349
+     * @param array $shipping
350
+     */
351
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
352 352
 
353
-		// Ensure the invoice exists.
353
+        // Ensure the invoice exists.
354 354
         if ( ! $invoice->exists() ) {
355 355
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
356 356
         }
357 357
 
358
-		// Save payment form data.
359
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
358
+        // Save payment form data.
359
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
360 360
         delete_post_meta( $invoice->get_id(), 'payment_form_data' );
361
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
362
-		if ( ! empty( $prepared_payment_form_data ) ) {
361
+        delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
362
+        if ( ! empty( $prepared_payment_form_data ) ) {
363 363
 
364
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
365
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
366
-			}
364
+            if ( ! empty( $prepared_payment_form_data['all'] ) ) {
365
+                update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
366
+            }
367 367
 
368
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
369
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
370
-			}
368
+            if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
369
+                update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
370
+            }
371 371
 
372
-		}
372
+        }
373 373
 
374
-		// Save payment form data.
374
+        // Save payment form data.
375 375
         if ( ! empty( $shipping ) ) {
376 376
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
377
-		}
377
+        }
378 378
 
379
-		// Backwards compatibility.
379
+        // Backwards compatibility.
380 380
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
381 381
 
382
-		$this->process_payment( $invoice );
382
+        $this->process_payment( $invoice );
383 383
 
384 384
         // If we are here, there was an error.
385
-		wpinv_send_back_to_checkout( $invoice );
385
+        wpinv_send_back_to_checkout( $invoice );
386 386
 
387
-	}
387
+    }
388 388
 
389
-	/**
390
-	 * Processes the actual payment.
391
-	 *
392
-	 * @param WPInv_Invoice $invoice
393
-	 */
394
-	protected function process_payment( $invoice ) {
389
+    /**
390
+     * Processes the actual payment.
391
+     *
392
+     * @param WPInv_Invoice $invoice
393
+     */
394
+    protected function process_payment( $invoice ) {
395 395
 
396
-		// Clear any checkout errors.
397
-		wpinv_clear_errors();
396
+        // Clear any checkout errors.
397
+        wpinv_clear_errors();
398 398
 
399
-		// No need to send free invoices to the gateway.
400
-		if ( $invoice->is_free() ) {
401
-			$this->process_free_payment( $invoice );
402
-		}
399
+        // No need to send free invoices to the gateway.
400
+        if ( $invoice->is_free() ) {
401
+            $this->process_free_payment( $invoice );
402
+        }
403 403
 
404
-		$submission = $this->payment_form_submission;
404
+        $submission = $this->payment_form_submission;
405 405
 
406
-		// Fires before sending to the gateway.
407
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
406
+        // Fires before sending to the gateway.
407
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
408 408
 
409
-		// Allow the sumission data to be modified before it is sent to the gateway.
410
-		$submission_data    = $submission->get_data();
411
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
412
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
409
+        // Allow the sumission data to be modified before it is sent to the gateway.
410
+        $submission_data    = $submission->get_data();
411
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
412
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
413 413
 
414
-		// Validate the currency.
415
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
416
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
417
-		}
414
+        // Validate the currency.
415
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
416
+            wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
417
+        }
418 418
 
419
-		// Check to see if we have any errors.
420
-		if ( wpinv_get_errors() ) {
421
-			wpinv_send_back_to_checkout( $invoice );
422
-		}
419
+        // Check to see if we have any errors.
420
+        if ( wpinv_get_errors() ) {
421
+            wpinv_send_back_to_checkout( $invoice );
422
+        }
423 423
 
424
-		// Send info to the gateway for payment processing
425
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
424
+        // Send info to the gateway for payment processing
425
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
426 426
 
427
-		// Backwards compatibility.
428
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
427
+        // Backwards compatibility.
428
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
429 429
 
430
-	}
430
+    }
431 431
 
432
-	/**
433
-	 * Marks the invoice as paid in case the checkout is free.
434
-	 *
435
-	 * @param WPInv_Invoice $invoice
436
-	 */
437
-	protected function process_free_payment( $invoice ) {
432
+    /**
433
+     * Marks the invoice as paid in case the checkout is free.
434
+     *
435
+     * @param WPInv_Invoice $invoice
436
+     */
437
+    protected function process_free_payment( $invoice ) {
438 438
 
439
-		$invoice->set_gateway( 'none' );
440
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
441
-		$invoice->mark_paid();
442
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
439
+        $invoice->set_gateway( 'none' );
440
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
441
+        $invoice->mark_paid();
442
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
443 443
 
444
-	}
444
+    }
445 445
 
446
-	/**
446
+    /**
447 447
      * Sends a redrect response to payment details.
448 448
      *
449 449
      */
Please login to merge, or discard this patch.